ss-component-new 1.1.259 → 1.1.261

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/{array-BAR5vwN7.js → array-BKq3BIQz.js} +2 -2
  2. package/dist/{array-8L1AOBQp.cjs → array-CGcjUVKX.cjs} +1 -1
  3. package/dist/{cloneDeep-vy5d0U00.cjs → cloneDeep-B7uQBoFQ.cjs} +1 -1
  4. package/dist/{cloneDeep-DZzy1Il4.js → cloneDeep-C2Kxf4cz.js} +1 -1
  5. package/dist/{index-C-9bL2-I.cjs → index-1FDUIkCX.cjs} +1 -1
  6. package/dist/{index-DKiauCvh.js → index-B-UH_ubV.js} +8 -8
  7. package/dist/{index-TCyNl2MK.js → index-B2U6bRXC.js} +1 -1
  8. package/dist/{index-DVDdSL2R.js → index-B5JYLkwE.js} +984 -941
  9. package/dist/{index-B4Ev6tVX.cjs → index-BDeQhlHq.cjs} +1 -1
  10. package/dist/{index-7ptGWZXL.cjs → index-BEMqiaE4.cjs} +1 -1
  11. package/dist/{index-C4heMZb-.js → index-BEUHy5vT.js} +5 -5
  12. package/dist/{index-CG19P4G2.cjs → index-BKkSFReI.cjs} +1 -1
  13. package/dist/{index-C8YTwQ2U.cjs → index-BNRMWt2X.cjs} +1 -1
  14. package/dist/{index-DHZhHL1L.js → index-BPDeDTcT.js} +8 -8
  15. package/dist/{index-rAGiNKLH.cjs → index-BPc4Eac7.cjs} +1 -1
  16. package/dist/{index-D5VxsSYo.cjs → index-BSHYuItV.cjs} +1 -1
  17. package/dist/index-BSvAtDik.js +32149 -0
  18. package/dist/{index-B0eP9Dy6.cjs → index-BTE2McnW.cjs} +1 -1
  19. package/dist/{index-CP5-LufC.js → index-BXTWkSfY.js} +3 -3
  20. package/dist/{index-CPKoBUqk.cjs → index-BePWixJ7.cjs} +1 -1
  21. package/dist/{index-DlDk8iSi.js → index-BpRK84YO.js} +9 -9
  22. package/dist/{index-Bi7W_wF3.cjs → index-BqjnsqxM.cjs} +1 -1
  23. package/dist/{index-B_CuXQ8H.js → index-BuzU8y87.js} +3 -3
  24. package/dist/index-BxNkT68g.js +271 -0
  25. package/dist/{index-ChOzMlwd.cjs → index-C4WiBNX7.cjs} +1 -1
  26. package/dist/{index-CvyNoFpY.cjs → index-C99sTbLR.cjs} +1 -1
  27. package/dist/{index-D2NWcpdI.cjs → index-CPLQkq0l.cjs} +1 -1
  28. package/dist/{index-DBROy8Np.js → index-CRA36cu_.js} +4 -4
  29. package/dist/{index-BPVoFxu1.js → index-CUS5J9_e.js} +3 -3
  30. package/dist/{index-DfzZvWqB.cjs → index-CU_Jx-5J.cjs} +1 -1
  31. package/dist/{index-Cn8hBlVR.js → index-CV8NL82B.js} +1 -1
  32. package/dist/index-CW3K0wJl.cjs +1 -0
  33. package/dist/index-CaEGsvtY.cjs +1 -0
  34. package/dist/{index-dEcwBSrA.cjs → index-CbAVZYKT.cjs} +1 -1
  35. package/dist/{index-CO8isUR8.js → index-CcWrPjiF.js} +1 -1
  36. package/dist/{index-CEU_-vVQ.cjs → index-CdbyfD9T.cjs} +1 -1
  37. package/dist/{index-DchO-l9M.cjs → index-ChDUVY4O.cjs} +1 -1
  38. package/dist/{index-3YXTNfHi.cjs → index-ChrvsNKe.cjs} +1 -1
  39. package/dist/{index-DZK00p0U.cjs → index-Clc0UQZs.cjs} +1 -1
  40. package/dist/index-CrY9cebv.cjs +1 -0
  41. package/dist/{index-VEeZQyiv.js → index-CtNApXqx.js} +1 -1
  42. package/dist/{index-C0KdYFnu.cjs → index-D5iqPx4_.cjs} +1 -1
  43. package/dist/{index-BZW3cHEf.js → index-DBUg3cD4.js} +5 -5
  44. package/dist/{index-C67E6B-n.cjs → index-DJXxlOVw.cjs} +1 -1
  45. package/dist/{index-CcbQH9dl.js → index-DJt9epxc.js} +3 -3
  46. package/dist/{index-BMz8jBkf.js → index-DMxFp_J8.js} +7 -7
  47. package/dist/{index-D2ZusKzk.js → index-DSHdwrIv.js} +4 -4
  48. package/dist/{index-Ci50GJSS.js → index-DiqIaffC.js} +6 -6
  49. package/dist/index-DqW6UiIO.cjs +3839 -0
  50. package/dist/{index-C2rXdvLP.js → index-Dqq6ANsR.js} +1 -1
  51. package/dist/{index-DSOsbQ8m.js → index-DrgtDDgh.js} +1 -1
  52. package/dist/index-Dz-F31F9.js +3475 -0
  53. package/dist/{index-MAuxykeu.js → index-JlAZlJSa.js} +6 -6
  54. package/dist/index-LztiiC8W.js +683 -0
  55. package/dist/{index-vS7rFC3d.js → index-P8qnw1yi.js} +5 -5
  56. package/dist/{index-D9qxwyPB.cjs → index-SuPnthkA.cjs} +1 -1
  57. package/dist/{index-CaZgwKKu.cjs → index-XGNOqMia.cjs} +1 -1
  58. package/dist/{index-_lrJ_Z3S.js → index-i7I_BwC_.js} +4 -4
  59. package/dist/{index-0Rbq0r0Y.js → index-k1B4X854.js} +4 -4
  60. package/dist/index-kzgPDfJF.cjs +9 -0
  61. package/dist/{index.vue_vue_type_script_setup_true_lang-t_FbjOts.cjs → index.vue_vue_type_script_setup_true_lang-CsELnqsB.cjs} +1 -1
  62. package/dist/{index.vue_vue_type_script_setup_true_lang-CvTBmGDC.js → index.vue_vue_type_script_setup_true_lang-GU5YecI_.js} +1 -1
  63. package/dist/{index.vue_vue_type_style_index_0_scoped_11a5120d_lang-BPrVtCUd.cjs → index.vue_vue_type_style_index_0_scoped_11a5120d_lang-CiQLJOHK.cjs} +1 -1
  64. package/dist/{index.vue_vue_type_style_index_0_scoped_11a5120d_lang-qsAIigHk.js → index.vue_vue_type_style_index_0_scoped_11a5120d_lang-HXVPBHSR.js} +6 -6
  65. package/dist/{index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-CdoqwUjR.js → index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-BP1ltJdK.js} +12 -12
  66. package/dist/{index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-BQgHk7jY.cjs → index.vue_vue_type_style_index_0_scoped_4b7a2e5d_lang-Dhxd_sQH.cjs} +1 -1
  67. package/dist/{login-B2FvC181.cjs → login-MRZ_aZ2l.cjs} +1 -1
  68. package/dist/{login-CN3w9WCz.js → login-f0ZOWhgZ.js} +2 -2
  69. package/dist/{main-BDgkyynt.js → main-CD7tAcIb.js} +7 -7
  70. package/dist/{main-DRa5LCF9.cjs → main-CpGTA5Qv.cjs} +1 -1
  71. package/dist/{menu-DjHQN1B-.cjs → menu-PjSpUL7w.cjs} +1 -1
  72. package/dist/{menu-B10MAns7.js → menu-uQv0bEzE.js} +1 -1
  73. package/dist/{modelComp-KS7VRV8A.js → modelComp-BavIqTd8.js} +1 -1
  74. package/dist/{modelComp-DqpOIkHs.cjs → modelComp-qapurFEA.cjs} +1 -1
  75. package/dist/ss-component.cjs +1 -1
  76. package/dist/ss-component.css +1 -1
  77. package/dist/ss-component.js +7 -7
  78. package/dist/ss-component3.cjs +1 -1
  79. package/dist/ss-component3.js +1 -1
  80. package/package.json +2 -1
  81. package/dist/index-B69DGyLH.js +0 -264
  82. package/dist/index-B8XOc8ur.js +0 -673
  83. package/dist/index-BG7PNsqD.js +0 -22139
  84. package/dist/index-C-lzYeWw.cjs +0 -3832
  85. package/dist/index-CS8aeX_B.cjs +0 -1
  86. package/dist/index-CkaXBiAY.cjs +0 -1
  87. package/dist/index-DjZKWUq4.cjs +0 -1
  88. package/dist/index-DzzEJh49.cjs +0 -9
  89. package/dist/index-_eZMZ6DS.js +0 -3459
@@ -1,3832 +0,0 @@
1
- "use strict";const $=require("vue"),Wi=require("./index-C0KdYFnu.cjs"),Jo=require("./modelComp-DqpOIkHs.cjs"),Mn=require("./index-CvyNoFpY.cjs"),Wt=require("./index-DzzEJh49.cjs"),Ma=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),Ae=require("./cloneDeep-vy5d0U00.cjs"),it=require("./menu-DjHQN1B-.cjs"),Ua=require("./index-CG19P4G2.cjs");var Yl="__lodash_hash_undefined__";function jl(i){return this.__data__.set(i,Yl),this}function Kl(i){return this.__data__.has(i)}function Fr(i){var e=-1,t=i==null?0:i.length;for(this.__data__=new Mn.MapCache;++e<t;)this.add(i[e])}Fr.prototype.add=Fr.prototype.push=jl;Fr.prototype.has=Kl;function Zl(i,e){for(var t=-1,n=i==null?0:i.length;++t<n;)if(e(i[t],t,i))return!0;return!1}function $l(i,e){return i.has(e)}var Jl=1,Ql=2;function Qo(i,e,t,n,r,s){var a=t&Jl,o=i.length,l=e.length;if(o!=l&&!(a&&l>o))return!1;var c=s.get(i),h=s.get(e);if(c&&h)return c==e&&h==i;var u=-1,d=!0,p=t&Ql?new Fr:void 0;for(s.set(i,e),s.set(e,i);++u<o;){var _=i[u],v=e[u];if(n)var m=a?n(v,_,u,e,i,s):n(_,v,u,i,e,s);if(m!==void 0){if(m)continue;d=!1;break}if(p){if(!Zl(e,function(f,b){if(!$l(p,b)&&(_===f||r(_,f,t,n,s)))return p.push(b)})){d=!1;break}}else if(!(_===v||r(_,v,t,n,s))){d=!1;break}}return s.delete(i),s.delete(e),d}function ec(i){var e=-1,t=Array(i.size);return i.forEach(function(n,r){t[++e]=[r,n]}),t}function tc(i){var e=-1,t=Array(i.size);return i.forEach(function(n){t[++e]=n}),t}var nc=1,ic=2,rc="[object Boolean]",sc="[object Date]",ac="[object Error]",oc="[object Map]",lc="[object Number]",cc="[object RegExp]",hc="[object Set]",uc="[object String]",fc="[object Symbol]",dc="[object ArrayBuffer]",pc="[object DataView]",Ia=Mn.Symbol?Mn.Symbol.prototype:void 0,Kr=Ia?Ia.valueOf:void 0;function mc(i,e,t,n,r,s,a){switch(t){case pc:if(i.byteLength!=e.byteLength||i.byteOffset!=e.byteOffset)return!1;i=i.buffer,e=e.buffer;case dc:return!(i.byteLength!=e.byteLength||!s(new Ae.Uint8Array(i),new Ae.Uint8Array(e)));case rc:case sc:case lc:return Mn.eq(+i,+e);case ac:return i.name==e.name&&i.message==e.message;case cc:case uc:return i==e+"";case oc:var o=ec;case hc:var l=n&nc;if(o||(o=tc),i.size!=e.size&&!l)return!1;var c=a.get(i);if(c)return c==e;n|=ic,a.set(i,e);var h=Qo(o(i),o(e),n,r,s,a);return a.delete(i),h;case fc:if(Kr)return Kr.call(i)==Kr.call(e)}return!1}var _c=1,gc=Object.prototype,vc=gc.hasOwnProperty;function xc(i,e,t,n,r,s){var a=t&_c,o=Ae.getAllKeys(i),l=o.length,c=Ae.getAllKeys(e),h=c.length;if(l!=h&&!a)return!1;for(var u=l;u--;){var d=o[u];if(!(a?d in e:vc.call(e,d)))return!1}var p=s.get(i),_=s.get(e);if(p&&_)return p==e&&_==i;var v=!0;s.set(i,e),s.set(e,i);for(var m=a;++u<l;){d=o[u];var f=i[d],b=e[d];if(n)var E=a?n(b,f,d,e,i,s):n(f,b,d,i,e,s);if(!(E===void 0?f===b||r(f,b,t,n,s):E)){v=!1;break}m||(m=d=="constructor")}if(v&&!m){var S=i.constructor,L=e.constructor;S!=L&&"constructor"in i&&"constructor"in e&&!(typeof S=="function"&&S instanceof S&&typeof L=="function"&&L instanceof L)&&(v=!1)}return s.delete(i),s.delete(e),v}var Mc=1,Na="[object Arguments]",Fa="[object Array]",er="[object Object]",Sc=Object.prototype,Oa=Sc.hasOwnProperty;function yc(i,e,t,n,r,s){var a=Mn.isArray(i),o=Mn.isArray(e),l=a?Fa:Ae.getTag(i),c=o?Fa:Ae.getTag(e);l=l==Na?er:l,c=c==Na?er:c;var h=l==er,u=c==er,d=l==c;if(d&&Ae.isBuffer(i)){if(!Ae.isBuffer(e))return!1;a=!0,h=!1}if(d&&!h)return s||(s=new Ae.Stack),a||Ae.isTypedArray(i)?Qo(i,e,t,n,r,s):mc(i,e,l,t,n,r,s);if(!(t&Mc)){var p=h&&Oa.call(i,"__wrapped__"),_=u&&Oa.call(e,"__wrapped__");if(p||_){var v=p?i.value():i,m=_?e.value():e;return s||(s=new Ae.Stack),r(v,m,t,n,s)}}return d?(s||(s=new Ae.Stack),xc(i,e,t,n,r,s)):!1}function el(i,e,t,n,r){return i===e?!0:i==null||e==null||!Mn.isObjectLike(i)&&!Mn.isObjectLike(e)?i!==i&&e!==e:yc(i,e,t,n,el,r)}function Ec(i,e){return el(i,e)}const Tc={__name:"index",props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:""},width:{type:Number,default:200}},setup(i){const e=i,t=$.ref(null),n=$.ref(!1),r=$.ref(null);return $.watch(()=>e==null?void 0:e.isVisible,()=>{n.value=e==null?void 0:e.isVisible},{deep:!0,immediate:!0}),$.watch(()=>r.value,()=>{$.nextTick(()=>{var s,a;(a=(s=t.value)==null?void 0:s.updatePopper)==null||a.call(s)})},{deep:!0,immediate:!0}),(s,a)=>{const o=$.resolveComponent("el-popover");return $.openBlock(),$.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:$.withCtx(()=>[$.createElementVNode("div",null,[$.renderSlot(s.$slots,"reference",{ref_key:"referenceRef",ref:r})])]),default:$.withCtx(()=>[$.createElementVNode("div",null,[$.renderSlot(s.$slots,"content")])]),_:3},8,["visible","title","width"])}}},bc={class:"extra-button-content"},Ac={key:0,class:"extra-header"},wc=["onClick"],Rc={class:"extra-button-filter"},Cc={class:"form-content-value"},Pc={__name:"header",props:{buttons:{type:Array,default:()=>[]},columns:{type:Array,default:()=>[]}},emits:["buttonClick","filter"],setup(i,{emit:e}){const t=e,n=i,r=$.ref(!1),s=$.ref([]),a=$.ref([{label:"取消"},{label:"确认"}]),o=h=>{t("buttonClick",h)},l=h=>{var u,d;s.value=(d=(u=Wt.getColumnChild(Ae.cloneDeep(h)))==null?void 0:u.filter(p=>(p==null?void 0:p.label)!==""&&(p==null?void 0:p.label)!=="操作"))==null?void 0:d.map(p=>({label:(p==null?void 0:p.label)??"",value:"",name:(p==null?void 0:p.label)??"",isFormColHidden:p==null?void 0:p.isTableColHidden}))},c=h=>{(h==null?void 0:h.buttonName)==="确认"&&t("filter",h==null?void 0:h.content),r.value=!1};return $.onMounted(()=>{l(n.columns)}),$.watch(()=>n.columns,()=>{l(n.columns)},{deep:!0,immediate:!0}),(h,u)=>{var p;const d=$.resolveComponent("el-tooltip");return $.openBlock(),$.createElementBlock("div",bc,[n!=null&&n.buttons&&((p=n==null?void 0:n.buttons)==null?void 0:p.length)>0?($.openBlock(),$.createElementBlock("div",Ac,[($.openBlock(!0),$.createElementBlock($.Fragment,null,$.renderList(n==null?void 0:n.buttons,(_,v)=>($.openBlock(),$.createElementBlock("div",{class:"extra-contents",key:v},[$.createElementVNode("div",{class:"extra-content",style:$.normalizeStyle({background:(_==null?void 0:_.background)??"var(--ssComponent-primary-color)",color:"var(--system-bg)"}),onClick:m=>o(_==null?void 0:_.label)},$.toDisplayString(_==null?void 0:_.label),13,wc)]))),128))])):$.createCommentVNode("",!0),$.createElementVNode("div",Rc,[$.createVNode(Tc,{title:"筛选数据",width:500,isVisible:r.value},{reference:$.withCtx(()=>[$.createVNode(d,{content:"筛选",placement:"top-start"},{default:$.withCtx(()=>[$.createElementVNode("div",{class:"button-style",onClick:u[0]||(u[0]=_=>r.value=!r.value)},[$.createVNode($.unref(Mn.filter_default),{color:"var(--ssComponent-black)"})])]),_:1})]),content:$.withCtx(()=>[$.createElementVNode("div",Cc,[($.openBlock(),$.createBlock(Wt.ssForm,{rowContents:s.value,buttonValue:a.value,isRowFlex:!0,isEnableWrap:!1,isButtonRow:!1,key:a.value,isStartJustify:!1,onOnButtonClick:c},null,8,["rowContents","buttonValue"]))])]),_:1},8,["isVisible"])])])}}},Dc=Ma._export_sfc(Pc,[["__scopeId","data-v-e7197dc5"]]);/**
2
- * @license
3
- * Copyright 2010-2025 Three.js Authors
4
- * SPDX-License-Identifier: MIT
5
- */const Sa="177",_i={ROTATE:0,DOLLY:1,PAN:2},pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Lc=0,Ba=1,Uc=2,tl=1,Ic=2,pn=3,Sn=0,It=1,_n=2,Dn=0,gi=1,za=2,ka=3,Ha=4,Nc=5,Xn=100,Fc=101,Oc=102,Bc=103,zc=104,kc=200,Hc=201,Vc=202,Gc=203,Ds=204,Ls=205,Wc=206,Xc=207,qc=208,Yc=209,jc=210,Kc=211,Zc=212,$c=213,Jc=214,Us=0,Is=1,Ns=2,Mi=3,Fs=4,Os=5,Bs=6,zs=7,ya=0,Qc=1,eh=2,Ln=0,th=1,nh=2,ih=3,rh=4,sh=5,ah=6,oh=7,nl=300,Si=301,yi=302,ks=303,Hs=304,Wr=306,Or=1e3,Yn=1001,Vs=1002,Qt=1003,lh=1004,tr=1005,rn=1006,Zr=1007,jn=1008,an=1009,il=1010,rl=1011,Xi=1012,Ea=1013,Kn=1014,gn=1015,Zi=1016,Ta=1017,ba=1018,qi=1020,sl=35902,al=1021,ol=1022,$t=1023,Yi=1026,ji=1027,ll=1028,Aa=1029,cl=1030,wa=1031,Ra=1033,Rr=33776,Cr=33777,Pr=33778,Dr=33779,Gs=35840,Ws=35841,Xs=35842,qs=35843,Ys=36196,js=37492,Ks=37496,Zs=37808,$s=37809,Js=37810,Qs=37811,ea=37812,ta=37813,na=37814,ia=37815,ra=37816,sa=37817,aa=37818,oa=37819,la=37820,ca=37821,Lr=36492,ha=36494,ua=36495,hl=36283,fa=36284,da=36285,pa=36286,ch=3200,hh=3201,ul=0,uh=1,Pn="",Et="srgb",Ei="srgb-linear",Br="linear",st="srgb",ei=7680,Va=519,fh=512,dh=513,ph=514,fl=515,mh=516,_h=517,gh=518,vh=519,Ga=35044,Wa="300 es",vn=2e3,zr=2001;class Jn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const Tt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Ur=Math.PI/180,ma=180/Math.PI;function $i(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Tt[i&255]+Tt[i>>8&255]+Tt[i>>16&255]+Tt[i>>24&255]+"-"+Tt[e&255]+Tt[e>>8&255]+"-"+Tt[e>>16&15|64]+Tt[e>>24&255]+"-"+Tt[t&63|128]+Tt[t>>8&255]+"-"+Tt[t>>16&255]+Tt[t>>24&255]+Tt[n&255]+Tt[n>>8&255]+Tt[n>>16&255]+Tt[n>>24&255]).toLowerCase()}function $e(i,e,t){return Math.max(e,Math.min(t,i))}function xh(i,e){return(i%e+e)%e}function $r(i,e,t){return(1-t)*i+t*e}function Ni(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Lt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Mh={DEG2RAD:Ur};class Xe{constructor(e=0,t=0){Xe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos($e(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Zn{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],u=n[r+3];const d=s[a+0],p=s[a+1],_=s[a+2],v=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=p,e[t+2]=_,e[t+3]=v;return}if(u!==v||l!==d||c!==p||h!==_){let m=1-o;const f=l*d+c*p+h*_+u*v,b=f>=0?1:-1,E=1-f*f;if(E>Number.EPSILON){const L=Math.sqrt(E),w=Math.atan2(L,f*b);m=Math.sin(m*w)/L,o=Math.sin(o*w)/L}const S=o*b;if(l=l*m+d*S,c=c*m+p*S,h=h*m+_*S,u=u*m+v*S,m===1-o){const L=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=L,c*=L,h*=L,u*=L}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],u=s[a],d=s[a+1],p=s[a+2],_=s[a+3];return e[t]=o*_+h*u+l*p-c*d,e[t+1]=l*_+h*d+c*u-o*p,e[t+2]=c*_+h*p+o*d-l*u,e[t+3]=h*_-o*u-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),u=o(s/2),d=l(n/2),p=l(r/2),_=l(s/2);switch(a){case"XYZ":this._x=d*h*u+c*p*_,this._y=c*p*u-d*h*_,this._z=c*h*_+d*p*u,this._w=c*h*u-d*p*_;break;case"YXZ":this._x=d*h*u+c*p*_,this._y=c*p*u-d*h*_,this._z=c*h*_-d*p*u,this._w=c*h*u+d*p*_;break;case"ZXY":this._x=d*h*u-c*p*_,this._y=c*p*u+d*h*_,this._z=c*h*_+d*p*u,this._w=c*h*u-d*p*_;break;case"ZYX":this._x=d*h*u-c*p*_,this._y=c*p*u+d*h*_,this._z=c*h*_-d*p*u,this._w=c*h*u+d*p*_;break;case"YZX":this._x=d*h*u+c*p*_,this._y=c*p*u+d*h*_,this._z=c*h*_-d*p*u,this._w=c*h*u-d*p*_;break;case"XZY":this._x=d*h*u-c*p*_,this._y=c*p*u-d*h*_,this._z=c*h*_+d*p*u,this._w=c*h*u+d*p*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(n>o&&n>u){const p=2*Math.sqrt(1+n-o-u);this._w=(h-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>u){const p=2*Math.sqrt(1+o-n-u);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+u-n-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs($e(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-t;return this._w=p*a+t*this._w,this._x=p*n+t*this._x,this._y=p*r+t*this._y,this._z=p*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-t)*h)/c,d=Math.sin(t*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class N{constructor(e=0,t=0,n=0){N.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Xa.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Xa.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*n),h=2*(o*t-s*r),u=2*(s*n-a*t);return this.x=t+l*c+a*u-o*h,this.y=n+l*h+o*c-s*u,this.z=r+l*u+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Jr.copy(this).projectOnVector(e),this.sub(Jr)}reflect(e){return this.sub(Jr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos($e(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Jr=new N,Xa=new Zn;class qe{constructor(e,t,n,r,s,a,o,l,c){qe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],p=n[5],_=n[8],v=r[0],m=r[3],f=r[6],b=r[1],E=r[4],S=r[7],L=r[2],w=r[5],C=r[8];return s[0]=a*v+o*b+l*L,s[3]=a*m+o*E+l*w,s[6]=a*f+o*S+l*C,s[1]=c*v+h*b+u*L,s[4]=c*m+h*E+u*w,s[7]=c*f+h*S+u*C,s[2]=d*v+p*b+_*L,s[5]=d*m+p*E+_*w,s[8]=d*f+p*S+_*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*s,p=c*s-a*l,_=t*u+n*d+r*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/_;return e[0]=u*v,e[1]=(r*c-h*n)*v,e[2]=(o*n-r*a)*v,e[3]=d*v,e[4]=(h*t-r*l)*v,e[5]=(r*s-o*t)*v,e[6]=p*v,e[7]=(n*l-c*t)*v,e[8]=(a*t-n*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Qr.makeScale(e,t)),this}rotate(e){return this.premultiply(Qr.makeRotation(-e)),this}translate(e,t){return this.premultiply(Qr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Qr=new qe;function dl(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Ki(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Sh(){const i=Ki("canvas");return i.style.display="block",i}const qa={};function vi(i){i in qa||(qa[i]=!0,console.warn(i))}function yh(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function Eh(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Th(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const Ya=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ja=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function bh(){const i={enabled:!0,workingColorSpace:Ei,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===st&&(r.r=xn(r.r),r.g=xn(r.g),r.b=xn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===st&&(r.r=xi(r.r),r.g=xi(r.g),r.b=xi(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Pn?Br:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return vi("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return vi("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Ei]:{primaries:e,whitePoint:n,transfer:Br,toXYZ:Ya,fromXYZ:ja,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Et},outputColorSpaceConfig:{drawingBufferColorSpace:Et}},[Et]:{primaries:e,whitePoint:n,transfer:st,toXYZ:Ya,fromXYZ:ja,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Et}}}),i}const Qe=bh();function xn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function xi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ti;class Ah{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ti===void 0&&(ti=Ki("canvas")),ti.width=e.width,ti.height=e.height;const r=ti.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=ti}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ki("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=xn(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(xn(t[n]/255)*255):t[n]=xn(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let wh=0;class Ca{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:wh++}),this.uuid=$i(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(es(r[a].image)):s.push(es(r[a]))}else s=es(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function es(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Ah.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Rh=0;const ts=new N;class Pt extends Jn{constructor(e=Pt.DEFAULT_IMAGE,t=Pt.DEFAULT_MAPPING,n=Yn,r=Yn,s=rn,a=jn,o=$t,l=an,c=Pt.DEFAULT_ANISOTROPY,h=Pn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Rh++}),this.uuid=$i(),this.name="",this.source=new Ca(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Xe(0,0),this.repeat=new Xe(1,1),this.center=new Xe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(ts).x}get height(){return this.source.getSize(ts).y}get depth(){return this.source.getSize(ts).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==nl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Or:e.x=e.x-Math.floor(e.x);break;case Yn:e.x=e.x<0?0:1;break;case Vs:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Or:e.y=e.y-Math.floor(e.y);break;case Yn:e.y=e.y<0?0:1;break;case Vs:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Pt.DEFAULT_IMAGE=null;Pt.DEFAULT_MAPPING=nl;Pt.DEFAULT_ANISOTROPY=1;class pt{constructor(e=0,t=0,n=0,r=1){pt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],p=l[5],_=l[9],v=l[2],m=l[6],f=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(_+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,S=(p+1)/2,L=(f+1)/2,w=(h+d)/4,C=(u+v)/4,P=(_+m)/4;return E>S&&E>L?E<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(E),r=w/n,s=C/n):S>L?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=w/r,s=P/r):L<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(L),n=C/s,r=P/s),this.set(n,r,s,t),this}let b=Math.sqrt((m-_)*(m-_)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(m-_)/b,this.y=(u-v)/b,this.z=(d-h)/b,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this.w=$e(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this.w=$e(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ch extends Jn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new Pt(r);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:rn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new Ca(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $n extends Ch{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class pl extends Pt{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Qt,this.minFilter=Qt,this.wrapR=Yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ph extends Pt{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Qt,this.minFilter=Qt,this.wrapR=Yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ai{constructor(e=new N(1/0,1/0,1/0),t=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Yt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Yt.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Yt.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Yt):Yt.fromBufferAttribute(s,a),Yt.applyMatrix4(e.matrixWorld),this.expandByPoint(Yt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),nr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),nr.copy(n.boundingBox)),nr.applyMatrix4(e.matrixWorld),this.union(nr)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Yt),Yt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Fi),ir.subVectors(this.max,Fi),ni.subVectors(e.a,Fi),ii.subVectors(e.b,Fi),ri.subVectors(e.c,Fi),En.subVectors(ii,ni),Tn.subVectors(ri,ii),Bn.subVectors(ni,ri);let t=[0,-En.z,En.y,0,-Tn.z,Tn.y,0,-Bn.z,Bn.y,En.z,0,-En.x,Tn.z,0,-Tn.x,Bn.z,0,-Bn.x,-En.y,En.x,0,-Tn.y,Tn.x,0,-Bn.y,Bn.x,0];return!ns(t,ni,ii,ri,ir)||(t=[1,0,0,0,1,0,0,0,1],!ns(t,ni,ii,ri,ir))?!1:(rr.crossVectors(En,Tn),t=[rr.x,rr.y,rr.z],ns(t,ni,ii,ri,ir))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Yt).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ln[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ln[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ln[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ln[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ln[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ln[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ln[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ln[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ln),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const ln=[new N,new N,new N,new N,new N,new N,new N,new N],Yt=new N,nr=new Ai,ni=new N,ii=new N,ri=new N,En=new N,Tn=new N,Bn=new N,Fi=new N,ir=new N,rr=new N,zn=new N;function ns(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){zn.fromArray(i,s);const o=r.x*Math.abs(zn.x)+r.y*Math.abs(zn.y)+r.z*Math.abs(zn.z),l=e.dot(zn),c=t.dot(zn),h=n.dot(zn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Dh=new Ai,Oi=new N,is=new N;class Ji{constructor(e=new N,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Dh.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Oi.subVectors(e,this.center);const t=Oi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Oi,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(is.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Oi.copy(e.center).add(is)),this.expandByPoint(Oi.copy(e.center).sub(is))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const cn=new N,rs=new N,sr=new N,bn=new N,ss=new N,ar=new N,as=new N;class Xr{constructor(e=new N,t=new N(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,cn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=cn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(cn.copy(this.origin).addScaledVector(this.direction,t),cn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){rs.copy(e).add(t).multiplyScalar(.5),sr.copy(t).sub(e).normalize(),bn.copy(this.origin).sub(rs);const s=e.distanceTo(t)*.5,a=-this.direction.dot(sr),o=bn.dot(this.direction),l=-bn.dot(sr),c=bn.lengthSq(),h=Math.abs(1-a*a);let u,d,p,_;if(h>0)if(u=a*l-o,d=a*o-l,_=s*h,u>=0)if(d>=-_)if(d<=_){const v=1/h;u*=v,d*=v,p=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d<=-_?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-l),s),p=-u*u+d*(d+2*l)+c):d<=_?(u=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-l),s),p=-u*u+d*(d+2*l)+c);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(rs).addScaledVector(sr,d),p}intersectSphere(e,t){cn.subVectors(e.center,this.origin);const n=cn.dot(this.direction),r=cn.dot(cn)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,cn)!==null}intersectTriangle(e,t,n,r,s){ss.subVectors(t,e),ar.subVectors(n,e),as.crossVectors(ss,ar);let a=this.direction.dot(as),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;bn.subVectors(this.origin,e);const l=o*this.direction.dot(ar.crossVectors(bn,ar));if(l<0)return null;const c=o*this.direction.dot(ss.cross(bn));if(c<0||l+c>a)return null;const h=-o*bn.dot(as);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ht{constructor(e,t,n,r,s,a,o,l,c,h,u,d,p,_,v,m){ht.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c,h,u,d,p,_,v,m)}set(e,t,n,r,s,a,o,l,c,h,u,d,p,_,v,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=r,f[1]=s,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=u,f[14]=d,f[3]=p,f[7]=_,f[11]=v,f[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ht().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/si.setFromMatrixColumn(e,0).length(),s=1/si.setFromMatrixColumn(e,1).length(),a=1/si.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const d=a*h,p=a*u,_=o*h,v=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=p+_*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=_+p*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,p=l*u,_=c*h,v=c*u;t[0]=d+v*o,t[4]=_*o-p,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=p*o-_,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,p=l*u,_=c*h,v=c*u;t[0]=d-v*o,t[4]=-a*u,t[8]=_+p*o,t[1]=p+_*o,t[5]=a*h,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,p=a*u,_=o*h,v=o*u;t[0]=l*h,t[4]=_*c-p,t[8]=d*c+v,t[1]=l*u,t[5]=v*c+d,t[9]=p*c-_,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,p=a*c,_=o*l,v=o*c;t[0]=l*h,t[4]=v-d*u,t[8]=_*u+p,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=p*u+_,t[10]=d-v*u}else if(e.order==="XZY"){const d=a*l,p=a*c,_=o*l,v=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+v,t[5]=a*h,t[9]=p*u-_,t[2]=_*u-p,t[6]=o*h,t[10]=v*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Lh,e,Uh)}lookAt(e,t,n){const r=this.elements;return Ot.subVectors(e,t),Ot.lengthSq()===0&&(Ot.z=1),Ot.normalize(),An.crossVectors(n,Ot),An.lengthSq()===0&&(Math.abs(n.z)===1?Ot.x+=1e-4:Ot.z+=1e-4,Ot.normalize(),An.crossVectors(n,Ot)),An.normalize(),or.crossVectors(Ot,An),r[0]=An.x,r[4]=or.x,r[8]=Ot.x,r[1]=An.y,r[5]=or.y,r[9]=Ot.y,r[2]=An.z,r[6]=or.z,r[10]=Ot.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],p=n[13],_=n[2],v=n[6],m=n[10],f=n[14],b=n[3],E=n[7],S=n[11],L=n[15],w=r[0],C=r[4],P=r[8],y=r[12],x=r[1],R=r[5],H=r[9],B=r[13],j=r[2],J=r[6],W=r[10],ne=r[14],G=r[3],fe=r[7],xe=r[11],se=r[15];return s[0]=a*w+o*x+l*j+c*G,s[4]=a*C+o*R+l*J+c*fe,s[8]=a*P+o*H+l*W+c*xe,s[12]=a*y+o*B+l*ne+c*se,s[1]=h*w+u*x+d*j+p*G,s[5]=h*C+u*R+d*J+p*fe,s[9]=h*P+u*H+d*W+p*xe,s[13]=h*y+u*B+d*ne+p*se,s[2]=_*w+v*x+m*j+f*G,s[6]=_*C+v*R+m*J+f*fe,s[10]=_*P+v*H+m*W+f*xe,s[14]=_*y+v*B+m*ne+f*se,s[3]=b*w+E*x+S*j+L*G,s[7]=b*C+E*R+S*J+L*fe,s[11]=b*P+E*H+S*W+L*xe,s[15]=b*y+E*B+S*ne+L*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],p=e[14],_=e[3],v=e[7],m=e[11],f=e[15];return _*(+s*l*u-r*c*u-s*o*d+n*c*d+r*o*p-n*l*p)+v*(+t*l*p-t*c*d+s*a*d-r*a*p+r*c*h-s*l*h)+m*(+t*c*u-t*o*p-s*a*u+n*a*p+s*o*h-n*c*h)+f*(-r*o*h-t*l*u+t*o*d+r*a*u-n*a*d+n*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],_=e[12],v=e[13],m=e[14],f=e[15],b=u*m*c-v*d*c+v*l*p-o*m*p-u*l*f+o*d*f,E=_*d*c-h*m*c-_*l*p+a*m*p+h*l*f-a*d*f,S=h*v*c-_*u*c+_*o*p-a*v*p-h*o*f+a*u*f,L=_*u*l-h*v*l-_*o*d+a*v*d+h*o*m-a*u*m,w=t*b+n*E+r*S+s*L;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/w;return e[0]=b*C,e[1]=(v*d*s-u*m*s-v*r*p+n*m*p+u*r*f-n*d*f)*C,e[2]=(o*m*s-v*l*s+v*r*c-n*m*c-o*r*f+n*l*f)*C,e[3]=(u*l*s-o*d*s-u*r*c+n*d*c+o*r*p-n*l*p)*C,e[4]=E*C,e[5]=(h*m*s-_*d*s+_*r*p-t*m*p-h*r*f+t*d*f)*C,e[6]=(_*l*s-a*m*s-_*r*c+t*m*c+a*r*f-t*l*f)*C,e[7]=(a*d*s-h*l*s+h*r*c-t*d*c-a*r*p+t*l*p)*C,e[8]=S*C,e[9]=(_*u*s-h*v*s-_*n*p+t*v*p+h*n*f-t*u*f)*C,e[10]=(a*v*s-_*o*s+_*n*c-t*v*c-a*n*f+t*o*f)*C,e[11]=(h*o*s-a*u*s-h*n*c+t*u*c+a*n*p-t*o*p)*C,e[12]=L*C,e[13]=(h*v*r-_*u*r+_*n*d-t*v*d-h*n*m+t*u*m)*C,e[14]=(_*o*r-a*v*r-_*n*l+t*v*l+a*n*m-t*o*m)*C,e[15]=(a*u*r-h*o*r+h*n*l-t*u*l-a*n*d+t*o*d)*C,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,u=o+o,d=s*c,p=s*h,_=s*u,v=a*h,m=a*u,f=o*u,b=l*c,E=l*h,S=l*u,L=n.x,w=n.y,C=n.z;return r[0]=(1-(v+f))*L,r[1]=(p+S)*L,r[2]=(_-E)*L,r[3]=0,r[4]=(p-S)*w,r[5]=(1-(d+f))*w,r[6]=(m+b)*w,r[7]=0,r[8]=(_+E)*C,r[9]=(m-b)*C,r[10]=(1-(d+v))*C,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=si.set(r[0],r[1],r[2]).length();const a=si.set(r[4],r[5],r[6]).length(),o=si.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],jt.copy(this);const c=1/s,h=1/a,u=1/o;return jt.elements[0]*=c,jt.elements[1]*=c,jt.elements[2]*=c,jt.elements[4]*=h,jt.elements[5]*=h,jt.elements[6]*=h,jt.elements[8]*=u,jt.elements[9]*=u,jt.elements[10]*=u,t.setFromRotationMatrix(jt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=vn){const l=this.elements,c=2*s/(t-e),h=2*s/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r);let p,_;if(o===vn)p=-(a+s)/(a-s),_=-2*a*s/(a-s);else if(o===zr)p=-a/(a-s),_=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=vn){const l=this.elements,c=1/(t-e),h=1/(n-r),u=1/(a-s),d=(t+e)*c,p=(n+r)*h;let _,v;if(o===vn)_=(a+s)*u,v=-2*u;else if(o===zr)_=s*u,v=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=v,l[14]=-_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const si=new N,jt=new ht,Lh=new N(0,0,0),Uh=new N(1,1,1),An=new N,or=new N,Ot=new N,Ka=new ht,Za=new Zn;class on{constructor(e=0,t=0,n=0,r=on.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],u=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin($e(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-$e(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin($e(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-$e(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin($e(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-$e(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ka.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ka,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Za.setFromEuler(this),this.setFromQuaternion(Za,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}on.DEFAULT_ORDER="XYZ";class ml{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Ih=0;const $a=new N,ai=new Zn,hn=new ht,lr=new N,Bi=new N,Nh=new N,Fh=new Zn,Ja=new N(1,0,0),Qa=new N(0,1,0),eo=new N(0,0,1),to={type:"added"},Oh={type:"removed"},oi={type:"childadded",child:null},os={type:"childremoved",child:null};class St extends Jn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ih++}),this.uuid=$i(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=St.DEFAULT_UP.clone();const e=new N,t=new on,n=new Zn,r=new N(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ht},normalMatrix:{value:new qe}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=St.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=St.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ml,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ai.setFromAxisAngle(e,t),this.quaternion.multiply(ai),this}rotateOnWorldAxis(e,t){return ai.setFromAxisAngle(e,t),this.quaternion.premultiply(ai),this}rotateX(e){return this.rotateOnAxis(Ja,e)}rotateY(e){return this.rotateOnAxis(Qa,e)}rotateZ(e){return this.rotateOnAxis(eo,e)}translateOnAxis(e,t){return $a.copy(e).applyQuaternion(this.quaternion),this.position.add($a.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ja,e)}translateY(e){return this.translateOnAxis(Qa,e)}translateZ(e){return this.translateOnAxis(eo,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(hn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?lr.copy(e):lr.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Bi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?hn.lookAt(Bi,lr,this.up):hn.lookAt(lr,Bi,this.up),this.quaternion.setFromRotationMatrix(hn),r&&(hn.extractRotation(r.matrixWorld),ai.setFromRotationMatrix(hn),this.quaternion.premultiply(ai.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(to),oi.child=e,this.dispatchEvent(oi),oi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Oh),os.child=e,this.dispatchEvent(os),os.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),hn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),hn.multiply(e.parent.matrixWorld)),e.applyMatrix4(hn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(to),oi.child=e,this.dispatchEvent(oi),oi.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Bi,e,Nh),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Bi,Fh,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),p=a(e.animations),_=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),_.length>0&&(n.nodes=_)}return n.object=r,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}St.DEFAULT_UP=new N(0,1,0);St.DEFAULT_MATRIX_AUTO_UPDATE=!0;St.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Kt=new N,un=new N,ls=new N,fn=new N,li=new N,ci=new N,no=new N,cs=new N,hs=new N,us=new N,fs=new pt,ds=new pt,ps=new pt;class Zt{constructor(e=new N,t=new N,n=new N){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Kt.subVectors(e,t),r.cross(Kt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Kt.subVectors(r,t),un.subVectors(n,t),ls.subVectors(e,t);const a=Kt.dot(Kt),o=Kt.dot(un),l=Kt.dot(ls),c=un.dot(un),h=un.dot(ls),u=a*c-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,p=(c*l-o*h)*d,_=(a*h-o*l)*d;return s.set(1-p-_,_,p)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,fn)===null?!1:fn.x>=0&&fn.y>=0&&fn.x+fn.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,fn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,fn.x),l.addScaledVector(a,fn.y),l.addScaledVector(o,fn.z),l)}static getInterpolatedAttribute(e,t,n,r,s,a){return fs.setScalar(0),ds.setScalar(0),ps.setScalar(0),fs.fromBufferAttribute(e,t),ds.fromBufferAttribute(e,n),ps.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(fs,s.x),a.addScaledVector(ds,s.y),a.addScaledVector(ps,s.z),a}static isFrontFacing(e,t,n,r){return Kt.subVectors(n,t),un.subVectors(e,t),Kt.cross(un).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Kt.subVectors(this.c,this.b),un.subVectors(this.a,this.b),Kt.cross(un).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Zt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Zt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;li.subVectors(r,n),ci.subVectors(s,n),cs.subVectors(e,n);const l=li.dot(cs),c=ci.dot(cs);if(l<=0&&c<=0)return t.copy(n);hs.subVectors(e,r);const h=li.dot(hs),u=ci.dot(hs);if(h>=0&&u<=h)return t.copy(r);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(li,a);us.subVectors(e,s);const p=li.dot(us),_=ci.dot(us);if(_>=0&&p<=_)return t.copy(s);const v=p*c-l*_;if(v<=0&&c>=0&&_<=0)return o=c/(c-_),t.copy(n).addScaledVector(ci,o);const m=h*_-p*u;if(m<=0&&u-h>=0&&p-_>=0)return no.subVectors(s,r),o=(u-h)/(u-h+(p-_)),t.copy(r).addScaledVector(no,o);const f=1/(m+v+d);return a=v*f,o=d*f,t.copy(n).addScaledVector(li,a).addScaledVector(ci,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const _l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},wn={h:0,s:0,l:0},cr={h:0,s:0,l:0};function ms(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Ke{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Et){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Qe.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Qe.workingColorSpace){if(e=xh(e,1),t=$e(t,0,1),n=$e(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=ms(a,s,e+1/3),this.g=ms(a,s,e),this.b=ms(a,s,e-1/3)}return Qe.colorSpaceToWorking(this,r),this}setStyle(e,t=Et){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Et){const n=_l[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=xn(e.r),this.g=xn(e.g),this.b=xn(e.b),this}copyLinearToSRGB(e){return this.r=xi(e.r),this.g=xi(e.g),this.b=xi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Et){return Qe.workingToColorSpace(bt.copy(this),e),Math.round($e(bt.r*255,0,255))*65536+Math.round($e(bt.g*255,0,255))*256+Math.round($e(bt.b*255,0,255))}getHexString(e=Et){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qe.workingColorSpace){Qe.workingToColorSpace(bt.copy(this),t);const n=bt.r,r=bt.g,s=bt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(r-s)/u+(r<s?6:0);break;case r:l=(s-n)/u+2;break;case s:l=(n-r)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Qe.workingColorSpace){return Qe.workingToColorSpace(bt.copy(this),t),e.r=bt.r,e.g=bt.g,e.b=bt.b,e}getStyle(e=Et){Qe.workingToColorSpace(bt.copy(this),e);const t=bt.r,n=bt.g,r=bt.b;return e!==Et?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(wn),this.setHSL(wn.h+e,wn.s+t,wn.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(wn),e.getHSL(cr);const n=$r(wn.h,cr.h,t),r=$r(wn.s,cr.s,t),s=$r(wn.l,cr.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const bt=new Ke;Ke.NAMES=_l;let Bh=0;class yn extends Jn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Bh++}),this.uuid=$i(),this.name="",this.type="Material",this.blending=gi,this.side=Sn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ds,this.blendDst=Ls,this.blendEquation=Xn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ke(0,0,0),this.blendAlpha=0,this.depthFunc=Mi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Va,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ei,this.stencilZFail=ei,this.stencilZPass=ei,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==gi&&(n.blending=this.blending),this.side!==Sn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Ds&&(n.blendSrc=this.blendSrc),this.blendDst!==Ls&&(n.blendDst=this.blendDst),this.blendEquation!==Xn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Mi&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Va&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ei&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ei&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ei&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class gl extends yn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ke(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new on,this.combine=ya,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const mt=new N,hr=new Xe;let zh=0;class sn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:zh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ga,this.updateRanges=[],this.gpuType=gn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)hr.fromBufferAttribute(this,t),hr.applyMatrix3(e),this.setXY(t,hr.x,hr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)mt.fromBufferAttribute(this,t),mt.applyMatrix3(e),this.setXYZ(t,mt.x,mt.y,mt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)mt.fromBufferAttribute(this,t),mt.applyMatrix4(e),this.setXYZ(t,mt.x,mt.y,mt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mt.fromBufferAttribute(this,t),mt.applyNormalMatrix(e),this.setXYZ(t,mt.x,mt.y,mt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mt.fromBufferAttribute(this,t),mt.transformDirection(e),this.setXYZ(t,mt.x,mt.y,mt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Lt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ni(t,this.array)),t}setX(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ni(t,this.array)),t}setY(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ni(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ni(t,this.array)),t}setW(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array),r=Lt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array),r=Lt(r,this.array),s=Lt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ga&&(e.usage=this.usage),e}}class vl extends sn{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class xl extends sn{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Ct extends sn{constructor(e,t,n){super(new Float32Array(e),t,n)}}let kh=0;const Vt=new ht,_s=new St,hi=new N,Bt=new Ai,zi=new Ai,Mt=new N;class en extends Jn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kh++}),this.uuid=$i(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(dl(e)?xl:vl)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new qe().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Vt.makeRotationFromQuaternion(e),this.applyMatrix4(Vt),this}rotateX(e){return Vt.makeRotationX(e),this.applyMatrix4(Vt),this}rotateY(e){return Vt.makeRotationY(e),this.applyMatrix4(Vt),this}rotateZ(e){return Vt.makeRotationZ(e),this.applyMatrix4(Vt),this}translate(e,t,n){return Vt.makeTranslation(e,t,n),this.applyMatrix4(Vt),this}scale(e,t,n){return Vt.makeScale(e,t,n),this.applyMatrix4(Vt),this}lookAt(e){return _s.lookAt(e),_s.updateMatrix(),this.applyMatrix4(_s.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hi).negate(),this.translate(hi.x,hi.y,hi.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ct(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ai);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Bt.setFromBufferAttribute(s),this.morphTargetsRelative?(Mt.addVectors(this.boundingBox.min,Bt.min),this.boundingBox.expandByPoint(Mt),Mt.addVectors(this.boundingBox.max,Bt.max),this.boundingBox.expandByPoint(Mt)):(this.boundingBox.expandByPoint(Bt.min),this.boundingBox.expandByPoint(Bt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ji);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){const n=this.boundingSphere.center;if(Bt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];zi.setFromBufferAttribute(o),this.morphTargetsRelative?(Mt.addVectors(Bt.min,zi.min),Bt.expandByPoint(Mt),Mt.addVectors(Bt.max,zi.max),Bt.expandByPoint(Mt)):(Bt.expandByPoint(zi.min),Bt.expandByPoint(zi.max))}Bt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)Mt.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(Mt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Mt.fromBufferAttribute(o,c),l&&(hi.fromBufferAttribute(e,c),Mt.add(hi)),r=Math.max(r,n.distanceToSquared(Mt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new sn(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let P=0;P<n.count;P++)o[P]=new N,l[P]=new N;const c=new N,h=new N,u=new N,d=new Xe,p=new Xe,_=new Xe,v=new N,m=new N;function f(P,y,x){c.fromBufferAttribute(n,P),h.fromBufferAttribute(n,y),u.fromBufferAttribute(n,x),d.fromBufferAttribute(s,P),p.fromBufferAttribute(s,y),_.fromBufferAttribute(s,x),h.sub(c),u.sub(c),p.sub(d),_.sub(d);const R=1/(p.x*_.y-_.x*p.y);isFinite(R)&&(v.copy(h).multiplyScalar(_.y).addScaledVector(u,-p.y).multiplyScalar(R),m.copy(u).multiplyScalar(p.x).addScaledVector(h,-_.x).multiplyScalar(R),o[P].add(v),o[y].add(v),o[x].add(v),l[P].add(m),l[y].add(m),l[x].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let P=0,y=b.length;P<y;++P){const x=b[P],R=x.start,H=x.count;for(let B=R,j=R+H;B<j;B+=3)f(e.getX(B+0),e.getX(B+1),e.getX(B+2))}const E=new N,S=new N,L=new N,w=new N;function C(P){L.fromBufferAttribute(r,P),w.copy(L);const y=o[P];E.copy(y),E.sub(L.multiplyScalar(L.dot(y))).normalize(),S.crossVectors(w,y);const R=S.dot(l[P])<0?-1:1;a.setXYZW(P,E.x,E.y,E.z,R)}for(let P=0,y=b.length;P<y;++P){const x=b[P],R=x.start,H=x.count;for(let B=R,j=R+H;B<j;B+=3)C(e.getX(B+0)),C(e.getX(B+1)),C(e.getX(B+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new sn(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const r=new N,s=new N,a=new N,o=new N,l=new N,c=new N,h=new N,u=new N;if(e)for(let d=0,p=e.count;d<p;d+=3){const _=e.getX(d+0),v=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,_),s.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),o.fromBufferAttribute(n,_),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Mt.fromBufferAttribute(e,t),Mt.normalize(),e.setXYZ(t,Mt.x,Mt.y,Mt.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let p=0,_=0;for(let v=0,m=l.length;v<m;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*h;for(let f=0;f<h;f++)d[_++]=c[p++]}return new sn(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new en,n=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],p=e(d,n);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const p=c[u];h.push(p.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const io=new ht,kn=new Xr,ur=new Ji,ro=new N,fr=new N,dr=new N,pr=new N,gs=new N,mr=new N,so=new N,_r=new N;class Jt extends St{constructor(e=new en,t=new gl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){mr.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],u=s[l];h!==0&&(gs.fromBufferAttribute(u,e),a?mr.addScaledVector(gs,h):mr.addScaledVector(gs.sub(t),h))}t.add(mr)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ur.copy(n.boundingSphere),ur.applyMatrix4(s),kn.copy(e.ray).recast(e.near),!(ur.containsPoint(kn.origin)===!1&&(kn.intersectSphere(ur,ro)===null||kn.origin.distanceToSquared(ro)>(e.far-e.near)**2))&&(io.copy(s).invert(),kn.copy(e.ray).applyMatrix4(io),!(n.boundingBox!==null&&kn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,kn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,v=d.length;_<v;_++){const m=d[_],f=a[m.materialIndex],b=Math.max(m.start,p.start),E=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let S=b,L=E;S<L;S+=3){const w=o.getX(S),C=o.getX(S+1),P=o.getX(S+2);r=gr(this,f,e,n,c,h,u,w,C,P),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const _=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let m=_,f=v;m<f;m+=3){const b=o.getX(m),E=o.getX(m+1),S=o.getX(m+2);r=gr(this,a,e,n,c,h,u,b,E,S),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let _=0,v=d.length;_<v;_++){const m=d[_],f=a[m.materialIndex],b=Math.max(m.start,p.start),E=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let S=b,L=E;S<L;S+=3){const w=S,C=S+1,P=S+2;r=gr(this,f,e,n,c,h,u,w,C,P),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const _=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let m=_,f=v;m<f;m+=3){const b=m,E=m+1,S=m+2;r=gr(this,a,e,n,c,h,u,b,E,S),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}}function Hh(i,e,t,n,r,s,a,o){let l;if(e.side===It?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===Sn,o),l===null)return null;_r.copy(o),_r.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(_r);return c<t.near||c>t.far?null:{distance:c,point:_r.clone(),object:i}}function gr(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,fr),i.getVertexPosition(l,dr),i.getVertexPosition(c,pr);const h=Hh(i,e,t,n,fr,dr,pr,so);if(h){const u=new N;Zt.getBarycoord(so,fr,dr,pr,u),r&&(h.uv=Zt.getInterpolatedAttribute(r,o,l,c,u,new Xe)),s&&(h.uv1=Zt.getInterpolatedAttribute(s,o,l,c,u,new Xe)),a&&(h.normal=Zt.getInterpolatedAttribute(a,o,l,c,u,new N),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new N,materialIndex:0};Zt.getNormal(fr,dr,pr,d.normal),h.face=d,h.barycoord=u}return h}class Qi extends en{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,p=0;_("z","y","x",-1,-1,n,t,e,a,s,0),_("z","y","x",1,-1,n,t,-e,a,s,1),_("x","z","y",1,1,e,n,t,r,a,2),_("x","z","y",1,-1,e,n,-t,r,a,3),_("x","y","z",1,-1,e,t,n,r,s,4),_("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new Ct(c,3)),this.setAttribute("normal",new Ct(h,3)),this.setAttribute("uv",new Ct(u,2));function _(v,m,f,b,E,S,L,w,C,P,y){const x=S/C,R=L/P,H=S/2,B=L/2,j=w/2,J=C+1,W=P+1;let ne=0,G=0;const fe=new N;for(let xe=0;xe<W;xe++){const se=xe*R-B;for(let We=0;We<J;We++){const Ze=We*x-H;fe[v]=Ze*b,fe[m]=se*E,fe[f]=j,c.push(fe.x,fe.y,fe.z),fe[v]=0,fe[m]=0,fe[f]=w>0?1:-1,h.push(fe.x,fe.y,fe.z),u.push(We/C),u.push(1-xe/P),ne+=1}}for(let xe=0;xe<P;xe++)for(let se=0;se<C;se++){const We=d+se+J*xe,Ze=d+se+J*(xe+1),Y=d+(se+1)+J*(xe+1),le=d+(se+1)+J*xe;l.push(We,Ze,le),l.push(Ze,Y,le),G+=6}o.addGroup(p,G,y),p+=G,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ti(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Rt(i){const e={};for(let t=0;t<i.length;t++){const n=Ti(i[t]);for(const r in n)e[r]=n[r]}return e}function Vh(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Ml(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Qe.workingColorSpace}const Gh={clone:Ti,merge:Rt};var Wh=`void main() {
6
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
- }`,Xh=`void main() {
8
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
- }`;class Un extends yn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Wh,this.fragmentShader=Xh,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ti(e.uniforms),this.uniformsGroups=Vh(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Sl extends St{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,this.coordinateSystem=vn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Rn=new N,ao=new Xe,oo=new Xe;class Xt extends Sl{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ma*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ur*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ma*2*Math.atan(Math.tan(Ur*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Rn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Rn.x,Rn.y).multiplyScalar(-e/Rn.z),Rn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Rn.x,Rn.y).multiplyScalar(-e/Rn.z)}getViewSize(e,t){return this.getViewBounds(e,ao,oo),t.subVectors(oo,ao)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ur*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ui=-90,fi=1;class qh extends St{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Xt(ui,fi,e,t);r.layers=this.layers,this.add(r);const s=new Xt(ui,fi,e,t);s.layers=this.layers,this.add(s);const a=new Xt(ui,fi,e,t);a.layers=this.layers,this.add(a);const o=new Xt(ui,fi,e,t);o.layers=this.layers,this.add(o);const l=new Xt(ui,fi,e,t);l.layers=this.layers,this.add(l);const c=new Xt(ui,fi,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===vn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===zr)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,l),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,r),e.render(t,h),e.setRenderTarget(u,d,p),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class yl extends Pt{constructor(e=[],t=Si,n,r,s,a,o,l,c,h){super(e,t,n,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Yh extends $n{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new yl(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
10
-
11
- varying vec3 vWorldDirection;
12
-
13
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
14
-
15
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
16
-
17
- }
18
-
19
- void main() {
20
-
21
- vWorldDirection = transformDirection( position, modelMatrix );
22
-
23
- #include <begin_vertex>
24
- #include <project_vertex>
25
-
26
- }
27
- `,fragmentShader:`
28
-
29
- uniform sampler2D tEquirect;
30
-
31
- varying vec3 vWorldDirection;
32
-
33
- #include <common>
34
-
35
- void main() {
36
-
37
- vec3 direction = normalize( vWorldDirection );
38
-
39
- vec2 sampleUV = equirectUv( direction );
40
-
41
- gl_FragColor = texture2D( tEquirect, sampleUV );
42
-
43
- }
44
- `},r=new Qi(5,5,5),s=new Un({name:"CubemapFromEquirect",uniforms:Ti(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:It,blending:Dn});s.uniforms.tEquirect.value=t;const a=new Jt(r,s),o=t.minFilter;return t.minFilter===jn&&(t.minFilter=rn),new qh(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Hi extends St{constructor(){super(),this.isGroup=!0,this.type="Group"}}const jh={type:"move"};class vs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Hi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Hi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Hi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,n),f=this._getHandJoint(c,v);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,_=.005;c.inputState.pinching&&d>p+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(jh)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Hi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Kh extends St{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new on,this.environmentIntensity=1,this.environmentRotation=new on,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const xs=new N,Zh=new N,$h=new qe;class Cn{constructor(e=new N(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=xs.subVectors(n,t).cross(Zh.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(xs),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||$h.getNormalMatrix(e),r=this.coplanarPoint(xs).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Hn=new Ji,vr=new N;class Pa{constructor(e=new Cn,t=new Cn,n=new Cn,r=new Cn,s=new Cn,a=new Cn){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=vn){const n=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],h=r[5],u=r[6],d=r[7],p=r[8],_=r[9],v=r[10],m=r[11],f=r[12],b=r[13],E=r[14],S=r[15];if(n[0].setComponents(l-s,d-c,m-p,S-f).normalize(),n[1].setComponents(l+s,d+c,m+p,S+f).normalize(),n[2].setComponents(l+a,d+h,m+_,S+b).normalize(),n[3].setComponents(l-a,d-h,m-_,S-b).normalize(),n[4].setComponents(l-o,d-u,m-v,S-E).normalize(),t===vn)n[5].setComponents(l+o,d+u,m+v,S+E).normalize();else if(t===zr)n[5].setComponents(o,u,v,E).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Hn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Hn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hn)}intersectsSprite(e){return Hn.center.set(0,0,0),Hn.radius=.7071067811865476,Hn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hn)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(vr.x=r.normal.x>0?e.max.x:e.min.x,vr.y=r.normal.y>0?e.max.y:e.min.y,vr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(vr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Ir extends yn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ke(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const kr=new N,Hr=new N,lo=new ht,ki=new Xr,xr=new Ji,Ms=new N,co=new N;class Jh extends St{constructor(e=new en,t=new Ir){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)kr.fromBufferAttribute(t,r-1),Hr.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=kr.distanceTo(Hr);e.setAttribute("lineDistance",new Ct(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),xr.copy(n.boundingSphere),xr.applyMatrix4(r),xr.radius+=s,e.ray.intersectsSphere(xr)===!1)return;lo.copy(r).invert(),ki.copy(e.ray).applyMatrix4(lo);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const p=Math.max(0,a.start),_=Math.min(h.count,a.start+a.count);for(let v=p,m=_-1;v<m;v+=c){const f=h.getX(v),b=h.getX(v+1),E=Mr(this,e,ki,l,f,b,v);E&&t.push(E)}if(this.isLineLoop){const v=h.getX(_-1),m=h.getX(p),f=Mr(this,e,ki,l,v,m,_-1);f&&t.push(f)}}else{const p=Math.max(0,a.start),_=Math.min(d.count,a.start+a.count);for(let v=p,m=_-1;v<m;v+=c){const f=Mr(this,e,ki,l,v,v+1,v);f&&t.push(f)}if(this.isLineLoop){const v=Mr(this,e,ki,l,_-1,p,_-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Mr(i,e,t,n,r,s,a){const o=i.geometry.attributes.position;if(kr.fromBufferAttribute(o,r),Hr.fromBufferAttribute(o,s),t.distanceSqToSegment(kr,Hr,Ms,co)>n)return;Ms.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Ms);if(!(c<e.near||c>e.far))return{distance:c,point:co.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const ho=new N,uo=new N;class fo extends Jh{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)ho.fromBufferAttribute(t,r),uo.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+ho.distanceTo(uo);e.setAttribute("lineDistance",new Ct(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Vi extends yn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ke(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const po=new ht,_a=new Xr,Sr=new Ji,yr=new N;class Ss extends St{constructor(e=new en,t=new Vi){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Sr.copy(n.boundingSphere),Sr.applyMatrix4(r),Sr.radius+=s,e.ray.intersectsSphere(Sr)===!1)return;po.copy(r).invert(),_a.copy(e.ray).applyMatrix4(po);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let _=d,v=p;_<v;_++){const m=c.getX(_);yr.fromBufferAttribute(u,m),mo(yr,m,l,r,e,t,this)}}else{const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let _=d,v=p;_<v;_++)yr.fromBufferAttribute(u,_),mo(yr,_,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function mo(i,e,t,n,r,s,a){const o=_a.distanceSqToPoint(i);if(o<t){const l=new N;_a.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class El extends Pt{constructor(e,t,n=Kn,r,s,a,o=Qt,l=Qt,c,h=Yi,u=1){if(h!==Yi&&h!==ji)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,r,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ca(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class qr extends en{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(r),c=o+1,h=l+1,u=e/o,d=t/l,p=[],_=[],v=[],m=[];for(let f=0;f<h;f++){const b=f*d-a;for(let E=0;E<c;E++){const S=E*u-s;_.push(S,-b,0),v.push(0,0,1),m.push(E/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let b=0;b<o;b++){const E=b+c*f,S=b+c*(f+1),L=b+1+c*(f+1),w=b+1+c*f;p.push(E,S,w),p.push(S,L,w)}this.setIndex(p),this.setAttribute("position",new Ct(_,3)),this.setAttribute("normal",new Ct(v,3)),this.setAttribute("uv",new Ct(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qr(e.width,e.height,e.widthSegments,e.heightSegments)}}class Tl extends yn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ke(16777215),this.specular=new Ke(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ul,this.normalScale=new Xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new on,this.combine=ya,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Qh extends yn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ch,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class eu extends yn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const Vr={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class tu{constructor(e,t,n){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){const p=c[u],_=c[u+1];if(p.global&&(p.lastIndex=0),p.test(h))return _}return null}}}const bl=new tu;class wi{constructor(e){this.manager=e!==void 0?e:bl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}wi.DEFAULT_MATERIAL_NAME="__DEFAULT";const dn={};class nu extends Error{constructor(e,t){super(e),this.response=t}}class Al extends wi{constructor(e){super(e),this.mimeType="",this.responseType=""}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Vr.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(dn[e]!==void 0){dn[e].push({onLoad:t,onProgress:n,onError:r});return}dn[e]=[],dn[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=dn[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,_=p!==0;let v=0;const m=new ReadableStream({start(f){b();function b(){u.read().then(({done:E,value:S})=>{if(E)f.close();else{v+=S.byteLength;const L=new ProgressEvent("progress",{lengthComputable:_,loaded:v,total:p});for(let w=0,C=h.length;w<C;w++){const P=h[w];P.onProgress&&P.onProgress(L)}f.enqueue(S),b()}},E=>{f.error(E)})}}});return new Response(m)}else throw new nu(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(_=>p.decode(_))}}}).then(c=>{Vr.add(e,c);const h=dn[e];delete dn[e];for(let u=0,d=h.length;u<d;u++){const p=h[u];p.onLoad&&p.onLoad(c)}}).catch(c=>{const h=dn[e];if(h===void 0)throw this.manager.itemError(e),c;delete dn[e];for(let u=0,d=h.length;u<d;u++){const p=h[u];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class iu extends wi{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Vr.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=Ki("img");function l(){h(),Vr.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(u){h(),r&&r(u),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class ru extends wi{constructor(e){super(e)}load(e,t,n,r){const s=new Pt,a=new iu(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}class wl extends St{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ke(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const ys=new ht,_o=new N,go=new N;class su{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Xe(512,512),this.mapType=an,this.map=null,this.mapPass=null,this.matrix=new ht,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Pa,this._frameExtents=new Xe(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;_o.setFromMatrixPosition(e.matrixWorld),t.position.copy(_o),go.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(go),t.updateMatrixWorld(),ys.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ys),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(ys)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Rl extends Sl{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class au extends su{constructor(){super(new Rl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class ou extends wl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.target=new St,this.shadow=new au}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class lu extends wl{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class cu{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class hu extends Xt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class vo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=$e(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos($e(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class uu extends Jn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function xo(i,e,t,n){const r=fu(n);switch(t){case al:return i*e;case ll:return i*e/r.components*r.byteLength;case Aa:return i*e/r.components*r.byteLength;case cl:return i*e*2/r.components*r.byteLength;case wa:return i*e*2/r.components*r.byteLength;case ol:return i*e*3/r.components*r.byteLength;case $t:return i*e*4/r.components*r.byteLength;case Ra:return i*e*4/r.components*r.byteLength;case Rr:case Cr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Pr:case Dr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ws:case qs:return Math.max(i,16)*Math.max(e,8)/4;case Gs:case Xs:return Math.max(i,8)*Math.max(e,8)/2;case Ys:case js:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ks:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Zs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case $s:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Js:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Qs:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case ea:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case ta:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case na:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case ia:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ra:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case sa:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case aa:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case oa:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case la:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ca:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Lr:case ha:case ua:return Math.ceil(i/4)*Math.ceil(e/4)*16;case hl:case fa:return Math.ceil(i/4)*Math.ceil(e/4)*8;case da:case pa:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function fu(i){switch(i){case an:case il:return{byteLength:1,components:1};case Xi:case rl:case Zi:return{byteLength:2,components:1};case Ta:case ba:return{byteLength:2,components:4};case Kn:case Ea:case gn:return{byteLength:4,components:1};case sl:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Sa}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Sa);/**
45
- * @license
46
- * Copyright 2010-2025 Three.js Authors
47
- * SPDX-License-Identifier: MIT
48
- */function Cl(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function du(i){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=i.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=i.SHORT;else if(c instanceof Uint32Array)p=i.UNSIGNED_INT;else if(c instanceof Int32Array)p=i.INT;else if(c instanceof Int8Array)p=i.BYTE;else if(c instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,0,h);else{u.sort((p,_)=>p.start-_.start);let d=0;for(let p=1;p<u.length;p++){const _=u[d],v=u[p];v.start<=_.start+_.count+1?_.count=Math.max(_.count,v.start+v.count-_.start):(++d,u[d]=v)}u.length=d+1;for(let p=0,_=u.length;p<_;p++){const v=u[p];i.bufferSubData(c,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}var pu=`#ifdef USE_ALPHAHASH
49
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
50
- #endif`,mu=`#ifdef USE_ALPHAHASH
51
- const float ALPHA_HASH_SCALE = 0.05;
52
- float hash2D( vec2 value ) {
53
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
54
- }
55
- float hash3D( vec3 value ) {
56
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
57
- }
58
- float getAlphaHashThreshold( vec3 position ) {
59
- float maxDeriv = max(
60
- length( dFdx( position.xyz ) ),
61
- length( dFdy( position.xyz ) )
62
- );
63
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
64
- vec2 pixScales = vec2(
65
- exp2( floor( log2( pixScale ) ) ),
66
- exp2( ceil( log2( pixScale ) ) )
67
- );
68
- vec2 alpha = vec2(
69
- hash3D( floor( pixScales.x * position.xyz ) ),
70
- hash3D( floor( pixScales.y * position.xyz ) )
71
- );
72
- float lerpFactor = fract( log2( pixScale ) );
73
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
74
- float a = min( lerpFactor, 1.0 - lerpFactor );
75
- vec3 cases = vec3(
76
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
77
- ( x - 0.5 * a ) / ( 1.0 - a ),
78
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
79
- );
80
- float threshold = ( x < ( 1.0 - a ) )
81
- ? ( ( x < a ) ? cases.x : cases.y )
82
- : cases.z;
83
- return clamp( threshold , 1.0e-6, 1.0 );
84
- }
85
- #endif`,_u=`#ifdef USE_ALPHAMAP
86
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
87
- #endif`,gu=`#ifdef USE_ALPHAMAP
88
- uniform sampler2D alphaMap;
89
- #endif`,vu=`#ifdef USE_ALPHATEST
90
- #ifdef ALPHA_TO_COVERAGE
91
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
92
- if ( diffuseColor.a == 0.0 ) discard;
93
- #else
94
- if ( diffuseColor.a < alphaTest ) discard;
95
- #endif
96
- #endif`,xu=`#ifdef USE_ALPHATEST
97
- uniform float alphaTest;
98
- #endif`,Mu=`#ifdef USE_AOMAP
99
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
100
- reflectedLight.indirectDiffuse *= ambientOcclusion;
101
- #if defined( USE_CLEARCOAT )
102
- clearcoatSpecularIndirect *= ambientOcclusion;
103
- #endif
104
- #if defined( USE_SHEEN )
105
- sheenSpecularIndirect *= ambientOcclusion;
106
- #endif
107
- #if defined( USE_ENVMAP ) && defined( STANDARD )
108
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
109
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
110
- #endif
111
- #endif`,Su=`#ifdef USE_AOMAP
112
- uniform sampler2D aoMap;
113
- uniform float aoMapIntensity;
114
- #endif`,yu=`#ifdef USE_BATCHING
115
- #if ! defined( GL_ANGLE_multi_draw )
116
- #define gl_DrawID _gl_DrawID
117
- uniform int _gl_DrawID;
118
- #endif
119
- uniform highp sampler2D batchingTexture;
120
- uniform highp usampler2D batchingIdTexture;
121
- mat4 getBatchingMatrix( const in float i ) {
122
- int size = textureSize( batchingTexture, 0 ).x;
123
- int j = int( i ) * 4;
124
- int x = j % size;
125
- int y = j / size;
126
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
127
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
128
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
129
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
130
- return mat4( v1, v2, v3, v4 );
131
- }
132
- float getIndirectIndex( const in int i ) {
133
- int size = textureSize( batchingIdTexture, 0 ).x;
134
- int x = i % size;
135
- int y = i / size;
136
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
137
- }
138
- #endif
139
- #ifdef USE_BATCHING_COLOR
140
- uniform sampler2D batchingColorTexture;
141
- vec3 getBatchingColor( const in float i ) {
142
- int size = textureSize( batchingColorTexture, 0 ).x;
143
- int j = int( i );
144
- int x = j % size;
145
- int y = j / size;
146
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
147
- }
148
- #endif`,Eu=`#ifdef USE_BATCHING
149
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
150
- #endif`,Tu=`vec3 transformed = vec3( position );
151
- #ifdef USE_ALPHAHASH
152
- vPosition = vec3( position );
153
- #endif`,bu=`vec3 objectNormal = vec3( normal );
154
- #ifdef USE_TANGENT
155
- vec3 objectTangent = vec3( tangent.xyz );
156
- #endif`,Au=`float G_BlinnPhong_Implicit( ) {
157
- return 0.25;
158
- }
159
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
160
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
161
- }
162
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
163
- vec3 halfDir = normalize( lightDir + viewDir );
164
- float dotNH = saturate( dot( normal, halfDir ) );
165
- float dotVH = saturate( dot( viewDir, halfDir ) );
166
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
167
- float G = G_BlinnPhong_Implicit( );
168
- float D = D_BlinnPhong( shininess, dotNH );
169
- return F * ( G * D );
170
- } // validated`,wu=`#ifdef USE_IRIDESCENCE
171
- const mat3 XYZ_TO_REC709 = mat3(
172
- 3.2404542, -0.9692660, 0.0556434,
173
- -1.5371385, 1.8760108, -0.2040259,
174
- -0.4985314, 0.0415560, 1.0572252
175
- );
176
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
177
- vec3 sqrtF0 = sqrt( fresnel0 );
178
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
179
- }
180
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
181
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
182
- }
183
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
184
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
185
- }
186
- vec3 evalSensitivity( float OPD, vec3 shift ) {
187
- float phase = 2.0 * PI * OPD * 1.0e-9;
188
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
189
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
190
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
191
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
192
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
193
- xyz /= 1.0685e-7;
194
- vec3 rgb = XYZ_TO_REC709 * xyz;
195
- return rgb;
196
- }
197
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
198
- vec3 I;
199
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
200
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
201
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
202
- if ( cosTheta2Sq < 0.0 ) {
203
- return vec3( 1.0 );
204
- }
205
- float cosTheta2 = sqrt( cosTheta2Sq );
206
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
207
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
208
- float T121 = 1.0 - R12;
209
- float phi12 = 0.0;
210
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
211
- float phi21 = PI - phi12;
212
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
213
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
214
- vec3 phi23 = vec3( 0.0 );
215
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
216
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
217
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
218
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
219
- vec3 phi = vec3( phi21 ) + phi23;
220
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
221
- vec3 r123 = sqrt( R123 );
222
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
223
- vec3 C0 = R12 + Rs;
224
- I = C0;
225
- vec3 Cm = Rs - T121;
226
- for ( int m = 1; m <= 2; ++ m ) {
227
- Cm *= r123;
228
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
229
- I += Cm * Sm;
230
- }
231
- return max( I, vec3( 0.0 ) );
232
- }
233
- #endif`,Ru=`#ifdef USE_BUMPMAP
234
- uniform sampler2D bumpMap;
235
- uniform float bumpScale;
236
- vec2 dHdxy_fwd() {
237
- vec2 dSTdx = dFdx( vBumpMapUv );
238
- vec2 dSTdy = dFdy( vBumpMapUv );
239
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
240
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
241
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
242
- return vec2( dBx, dBy );
243
- }
244
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
245
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
246
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
247
- vec3 vN = surf_norm;
248
- vec3 R1 = cross( vSigmaY, vN );
249
- vec3 R2 = cross( vN, vSigmaX );
250
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
251
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
252
- return normalize( abs( fDet ) * surf_norm - vGrad );
253
- }
254
- #endif`,Cu=`#if NUM_CLIPPING_PLANES > 0
255
- vec4 plane;
256
- #ifdef ALPHA_TO_COVERAGE
257
- float distanceToPlane, distanceGradient;
258
- float clipOpacity = 1.0;
259
- #pragma unroll_loop_start
260
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
261
- plane = clippingPlanes[ i ];
262
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
263
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
264
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
265
- if ( clipOpacity == 0.0 ) discard;
266
- }
267
- #pragma unroll_loop_end
268
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
269
- float unionClipOpacity = 1.0;
270
- #pragma unroll_loop_start
271
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
272
- plane = clippingPlanes[ i ];
273
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
274
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
275
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
276
- }
277
- #pragma unroll_loop_end
278
- clipOpacity *= 1.0 - unionClipOpacity;
279
- #endif
280
- diffuseColor.a *= clipOpacity;
281
- if ( diffuseColor.a == 0.0 ) discard;
282
- #else
283
- #pragma unroll_loop_start
284
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
285
- plane = clippingPlanes[ i ];
286
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
287
- }
288
- #pragma unroll_loop_end
289
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
290
- bool clipped = true;
291
- #pragma unroll_loop_start
292
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
293
- plane = clippingPlanes[ i ];
294
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
295
- }
296
- #pragma unroll_loop_end
297
- if ( clipped ) discard;
298
- #endif
299
- #endif
300
- #endif`,Pu=`#if NUM_CLIPPING_PLANES > 0
301
- varying vec3 vClipPosition;
302
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
303
- #endif`,Du=`#if NUM_CLIPPING_PLANES > 0
304
- varying vec3 vClipPosition;
305
- #endif`,Lu=`#if NUM_CLIPPING_PLANES > 0
306
- vClipPosition = - mvPosition.xyz;
307
- #endif`,Uu=`#if defined( USE_COLOR_ALPHA )
308
- diffuseColor *= vColor;
309
- #elif defined( USE_COLOR )
310
- diffuseColor.rgb *= vColor;
311
- #endif`,Iu=`#if defined( USE_COLOR_ALPHA )
312
- varying vec4 vColor;
313
- #elif defined( USE_COLOR )
314
- varying vec3 vColor;
315
- #endif`,Nu=`#if defined( USE_COLOR_ALPHA )
316
- varying vec4 vColor;
317
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
318
- varying vec3 vColor;
319
- #endif`,Fu=`#if defined( USE_COLOR_ALPHA )
320
- vColor = vec4( 1.0 );
321
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
322
- vColor = vec3( 1.0 );
323
- #endif
324
- #ifdef USE_COLOR
325
- vColor *= color;
326
- #endif
327
- #ifdef USE_INSTANCING_COLOR
328
- vColor.xyz *= instanceColor.xyz;
329
- #endif
330
- #ifdef USE_BATCHING_COLOR
331
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
332
- vColor.xyz *= batchingColor.xyz;
333
- #endif`,Ou=`#define PI 3.141592653589793
334
- #define PI2 6.283185307179586
335
- #define PI_HALF 1.5707963267948966
336
- #define RECIPROCAL_PI 0.3183098861837907
337
- #define RECIPROCAL_PI2 0.15915494309189535
338
- #define EPSILON 1e-6
339
- #ifndef saturate
340
- #define saturate( a ) clamp( a, 0.0, 1.0 )
341
- #endif
342
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
343
- float pow2( const in float x ) { return x*x; }
344
- vec3 pow2( const in vec3 x ) { return x*x; }
345
- float pow3( const in float x ) { return x*x*x; }
346
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
347
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
348
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
349
- highp float rand( const in vec2 uv ) {
350
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
351
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
352
- return fract( sin( sn ) * c );
353
- }
354
- #ifdef HIGH_PRECISION
355
- float precisionSafeLength( vec3 v ) { return length( v ); }
356
- #else
357
- float precisionSafeLength( vec3 v ) {
358
- float maxComponent = max3( abs( v ) );
359
- return length( v / maxComponent ) * maxComponent;
360
- }
361
- #endif
362
- struct IncidentLight {
363
- vec3 color;
364
- vec3 direction;
365
- bool visible;
366
- };
367
- struct ReflectedLight {
368
- vec3 directDiffuse;
369
- vec3 directSpecular;
370
- vec3 indirectDiffuse;
371
- vec3 indirectSpecular;
372
- };
373
- #ifdef USE_ALPHAHASH
374
- varying vec3 vPosition;
375
- #endif
376
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
377
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
378
- }
379
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
380
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
381
- }
382
- mat3 transposeMat3( const in mat3 m ) {
383
- mat3 tmp;
384
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
385
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
386
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
387
- return tmp;
388
- }
389
- bool isPerspectiveMatrix( mat4 m ) {
390
- return m[ 2 ][ 3 ] == - 1.0;
391
- }
392
- vec2 equirectUv( in vec3 dir ) {
393
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
394
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
395
- return vec2( u, v );
396
- }
397
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
398
- return RECIPROCAL_PI * diffuseColor;
399
- }
400
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
401
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
402
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
403
- }
404
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
405
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
406
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
407
- } // validated`,Bu=`#ifdef ENVMAP_TYPE_CUBE_UV
408
- #define cubeUV_minMipLevel 4.0
409
- #define cubeUV_minTileSize 16.0
410
- float getFace( vec3 direction ) {
411
- vec3 absDirection = abs( direction );
412
- float face = - 1.0;
413
- if ( absDirection.x > absDirection.z ) {
414
- if ( absDirection.x > absDirection.y )
415
- face = direction.x > 0.0 ? 0.0 : 3.0;
416
- else
417
- face = direction.y > 0.0 ? 1.0 : 4.0;
418
- } else {
419
- if ( absDirection.z > absDirection.y )
420
- face = direction.z > 0.0 ? 2.0 : 5.0;
421
- else
422
- face = direction.y > 0.0 ? 1.0 : 4.0;
423
- }
424
- return face;
425
- }
426
- vec2 getUV( vec3 direction, float face ) {
427
- vec2 uv;
428
- if ( face == 0.0 ) {
429
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
430
- } else if ( face == 1.0 ) {
431
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
432
- } else if ( face == 2.0 ) {
433
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
434
- } else if ( face == 3.0 ) {
435
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
436
- } else if ( face == 4.0 ) {
437
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
438
- } else {
439
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
440
- }
441
- return 0.5 * ( uv + 1.0 );
442
- }
443
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
444
- float face = getFace( direction );
445
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
446
- mipInt = max( mipInt, cubeUV_minMipLevel );
447
- float faceSize = exp2( mipInt );
448
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
449
- if ( face > 2.0 ) {
450
- uv.y += faceSize;
451
- face -= 3.0;
452
- }
453
- uv.x += face * faceSize;
454
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
455
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
456
- uv.x *= CUBEUV_TEXEL_WIDTH;
457
- uv.y *= CUBEUV_TEXEL_HEIGHT;
458
- #ifdef texture2DGradEXT
459
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
460
- #else
461
- return texture2D( envMap, uv ).rgb;
462
- #endif
463
- }
464
- #define cubeUV_r0 1.0
465
- #define cubeUV_m0 - 2.0
466
- #define cubeUV_r1 0.8
467
- #define cubeUV_m1 - 1.0
468
- #define cubeUV_r4 0.4
469
- #define cubeUV_m4 2.0
470
- #define cubeUV_r5 0.305
471
- #define cubeUV_m5 3.0
472
- #define cubeUV_r6 0.21
473
- #define cubeUV_m6 4.0
474
- float roughnessToMip( float roughness ) {
475
- float mip = 0.0;
476
- if ( roughness >= cubeUV_r1 ) {
477
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
478
- } else if ( roughness >= cubeUV_r4 ) {
479
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
480
- } else if ( roughness >= cubeUV_r5 ) {
481
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
482
- } else if ( roughness >= cubeUV_r6 ) {
483
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
484
- } else {
485
- mip = - 2.0 * log2( 1.16 * roughness ); }
486
- return mip;
487
- }
488
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
489
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
490
- float mipF = fract( mip );
491
- float mipInt = floor( mip );
492
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
493
- if ( mipF == 0.0 ) {
494
- return vec4( color0, 1.0 );
495
- } else {
496
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
497
- return vec4( mix( color0, color1, mipF ), 1.0 );
498
- }
499
- }
500
- #endif`,zu=`vec3 transformedNormal = objectNormal;
501
- #ifdef USE_TANGENT
502
- vec3 transformedTangent = objectTangent;
503
- #endif
504
- #ifdef USE_BATCHING
505
- mat3 bm = mat3( batchingMatrix );
506
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
507
- transformedNormal = bm * transformedNormal;
508
- #ifdef USE_TANGENT
509
- transformedTangent = bm * transformedTangent;
510
- #endif
511
- #endif
512
- #ifdef USE_INSTANCING
513
- mat3 im = mat3( instanceMatrix );
514
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
515
- transformedNormal = im * transformedNormal;
516
- #ifdef USE_TANGENT
517
- transformedTangent = im * transformedTangent;
518
- #endif
519
- #endif
520
- transformedNormal = normalMatrix * transformedNormal;
521
- #ifdef FLIP_SIDED
522
- transformedNormal = - transformedNormal;
523
- #endif
524
- #ifdef USE_TANGENT
525
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
526
- #ifdef FLIP_SIDED
527
- transformedTangent = - transformedTangent;
528
- #endif
529
- #endif`,ku=`#ifdef USE_DISPLACEMENTMAP
530
- uniform sampler2D displacementMap;
531
- uniform float displacementScale;
532
- uniform float displacementBias;
533
- #endif`,Hu=`#ifdef USE_DISPLACEMENTMAP
534
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
535
- #endif`,Vu=`#ifdef USE_EMISSIVEMAP
536
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
537
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
538
- emissiveColor = sRGBTransferEOTF( emissiveColor );
539
- #endif
540
- totalEmissiveRadiance *= emissiveColor.rgb;
541
- #endif`,Gu=`#ifdef USE_EMISSIVEMAP
542
- uniform sampler2D emissiveMap;
543
- #endif`,Wu="gl_FragColor = linearToOutputTexel( gl_FragColor );",Xu=`vec4 LinearTransferOETF( in vec4 value ) {
544
- return value;
545
- }
546
- vec4 sRGBTransferEOTF( in vec4 value ) {
547
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
548
- }
549
- vec4 sRGBTransferOETF( in vec4 value ) {
550
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
551
- }`,qu=`#ifdef USE_ENVMAP
552
- #ifdef ENV_WORLDPOS
553
- vec3 cameraToFrag;
554
- if ( isOrthographic ) {
555
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
556
- } else {
557
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
558
- }
559
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
560
- #ifdef ENVMAP_MODE_REFLECTION
561
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
562
- #else
563
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
564
- #endif
565
- #else
566
- vec3 reflectVec = vReflect;
567
- #endif
568
- #ifdef ENVMAP_TYPE_CUBE
569
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
570
- #else
571
- vec4 envColor = vec4( 0.0 );
572
- #endif
573
- #ifdef ENVMAP_BLENDING_MULTIPLY
574
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
575
- #elif defined( ENVMAP_BLENDING_MIX )
576
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
577
- #elif defined( ENVMAP_BLENDING_ADD )
578
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
579
- #endif
580
- #endif`,Yu=`#ifdef USE_ENVMAP
581
- uniform float envMapIntensity;
582
- uniform float flipEnvMap;
583
- uniform mat3 envMapRotation;
584
- #ifdef ENVMAP_TYPE_CUBE
585
- uniform samplerCube envMap;
586
- #else
587
- uniform sampler2D envMap;
588
- #endif
589
-
590
- #endif`,ju=`#ifdef USE_ENVMAP
591
- uniform float reflectivity;
592
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
593
- #define ENV_WORLDPOS
594
- #endif
595
- #ifdef ENV_WORLDPOS
596
- varying vec3 vWorldPosition;
597
- uniform float refractionRatio;
598
- #else
599
- varying vec3 vReflect;
600
- #endif
601
- #endif`,Ku=`#ifdef USE_ENVMAP
602
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
603
- #define ENV_WORLDPOS
604
- #endif
605
- #ifdef ENV_WORLDPOS
606
-
607
- varying vec3 vWorldPosition;
608
- #else
609
- varying vec3 vReflect;
610
- uniform float refractionRatio;
611
- #endif
612
- #endif`,Zu=`#ifdef USE_ENVMAP
613
- #ifdef ENV_WORLDPOS
614
- vWorldPosition = worldPosition.xyz;
615
- #else
616
- vec3 cameraToVertex;
617
- if ( isOrthographic ) {
618
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
619
- } else {
620
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
621
- }
622
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
623
- #ifdef ENVMAP_MODE_REFLECTION
624
- vReflect = reflect( cameraToVertex, worldNormal );
625
- #else
626
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
627
- #endif
628
- #endif
629
- #endif`,$u=`#ifdef USE_FOG
630
- vFogDepth = - mvPosition.z;
631
- #endif`,Ju=`#ifdef USE_FOG
632
- varying float vFogDepth;
633
- #endif`,Qu=`#ifdef USE_FOG
634
- #ifdef FOG_EXP2
635
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
636
- #else
637
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
638
- #endif
639
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
640
- #endif`,ef=`#ifdef USE_FOG
641
- uniform vec3 fogColor;
642
- varying float vFogDepth;
643
- #ifdef FOG_EXP2
644
- uniform float fogDensity;
645
- #else
646
- uniform float fogNear;
647
- uniform float fogFar;
648
- #endif
649
- #endif`,tf=`#ifdef USE_GRADIENTMAP
650
- uniform sampler2D gradientMap;
651
- #endif
652
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
653
- float dotNL = dot( normal, lightDirection );
654
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
655
- #ifdef USE_GRADIENTMAP
656
- return vec3( texture2D( gradientMap, coord ).r );
657
- #else
658
- vec2 fw = fwidth( coord ) * 0.5;
659
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
660
- #endif
661
- }`,nf=`#ifdef USE_LIGHTMAP
662
- uniform sampler2D lightMap;
663
- uniform float lightMapIntensity;
664
- #endif`,rf=`LambertMaterial material;
665
- material.diffuseColor = diffuseColor.rgb;
666
- material.specularStrength = specularStrength;`,sf=`varying vec3 vViewPosition;
667
- struct LambertMaterial {
668
- vec3 diffuseColor;
669
- float specularStrength;
670
- };
671
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
672
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
673
- vec3 irradiance = dotNL * directLight.color;
674
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
675
- }
676
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
677
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
678
- }
679
- #define RE_Direct RE_Direct_Lambert
680
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,af=`uniform bool receiveShadow;
681
- uniform vec3 ambientLightColor;
682
- #if defined( USE_LIGHT_PROBES )
683
- uniform vec3 lightProbe[ 9 ];
684
- #endif
685
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
686
- float x = normal.x, y = normal.y, z = normal.z;
687
- vec3 result = shCoefficients[ 0 ] * 0.886227;
688
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
689
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
690
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
691
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
692
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
693
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
694
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
695
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
696
- return result;
697
- }
698
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
699
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
700
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
701
- return irradiance;
702
- }
703
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
704
- vec3 irradiance = ambientLightColor;
705
- return irradiance;
706
- }
707
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
708
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
709
- if ( cutoffDistance > 0.0 ) {
710
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
711
- }
712
- return distanceFalloff;
713
- }
714
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
715
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
716
- }
717
- #if NUM_DIR_LIGHTS > 0
718
- struct DirectionalLight {
719
- vec3 direction;
720
- vec3 color;
721
- };
722
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
723
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
724
- light.color = directionalLight.color;
725
- light.direction = directionalLight.direction;
726
- light.visible = true;
727
- }
728
- #endif
729
- #if NUM_POINT_LIGHTS > 0
730
- struct PointLight {
731
- vec3 position;
732
- vec3 color;
733
- float distance;
734
- float decay;
735
- };
736
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
737
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
738
- vec3 lVector = pointLight.position - geometryPosition;
739
- light.direction = normalize( lVector );
740
- float lightDistance = length( lVector );
741
- light.color = pointLight.color;
742
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
743
- light.visible = ( light.color != vec3( 0.0 ) );
744
- }
745
- #endif
746
- #if NUM_SPOT_LIGHTS > 0
747
- struct SpotLight {
748
- vec3 position;
749
- vec3 direction;
750
- vec3 color;
751
- float distance;
752
- float decay;
753
- float coneCos;
754
- float penumbraCos;
755
- };
756
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
757
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
758
- vec3 lVector = spotLight.position - geometryPosition;
759
- light.direction = normalize( lVector );
760
- float angleCos = dot( light.direction, spotLight.direction );
761
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
762
- if ( spotAttenuation > 0.0 ) {
763
- float lightDistance = length( lVector );
764
- light.color = spotLight.color * spotAttenuation;
765
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
766
- light.visible = ( light.color != vec3( 0.0 ) );
767
- } else {
768
- light.color = vec3( 0.0 );
769
- light.visible = false;
770
- }
771
- }
772
- #endif
773
- #if NUM_RECT_AREA_LIGHTS > 0
774
- struct RectAreaLight {
775
- vec3 color;
776
- vec3 position;
777
- vec3 halfWidth;
778
- vec3 halfHeight;
779
- };
780
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
781
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
782
- #endif
783
- #if NUM_HEMI_LIGHTS > 0
784
- struct HemisphereLight {
785
- vec3 direction;
786
- vec3 skyColor;
787
- vec3 groundColor;
788
- };
789
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
790
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
791
- float dotNL = dot( normal, hemiLight.direction );
792
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
793
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
794
- return irradiance;
795
- }
796
- #endif`,of=`#ifdef USE_ENVMAP
797
- vec3 getIBLIrradiance( const in vec3 normal ) {
798
- #ifdef ENVMAP_TYPE_CUBE_UV
799
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
800
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
801
- return PI * envMapColor.rgb * envMapIntensity;
802
- #else
803
- return vec3( 0.0 );
804
- #endif
805
- }
806
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
807
- #ifdef ENVMAP_TYPE_CUBE_UV
808
- vec3 reflectVec = reflect( - viewDir, normal );
809
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
810
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
811
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
812
- return envMapColor.rgb * envMapIntensity;
813
- #else
814
- return vec3( 0.0 );
815
- #endif
816
- }
817
- #ifdef USE_ANISOTROPY
818
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
819
- #ifdef ENVMAP_TYPE_CUBE_UV
820
- vec3 bentNormal = cross( bitangent, viewDir );
821
- bentNormal = normalize( cross( bentNormal, bitangent ) );
822
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
823
- return getIBLRadiance( viewDir, bentNormal, roughness );
824
- #else
825
- return vec3( 0.0 );
826
- #endif
827
- }
828
- #endif
829
- #endif`,lf=`ToonMaterial material;
830
- material.diffuseColor = diffuseColor.rgb;`,cf=`varying vec3 vViewPosition;
831
- struct ToonMaterial {
832
- vec3 diffuseColor;
833
- };
834
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
835
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
836
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
837
- }
838
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
839
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
840
- }
841
- #define RE_Direct RE_Direct_Toon
842
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,hf=`BlinnPhongMaterial material;
843
- material.diffuseColor = diffuseColor.rgb;
844
- material.specularColor = specular;
845
- material.specularShininess = shininess;
846
- material.specularStrength = specularStrength;`,uf=`varying vec3 vViewPosition;
847
- struct BlinnPhongMaterial {
848
- vec3 diffuseColor;
849
- vec3 specularColor;
850
- float specularShininess;
851
- float specularStrength;
852
- };
853
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
854
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
855
- vec3 irradiance = dotNL * directLight.color;
856
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
857
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
858
- }
859
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
860
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
861
- }
862
- #define RE_Direct RE_Direct_BlinnPhong
863
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ff=`PhysicalMaterial material;
864
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
865
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
866
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
867
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
868
- material.roughness = min( material.roughness, 1.0 );
869
- #ifdef IOR
870
- material.ior = ior;
871
- #ifdef USE_SPECULAR
872
- float specularIntensityFactor = specularIntensity;
873
- vec3 specularColorFactor = specularColor;
874
- #ifdef USE_SPECULAR_COLORMAP
875
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
876
- #endif
877
- #ifdef USE_SPECULAR_INTENSITYMAP
878
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
879
- #endif
880
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
881
- #else
882
- float specularIntensityFactor = 1.0;
883
- vec3 specularColorFactor = vec3( 1.0 );
884
- material.specularF90 = 1.0;
885
- #endif
886
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
887
- #else
888
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
889
- material.specularF90 = 1.0;
890
- #endif
891
- #ifdef USE_CLEARCOAT
892
- material.clearcoat = clearcoat;
893
- material.clearcoatRoughness = clearcoatRoughness;
894
- material.clearcoatF0 = vec3( 0.04 );
895
- material.clearcoatF90 = 1.0;
896
- #ifdef USE_CLEARCOATMAP
897
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
898
- #endif
899
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
900
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
901
- #endif
902
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
903
- material.clearcoatRoughness += geometryRoughness;
904
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
905
- #endif
906
- #ifdef USE_DISPERSION
907
- material.dispersion = dispersion;
908
- #endif
909
- #ifdef USE_IRIDESCENCE
910
- material.iridescence = iridescence;
911
- material.iridescenceIOR = iridescenceIOR;
912
- #ifdef USE_IRIDESCENCEMAP
913
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
914
- #endif
915
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
916
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
917
- #else
918
- material.iridescenceThickness = iridescenceThicknessMaximum;
919
- #endif
920
- #endif
921
- #ifdef USE_SHEEN
922
- material.sheenColor = sheenColor;
923
- #ifdef USE_SHEEN_COLORMAP
924
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
925
- #endif
926
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
927
- #ifdef USE_SHEEN_ROUGHNESSMAP
928
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
929
- #endif
930
- #endif
931
- #ifdef USE_ANISOTROPY
932
- #ifdef USE_ANISOTROPYMAP
933
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
934
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
935
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
936
- #else
937
- vec2 anisotropyV = anisotropyVector;
938
- #endif
939
- material.anisotropy = length( anisotropyV );
940
- if( material.anisotropy == 0.0 ) {
941
- anisotropyV = vec2( 1.0, 0.0 );
942
- } else {
943
- anisotropyV /= material.anisotropy;
944
- material.anisotropy = saturate( material.anisotropy );
945
- }
946
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
947
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
948
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
949
- #endif`,df=`struct PhysicalMaterial {
950
- vec3 diffuseColor;
951
- float roughness;
952
- vec3 specularColor;
953
- float specularF90;
954
- float dispersion;
955
- #ifdef USE_CLEARCOAT
956
- float clearcoat;
957
- float clearcoatRoughness;
958
- vec3 clearcoatF0;
959
- float clearcoatF90;
960
- #endif
961
- #ifdef USE_IRIDESCENCE
962
- float iridescence;
963
- float iridescenceIOR;
964
- float iridescenceThickness;
965
- vec3 iridescenceFresnel;
966
- vec3 iridescenceF0;
967
- #endif
968
- #ifdef USE_SHEEN
969
- vec3 sheenColor;
970
- float sheenRoughness;
971
- #endif
972
- #ifdef IOR
973
- float ior;
974
- #endif
975
- #ifdef USE_TRANSMISSION
976
- float transmission;
977
- float transmissionAlpha;
978
- float thickness;
979
- float attenuationDistance;
980
- vec3 attenuationColor;
981
- #endif
982
- #ifdef USE_ANISOTROPY
983
- float anisotropy;
984
- float alphaT;
985
- vec3 anisotropyT;
986
- vec3 anisotropyB;
987
- #endif
988
- };
989
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
990
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
991
- vec3 sheenSpecularDirect = vec3( 0.0 );
992
- vec3 sheenSpecularIndirect = vec3(0.0 );
993
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
994
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
995
- float x2 = x * x;
996
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
997
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
998
- }
999
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
1000
- float a2 = pow2( alpha );
1001
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
1002
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
1003
- return 0.5 / max( gv + gl, EPSILON );
1004
- }
1005
- float D_GGX( const in float alpha, const in float dotNH ) {
1006
- float a2 = pow2( alpha );
1007
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1008
- return RECIPROCAL_PI * a2 / pow2( denom );
1009
- }
1010
- #ifdef USE_ANISOTROPY
1011
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
1012
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1013
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1014
- float v = 0.5 / ( gv + gl );
1015
- return saturate(v);
1016
- }
1017
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1018
- float a2 = alphaT * alphaB;
1019
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1020
- highp float v2 = dot( v, v );
1021
- float w2 = a2 / v2;
1022
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
1023
- }
1024
- #endif
1025
- #ifdef USE_CLEARCOAT
1026
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1027
- vec3 f0 = material.clearcoatF0;
1028
- float f90 = material.clearcoatF90;
1029
- float roughness = material.clearcoatRoughness;
1030
- float alpha = pow2( roughness );
1031
- vec3 halfDir = normalize( lightDir + viewDir );
1032
- float dotNL = saturate( dot( normal, lightDir ) );
1033
- float dotNV = saturate( dot( normal, viewDir ) );
1034
- float dotNH = saturate( dot( normal, halfDir ) );
1035
- float dotVH = saturate( dot( viewDir, halfDir ) );
1036
- vec3 F = F_Schlick( f0, f90, dotVH );
1037
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1038
- float D = D_GGX( alpha, dotNH );
1039
- return F * ( V * D );
1040
- }
1041
- #endif
1042
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1043
- vec3 f0 = material.specularColor;
1044
- float f90 = material.specularF90;
1045
- float roughness = material.roughness;
1046
- float alpha = pow2( roughness );
1047
- vec3 halfDir = normalize( lightDir + viewDir );
1048
- float dotNL = saturate( dot( normal, lightDir ) );
1049
- float dotNV = saturate( dot( normal, viewDir ) );
1050
- float dotNH = saturate( dot( normal, halfDir ) );
1051
- float dotVH = saturate( dot( viewDir, halfDir ) );
1052
- vec3 F = F_Schlick( f0, f90, dotVH );
1053
- #ifdef USE_IRIDESCENCE
1054
- F = mix( F, material.iridescenceFresnel, material.iridescence );
1055
- #endif
1056
- #ifdef USE_ANISOTROPY
1057
- float dotTL = dot( material.anisotropyT, lightDir );
1058
- float dotTV = dot( material.anisotropyT, viewDir );
1059
- float dotTH = dot( material.anisotropyT, halfDir );
1060
- float dotBL = dot( material.anisotropyB, lightDir );
1061
- float dotBV = dot( material.anisotropyB, viewDir );
1062
- float dotBH = dot( material.anisotropyB, halfDir );
1063
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1064
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1065
- #else
1066
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1067
- float D = D_GGX( alpha, dotNH );
1068
- #endif
1069
- return F * ( V * D );
1070
- }
1071
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1072
- const float LUT_SIZE = 64.0;
1073
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1074
- const float LUT_BIAS = 0.5 / LUT_SIZE;
1075
- float dotNV = saturate( dot( N, V ) );
1076
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1077
- uv = uv * LUT_SCALE + LUT_BIAS;
1078
- return uv;
1079
- }
1080
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1081
- float l = length( f );
1082
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1083
- }
1084
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1085
- float x = dot( v1, v2 );
1086
- float y = abs( x );
1087
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1088
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
1089
- float v = a / b;
1090
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1091
- return cross( v1, v2 ) * theta_sintheta;
1092
- }
1093
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1094
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1095
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1096
- vec3 lightNormal = cross( v1, v2 );
1097
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1098
- vec3 T1, T2;
1099
- T1 = normalize( V - N * dot( V, N ) );
1100
- T2 = - cross( N, T1 );
1101
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1102
- vec3 coords[ 4 ];
1103
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1104
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1105
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1106
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1107
- coords[ 0 ] = normalize( coords[ 0 ] );
1108
- coords[ 1 ] = normalize( coords[ 1 ] );
1109
- coords[ 2 ] = normalize( coords[ 2 ] );
1110
- coords[ 3 ] = normalize( coords[ 3 ] );
1111
- vec3 vectorFormFactor = vec3( 0.0 );
1112
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1113
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1114
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1115
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1116
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1117
- return vec3( result );
1118
- }
1119
- #if defined( USE_SHEEN )
1120
- float D_Charlie( float roughness, float dotNH ) {
1121
- float alpha = pow2( roughness );
1122
- float invAlpha = 1.0 / alpha;
1123
- float cos2h = dotNH * dotNH;
1124
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
1125
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1126
- }
1127
- float V_Neubelt( float dotNV, float dotNL ) {
1128
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1129
- }
1130
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1131
- vec3 halfDir = normalize( lightDir + viewDir );
1132
- float dotNL = saturate( dot( normal, lightDir ) );
1133
- float dotNV = saturate( dot( normal, viewDir ) );
1134
- float dotNH = saturate( dot( normal, halfDir ) );
1135
- float D = D_Charlie( sheenRoughness, dotNH );
1136
- float V = V_Neubelt( dotNV, dotNL );
1137
- return sheenColor * ( D * V );
1138
- }
1139
- #endif
1140
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1141
- float dotNV = saturate( dot( normal, viewDir ) );
1142
- float r2 = roughness * roughness;
1143
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1144
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1145
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1146
- return saturate( DG * RECIPROCAL_PI );
1147
- }
1148
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1149
- float dotNV = saturate( dot( normal, viewDir ) );
1150
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1151
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1152
- vec4 r = roughness * c0 + c1;
1153
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1154
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1155
- return fab;
1156
- }
1157
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1158
- vec2 fab = DFGApprox( normal, viewDir, roughness );
1159
- return specularColor * fab.x + specularF90 * fab.y;
1160
- }
1161
- #ifdef USE_IRIDESCENCE
1162
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1163
- #else
1164
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1165
- #endif
1166
- vec2 fab = DFGApprox( normal, viewDir, roughness );
1167
- #ifdef USE_IRIDESCENCE
1168
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1169
- #else
1170
- vec3 Fr = specularColor;
1171
- #endif
1172
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1173
- float Ess = fab.x + fab.y;
1174
- float Ems = 1.0 - Ess;
1175
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1176
- singleScatter += FssEss;
1177
- multiScatter += Fms * Ems;
1178
- }
1179
- #if NUM_RECT_AREA_LIGHTS > 0
1180
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1181
- vec3 normal = geometryNormal;
1182
- vec3 viewDir = geometryViewDir;
1183
- vec3 position = geometryPosition;
1184
- vec3 lightPos = rectAreaLight.position;
1185
- vec3 halfWidth = rectAreaLight.halfWidth;
1186
- vec3 halfHeight = rectAreaLight.halfHeight;
1187
- vec3 lightColor = rectAreaLight.color;
1188
- float roughness = material.roughness;
1189
- vec3 rectCoords[ 4 ];
1190
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1191
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1192
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1193
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
1194
- vec4 t1 = texture2D( ltc_1, uv );
1195
- vec4 t2 = texture2D( ltc_2, uv );
1196
- mat3 mInv = mat3(
1197
- vec3( t1.x, 0, t1.y ),
1198
- vec3( 0, 1, 0 ),
1199
- vec3( t1.z, 0, t1.w )
1200
- );
1201
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1202
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1203
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1204
- }
1205
- #endif
1206
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1207
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1208
- vec3 irradiance = dotNL * directLight.color;
1209
- #ifdef USE_CLEARCOAT
1210
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1211
- vec3 ccIrradiance = dotNLcc * directLight.color;
1212
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1213
- #endif
1214
- #ifdef USE_SHEEN
1215
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1216
- #endif
1217
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1218
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1219
- }
1220
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1221
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1222
- }
1223
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
1224
- #ifdef USE_CLEARCOAT
1225
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1226
- #endif
1227
- #ifdef USE_SHEEN
1228
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1229
- #endif
1230
- vec3 singleScattering = vec3( 0.0 );
1231
- vec3 multiScattering = vec3( 0.0 );
1232
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1233
- #ifdef USE_IRIDESCENCE
1234
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1235
- #else
1236
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1237
- #endif
1238
- vec3 totalScattering = singleScattering + multiScattering;
1239
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1240
- reflectedLight.indirectSpecular += radiance * singleScattering;
1241
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1242
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1243
- }
1244
- #define RE_Direct RE_Direct_Physical
1245
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1246
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1247
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1248
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1249
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1250
- }`,pf=`
1251
- vec3 geometryPosition = - vViewPosition;
1252
- vec3 geometryNormal = normal;
1253
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1254
- vec3 geometryClearcoatNormal = vec3( 0.0 );
1255
- #ifdef USE_CLEARCOAT
1256
- geometryClearcoatNormal = clearcoatNormal;
1257
- #endif
1258
- #ifdef USE_IRIDESCENCE
1259
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
1260
- if ( material.iridescenceThickness == 0.0 ) {
1261
- material.iridescence = 0.0;
1262
- } else {
1263
- material.iridescence = saturate( material.iridescence );
1264
- }
1265
- if ( material.iridescence > 0.0 ) {
1266
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1267
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1268
- }
1269
- #endif
1270
- IncidentLight directLight;
1271
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1272
- PointLight pointLight;
1273
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1274
- PointLightShadow pointLightShadow;
1275
- #endif
1276
- #pragma unroll_loop_start
1277
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1278
- pointLight = pointLights[ i ];
1279
- getPointLightInfo( pointLight, geometryPosition, directLight );
1280
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1281
- pointLightShadow = pointLightShadows[ i ];
1282
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1283
- #endif
1284
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1285
- }
1286
- #pragma unroll_loop_end
1287
- #endif
1288
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1289
- SpotLight spotLight;
1290
- vec4 spotColor;
1291
- vec3 spotLightCoord;
1292
- bool inSpotLightMap;
1293
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1294
- SpotLightShadow spotLightShadow;
1295
- #endif
1296
- #pragma unroll_loop_start
1297
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1298
- spotLight = spotLights[ i ];
1299
- getSpotLightInfo( spotLight, geometryPosition, directLight );
1300
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1301
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1302
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1303
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1304
- #else
1305
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1306
- #endif
1307
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1308
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1309
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1310
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1311
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1312
- #endif
1313
- #undef SPOT_LIGHT_MAP_INDEX
1314
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1315
- spotLightShadow = spotLightShadows[ i ];
1316
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1317
- #endif
1318
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1319
- }
1320
- #pragma unroll_loop_end
1321
- #endif
1322
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1323
- DirectionalLight directionalLight;
1324
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1325
- DirectionalLightShadow directionalLightShadow;
1326
- #endif
1327
- #pragma unroll_loop_start
1328
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1329
- directionalLight = directionalLights[ i ];
1330
- getDirectionalLightInfo( directionalLight, directLight );
1331
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1332
- directionalLightShadow = directionalLightShadows[ i ];
1333
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1334
- #endif
1335
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1336
- }
1337
- #pragma unroll_loop_end
1338
- #endif
1339
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1340
- RectAreaLight rectAreaLight;
1341
- #pragma unroll_loop_start
1342
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1343
- rectAreaLight = rectAreaLights[ i ];
1344
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1345
- }
1346
- #pragma unroll_loop_end
1347
- #endif
1348
- #if defined( RE_IndirectDiffuse )
1349
- vec3 iblIrradiance = vec3( 0.0 );
1350
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1351
- #if defined( USE_LIGHT_PROBES )
1352
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1353
- #endif
1354
- #if ( NUM_HEMI_LIGHTS > 0 )
1355
- #pragma unroll_loop_start
1356
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1357
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1358
- }
1359
- #pragma unroll_loop_end
1360
- #endif
1361
- #endif
1362
- #if defined( RE_IndirectSpecular )
1363
- vec3 radiance = vec3( 0.0 );
1364
- vec3 clearcoatRadiance = vec3( 0.0 );
1365
- #endif`,mf=`#if defined( RE_IndirectDiffuse )
1366
- #ifdef USE_LIGHTMAP
1367
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1368
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1369
- irradiance += lightMapIrradiance;
1370
- #endif
1371
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1372
- iblIrradiance += getIBLIrradiance( geometryNormal );
1373
- #endif
1374
- #endif
1375
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1376
- #ifdef USE_ANISOTROPY
1377
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1378
- #else
1379
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1380
- #endif
1381
- #ifdef USE_CLEARCOAT
1382
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1383
- #endif
1384
- #endif`,_f=`#if defined( RE_IndirectDiffuse )
1385
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1386
- #endif
1387
- #if defined( RE_IndirectSpecular )
1388
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1389
- #endif`,gf=`#if defined( USE_LOGDEPTHBUF )
1390
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1391
- #endif`,vf=`#if defined( USE_LOGDEPTHBUF )
1392
- uniform float logDepthBufFC;
1393
- varying float vFragDepth;
1394
- varying float vIsPerspective;
1395
- #endif`,xf=`#ifdef USE_LOGDEPTHBUF
1396
- varying float vFragDepth;
1397
- varying float vIsPerspective;
1398
- #endif`,Mf=`#ifdef USE_LOGDEPTHBUF
1399
- vFragDepth = 1.0 + gl_Position.w;
1400
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1401
- #endif`,Sf=`#ifdef USE_MAP
1402
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1403
- #ifdef DECODE_VIDEO_TEXTURE
1404
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1405
- #endif
1406
- diffuseColor *= sampledDiffuseColor;
1407
- #endif`,yf=`#ifdef USE_MAP
1408
- uniform sampler2D map;
1409
- #endif`,Ef=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1410
- #if defined( USE_POINTS_UV )
1411
- vec2 uv = vUv;
1412
- #else
1413
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1414
- #endif
1415
- #endif
1416
- #ifdef USE_MAP
1417
- diffuseColor *= texture2D( map, uv );
1418
- #endif
1419
- #ifdef USE_ALPHAMAP
1420
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
1421
- #endif`,Tf=`#if defined( USE_POINTS_UV )
1422
- varying vec2 vUv;
1423
- #else
1424
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1425
- uniform mat3 uvTransform;
1426
- #endif
1427
- #endif
1428
- #ifdef USE_MAP
1429
- uniform sampler2D map;
1430
- #endif
1431
- #ifdef USE_ALPHAMAP
1432
- uniform sampler2D alphaMap;
1433
- #endif`,bf=`float metalnessFactor = metalness;
1434
- #ifdef USE_METALNESSMAP
1435
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1436
- metalnessFactor *= texelMetalness.b;
1437
- #endif`,Af=`#ifdef USE_METALNESSMAP
1438
- uniform sampler2D metalnessMap;
1439
- #endif`,wf=`#ifdef USE_INSTANCING_MORPH
1440
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1441
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1442
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1443
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1444
- }
1445
- #endif`,Rf=`#if defined( USE_MORPHCOLORS )
1446
- vColor *= morphTargetBaseInfluence;
1447
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1448
- #if defined( USE_COLOR_ALPHA )
1449
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1450
- #elif defined( USE_COLOR )
1451
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1452
- #endif
1453
- }
1454
- #endif`,Cf=`#ifdef USE_MORPHNORMALS
1455
- objectNormal *= morphTargetBaseInfluence;
1456
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1457
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1458
- }
1459
- #endif`,Pf=`#ifdef USE_MORPHTARGETS
1460
- #ifndef USE_INSTANCING_MORPH
1461
- uniform float morphTargetBaseInfluence;
1462
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1463
- #endif
1464
- uniform sampler2DArray morphTargetsTexture;
1465
- uniform ivec2 morphTargetsTextureSize;
1466
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1467
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1468
- int y = texelIndex / morphTargetsTextureSize.x;
1469
- int x = texelIndex - y * morphTargetsTextureSize.x;
1470
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1471
- return texelFetch( morphTargetsTexture, morphUV, 0 );
1472
- }
1473
- #endif`,Df=`#ifdef USE_MORPHTARGETS
1474
- transformed *= morphTargetBaseInfluence;
1475
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1476
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1477
- }
1478
- #endif`,Lf=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1479
- #ifdef FLAT_SHADED
1480
- vec3 fdx = dFdx( vViewPosition );
1481
- vec3 fdy = dFdy( vViewPosition );
1482
- vec3 normal = normalize( cross( fdx, fdy ) );
1483
- #else
1484
- vec3 normal = normalize( vNormal );
1485
- #ifdef DOUBLE_SIDED
1486
- normal *= faceDirection;
1487
- #endif
1488
- #endif
1489
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1490
- #ifdef USE_TANGENT
1491
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1492
- #else
1493
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
1494
- #if defined( USE_NORMALMAP )
1495
- vNormalMapUv
1496
- #elif defined( USE_CLEARCOAT_NORMALMAP )
1497
- vClearcoatNormalMapUv
1498
- #else
1499
- vUv
1500
- #endif
1501
- );
1502
- #endif
1503
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1504
- tbn[0] *= faceDirection;
1505
- tbn[1] *= faceDirection;
1506
- #endif
1507
- #endif
1508
- #ifdef USE_CLEARCOAT_NORMALMAP
1509
- #ifdef USE_TANGENT
1510
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1511
- #else
1512
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1513
- #endif
1514
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1515
- tbn2[0] *= faceDirection;
1516
- tbn2[1] *= faceDirection;
1517
- #endif
1518
- #endif
1519
- vec3 nonPerturbedNormal = normal;`,Uf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1520
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1521
- #ifdef FLIP_SIDED
1522
- normal = - normal;
1523
- #endif
1524
- #ifdef DOUBLE_SIDED
1525
- normal = normal * faceDirection;
1526
- #endif
1527
- normal = normalize( normalMatrix * normal );
1528
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
1529
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1530
- mapN.xy *= normalScale;
1531
- normal = normalize( tbn * mapN );
1532
- #elif defined( USE_BUMPMAP )
1533
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1534
- #endif`,If=`#ifndef FLAT_SHADED
1535
- varying vec3 vNormal;
1536
- #ifdef USE_TANGENT
1537
- varying vec3 vTangent;
1538
- varying vec3 vBitangent;
1539
- #endif
1540
- #endif`,Nf=`#ifndef FLAT_SHADED
1541
- varying vec3 vNormal;
1542
- #ifdef USE_TANGENT
1543
- varying vec3 vTangent;
1544
- varying vec3 vBitangent;
1545
- #endif
1546
- #endif`,Ff=`#ifndef FLAT_SHADED
1547
- vNormal = normalize( transformedNormal );
1548
- #ifdef USE_TANGENT
1549
- vTangent = normalize( transformedTangent );
1550
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1551
- #endif
1552
- #endif`,Of=`#ifdef USE_NORMALMAP
1553
- uniform sampler2D normalMap;
1554
- uniform vec2 normalScale;
1555
- #endif
1556
- #ifdef USE_NORMALMAP_OBJECTSPACE
1557
- uniform mat3 normalMatrix;
1558
- #endif
1559
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1560
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1561
- vec3 q0 = dFdx( eye_pos.xyz );
1562
- vec3 q1 = dFdy( eye_pos.xyz );
1563
- vec2 st0 = dFdx( uv.st );
1564
- vec2 st1 = dFdy( uv.st );
1565
- vec3 N = surf_norm;
1566
- vec3 q1perp = cross( q1, N );
1567
- vec3 q0perp = cross( N, q0 );
1568
- vec3 T = q1perp * st0.x + q0perp * st1.x;
1569
- vec3 B = q1perp * st0.y + q0perp * st1.y;
1570
- float det = max( dot( T, T ), dot( B, B ) );
1571
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1572
- return mat3( T * scale, B * scale, N );
1573
- }
1574
- #endif`,Bf=`#ifdef USE_CLEARCOAT
1575
- vec3 clearcoatNormal = nonPerturbedNormal;
1576
- #endif`,zf=`#ifdef USE_CLEARCOAT_NORMALMAP
1577
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1578
- clearcoatMapN.xy *= clearcoatNormalScale;
1579
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1580
- #endif`,kf=`#ifdef USE_CLEARCOATMAP
1581
- uniform sampler2D clearcoatMap;
1582
- #endif
1583
- #ifdef USE_CLEARCOAT_NORMALMAP
1584
- uniform sampler2D clearcoatNormalMap;
1585
- uniform vec2 clearcoatNormalScale;
1586
- #endif
1587
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1588
- uniform sampler2D clearcoatRoughnessMap;
1589
- #endif`,Hf=`#ifdef USE_IRIDESCENCEMAP
1590
- uniform sampler2D iridescenceMap;
1591
- #endif
1592
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
1593
- uniform sampler2D iridescenceThicknessMap;
1594
- #endif`,Vf=`#ifdef OPAQUE
1595
- diffuseColor.a = 1.0;
1596
- #endif
1597
- #ifdef USE_TRANSMISSION
1598
- diffuseColor.a *= material.transmissionAlpha;
1599
- #endif
1600
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Gf=`vec3 packNormalToRGB( const in vec3 normal ) {
1601
- return normalize( normal ) * 0.5 + 0.5;
1602
- }
1603
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
1604
- return 2.0 * rgb.xyz - 1.0;
1605
- }
1606
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1607
- const float Inv255 = 1. / 255.;
1608
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1609
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1610
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1611
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1612
- vec4 packDepthToRGBA( const in float v ) {
1613
- if( v <= 0.0 )
1614
- return vec4( 0., 0., 0., 0. );
1615
- if( v >= 1.0 )
1616
- return vec4( 1., 1., 1., 1. );
1617
- float vuf;
1618
- float af = modf( v * PackFactors.a, vuf );
1619
- float bf = modf( vuf * ShiftRight8, vuf );
1620
- float gf = modf( vuf * ShiftRight8, vuf );
1621
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1622
- }
1623
- vec3 packDepthToRGB( const in float v ) {
1624
- if( v <= 0.0 )
1625
- return vec3( 0., 0., 0. );
1626
- if( v >= 1.0 )
1627
- return vec3( 1., 1., 1. );
1628
- float vuf;
1629
- float bf = modf( v * PackFactors.b, vuf );
1630
- float gf = modf( vuf * ShiftRight8, vuf );
1631
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
1632
- }
1633
- vec2 packDepthToRG( const in float v ) {
1634
- if( v <= 0.0 )
1635
- return vec2( 0., 0. );
1636
- if( v >= 1.0 )
1637
- return vec2( 1., 1. );
1638
- float vuf;
1639
- float gf = modf( v * 256., vuf );
1640
- return vec2( vuf * Inv255, gf );
1641
- }
1642
- float unpackRGBAToDepth( const in vec4 v ) {
1643
- return dot( v, UnpackFactors4 );
1644
- }
1645
- float unpackRGBToDepth( const in vec3 v ) {
1646
- return dot( v, UnpackFactors3 );
1647
- }
1648
- float unpackRGToDepth( const in vec2 v ) {
1649
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1650
- }
1651
- vec4 pack2HalfToRGBA( const in vec2 v ) {
1652
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1653
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1654
- }
1655
- vec2 unpackRGBATo2Half( const in vec4 v ) {
1656
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1657
- }
1658
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1659
- return ( viewZ + near ) / ( near - far );
1660
- }
1661
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1662
- return depth * ( near - far ) - near;
1663
- }
1664
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1665
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1666
- }
1667
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1668
- return ( near * far ) / ( ( far - near ) * depth - far );
1669
- }`,Wf=`#ifdef PREMULTIPLIED_ALPHA
1670
- gl_FragColor.rgb *= gl_FragColor.a;
1671
- #endif`,Xf=`vec4 mvPosition = vec4( transformed, 1.0 );
1672
- #ifdef USE_BATCHING
1673
- mvPosition = batchingMatrix * mvPosition;
1674
- #endif
1675
- #ifdef USE_INSTANCING
1676
- mvPosition = instanceMatrix * mvPosition;
1677
- #endif
1678
- mvPosition = modelViewMatrix * mvPosition;
1679
- gl_Position = projectionMatrix * mvPosition;`,qf=`#ifdef DITHERING
1680
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1681
- #endif`,Yf=`#ifdef DITHERING
1682
- vec3 dithering( vec3 color ) {
1683
- float grid_position = rand( gl_FragCoord.xy );
1684
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1685
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1686
- return color + dither_shift_RGB;
1687
- }
1688
- #endif`,jf=`float roughnessFactor = roughness;
1689
- #ifdef USE_ROUGHNESSMAP
1690
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1691
- roughnessFactor *= texelRoughness.g;
1692
- #endif`,Kf=`#ifdef USE_ROUGHNESSMAP
1693
- uniform sampler2D roughnessMap;
1694
- #endif`,Zf=`#if NUM_SPOT_LIGHT_COORDS > 0
1695
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1696
- #endif
1697
- #if NUM_SPOT_LIGHT_MAPS > 0
1698
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1699
- #endif
1700
- #ifdef USE_SHADOWMAP
1701
- #if NUM_DIR_LIGHT_SHADOWS > 0
1702
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1703
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1704
- struct DirectionalLightShadow {
1705
- float shadowIntensity;
1706
- float shadowBias;
1707
- float shadowNormalBias;
1708
- float shadowRadius;
1709
- vec2 shadowMapSize;
1710
- };
1711
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1712
- #endif
1713
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1714
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1715
- struct SpotLightShadow {
1716
- float shadowIntensity;
1717
- float shadowBias;
1718
- float shadowNormalBias;
1719
- float shadowRadius;
1720
- vec2 shadowMapSize;
1721
- };
1722
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1723
- #endif
1724
- #if NUM_POINT_LIGHT_SHADOWS > 0
1725
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1726
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1727
- struct PointLightShadow {
1728
- float shadowIntensity;
1729
- float shadowBias;
1730
- float shadowNormalBias;
1731
- float shadowRadius;
1732
- vec2 shadowMapSize;
1733
- float shadowCameraNear;
1734
- float shadowCameraFar;
1735
- };
1736
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1737
- #endif
1738
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1739
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1740
- }
1741
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1742
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
1743
- }
1744
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1745
- float occlusion = 1.0;
1746
- vec2 distribution = texture2DDistribution( shadow, uv );
1747
- float hard_shadow = step( compare , distribution.x );
1748
- if (hard_shadow != 1.0 ) {
1749
- float distance = compare - distribution.x ;
1750
- float variance = max( 0.00000, distribution.y * distribution.y );
1751
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
1752
- }
1753
- return occlusion;
1754
- }
1755
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1756
- float shadow = 1.0;
1757
- shadowCoord.xyz /= shadowCoord.w;
1758
- shadowCoord.z += shadowBias;
1759
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1760
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1761
- if ( frustumTest ) {
1762
- #if defined( SHADOWMAP_TYPE_PCF )
1763
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1764
- float dx0 = - texelSize.x * shadowRadius;
1765
- float dy0 = - texelSize.y * shadowRadius;
1766
- float dx1 = + texelSize.x * shadowRadius;
1767
- float dy1 = + texelSize.y * shadowRadius;
1768
- float dx2 = dx0 / 2.0;
1769
- float dy2 = dy0 / 2.0;
1770
- float dx3 = dx1 / 2.0;
1771
- float dy3 = dy1 / 2.0;
1772
- shadow = (
1773
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1774
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1775
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1776
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1777
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1778
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1779
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1780
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1781
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1782
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1783
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1784
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1785
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1786
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1787
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1788
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1789
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1790
- ) * ( 1.0 / 17.0 );
1791
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1792
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1793
- float dx = texelSize.x;
1794
- float dy = texelSize.y;
1795
- vec2 uv = shadowCoord.xy;
1796
- vec2 f = fract( uv * shadowMapSize + 0.5 );
1797
- uv -= f * texelSize;
1798
- shadow = (
1799
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1800
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1801
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1802
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1803
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1804
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1805
- f.x ) +
1806
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1807
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1808
- f.x ) +
1809
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1810
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1811
- f.y ) +
1812
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1813
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1814
- f.y ) +
1815
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1816
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1817
- f.x ),
1818
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1819
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1820
- f.x ),
1821
- f.y )
1822
- ) * ( 1.0 / 9.0 );
1823
- #elif defined( SHADOWMAP_TYPE_VSM )
1824
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1825
- #else
1826
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1827
- #endif
1828
- }
1829
- return mix( 1.0, shadow, shadowIntensity );
1830
- }
1831
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
1832
- vec3 absV = abs( v );
1833
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1834
- absV *= scaleToCube;
1835
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1836
- vec2 planar = v.xy;
1837
- float almostATexel = 1.5 * texelSizeY;
1838
- float almostOne = 1.0 - almostATexel;
1839
- if ( absV.z >= almostOne ) {
1840
- if ( v.z > 0.0 )
1841
- planar.x = 4.0 - v.x;
1842
- } else if ( absV.x >= almostOne ) {
1843
- float signX = sign( v.x );
1844
- planar.x = v.z * signX + 2.0 * signX;
1845
- } else if ( absV.y >= almostOne ) {
1846
- float signY = sign( v.y );
1847
- planar.x = v.x + 2.0 * signY + 2.0;
1848
- planar.y = v.z * signY - 2.0;
1849
- }
1850
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1851
- }
1852
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1853
- float shadow = 1.0;
1854
- vec3 lightToPosition = shadowCoord.xyz;
1855
-
1856
- float lightToPositionLength = length( lightToPosition );
1857
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1858
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1859
- vec3 bd3D = normalize( lightToPosition );
1860
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1861
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1862
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1863
- shadow = (
1864
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1865
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1866
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1867
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1868
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1869
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1870
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1871
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1872
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1873
- ) * ( 1.0 / 9.0 );
1874
- #else
1875
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1876
- #endif
1877
- }
1878
- return mix( 1.0, shadow, shadowIntensity );
1879
- }
1880
- #endif`,$f=`#if NUM_SPOT_LIGHT_COORDS > 0
1881
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1882
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1883
- #endif
1884
- #ifdef USE_SHADOWMAP
1885
- #if NUM_DIR_LIGHT_SHADOWS > 0
1886
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1887
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1888
- struct DirectionalLightShadow {
1889
- float shadowIntensity;
1890
- float shadowBias;
1891
- float shadowNormalBias;
1892
- float shadowRadius;
1893
- vec2 shadowMapSize;
1894
- };
1895
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1896
- #endif
1897
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1898
- struct SpotLightShadow {
1899
- float shadowIntensity;
1900
- float shadowBias;
1901
- float shadowNormalBias;
1902
- float shadowRadius;
1903
- vec2 shadowMapSize;
1904
- };
1905
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1906
- #endif
1907
- #if NUM_POINT_LIGHT_SHADOWS > 0
1908
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1909
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1910
- struct PointLightShadow {
1911
- float shadowIntensity;
1912
- float shadowBias;
1913
- float shadowNormalBias;
1914
- float shadowRadius;
1915
- vec2 shadowMapSize;
1916
- float shadowCameraNear;
1917
- float shadowCameraFar;
1918
- };
1919
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1920
- #endif
1921
- #endif`,Jf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1922
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1923
- vec4 shadowWorldPosition;
1924
- #endif
1925
- #if defined( USE_SHADOWMAP )
1926
- #if NUM_DIR_LIGHT_SHADOWS > 0
1927
- #pragma unroll_loop_start
1928
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1929
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1930
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1931
- }
1932
- #pragma unroll_loop_end
1933
- #endif
1934
- #if NUM_POINT_LIGHT_SHADOWS > 0
1935
- #pragma unroll_loop_start
1936
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1937
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1938
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1939
- }
1940
- #pragma unroll_loop_end
1941
- #endif
1942
- #endif
1943
- #if NUM_SPOT_LIGHT_COORDS > 0
1944
- #pragma unroll_loop_start
1945
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1946
- shadowWorldPosition = worldPosition;
1947
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1948
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1949
- #endif
1950
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1951
- }
1952
- #pragma unroll_loop_end
1953
- #endif`,Qf=`float getShadowMask() {
1954
- float shadow = 1.0;
1955
- #ifdef USE_SHADOWMAP
1956
- #if NUM_DIR_LIGHT_SHADOWS > 0
1957
- DirectionalLightShadow directionalLight;
1958
- #pragma unroll_loop_start
1959
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1960
- directionalLight = directionalLightShadows[ i ];
1961
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1962
- }
1963
- #pragma unroll_loop_end
1964
- #endif
1965
- #if NUM_SPOT_LIGHT_SHADOWS > 0
1966
- SpotLightShadow spotLight;
1967
- #pragma unroll_loop_start
1968
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1969
- spotLight = spotLightShadows[ i ];
1970
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1971
- }
1972
- #pragma unroll_loop_end
1973
- #endif
1974
- #if NUM_POINT_LIGHT_SHADOWS > 0
1975
- PointLightShadow pointLight;
1976
- #pragma unroll_loop_start
1977
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1978
- pointLight = pointLightShadows[ i ];
1979
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1980
- }
1981
- #pragma unroll_loop_end
1982
- #endif
1983
- #endif
1984
- return shadow;
1985
- }`,ed=`#ifdef USE_SKINNING
1986
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
1987
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
1988
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1989
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
1990
- #endif`,td=`#ifdef USE_SKINNING
1991
- uniform mat4 bindMatrix;
1992
- uniform mat4 bindMatrixInverse;
1993
- uniform highp sampler2D boneTexture;
1994
- mat4 getBoneMatrix( const in float i ) {
1995
- int size = textureSize( boneTexture, 0 ).x;
1996
- int j = int( i ) * 4;
1997
- int x = j % size;
1998
- int y = j / size;
1999
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
2000
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
2001
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2002
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2003
- return mat4( v1, v2, v3, v4 );
2004
- }
2005
- #endif`,nd=`#ifdef USE_SKINNING
2006
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2007
- vec4 skinned = vec4( 0.0 );
2008
- skinned += boneMatX * skinVertex * skinWeight.x;
2009
- skinned += boneMatY * skinVertex * skinWeight.y;
2010
- skinned += boneMatZ * skinVertex * skinWeight.z;
2011
- skinned += boneMatW * skinVertex * skinWeight.w;
2012
- transformed = ( bindMatrixInverse * skinned ).xyz;
2013
- #endif`,id=`#ifdef USE_SKINNING
2014
- mat4 skinMatrix = mat4( 0.0 );
2015
- skinMatrix += skinWeight.x * boneMatX;
2016
- skinMatrix += skinWeight.y * boneMatY;
2017
- skinMatrix += skinWeight.z * boneMatZ;
2018
- skinMatrix += skinWeight.w * boneMatW;
2019
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2020
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2021
- #ifdef USE_TANGENT
2022
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2023
- #endif
2024
- #endif`,rd=`float specularStrength;
2025
- #ifdef USE_SPECULARMAP
2026
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2027
- specularStrength = texelSpecular.r;
2028
- #else
2029
- specularStrength = 1.0;
2030
- #endif`,sd=`#ifdef USE_SPECULARMAP
2031
- uniform sampler2D specularMap;
2032
- #endif`,ad=`#if defined( TONE_MAPPING )
2033
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2034
- #endif`,od=`#ifndef saturate
2035
- #define saturate( a ) clamp( a, 0.0, 1.0 )
2036
- #endif
2037
- uniform float toneMappingExposure;
2038
- vec3 LinearToneMapping( vec3 color ) {
2039
- return saturate( toneMappingExposure * color );
2040
- }
2041
- vec3 ReinhardToneMapping( vec3 color ) {
2042
- color *= toneMappingExposure;
2043
- return saturate( color / ( vec3( 1.0 ) + color ) );
2044
- }
2045
- vec3 CineonToneMapping( vec3 color ) {
2046
- color *= toneMappingExposure;
2047
- color = max( vec3( 0.0 ), color - 0.004 );
2048
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2049
- }
2050
- vec3 RRTAndODTFit( vec3 v ) {
2051
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2052
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2053
- return a / b;
2054
- }
2055
- vec3 ACESFilmicToneMapping( vec3 color ) {
2056
- const mat3 ACESInputMat = mat3(
2057
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2058
- vec3( 0.04823, 0.01566, 0.83777 )
2059
- );
2060
- const mat3 ACESOutputMat = mat3(
2061
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2062
- vec3( -0.07367, -0.00605, 1.07602 )
2063
- );
2064
- color *= toneMappingExposure / 0.6;
2065
- color = ACESInputMat * color;
2066
- color = RRTAndODTFit( color );
2067
- color = ACESOutputMat * color;
2068
- return saturate( color );
2069
- }
2070
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2071
- vec3( 1.6605, - 0.1246, - 0.0182 ),
2072
- vec3( - 0.5876, 1.1329, - 0.1006 ),
2073
- vec3( - 0.0728, - 0.0083, 1.1187 )
2074
- );
2075
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2076
- vec3( 0.6274, 0.0691, 0.0164 ),
2077
- vec3( 0.3293, 0.9195, 0.0880 ),
2078
- vec3( 0.0433, 0.0113, 0.8956 )
2079
- );
2080
- vec3 agxDefaultContrastApprox( vec3 x ) {
2081
- vec3 x2 = x * x;
2082
- vec3 x4 = x2 * x2;
2083
- return + 15.5 * x4 * x2
2084
- - 40.14 * x4 * x
2085
- + 31.96 * x4
2086
- - 6.868 * x2 * x
2087
- + 0.4298 * x2
2088
- + 0.1191 * x
2089
- - 0.00232;
2090
- }
2091
- vec3 AgXToneMapping( vec3 color ) {
2092
- const mat3 AgXInsetMatrix = mat3(
2093
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2094
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2095
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2096
- );
2097
- const mat3 AgXOutsetMatrix = mat3(
2098
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2099
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2100
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2101
- );
2102
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2103
- color *= toneMappingExposure;
2104
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2105
- color = AgXInsetMatrix * color;
2106
- color = max( color, 1e-10 ); color = log2( color );
2107
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2108
- color = clamp( color, 0.0, 1.0 );
2109
- color = agxDefaultContrastApprox( color );
2110
- color = AgXOutsetMatrix * color;
2111
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2112
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2113
- color = clamp( color, 0.0, 1.0 );
2114
- return color;
2115
- }
2116
- vec3 NeutralToneMapping( vec3 color ) {
2117
- const float StartCompression = 0.8 - 0.04;
2118
- const float Desaturation = 0.15;
2119
- color *= toneMappingExposure;
2120
- float x = min( color.r, min( color.g, color.b ) );
2121
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2122
- color -= offset;
2123
- float peak = max( color.r, max( color.g, color.b ) );
2124
- if ( peak < StartCompression ) return color;
2125
- float d = 1. - StartCompression;
2126
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
2127
- color *= newPeak / peak;
2128
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2129
- return mix( color, vec3( newPeak ), g );
2130
- }
2131
- vec3 CustomToneMapping( vec3 color ) { return color; }`,ld=`#ifdef USE_TRANSMISSION
2132
- material.transmission = transmission;
2133
- material.transmissionAlpha = 1.0;
2134
- material.thickness = thickness;
2135
- material.attenuationDistance = attenuationDistance;
2136
- material.attenuationColor = attenuationColor;
2137
- #ifdef USE_TRANSMISSIONMAP
2138
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2139
- #endif
2140
- #ifdef USE_THICKNESSMAP
2141
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2142
- #endif
2143
- vec3 pos = vWorldPosition;
2144
- vec3 v = normalize( cameraPosition - pos );
2145
- vec3 n = inverseTransformDirection( normal, viewMatrix );
2146
- vec4 transmitted = getIBLVolumeRefraction(
2147
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2148
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2149
- material.attenuationColor, material.attenuationDistance );
2150
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2151
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2152
- #endif`,cd=`#ifdef USE_TRANSMISSION
2153
- uniform float transmission;
2154
- uniform float thickness;
2155
- uniform float attenuationDistance;
2156
- uniform vec3 attenuationColor;
2157
- #ifdef USE_TRANSMISSIONMAP
2158
- uniform sampler2D transmissionMap;
2159
- #endif
2160
- #ifdef USE_THICKNESSMAP
2161
- uniform sampler2D thicknessMap;
2162
- #endif
2163
- uniform vec2 transmissionSamplerSize;
2164
- uniform sampler2D transmissionSamplerMap;
2165
- uniform mat4 modelMatrix;
2166
- uniform mat4 projectionMatrix;
2167
- varying vec3 vWorldPosition;
2168
- float w0( float a ) {
2169
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2170
- }
2171
- float w1( float a ) {
2172
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2173
- }
2174
- float w2( float a ){
2175
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2176
- }
2177
- float w3( float a ) {
2178
- return ( 1.0 / 6.0 ) * ( a * a * a );
2179
- }
2180
- float g0( float a ) {
2181
- return w0( a ) + w1( a );
2182
- }
2183
- float g1( float a ) {
2184
- return w2( a ) + w3( a );
2185
- }
2186
- float h0( float a ) {
2187
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2188
- }
2189
- float h1( float a ) {
2190
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2191
- }
2192
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2193
- uv = uv * texelSize.zw + 0.5;
2194
- vec2 iuv = floor( uv );
2195
- vec2 fuv = fract( uv );
2196
- float g0x = g0( fuv.x );
2197
- float g1x = g1( fuv.x );
2198
- float h0x = h0( fuv.x );
2199
- float h1x = h1( fuv.x );
2200
- float h0y = h0( fuv.y );
2201
- float h1y = h1( fuv.y );
2202
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2203
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2204
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2205
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2206
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2207
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2208
- }
2209
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2210
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2211
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2212
- vec2 fLodSizeInv = 1.0 / fLodSize;
2213
- vec2 cLodSizeInv = 1.0 / cLodSize;
2214
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2215
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2216
- return mix( fSample, cSample, fract( lod ) );
2217
- }
2218
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2219
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2220
- vec3 modelScale;
2221
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2222
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2223
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2224
- return normalize( refractionVector ) * thickness * modelScale;
2225
- }
2226
- float applyIorToRoughness( const in float roughness, const in float ior ) {
2227
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2228
- }
2229
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2230
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2231
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2232
- }
2233
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2234
- if ( isinf( attenuationDistance ) ) {
2235
- return vec3( 1.0 );
2236
- } else {
2237
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2238
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2239
- }
2240
- }
2241
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2242
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2243
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2244
- const in vec3 attenuationColor, const in float attenuationDistance ) {
2245
- vec4 transmittedLight;
2246
- vec3 transmittance;
2247
- #ifdef USE_DISPERSION
2248
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2249
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2250
- for ( int i = 0; i < 3; i ++ ) {
2251
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2252
- vec3 refractedRayExit = position + transmissionRay;
2253
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2254
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2255
- refractionCoords += 1.0;
2256
- refractionCoords /= 2.0;
2257
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2258
- transmittedLight[ i ] = transmissionSample[ i ];
2259
- transmittedLight.a += transmissionSample.a;
2260
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2261
- }
2262
- transmittedLight.a /= 3.0;
2263
- #else
2264
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2265
- vec3 refractedRayExit = position + transmissionRay;
2266
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2267
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2268
- refractionCoords += 1.0;
2269
- refractionCoords /= 2.0;
2270
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2271
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2272
- #endif
2273
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2274
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2275
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2276
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2277
- }
2278
- #endif`,hd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2279
- varying vec2 vUv;
2280
- #endif
2281
- #ifdef USE_MAP
2282
- varying vec2 vMapUv;
2283
- #endif
2284
- #ifdef USE_ALPHAMAP
2285
- varying vec2 vAlphaMapUv;
2286
- #endif
2287
- #ifdef USE_LIGHTMAP
2288
- varying vec2 vLightMapUv;
2289
- #endif
2290
- #ifdef USE_AOMAP
2291
- varying vec2 vAoMapUv;
2292
- #endif
2293
- #ifdef USE_BUMPMAP
2294
- varying vec2 vBumpMapUv;
2295
- #endif
2296
- #ifdef USE_NORMALMAP
2297
- varying vec2 vNormalMapUv;
2298
- #endif
2299
- #ifdef USE_EMISSIVEMAP
2300
- varying vec2 vEmissiveMapUv;
2301
- #endif
2302
- #ifdef USE_METALNESSMAP
2303
- varying vec2 vMetalnessMapUv;
2304
- #endif
2305
- #ifdef USE_ROUGHNESSMAP
2306
- varying vec2 vRoughnessMapUv;
2307
- #endif
2308
- #ifdef USE_ANISOTROPYMAP
2309
- varying vec2 vAnisotropyMapUv;
2310
- #endif
2311
- #ifdef USE_CLEARCOATMAP
2312
- varying vec2 vClearcoatMapUv;
2313
- #endif
2314
- #ifdef USE_CLEARCOAT_NORMALMAP
2315
- varying vec2 vClearcoatNormalMapUv;
2316
- #endif
2317
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2318
- varying vec2 vClearcoatRoughnessMapUv;
2319
- #endif
2320
- #ifdef USE_IRIDESCENCEMAP
2321
- varying vec2 vIridescenceMapUv;
2322
- #endif
2323
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2324
- varying vec2 vIridescenceThicknessMapUv;
2325
- #endif
2326
- #ifdef USE_SHEEN_COLORMAP
2327
- varying vec2 vSheenColorMapUv;
2328
- #endif
2329
- #ifdef USE_SHEEN_ROUGHNESSMAP
2330
- varying vec2 vSheenRoughnessMapUv;
2331
- #endif
2332
- #ifdef USE_SPECULARMAP
2333
- varying vec2 vSpecularMapUv;
2334
- #endif
2335
- #ifdef USE_SPECULAR_COLORMAP
2336
- varying vec2 vSpecularColorMapUv;
2337
- #endif
2338
- #ifdef USE_SPECULAR_INTENSITYMAP
2339
- varying vec2 vSpecularIntensityMapUv;
2340
- #endif
2341
- #ifdef USE_TRANSMISSIONMAP
2342
- uniform mat3 transmissionMapTransform;
2343
- varying vec2 vTransmissionMapUv;
2344
- #endif
2345
- #ifdef USE_THICKNESSMAP
2346
- uniform mat3 thicknessMapTransform;
2347
- varying vec2 vThicknessMapUv;
2348
- #endif`,ud=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2349
- varying vec2 vUv;
2350
- #endif
2351
- #ifdef USE_MAP
2352
- uniform mat3 mapTransform;
2353
- varying vec2 vMapUv;
2354
- #endif
2355
- #ifdef USE_ALPHAMAP
2356
- uniform mat3 alphaMapTransform;
2357
- varying vec2 vAlphaMapUv;
2358
- #endif
2359
- #ifdef USE_LIGHTMAP
2360
- uniform mat3 lightMapTransform;
2361
- varying vec2 vLightMapUv;
2362
- #endif
2363
- #ifdef USE_AOMAP
2364
- uniform mat3 aoMapTransform;
2365
- varying vec2 vAoMapUv;
2366
- #endif
2367
- #ifdef USE_BUMPMAP
2368
- uniform mat3 bumpMapTransform;
2369
- varying vec2 vBumpMapUv;
2370
- #endif
2371
- #ifdef USE_NORMALMAP
2372
- uniform mat3 normalMapTransform;
2373
- varying vec2 vNormalMapUv;
2374
- #endif
2375
- #ifdef USE_DISPLACEMENTMAP
2376
- uniform mat3 displacementMapTransform;
2377
- varying vec2 vDisplacementMapUv;
2378
- #endif
2379
- #ifdef USE_EMISSIVEMAP
2380
- uniform mat3 emissiveMapTransform;
2381
- varying vec2 vEmissiveMapUv;
2382
- #endif
2383
- #ifdef USE_METALNESSMAP
2384
- uniform mat3 metalnessMapTransform;
2385
- varying vec2 vMetalnessMapUv;
2386
- #endif
2387
- #ifdef USE_ROUGHNESSMAP
2388
- uniform mat3 roughnessMapTransform;
2389
- varying vec2 vRoughnessMapUv;
2390
- #endif
2391
- #ifdef USE_ANISOTROPYMAP
2392
- uniform mat3 anisotropyMapTransform;
2393
- varying vec2 vAnisotropyMapUv;
2394
- #endif
2395
- #ifdef USE_CLEARCOATMAP
2396
- uniform mat3 clearcoatMapTransform;
2397
- varying vec2 vClearcoatMapUv;
2398
- #endif
2399
- #ifdef USE_CLEARCOAT_NORMALMAP
2400
- uniform mat3 clearcoatNormalMapTransform;
2401
- varying vec2 vClearcoatNormalMapUv;
2402
- #endif
2403
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2404
- uniform mat3 clearcoatRoughnessMapTransform;
2405
- varying vec2 vClearcoatRoughnessMapUv;
2406
- #endif
2407
- #ifdef USE_SHEEN_COLORMAP
2408
- uniform mat3 sheenColorMapTransform;
2409
- varying vec2 vSheenColorMapUv;
2410
- #endif
2411
- #ifdef USE_SHEEN_ROUGHNESSMAP
2412
- uniform mat3 sheenRoughnessMapTransform;
2413
- varying vec2 vSheenRoughnessMapUv;
2414
- #endif
2415
- #ifdef USE_IRIDESCENCEMAP
2416
- uniform mat3 iridescenceMapTransform;
2417
- varying vec2 vIridescenceMapUv;
2418
- #endif
2419
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2420
- uniform mat3 iridescenceThicknessMapTransform;
2421
- varying vec2 vIridescenceThicknessMapUv;
2422
- #endif
2423
- #ifdef USE_SPECULARMAP
2424
- uniform mat3 specularMapTransform;
2425
- varying vec2 vSpecularMapUv;
2426
- #endif
2427
- #ifdef USE_SPECULAR_COLORMAP
2428
- uniform mat3 specularColorMapTransform;
2429
- varying vec2 vSpecularColorMapUv;
2430
- #endif
2431
- #ifdef USE_SPECULAR_INTENSITYMAP
2432
- uniform mat3 specularIntensityMapTransform;
2433
- varying vec2 vSpecularIntensityMapUv;
2434
- #endif
2435
- #ifdef USE_TRANSMISSIONMAP
2436
- uniform mat3 transmissionMapTransform;
2437
- varying vec2 vTransmissionMapUv;
2438
- #endif
2439
- #ifdef USE_THICKNESSMAP
2440
- uniform mat3 thicknessMapTransform;
2441
- varying vec2 vThicknessMapUv;
2442
- #endif`,fd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2443
- vUv = vec3( uv, 1 ).xy;
2444
- #endif
2445
- #ifdef USE_MAP
2446
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2447
- #endif
2448
- #ifdef USE_ALPHAMAP
2449
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2450
- #endif
2451
- #ifdef USE_LIGHTMAP
2452
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2453
- #endif
2454
- #ifdef USE_AOMAP
2455
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2456
- #endif
2457
- #ifdef USE_BUMPMAP
2458
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2459
- #endif
2460
- #ifdef USE_NORMALMAP
2461
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2462
- #endif
2463
- #ifdef USE_DISPLACEMENTMAP
2464
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2465
- #endif
2466
- #ifdef USE_EMISSIVEMAP
2467
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2468
- #endif
2469
- #ifdef USE_METALNESSMAP
2470
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2471
- #endif
2472
- #ifdef USE_ROUGHNESSMAP
2473
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2474
- #endif
2475
- #ifdef USE_ANISOTROPYMAP
2476
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2477
- #endif
2478
- #ifdef USE_CLEARCOATMAP
2479
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2480
- #endif
2481
- #ifdef USE_CLEARCOAT_NORMALMAP
2482
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2483
- #endif
2484
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2485
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2486
- #endif
2487
- #ifdef USE_IRIDESCENCEMAP
2488
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2489
- #endif
2490
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
2491
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2492
- #endif
2493
- #ifdef USE_SHEEN_COLORMAP
2494
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2495
- #endif
2496
- #ifdef USE_SHEEN_ROUGHNESSMAP
2497
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2498
- #endif
2499
- #ifdef USE_SPECULARMAP
2500
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2501
- #endif
2502
- #ifdef USE_SPECULAR_COLORMAP
2503
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2504
- #endif
2505
- #ifdef USE_SPECULAR_INTENSITYMAP
2506
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2507
- #endif
2508
- #ifdef USE_TRANSMISSIONMAP
2509
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2510
- #endif
2511
- #ifdef USE_THICKNESSMAP
2512
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2513
- #endif`,dd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2514
- vec4 worldPosition = vec4( transformed, 1.0 );
2515
- #ifdef USE_BATCHING
2516
- worldPosition = batchingMatrix * worldPosition;
2517
- #endif
2518
- #ifdef USE_INSTANCING
2519
- worldPosition = instanceMatrix * worldPosition;
2520
- #endif
2521
- worldPosition = modelMatrix * worldPosition;
2522
- #endif`;const pd=`varying vec2 vUv;
2523
- uniform mat3 uvTransform;
2524
- void main() {
2525
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2526
- gl_Position = vec4( position.xy, 1.0, 1.0 );
2527
- }`,md=`uniform sampler2D t2D;
2528
- uniform float backgroundIntensity;
2529
- varying vec2 vUv;
2530
- void main() {
2531
- vec4 texColor = texture2D( t2D, vUv );
2532
- #ifdef DECODE_VIDEO_TEXTURE
2533
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
2534
- #endif
2535
- texColor.rgb *= backgroundIntensity;
2536
- gl_FragColor = texColor;
2537
- #include <tonemapping_fragment>
2538
- #include <colorspace_fragment>
2539
- }`,_d=`varying vec3 vWorldDirection;
2540
- #include <common>
2541
- void main() {
2542
- vWorldDirection = transformDirection( position, modelMatrix );
2543
- #include <begin_vertex>
2544
- #include <project_vertex>
2545
- gl_Position.z = gl_Position.w;
2546
- }`,gd=`#ifdef ENVMAP_TYPE_CUBE
2547
- uniform samplerCube envMap;
2548
- #elif defined( ENVMAP_TYPE_CUBE_UV )
2549
- uniform sampler2D envMap;
2550
- #endif
2551
- uniform float flipEnvMap;
2552
- uniform float backgroundBlurriness;
2553
- uniform float backgroundIntensity;
2554
- uniform mat3 backgroundRotation;
2555
- varying vec3 vWorldDirection;
2556
- #include <cube_uv_reflection_fragment>
2557
- void main() {
2558
- #ifdef ENVMAP_TYPE_CUBE
2559
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2560
- #elif defined( ENVMAP_TYPE_CUBE_UV )
2561
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2562
- #else
2563
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2564
- #endif
2565
- texColor.rgb *= backgroundIntensity;
2566
- gl_FragColor = texColor;
2567
- #include <tonemapping_fragment>
2568
- #include <colorspace_fragment>
2569
- }`,vd=`varying vec3 vWorldDirection;
2570
- #include <common>
2571
- void main() {
2572
- vWorldDirection = transformDirection( position, modelMatrix );
2573
- #include <begin_vertex>
2574
- #include <project_vertex>
2575
- gl_Position.z = gl_Position.w;
2576
- }`,xd=`uniform samplerCube tCube;
2577
- uniform float tFlip;
2578
- uniform float opacity;
2579
- varying vec3 vWorldDirection;
2580
- void main() {
2581
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2582
- gl_FragColor = texColor;
2583
- gl_FragColor.a *= opacity;
2584
- #include <tonemapping_fragment>
2585
- #include <colorspace_fragment>
2586
- }`,Md=`#include <common>
2587
- #include <batching_pars_vertex>
2588
- #include <uv_pars_vertex>
2589
- #include <displacementmap_pars_vertex>
2590
- #include <morphtarget_pars_vertex>
2591
- #include <skinning_pars_vertex>
2592
- #include <logdepthbuf_pars_vertex>
2593
- #include <clipping_planes_pars_vertex>
2594
- varying vec2 vHighPrecisionZW;
2595
- void main() {
2596
- #include <uv_vertex>
2597
- #include <batching_vertex>
2598
- #include <skinbase_vertex>
2599
- #include <morphinstance_vertex>
2600
- #ifdef USE_DISPLACEMENTMAP
2601
- #include <beginnormal_vertex>
2602
- #include <morphnormal_vertex>
2603
- #include <skinnormal_vertex>
2604
- #endif
2605
- #include <begin_vertex>
2606
- #include <morphtarget_vertex>
2607
- #include <skinning_vertex>
2608
- #include <displacementmap_vertex>
2609
- #include <project_vertex>
2610
- #include <logdepthbuf_vertex>
2611
- #include <clipping_planes_vertex>
2612
- vHighPrecisionZW = gl_Position.zw;
2613
- }`,Sd=`#if DEPTH_PACKING == 3200
2614
- uniform float opacity;
2615
- #endif
2616
- #include <common>
2617
- #include <packing>
2618
- #include <uv_pars_fragment>
2619
- #include <map_pars_fragment>
2620
- #include <alphamap_pars_fragment>
2621
- #include <alphatest_pars_fragment>
2622
- #include <alphahash_pars_fragment>
2623
- #include <logdepthbuf_pars_fragment>
2624
- #include <clipping_planes_pars_fragment>
2625
- varying vec2 vHighPrecisionZW;
2626
- void main() {
2627
- vec4 diffuseColor = vec4( 1.0 );
2628
- #include <clipping_planes_fragment>
2629
- #if DEPTH_PACKING == 3200
2630
- diffuseColor.a = opacity;
2631
- #endif
2632
- #include <map_fragment>
2633
- #include <alphamap_fragment>
2634
- #include <alphatest_fragment>
2635
- #include <alphahash_fragment>
2636
- #include <logdepthbuf_fragment>
2637
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2638
- #if DEPTH_PACKING == 3200
2639
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2640
- #elif DEPTH_PACKING == 3201
2641
- gl_FragColor = packDepthToRGBA( fragCoordZ );
2642
- #elif DEPTH_PACKING == 3202
2643
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2644
- #elif DEPTH_PACKING == 3203
2645
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2646
- #endif
2647
- }`,yd=`#define DISTANCE
2648
- varying vec3 vWorldPosition;
2649
- #include <common>
2650
- #include <batching_pars_vertex>
2651
- #include <uv_pars_vertex>
2652
- #include <displacementmap_pars_vertex>
2653
- #include <morphtarget_pars_vertex>
2654
- #include <skinning_pars_vertex>
2655
- #include <clipping_planes_pars_vertex>
2656
- void main() {
2657
- #include <uv_vertex>
2658
- #include <batching_vertex>
2659
- #include <skinbase_vertex>
2660
- #include <morphinstance_vertex>
2661
- #ifdef USE_DISPLACEMENTMAP
2662
- #include <beginnormal_vertex>
2663
- #include <morphnormal_vertex>
2664
- #include <skinnormal_vertex>
2665
- #endif
2666
- #include <begin_vertex>
2667
- #include <morphtarget_vertex>
2668
- #include <skinning_vertex>
2669
- #include <displacementmap_vertex>
2670
- #include <project_vertex>
2671
- #include <worldpos_vertex>
2672
- #include <clipping_planes_vertex>
2673
- vWorldPosition = worldPosition.xyz;
2674
- }`,Ed=`#define DISTANCE
2675
- uniform vec3 referencePosition;
2676
- uniform float nearDistance;
2677
- uniform float farDistance;
2678
- varying vec3 vWorldPosition;
2679
- #include <common>
2680
- #include <packing>
2681
- #include <uv_pars_fragment>
2682
- #include <map_pars_fragment>
2683
- #include <alphamap_pars_fragment>
2684
- #include <alphatest_pars_fragment>
2685
- #include <alphahash_pars_fragment>
2686
- #include <clipping_planes_pars_fragment>
2687
- void main () {
2688
- vec4 diffuseColor = vec4( 1.0 );
2689
- #include <clipping_planes_fragment>
2690
- #include <map_fragment>
2691
- #include <alphamap_fragment>
2692
- #include <alphatest_fragment>
2693
- #include <alphahash_fragment>
2694
- float dist = length( vWorldPosition - referencePosition );
2695
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2696
- dist = saturate( dist );
2697
- gl_FragColor = packDepthToRGBA( dist );
2698
- }`,Td=`varying vec3 vWorldDirection;
2699
- #include <common>
2700
- void main() {
2701
- vWorldDirection = transformDirection( position, modelMatrix );
2702
- #include <begin_vertex>
2703
- #include <project_vertex>
2704
- }`,bd=`uniform sampler2D tEquirect;
2705
- varying vec3 vWorldDirection;
2706
- #include <common>
2707
- void main() {
2708
- vec3 direction = normalize( vWorldDirection );
2709
- vec2 sampleUV = equirectUv( direction );
2710
- gl_FragColor = texture2D( tEquirect, sampleUV );
2711
- #include <tonemapping_fragment>
2712
- #include <colorspace_fragment>
2713
- }`,Ad=`uniform float scale;
2714
- attribute float lineDistance;
2715
- varying float vLineDistance;
2716
- #include <common>
2717
- #include <uv_pars_vertex>
2718
- #include <color_pars_vertex>
2719
- #include <fog_pars_vertex>
2720
- #include <morphtarget_pars_vertex>
2721
- #include <logdepthbuf_pars_vertex>
2722
- #include <clipping_planes_pars_vertex>
2723
- void main() {
2724
- vLineDistance = scale * lineDistance;
2725
- #include <uv_vertex>
2726
- #include <color_vertex>
2727
- #include <morphinstance_vertex>
2728
- #include <morphcolor_vertex>
2729
- #include <begin_vertex>
2730
- #include <morphtarget_vertex>
2731
- #include <project_vertex>
2732
- #include <logdepthbuf_vertex>
2733
- #include <clipping_planes_vertex>
2734
- #include <fog_vertex>
2735
- }`,wd=`uniform vec3 diffuse;
2736
- uniform float opacity;
2737
- uniform float dashSize;
2738
- uniform float totalSize;
2739
- varying float vLineDistance;
2740
- #include <common>
2741
- #include <color_pars_fragment>
2742
- #include <uv_pars_fragment>
2743
- #include <map_pars_fragment>
2744
- #include <fog_pars_fragment>
2745
- #include <logdepthbuf_pars_fragment>
2746
- #include <clipping_planes_pars_fragment>
2747
- void main() {
2748
- vec4 diffuseColor = vec4( diffuse, opacity );
2749
- #include <clipping_planes_fragment>
2750
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
2751
- discard;
2752
- }
2753
- vec3 outgoingLight = vec3( 0.0 );
2754
- #include <logdepthbuf_fragment>
2755
- #include <map_fragment>
2756
- #include <color_fragment>
2757
- outgoingLight = diffuseColor.rgb;
2758
- #include <opaque_fragment>
2759
- #include <tonemapping_fragment>
2760
- #include <colorspace_fragment>
2761
- #include <fog_fragment>
2762
- #include <premultiplied_alpha_fragment>
2763
- }`,Rd=`#include <common>
2764
- #include <batching_pars_vertex>
2765
- #include <uv_pars_vertex>
2766
- #include <envmap_pars_vertex>
2767
- #include <color_pars_vertex>
2768
- #include <fog_pars_vertex>
2769
- #include <morphtarget_pars_vertex>
2770
- #include <skinning_pars_vertex>
2771
- #include <logdepthbuf_pars_vertex>
2772
- #include <clipping_planes_pars_vertex>
2773
- void main() {
2774
- #include <uv_vertex>
2775
- #include <color_vertex>
2776
- #include <morphinstance_vertex>
2777
- #include <morphcolor_vertex>
2778
- #include <batching_vertex>
2779
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2780
- #include <beginnormal_vertex>
2781
- #include <morphnormal_vertex>
2782
- #include <skinbase_vertex>
2783
- #include <skinnormal_vertex>
2784
- #include <defaultnormal_vertex>
2785
- #endif
2786
- #include <begin_vertex>
2787
- #include <morphtarget_vertex>
2788
- #include <skinning_vertex>
2789
- #include <project_vertex>
2790
- #include <logdepthbuf_vertex>
2791
- #include <clipping_planes_vertex>
2792
- #include <worldpos_vertex>
2793
- #include <envmap_vertex>
2794
- #include <fog_vertex>
2795
- }`,Cd=`uniform vec3 diffuse;
2796
- uniform float opacity;
2797
- #ifndef FLAT_SHADED
2798
- varying vec3 vNormal;
2799
- #endif
2800
- #include <common>
2801
- #include <dithering_pars_fragment>
2802
- #include <color_pars_fragment>
2803
- #include <uv_pars_fragment>
2804
- #include <map_pars_fragment>
2805
- #include <alphamap_pars_fragment>
2806
- #include <alphatest_pars_fragment>
2807
- #include <alphahash_pars_fragment>
2808
- #include <aomap_pars_fragment>
2809
- #include <lightmap_pars_fragment>
2810
- #include <envmap_common_pars_fragment>
2811
- #include <envmap_pars_fragment>
2812
- #include <fog_pars_fragment>
2813
- #include <specularmap_pars_fragment>
2814
- #include <logdepthbuf_pars_fragment>
2815
- #include <clipping_planes_pars_fragment>
2816
- void main() {
2817
- vec4 diffuseColor = vec4( diffuse, opacity );
2818
- #include <clipping_planes_fragment>
2819
- #include <logdepthbuf_fragment>
2820
- #include <map_fragment>
2821
- #include <color_fragment>
2822
- #include <alphamap_fragment>
2823
- #include <alphatest_fragment>
2824
- #include <alphahash_fragment>
2825
- #include <specularmap_fragment>
2826
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2827
- #ifdef USE_LIGHTMAP
2828
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2829
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2830
- #else
2831
- reflectedLight.indirectDiffuse += vec3( 1.0 );
2832
- #endif
2833
- #include <aomap_fragment>
2834
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2835
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
2836
- #include <envmap_fragment>
2837
- #include <opaque_fragment>
2838
- #include <tonemapping_fragment>
2839
- #include <colorspace_fragment>
2840
- #include <fog_fragment>
2841
- #include <premultiplied_alpha_fragment>
2842
- #include <dithering_fragment>
2843
- }`,Pd=`#define LAMBERT
2844
- varying vec3 vViewPosition;
2845
- #include <common>
2846
- #include <batching_pars_vertex>
2847
- #include <uv_pars_vertex>
2848
- #include <displacementmap_pars_vertex>
2849
- #include <envmap_pars_vertex>
2850
- #include <color_pars_vertex>
2851
- #include <fog_pars_vertex>
2852
- #include <normal_pars_vertex>
2853
- #include <morphtarget_pars_vertex>
2854
- #include <skinning_pars_vertex>
2855
- #include <shadowmap_pars_vertex>
2856
- #include <logdepthbuf_pars_vertex>
2857
- #include <clipping_planes_pars_vertex>
2858
- void main() {
2859
- #include <uv_vertex>
2860
- #include <color_vertex>
2861
- #include <morphinstance_vertex>
2862
- #include <morphcolor_vertex>
2863
- #include <batching_vertex>
2864
- #include <beginnormal_vertex>
2865
- #include <morphnormal_vertex>
2866
- #include <skinbase_vertex>
2867
- #include <skinnormal_vertex>
2868
- #include <defaultnormal_vertex>
2869
- #include <normal_vertex>
2870
- #include <begin_vertex>
2871
- #include <morphtarget_vertex>
2872
- #include <skinning_vertex>
2873
- #include <displacementmap_vertex>
2874
- #include <project_vertex>
2875
- #include <logdepthbuf_vertex>
2876
- #include <clipping_planes_vertex>
2877
- vViewPosition = - mvPosition.xyz;
2878
- #include <worldpos_vertex>
2879
- #include <envmap_vertex>
2880
- #include <shadowmap_vertex>
2881
- #include <fog_vertex>
2882
- }`,Dd=`#define LAMBERT
2883
- uniform vec3 diffuse;
2884
- uniform vec3 emissive;
2885
- uniform float opacity;
2886
- #include <common>
2887
- #include <packing>
2888
- #include <dithering_pars_fragment>
2889
- #include <color_pars_fragment>
2890
- #include <uv_pars_fragment>
2891
- #include <map_pars_fragment>
2892
- #include <alphamap_pars_fragment>
2893
- #include <alphatest_pars_fragment>
2894
- #include <alphahash_pars_fragment>
2895
- #include <aomap_pars_fragment>
2896
- #include <lightmap_pars_fragment>
2897
- #include <emissivemap_pars_fragment>
2898
- #include <envmap_common_pars_fragment>
2899
- #include <envmap_pars_fragment>
2900
- #include <fog_pars_fragment>
2901
- #include <bsdfs>
2902
- #include <lights_pars_begin>
2903
- #include <normal_pars_fragment>
2904
- #include <lights_lambert_pars_fragment>
2905
- #include <shadowmap_pars_fragment>
2906
- #include <bumpmap_pars_fragment>
2907
- #include <normalmap_pars_fragment>
2908
- #include <specularmap_pars_fragment>
2909
- #include <logdepthbuf_pars_fragment>
2910
- #include <clipping_planes_pars_fragment>
2911
- void main() {
2912
- vec4 diffuseColor = vec4( diffuse, opacity );
2913
- #include <clipping_planes_fragment>
2914
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2915
- vec3 totalEmissiveRadiance = emissive;
2916
- #include <logdepthbuf_fragment>
2917
- #include <map_fragment>
2918
- #include <color_fragment>
2919
- #include <alphamap_fragment>
2920
- #include <alphatest_fragment>
2921
- #include <alphahash_fragment>
2922
- #include <specularmap_fragment>
2923
- #include <normal_fragment_begin>
2924
- #include <normal_fragment_maps>
2925
- #include <emissivemap_fragment>
2926
- #include <lights_lambert_fragment>
2927
- #include <lights_fragment_begin>
2928
- #include <lights_fragment_maps>
2929
- #include <lights_fragment_end>
2930
- #include <aomap_fragment>
2931
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2932
- #include <envmap_fragment>
2933
- #include <opaque_fragment>
2934
- #include <tonemapping_fragment>
2935
- #include <colorspace_fragment>
2936
- #include <fog_fragment>
2937
- #include <premultiplied_alpha_fragment>
2938
- #include <dithering_fragment>
2939
- }`,Ld=`#define MATCAP
2940
- varying vec3 vViewPosition;
2941
- #include <common>
2942
- #include <batching_pars_vertex>
2943
- #include <uv_pars_vertex>
2944
- #include <color_pars_vertex>
2945
- #include <displacementmap_pars_vertex>
2946
- #include <fog_pars_vertex>
2947
- #include <normal_pars_vertex>
2948
- #include <morphtarget_pars_vertex>
2949
- #include <skinning_pars_vertex>
2950
- #include <logdepthbuf_pars_vertex>
2951
- #include <clipping_planes_pars_vertex>
2952
- void main() {
2953
- #include <uv_vertex>
2954
- #include <color_vertex>
2955
- #include <morphinstance_vertex>
2956
- #include <morphcolor_vertex>
2957
- #include <batching_vertex>
2958
- #include <beginnormal_vertex>
2959
- #include <morphnormal_vertex>
2960
- #include <skinbase_vertex>
2961
- #include <skinnormal_vertex>
2962
- #include <defaultnormal_vertex>
2963
- #include <normal_vertex>
2964
- #include <begin_vertex>
2965
- #include <morphtarget_vertex>
2966
- #include <skinning_vertex>
2967
- #include <displacementmap_vertex>
2968
- #include <project_vertex>
2969
- #include <logdepthbuf_vertex>
2970
- #include <clipping_planes_vertex>
2971
- #include <fog_vertex>
2972
- vViewPosition = - mvPosition.xyz;
2973
- }`,Ud=`#define MATCAP
2974
- uniform vec3 diffuse;
2975
- uniform float opacity;
2976
- uniform sampler2D matcap;
2977
- varying vec3 vViewPosition;
2978
- #include <common>
2979
- #include <dithering_pars_fragment>
2980
- #include <color_pars_fragment>
2981
- #include <uv_pars_fragment>
2982
- #include <map_pars_fragment>
2983
- #include <alphamap_pars_fragment>
2984
- #include <alphatest_pars_fragment>
2985
- #include <alphahash_pars_fragment>
2986
- #include <fog_pars_fragment>
2987
- #include <normal_pars_fragment>
2988
- #include <bumpmap_pars_fragment>
2989
- #include <normalmap_pars_fragment>
2990
- #include <logdepthbuf_pars_fragment>
2991
- #include <clipping_planes_pars_fragment>
2992
- void main() {
2993
- vec4 diffuseColor = vec4( diffuse, opacity );
2994
- #include <clipping_planes_fragment>
2995
- #include <logdepthbuf_fragment>
2996
- #include <map_fragment>
2997
- #include <color_fragment>
2998
- #include <alphamap_fragment>
2999
- #include <alphatest_fragment>
3000
- #include <alphahash_fragment>
3001
- #include <normal_fragment_begin>
3002
- #include <normal_fragment_maps>
3003
- vec3 viewDir = normalize( vViewPosition );
3004
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3005
- vec3 y = cross( viewDir, x );
3006
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3007
- #ifdef USE_MATCAP
3008
- vec4 matcapColor = texture2D( matcap, uv );
3009
- #else
3010
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3011
- #endif
3012
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3013
- #include <opaque_fragment>
3014
- #include <tonemapping_fragment>
3015
- #include <colorspace_fragment>
3016
- #include <fog_fragment>
3017
- #include <premultiplied_alpha_fragment>
3018
- #include <dithering_fragment>
3019
- }`,Id=`#define NORMAL
3020
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3021
- varying vec3 vViewPosition;
3022
- #endif
3023
- #include <common>
3024
- #include <batching_pars_vertex>
3025
- #include <uv_pars_vertex>
3026
- #include <displacementmap_pars_vertex>
3027
- #include <normal_pars_vertex>
3028
- #include <morphtarget_pars_vertex>
3029
- #include <skinning_pars_vertex>
3030
- #include <logdepthbuf_pars_vertex>
3031
- #include <clipping_planes_pars_vertex>
3032
- void main() {
3033
- #include <uv_vertex>
3034
- #include <batching_vertex>
3035
- #include <beginnormal_vertex>
3036
- #include <morphinstance_vertex>
3037
- #include <morphnormal_vertex>
3038
- #include <skinbase_vertex>
3039
- #include <skinnormal_vertex>
3040
- #include <defaultnormal_vertex>
3041
- #include <normal_vertex>
3042
- #include <begin_vertex>
3043
- #include <morphtarget_vertex>
3044
- #include <skinning_vertex>
3045
- #include <displacementmap_vertex>
3046
- #include <project_vertex>
3047
- #include <logdepthbuf_vertex>
3048
- #include <clipping_planes_vertex>
3049
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3050
- vViewPosition = - mvPosition.xyz;
3051
- #endif
3052
- }`,Nd=`#define NORMAL
3053
- uniform float opacity;
3054
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3055
- varying vec3 vViewPosition;
3056
- #endif
3057
- #include <packing>
3058
- #include <uv_pars_fragment>
3059
- #include <normal_pars_fragment>
3060
- #include <bumpmap_pars_fragment>
3061
- #include <normalmap_pars_fragment>
3062
- #include <logdepthbuf_pars_fragment>
3063
- #include <clipping_planes_pars_fragment>
3064
- void main() {
3065
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3066
- #include <clipping_planes_fragment>
3067
- #include <logdepthbuf_fragment>
3068
- #include <normal_fragment_begin>
3069
- #include <normal_fragment_maps>
3070
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3071
- #ifdef OPAQUE
3072
- gl_FragColor.a = 1.0;
3073
- #endif
3074
- }`,Fd=`#define PHONG
3075
- varying vec3 vViewPosition;
3076
- #include <common>
3077
- #include <batching_pars_vertex>
3078
- #include <uv_pars_vertex>
3079
- #include <displacementmap_pars_vertex>
3080
- #include <envmap_pars_vertex>
3081
- #include <color_pars_vertex>
3082
- #include <fog_pars_vertex>
3083
- #include <normal_pars_vertex>
3084
- #include <morphtarget_pars_vertex>
3085
- #include <skinning_pars_vertex>
3086
- #include <shadowmap_pars_vertex>
3087
- #include <logdepthbuf_pars_vertex>
3088
- #include <clipping_planes_pars_vertex>
3089
- void main() {
3090
- #include <uv_vertex>
3091
- #include <color_vertex>
3092
- #include <morphcolor_vertex>
3093
- #include <batching_vertex>
3094
- #include <beginnormal_vertex>
3095
- #include <morphinstance_vertex>
3096
- #include <morphnormal_vertex>
3097
- #include <skinbase_vertex>
3098
- #include <skinnormal_vertex>
3099
- #include <defaultnormal_vertex>
3100
- #include <normal_vertex>
3101
- #include <begin_vertex>
3102
- #include <morphtarget_vertex>
3103
- #include <skinning_vertex>
3104
- #include <displacementmap_vertex>
3105
- #include <project_vertex>
3106
- #include <logdepthbuf_vertex>
3107
- #include <clipping_planes_vertex>
3108
- vViewPosition = - mvPosition.xyz;
3109
- #include <worldpos_vertex>
3110
- #include <envmap_vertex>
3111
- #include <shadowmap_vertex>
3112
- #include <fog_vertex>
3113
- }`,Od=`#define PHONG
3114
- uniform vec3 diffuse;
3115
- uniform vec3 emissive;
3116
- uniform vec3 specular;
3117
- uniform float shininess;
3118
- uniform float opacity;
3119
- #include <common>
3120
- #include <packing>
3121
- #include <dithering_pars_fragment>
3122
- #include <color_pars_fragment>
3123
- #include <uv_pars_fragment>
3124
- #include <map_pars_fragment>
3125
- #include <alphamap_pars_fragment>
3126
- #include <alphatest_pars_fragment>
3127
- #include <alphahash_pars_fragment>
3128
- #include <aomap_pars_fragment>
3129
- #include <lightmap_pars_fragment>
3130
- #include <emissivemap_pars_fragment>
3131
- #include <envmap_common_pars_fragment>
3132
- #include <envmap_pars_fragment>
3133
- #include <fog_pars_fragment>
3134
- #include <bsdfs>
3135
- #include <lights_pars_begin>
3136
- #include <normal_pars_fragment>
3137
- #include <lights_phong_pars_fragment>
3138
- #include <shadowmap_pars_fragment>
3139
- #include <bumpmap_pars_fragment>
3140
- #include <normalmap_pars_fragment>
3141
- #include <specularmap_pars_fragment>
3142
- #include <logdepthbuf_pars_fragment>
3143
- #include <clipping_planes_pars_fragment>
3144
- void main() {
3145
- vec4 diffuseColor = vec4( diffuse, opacity );
3146
- #include <clipping_planes_fragment>
3147
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3148
- vec3 totalEmissiveRadiance = emissive;
3149
- #include <logdepthbuf_fragment>
3150
- #include <map_fragment>
3151
- #include <color_fragment>
3152
- #include <alphamap_fragment>
3153
- #include <alphatest_fragment>
3154
- #include <alphahash_fragment>
3155
- #include <specularmap_fragment>
3156
- #include <normal_fragment_begin>
3157
- #include <normal_fragment_maps>
3158
- #include <emissivemap_fragment>
3159
- #include <lights_phong_fragment>
3160
- #include <lights_fragment_begin>
3161
- #include <lights_fragment_maps>
3162
- #include <lights_fragment_end>
3163
- #include <aomap_fragment>
3164
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3165
- #include <envmap_fragment>
3166
- #include <opaque_fragment>
3167
- #include <tonemapping_fragment>
3168
- #include <colorspace_fragment>
3169
- #include <fog_fragment>
3170
- #include <premultiplied_alpha_fragment>
3171
- #include <dithering_fragment>
3172
- }`,Bd=`#define STANDARD
3173
- varying vec3 vViewPosition;
3174
- #ifdef USE_TRANSMISSION
3175
- varying vec3 vWorldPosition;
3176
- #endif
3177
- #include <common>
3178
- #include <batching_pars_vertex>
3179
- #include <uv_pars_vertex>
3180
- #include <displacementmap_pars_vertex>
3181
- #include <color_pars_vertex>
3182
- #include <fog_pars_vertex>
3183
- #include <normal_pars_vertex>
3184
- #include <morphtarget_pars_vertex>
3185
- #include <skinning_pars_vertex>
3186
- #include <shadowmap_pars_vertex>
3187
- #include <logdepthbuf_pars_vertex>
3188
- #include <clipping_planes_pars_vertex>
3189
- void main() {
3190
- #include <uv_vertex>
3191
- #include <color_vertex>
3192
- #include <morphinstance_vertex>
3193
- #include <morphcolor_vertex>
3194
- #include <batching_vertex>
3195
- #include <beginnormal_vertex>
3196
- #include <morphnormal_vertex>
3197
- #include <skinbase_vertex>
3198
- #include <skinnormal_vertex>
3199
- #include <defaultnormal_vertex>
3200
- #include <normal_vertex>
3201
- #include <begin_vertex>
3202
- #include <morphtarget_vertex>
3203
- #include <skinning_vertex>
3204
- #include <displacementmap_vertex>
3205
- #include <project_vertex>
3206
- #include <logdepthbuf_vertex>
3207
- #include <clipping_planes_vertex>
3208
- vViewPosition = - mvPosition.xyz;
3209
- #include <worldpos_vertex>
3210
- #include <shadowmap_vertex>
3211
- #include <fog_vertex>
3212
- #ifdef USE_TRANSMISSION
3213
- vWorldPosition = worldPosition.xyz;
3214
- #endif
3215
- }`,zd=`#define STANDARD
3216
- #ifdef PHYSICAL
3217
- #define IOR
3218
- #define USE_SPECULAR
3219
- #endif
3220
- uniform vec3 diffuse;
3221
- uniform vec3 emissive;
3222
- uniform float roughness;
3223
- uniform float metalness;
3224
- uniform float opacity;
3225
- #ifdef IOR
3226
- uniform float ior;
3227
- #endif
3228
- #ifdef USE_SPECULAR
3229
- uniform float specularIntensity;
3230
- uniform vec3 specularColor;
3231
- #ifdef USE_SPECULAR_COLORMAP
3232
- uniform sampler2D specularColorMap;
3233
- #endif
3234
- #ifdef USE_SPECULAR_INTENSITYMAP
3235
- uniform sampler2D specularIntensityMap;
3236
- #endif
3237
- #endif
3238
- #ifdef USE_CLEARCOAT
3239
- uniform float clearcoat;
3240
- uniform float clearcoatRoughness;
3241
- #endif
3242
- #ifdef USE_DISPERSION
3243
- uniform float dispersion;
3244
- #endif
3245
- #ifdef USE_IRIDESCENCE
3246
- uniform float iridescence;
3247
- uniform float iridescenceIOR;
3248
- uniform float iridescenceThicknessMinimum;
3249
- uniform float iridescenceThicknessMaximum;
3250
- #endif
3251
- #ifdef USE_SHEEN
3252
- uniform vec3 sheenColor;
3253
- uniform float sheenRoughness;
3254
- #ifdef USE_SHEEN_COLORMAP
3255
- uniform sampler2D sheenColorMap;
3256
- #endif
3257
- #ifdef USE_SHEEN_ROUGHNESSMAP
3258
- uniform sampler2D sheenRoughnessMap;
3259
- #endif
3260
- #endif
3261
- #ifdef USE_ANISOTROPY
3262
- uniform vec2 anisotropyVector;
3263
- #ifdef USE_ANISOTROPYMAP
3264
- uniform sampler2D anisotropyMap;
3265
- #endif
3266
- #endif
3267
- varying vec3 vViewPosition;
3268
- #include <common>
3269
- #include <packing>
3270
- #include <dithering_pars_fragment>
3271
- #include <color_pars_fragment>
3272
- #include <uv_pars_fragment>
3273
- #include <map_pars_fragment>
3274
- #include <alphamap_pars_fragment>
3275
- #include <alphatest_pars_fragment>
3276
- #include <alphahash_pars_fragment>
3277
- #include <aomap_pars_fragment>
3278
- #include <lightmap_pars_fragment>
3279
- #include <emissivemap_pars_fragment>
3280
- #include <iridescence_fragment>
3281
- #include <cube_uv_reflection_fragment>
3282
- #include <envmap_common_pars_fragment>
3283
- #include <envmap_physical_pars_fragment>
3284
- #include <fog_pars_fragment>
3285
- #include <lights_pars_begin>
3286
- #include <normal_pars_fragment>
3287
- #include <lights_physical_pars_fragment>
3288
- #include <transmission_pars_fragment>
3289
- #include <shadowmap_pars_fragment>
3290
- #include <bumpmap_pars_fragment>
3291
- #include <normalmap_pars_fragment>
3292
- #include <clearcoat_pars_fragment>
3293
- #include <iridescence_pars_fragment>
3294
- #include <roughnessmap_pars_fragment>
3295
- #include <metalnessmap_pars_fragment>
3296
- #include <logdepthbuf_pars_fragment>
3297
- #include <clipping_planes_pars_fragment>
3298
- void main() {
3299
- vec4 diffuseColor = vec4( diffuse, opacity );
3300
- #include <clipping_planes_fragment>
3301
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3302
- vec3 totalEmissiveRadiance = emissive;
3303
- #include <logdepthbuf_fragment>
3304
- #include <map_fragment>
3305
- #include <color_fragment>
3306
- #include <alphamap_fragment>
3307
- #include <alphatest_fragment>
3308
- #include <alphahash_fragment>
3309
- #include <roughnessmap_fragment>
3310
- #include <metalnessmap_fragment>
3311
- #include <normal_fragment_begin>
3312
- #include <normal_fragment_maps>
3313
- #include <clearcoat_normal_fragment_begin>
3314
- #include <clearcoat_normal_fragment_maps>
3315
- #include <emissivemap_fragment>
3316
- #include <lights_physical_fragment>
3317
- #include <lights_fragment_begin>
3318
- #include <lights_fragment_maps>
3319
- #include <lights_fragment_end>
3320
- #include <aomap_fragment>
3321
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3322
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3323
- #include <transmission_fragment>
3324
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3325
- #ifdef USE_SHEEN
3326
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3327
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3328
- #endif
3329
- #ifdef USE_CLEARCOAT
3330
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3331
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3332
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3333
- #endif
3334
- #include <opaque_fragment>
3335
- #include <tonemapping_fragment>
3336
- #include <colorspace_fragment>
3337
- #include <fog_fragment>
3338
- #include <premultiplied_alpha_fragment>
3339
- #include <dithering_fragment>
3340
- }`,kd=`#define TOON
3341
- varying vec3 vViewPosition;
3342
- #include <common>
3343
- #include <batching_pars_vertex>
3344
- #include <uv_pars_vertex>
3345
- #include <displacementmap_pars_vertex>
3346
- #include <color_pars_vertex>
3347
- #include <fog_pars_vertex>
3348
- #include <normal_pars_vertex>
3349
- #include <morphtarget_pars_vertex>
3350
- #include <skinning_pars_vertex>
3351
- #include <shadowmap_pars_vertex>
3352
- #include <logdepthbuf_pars_vertex>
3353
- #include <clipping_planes_pars_vertex>
3354
- void main() {
3355
- #include <uv_vertex>
3356
- #include <color_vertex>
3357
- #include <morphinstance_vertex>
3358
- #include <morphcolor_vertex>
3359
- #include <batching_vertex>
3360
- #include <beginnormal_vertex>
3361
- #include <morphnormal_vertex>
3362
- #include <skinbase_vertex>
3363
- #include <skinnormal_vertex>
3364
- #include <defaultnormal_vertex>
3365
- #include <normal_vertex>
3366
- #include <begin_vertex>
3367
- #include <morphtarget_vertex>
3368
- #include <skinning_vertex>
3369
- #include <displacementmap_vertex>
3370
- #include <project_vertex>
3371
- #include <logdepthbuf_vertex>
3372
- #include <clipping_planes_vertex>
3373
- vViewPosition = - mvPosition.xyz;
3374
- #include <worldpos_vertex>
3375
- #include <shadowmap_vertex>
3376
- #include <fog_vertex>
3377
- }`,Hd=`#define TOON
3378
- uniform vec3 diffuse;
3379
- uniform vec3 emissive;
3380
- uniform float opacity;
3381
- #include <common>
3382
- #include <packing>
3383
- #include <dithering_pars_fragment>
3384
- #include <color_pars_fragment>
3385
- #include <uv_pars_fragment>
3386
- #include <map_pars_fragment>
3387
- #include <alphamap_pars_fragment>
3388
- #include <alphatest_pars_fragment>
3389
- #include <alphahash_pars_fragment>
3390
- #include <aomap_pars_fragment>
3391
- #include <lightmap_pars_fragment>
3392
- #include <emissivemap_pars_fragment>
3393
- #include <gradientmap_pars_fragment>
3394
- #include <fog_pars_fragment>
3395
- #include <bsdfs>
3396
- #include <lights_pars_begin>
3397
- #include <normal_pars_fragment>
3398
- #include <lights_toon_pars_fragment>
3399
- #include <shadowmap_pars_fragment>
3400
- #include <bumpmap_pars_fragment>
3401
- #include <normalmap_pars_fragment>
3402
- #include <logdepthbuf_pars_fragment>
3403
- #include <clipping_planes_pars_fragment>
3404
- void main() {
3405
- vec4 diffuseColor = vec4( diffuse, opacity );
3406
- #include <clipping_planes_fragment>
3407
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3408
- vec3 totalEmissiveRadiance = emissive;
3409
- #include <logdepthbuf_fragment>
3410
- #include <map_fragment>
3411
- #include <color_fragment>
3412
- #include <alphamap_fragment>
3413
- #include <alphatest_fragment>
3414
- #include <alphahash_fragment>
3415
- #include <normal_fragment_begin>
3416
- #include <normal_fragment_maps>
3417
- #include <emissivemap_fragment>
3418
- #include <lights_toon_fragment>
3419
- #include <lights_fragment_begin>
3420
- #include <lights_fragment_maps>
3421
- #include <lights_fragment_end>
3422
- #include <aomap_fragment>
3423
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3424
- #include <opaque_fragment>
3425
- #include <tonemapping_fragment>
3426
- #include <colorspace_fragment>
3427
- #include <fog_fragment>
3428
- #include <premultiplied_alpha_fragment>
3429
- #include <dithering_fragment>
3430
- }`,Vd=`uniform float size;
3431
- uniform float scale;
3432
- #include <common>
3433
- #include <color_pars_vertex>
3434
- #include <fog_pars_vertex>
3435
- #include <morphtarget_pars_vertex>
3436
- #include <logdepthbuf_pars_vertex>
3437
- #include <clipping_planes_pars_vertex>
3438
- #ifdef USE_POINTS_UV
3439
- varying vec2 vUv;
3440
- uniform mat3 uvTransform;
3441
- #endif
3442
- void main() {
3443
- #ifdef USE_POINTS_UV
3444
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3445
- #endif
3446
- #include <color_vertex>
3447
- #include <morphinstance_vertex>
3448
- #include <morphcolor_vertex>
3449
- #include <begin_vertex>
3450
- #include <morphtarget_vertex>
3451
- #include <project_vertex>
3452
- gl_PointSize = size;
3453
- #ifdef USE_SIZEATTENUATION
3454
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3455
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3456
- #endif
3457
- #include <logdepthbuf_vertex>
3458
- #include <clipping_planes_vertex>
3459
- #include <worldpos_vertex>
3460
- #include <fog_vertex>
3461
- }`,Gd=`uniform vec3 diffuse;
3462
- uniform float opacity;
3463
- #include <common>
3464
- #include <color_pars_fragment>
3465
- #include <map_particle_pars_fragment>
3466
- #include <alphatest_pars_fragment>
3467
- #include <alphahash_pars_fragment>
3468
- #include <fog_pars_fragment>
3469
- #include <logdepthbuf_pars_fragment>
3470
- #include <clipping_planes_pars_fragment>
3471
- void main() {
3472
- vec4 diffuseColor = vec4( diffuse, opacity );
3473
- #include <clipping_planes_fragment>
3474
- vec3 outgoingLight = vec3( 0.0 );
3475
- #include <logdepthbuf_fragment>
3476
- #include <map_particle_fragment>
3477
- #include <color_fragment>
3478
- #include <alphatest_fragment>
3479
- #include <alphahash_fragment>
3480
- outgoingLight = diffuseColor.rgb;
3481
- #include <opaque_fragment>
3482
- #include <tonemapping_fragment>
3483
- #include <colorspace_fragment>
3484
- #include <fog_fragment>
3485
- #include <premultiplied_alpha_fragment>
3486
- }`,Wd=`#include <common>
3487
- #include <batching_pars_vertex>
3488
- #include <fog_pars_vertex>
3489
- #include <morphtarget_pars_vertex>
3490
- #include <skinning_pars_vertex>
3491
- #include <logdepthbuf_pars_vertex>
3492
- #include <shadowmap_pars_vertex>
3493
- void main() {
3494
- #include <batching_vertex>
3495
- #include <beginnormal_vertex>
3496
- #include <morphinstance_vertex>
3497
- #include <morphnormal_vertex>
3498
- #include <skinbase_vertex>
3499
- #include <skinnormal_vertex>
3500
- #include <defaultnormal_vertex>
3501
- #include <begin_vertex>
3502
- #include <morphtarget_vertex>
3503
- #include <skinning_vertex>
3504
- #include <project_vertex>
3505
- #include <logdepthbuf_vertex>
3506
- #include <worldpos_vertex>
3507
- #include <shadowmap_vertex>
3508
- #include <fog_vertex>
3509
- }`,Xd=`uniform vec3 color;
3510
- uniform float opacity;
3511
- #include <common>
3512
- #include <packing>
3513
- #include <fog_pars_fragment>
3514
- #include <bsdfs>
3515
- #include <lights_pars_begin>
3516
- #include <logdepthbuf_pars_fragment>
3517
- #include <shadowmap_pars_fragment>
3518
- #include <shadowmask_pars_fragment>
3519
- void main() {
3520
- #include <logdepthbuf_fragment>
3521
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3522
- #include <tonemapping_fragment>
3523
- #include <colorspace_fragment>
3524
- #include <fog_fragment>
3525
- }`,qd=`uniform float rotation;
3526
- uniform vec2 center;
3527
- #include <common>
3528
- #include <uv_pars_vertex>
3529
- #include <fog_pars_vertex>
3530
- #include <logdepthbuf_pars_vertex>
3531
- #include <clipping_planes_pars_vertex>
3532
- void main() {
3533
- #include <uv_vertex>
3534
- vec4 mvPosition = modelViewMatrix[ 3 ];
3535
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3536
- #ifndef USE_SIZEATTENUATION
3537
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3538
- if ( isPerspective ) scale *= - mvPosition.z;
3539
- #endif
3540
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3541
- vec2 rotatedPosition;
3542
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3543
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3544
- mvPosition.xy += rotatedPosition;
3545
- gl_Position = projectionMatrix * mvPosition;
3546
- #include <logdepthbuf_vertex>
3547
- #include <clipping_planes_vertex>
3548
- #include <fog_vertex>
3549
- }`,Yd=`uniform vec3 diffuse;
3550
- uniform float opacity;
3551
- #include <common>
3552
- #include <uv_pars_fragment>
3553
- #include <map_pars_fragment>
3554
- #include <alphamap_pars_fragment>
3555
- #include <alphatest_pars_fragment>
3556
- #include <alphahash_pars_fragment>
3557
- #include <fog_pars_fragment>
3558
- #include <logdepthbuf_pars_fragment>
3559
- #include <clipping_planes_pars_fragment>
3560
- void main() {
3561
- vec4 diffuseColor = vec4( diffuse, opacity );
3562
- #include <clipping_planes_fragment>
3563
- vec3 outgoingLight = vec3( 0.0 );
3564
- #include <logdepthbuf_fragment>
3565
- #include <map_fragment>
3566
- #include <alphamap_fragment>
3567
- #include <alphatest_fragment>
3568
- #include <alphahash_fragment>
3569
- outgoingLight = diffuseColor.rgb;
3570
- #include <opaque_fragment>
3571
- #include <tonemapping_fragment>
3572
- #include <colorspace_fragment>
3573
- #include <fog_fragment>
3574
- }`,je={alphahash_fragment:pu,alphahash_pars_fragment:mu,alphamap_fragment:_u,alphamap_pars_fragment:gu,alphatest_fragment:vu,alphatest_pars_fragment:xu,aomap_fragment:Mu,aomap_pars_fragment:Su,batching_pars_vertex:yu,batching_vertex:Eu,begin_vertex:Tu,beginnormal_vertex:bu,bsdfs:Au,iridescence_fragment:wu,bumpmap_pars_fragment:Ru,clipping_planes_fragment:Cu,clipping_planes_pars_fragment:Pu,clipping_planes_pars_vertex:Du,clipping_planes_vertex:Lu,color_fragment:Uu,color_pars_fragment:Iu,color_pars_vertex:Nu,color_vertex:Fu,common:Ou,cube_uv_reflection_fragment:Bu,defaultnormal_vertex:zu,displacementmap_pars_vertex:ku,displacementmap_vertex:Hu,emissivemap_fragment:Vu,emissivemap_pars_fragment:Gu,colorspace_fragment:Wu,colorspace_pars_fragment:Xu,envmap_fragment:qu,envmap_common_pars_fragment:Yu,envmap_pars_fragment:ju,envmap_pars_vertex:Ku,envmap_physical_pars_fragment:of,envmap_vertex:Zu,fog_vertex:$u,fog_pars_vertex:Ju,fog_fragment:Qu,fog_pars_fragment:ef,gradientmap_pars_fragment:tf,lightmap_pars_fragment:nf,lights_lambert_fragment:rf,lights_lambert_pars_fragment:sf,lights_pars_begin:af,lights_toon_fragment:lf,lights_toon_pars_fragment:cf,lights_phong_fragment:hf,lights_phong_pars_fragment:uf,lights_physical_fragment:ff,lights_physical_pars_fragment:df,lights_fragment_begin:pf,lights_fragment_maps:mf,lights_fragment_end:_f,logdepthbuf_fragment:gf,logdepthbuf_pars_fragment:vf,logdepthbuf_pars_vertex:xf,logdepthbuf_vertex:Mf,map_fragment:Sf,map_pars_fragment:yf,map_particle_fragment:Ef,map_particle_pars_fragment:Tf,metalnessmap_fragment:bf,metalnessmap_pars_fragment:Af,morphinstance_vertex:wf,morphcolor_vertex:Rf,morphnormal_vertex:Cf,morphtarget_pars_vertex:Pf,morphtarget_vertex:Df,normal_fragment_begin:Lf,normal_fragment_maps:Uf,normal_pars_fragment:If,normal_pars_vertex:Nf,normal_vertex:Ff,normalmap_pars_fragment:Of,clearcoat_normal_fragment_begin:Bf,clearcoat_normal_fragment_maps:zf,clearcoat_pars_fragment:kf,iridescence_pars_fragment:Hf,opaque_fragment:Vf,packing:Gf,premultiplied_alpha_fragment:Wf,project_vertex:Xf,dithering_fragment:qf,dithering_pars_fragment:Yf,roughnessmap_fragment:jf,roughnessmap_pars_fragment:Kf,shadowmap_pars_fragment:Zf,shadowmap_pars_vertex:$f,shadowmap_vertex:Jf,shadowmask_pars_fragment:Qf,skinbase_vertex:ed,skinning_pars_vertex:td,skinning_vertex:nd,skinnormal_vertex:id,specularmap_fragment:rd,specularmap_pars_fragment:sd,tonemapping_fragment:ad,tonemapping_pars_fragment:od,transmission_fragment:ld,transmission_pars_fragment:cd,uv_pars_fragment:hd,uv_pars_vertex:ud,uv_vertex:fd,worldpos_vertex:dd,background_vert:pd,background_frag:md,backgroundCube_vert:_d,backgroundCube_frag:gd,cube_vert:vd,cube_frag:xd,depth_vert:Md,depth_frag:Sd,distanceRGBA_vert:yd,distanceRGBA_frag:Ed,equirect_vert:Td,equirect_frag:bd,linedashed_vert:Ad,linedashed_frag:wd,meshbasic_vert:Rd,meshbasic_frag:Cd,meshlambert_vert:Pd,meshlambert_frag:Dd,meshmatcap_vert:Ld,meshmatcap_frag:Ud,meshnormal_vert:Id,meshnormal_frag:Nd,meshphong_vert:Fd,meshphong_frag:Od,meshphysical_vert:Bd,meshphysical_frag:zd,meshtoon_vert:kd,meshtoon_frag:Hd,points_vert:Vd,points_frag:Gd,shadow_vert:Wd,shadow_frag:Xd,sprite_vert:qd,sprite_frag:Yd},me={common:{diffuse:{value:new Ke(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Xe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ke(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 Ke(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Ke(16777215)},opacity:{value:1},center:{value:new Xe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},nn={basic:{uniforms:Rt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:je.meshbasic_vert,fragmentShader:je.meshbasic_frag},lambert:{uniforms:Rt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ke(0)}}]),vertexShader:je.meshlambert_vert,fragmentShader:je.meshlambert_frag},phong:{uniforms:Rt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ke(0)},specular:{value:new Ke(1118481)},shininess:{value:30}}]),vertexShader:je.meshphong_vert,fragmentShader:je.meshphong_frag},standard:{uniforms:Rt([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new Ke(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:je.meshphysical_vert,fragmentShader:je.meshphysical_frag},toon:{uniforms:Rt([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new Ke(0)}}]),vertexShader:je.meshtoon_vert,fragmentShader:je.meshtoon_frag},matcap:{uniforms:Rt([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:je.meshmatcap_vert,fragmentShader:je.meshmatcap_frag},points:{uniforms:Rt([me.points,me.fog]),vertexShader:je.points_vert,fragmentShader:je.points_frag},dashed:{uniforms:Rt([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:je.linedashed_vert,fragmentShader:je.linedashed_frag},depth:{uniforms:Rt([me.common,me.displacementmap]),vertexShader:je.depth_vert,fragmentShader:je.depth_frag},normal:{uniforms:Rt([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:je.meshnormal_vert,fragmentShader:je.meshnormal_frag},sprite:{uniforms:Rt([me.sprite,me.fog]),vertexShader:je.sprite_vert,fragmentShader:je.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:je.background_vert,fragmentShader:je.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:je.backgroundCube_vert,fragmentShader:je.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:je.cube_vert,fragmentShader:je.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:je.equirect_vert,fragmentShader:je.equirect_frag},distanceRGBA:{uniforms:Rt([me.common,me.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:je.distanceRGBA_vert,fragmentShader:je.distanceRGBA_frag},shadow:{uniforms:Rt([me.lights,me.fog,{color:{value:new Ke(0)},opacity:{value:1}}]),vertexShader:je.shadow_vert,fragmentShader:je.shadow_frag}};nn.physical={uniforms:Rt([nn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Xe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Ke(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Xe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Ke(0)},specularColor:{value:new Ke(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Xe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:je.meshphysical_vert,fragmentShader:je.meshphysical_frag};const Er={r:0,b:0,g:0},Vn=new on,jd=new ht;function Kd(i,e,t,n,r,s,a){const o=new Ke(0);let l=s===!0?0:1,c,h,u=null,d=0,p=null;function _(E){let S=E.isScene===!0?E.background:null;return S&&S.isTexture&&(S=(E.backgroundBlurriness>0?t:e).get(S)),S}function v(E){let S=!1;const L=_(E);L===null?f(o,l):L&&L.isColor&&(f(L,1),S=!0);const w=i.xr.getEnvironmentBlendMode();w==="additive"?n.buffers.color.setClear(0,0,0,1,a):w==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||S)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(E,S){const L=_(S);L&&(L.isCubeTexture||L.mapping===Wr)?(h===void 0&&(h=new Jt(new Qi(1,1,1),new Un({name:"BackgroundCubeMaterial",uniforms:Ti(nn.backgroundCube.uniforms),vertexShader:nn.backgroundCube.vertexShader,fragmentShader:nn.backgroundCube.fragmentShader,side:It,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,C,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),Vn.copy(S.backgroundRotation),Vn.x*=-1,Vn.y*=-1,Vn.z*=-1,L.isCubeTexture&&L.isRenderTargetTexture===!1&&(Vn.y*=-1,Vn.z*=-1),h.material.uniforms.envMap.value=L,h.material.uniforms.flipEnvMap.value=L.isCubeTexture&&L.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(jd.makeRotationFromEuler(Vn)),h.material.toneMapped=Qe.getTransfer(L.colorSpace)!==st,(u!==L||d!==L.version||p!==i.toneMapping)&&(h.material.needsUpdate=!0,u=L,d=L.version,p=i.toneMapping),h.layers.enableAll(),E.unshift(h,h.geometry,h.material,0,0,null)):L&&L.isTexture&&(c===void 0&&(c=new Jt(new qr(2,2),new Un({name:"BackgroundMaterial",uniforms:Ti(nn.background.uniforms),vertexShader:nn.background.vertexShader,fragmentShader:nn.background.fragmentShader,side:Sn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=L,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=Qe.getTransfer(L.colorSpace)!==st,L.matrixAutoUpdate===!0&&L.updateMatrix(),c.material.uniforms.uvTransform.value.copy(L.matrix),(u!==L||d!==L.version||p!==i.toneMapping)&&(c.material.needsUpdate=!0,u=L,d=L.version,p=i.toneMapping),c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null))}function f(E,S){E.getRGB(Er,Ml(i)),n.buffers.color.setClear(Er.r,Er.g,Er.b,S,a)}function b(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(E,S=1){o.set(E),l=S,f(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(E){l=E,f(o,l)},render:v,addToRenderList:m,dispose:b}}function Zd(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null);let s=r,a=!1;function o(x,R,H,B,j){let J=!1;const W=u(B,H,R);s!==W&&(s=W,c(s.object)),J=p(x,B,H,j),J&&_(x,B,H,j),j!==null&&e.update(j,i.ELEMENT_ARRAY_BUFFER),(J||a)&&(a=!1,S(x,R,H,B),j!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function l(){return i.createVertexArray()}function c(x){return i.bindVertexArray(x)}function h(x){return i.deleteVertexArray(x)}function u(x,R,H){const B=H.wireframe===!0;let j=n[x.id];j===void 0&&(j={},n[x.id]=j);let J=j[R.id];J===void 0&&(J={},j[R.id]=J);let W=J[B];return W===void 0&&(W=d(l()),J[B]=W),W}function d(x){const R=[],H=[],B=[];for(let j=0;j<t;j++)R[j]=0,H[j]=0,B[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:H,attributeDivisors:B,object:x,attributes:{},index:null}}function p(x,R,H,B){const j=s.attributes,J=R.attributes;let W=0;const ne=H.getAttributes();for(const G in ne)if(ne[G].location>=0){const xe=j[G];let se=J[G];if(se===void 0&&(G==="instanceMatrix"&&x.instanceMatrix&&(se=x.instanceMatrix),G==="instanceColor"&&x.instanceColor&&(se=x.instanceColor)),xe===void 0||xe.attribute!==se||se&&xe.data!==se.data)return!0;W++}return s.attributesNum!==W||s.index!==B}function _(x,R,H,B){const j={},J=R.attributes;let W=0;const ne=H.getAttributes();for(const G in ne)if(ne[G].location>=0){let xe=J[G];xe===void 0&&(G==="instanceMatrix"&&x.instanceMatrix&&(xe=x.instanceMatrix),G==="instanceColor"&&x.instanceColor&&(xe=x.instanceColor));const se={};se.attribute=xe,xe&&xe.data&&(se.data=xe.data),j[G]=se,W++}s.attributes=j,s.attributesNum=W,s.index=B}function v(){const x=s.newAttributes;for(let R=0,H=x.length;R<H;R++)x[R]=0}function m(x){f(x,0)}function f(x,R){const H=s.newAttributes,B=s.enabledAttributes,j=s.attributeDivisors;H[x]=1,B[x]===0&&(i.enableVertexAttribArray(x),B[x]=1),j[x]!==R&&(i.vertexAttribDivisor(x,R),j[x]=R)}function b(){const x=s.newAttributes,R=s.enabledAttributes;for(let H=0,B=R.length;H<B;H++)R[H]!==x[H]&&(i.disableVertexAttribArray(H),R[H]=0)}function E(x,R,H,B,j,J,W){W===!0?i.vertexAttribIPointer(x,R,H,j,J):i.vertexAttribPointer(x,R,H,B,j,J)}function S(x,R,H,B){v();const j=B.attributes,J=H.getAttributes(),W=R.defaultAttributeValues;for(const ne in J){const G=J[ne];if(G.location>=0){let fe=j[ne];if(fe===void 0&&(ne==="instanceMatrix"&&x.instanceMatrix&&(fe=x.instanceMatrix),ne==="instanceColor"&&x.instanceColor&&(fe=x.instanceColor)),fe!==void 0){const xe=fe.normalized,se=fe.itemSize,We=e.get(fe);if(We===void 0)continue;const Ze=We.buffer,Y=We.type,le=We.bytesPerElement,Pe=Y===i.INT||Y===i.UNSIGNED_INT||fe.gpuType===Ea;if(fe.isInterleavedBufferAttribute){const ve=fe.data,Ue=ve.stride,Z=fe.offset;if(ve.isInstancedInterleavedBuffer){for(let Q=0;Q<G.locationSize;Q++)f(G.location+Q,ve.meshPerAttribute);x.isInstancedMesh!==!0&&B._maxInstanceCount===void 0&&(B._maxInstanceCount=ve.meshPerAttribute*ve.count)}else for(let Q=0;Q<G.locationSize;Q++)m(G.location+Q);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let Q=0;Q<G.locationSize;Q++)E(G.location+Q,se/G.locationSize,Y,xe,Ue*le,(Z+se/G.locationSize*Q)*le,Pe)}else{if(fe.isInstancedBufferAttribute){for(let ve=0;ve<G.locationSize;ve++)f(G.location+ve,fe.meshPerAttribute);x.isInstancedMesh!==!0&&B._maxInstanceCount===void 0&&(B._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let ve=0;ve<G.locationSize;ve++)m(G.location+ve);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let ve=0;ve<G.locationSize;ve++)E(G.location+ve,se/G.locationSize,Y,xe,se*le,se/G.locationSize*ve*le,Pe)}}else if(W!==void 0){const xe=W[ne];if(xe!==void 0)switch(xe.length){case 2:i.vertexAttrib2fv(G.location,xe);break;case 3:i.vertexAttrib3fv(G.location,xe);break;case 4:i.vertexAttrib4fv(G.location,xe);break;default:i.vertexAttrib1fv(G.location,xe)}}}}b()}function L(){P();for(const x in n){const R=n[x];for(const H in R){const B=R[H];for(const j in B)h(B[j].object),delete B[j];delete R[H]}delete n[x]}}function w(x){if(n[x.id]===void 0)return;const R=n[x.id];for(const H in R){const B=R[H];for(const j in B)h(B[j].object),delete B[j];delete R[H]}delete n[x.id]}function C(x){for(const R in n){const H=n[R];if(H[x.id]===void 0)continue;const B=H[x.id];for(const j in B)h(B[j].object),delete B[j];delete H[x.id]}}function P(){y(),a=!0,s!==r&&(s=r,c(s.object))}function y(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:P,resetDefaultState:y,dispose:L,releaseStatesOfGeometry:w,releaseStatesOfProgram:C,initAttributes:v,enableAttribute:m,disableUnusedAttributes:b}}function $d(i,e,t){let n;function r(c){n=c}function s(c,h){i.drawArrays(n,c,h),t.update(h,n,1)}function a(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),t.update(h,n,u))}function o(c,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let p=0;for(let _=0;_<u;_++)p+=h[_];t.update(p,n,1)}function l(c,h,u,d){if(u===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let _=0;_<c.length;_++)a(c[_],h[_],d[_]);else{p.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let _=0;for(let v=0;v<u;v++)_+=h[v]*d[v];t.update(_,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Jd(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){return!(C!==$t&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const P=C===Zi&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==an&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==gn&&!P)}function l(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),E=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),L=_>0,w=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:_,maxTextureSize:v,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:S,vertexTextures:L,maxSamples:w}}function Qd(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new Cn,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const p=u.length!==0||d||n!==0||r;return r=d,n=u.length,p},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,p){const _=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,f=i.get(u);if(!r||_===null||_.length===0||s&&!m)s?h(null):c();else{const b=s?0:n,E=b*4;let S=f.clippingState||null;l.value=S,S=h(_,d,E,p);for(let L=0;L!==E;++L)S[L]=t[L];f.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,p,_){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=l.value,_!==!0||m===null){const f=p+v*4,b=d.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<f)&&(m=new Float32Array(f));for(let E=0,S=p;E!==v;++E,S+=4)a.copy(u[E]).applyMatrix4(b,o),a.normal.toArray(m,S),m[S+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}function ep(i){let e=new WeakMap;function t(a,o){return o===ks?a.mapping=Si:o===Hs&&(a.mapping=yi),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===ks||o===Hs)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 Yh(l.height);return c.fromEquirectangularTexture(i,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const mi=4,Mo=[.125,.215,.35,.446,.526,.582],qn=20,Es=new Rl,So=new Ke;let Ts=null,bs=0,As=0,ws=!1;const Wn=(1+Math.sqrt(5))/2,di=1/Wn,yo=[new N(-Wn,di,0),new N(Wn,di,0),new N(-di,0,Wn),new N(di,0,Wn),new N(0,Wn,-di),new N(0,Wn,di),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],tp=new N;class Eo{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100,s={}){const{size:a=256,position:o=tp}=s;Ts=this._renderer.getRenderTarget(),bs=this._renderer.getActiveCubeFace(),As=this._renderer.getActiveMipmapLevel(),ws=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,r,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=Ao(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=bo(),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(Ts,bs,As),this._renderer.xr.enabled=ws,e.scissorTest=!1,Tr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Si||e.mapping===yi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ts=this._renderer.getRenderTarget(),bs=this._renderer.getActiveCubeFace(),As=this._renderer.getActiveMipmapLevel(),ws=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:rn,minFilter:rn,generateMipmaps:!1,type:Zi,format:$t,colorSpace:Ei,depthBuffer:!1},r=To(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=To(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=np(s)),this._blurMaterial=ip(s,e,t)}return r}_compileMaterial(e){const t=new Jt(this._lodPlanes[0],e);this._renderer.compile(t,Es)}_sceneToCubeUV(e,t,n,r,s){const l=new Xt(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,p=u.toneMapping;u.getClearColor(So),u.toneMapping=Ln,u.autoClear=!1;const _=new gl({name:"PMREM.Background",side:It,depthWrite:!1,depthTest:!1}),v=new Jt(new Qi,_);let m=!1;const f=e.background;f?f.isColor&&(_.color.copy(f),e.background=null,m=!0):(_.color.copy(So),m=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[b],s.y,s.z)):E===1?(l.up.set(0,0,c[b]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[b],s.z)):(l.up.set(0,c[b],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[b]));const S=this._cubeSize;Tr(r,E*S,b>2?S:0,S,S),u.setRenderTarget(r),m&&u.render(v,l),u.render(e,l)}v.geometry.dispose(),v.material.dispose(),u.toneMapping=p,u.autoClear=d,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Si||e.mapping===yi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ao()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=bo());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new Jt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Tr(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Es)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=yo[(r-s-1)%yo.length];this._blur(e,s-1,s,a,o)}t.autoClear=n}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new Jt(this._lodPlanes[r],c),d=c.uniforms,p=this._sizeLods[n]-1,_=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*qn-1),v=s/_,m=isFinite(s)?1+Math.floor(h*v):qn;m>qn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${qn}`);const f=[];let b=0;for(let C=0;C<qn;++C){const P=C/v,y=Math.exp(-P*P/2);f.push(y),C===0?b+=y:C<m&&(b+=2*y)}for(let C=0;C<f.length;C++)f[C]=f[C]/b;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:E}=this;d.dTheta.value=_,d.mipInt.value=E-n;const S=this._sizeLods[r],L=3*S*(r>E-mi?r-E+mi:0),w=4*(this._cubeSize-S);Tr(t,L,w,3*S,2*S),l.setRenderTarget(t),l.render(u,Es)}}function np(i){const e=[],t=[],n=[];let r=i;const s=i-mi+1+Mo.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>i-mi?l=Mo[a-i+mi-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],p=6,_=6,v=3,m=2,f=1,b=new Float32Array(v*_*p),E=new Float32Array(m*_*p),S=new Float32Array(f*_*p);for(let w=0;w<p;w++){const C=w%3*2/3-1,P=w>2?0:-1,y=[C,P,0,C+2/3,P,0,C+2/3,P+1,0,C,P,0,C+2/3,P+1,0,C,P+1,0];b.set(y,v*_*w),E.set(d,m*_*w);const x=[w,w,w,w,w,w];S.set(x,f*_*w)}const L=new en;L.setAttribute("position",new sn(b,v)),L.setAttribute("uv",new sn(E,m)),L.setAttribute("faceIndex",new sn(S,f)),e.push(L),r>mi&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function To(i,e,t){const n=new $n(i,e,t);return n.texture.mapping=Wr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Tr(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function ip(i,e,t){const n=new Float32Array(qn),r=new N(0,1,0);return new Un({name:"SphericalGaussianBlur",defines:{n:qn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Da(),fragmentShader:`
3575
-
3576
- precision mediump float;
3577
- precision mediump int;
3578
-
3579
- varying vec3 vOutputDirection;
3580
-
3581
- uniform sampler2D envMap;
3582
- uniform int samples;
3583
- uniform float weights[ n ];
3584
- uniform bool latitudinal;
3585
- uniform float dTheta;
3586
- uniform float mipInt;
3587
- uniform vec3 poleAxis;
3588
-
3589
- #define ENVMAP_TYPE_CUBE_UV
3590
- #include <cube_uv_reflection_fragment>
3591
-
3592
- vec3 getSample( float theta, vec3 axis ) {
3593
-
3594
- float cosTheta = cos( theta );
3595
- // Rodrigues' axis-angle rotation
3596
- vec3 sampleDirection = vOutputDirection * cosTheta
3597
- + cross( axis, vOutputDirection ) * sin( theta )
3598
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3599
-
3600
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
3601
-
3602
- }
3603
-
3604
- void main() {
3605
-
3606
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3607
-
3608
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3609
-
3610
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3611
-
3612
- }
3613
-
3614
- axis = normalize( axis );
3615
-
3616
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3617
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3618
-
3619
- for ( int i = 1; i < n; i++ ) {
3620
-
3621
- if ( i >= samples ) {
3622
-
3623
- break;
3624
-
3625
- }
3626
-
3627
- float theta = dTheta * float( i );
3628
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3629
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3630
-
3631
- }
3632
-
3633
- }
3634
- `,blending:Dn,depthTest:!1,depthWrite:!1})}function bo(){return new Un({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Da(),fragmentShader:`
3635
-
3636
- precision mediump float;
3637
- precision mediump int;
3638
-
3639
- varying vec3 vOutputDirection;
3640
-
3641
- uniform sampler2D envMap;
3642
-
3643
- #include <common>
3644
-
3645
- void main() {
3646
-
3647
- vec3 outputDirection = normalize( vOutputDirection );
3648
- vec2 uv = equirectUv( outputDirection );
3649
-
3650
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3651
-
3652
- }
3653
- `,blending:Dn,depthTest:!1,depthWrite:!1})}function Ao(){return new Un({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Da(),fragmentShader:`
3654
-
3655
- precision mediump float;
3656
- precision mediump int;
3657
-
3658
- uniform float flipEnvMap;
3659
-
3660
- varying vec3 vOutputDirection;
3661
-
3662
- uniform samplerCube envMap;
3663
-
3664
- void main() {
3665
-
3666
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3667
-
3668
- }
3669
- `,blending:Dn,depthTest:!1,depthWrite:!1})}function Da(){return`
3670
-
3671
- precision mediump float;
3672
- precision mediump int;
3673
-
3674
- attribute float faceIndex;
3675
-
3676
- varying vec3 vOutputDirection;
3677
-
3678
- // RH coordinate system; PMREM face-indexing convention
3679
- vec3 getDirection( vec2 uv, float face ) {
3680
-
3681
- uv = 2.0 * uv - 1.0;
3682
-
3683
- vec3 direction = vec3( uv, 1.0 );
3684
-
3685
- if ( face == 0.0 ) {
3686
-
3687
- direction = direction.zyx; // ( 1, v, u ) pos x
3688
-
3689
- } else if ( face == 1.0 ) {
3690
-
3691
- direction = direction.xzy;
3692
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3693
-
3694
- } else if ( face == 2.0 ) {
3695
-
3696
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
3697
-
3698
- } else if ( face == 3.0 ) {
3699
-
3700
- direction = direction.zyx;
3701
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
3702
-
3703
- } else if ( face == 4.0 ) {
3704
-
3705
- direction = direction.xzy;
3706
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
3707
-
3708
- } else if ( face == 5.0 ) {
3709
-
3710
- direction.z *= -1.0; // ( u, v, -1 ) neg z
3711
-
3712
- }
3713
-
3714
- return direction;
3715
-
3716
- }
3717
-
3718
- void main() {
3719
-
3720
- vOutputDirection = getDirection( uv, faceIndex );
3721
- gl_Position = vec4( position, 1.0 );
3722
-
3723
- }
3724
- `}function rp(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===ks||l===Hs,h=l===Si||l===yi;if(c||h){let u=e.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Eo(i)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),u.texture;if(u!==void 0)return u.texture;{const p=o.image;return c&&p&&p.height>0||h&&p&&r(p)?(t===null&&(t=new Eo(i)),u=c?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",s),u.texture):null}}}return o}function r(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function sp(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&vi("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function ap(i,e,t,n){const r={},s=new WeakMap;function a(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const _ in d.attributes)e.remove(d.attributes[_]);d.removeEventListener("dispose",a),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(u){const d=u.attributes;for(const p in d)e.update(d[p],i.ARRAY_BUFFER)}function c(u){const d=[],p=u.index,_=u.attributes.position;let v=0;if(p!==null){const b=p.array;v=p.version;for(let E=0,S=b.length;E<S;E+=3){const L=b[E+0],w=b[E+1],C=b[E+2];d.push(L,w,w,C,C,L)}}else if(_!==void 0){const b=_.array;v=_.version;for(let E=0,S=b.length/3-1;E<S;E+=3){const L=E+0,w=E+1,C=E+2;d.push(L,w,w,C,C,L)}}else return;const m=new(dl(d)?xl:vl)(d,1);m.version=v;const f=s.get(u);f&&e.remove(f),s.set(u,m)}function h(u){const d=s.get(u);if(d){const p=u.index;p!==null&&d.version<p.version&&c(u)}else c(u);return s.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function op(i,e,t){let n;function r(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,p){i.drawElements(n,p,s,d*a),t.update(p,n,1)}function c(d,p,_){_!==0&&(i.drawElementsInstanced(n,p,s,d*a,_),t.update(p,n,_))}function h(d,p,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,s,d,0,_);let m=0;for(let f=0;f<_;f++)m+=p[f];t.update(m,n,1)}function u(d,p,_,v){if(_===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<d.length;f++)c(d[f]/a,p[f],v[f]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,s,d,0,v,0,_);let f=0;for(let b=0;b<_;b++)f+=p[b]*v[b];t.update(f,n,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function lp(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(s/3);break;case i.LINES:t.lines+=o*(s/2);break;case i.LINE_STRIP:t.lines+=o*(s-1);break;case i.LINE_LOOP:t.lines+=o*s;break;case i.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function cp(i,e,t){const n=new WeakMap,r=new pt;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let y=function(){C.dispose(),n.delete(o),o.removeEventListener("dispose",y)};d!==void 0&&d.texture.dispose();const p=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let E=0;p===!0&&(E=1),_===!0&&(E=2),v===!0&&(E=3);let S=o.attributes.position.count*E,L=1;S>e.maxTextureSize&&(L=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const w=new Float32Array(S*L*4*u),C=new pl(w,S,L,u);C.type=gn,C.needsUpdate=!0;const P=E*4;for(let x=0;x<u;x++){const R=m[x],H=f[x],B=b[x],j=S*L*4*x;for(let J=0;J<R.count;J++){const W=J*P;p===!0&&(r.fromBufferAttribute(R,J),w[j+W+0]=r.x,w[j+W+1]=r.y,w[j+W+2]=r.z,w[j+W+3]=0),_===!0&&(r.fromBufferAttribute(H,J),w[j+W+4]=r.x,w[j+W+5]=r.y,w[j+W+6]=r.z,w[j+W+7]=0),v===!0&&(r.fromBufferAttribute(B,J),w[j+W+8]=r.x,w[j+W+9]=r.y,w[j+W+10]=r.z,w[j+W+11]=B.itemSize===4?r.w:1)}}d={count:u,texture:C,size:new Xe(S,L)},n.set(o,d),o.addEventListener("dispose",y)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const _=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function hp(i,e,t,n){let r=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,u=e.get(l,h);if(r.get(u)!==c&&(e.update(u),r.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return u}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const Pl=new Pt,wo=new El(1,1),Dl=new pl,Ll=new Ph,Ul=new yl,Ro=[],Co=[],Po=new Float32Array(16),Do=new Float32Array(9),Lo=new Float32Array(4);function Ri(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=Ro[r];if(s===void 0&&(s=new Float32Array(r),Ro[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function gt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function vt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Yr(i,e){let t=Co[e];t===void 0&&(t=new Int32Array(e),Co[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function up(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function fp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gt(t,e))return;i.uniform2fv(this.addr,e),vt(t,e)}}function dp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(gt(t,e))return;i.uniform3fv(this.addr,e),vt(t,e)}}function pp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(gt(t,e))return;i.uniform4fv(this.addr,e),vt(t,e)}}function mp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(gt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),vt(t,e)}else{if(gt(t,n))return;Lo.set(n),i.uniformMatrix2fv(this.addr,!1,Lo),vt(t,n)}}function _p(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(gt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),vt(t,e)}else{if(gt(t,n))return;Do.set(n),i.uniformMatrix3fv(this.addr,!1,Do),vt(t,n)}}function gp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(gt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),vt(t,e)}else{if(gt(t,n))return;Po.set(n),i.uniformMatrix4fv(this.addr,!1,Po),vt(t,n)}}function vp(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function xp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gt(t,e))return;i.uniform2iv(this.addr,e),vt(t,e)}}function Mp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(gt(t,e))return;i.uniform3iv(this.addr,e),vt(t,e)}}function Sp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(gt(t,e))return;i.uniform4iv(this.addr,e),vt(t,e)}}function yp(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Ep(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gt(t,e))return;i.uniform2uiv(this.addr,e),vt(t,e)}}function Tp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(gt(t,e))return;i.uniform3uiv(this.addr,e),vt(t,e)}}function bp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(gt(t,e))return;i.uniform4uiv(this.addr,e),vt(t,e)}}function Ap(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(wo.compareFunction=fl,s=wo):s=Pl,t.setTexture2D(e||s,r)}function wp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Ll,r)}function Rp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||Ul,r)}function Cp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Dl,r)}function Pp(i){switch(i){case 5126:return up;case 35664:return fp;case 35665:return dp;case 35666:return pp;case 35674:return mp;case 35675:return _p;case 35676:return gp;case 5124:case 35670:return vp;case 35667:case 35671:return xp;case 35668:case 35672:return Mp;case 35669:case 35673:return Sp;case 5125:return yp;case 36294:return Ep;case 36295:return Tp;case 36296:return bp;case 35678:case 36198:case 36298:case 36306:case 35682:return Ap;case 35679:case 36299:case 36307:return wp;case 35680:case 36300:case 36308:case 36293:return Rp;case 36289:case 36303:case 36311:case 36292:return Cp}}function Dp(i,e){i.uniform1fv(this.addr,e)}function Lp(i,e){const t=Ri(e,this.size,2);i.uniform2fv(this.addr,t)}function Up(i,e){const t=Ri(e,this.size,3);i.uniform3fv(this.addr,t)}function Ip(i,e){const t=Ri(e,this.size,4);i.uniform4fv(this.addr,t)}function Np(i,e){const t=Ri(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Fp(i,e){const t=Ri(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Op(i,e){const t=Ri(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Bp(i,e){i.uniform1iv(this.addr,e)}function zp(i,e){i.uniform2iv(this.addr,e)}function kp(i,e){i.uniform3iv(this.addr,e)}function Hp(i,e){i.uniform4iv(this.addr,e)}function Vp(i,e){i.uniform1uiv(this.addr,e)}function Gp(i,e){i.uniform2uiv(this.addr,e)}function Wp(i,e){i.uniform3uiv(this.addr,e)}function Xp(i,e){i.uniform4uiv(this.addr,e)}function qp(i,e,t){const n=this.cache,r=e.length,s=Yr(t,r);gt(n,s)||(i.uniform1iv(this.addr,s),vt(n,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Pl,s[a])}function Yp(i,e,t){const n=this.cache,r=e.length,s=Yr(t,r);gt(n,s)||(i.uniform1iv(this.addr,s),vt(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Ll,s[a])}function jp(i,e,t){const n=this.cache,r=e.length,s=Yr(t,r);gt(n,s)||(i.uniform1iv(this.addr,s),vt(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Ul,s[a])}function Kp(i,e,t){const n=this.cache,r=e.length,s=Yr(t,r);gt(n,s)||(i.uniform1iv(this.addr,s),vt(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Dl,s[a])}function Zp(i){switch(i){case 5126:return Dp;case 35664:return Lp;case 35665:return Up;case 35666:return Ip;case 35674:return Np;case 35675:return Fp;case 35676:return Op;case 5124:case 35670:return Bp;case 35667:case 35671:return zp;case 35668:case 35672:return kp;case 35669:case 35673:return Hp;case 5125:return Vp;case 36294:return Gp;case 36295:return Wp;case 36296:return Xp;case 35678:case 36198:case 36298:case 36306:case 35682:return qp;case 35679:case 36299:case 36307:return Yp;case 35680:case 36300:case 36308:case 36293:return jp;case 36289:case 36303:case 36311:case 36292:return Kp}}class $p{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Pp(t.type)}}class Jp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Zp(t.type)}}class Qp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const Rs=/(\w+)(\])?(\[|\.)?/g;function Uo(i,e){i.seq.push(e),i.map[e.id]=e}function em(i,e,t){const n=i.name,r=n.length;for(Rs.lastIndex=0;;){const s=Rs.exec(n),a=Rs.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){Uo(t,c===void 0?new $p(o,i,e):new Jp(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new Qp(o),Uo(t,u)),t=u}}}class Nr{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);em(s,a,this)}}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function Io(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const tm=37297;let nm=0;function im(i,e){const t=i.split(`
3725
- `),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3726
- `)}const No=new qe;function rm(i){Qe._getMatrix(No,Qe.workingColorSpace,i);const e=`mat3( ${No.elements.map(t=>t.toFixed(4))} )`;switch(Qe.getTransfer(i)){case Br:return[e,"LinearTransferOETF"];case st:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Fo(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
3727
-
3728
- `+r+`
3729
-
3730
- `+im(i.getShaderSource(e),a)}else return r}function sm(i,e){const t=rm(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3731
- `)}function am(i,e){let t;switch(e){case th:t="Linear";break;case nh:t="Reinhard";break;case ih:t="Cineon";break;case rh:t="ACESFilmic";break;case ah:t="AgX";break;case oh:t="Neutral";break;case sh:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const br=new N;function om(){Qe.getLuminanceCoefficients(br);const i=br.x.toFixed(4),e=br.y.toFixed(4),t=br.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3732
- `)}function lm(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Gi).join(`
3733
- `)}function cm(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3734
- `)}function hm(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Gi(i){return i!==""}function Oo(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Bo(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const um=/^[ \t]*#include +<([\w\d./]+)>/gm;function ga(i){return i.replace(um,dm)}const fm=new Map;function dm(i,e){let t=je[e];if(t===void 0){const n=fm.get(e);if(n!==void 0)t=je[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return ga(t)}const pm=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function zo(i){return i.replace(pm,mm)}function mm(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function ko(i){let e=`precision ${i.precision} float;
3735
- precision ${i.precision} int;
3736
- precision ${i.precision} sampler2D;
3737
- precision ${i.precision} samplerCube;
3738
- precision ${i.precision} sampler3D;
3739
- precision ${i.precision} sampler2DArray;
3740
- precision ${i.precision} sampler2DShadow;
3741
- precision ${i.precision} samplerCubeShadow;
3742
- precision ${i.precision} sampler2DArrayShadow;
3743
- precision ${i.precision} isampler2D;
3744
- precision ${i.precision} isampler3D;
3745
- precision ${i.precision} isamplerCube;
3746
- precision ${i.precision} isampler2DArray;
3747
- precision ${i.precision} usampler2D;
3748
- precision ${i.precision} usampler3D;
3749
- precision ${i.precision} usamplerCube;
3750
- precision ${i.precision} usampler2DArray;
3751
- `;return i.precision==="highp"?e+=`
3752
- #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
3753
- #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
3754
- #define LOW_PRECISION`),e}function _m(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===tl?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Ic?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===pn&&(e="SHADOWMAP_TYPE_VSM"),e}function gm(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Si:case yi:e="ENVMAP_TYPE_CUBE";break;case Wr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function vm(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case yi:e="ENVMAP_MODE_REFRACTION";break}return e}function xm(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case ya:e="ENVMAP_BLENDING_MULTIPLY";break;case Qc:e="ENVMAP_BLENDING_MIX";break;case eh:e="ENVMAP_BLENDING_ADD";break}return e}function Mm(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function Sm(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=_m(t),c=gm(t),h=vm(t),u=xm(t),d=Mm(t),p=lm(t),_=cm(s),v=r.createProgram();let m,f,b=t.glslVersion?"#version "+t.glslVersion+`
3755
- `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(Gi).join(`
3756
- `),m.length>0&&(m+=`
3757
- `),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(Gi).join(`
3758
- `),f.length>0&&(f+=`
3759
- `)):(m=[ko(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3760
- `].filter(Gi).join(`
3761
- `),f=[ko(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ln?"#define TONE_MAPPING":"",t.toneMapping!==Ln?je.tonemapping_pars_fragment:"",t.toneMapping!==Ln?am("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",je.colorspace_pars_fragment,sm("linearToOutputTexel",t.outputColorSpace),om(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3762
- `].filter(Gi).join(`
3763
- `)),a=ga(a),a=Oo(a,t),a=Bo(a,t),o=ga(o),o=Oo(o,t),o=Bo(o,t),a=zo(a),o=zo(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es
3764
- `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3765
- `)+`
3766
- `+m,f=["#define varying in",t.glslVersion===Wa?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Wa?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
3767
- `)+`
3768
- `+f);const E=b+m+a,S=b+f+o,L=Io(r,r.VERTEX_SHADER,E),w=Io(r,r.FRAGMENT_SHADER,S);r.attachShader(v,L),r.attachShader(v,w),t.index0AttributeName!==void 0?r.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function C(R){if(i.debug.checkShaderErrors){const H=r.getProgramInfoLog(v).trim(),B=r.getShaderInfoLog(L).trim(),j=r.getShaderInfoLog(w).trim();let J=!0,W=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(J=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,v,L,w);else{const ne=Fo(r,L,"vertex"),G=Fo(r,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
3769
-
3770
- Material Name: `+R.name+`
3771
- Material Type: `+R.type+`
3772
-
3773
- Program Info Log: `+H+`
3774
- `+ne+`
3775
- `+G)}else H!==""?console.warn("THREE.WebGLProgram: Program Info Log:",H):(B===""||j==="")&&(W=!1);W&&(R.diagnostics={runnable:J,programLog:H,vertexShader:{log:B,prefix:m},fragmentShader:{log:j,prefix:f}})}r.deleteShader(L),r.deleteShader(w),P=new Nr(r,v),y=hm(r,v)}let P;this.getUniforms=function(){return P===void 0&&C(this),P};let y;this.getAttributes=function(){return y===void 0&&C(this),y};let x=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return x===!1&&(x=r.getProgramParameter(v,tm)),x},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=nm++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=L,this.fragmentShader=w,this}let ym=0;class Em{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Tm(e),t.set(e,n)),n}}class Tm{constructor(e){this.id=ym++,this.code=e,this.usedTimes=0}}function bm(i,e,t,n,r,s,a){const o=new ml,l=new Em,c=new Set,h=[],u=r.logarithmicDepthBuffer,d=r.vertexTextures;let p=r.precision;const _={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 v(y){return c.add(y),y===0?"uv":`uv${y}`}function m(y,x,R,H,B){const j=H.fog,J=B.geometry,W=y.isMeshStandardMaterial?H.environment:null,ne=(y.isMeshStandardMaterial?t:e).get(y.envMap||W),G=ne&&ne.mapping===Wr?ne.image.height:null,fe=_[y.type];y.precision!==null&&(p=r.getMaxPrecision(y.precision),p!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",p,"instead."));const xe=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,se=xe!==void 0?xe.length:0;let We=0;J.morphAttributes.position!==void 0&&(We=1),J.morphAttributes.normal!==void 0&&(We=2),J.morphAttributes.color!==void 0&&(We=3);let Ze,Y,le,Pe;if(fe){const et=nn[fe];Ze=et.vertexShader,Y=et.fragmentShader}else Ze=y.vertexShader,Y=y.fragmentShader,l.update(y),le=l.getVertexShaderID(y),Pe=l.getFragmentShaderID(y);const ve=i.getRenderTarget(),Ue=i.state.buffers.depth.getReversed(),Z=B.isInstancedMesh===!0,Q=B.isBatchedMesh===!0,de=!!y.map,Se=!!y.matcap,oe=!!ne,A=!!y.aoMap,ae=!!y.lightMap,Re=!!y.bumpMap,Ye=!!y.normalMap,ie=!!y.displacementMap,Fe=!!y.emissiveMap,Ee=!!y.metalnessMap,Ve=!!y.roughnessMap,lt=y.anisotropy>0,T=y.clearcoat>0,g=y.dispersion>0,F=y.iridescence>0,q=y.sheen>0,K=y.transmission>0,V=lt&&!!y.anisotropyMap,De=T&&!!y.clearcoatMap,he=T&&!!y.clearcoatNormalMap,be=T&&!!y.clearcoatRoughnessMap,Le=F&&!!y.iridescenceMap,ee=F&&!!y.iridescenceThicknessMap,Me=q&&!!y.sheenColorMap,Oe=q&&!!y.sheenRoughnessMap,Ne=!!y.specularMap,ce=!!y.specularColorMap,ke=!!y.specularIntensityMap,D=K&&!!y.transmissionMap,pe=K&&!!y.thicknessMap,te=!!y.gradientMap,ye=!!y.alphaMap,O=y.alphaTest>0,X=!!y.alphaHash,ue=!!y.extensions;let Be=Ln;y.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(Be=i.toneMapping);const ot={shaderID:fe,shaderType:y.type,shaderName:y.name,vertexShader:Ze,fragmentShader:Y,defines:y.defines,customVertexShaderID:le,customFragmentShaderID:Pe,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:p,batching:Q,batchingColor:Q&&B._colorsTexture!==null,instancing:Z,instancingColor:Z&&B.instanceColor!==null,instancingMorph:Z&&B.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:ve===null?i.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:Ei,alphaToCoverage:!!y.alphaToCoverage,map:de,matcap:Se,envMap:oe,envMapMode:oe&&ne.mapping,envMapCubeUVHeight:G,aoMap:A,lightMap:ae,bumpMap:Re,normalMap:Ye,displacementMap:d&&ie,emissiveMap:Fe,normalMapObjectSpace:Ye&&y.normalMapType===uh,normalMapTangentSpace:Ye&&y.normalMapType===ul,metalnessMap:Ee,roughnessMap:Ve,anisotropy:lt,anisotropyMap:V,clearcoat:T,clearcoatMap:De,clearcoatNormalMap:he,clearcoatRoughnessMap:be,dispersion:g,iridescence:F,iridescenceMap:Le,iridescenceThicknessMap:ee,sheen:q,sheenColorMap:Me,sheenRoughnessMap:Oe,specularMap:Ne,specularColorMap:ce,specularIntensityMap:ke,transmission:K,transmissionMap:D,thicknessMap:pe,gradientMap:te,opaque:y.transparent===!1&&y.blending===gi&&y.alphaToCoverage===!1,alphaMap:ye,alphaTest:O,alphaHash:X,combine:y.combine,mapUv:de&&v(y.map.channel),aoMapUv:A&&v(y.aoMap.channel),lightMapUv:ae&&v(y.lightMap.channel),bumpMapUv:Re&&v(y.bumpMap.channel),normalMapUv:Ye&&v(y.normalMap.channel),displacementMapUv:ie&&v(y.displacementMap.channel),emissiveMapUv:Fe&&v(y.emissiveMap.channel),metalnessMapUv:Ee&&v(y.metalnessMap.channel),roughnessMapUv:Ve&&v(y.roughnessMap.channel),anisotropyMapUv:V&&v(y.anisotropyMap.channel),clearcoatMapUv:De&&v(y.clearcoatMap.channel),clearcoatNormalMapUv:he&&v(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:be&&v(y.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&v(y.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&v(y.iridescenceThicknessMap.channel),sheenColorMapUv:Me&&v(y.sheenColorMap.channel),sheenRoughnessMapUv:Oe&&v(y.sheenRoughnessMap.channel),specularMapUv:Ne&&v(y.specularMap.channel),specularColorMapUv:ce&&v(y.specularColorMap.channel),specularIntensityMapUv:ke&&v(y.specularIntensityMap.channel),transmissionMapUv:D&&v(y.transmissionMap.channel),thicknessMapUv:pe&&v(y.thicknessMap.channel),alphaMapUv:ye&&v(y.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(Ye||lt),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:B.isPoints===!0&&!!J.attributes.uv&&(de||ye),fog:!!j,useFog:y.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:Ue,skinning:B.isSkinnedMesh===!0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:se,morphTextureStride:We,numDirLights:x.directional.length,numPointLights:x.point.length,numSpotLights:x.spot.length,numSpotLightMaps:x.spotLightMap.length,numRectAreaLights:x.rectArea.length,numHemiLights:x.hemi.length,numDirLightShadows:x.directionalShadowMap.length,numPointLightShadows:x.pointShadowMap.length,numSpotLightShadows:x.spotShadowMap.length,numSpotLightShadowsWithMaps:x.numSpotLightShadowsWithMaps,numLightProbes:x.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&R.length>0,shadowMapType:i.shadowMap.type,toneMapping:Be,decodeVideoTexture:de&&y.map.isVideoTexture===!0&&Qe.getTransfer(y.map.colorSpace)===st,decodeVideoTextureEmissive:Fe&&y.emissiveMap.isVideoTexture===!0&&Qe.getTransfer(y.emissiveMap.colorSpace)===st,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===_n,flipSided:y.side===It,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:ue&&y.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ue&&y.extensions.multiDraw===!0||Q)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return ot.vertexUv1s=c.has(1),ot.vertexUv2s=c.has(2),ot.vertexUv3s=c.has(3),c.clear(),ot}function f(y){const x=[];if(y.shaderID?x.push(y.shaderID):(x.push(y.customVertexShaderID),x.push(y.customFragmentShaderID)),y.defines!==void 0)for(const R in y.defines)x.push(R),x.push(y.defines[R]);return y.isRawShaderMaterial===!1&&(b(x,y),E(x,y),x.push(i.outputColorSpace)),x.push(y.customProgramCacheKey),x.join()}function b(y,x){y.push(x.precision),y.push(x.outputColorSpace),y.push(x.envMapMode),y.push(x.envMapCubeUVHeight),y.push(x.mapUv),y.push(x.alphaMapUv),y.push(x.lightMapUv),y.push(x.aoMapUv),y.push(x.bumpMapUv),y.push(x.normalMapUv),y.push(x.displacementMapUv),y.push(x.emissiveMapUv),y.push(x.metalnessMapUv),y.push(x.roughnessMapUv),y.push(x.anisotropyMapUv),y.push(x.clearcoatMapUv),y.push(x.clearcoatNormalMapUv),y.push(x.clearcoatRoughnessMapUv),y.push(x.iridescenceMapUv),y.push(x.iridescenceThicknessMapUv),y.push(x.sheenColorMapUv),y.push(x.sheenRoughnessMapUv),y.push(x.specularMapUv),y.push(x.specularColorMapUv),y.push(x.specularIntensityMapUv),y.push(x.transmissionMapUv),y.push(x.thicknessMapUv),y.push(x.combine),y.push(x.fogExp2),y.push(x.sizeAttenuation),y.push(x.morphTargetsCount),y.push(x.morphAttributeCount),y.push(x.numDirLights),y.push(x.numPointLights),y.push(x.numSpotLights),y.push(x.numSpotLightMaps),y.push(x.numHemiLights),y.push(x.numRectAreaLights),y.push(x.numDirLightShadows),y.push(x.numPointLightShadows),y.push(x.numSpotLightShadows),y.push(x.numSpotLightShadowsWithMaps),y.push(x.numLightProbes),y.push(x.shadowMapType),y.push(x.toneMapping),y.push(x.numClippingPlanes),y.push(x.numClipIntersection),y.push(x.depthPacking)}function E(y,x){o.disableAll(),x.supportsVertexTextures&&o.enable(0),x.instancing&&o.enable(1),x.instancingColor&&o.enable(2),x.instancingMorph&&o.enable(3),x.matcap&&o.enable(4),x.envMap&&o.enable(5),x.normalMapObjectSpace&&o.enable(6),x.normalMapTangentSpace&&o.enable(7),x.clearcoat&&o.enable(8),x.iridescence&&o.enable(9),x.alphaTest&&o.enable(10),x.vertexColors&&o.enable(11),x.vertexAlphas&&o.enable(12),x.vertexUv1s&&o.enable(13),x.vertexUv2s&&o.enable(14),x.vertexUv3s&&o.enable(15),x.vertexTangents&&o.enable(16),x.anisotropy&&o.enable(17),x.alphaHash&&o.enable(18),x.batching&&o.enable(19),x.dispersion&&o.enable(20),x.batchingColor&&o.enable(21),y.push(o.mask),o.disableAll(),x.fog&&o.enable(0),x.useFog&&o.enable(1),x.flatShading&&o.enable(2),x.logarithmicDepthBuffer&&o.enable(3),x.reverseDepthBuffer&&o.enable(4),x.skinning&&o.enable(5),x.morphTargets&&o.enable(6),x.morphNormals&&o.enable(7),x.morphColors&&o.enable(8),x.premultipliedAlpha&&o.enable(9),x.shadowMapEnabled&&o.enable(10),x.doubleSided&&o.enable(11),x.flipSided&&o.enable(12),x.useDepthPacking&&o.enable(13),x.dithering&&o.enable(14),x.transmission&&o.enable(15),x.sheen&&o.enable(16),x.opaque&&o.enable(17),x.pointsUvs&&o.enable(18),x.decodeVideoTexture&&o.enable(19),x.decodeVideoTextureEmissive&&o.enable(20),x.alphaToCoverage&&o.enable(21),y.push(o.mask)}function S(y){const x=_[y.type];let R;if(x){const H=nn[x];R=Gh.clone(H.uniforms)}else R=y.uniforms;return R}function L(y,x){let R;for(let H=0,B=h.length;H<B;H++){const j=h[H];if(j.cacheKey===x){R=j,++R.usedTimes;break}}return R===void 0&&(R=new Sm(i,x,y,s),h.push(R)),R}function w(y){if(--y.usedTimes===0){const x=h.indexOf(y);h[x]=h[h.length-1],h.pop(),y.destroy()}}function C(y){l.remove(y)}function P(){l.dispose()}return{getParameters:m,getProgramCacheKey:f,getUniforms:S,acquireProgram:L,releaseProgram:w,releaseShaderCache:C,programs:h,dispose:P}}function Am(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,l){i.get(a)[o]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function wm(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function Ho(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Vo(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(u,d,p,_,v,m){let f=i[e];return f===void 0?(f={id:u.id,object:u,geometry:d,material:p,groupOrder:_,renderOrder:u.renderOrder,z:v,group:m},i[e]=f):(f.id=u.id,f.object=u,f.geometry=d,f.material=p,f.groupOrder=_,f.renderOrder=u.renderOrder,f.z=v,f.group=m),e++,f}function o(u,d,p,_,v,m){const f=a(u,d,p,_,v,m);p.transmission>0?n.push(f):p.transparent===!0?r.push(f):t.push(f)}function l(u,d,p,_,v,m){const f=a(u,d,p,_,v,m);p.transmission>0?n.unshift(f):p.transparent===!0?r.unshift(f):t.unshift(f)}function c(u,d){t.length>1&&t.sort(u||wm),n.length>1&&n.sort(d||Ho),r.length>1&&r.sort(d||Ho)}function h(){for(let u=e,d=i.length;u<d;u++){const p=i[u];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:o,unshift:l,finish:h,sort:c}}function Rm(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new Vo,i.set(n,[a])):r>=s.length?(a=new Vo,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Cm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new Ke};break;case"SpotLight":t={position:new N,direction:new N,color:new Ke,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new Ke,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new Ke,groundColor:new Ke};break;case"RectAreaLight":t={color:new Ke,position:new N,halfWidth:new N,halfHeight:new N};break}return i[e.id]=t,t}}}function Pm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Dm=0;function Lm(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Um(i){const e=new Cm,t=Pm(),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 N);const r=new N,s=new ht,a=new ht;function o(c){let h=0,u=0,d=0;for(let y=0;y<9;y++)n.probe[y].set(0,0,0);let p=0,_=0,v=0,m=0,f=0,b=0,E=0,S=0,L=0,w=0,C=0;c.sort(Lm);for(let y=0,x=c.length;y<x;y++){const R=c[y],H=R.color,B=R.intensity,j=R.distance,J=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)h+=H.r*B,u+=H.g*B,d+=H.b*B;else if(R.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(R.sh.coefficients[W],B);C++}else if(R.isDirectionalLight){const W=e.get(R);if(W.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){const ne=R.shadow,G=t.get(R);G.shadowIntensity=ne.intensity,G.shadowBias=ne.bias,G.shadowNormalBias=ne.normalBias,G.shadowRadius=ne.radius,G.shadowMapSize=ne.mapSize,n.directionalShadow[p]=G,n.directionalShadowMap[p]=J,n.directionalShadowMatrix[p]=R.shadow.matrix,b++}n.directional[p]=W,p++}else if(R.isSpotLight){const W=e.get(R);W.position.setFromMatrixPosition(R.matrixWorld),W.color.copy(H).multiplyScalar(B),W.distance=j,W.coneCos=Math.cos(R.angle),W.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),W.decay=R.decay,n.spot[v]=W;const ne=R.shadow;if(R.map&&(n.spotLightMap[L]=R.map,L++,ne.updateMatrices(R),R.castShadow&&w++),n.spotLightMatrix[v]=ne.matrix,R.castShadow){const G=t.get(R);G.shadowIntensity=ne.intensity,G.shadowBias=ne.bias,G.shadowNormalBias=ne.normalBias,G.shadowRadius=ne.radius,G.shadowMapSize=ne.mapSize,n.spotShadow[v]=G,n.spotShadowMap[v]=J,S++}v++}else if(R.isRectAreaLight){const W=e.get(R);W.color.copy(H).multiplyScalar(B),W.halfWidth.set(R.width*.5,0,0),W.halfHeight.set(0,R.height*.5,0),n.rectArea[m]=W,m++}else if(R.isPointLight){const W=e.get(R);if(W.color.copy(R.color).multiplyScalar(R.intensity),W.distance=R.distance,W.decay=R.decay,R.castShadow){const ne=R.shadow,G=t.get(R);G.shadowIntensity=ne.intensity,G.shadowBias=ne.bias,G.shadowNormalBias=ne.normalBias,G.shadowRadius=ne.radius,G.shadowMapSize=ne.mapSize,G.shadowCameraNear=ne.camera.near,G.shadowCameraFar=ne.camera.far,n.pointShadow[_]=G,n.pointShadowMap[_]=J,n.pointShadowMatrix[_]=R.shadow.matrix,E++}n.point[_]=W,_++}else if(R.isHemisphereLight){const W=e.get(R);W.skyColor.copy(R.color).multiplyScalar(B),W.groundColor.copy(R.groundColor).multiplyScalar(B),n.hemi[f]=W,f++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=me.LTC_FLOAT_1,n.rectAreaLTC2=me.LTC_FLOAT_2):(n.rectAreaLTC1=me.LTC_HALF_1,n.rectAreaLTC2=me.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const P=n.hash;(P.directionalLength!==p||P.pointLength!==_||P.spotLength!==v||P.rectAreaLength!==m||P.hemiLength!==f||P.numDirectionalShadows!==b||P.numPointShadows!==E||P.numSpotShadows!==S||P.numSpotMaps!==L||P.numLightProbes!==C)&&(n.directional.length=p,n.spot.length=v,n.rectArea.length=m,n.point.length=_,n.hemi.length=f,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=S+L-w,n.spotLightMap.length=L,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=C,P.directionalLength=p,P.pointLength=_,P.spotLength=v,P.rectAreaLength=m,P.hemiLength=f,P.numDirectionalShadows=b,P.numPointShadows=E,P.numSpotShadows=S,P.numSpotMaps=L,P.numLightProbes=C,n.version=Dm++)}function l(c,h){let u=0,d=0,p=0,_=0,v=0;const m=h.matrixWorldInverse;for(let f=0,b=c.length;f<b;f++){const E=c[f];if(E.isDirectionalLight){const S=n.directional[u];S.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),u++}else if(E.isSpotLight){const S=n.spot[p];S.position.setFromMatrixPosition(E.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),p++}else if(E.isRectAreaLight){const S=n.rectArea[_];S.position.setFromMatrixPosition(E.matrixWorld),S.position.applyMatrix4(m),a.identity(),s.copy(E.matrixWorld),s.premultiply(m),a.extractRotation(s),S.halfWidth.set(E.width*.5,0,0),S.halfHeight.set(0,E.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),_++}else if(E.isPointLight){const S=n.point[d];S.position.setFromMatrixPosition(E.matrixWorld),S.position.applyMatrix4(m),d++}else if(E.isHemisphereLight){const S=n.hemi[v];S.direction.setFromMatrixPosition(E.matrixWorld),S.direction.transformDirection(m),v++}}}return{setup:o,setupView:l,state:n}}function Go(i){const e=new Um(i),t=[],n=[];function r(h){c.camera=h,t.length=0,n.length=0}function s(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function Im(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new Go(i),e.set(r,[o])):s>=a.length?(o=new Go(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Nm=`void main() {
3776
- gl_Position = vec4( position, 1.0 );
3777
- }`,Fm=`uniform sampler2D shadow_pass;
3778
- uniform vec2 resolution;
3779
- uniform float radius;
3780
- #include <packing>
3781
- void main() {
3782
- const float samples = float( VSM_SAMPLES );
3783
- float mean = 0.0;
3784
- float squared_mean = 0.0;
3785
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3786
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3787
- for ( float i = 0.0; i < samples; i ++ ) {
3788
- float uvOffset = uvStart + i * uvStride;
3789
- #ifdef HORIZONTAL_PASS
3790
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3791
- mean += distribution.x;
3792
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3793
- #else
3794
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3795
- mean += depth;
3796
- squared_mean += depth * depth;
3797
- #endif
3798
- }
3799
- mean = mean / samples;
3800
- squared_mean = squared_mean / samples;
3801
- float std_dev = sqrt( squared_mean - mean * mean );
3802
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3803
- }`;function Om(i,e,t){let n=new Pa;const r=new Xe,s=new Xe,a=new pt,o=new Qh({depthPacking:hh}),l=new eu,c={},h=t.maxTextureSize,u={[Sn]:It,[It]:Sn,[_n]:_n},d=new Un({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Xe},radius:{value:4}},vertexShader:Nm,fragmentShader:Fm}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const _=new en;_.setAttribute("position",new sn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Jt(_,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=tl;let f=this.type;this.render=function(w,C,P){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;const y=i.getRenderTarget(),x=i.getActiveCubeFace(),R=i.getActiveMipmapLevel(),H=i.state;H.setBlending(Dn),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const B=f!==pn&&this.type===pn,j=f===pn&&this.type!==pn;for(let J=0,W=w.length;J<W;J++){const ne=w[J],G=ne.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",ne,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;r.copy(G.mapSize);const fe=G.getFrameExtents();if(r.multiply(fe),s.copy(G.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/fe.x),r.x=s.x*fe.x,G.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/fe.y),r.y=s.y*fe.y,G.mapSize.y=s.y)),G.map===null||B===!0||j===!0){const se=this.type!==pn?{minFilter:Qt,magFilter:Qt}:{};G.map!==null&&G.map.dispose(),G.map=new $n(r.x,r.y,se),G.map.texture.name=ne.name+".shadowMap",G.camera.updateProjectionMatrix()}i.setRenderTarget(G.map),i.clear();const xe=G.getViewportCount();for(let se=0;se<xe;se++){const We=G.getViewport(se);a.set(s.x*We.x,s.y*We.y,s.x*We.z,s.y*We.w),H.viewport(a),G.updateMatrices(ne,se),n=G.getFrustum(),S(C,P,G.camera,ne,this.type)}G.isPointLightShadow!==!0&&this.type===pn&&b(G,P),G.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(y,x,R)};function b(w,C){const P=e.update(v);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new $n(r.x,r.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(C,null,P,d,v,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(C,null,P,p,v,null)}function E(w,C,P,y){let x=null;const R=P.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0)x=R;else if(x=P.isPointLight===!0?l:o,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const H=x.uuid,B=C.uuid;let j=c[H];j===void 0&&(j={},c[H]=j);let J=j[B];J===void 0&&(J=x.clone(),j[B]=J,C.addEventListener("dispose",L)),x=J}if(x.visible=C.visible,x.wireframe=C.wireframe,y===pn?x.side=C.shadowSide!==null?C.shadowSide:C.side:x.side=C.shadowSide!==null?C.shadowSide:u[C.side],x.alphaMap=C.alphaMap,x.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,x.map=C.map,x.clipShadows=C.clipShadows,x.clippingPlanes=C.clippingPlanes,x.clipIntersection=C.clipIntersection,x.displacementMap=C.displacementMap,x.displacementScale=C.displacementScale,x.displacementBias=C.displacementBias,x.wireframeLinewidth=C.wireframeLinewidth,x.linewidth=C.linewidth,P.isPointLight===!0&&x.isMeshDistanceMaterial===!0){const H=i.properties.get(x);H.light=P}return x}function S(w,C,P,y,x){if(w.visible===!1)return;if(w.layers.test(C.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&x===pn)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,w.matrixWorld);const B=e.update(w),j=w.material;if(Array.isArray(j)){const J=B.groups;for(let W=0,ne=J.length;W<ne;W++){const G=J[W],fe=j[G.materialIndex];if(fe&&fe.visible){const xe=E(w,fe,y,x);w.onBeforeShadow(i,w,C,P,B,xe,G),i.renderBufferDirect(P,null,B,xe,w,G),w.onAfterShadow(i,w,C,P,B,xe,G)}}}else if(j.visible){const J=E(w,j,y,x);w.onBeforeShadow(i,w,C,P,B,J,null),i.renderBufferDirect(P,null,B,J,w,null),w.onAfterShadow(i,w,C,P,B,J,null)}}const H=w.children;for(let B=0,j=H.length;B<j;B++)S(H[B],C,P,y,x)}function L(w){w.target.removeEventListener("dispose",L);for(const P in c){const y=c[P],x=w.target.uuid;x in y&&(y[x].dispose(),delete y[x])}}}const Bm={[Us]:Is,[Ns]:Bs,[Fs]:zs,[Mi]:Os,[Is]:Us,[Bs]:Ns,[zs]:Fs,[Os]:Mi};function zm(i,e){function t(){let D=!1;const pe=new pt;let te=null;const ye=new pt(0,0,0,0);return{setMask:function(O){te!==O&&!D&&(i.colorMask(O,O,O,O),te=O)},setLocked:function(O){D=O},setClear:function(O,X,ue,Be,ot){ot===!0&&(O*=Be,X*=Be,ue*=Be),pe.set(O,X,ue,Be),ye.equals(pe)===!1&&(i.clearColor(O,X,ue,Be),ye.copy(pe))},reset:function(){D=!1,te=null,ye.set(-1,0,0,0)}}}function n(){let D=!1,pe=!1,te=null,ye=null,O=null;return{setReversed:function(X){if(pe!==X){const ue=e.get("EXT_clip_control");X?ue.clipControlEXT(ue.LOWER_LEFT_EXT,ue.ZERO_TO_ONE_EXT):ue.clipControlEXT(ue.LOWER_LEFT_EXT,ue.NEGATIVE_ONE_TO_ONE_EXT),pe=X;const Be=O;O=null,this.setClear(Be)}},getReversed:function(){return pe},setTest:function(X){X?ve(i.DEPTH_TEST):Ue(i.DEPTH_TEST)},setMask:function(X){te!==X&&!D&&(i.depthMask(X),te=X)},setFunc:function(X){if(pe&&(X=Bm[X]),ye!==X){switch(X){case Us:i.depthFunc(i.NEVER);break;case Is:i.depthFunc(i.ALWAYS);break;case Ns:i.depthFunc(i.LESS);break;case Mi:i.depthFunc(i.LEQUAL);break;case Fs:i.depthFunc(i.EQUAL);break;case Os:i.depthFunc(i.GEQUAL);break;case Bs:i.depthFunc(i.GREATER);break;case zs:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ye=X}},setLocked:function(X){D=X},setClear:function(X){O!==X&&(pe&&(X=1-X),i.clearDepth(X),O=X)},reset:function(){D=!1,te=null,ye=null,O=null,pe=!1}}}function r(){let D=!1,pe=null,te=null,ye=null,O=null,X=null,ue=null,Be=null,ot=null;return{setTest:function(et){D||(et?ve(i.STENCIL_TEST):Ue(i.STENCIL_TEST))},setMask:function(et){pe!==et&&!D&&(i.stencilMask(et),pe=et)},setFunc:function(et,Ce,_e){(te!==et||ye!==Ce||O!==_e)&&(i.stencilFunc(et,Ce,_e),te=et,ye=Ce,O=_e)},setOp:function(et,Ce,_e){(X!==et||ue!==Ce||Be!==_e)&&(i.stencilOp(et,Ce,_e),X=et,ue=Ce,Be=_e)},setLocked:function(et){D=et},setClear:function(et){ot!==et&&(i.clearStencil(et),ot=et)},reset:function(){D=!1,pe=null,te=null,ye=null,O=null,X=null,ue=null,Be=null,ot=null}}}const s=new t,a=new n,o=new r,l=new WeakMap,c=new WeakMap;let h={},u={},d=new WeakMap,p=[],_=null,v=!1,m=null,f=null,b=null,E=null,S=null,L=null,w=null,C=new Ke(0,0,0),P=0,y=!1,x=null,R=null,H=null,B=null,j=null;const J=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,ne=0;const G=i.getParameter(i.VERSION);G.indexOf("WebGL")!==-1?(ne=parseFloat(/^WebGL (\d)/.exec(G)[1]),W=ne>=1):G.indexOf("OpenGL ES")!==-1&&(ne=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),W=ne>=2);let fe=null,xe={};const se=i.getParameter(i.SCISSOR_BOX),We=i.getParameter(i.VIEWPORT),Ze=new pt().fromArray(se),Y=new pt().fromArray(We);function le(D,pe,te,ye){const O=new Uint8Array(4),X=i.createTexture();i.bindTexture(D,X),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ue=0;ue<te;ue++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(pe,0,i.RGBA,1,1,ye,0,i.RGBA,i.UNSIGNED_BYTE,O):i.texImage2D(pe+ue,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,O);return X}const Pe={};Pe[i.TEXTURE_2D]=le(i.TEXTURE_2D,i.TEXTURE_2D,1),Pe[i.TEXTURE_CUBE_MAP]=le(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Pe[i.TEXTURE_2D_ARRAY]=le(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Pe[i.TEXTURE_3D]=le(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ve(i.DEPTH_TEST),a.setFunc(Mi),Re(!1),Ye(Ba),ve(i.CULL_FACE),A(Dn);function ve(D){h[D]!==!0&&(i.enable(D),h[D]=!0)}function Ue(D){h[D]!==!1&&(i.disable(D),h[D]=!1)}function Z(D,pe){return u[D]!==pe?(i.bindFramebuffer(D,pe),u[D]=pe,D===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=pe),D===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=pe),!0):!1}function Q(D,pe){let te=p,ye=!1;if(D){te=d.get(pe),te===void 0&&(te=[],d.set(pe,te));const O=D.textures;if(te.length!==O.length||te[0]!==i.COLOR_ATTACHMENT0){for(let X=0,ue=O.length;X<ue;X++)te[X]=i.COLOR_ATTACHMENT0+X;te.length=O.length,ye=!0}}else te[0]!==i.BACK&&(te[0]=i.BACK,ye=!0);ye&&i.drawBuffers(te)}function de(D){return _!==D?(i.useProgram(D),_=D,!0):!1}const Se={[Xn]:i.FUNC_ADD,[Fc]:i.FUNC_SUBTRACT,[Oc]:i.FUNC_REVERSE_SUBTRACT};Se[Bc]=i.MIN,Se[zc]=i.MAX;const oe={[kc]:i.ZERO,[Hc]:i.ONE,[Vc]:i.SRC_COLOR,[Ds]:i.SRC_ALPHA,[jc]:i.SRC_ALPHA_SATURATE,[qc]:i.DST_COLOR,[Wc]:i.DST_ALPHA,[Gc]:i.ONE_MINUS_SRC_COLOR,[Ls]:i.ONE_MINUS_SRC_ALPHA,[Yc]:i.ONE_MINUS_DST_COLOR,[Xc]:i.ONE_MINUS_DST_ALPHA,[Kc]:i.CONSTANT_COLOR,[Zc]:i.ONE_MINUS_CONSTANT_COLOR,[$c]:i.CONSTANT_ALPHA,[Jc]:i.ONE_MINUS_CONSTANT_ALPHA};function A(D,pe,te,ye,O,X,ue,Be,ot,et){if(D===Dn){v===!0&&(Ue(i.BLEND),v=!1);return}if(v===!1&&(ve(i.BLEND),v=!0),D!==Nc){if(D!==m||et!==y){if((f!==Xn||S!==Xn)&&(i.blendEquation(i.FUNC_ADD),f=Xn,S=Xn),et)switch(D){case gi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case za:i.blendFunc(i.ONE,i.ONE);break;case ka:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ha:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}else switch(D){case gi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case za:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case ka:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ha:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}b=null,E=null,L=null,w=null,C.set(0,0,0),P=0,m=D,y=et}return}O=O||pe,X=X||te,ue=ue||ye,(pe!==f||O!==S)&&(i.blendEquationSeparate(Se[pe],Se[O]),f=pe,S=O),(te!==b||ye!==E||X!==L||ue!==w)&&(i.blendFuncSeparate(oe[te],oe[ye],oe[X],oe[ue]),b=te,E=ye,L=X,w=ue),(Be.equals(C)===!1||ot!==P)&&(i.blendColor(Be.r,Be.g,Be.b,ot),C.copy(Be),P=ot),m=D,y=!1}function ae(D,pe){D.side===_n?Ue(i.CULL_FACE):ve(i.CULL_FACE);let te=D.side===It;pe&&(te=!te),Re(te),D.blending===gi&&D.transparent===!1?A(Dn):A(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),s.setMask(D.colorWrite);const ye=D.stencilWrite;o.setTest(ye),ye&&(o.setMask(D.stencilWriteMask),o.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),o.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),Fe(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?ve(i.SAMPLE_ALPHA_TO_COVERAGE):Ue(i.SAMPLE_ALPHA_TO_COVERAGE)}function Re(D){x!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),x=D)}function Ye(D){D!==Lc?(ve(i.CULL_FACE),D!==R&&(D===Ba?i.cullFace(i.BACK):D===Uc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Ue(i.CULL_FACE),R=D}function ie(D){D!==H&&(W&&i.lineWidth(D),H=D)}function Fe(D,pe,te){D?(ve(i.POLYGON_OFFSET_FILL),(B!==pe||j!==te)&&(i.polygonOffset(pe,te),B=pe,j=te)):Ue(i.POLYGON_OFFSET_FILL)}function Ee(D){D?ve(i.SCISSOR_TEST):Ue(i.SCISSOR_TEST)}function Ve(D){D===void 0&&(D=i.TEXTURE0+J-1),fe!==D&&(i.activeTexture(D),fe=D)}function lt(D,pe,te){te===void 0&&(fe===null?te=i.TEXTURE0+J-1:te=fe);let ye=xe[te];ye===void 0&&(ye={type:void 0,texture:void 0},xe[te]=ye),(ye.type!==D||ye.texture!==pe)&&(fe!==te&&(i.activeTexture(te),fe=te),i.bindTexture(D,pe||Pe[D]),ye.type=D,ye.texture=pe)}function T(){const D=xe[fe];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function g(){try{i.compressedTexImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function F(){try{i.compressedTexImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function q(){try{i.texSubImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function K(){try{i.texSubImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function V(){try{i.compressedTexSubImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function De(){try{i.compressedTexSubImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function he(){try{i.texStorage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function be(){try{i.texStorage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Le(){try{i.texImage2D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ee(){try{i.texImage3D(...arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Me(D){Ze.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),Ze.copy(D))}function Oe(D){Y.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),Y.copy(D))}function Ne(D,pe){let te=c.get(pe);te===void 0&&(te=new WeakMap,c.set(pe,te));let ye=te.get(D);ye===void 0&&(ye=i.getUniformBlockIndex(pe,D.name),te.set(D,ye))}function ce(D,pe){const ye=c.get(pe).get(D);l.get(pe)!==ye&&(i.uniformBlockBinding(pe,ye,D.__bindingPointIndex),l.set(pe,ye))}function ke(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},fe=null,xe={},u={},d=new WeakMap,p=[],_=null,v=!1,m=null,f=null,b=null,E=null,S=null,L=null,w=null,C=new Ke(0,0,0),P=0,y=!1,x=null,R=null,H=null,B=null,j=null,Ze.set(0,0,i.canvas.width,i.canvas.height),Y.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:ve,disable:Ue,bindFramebuffer:Z,drawBuffers:Q,useProgram:de,setBlending:A,setMaterial:ae,setFlipSided:Re,setCullFace:Ye,setLineWidth:ie,setPolygonOffset:Fe,setScissorTest:Ee,activeTexture:Ve,bindTexture:lt,unbindTexture:T,compressedTexImage2D:g,compressedTexImage3D:F,texImage2D:Le,texImage3D:ee,updateUBOMapping:Ne,uniformBlockBinding:ce,texStorage2D:he,texStorage3D:be,texSubImage2D:q,texSubImage3D:K,compressedTexSubImage2D:V,compressedTexSubImage3D:De,scissor:Me,viewport:Oe,reset:ke}}function km(i,e,t,n,r,s,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 Xe,h=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(T,g){return p?new OffscreenCanvas(T,g):Ki("canvas")}function v(T,g,F){let q=1;const K=lt(T);if((K.width>F||K.height>F)&&(q=F/Math.max(K.width,K.height)),q<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const V=Math.floor(q*K.width),De=Math.floor(q*K.height);u===void 0&&(u=_(V,De));const he=g?_(V,De):u;return he.width=V,he.height=De,he.getContext("2d").drawImage(T,0,0,V,De),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+V+"x"+De+")."),he}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function m(T){return T.generateMipmaps}function f(T){i.generateMipmap(T)}function b(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function E(T,g,F,q,K=!1){if(T!==null){if(i[T]!==void 0)return i[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let V=g;if(g===i.RED&&(F===i.FLOAT&&(V=i.R32F),F===i.HALF_FLOAT&&(V=i.R16F),F===i.UNSIGNED_BYTE&&(V=i.R8)),g===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(V=i.R8UI),F===i.UNSIGNED_SHORT&&(V=i.R16UI),F===i.UNSIGNED_INT&&(V=i.R32UI),F===i.BYTE&&(V=i.R8I),F===i.SHORT&&(V=i.R16I),F===i.INT&&(V=i.R32I)),g===i.RG&&(F===i.FLOAT&&(V=i.RG32F),F===i.HALF_FLOAT&&(V=i.RG16F),F===i.UNSIGNED_BYTE&&(V=i.RG8)),g===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(V=i.RG8UI),F===i.UNSIGNED_SHORT&&(V=i.RG16UI),F===i.UNSIGNED_INT&&(V=i.RG32UI),F===i.BYTE&&(V=i.RG8I),F===i.SHORT&&(V=i.RG16I),F===i.INT&&(V=i.RG32I)),g===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(V=i.RGB8UI),F===i.UNSIGNED_SHORT&&(V=i.RGB16UI),F===i.UNSIGNED_INT&&(V=i.RGB32UI),F===i.BYTE&&(V=i.RGB8I),F===i.SHORT&&(V=i.RGB16I),F===i.INT&&(V=i.RGB32I)),g===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(V=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(V=i.RGBA16UI),F===i.UNSIGNED_INT&&(V=i.RGBA32UI),F===i.BYTE&&(V=i.RGBA8I),F===i.SHORT&&(V=i.RGBA16I),F===i.INT&&(V=i.RGBA32I)),g===i.RGB&&F===i.UNSIGNED_INT_5_9_9_9_REV&&(V=i.RGB9_E5),g===i.RGBA){const De=K?Br:Qe.getTransfer(q);F===i.FLOAT&&(V=i.RGBA32F),F===i.HALF_FLOAT&&(V=i.RGBA16F),F===i.UNSIGNED_BYTE&&(V=De===st?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT_4_4_4_4&&(V=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(V=i.RGB5_A1)}return(V===i.R16F||V===i.R32F||V===i.RG16F||V===i.RG32F||V===i.RGBA16F||V===i.RGBA32F)&&e.get("EXT_color_buffer_float"),V}function S(T,g){let F;return T?g===null||g===Kn||g===qi?F=i.DEPTH24_STENCIL8:g===gn?F=i.DEPTH32F_STENCIL8:g===Xi&&(F=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===Kn||g===qi?F=i.DEPTH_COMPONENT24:g===gn?F=i.DEPTH_COMPONENT32F:g===Xi&&(F=i.DEPTH_COMPONENT16),F}function L(T,g){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==Qt&&T.minFilter!==rn?Math.log2(Math.max(g.width,g.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?g.mipmaps.length:1}function w(T){const g=T.target;g.removeEventListener("dispose",w),P(g),g.isVideoTexture&&h.delete(g)}function C(T){const g=T.target;g.removeEventListener("dispose",C),x(g)}function P(T){const g=n.get(T);if(g.__webglInit===void 0)return;const F=T.source,q=d.get(F);if(q){const K=q[g.__cacheKey];K.usedTimes--,K.usedTimes===0&&y(T),Object.keys(q).length===0&&d.delete(F)}n.remove(T)}function y(T){const g=n.get(T);i.deleteTexture(g.__webglTexture);const F=T.source,q=d.get(F);delete q[g.__cacheKey],a.memory.textures--}function x(T){const g=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(g.__webglFramebuffer[q]))for(let K=0;K<g.__webglFramebuffer[q].length;K++)i.deleteFramebuffer(g.__webglFramebuffer[q][K]);else i.deleteFramebuffer(g.__webglFramebuffer[q]);g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer[q])}else{if(Array.isArray(g.__webglFramebuffer))for(let q=0;q<g.__webglFramebuffer.length;q++)i.deleteFramebuffer(g.__webglFramebuffer[q]);else i.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer),g.__webglMultisampledFramebuffer&&i.deleteFramebuffer(g.__webglMultisampledFramebuffer),g.__webglColorRenderbuffer)for(let q=0;q<g.__webglColorRenderbuffer.length;q++)g.__webglColorRenderbuffer[q]&&i.deleteRenderbuffer(g.__webglColorRenderbuffer[q]);g.__webglDepthRenderbuffer&&i.deleteRenderbuffer(g.__webglDepthRenderbuffer)}const F=T.textures;for(let q=0,K=F.length;q<K;q++){const V=n.get(F[q]);V.__webglTexture&&(i.deleteTexture(V.__webglTexture),a.memory.textures--),n.remove(F[q])}n.remove(T)}let R=0;function H(){R=0}function B(){const T=R;return T>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+r.maxTextures),R+=1,T}function j(T){const g=[];return g.push(T.wrapS),g.push(T.wrapT),g.push(T.wrapR||0),g.push(T.magFilter),g.push(T.minFilter),g.push(T.anisotropy),g.push(T.internalFormat),g.push(T.format),g.push(T.type),g.push(T.generateMipmaps),g.push(T.premultiplyAlpha),g.push(T.flipY),g.push(T.unpackAlignment),g.push(T.colorSpace),g.join()}function J(T,g){const F=n.get(T);if(T.isVideoTexture&&Ee(T),T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){const q=T.image;if(q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(F,T,g);return}}t.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+g)}function W(T,g){const F=n.get(T);if(T.version>0&&F.__version!==T.version){Pe(F,T,g);return}t.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+g)}function ne(T,g){const F=n.get(T);if(T.version>0&&F.__version!==T.version){Pe(F,T,g);return}t.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+g)}function G(T,g){const F=n.get(T);if(T.version>0&&F.__version!==T.version){ve(F,T,g);return}t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+g)}const fe={[Or]:i.REPEAT,[Yn]:i.CLAMP_TO_EDGE,[Vs]:i.MIRRORED_REPEAT},xe={[Qt]:i.NEAREST,[lh]:i.NEAREST_MIPMAP_NEAREST,[tr]:i.NEAREST_MIPMAP_LINEAR,[rn]:i.LINEAR,[Zr]:i.LINEAR_MIPMAP_NEAREST,[jn]:i.LINEAR_MIPMAP_LINEAR},se={[fh]:i.NEVER,[vh]:i.ALWAYS,[dh]:i.LESS,[fl]:i.LEQUAL,[ph]:i.EQUAL,[gh]:i.GEQUAL,[mh]:i.GREATER,[_h]:i.NOTEQUAL};function We(T,g){if(g.type===gn&&e.has("OES_texture_float_linear")===!1&&(g.magFilter===rn||g.magFilter===Zr||g.magFilter===tr||g.magFilter===jn||g.minFilter===rn||g.minFilter===Zr||g.minFilter===tr||g.minFilter===jn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,fe[g.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,fe[g.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,fe[g.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,xe[g.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,xe[g.minFilter]),g.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,se[g.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===Qt||g.minFilter!==tr&&g.minFilter!==jn||g.type===gn&&e.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||n.get(g).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,r.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function Ze(T,g){let F=!1;T.__webglInit===void 0&&(T.__webglInit=!0,g.addEventListener("dispose",w));const q=g.source;let K=d.get(q);K===void 0&&(K={},d.set(q,K));const V=j(g);if(V!==T.__cacheKey){K[V]===void 0&&(K[V]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[V].usedTimes++;const De=K[T.__cacheKey];De!==void 0&&(K[T.__cacheKey].usedTimes--,De.usedTimes===0&&y(g)),T.__cacheKey=V,T.__webglTexture=K[V].texture}return F}function Y(T,g,F){return Math.floor(Math.floor(T/F)/g)}function le(T,g,F,q){const V=T.updateRanges;if(V.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,g.width,g.height,F,q,g.data);else{V.sort((ee,Me)=>ee.start-Me.start);let De=0;for(let ee=1;ee<V.length;ee++){const Me=V[De],Oe=V[ee],Ne=Me.start+Me.count,ce=Y(Oe.start,g.width,4),ke=Y(Me.start,g.width,4);Oe.start<=Ne+1&&ce===ke&&Y(Oe.start+Oe.count-1,g.width,4)===ce?Me.count=Math.max(Me.count,Oe.start+Oe.count-Me.start):(++De,V[De]=Oe)}V.length=De+1;const he=i.getParameter(i.UNPACK_ROW_LENGTH),be=i.getParameter(i.UNPACK_SKIP_PIXELS),Le=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,g.width);for(let ee=0,Me=V.length;ee<Me;ee++){const Oe=V[ee],Ne=Math.floor(Oe.start/4),ce=Math.ceil(Oe.count/4),ke=Ne%g.width,D=Math.floor(Ne/g.width),pe=ce,te=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,ke),i.pixelStorei(i.UNPACK_SKIP_ROWS,D),t.texSubImage2D(i.TEXTURE_2D,0,ke,D,pe,te,F,q,g.data)}T.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,he),i.pixelStorei(i.UNPACK_SKIP_PIXELS,be),i.pixelStorei(i.UNPACK_SKIP_ROWS,Le)}}function Pe(T,g,F){let q=i.TEXTURE_2D;(g.isDataArrayTexture||g.isCompressedArrayTexture)&&(q=i.TEXTURE_2D_ARRAY),g.isData3DTexture&&(q=i.TEXTURE_3D);const K=Ze(T,g),V=g.source;t.bindTexture(q,T.__webglTexture,i.TEXTURE0+F);const De=n.get(V);if(V.version!==De.__version||K===!0){t.activeTexture(i.TEXTURE0+F);const he=Qe.getPrimaries(Qe.workingColorSpace),be=g.colorSpace===Pn?null:Qe.getPrimaries(g.colorSpace),Le=g.colorSpace===Pn||he===be?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Le);let ee=v(g.image,!1,r.maxTextureSize);ee=Ve(g,ee);const Me=s.convert(g.format,g.colorSpace),Oe=s.convert(g.type);let Ne=E(g.internalFormat,Me,Oe,g.colorSpace,g.isVideoTexture);We(q,g);let ce;const ke=g.mipmaps,D=g.isVideoTexture!==!0,pe=De.__version===void 0||K===!0,te=V.dataReady,ye=L(g,ee);if(g.isDepthTexture)Ne=S(g.format===ji,g.type),pe&&(D?t.texStorage2D(i.TEXTURE_2D,1,Ne,ee.width,ee.height):t.texImage2D(i.TEXTURE_2D,0,Ne,ee.width,ee.height,0,Me,Oe,null));else if(g.isDataTexture)if(ke.length>0){D&&pe&&t.texStorage2D(i.TEXTURE_2D,ye,Ne,ke[0].width,ke[0].height);for(let O=0,X=ke.length;O<X;O++)ce=ke[O],D?te&&t.texSubImage2D(i.TEXTURE_2D,O,0,0,ce.width,ce.height,Me,Oe,ce.data):t.texImage2D(i.TEXTURE_2D,O,Ne,ce.width,ce.height,0,Me,Oe,ce.data);g.generateMipmaps=!1}else D?(pe&&t.texStorage2D(i.TEXTURE_2D,ye,Ne,ee.width,ee.height),te&&le(g,ee,Me,Oe)):t.texImage2D(i.TEXTURE_2D,0,Ne,ee.width,ee.height,0,Me,Oe,ee.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){D&&pe&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ye,Ne,ke[0].width,ke[0].height,ee.depth);for(let O=0,X=ke.length;O<X;O++)if(ce=ke[O],g.format!==$t)if(Me!==null)if(D){if(te)if(g.layerUpdates.size>0){const ue=xo(ce.width,ce.height,g.format,g.type);for(const Be of g.layerUpdates){const ot=ce.data.subarray(Be*ue/ce.data.BYTES_PER_ELEMENT,(Be+1)*ue/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,O,0,0,Be,ce.width,ce.height,1,Me,ot)}g.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,O,0,0,0,ce.width,ce.height,ee.depth,Me,ce.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,O,Ne,ce.width,ce.height,ee.depth,0,ce.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else D?te&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,O,0,0,0,ce.width,ce.height,ee.depth,Me,Oe,ce.data):t.texImage3D(i.TEXTURE_2D_ARRAY,O,Ne,ce.width,ce.height,ee.depth,0,Me,Oe,ce.data)}else{D&&pe&&t.texStorage2D(i.TEXTURE_2D,ye,Ne,ke[0].width,ke[0].height);for(let O=0,X=ke.length;O<X;O++)ce=ke[O],g.format!==$t?Me!==null?D?te&&t.compressedTexSubImage2D(i.TEXTURE_2D,O,0,0,ce.width,ce.height,Me,ce.data):t.compressedTexImage2D(i.TEXTURE_2D,O,Ne,ce.width,ce.height,0,ce.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):D?te&&t.texSubImage2D(i.TEXTURE_2D,O,0,0,ce.width,ce.height,Me,Oe,ce.data):t.texImage2D(i.TEXTURE_2D,O,Ne,ce.width,ce.height,0,Me,Oe,ce.data)}else if(g.isDataArrayTexture)if(D){if(pe&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ye,Ne,ee.width,ee.height,ee.depth),te)if(g.layerUpdates.size>0){const O=xo(ee.width,ee.height,g.format,g.type);for(const X of g.layerUpdates){const ue=ee.data.subarray(X*O/ee.data.BYTES_PER_ELEMENT,(X+1)*O/ee.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,X,ee.width,ee.height,1,Me,Oe,ue)}g.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ee.width,ee.height,ee.depth,Me,Oe,ee.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Ne,ee.width,ee.height,ee.depth,0,Me,Oe,ee.data);else if(g.isData3DTexture)D?(pe&&t.texStorage3D(i.TEXTURE_3D,ye,Ne,ee.width,ee.height,ee.depth),te&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ee.width,ee.height,ee.depth,Me,Oe,ee.data)):t.texImage3D(i.TEXTURE_3D,0,Ne,ee.width,ee.height,ee.depth,0,Me,Oe,ee.data);else if(g.isFramebufferTexture){if(pe)if(D)t.texStorage2D(i.TEXTURE_2D,ye,Ne,ee.width,ee.height);else{let O=ee.width,X=ee.height;for(let ue=0;ue<ye;ue++)t.texImage2D(i.TEXTURE_2D,ue,Ne,O,X,0,Me,Oe,null),O>>=1,X>>=1}}else if(ke.length>0){if(D&&pe){const O=lt(ke[0]);t.texStorage2D(i.TEXTURE_2D,ye,Ne,O.width,O.height)}for(let O=0,X=ke.length;O<X;O++)ce=ke[O],D?te&&t.texSubImage2D(i.TEXTURE_2D,O,0,0,Me,Oe,ce):t.texImage2D(i.TEXTURE_2D,O,Ne,Me,Oe,ce);g.generateMipmaps=!1}else if(D){if(pe){const O=lt(ee);t.texStorage2D(i.TEXTURE_2D,ye,Ne,O.width,O.height)}te&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Me,Oe,ee)}else t.texImage2D(i.TEXTURE_2D,0,Ne,Me,Oe,ee);m(g)&&f(q),De.__version=V.version,g.onUpdate&&g.onUpdate(g)}T.__version=g.version}function ve(T,g,F){if(g.image.length!==6)return;const q=Ze(T,g),K=g.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+F);const V=n.get(K);if(K.version!==V.__version||q===!0){t.activeTexture(i.TEXTURE0+F);const De=Qe.getPrimaries(Qe.workingColorSpace),he=g.colorSpace===Pn?null:Qe.getPrimaries(g.colorSpace),be=g.colorSpace===Pn||De===he?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,be);const Le=g.isCompressedTexture||g.image[0].isCompressedTexture,ee=g.image[0]&&g.image[0].isDataTexture,Me=[];for(let X=0;X<6;X++)!Le&&!ee?Me[X]=v(g.image[X],!0,r.maxCubemapSize):Me[X]=ee?g.image[X].image:g.image[X],Me[X]=Ve(g,Me[X]);const Oe=Me[0],Ne=s.convert(g.format,g.colorSpace),ce=s.convert(g.type),ke=E(g.internalFormat,Ne,ce,g.colorSpace),D=g.isVideoTexture!==!0,pe=V.__version===void 0||q===!0,te=K.dataReady;let ye=L(g,Oe);We(i.TEXTURE_CUBE_MAP,g);let O;if(Le){D&&pe&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ye,ke,Oe.width,Oe.height);for(let X=0;X<6;X++){O=Me[X].mipmaps;for(let ue=0;ue<O.length;ue++){const Be=O[ue];g.format!==$t?Ne!==null?D?te&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ue,0,0,Be.width,Be.height,Ne,Be.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ue,ke,Be.width,Be.height,0,Be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ue,0,0,Be.width,Be.height,Ne,ce,Be.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ue,ke,Be.width,Be.height,0,Ne,ce,Be.data)}}}else{if(O=g.mipmaps,D&&pe){O.length>0&&ye++;const X=lt(Me[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ye,ke,X.width,X.height)}for(let X=0;X<6;X++)if(ee){D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,Me[X].width,Me[X].height,Ne,ce,Me[X].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,ke,Me[X].width,Me[X].height,0,Ne,ce,Me[X].data);for(let ue=0;ue<O.length;ue++){const ot=O[ue].image[X].image;D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ue+1,0,0,ot.width,ot.height,Ne,ce,ot.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ue+1,ke,ot.width,ot.height,0,Ne,ce,ot.data)}}else{D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,Ne,ce,Me[X]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,ke,Ne,ce,Me[X]);for(let ue=0;ue<O.length;ue++){const Be=O[ue];D?te&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ue+1,0,0,Ne,ce,Be.image[X]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,ue+1,ke,Ne,ce,Be.image[X])}}}m(g)&&f(i.TEXTURE_CUBE_MAP),V.__version=K.version,g.onUpdate&&g.onUpdate(g)}T.__version=g.version}function Ue(T,g,F,q,K,V){const De=s.convert(F.format,F.colorSpace),he=s.convert(F.type),be=E(F.internalFormat,De,he,F.colorSpace),Le=n.get(g),ee=n.get(F);if(ee.__renderTarget=g,!Le.__hasExternalTextures){const Me=Math.max(1,g.width>>V),Oe=Math.max(1,g.height>>V);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?t.texImage3D(K,V,be,Me,Oe,g.depth,0,De,he,null):t.texImage2D(K,V,be,Me,Oe,0,De,he,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),Fe(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,q,K,ee.__webglTexture,0,ie(g)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,q,K,ee.__webglTexture,V),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Z(T,g,F){if(i.bindRenderbuffer(i.RENDERBUFFER,T),g.depthBuffer){const q=g.depthTexture,K=q&&q.isDepthTexture?q.type:null,V=S(g.stencilBuffer,K),De=g.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=ie(g);Fe(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,he,V,g.width,g.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,he,V,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,V,g.width,g.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,De,i.RENDERBUFFER,T)}else{const q=g.textures;for(let K=0;K<q.length;K++){const V=q[K],De=s.convert(V.format,V.colorSpace),he=s.convert(V.type),be=E(V.internalFormat,De,he,V.colorSpace),Le=ie(g);F&&Fe(g)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Le,be,g.width,g.height):Fe(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Le,be,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,be,g.width,g.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Q(T,g){if(g&&g.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,T),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const q=n.get(g.depthTexture);q.__renderTarget=g,(!q.__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)&&(g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0),J(g.depthTexture,0);const K=q.__webglTexture,V=ie(g);if(g.depthTexture.format===Yi)Fe(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,K,0,V):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,K,0);else if(g.depthTexture.format===ji)Fe(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,K,0,V):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,K,0);else throw new Error("Unknown depthTexture format")}function de(T){const g=n.get(T),F=T.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==T.depthTexture){const q=T.depthTexture;if(g.__depthDisposeCallback&&g.__depthDisposeCallback(),q){const K=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,q.removeEventListener("dispose",K)};q.addEventListener("dispose",K),g.__depthDisposeCallback=K}g.__boundDepthTexture=q}if(T.depthTexture&&!g.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");const q=T.texture.mipmaps;q&&q.length>0?Q(g.__webglFramebuffer[0],T):Q(g.__webglFramebuffer,T)}else if(F){g.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[q]),g.__webglDepthbuffer[q]===void 0)g.__webglDepthbuffer[q]=i.createRenderbuffer(),Z(g.__webglDepthbuffer[q],T,!1);else{const K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,V=g.__webglDepthbuffer[q];i.bindRenderbuffer(i.RENDERBUFFER,V),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,V)}}else{const q=T.texture.mipmaps;if(q&&q.length>0?t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer),g.__webglDepthbuffer===void 0)g.__webglDepthbuffer=i.createRenderbuffer(),Z(g.__webglDepthbuffer,T,!1);else{const K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,V=g.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,V),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,V)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Se(T,g,F){const q=n.get(T);g!==void 0&&Ue(q.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&de(T)}function oe(T){const g=T.texture,F=n.get(T),q=n.get(g);T.addEventListener("dispose",C);const K=T.textures,V=T.isWebGLCubeRenderTarget===!0,De=K.length>1;if(De||(q.__webglTexture===void 0&&(q.__webglTexture=i.createTexture()),q.__version=g.version,a.memory.textures++),V){F.__webglFramebuffer=[];for(let he=0;he<6;he++)if(g.mipmaps&&g.mipmaps.length>0){F.__webglFramebuffer[he]=[];for(let be=0;be<g.mipmaps.length;be++)F.__webglFramebuffer[he][be]=i.createFramebuffer()}else F.__webglFramebuffer[he]=i.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){F.__webglFramebuffer=[];for(let he=0;he<g.mipmaps.length;he++)F.__webglFramebuffer[he]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(De)for(let he=0,be=K.length;he<be;he++){const Le=n.get(K[he]);Le.__webglTexture===void 0&&(Le.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&Fe(T)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let he=0;he<K.length;he++){const be=K[he];F.__webglColorRenderbuffer[he]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[he]);const Le=s.convert(be.format,be.colorSpace),ee=s.convert(be.type),Me=E(be.internalFormat,Le,ee,be.colorSpace,T.isXRRenderTarget===!0),Oe=ie(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,Oe,Me,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+he,i.RENDERBUFFER,F.__webglColorRenderbuffer[he])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),Z(F.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(V){t.bindTexture(i.TEXTURE_CUBE_MAP,q.__webglTexture),We(i.TEXTURE_CUBE_MAP,g);for(let he=0;he<6;he++)if(g.mipmaps&&g.mipmaps.length>0)for(let be=0;be<g.mipmaps.length;be++)Ue(F.__webglFramebuffer[he][be],T,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+he,be);else Ue(F.__webglFramebuffer[he],T,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+he,0);m(g)&&f(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(De){for(let he=0,be=K.length;he<be;he++){const Le=K[he],ee=n.get(Le);t.bindTexture(i.TEXTURE_2D,ee.__webglTexture),We(i.TEXTURE_2D,Le),Ue(F.__webglFramebuffer,T,Le,i.COLOR_ATTACHMENT0+he,i.TEXTURE_2D,0),m(Le)&&f(i.TEXTURE_2D)}t.unbindTexture()}else{let he=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(he=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(he,q.__webglTexture),We(he,g),g.mipmaps&&g.mipmaps.length>0)for(let be=0;be<g.mipmaps.length;be++)Ue(F.__webglFramebuffer[be],T,g,i.COLOR_ATTACHMENT0,he,be);else Ue(F.__webglFramebuffer,T,g,i.COLOR_ATTACHMENT0,he,0);m(g)&&f(he),t.unbindTexture()}T.depthBuffer&&de(T)}function A(T){const g=T.textures;for(let F=0,q=g.length;F<q;F++){const K=g[F];if(m(K)){const V=b(T),De=n.get(K).__webglTexture;t.bindTexture(V,De),f(V),t.unbindTexture()}}}const ae=[],Re=[];function Ye(T){if(T.samples>0){if(Fe(T)===!1){const g=T.textures,F=T.width,q=T.height;let K=i.COLOR_BUFFER_BIT;const V=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,De=n.get(T),he=g.length>1;if(he)for(let Le=0;Le<g.length;Le++)t.bindFramebuffer(i.FRAMEBUFFER,De.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Le,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,De.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Le,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,De.__webglMultisampledFramebuffer);const be=T.texture.mipmaps;be&&be.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,De.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,De.__webglFramebuffer);for(let Le=0;Le<g.length;Le++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=i.STENCIL_BUFFER_BIT)),he){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,De.__webglColorRenderbuffer[Le]);const ee=n.get(g[Le]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ee,0)}i.blitFramebuffer(0,0,F,q,0,0,F,q,K,i.NEAREST),l===!0&&(ae.length=0,Re.length=0,ae.push(i.COLOR_ATTACHMENT0+Le),T.depthBuffer&&T.resolveDepthBuffer===!1&&(ae.push(V),Re.push(V),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Re)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ae))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),he)for(let Le=0;Le<g.length;Le++){t.bindFramebuffer(i.FRAMEBUFFER,De.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Le,i.RENDERBUFFER,De.__webglColorRenderbuffer[Le]);const ee=n.get(g[Le]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,De.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Le,i.TEXTURE_2D,ee,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,De.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){const g=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[g])}}}function ie(T){return Math.min(r.maxSamples,T.samples)}function Fe(T){const g=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function Ee(T){const g=a.render.frame;h.get(T)!==g&&(h.set(T,g),T.update())}function Ve(T,g){const F=T.colorSpace,q=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||F!==Ei&&F!==Pn&&(Qe.getTransfer(F)===st?(q!==$t||K!==an)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),g}function lt(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=B,this.resetTextureUnits=H,this.setTexture2D=J,this.setTexture2DArray=W,this.setTexture3D=ne,this.setTextureCube=G,this.rebindTextures=Se,this.setupRenderTarget=oe,this.updateRenderTargetMipmap=A,this.updateMultisampleRenderTarget=Ye,this.setupDepthRenderbuffer=de,this.setupFrameBufferTexture=Ue,this.useMultisampledRTT=Fe}function Hm(i,e){function t(n,r=Pn){let s;const a=Qe.getTransfer(r);if(n===an)return i.UNSIGNED_BYTE;if(n===Ta)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ba)return i.UNSIGNED_SHORT_5_5_5_1;if(n===sl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===il)return i.BYTE;if(n===rl)return i.SHORT;if(n===Xi)return i.UNSIGNED_SHORT;if(n===Ea)return i.INT;if(n===Kn)return i.UNSIGNED_INT;if(n===gn)return i.FLOAT;if(n===Zi)return i.HALF_FLOAT;if(n===al)return i.ALPHA;if(n===ol)return i.RGB;if(n===$t)return i.RGBA;if(n===Yi)return i.DEPTH_COMPONENT;if(n===ji)return i.DEPTH_STENCIL;if(n===ll)return i.RED;if(n===Aa)return i.RED_INTEGER;if(n===cl)return i.RG;if(n===wa)return i.RG_INTEGER;if(n===Ra)return i.RGBA_INTEGER;if(n===Rr||n===Cr||n===Pr||n===Dr)if(a===st)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Rr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Cr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Pr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Dr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Rr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Cr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Pr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Dr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Gs||n===Ws||n===Xs||n===qs)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Gs)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ws)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Xs)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===qs)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ys||n===js||n===Ks)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Ys||n===js)return a===st?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Ks)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Zs||n===$s||n===Js||n===Qs||n===ea||n===ta||n===na||n===ia||n===ra||n===sa||n===aa||n===oa||n===la||n===ca)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Zs)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===$s)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Js)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Qs)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ea)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ta)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===na)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ia)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ra)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===sa)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===aa)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===oa)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===la)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ca)return a===st?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Lr||n===ha||n===ua)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Lr)return a===st?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ha)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ua)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===hl||n===fa||n===da||n===pa)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Lr)return s.COMPRESSED_RED_RGTC1_EXT;if(n===fa)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===da)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===pa)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===qi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Vm=`
3804
- void main() {
3805
-
3806
- gl_Position = vec4( position, 1.0 );
3807
-
3808
- }`,Gm=`
3809
- uniform sampler2DArray depthColor;
3810
- uniform float depthWidth;
3811
- uniform float depthHeight;
3812
-
3813
- void main() {
3814
-
3815
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3816
-
3817
- if ( coord.x >= 1.0 ) {
3818
-
3819
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3820
-
3821
- } else {
3822
-
3823
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3824
-
3825
- }
3826
-
3827
- }`;class Wm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new Pt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Un({vertexShader:Vm,fragmentShader:Gm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Jt(new qr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Xm extends Jn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,p=null,_=null;const v=new Wm,m=t.getContextAttributes();let f=null,b=null;const E=[],S=[],L=new Xe;let w=null;const C=new Xt;C.viewport=new pt;const P=new Xt;P.viewport=new pt;const y=[C,P],x=new hu;let R=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let le=E[Y];return le===void 0&&(le=new vs,E[Y]=le),le.getTargetRaySpace()},this.getControllerGrip=function(Y){let le=E[Y];return le===void 0&&(le=new vs,E[Y]=le),le.getGripSpace()},this.getHand=function(Y){let le=E[Y];return le===void 0&&(le=new vs,E[Y]=le),le.getHandSpace()};function B(Y){const le=S.indexOf(Y.inputSource);if(le===-1)return;const Pe=E[le];Pe!==void 0&&(Pe.update(Y.inputSource,Y.frame,c||a),Pe.dispatchEvent({type:Y.type,data:Y.inputSource}))}function j(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",j),r.removeEventListener("inputsourceschange",J);for(let Y=0;Y<E.length;Y++){const le=S[Y];le!==null&&(S[Y]=null,E[Y].disconnect(le))}R=null,H=null,v.reset(),e.setRenderTarget(f),p=null,d=null,u=null,r=null,b=null,Ze.stop(),n.isPresenting=!1,e.setPixelRatio(w),e.setSize(L.width,L.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Y){c=Y},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(f=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",j),r.addEventListener("inputsourceschange",J),m.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(L),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let Pe=null,ve=null,Ue=null;m.depth&&(Ue=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Pe=m.stencil?ji:Yi,ve=m.stencil?qi:Kn);const Z={colorFormat:t.RGBA8,depthFormat:Ue,scaleFactor:s};u=new XRWebGLBinding(r,t),d=u.createProjectionLayer(Z),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),b=new $n(d.textureWidth,d.textureHeight,{format:$t,type:an,depthTexture:new El(d.textureWidth,d.textureHeight,ve,void 0,void 0,void 0,void 0,void 0,void 0,Pe),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const Pe={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,Pe),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),b=new $n(p.framebufferWidth,p.framebufferHeight,{format:$t,type:an,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),Ze.setContext(r),Ze.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function J(Y){for(let le=0;le<Y.removed.length;le++){const Pe=Y.removed[le],ve=S.indexOf(Pe);ve>=0&&(S[ve]=null,E[ve].disconnect(Pe))}for(let le=0;le<Y.added.length;le++){const Pe=Y.added[le];let ve=S.indexOf(Pe);if(ve===-1){for(let Z=0;Z<E.length;Z++)if(Z>=S.length){S.push(Pe),ve=Z;break}else if(S[Z]===null){S[Z]=Pe,ve=Z;break}if(ve===-1)break}const Ue=E[ve];Ue&&Ue.connect(Pe)}}const W=new N,ne=new N;function G(Y,le,Pe){W.setFromMatrixPosition(le.matrixWorld),ne.setFromMatrixPosition(Pe.matrixWorld);const ve=W.distanceTo(ne),Ue=le.projectionMatrix.elements,Z=Pe.projectionMatrix.elements,Q=Ue[14]/(Ue[10]-1),de=Ue[14]/(Ue[10]+1),Se=(Ue[9]+1)/Ue[5],oe=(Ue[9]-1)/Ue[5],A=(Ue[8]-1)/Ue[0],ae=(Z[8]+1)/Z[0],Re=Q*A,Ye=Q*ae,ie=ve/(-A+ae),Fe=ie*-A;if(le.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Fe),Y.translateZ(ie),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Ue[10]===-1)Y.projectionMatrix.copy(le.projectionMatrix),Y.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const Ee=Q+ie,Ve=de+ie,lt=Re-Fe,T=Ye+(ve-Fe),g=Se*de/Ve*Ee,F=oe*de/Ve*Ee;Y.projectionMatrix.makePerspective(lt,T,g,F,Ee,Ve),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function fe(Y,le){le===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(le.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let le=Y.near,Pe=Y.far;v.texture!==null&&(v.depthNear>0&&(le=v.depthNear),v.depthFar>0&&(Pe=v.depthFar)),x.near=P.near=C.near=le,x.far=P.far=C.far=Pe,(R!==x.near||H!==x.far)&&(r.updateRenderState({depthNear:x.near,depthFar:x.far}),R=x.near,H=x.far),C.layers.mask=Y.layers.mask|2,P.layers.mask=Y.layers.mask|4,x.layers.mask=C.layers.mask|P.layers.mask;const ve=Y.parent,Ue=x.cameras;fe(x,ve);for(let Z=0;Z<Ue.length;Z++)fe(Ue[Z],ve);Ue.length===2?G(x,C,P):x.projectionMatrix.copy(C.projectionMatrix),xe(Y,x,ve)};function xe(Y,le,Pe){Pe===null?Y.matrix.copy(le.matrixWorld):(Y.matrix.copy(Pe.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(le.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(le.projectionMatrix),Y.projectionMatrixInverse.copy(le.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=ma*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return x},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(Y){l=Y,d!==null&&(d.fixedFoveation=Y),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Y)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(x)};let se=null;function We(Y,le){if(h=le.getViewerPose(c||a),_=le,h!==null){const Pe=h.views;p!==null&&(e.setRenderTargetFramebuffer(b,p.framebuffer),e.setRenderTarget(b));let ve=!1;Pe.length!==x.cameras.length&&(x.cameras.length=0,ve=!0);for(let Q=0;Q<Pe.length;Q++){const de=Pe[Q];let Se=null;if(p!==null)Se=p.getViewport(de);else{const A=u.getViewSubImage(d,de);Se=A.viewport,Q===0&&(e.setRenderTargetTextures(b,A.colorTexture,A.depthStencilTexture),e.setRenderTarget(b))}let oe=y[Q];oe===void 0&&(oe=new Xt,oe.layers.enable(Q),oe.viewport=new pt,y[Q]=oe),oe.matrix.fromArray(de.transform.matrix),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.projectionMatrix.fromArray(de.projectionMatrix),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert(),oe.viewport.set(Se.x,Se.y,Se.width,Se.height),Q===0&&(x.matrix.copy(oe.matrix),x.matrix.decompose(x.position,x.quaternion,x.scale)),ve===!0&&x.cameras.push(oe)}const Ue=r.enabledFeatures;if(Ue&&Ue.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&u){const Q=u.getDepthInformation(Pe[0]);Q&&Q.isValid&&Q.texture&&v.init(e,Q,r.renderState)}}for(let Pe=0;Pe<E.length;Pe++){const ve=S[Pe],Ue=E[Pe];ve!==null&&Ue!==void 0&&Ue.update(ve,le,c||a)}se&&se(Y,le),le.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:le}),_=null}const Ze=new Cl;Ze.setAnimationLoop(We),this.setAnimationLoop=function(Y){se=Y},this.dispose=function(){}}}const Gn=new on,qm=new ht;function Ym(i,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,Ml(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function r(m,f,b,E,S){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(m,f):f.isMeshToonMaterial?(s(m,f),u(m,f)):f.isMeshPhongMaterial?(s(m,f),h(m,f)):f.isMeshStandardMaterial?(s(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,S)):f.isMeshMatcapMaterial?(s(m,f),_(m,f)):f.isMeshDepthMaterial?s(m,f):f.isMeshDistanceMaterial?(s(m,f),v(m,f)):f.isMeshNormalMaterial?s(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,b,E):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===It&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===It&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const b=e.get(f),E=b.envMap,S=b.envMapRotation;E&&(m.envMap.value=E,Gn.copy(S),Gn.x*=-1,Gn.y*=-1,Gn.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Gn.y*=-1,Gn.z*=-1),m.envMapRotation.value.setFromMatrix4(qm.makeRotationFromEuler(Gn)),m.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,b,E){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*b,m.scale.value=E*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function u(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,b){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===It&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,f){f.matcap&&(m.matcap.value=f.matcap)}function v(m,f){const b=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function jm(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(b,E){const S=E.program;n.uniformBlockBinding(b,S)}function c(b,E){let S=r[b.id];S===void 0&&(_(b),S=h(b),r[b.id]=S,b.addEventListener("dispose",m));const L=E.program;n.updateUBOMapping(b,L);const w=e.render.frame;s[b.id]!==w&&(d(b),s[b.id]=w)}function h(b){const E=u();b.__bindingPointIndex=E;const S=i.createBuffer(),L=b.__size,w=b.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,L,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,E,S),S}function u(){for(let b=0;b<o;b++)if(a.indexOf(b)===-1)return a.push(b),b;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(b){const E=r[b.id],S=b.uniforms,L=b.__cache;i.bindBuffer(i.UNIFORM_BUFFER,E);for(let w=0,C=S.length;w<C;w++){const P=Array.isArray(S[w])?S[w]:[S[w]];for(let y=0,x=P.length;y<x;y++){const R=P[y];if(p(R,w,y,L)===!0){const H=R.__offset,B=Array.isArray(R.value)?R.value:[R.value];let j=0;for(let J=0;J<B.length;J++){const W=B[J],ne=v(W);typeof W=="number"||typeof W=="boolean"?(R.__data[0]=W,i.bufferSubData(i.UNIFORM_BUFFER,H+j,R.__data)):W.isMatrix3?(R.__data[0]=W.elements[0],R.__data[1]=W.elements[1],R.__data[2]=W.elements[2],R.__data[3]=0,R.__data[4]=W.elements[3],R.__data[5]=W.elements[4],R.__data[6]=W.elements[5],R.__data[7]=0,R.__data[8]=W.elements[6],R.__data[9]=W.elements[7],R.__data[10]=W.elements[8],R.__data[11]=0):(W.toArray(R.__data,j),j+=ne.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,H,R.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(b,E,S,L){const w=b.value,C=E+"_"+S;if(L[C]===void 0)return typeof w=="number"||typeof w=="boolean"?L[C]=w:L[C]=w.clone(),!0;{const P=L[C];if(typeof w=="number"||typeof w=="boolean"){if(P!==w)return L[C]=w,!0}else if(P.equals(w)===!1)return P.copy(w),!0}return!1}function _(b){const E=b.uniforms;let S=0;const L=16;for(let C=0,P=E.length;C<P;C++){const y=Array.isArray(E[C])?E[C]:[E[C]];for(let x=0,R=y.length;x<R;x++){const H=y[x],B=Array.isArray(H.value)?H.value:[H.value];for(let j=0,J=B.length;j<J;j++){const W=B[j],ne=v(W),G=S%L,fe=G%ne.boundary,xe=G+fe;S+=fe,xe!==0&&L-xe<ne.storage&&(S+=L-xe),H.__data=new Float32Array(ne.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=S,S+=ne.storage}}}const w=S%L;return w>0&&(S+=L-w),b.__size=S,b.__cache={},this}function v(b){const E={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(E.boundary=4,E.storage=4):b.isVector2?(E.boundary=8,E.storage=8):b.isVector3||b.isColor?(E.boundary=16,E.storage=12):b.isVector4?(E.boundary=16,E.storage=16):b.isMatrix3?(E.boundary=48,E.storage=48):b.isMatrix4?(E.boundary=64,E.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),E}function m(b){const E=b.target;E.removeEventListener("dispose",m);const S=a.indexOf(E.__bindingPointIndex);a.splice(S,1),i.deleteBuffer(r[E.id]),delete r[E.id],delete s[E.id]}function f(){for(const b in r)i.deleteBuffer(r[b]);a=[],r={},s={}}return{bind:l,update:c,dispose:f}}class Km{constructor(e={}){const{canvas:t=Sh(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const _=new Uint32Array(4),v=new Int32Array(4);let m=null,f=null;const b=[],E=[];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=Ln,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const S=this;let L=!1;this._outputColorSpace=Et;let w=0,C=0,P=null,y=-1,x=null;const R=new pt,H=new pt;let B=null;const j=new Ke(0);let J=0,W=t.width,ne=t.height,G=1,fe=null,xe=null;const se=new pt(0,0,W,ne),We=new pt(0,0,W,ne);let Ze=!1;const Y=new Pa;let le=!1,Pe=!1;const ve=new ht,Ue=new ht,Z=new N,Q=new pt,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Se=!1;function oe(){return P===null?G:1}let A=n;function ae(M,U){return t.getContext(M,U)}try{const M={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Sa}`),t.addEventListener("webglcontextlost",ye,!1),t.addEventListener("webglcontextrestored",O,!1),t.addEventListener("webglcontextcreationerror",X,!1),A===null){const U="webgl2";if(A=ae(U,M),A===null)throw ae(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(M){throw console.error("THREE.WebGLRenderer: "+M.message),M}let Re,Ye,ie,Fe,Ee,Ve,lt,T,g,F,q,K,V,De,he,be,Le,ee,Me,Oe,Ne,ce,ke,D;function pe(){Re=new sp(A),Re.init(),ce=new Hm(A,Re),Ye=new Jd(A,Re,e,ce),ie=new zm(A,Re),Ye.reverseDepthBuffer&&d&&ie.buffers.depth.setReversed(!0),Fe=new lp(A),Ee=new Am,Ve=new km(A,Re,ie,Ee,Ye,ce,Fe),lt=new ep(S),T=new rp(S),g=new du(A),ke=new Zd(A,g),F=new ap(A,g,Fe,ke),q=new hp(A,F,g,Fe),Me=new cp(A,Ye,Ve),be=new Qd(Ee),K=new bm(S,lt,T,Re,Ye,ke,be),V=new Ym(S,Ee),De=new Rm,he=new Im(Re),ee=new Kd(S,lt,T,ie,q,p,l),Le=new Om(S,q,Ye),D=new jm(A,Fe,Ye,ie),Oe=new $d(A,Re,Fe),Ne=new op(A,Re,Fe),Fe.programs=K.programs,S.capabilities=Ye,S.extensions=Re,S.properties=Ee,S.renderLists=De,S.shadowMap=Le,S.state=ie,S.info=Fe}pe();const te=new Xm(S,A);this.xr=te,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){const M=Re.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=Re.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(M){M!==void 0&&(G=M,this.setSize(W,ne,!1))},this.getSize=function(M){return M.set(W,ne)},this.setSize=function(M,U,z=!0){if(te.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=M,ne=U,t.width=Math.floor(M*G),t.height=Math.floor(U*G),z===!0&&(t.style.width=M+"px",t.style.height=U+"px"),this.setViewport(0,0,M,U)},this.getDrawingBufferSize=function(M){return M.set(W*G,ne*G).floor()},this.setDrawingBufferSize=function(M,U,z){W=M,ne=U,G=z,t.width=Math.floor(M*z),t.height=Math.floor(U*z),this.setViewport(0,0,M,U)},this.getCurrentViewport=function(M){return M.copy(R)},this.getViewport=function(M){return M.copy(se)},this.setViewport=function(M,U,z,k){M.isVector4?se.set(M.x,M.y,M.z,M.w):se.set(M,U,z,k),ie.viewport(R.copy(se).multiplyScalar(G).round())},this.getScissor=function(M){return M.copy(We)},this.setScissor=function(M,U,z,k){M.isVector4?We.set(M.x,M.y,M.z,M.w):We.set(M,U,z,k),ie.scissor(H.copy(We).multiplyScalar(G).round())},this.getScissorTest=function(){return Ze},this.setScissorTest=function(M){ie.setScissorTest(Ze=M)},this.setOpaqueSort=function(M){fe=M},this.setTransparentSort=function(M){xe=M},this.getClearColor=function(M){return M.copy(ee.getClearColor())},this.setClearColor=function(){ee.setClearColor(...arguments)},this.getClearAlpha=function(){return ee.getClearAlpha()},this.setClearAlpha=function(){ee.setClearAlpha(...arguments)},this.clear=function(M=!0,U=!0,z=!0){let k=0;if(M){let I=!1;if(P!==null){const re=P.texture.format;I=re===Ra||re===wa||re===Aa}if(I){const re=P.texture.type,ge=re===an||re===Kn||re===Xi||re===qi||re===Ta||re===ba,we=ee.getClearColor(),Te=ee.getClearAlpha(),He=we.r,Ge=we.g,Ie=we.b;ge?(_[0]=He,_[1]=Ge,_[2]=Ie,_[3]=Te,A.clearBufferuiv(A.COLOR,0,_)):(v[0]=He,v[1]=Ge,v[2]=Ie,v[3]=Te,A.clearBufferiv(A.COLOR,0,v))}else k|=A.COLOR_BUFFER_BIT}U&&(k|=A.DEPTH_BUFFER_BIT),z&&(k|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(k)},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",ye,!1),t.removeEventListener("webglcontextrestored",O,!1),t.removeEventListener("webglcontextcreationerror",X,!1),ee.dispose(),De.dispose(),he.dispose(),Ee.dispose(),lt.dispose(),T.dispose(),q.dispose(),ke.dispose(),D.dispose(),K.dispose(),te.dispose(),te.removeEventListener("sessionstart",xt),te.removeEventListener("sessionend",tn),ut.stop()};function ye(M){M.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),L=!0}function O(){console.log("THREE.WebGLRenderer: Context Restored."),L=!1;const M=Fe.autoReset,U=Le.enabled,z=Le.autoUpdate,k=Le.needsUpdate,I=Le.type;pe(),Fe.autoReset=M,Le.enabled=U,Le.autoUpdate=z,Le.needsUpdate=k,Le.type=I}function X(M){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function ue(M){const U=M.target;U.removeEventListener("dispose",ue),Be(U)}function Be(M){ot(M),Ee.remove(M)}function ot(M){const U=Ee.get(M).programs;U!==void 0&&(U.forEach(function(z){K.releaseProgram(z)}),M.isShaderMaterial&&K.releaseShaderCache(M))}this.renderBufferDirect=function(M,U,z,k,I,re){U===null&&(U=de);const ge=I.isMesh&&I.matrixWorld.determinant()<0,we=Ui(M,U,z,k,I);ie.setMaterial(k,ge);let Te=z.index,He=1;if(k.wireframe===!0){if(Te=F.getWireframeAttribute(z),Te===void 0)return;He=2}const Ge=z.drawRange,Ie=z.attributes.position;let Je=Ge.start*He,rt=(Ge.start+Ge.count)*He;re!==null&&(Je=Math.max(Je,re.start*He),rt=Math.min(rt,(re.start+re.count)*He)),Te!==null?(Je=Math.max(Je,0),rt=Math.min(rt,Te.count)):Ie!=null&&(Je=Math.max(Je,0),rt=Math.min(rt,Ie.count));const ft=rt-Je;if(ft<0||ft===1/0)return;ke.setup(I,k,we,z,Te);let dt,tt=Oe;if(Te!==null&&(dt=g.get(Te),tt=Ne,tt.setIndex(dt)),I.isMesh)k.wireframe===!0?(ie.setLineWidth(k.wireframeLinewidth*oe()),tt.setMode(A.LINES)):tt.setMode(A.TRIANGLES);else if(I.isLine){let ze=k.linewidth;ze===void 0&&(ze=1),ie.setLineWidth(ze*oe()),I.isLineSegments?tt.setMode(A.LINES):I.isLineLoop?tt.setMode(A.LINE_LOOP):tt.setMode(A.LINE_STRIP)}else I.isPoints?tt.setMode(A.POINTS):I.isSprite&&tt.setMode(A.TRIANGLES);if(I.isBatchedMesh)if(I._multiDrawInstances!==null)vi("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),tt.renderMultiDrawInstances(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount,I._multiDrawInstances);else if(Re.get("WEBGL_multi_draw"))tt.renderMultiDraw(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount);else{const ze=I._multiDrawStarts,yt=I._multiDrawCounts,nt=I._multiDrawCount,qt=Te?g.get(Te).bytesPerElement:1,Qn=Ee.get(k).currentProgram.getUniforms();for(let Ft=0;Ft<nt;Ft++)Qn.setValue(A,"_gl_DrawID",Ft),tt.render(ze[Ft]/qt,yt[Ft])}else if(I.isInstancedMesh)tt.renderInstances(Je,ft,I.count);else if(z.isInstancedBufferGeometry){const ze=z._maxInstanceCount!==void 0?z._maxInstanceCount:1/0,yt=Math.min(z.instanceCount,ze);tt.renderInstances(Je,ft,yt)}else tt.render(Je,ft)};function et(M,U,z){M.transparent===!0&&M.side===_n&&M.forceSinglePass===!1?(M.side=It,M.needsUpdate=!0,Nn(M,U,z),M.side=Sn,M.needsUpdate=!0,Nn(M,U,z),M.side=_n):Nn(M,U,z)}this.compile=function(M,U,z=null){z===null&&(z=M),f=he.get(z),f.init(U),E.push(f),z.traverseVisible(function(I){I.isLight&&I.layers.test(U.layers)&&(f.pushLight(I),I.castShadow&&f.pushShadow(I))}),M!==z&&M.traverseVisible(function(I){I.isLight&&I.layers.test(U.layers)&&(f.pushLight(I),I.castShadow&&f.pushShadow(I))}),f.setupLights();const k=new Set;return M.traverse(function(I){if(!(I.isMesh||I.isPoints||I.isLine||I.isSprite))return;const re=I.material;if(re)if(Array.isArray(re))for(let ge=0;ge<re.length;ge++){const we=re[ge];et(we,z,I),k.add(we)}else et(re,z,I),k.add(re)}),f=E.pop(),k},this.compileAsync=function(M,U,z=null){const k=this.compile(M,U,z);return new Promise(I=>{function re(){if(k.forEach(function(ge){Ee.get(ge).currentProgram.isReady()&&k.delete(ge)}),k.size===0){I(M);return}setTimeout(re,10)}Re.get("KHR_parallel_shader_compile")!==null?re():setTimeout(re,10)})};let Ce=null;function _e(M){Ce&&Ce(M)}function xt(){ut.stop()}function tn(){ut.start()}const ut=new Cl;ut.setAnimationLoop(_e),typeof self<"u"&&ut.setContext(self),this.setAnimationLoop=function(M){Ce=M,te.setAnimationLoop(M),M===null?ut.stop():ut.start()},te.addEventListener("sessionstart",xt),te.addEventListener("sessionend",tn),this.render=function(M,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;if(M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),te.enabled===!0&&te.isPresenting===!0&&(te.cameraAutoUpdate===!0&&te.updateCamera(U),U=te.getCamera()),M.isScene===!0&&M.onBeforeRender(S,M,U,P),f=he.get(M,E.length),f.init(U),E.push(f),Ue.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Y.setFromProjectionMatrix(Ue),Pe=this.localClippingEnabled,le=be.init(this.clippingPlanes,Pe),m=De.get(M,b.length),m.init(),b.push(m),te.enabled===!0&&te.isPresenting===!0){const re=S.xr.getDepthSensingMesh();re!==null&&At(re,U,-1/0,S.sortObjects)}At(M,U,0,S.sortObjects),m.finish(),S.sortObjects===!0&&m.sort(fe,xe),Se=te.enabled===!1||te.isPresenting===!1||te.hasDepthSensing()===!1,Se&&ee.addToRenderList(m,M),this.info.render.frame++,le===!0&&be.beginShadows();const z=f.state.shadowsArray;Le.render(z,M,U),le===!0&&be.endShadows(),this.info.autoReset===!0&&this.info.reset();const k=m.opaque,I=m.transmissive;if(f.setupLights(),U.isArrayCamera){const re=U.cameras;if(I.length>0)for(let ge=0,we=re.length;ge<we;ge++){const Te=re[ge];Ci(k,I,M,Te)}Se&&ee.render(M);for(let ge=0,we=re.length;ge<we;ge++){const Te=re[ge];zt(m,M,Te,Te.viewport)}}else I.length>0&&Ci(k,I,M,U),Se&&ee.render(M),zt(m,M,U);P!==null&&C===0&&(Ve.updateMultisampleRenderTarget(P),Ve.updateRenderTargetMipmap(P)),M.isScene===!0&&M.onAfterRender(S,M,U),ke.resetDefaultState(),y=-1,x=null,E.pop(),E.length>0?(f=E[E.length-1],le===!0&&be.setGlobalState(S.clippingPlanes,f.state.camera)):f=null,b.pop(),b.length>0?m=b[b.length-1]:m=null};function At(M,U,z,k){if(M.visible===!1)return;if(M.layers.test(U.layers)){if(M.isGroup)z=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(U);else if(M.isLight)f.pushLight(M),M.castShadow&&f.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||Y.intersectsSprite(M)){k&&Q.setFromMatrixPosition(M.matrixWorld).applyMatrix4(Ue);const ge=q.update(M),we=M.material;we.visible&&m.push(M,ge,we,z,Q.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||Y.intersectsObject(M))){const ge=q.update(M),we=M.material;if(k&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),Q.copy(M.boundingSphere.center)):(ge.boundingSphere===null&&ge.computeBoundingSphere(),Q.copy(ge.boundingSphere.center)),Q.applyMatrix4(M.matrixWorld).applyMatrix4(Ue)),Array.isArray(we)){const Te=ge.groups;for(let He=0,Ge=Te.length;He<Ge;He++){const Ie=Te[He],Je=we[Ie.materialIndex];Je&&Je.visible&&m.push(M,ge,Je,z,Q.z,Ie)}}else we.visible&&m.push(M,ge,we,z,Q.z,null)}}const re=M.children;for(let ge=0,we=re.length;ge<we;ge++)At(re[ge],U,z,k)}function zt(M,U,z,k){const I=M.opaque,re=M.transmissive,ge=M.transparent;f.setupLightsView(z),le===!0&&be.setGlobalState(S.clippingPlanes,z),k&&ie.viewport(R.copy(k)),I.length>0&&In(I,U,z),re.length>0&&In(re,U,z),ge.length>0&&In(ge,U,z),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function Ci(M,U,z,k){if((z.isScene===!0?z.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[k.id]===void 0&&(f.state.transmissionRenderTarget[k.id]=new $n(1,1,{generateMipmaps:!0,type:Re.has("EXT_color_buffer_half_float")||Re.has("EXT_color_buffer_float")?Zi:an,minFilter:jn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qe.workingColorSpace}));const re=f.state.transmissionRenderTarget[k.id],ge=k.viewport||R;re.setSize(ge.z*S.transmissionResolutionScale,ge.w*S.transmissionResolutionScale);const we=S.getRenderTarget();S.setRenderTarget(re),S.getClearColor(j),J=S.getClearAlpha(),J<1&&S.setClearColor(16777215,.5),S.clear(),Se&&ee.render(z);const Te=S.toneMapping;S.toneMapping=Ln;const He=k.viewport;if(k.viewport!==void 0&&(k.viewport=void 0),f.setupLightsView(k),le===!0&&be.setGlobalState(S.clippingPlanes,k),In(M,z,k),Ve.updateMultisampleRenderTarget(re),Ve.updateRenderTargetMipmap(re),Re.has("WEBGL_multisampled_render_to_texture")===!1){let Ge=!1;for(let Ie=0,Je=U.length;Ie<Je;Ie++){const rt=U[Ie],ft=rt.object,dt=rt.geometry,tt=rt.material,ze=rt.group;if(tt.side===_n&&ft.layers.test(k.layers)){const yt=tt.side;tt.side=It,tt.needsUpdate=!0,Pi(ft,z,k,dt,tt,ze),tt.side=yt,tt.needsUpdate=!0,Ge=!0}}Ge===!0&&(Ve.updateMultisampleRenderTarget(re),Ve.updateRenderTargetMipmap(re))}S.setRenderTarget(we),S.setClearColor(j,J),He!==void 0&&(k.viewport=He),S.toneMapping=Te}function In(M,U,z){const k=U.isScene===!0?U.overrideMaterial:null;for(let I=0,re=M.length;I<re;I++){const ge=M[I],we=ge.object,Te=ge.geometry,He=ge.group;let Ge=ge.material;Ge.allowOverride===!0&&k!==null&&(Ge=k),we.layers.test(z.layers)&&Pi(we,U,z,Te,Ge,He)}}function Pi(M,U,z,k,I,re){M.onBeforeRender(S,U,z,k,I,re),M.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),I.onBeforeRender(S,U,z,k,M,re),I.transparent===!0&&I.side===_n&&I.forceSinglePass===!1?(I.side=It,I.needsUpdate=!0,S.renderBufferDirect(z,U,k,I,M,re),I.side=Sn,I.needsUpdate=!0,S.renderBufferDirect(z,U,k,I,M,re),I.side=_n):S.renderBufferDirect(z,U,k,I,M,re),M.onAfterRender(S,U,z,k,I,re)}function Nn(M,U,z){U.isScene!==!0&&(U=de);const k=Ee.get(M),I=f.state.lights,re=f.state.shadowsArray,ge=I.state.version,we=K.getParameters(M,I.state,re,U,z),Te=K.getProgramCacheKey(we);let He=k.programs;k.environment=M.isMeshStandardMaterial?U.environment:null,k.fog=U.fog,k.envMap=(M.isMeshStandardMaterial?T:lt).get(M.envMap||k.environment),k.envMapRotation=k.environment!==null&&M.envMap===null?U.environmentRotation:M.envMapRotation,He===void 0&&(M.addEventListener("dispose",ue),He=new Map,k.programs=He);let Ge=He.get(Te);if(Ge!==void 0){if(k.currentProgram===Ge&&k.lightsStateVersion===ge)return Li(M,we),Ge}else we.uniforms=K.getUniforms(M),M.onBeforeCompile(we,S),Ge=K.acquireProgram(we,Te),He.set(Te,Ge),k.uniforms=we.uniforms;const Ie=k.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(Ie.clippingPlanes=be.uniform),Li(M,we),k.needsLights=Fn(M),k.lightsStateVersion=ge,k.needsLights&&(Ie.ambientLightColor.value=I.state.ambient,Ie.lightProbe.value=I.state.probe,Ie.directionalLights.value=I.state.directional,Ie.directionalLightShadows.value=I.state.directionalShadow,Ie.spotLights.value=I.state.spot,Ie.spotLightShadows.value=I.state.spotShadow,Ie.rectAreaLights.value=I.state.rectArea,Ie.ltc_1.value=I.state.rectAreaLTC1,Ie.ltc_2.value=I.state.rectAreaLTC2,Ie.pointLights.value=I.state.point,Ie.pointLightShadows.value=I.state.pointShadow,Ie.hemisphereLights.value=I.state.hemi,Ie.directionalShadowMap.value=I.state.directionalShadowMap,Ie.directionalShadowMatrix.value=I.state.directionalShadowMatrix,Ie.spotShadowMap.value=I.state.spotShadowMap,Ie.spotLightMatrix.value=I.state.spotLightMatrix,Ie.spotLightMap.value=I.state.spotLightMap,Ie.pointShadowMap.value=I.state.pointShadowMap,Ie.pointShadowMatrix.value=I.state.pointShadowMatrix),k.currentProgram=Ge,k.uniformsList=null,Ge}function Di(M){if(M.uniformsList===null){const U=M.currentProgram.getUniforms();M.uniformsList=Nr.seqWithValue(U.seq,M.uniforms)}return M.uniformsList}function Li(M,U){const z=Ee.get(M);z.outputColorSpace=U.outputColorSpace,z.batching=U.batching,z.batchingColor=U.batchingColor,z.instancing=U.instancing,z.instancingColor=U.instancingColor,z.instancingMorph=U.instancingMorph,z.skinning=U.skinning,z.morphTargets=U.morphTargets,z.morphNormals=U.morphNormals,z.morphColors=U.morphColors,z.morphTargetsCount=U.morphTargetsCount,z.numClippingPlanes=U.numClippingPlanes,z.numIntersection=U.numClipIntersection,z.vertexAlphas=U.vertexAlphas,z.vertexTangents=U.vertexTangents,z.toneMapping=U.toneMapping}function Ui(M,U,z,k,I){U.isScene!==!0&&(U=de),Ve.resetTextureUnits();const re=U.fog,ge=k.isMeshStandardMaterial?U.environment:null,we=P===null?S.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:Ei,Te=(k.isMeshStandardMaterial?T:lt).get(k.envMap||ge),He=k.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,Ge=!!z.attributes.tangent&&(!!k.normalMap||k.anisotropy>0),Ie=!!z.morphAttributes.position,Je=!!z.morphAttributes.normal,rt=!!z.morphAttributes.color;let ft=Ln;k.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(ft=S.toneMapping);const dt=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,tt=dt!==void 0?dt.length:0,ze=Ee.get(k),yt=f.state.lights;if(le===!0&&(Pe===!0||M!==x)){const wt=M===x&&k.id===y;be.setState(k,M,wt)}let nt=!1;k.version===ze.__version?(ze.needsLights&&ze.lightsStateVersion!==yt.state.version||ze.outputColorSpace!==we||I.isBatchedMesh&&ze.batching===!1||!I.isBatchedMesh&&ze.batching===!0||I.isBatchedMesh&&ze.batchingColor===!0&&I.colorTexture===null||I.isBatchedMesh&&ze.batchingColor===!1&&I.colorTexture!==null||I.isInstancedMesh&&ze.instancing===!1||!I.isInstancedMesh&&ze.instancing===!0||I.isSkinnedMesh&&ze.skinning===!1||!I.isSkinnedMesh&&ze.skinning===!0||I.isInstancedMesh&&ze.instancingColor===!0&&I.instanceColor===null||I.isInstancedMesh&&ze.instancingColor===!1&&I.instanceColor!==null||I.isInstancedMesh&&ze.instancingMorph===!0&&I.morphTexture===null||I.isInstancedMesh&&ze.instancingMorph===!1&&I.morphTexture!==null||ze.envMap!==Te||k.fog===!0&&ze.fog!==re||ze.numClippingPlanes!==void 0&&(ze.numClippingPlanes!==be.numPlanes||ze.numIntersection!==be.numIntersection)||ze.vertexAlphas!==He||ze.vertexTangents!==Ge||ze.morphTargets!==Ie||ze.morphNormals!==Je||ze.morphColors!==rt||ze.toneMapping!==ft||ze.morphTargetsCount!==tt)&&(nt=!0):(nt=!0,ze.__version=k.version);let qt=ze.currentProgram;nt===!0&&(qt=Nn(k,U,I));let Qn=!1,Ft=!1,Ii=!1;const ct=qt.getUniforms(),kt=ze.uniforms;if(ie.useProgram(qt.program)&&(Qn=!0,Ft=!0,Ii=!0),k.id!==y&&(y=k.id,Ft=!0),Qn||x!==M){ie.buffers.depth.getReversed()?(ve.copy(M.projectionMatrix),Eh(ve),Th(ve),ct.setValue(A,"projectionMatrix",ve)):ct.setValue(A,"projectionMatrix",M.projectionMatrix),ct.setValue(A,"viewMatrix",M.matrixWorldInverse);const Dt=ct.map.cameraPosition;Dt!==void 0&&Dt.setValue(A,Z.setFromMatrixPosition(M.matrixWorld)),Ye.logarithmicDepthBuffer&&ct.setValue(A,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)&&ct.setValue(A,"isOrthographic",M.isOrthographicCamera===!0),x!==M&&(x=M,Ft=!0,Ii=!0)}if(I.isSkinnedMesh){ct.setOptional(A,I,"bindMatrix"),ct.setOptional(A,I,"bindMatrixInverse");const wt=I.skeleton;wt&&(wt.boneTexture===null&&wt.computeBoneTexture(),ct.setValue(A,"boneTexture",wt.boneTexture,Ve))}I.isBatchedMesh&&(ct.setOptional(A,I,"batchingTexture"),ct.setValue(A,"batchingTexture",I._matricesTexture,Ve),ct.setOptional(A,I,"batchingIdTexture"),ct.setValue(A,"batchingIdTexture",I._indirectTexture,Ve),ct.setOptional(A,I,"batchingColorTexture"),I._colorsTexture!==null&&ct.setValue(A,"batchingColorTexture",I._colorsTexture,Ve));const Ht=z.morphAttributes;if((Ht.position!==void 0||Ht.normal!==void 0||Ht.color!==void 0)&&Me.update(I,z,qt),(Ft||ze.receiveShadow!==I.receiveShadow)&&(ze.receiveShadow=I.receiveShadow,ct.setValue(A,"receiveShadow",I.receiveShadow)),k.isMeshGouraudMaterial&&k.envMap!==null&&(kt.envMap.value=Te,kt.flipEnvMap.value=Te.isCubeTexture&&Te.isRenderTargetTexture===!1?-1:1),k.isMeshStandardMaterial&&k.envMap===null&&U.environment!==null&&(kt.envMapIntensity.value=U.environmentIntensity),Ft&&(ct.setValue(A,"toneMappingExposure",S.toneMappingExposure),ze.needsLights&&Nt(kt,Ii),re&&k.fog===!0&&V.refreshFogUniforms(kt,re),V.refreshMaterialUniforms(kt,k,G,ne,f.state.transmissionRenderTarget[M.id]),Nr.upload(A,Di(ze),kt,Ve)),k.isShaderMaterial&&k.uniformsNeedUpdate===!0&&(Nr.upload(A,Di(ze),kt,Ve),k.uniformsNeedUpdate=!1),k.isSpriteMaterial&&ct.setValue(A,"center",I.center),ct.setValue(A,"modelViewMatrix",I.modelViewMatrix),ct.setValue(A,"normalMatrix",I.normalMatrix),ct.setValue(A,"modelMatrix",I.matrixWorld),k.isShaderMaterial||k.isRawShaderMaterial){const wt=k.uniformsGroups;for(let Dt=0,jr=wt.length;Dt<jr;Dt++){const On=wt[Dt];D.update(On,qt),D.bind(On,qt)}}return qt}function Nt(M,U){M.ambientLightColor.needsUpdate=U,M.lightProbe.needsUpdate=U,M.directionalLights.needsUpdate=U,M.directionalLightShadows.needsUpdate=U,M.pointLights.needsUpdate=U,M.pointLightShadows.needsUpdate=U,M.spotLights.needsUpdate=U,M.spotLightShadows.needsUpdate=U,M.rectAreaLights.needsUpdate=U,M.hemisphereLights.needsUpdate=U}function Fn(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(M,U,z){const k=Ee.get(M);k.__autoAllocateDepthBuffer=M.resolveDepthBuffer===!1,k.__autoAllocateDepthBuffer===!1&&(k.__useRenderToTexture=!1),Ee.get(M.texture).__webglTexture=U,Ee.get(M.depthTexture).__webglTexture=k.__autoAllocateDepthBuffer?void 0:z,k.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(M,U){const z=Ee.get(M);z.__webglFramebuffer=U,z.__useDefaultFramebuffer=U===void 0};const Wl=A.createFramebuffer();this.setRenderTarget=function(M,U=0,z=0){P=M,w=U,C=z;let k=!0,I=null,re=!1,ge=!1;if(M){const Te=Ee.get(M);if(Te.__useDefaultFramebuffer!==void 0)ie.bindFramebuffer(A.FRAMEBUFFER,null),k=!1;else if(Te.__webglFramebuffer===void 0)Ve.setupRenderTarget(M);else if(Te.__hasExternalTextures)Ve.rebindTextures(M,Ee.get(M.texture).__webglTexture,Ee.get(M.depthTexture).__webglTexture);else if(M.depthBuffer){const Ie=M.depthTexture;if(Te.__boundDepthTexture!==Ie){if(Ie!==null&&Ee.has(Ie)&&(M.width!==Ie.image.width||M.height!==Ie.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ve.setupDepthRenderbuffer(M)}}const He=M.texture;(He.isData3DTexture||He.isDataArrayTexture||He.isCompressedArrayTexture)&&(ge=!0);const Ge=Ee.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(Ge[U])?I=Ge[U][z]:I=Ge[U],re=!0):M.samples>0&&Ve.useMultisampledRTT(M)===!1?I=Ee.get(M).__webglMultisampledFramebuffer:Array.isArray(Ge)?I=Ge[z]:I=Ge,R.copy(M.viewport),H.copy(M.scissor),B=M.scissorTest}else R.copy(se).multiplyScalar(G).floor(),H.copy(We).multiplyScalar(G).floor(),B=Ze;if(z!==0&&(I=Wl),ie.bindFramebuffer(A.FRAMEBUFFER,I)&&k&&ie.drawBuffers(M,I),ie.viewport(R),ie.scissor(H),ie.setScissorTest(B),re){const Te=Ee.get(M.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+U,Te.__webglTexture,z)}else if(ge){const Te=Ee.get(M.texture),He=U;A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,Te.__webglTexture,z,He)}else if(M!==null&&z!==0){const Te=Ee.get(M.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Te.__webglTexture,z)}y=-1},this.readRenderTargetPixels=function(M,U,z,k,I,re,ge,we=0){if(!(M&&M.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=Ee.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&ge!==void 0&&(Te=Te[ge]),Te){ie.bindFramebuffer(A.FRAMEBUFFER,Te);try{const He=M.textures[we],Ge=He.format,Ie=He.type;if(!Ye.textureFormatReadable(Ge)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ye.textureTypeReadable(Ie)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=M.width-k&&z>=0&&z<=M.height-I&&(M.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+we),A.readPixels(U,z,k,I,ce.convert(Ge),ce.convert(Ie),re))}finally{const He=P!==null?Ee.get(P).__webglFramebuffer:null;ie.bindFramebuffer(A.FRAMEBUFFER,He)}}},this.readRenderTargetPixelsAsync=async function(M,U,z,k,I,re,ge,we=0){if(!(M&&M.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=Ee.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&ge!==void 0&&(Te=Te[ge]),Te)if(U>=0&&U<=M.width-k&&z>=0&&z<=M.height-I){ie.bindFramebuffer(A.FRAMEBUFFER,Te);const He=M.textures[we],Ge=He.format,Ie=He.type;if(!Ye.textureFormatReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ye.textureTypeReadable(Ie))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Je=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,Je),A.bufferData(A.PIXEL_PACK_BUFFER,re.byteLength,A.STREAM_READ),M.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+we),A.readPixels(U,z,k,I,ce.convert(Ge),ce.convert(Ie),0);const rt=P!==null?Ee.get(P).__webglFramebuffer:null;ie.bindFramebuffer(A.FRAMEBUFFER,rt);const ft=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await yh(A,ft,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,Je),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,re),A.deleteBuffer(Je),A.deleteSync(ft),re}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(M,U=null,z=0){const k=Math.pow(2,-z),I=Math.floor(M.image.width*k),re=Math.floor(M.image.height*k),ge=U!==null?U.x:0,we=U!==null?U.y:0;Ve.setTexture2D(M,0),A.copyTexSubImage2D(A.TEXTURE_2D,z,0,0,ge,we,I,re),ie.unbindTexture()};const Xl=A.createFramebuffer(),ql=A.createFramebuffer();this.copyTextureToTexture=function(M,U,z=null,k=null,I=0,re=null){re===null&&(I!==0?(vi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),re=I,I=0):re=0);let ge,we,Te,He,Ge,Ie,Je,rt,ft;const dt=M.isCompressedTexture?M.mipmaps[re]:M.image;if(z!==null)ge=z.max.x-z.min.x,we=z.max.y-z.min.y,Te=z.isBox3?z.max.z-z.min.z:1,He=z.min.x,Ge=z.min.y,Ie=z.isBox3?z.min.z:0;else{const Ht=Math.pow(2,-I);ge=Math.floor(dt.width*Ht),we=Math.floor(dt.height*Ht),M.isDataArrayTexture?Te=dt.depth:M.isData3DTexture?Te=Math.floor(dt.depth*Ht):Te=1,He=0,Ge=0,Ie=0}k!==null?(Je=k.x,rt=k.y,ft=k.z):(Je=0,rt=0,ft=0);const tt=ce.convert(U.format),ze=ce.convert(U.type);let yt;U.isData3DTexture?(Ve.setTexture3D(U,0),yt=A.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(Ve.setTexture2DArray(U,0),yt=A.TEXTURE_2D_ARRAY):(Ve.setTexture2D(U,0),yt=A.TEXTURE_2D),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,U.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,U.unpackAlignment);const nt=A.getParameter(A.UNPACK_ROW_LENGTH),qt=A.getParameter(A.UNPACK_IMAGE_HEIGHT),Qn=A.getParameter(A.UNPACK_SKIP_PIXELS),Ft=A.getParameter(A.UNPACK_SKIP_ROWS),Ii=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,dt.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,dt.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,He),A.pixelStorei(A.UNPACK_SKIP_ROWS,Ge),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Ie);const ct=M.isDataArrayTexture||M.isData3DTexture,kt=U.isDataArrayTexture||U.isData3DTexture;if(M.isDepthTexture){const Ht=Ee.get(M),wt=Ee.get(U),Dt=Ee.get(Ht.__renderTarget),jr=Ee.get(wt.__renderTarget);ie.bindFramebuffer(A.READ_FRAMEBUFFER,Dt.__webglFramebuffer),ie.bindFramebuffer(A.DRAW_FRAMEBUFFER,jr.__webglFramebuffer);for(let On=0;On<Te;On++)ct&&(A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Ee.get(M).__webglTexture,I,Ie+On),A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Ee.get(U).__webglTexture,re,ft+On)),A.blitFramebuffer(He,Ge,ge,we,Je,rt,ge,we,A.DEPTH_BUFFER_BIT,A.NEAREST);ie.bindFramebuffer(A.READ_FRAMEBUFFER,null),ie.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else if(I!==0||M.isRenderTargetTexture||Ee.has(M)){const Ht=Ee.get(M),wt=Ee.get(U);ie.bindFramebuffer(A.READ_FRAMEBUFFER,Xl),ie.bindFramebuffer(A.DRAW_FRAMEBUFFER,ql);for(let Dt=0;Dt<Te;Dt++)ct?A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Ht.__webglTexture,I,Ie+Dt):A.framebufferTexture2D(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Ht.__webglTexture,I),kt?A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,wt.__webglTexture,re,ft+Dt):A.framebufferTexture2D(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,wt.__webglTexture,re),I!==0?A.blitFramebuffer(He,Ge,ge,we,Je,rt,ge,we,A.COLOR_BUFFER_BIT,A.NEAREST):kt?A.copyTexSubImage3D(yt,re,Je,rt,ft+Dt,He,Ge,ge,we):A.copyTexSubImage2D(yt,re,Je,rt,He,Ge,ge,we);ie.bindFramebuffer(A.READ_FRAMEBUFFER,null),ie.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else kt?M.isDataTexture||M.isData3DTexture?A.texSubImage3D(yt,re,Je,rt,ft,ge,we,Te,tt,ze,dt.data):U.isCompressedArrayTexture?A.compressedTexSubImage3D(yt,re,Je,rt,ft,ge,we,Te,tt,dt.data):A.texSubImage3D(yt,re,Je,rt,ft,ge,we,Te,tt,ze,dt):M.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,re,Je,rt,ge,we,tt,ze,dt.data):M.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,re,Je,rt,dt.width,dt.height,tt,dt.data):A.texSubImage2D(A.TEXTURE_2D,re,Je,rt,ge,we,tt,ze,dt);A.pixelStorei(A.UNPACK_ROW_LENGTH,nt),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,qt),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Qn),A.pixelStorei(A.UNPACK_SKIP_ROWS,Ft),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Ii),re===0&&U.generateMipmaps&&A.generateMipmap(yt),ie.unbindTexture()},this.copyTextureToTexture3D=function(M,U,z=null,k=null,I=0){return vi('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(M,U,z,k,I)},this.initRenderTarget=function(M){Ee.get(M).__webglFramebuffer===void 0&&Ve.setupRenderTarget(M)},this.initTexture=function(M){M.isCubeTexture?Ve.setTextureCube(M,0):M.isData3DTexture?Ve.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?Ve.setTexture2DArray(M,0):Ve.setTexture2D(M,0),ie.unbindTexture()},this.resetState=function(){w=0,C=0,P=null,ie.reset(),ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return vn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Qe._getUnpackColorSpace()}}const Zm=/^[og]\s*(.+)?/,$m=/^mtllib /,Jm=/^usemtl /,Qm=/^usemap /,Wo=/\s+/,Xo=new N,Cs=new N,qo=new N,Yo=new N,Gt=new N,Ar=new Ke;function e_(){const i={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(r,s){const a=this._finalize(!1);a&&(a.inherited||a.groupCount<=0)&&this.materials.splice(a.index,1);const o={index:this.materials.length,name:r||"",mtllib:Array.isArray(s)&&s.length>0?s[s.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(r){const s=this.currentMaterial();if(s&&s.groupEnd===-1&&(s.groupEnd=this.geometry.vertices.length/3,s.groupCount=s.groupEnd-s.groupStart,s.inherited=!1),r&&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 r&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),s}},n&&n.name&&typeof n.clone=="function"){const r=n.clone(0);r.inherited=!0,this.object.materials.push(r)}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 r=this.vertices,s=this.object.geometry.vertices;s.push(r[e+0],r[e+1],r[e+2]),s.push(r[t+0],r[t+1],r[t+2]),s.push(r[n+0],r[n+1],r[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 r=this.normals,s=this.object.geometry.normals;s.push(r[e+0],r[e+1],r[e+2]),s.push(r[t+0],r[t+1],r[t+2]),s.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){const r=this.vertices,s=this.object.geometry.normals;Xo.fromArray(r,e),Cs.fromArray(r,t),qo.fromArray(r,n),Gt.subVectors(qo,Cs),Yo.subVectors(Xo,Cs),Gt.cross(Yo),Gt.normalize(),s.push(Gt.x,Gt.y,Gt.z),s.push(Gt.x,Gt.y,Gt.z),s.push(Gt.x,Gt.y,Gt.z)},addColor:function(e,t,n){const r=this.colors,s=this.object.geometry.colors;r[e]!==void 0&&s.push(r[e+0],r[e+1],r[e+2]),r[t]!==void 0&&s.push(r[t+0],r[t+1],r[t+2]),r[n]!==void 0&&s.push(r[n+0],r[n+1],r[n+2])},addUV:function(e,t,n){const r=this.uvs,s=this.object.geometry.uvs;s.push(r[e+0],r[e+1]),s.push(r[t+0],r[t+1]),s.push(r[n+0],r[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,r,s,a,o,l,c){const h=this.vertices.length;let u=this.parseVertexIndex(e,h),d=this.parseVertexIndex(t,h),p=this.parseVertexIndex(n,h);if(this.addVertex(u,d,p),this.addColor(u,d,p),o!==void 0&&o!==""){const _=this.normals.length;u=this.parseNormalIndex(o,_),d=this.parseNormalIndex(l,_),p=this.parseNormalIndex(c,_),this.addNormal(u,d,p)}else this.addFaceNormal(u,d,p);if(r!==void 0&&r!==""){const _=this.uvs.length;u=this.parseUVIndex(r,_),d=this.parseUVIndex(s,_),p=this.parseUVIndex(a,_),this.addUV(u,d,p),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,r=e.length;n<r;n++){const s=this.parseVertexIndex(e[n],t);this.addVertexPoint(s),this.addColor(s)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,r=this.uvs.length;for(let s=0,a=e.length;s<a;s++)this.addVertexLine(this.parseVertexIndex(e[s],n));for(let s=0,a=t.length;s<a;s++)this.addUVLine(this.parseUVIndex(t[s],r))}};return i.startObject("",!1),i}class t_ extends wi{constructor(e){super(e),this.materials=null}load(e,t,n,r){const s=this,a=new Al(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(o))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}setMaterials(e){return this.materials=e,this}parse(e){const t=new e_;e.indexOf(`\r
3828
- `)!==-1&&(e=e.replace(/\r\n/g,`
3829
- `)),e.indexOf(`\\
3830
- `)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(`
3831
- `);let r=[];for(let o=0,l=n.length;o<l;o++){const c=n[o].trimStart();if(c.length===0)continue;const h=c.charAt(0);if(h!=="#")if(h==="v"){const u=c.split(Wo);switch(u[0]){case"v":t.vertices.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3])),u.length>=7?(Ar.setRGB(parseFloat(u[4]),parseFloat(u[5]),parseFloat(u[6]),Et),t.colors.push(Ar.r,Ar.g,Ar.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));break;case"vt":t.uvs.push(parseFloat(u[1]),parseFloat(u[2]));break}}else if(h==="f"){const d=c.slice(1).trim().split(Wo),p=[];for(let v=0,m=d.length;v<m;v++){const f=d[v];if(f.length>0){const b=f.split("/");p.push(b)}}const _=p[0];for(let v=1,m=p.length-1;v<m;v++){const f=p[v],b=p[v+1];t.addFace(_[0],f[0],b[0],_[1],f[1],b[1],_[2],f[2],b[2])}}else if(h==="l"){const u=c.substring(1).trim().split(" ");let d=[];const p=[];if(c.indexOf("/")===-1)d=u;else for(let _=0,v=u.length;_<v;_++){const m=u[_].split("/");m[0]!==""&&d.push(m[0]),m[1]!==""&&p.push(m[1])}t.addLineGeometry(d,p)}else if(h==="p"){const d=c.slice(1).trim().split(" ");t.addPointGeometry(d)}else if((r=Zm.exec(c))!==null){const u=(" "+r[0].slice(1).trim()).slice(1);t.startObject(u)}else if(Jm.test(c))t.object.startMaterial(c.substring(7).trim(),t.materialLibraries);else if($m.test(c))t.materialLibraries.push(c.substring(7).trim());else if(Qm.test(c))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(h==="s"){if(r=c.split(" "),r.length>1){const d=r[1].trim().toLowerCase();t.object.smooth=d!=="0"&&d!=="off"}else t.object.smooth=!0;const u=t.object.currentMaterial();u&&(u.smooth=t.object.smooth)}else{if(c==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+c+'"')}}t.finalize();const s=new Hi;if(s.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let o=0,l=t.objects.length;o<l;o++){const c=t.objects[o],h=c.geometry,u=c.materials,d=h.type==="Line",p=h.type==="Points";let _=!1;if(h.vertices.length===0)continue;const v=new en;v.setAttribute("position",new Ct(h.vertices,3)),h.normals.length>0&&v.setAttribute("normal",new Ct(h.normals,3)),h.colors.length>0&&(_=!0,v.setAttribute("color",new Ct(h.colors,3))),h.hasUVIndices===!0&&v.setAttribute("uv",new Ct(h.uvs,2));const m=[];for(let b=0,E=u.length;b<E;b++){const S=u[b],L=S.name+"_"+S.smooth+"_"+_;let w=t.materials[L];if(this.materials!==null){if(w=this.materials.create(S.name),d&&w&&!(w instanceof Ir)){const C=new Ir;yn.prototype.copy.call(C,w),C.color.copy(w.color),w=C}else if(p&&w&&!(w instanceof Vi)){const C=new Vi({size:10,sizeAttenuation:!1});yn.prototype.copy.call(C,w),C.color.copy(w.color),C.map=w.map,w=C}}w===void 0&&(d?w=new Ir:p?w=new Vi({size:1,sizeAttenuation:!1}):w=new Tl,w.name=S.name,w.flatShading=!S.smooth,w.vertexColors=_,t.materials[L]=w),m.push(w)}let f;if(m.length>1){for(let b=0,E=u.length;b<E;b++){const S=u[b];v.addGroup(S.groupStart,S.groupCount,b)}d?f=new fo(v,m):p?f=new Ss(v,m):f=new Jt(v,m)}else d?f=new fo(v,m[0]):p?f=new Ss(v,m[0]):f=new Jt(v,m[0]);f.name=c.name,s.add(f)}else if(t.vertices.length>0){const o=new Vi({size:1,sizeAttenuation:!1}),l=new en;l.setAttribute("position",new Ct(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(l.setAttribute("color",new Ct(t.colors,3)),o.vertexColors=!0);const c=new Ss(l,o);s.add(c)}return s}}class n_ extends wi{constructor(e){super(e)}load(e,t,n,r){const s=this,a=this.path===""?cu.extractUrlBase(e):this.path,o=new Al(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{t(s.parse(l,a))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}setMaterialOptions(e){return this.materialOptions=e,this}parse(e,t){const n=e.split(`
3832
- `);let r={};const s=/\s+/,a={};for(let l=0;l<n.length;l++){let c=n[l];if(c=c.trim(),c.length===0||c.charAt(0)==="#")continue;const h=c.indexOf(" ");let u=h>=0?c.substring(0,h):c;u=u.toLowerCase();let d=h>=0?c.substring(h+1):"";if(d=d.trim(),u==="newmtl")r={name:d},a[d]=r;else if(u==="ka"||u==="kd"||u==="ks"||u==="ke"){const p=d.split(s,3);r[u]=[parseFloat(p[0]),parseFloat(p[1]),parseFloat(p[2])]}else r[u]=d}const o=new i_(this.resourcePath||t,this.materialOptions);return o.setCrossOrigin(this.crossOrigin),o.setManager(this.manager),o.setMaterials(a),o}}class i_{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=this.options.side!==void 0?this.options.side:Sn,this.wrap=this.options.wrap!==void 0?this.options.wrap:Or}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;const t={};for(const n in e){const r=e[n],s={};t[n]=s;for(const a in r){let o=!0,l=r[a];const c=a.toLowerCase();switch(c){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(l=[l[0]/255,l[1]/255,l[2]/255]),this.options&&this.options.ignoreZeroRGBs&&l[0]===0&&l[1]===0&&l[2]===0&&(o=!1);break}o&&(s[c]=l)}}return t}preload(){for(const e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(const t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return this.materials[e]===void 0&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){const t=this,n=this.materialsInfo[e],r={name:e,side:this.side};function s(o,l){return typeof l!="string"||l===""?"":/^https?:\/\//i.test(l)?l:o+l}function a(o,l){if(r[o])return;const c=t.getTextureParams(l,r),h=t.loadTexture(s(t.baseUrl,c.url));h.repeat.copy(c.scale),h.offset.copy(c.offset),h.wrapS=t.wrap,h.wrapT=t.wrap,(o==="map"||o==="emissiveMap")&&(h.colorSpace=Et),r[o]=h}for(const o in n){const l=n[o];let c;if(l!=="")switch(o.toLowerCase()){case"kd":r.color=Qe.colorSpaceToWorking(new Ke().fromArray(l),Et);break;case"ks":r.specular=Qe.colorSpaceToWorking(new Ke().fromArray(l),Et);break;case"ke":r.emissive=Qe.colorSpaceToWorking(new Ke().fromArray(l),Et);break;case"map_kd":a("map",l);break;case"map_ks":a("specularMap",l);break;case"map_ke":a("emissiveMap",l);break;case"norm":a("normalMap",l);break;case"map_bump":case"bump":a("bumpMap",l);break;case"disp":a("displacementMap",l);break;case"map_d":a("alphaMap",l),r.transparent=!0;break;case"ns":r.shininess=parseFloat(l);break;case"d":c=parseFloat(l),c<1&&(r.opacity=c,r.transparent=!0);break;case"tr":c=parseFloat(l),this.options&&this.options.invertTrProperty&&(c=1-c),c>0&&(r.opacity=1-c,r.transparent=!0);break}}return this.materials[e]=new Tl(r),this.materials[e]}getTextureParams(e,t){const n={scale:new Xe(1,1),offset:new Xe(0,0)},r=e.split(/\s+/);let s;return s=r.indexOf("-bm"),s>=0&&(t.bumpScale=parseFloat(r[s+1]),r.splice(s,2)),s=r.indexOf("-mm"),s>=0&&(t.displacementBias=parseFloat(r[s+1]),t.displacementScale=parseFloat(r[s+2]),r.splice(s,3)),s=r.indexOf("-s"),s>=0&&(n.scale.set(parseFloat(r[s+1]),parseFloat(r[s+2])),r.splice(s,4)),s=r.indexOf("-o"),s>=0&&(n.offset.set(parseFloat(r[s+1]),parseFloat(r[s+2])),r.splice(s,4)),n.url=r.join(" ").trim(),n}loadTexture(e,t,n,r,s){const a=this.manager!==void 0?this.manager:bl;let o=a.getHandler(e);o===null&&(o=new ru(a)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin);const l=o.load(e,n,r,s);return t!==void 0&&(l.mapping=t),l}}const jo={type:"change"},La={type:"start"},Il={type:"end"},wr=new Xr,Ko=new Cn,r_=Math.cos(70*Mh.DEG2RAD),_t=new N,Ut=2*Math.PI,at={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ps=1e-6;class s_ extends uu{constructor(e,t=null){super(e,t),this.state=at.NONE,this.target=new N,this.cursor=new N,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:_i.ROTATE,MIDDLE:_i.DOLLY,RIGHT:_i.PAN},this.touches={ONE:pi.ROTATE,TWO:pi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new N,this._lastQuaternion=new Zn,this._lastTargetPosition=new N,this._quat=new Zn().setFromUnitVectors(e.up,new N(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new vo,this._sphericalDelta=new vo,this._scale=1,this._panOffset=new N,this._rotateStart=new Xe,this._rotateEnd=new Xe,this._rotateDelta=new Xe,this._panStart=new Xe,this._panEnd=new Xe,this._panDelta=new Xe,this._dollyStart=new Xe,this._dollyEnd=new Xe,this._dollyDelta=new Xe,this._dollyDirection=new N,this._mouse=new Xe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=o_.bind(this),this._onPointerDown=a_.bind(this),this._onPointerUp=l_.bind(this),this._onContextMenu=m_.bind(this),this._onMouseWheel=u_.bind(this),this._onKeyDown=f_.bind(this),this._onTouchStart=d_.bind(this),this._onTouchMove=p_.bind(this),this._onMouseDown=c_.bind(this),this._onMouseMove=h_.bind(this),this._interceptControlDown=__.bind(this),this._interceptControlUp=g_.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(jo),this.update(),this.state=at.NONE}update(e=null){const t=this.object.position;_t.copy(t).sub(this.target),_t.applyQuaternion(this._quat),this._spherical.setFromVector3(_t),this.autoRotate&&this.state===at.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Ut:n>Math.PI&&(n-=Ut),r<-Math.PI?r+=Ut:r>Math.PI&&(r-=Ut),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(_t.setFromSpherical(this._spherical),_t.applyQuaternion(this._quatInverse),t.copy(this.target).add(_t),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=_t.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new N(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(),s=l!==this.object.zoom;const c=new N(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=_t.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):(wr.origin.copy(this.object.position),wr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(wr.direction))<r_?this.object.lookAt(this.target):(Ko.setFromNormalAndCoplanarPoint(this.object.up,this.target),wr.intersectPlane(Ko,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Ps||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ps||this._lastTargetPosition.distanceToSquared(this.target)>Ps?(this.dispatchEvent(jo),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ut/60*this.autoRotateSpeed*e:Ut/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){_t.setFromMatrixColumn(t,0),_t.multiplyScalar(-e),this._panOffset.add(_t)}_panUp(e,t){this.screenSpacePanning===!0?_t.setFromMatrixColumn(t,1):(_t.setFromMatrixColumn(t,0),_t.crossVectors(this.object.up,_t)),_t.multiplyScalar(e),this._panOffset.add(_t)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;_t.copy(r).sub(this.target);let s=_t.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ut*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ut*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Ut*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Ut*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Ut*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Ut*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ut*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ut*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const 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 Xe,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 a_(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function o_(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function l_(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Il),this.state=at.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 c_(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case _i.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=at.DOLLY;break;case _i.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=at.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=at.ROTATE}break;case _i.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=at.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=at.PAN}break;default:this.state=at.NONE}this.state!==at.NONE&&this.dispatchEvent(La)}function h_(i){switch(this.state){case at.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case at.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case at.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function u_(i){this.enabled===!1||this.enableZoom===!1||this.state!==at.NONE||(i.preventDefault(),this.dispatchEvent(La),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Il))}function f_(i){this.enabled!==!1&&this._handleKeyDown(i)}function d_(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case pi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=at.TOUCH_ROTATE;break;case pi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=at.TOUCH_PAN;break;default:this.state=at.NONE}break;case 2:switch(this.touches.TWO){case pi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=at.TOUCH_DOLLY_PAN;break;case pi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=at.TOUCH_DOLLY_ROTATE;break;default:this.state=at.NONE}break;default:this.state=at.NONE}this.state!==at.NONE&&this.dispatchEvent(La)}function p_(i){switch(this._trackPointer(i),this.state){case at.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case at.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case at.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case at.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=at.NONE}}function m_(i){this.enabled!==!1&&i.preventDefault()}function __(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function g_(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const v_={class:"content-show"},x_={__name:"threeModel",props:{isShow:Boolean},setup(i){const e=$.ref(null),t=i,n=Jo.useModelComp(Wi.pinia),{nodeDev:r}=it.storeToRefs(n);let s,a,o,l,c;const h=async()=>{s=new Kh,s.background=new Ke(15790320),a=new Xt(75,e.value.clientWidth/e.value.clientHeight,.1,1e3),a.position.z=5,o=new Km({antialias:!0}),o.setSize(e.value.clientWidth,e.value.clientHeight),o.setPixelRatio(window.devicePixelRatio),e.value.appendChild(o.domElement),l=new s_(a,o.domElement),l.enableDamping=!0,l.dampingFactor=.05;const _=new lu(16777215,.5);s.add(_);const v=new ou(16777215,.8);v.position.set(1,1,1),s.add(v),await u(),d()},u=async _=>{const v=await Ua.downloadAvatarApi({url:"upload/2025/06/17/688010456879173.obj"}),m=new Blob([v.data],{type:"application/octet-stream;charset=UTF-8"}),f=URL.createObjectURL(m),b=await Ua.downloadAvatarApi({url:"upload/2025/06/17/688013326958661.mtl"}),E=new Blob([b.data],{type:"application/octet-stream;charset=UTF-8"}),S=URL.createObjectURL(E);new n_().load(S,w=>{w.preload();const C=new t_;C.setMaterials(w),C.load(f,P=>{c=P,c.rotation.set(50,-20,200),s.add(c);const y=new Ai().setFromObject(c),x=y.getSize(new N).length(),R=y.getCenter(new N);a.position.copy(R),a.position.z+=x*.6,a.lookAt(R),l.target.copy(R)},P=>{console.log(P.loaded/P.total*100+"% loaded")},P=>{console.error("An error happened loading the OBJ model:",P)})},w=>{console.log(w.loaded/w.total*100+"% loaded")},w=>{console.error("An error happened loading the MTL materials:",w)})},d=()=>{requestAnimationFrame(d),l.update(),o.render(s,a)},p=()=>{a.aspect=e.value.clientWidth/e.value.clientHeight,a.updateProjectionMatrix(),o.setSize(e.value.clientWidth,e.value.clientHeight)};return $.onMounted(async()=>{window.addEventListener("resize",p),await h()}),$.watch(()=>t==null?void 0:t.isShow,()=>{t!=null&&t.isShow&&!l&&!o&&(console.log(123,(t==null?void 0:t.isShow)&&!l&&!o),setTimeout(async()=>{window.addEventListener("resize",p),await h()},50))},{deep:!0,immediate:!0}),$.onBeforeUnmount(()=>{window.removeEventListener("resize",p),o&&o.dispose(),l&&l.dispose()}),(_,v)=>($.openBlock(),$.createElementBlock("div",v_,[$.createElementVNode("div",{ref_key:"container",ref:e,class:"three-container"},null,512)]))}},Nl=Ma._export_sfc(x_,[["__scopeId","data-v-5f5332e0"]]),Fl=it.defineStore("formToTableComp",{state:()=>({selectArray:[],selectString:""}),actions:{setSelectArray(i){this.selectArray=i},setSelectString(i){this.selectString=i}}}),Ol=it.defineStore("unit",{state:()=>({selectIndex:"",selectMenu:"",selectTitle:[]}),actions:{setSelectIndex(i){this.selectIndex=i},setSelectMenu(i){this.selectMenu=i},setSelectTitle(i){this.selectTitle=i}}}),Bl=(i,e)=>{let t=i,n=e;return Array.isArray(t)&&(t=t==null?void 0:t.map((r,s)=>{if(Array.isArray(r)){let a={};return r=r==null?void 0:r.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=Bl(o,n))}),Object.assign(a,{id:s})}else return r})),t},zl=(i,e,t)=>{let n=i,r=e;return n=n==null?void 0:n.map((s,a)=>{var o,l;return!Array.isArray(s)||!((o=r==null?void 0:r[a])!=null&&o.label)&&!t||(s.unshift(((l=r==null?void 0:r[a])==null?void 0:l.label)??""),s.some(c=>Array.isArray(c))&&(s=s==null?void 0:s.map(c=>{var h;return Array.isArray(c)&&(c=zl(c,(h=r==null?void 0:r[a])==null?void 0:h.children,t)),c}))),s}),n},M_=(i,e,t)=>{if(e==="")return i==null?void 0:i.filter(n=>(n==null?void 0:n.id)!==t);{const n=e.split("-");return S_(i,n,t)}},S_=(i,e,t)=>{let n=i,r=e;return(r==null?void 0:r.length)===0?n=n==null?void 0:n.filter(s=>s.id!==t):n=n==null?void 0:n.map(s=>(s.id.toString()===(r==null?void 0:r[0])&&(r==null||r.shift(),s=kl(s,r,t)),s)),n},kl=(i,e,t)=>{var s,a;let n=i,r=e;return(r==null?void 0:r.length)===0?n.children=(s=n.children)==null?void 0:s.filter(o=>o.id!==t):n.children=(a=n.children)==null?void 0:a.map(o=>(o.id.toString()===(r==null?void 0:r[0])&&(r==null||r.shift(),o=kl(o,r,t)),o)),n},y_=(i,e,t)=>{if(e==="")return t;{const n=e.split("-");return E_(i,n,t)}},E_=(i,e,t)=>{let n=i,r=e;return(r==null?void 0:r.length)===0?n=t:n=n==null?void 0:n.map(s=>(s.id.toString()===(r==null?void 0:r[0])&&(r==null||r.shift(),s=Hl(s,r,t)),s)),n},Hl=(i,e,t)=>{var s;let n=i,r=e;return(r==null?void 0:r.length)===0?n.children=t:n.children=(s=n.children)==null?void 0:s.map(a=>(a.id.toString()===(r==null?void 0:r[0])&&(r==null||r.shift(),a=Hl(a,r,t)),a)),n},Vl=(i,e)=>i==null?void 0:i.map(n=>{var r,s,a,o,l,c;if(Array.isArray(n)?n=n:n=[n],(r=n==null?void 0:n.filter(h=>!(h!=null&&h.id)))!=null&&r.every(h=>typeof h!="object"||h===null))return n;if((s=n==null?void 0:n.filter(h=>!(h!=null&&h.id)))!=null&&s.some(h=>Array.isArray(h)))return n;{let h=[];if(h.push(n==null?void 0:n.find(u=>u==null?void 0:u.id)),Array.isArray(e==null?void 0:e[0])){const u=(a=n==null?void 0:n.filter(d=>!(d!=null&&d.id)))==null?void 0:a[0];(o=Wt.getColumnChild(Ae.cloneDeep(e==null?void 0:e[0])))==null||o.forEach(d=>{h.push(u==null?void 0:u[(d==null?void 0:d.prop)??(d==null?void 0:d.label)??d])})}else{const u=(l=n==null?void 0:n.filter(d=>!(d!=null&&d.id)))==null?void 0:l[0];(c=Wt.getColumnChild(Ae.cloneDeep(e)))==null||c.forEach(d=>{h.push(u==null?void 0:u[(d==null?void 0:d.prop)??(d==null?void 0:d.label)??d])})}return h}}),T_=i=>{try{return JSON.parse(i),!0}catch{return!1}},Zo=(i,e)=>Ec(i,e),bi=i=>{let e=[];function t(r){Array.isArray(r)&&(r==null||r.forEach(s=>{Array.isArray(s)||(s=[s]),s==null||s.forEach(a=>{!(a!=null&&a.children)||a.children.length===0?e.push(a.label):n(a.children)})}))}function n(r){r==null||r.forEach(s=>{!(s!=null&&s.children)||s.children.length===0?e.push(s.label):n(s.children)})}return t(i),e},b_=(i,e,t)=>{var r;let n=(r=Ae.cloneDeep(i))==null?void 0:r.map(s=>(s=s.filter(a=>!(a!=null&&a.id)),s));return n=n==null?void 0:n.map(s=>{var a;return s=(a=s.map((o,l)=>{let c={};if(t!=null&&t.find(h=>h===e[l]))return c[e[l]]=o,c}))==null?void 0:a.filter(o=>o),s}),n},A_=(i,e)=>{var a,o;const t=Ae.cloneDeep(i),n=(a=t==null?void 0:t.find(l=>(l==null?void 0:l.key)==="header"))==null?void 0:a.contents,r=(o=t==null?void 0:t.find(l=>(l==null?void 0:l.key)==="tableContents"))==null?void 0:o.contents;return b_(r,bi(n).slice(0,bi(n).length-1),e)},mn=i=>{var r,s,a,o;const e=i;let t=[];e.compData=(r=e.compData)==null?void 0:r.filter(l=>(l==null?void 0:l.key)!=="tableContents"&&(l==null?void 0:l.key)!=="tableIndex");const n=(a=(s=Ae.cloneDeep(e.compData))==null?void 0:s.find(l=>(l==null?void 0:l.key)==="tableIndexColumn"))==null?void 0:a.contents;return(o=Ae.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(h=>Array.isArray(h))?c==null||c[0].unshift({label:n}):c.unshift({label:n})),t.push({key:"header",contents:c})}}),e.compData=t,e},va=i=>{var s,a,o,l,c;const e=(s=i.compData)==null?void 0:s.filter(h=>(h==null?void 0:h.key)==="tableContents"||(h==null?void 0:h.key)==="tableIndex"),t=(o=(a=e==null?void 0:e.find(h=>(h==null?void 0:h.key)==="tableIndex"))==null?void 0:a.contents)==null?void 0:o.map(h=>h.label),n=(l=e==null?void 0:e.find(h=>(h==null?void 0:h.key)==="tableContents"))==null?void 0:l.contents;let r=[];return(t==null?void 0:t.length)>0&&(n!=null&&n.every(h=>Array.isArray(h)))?r=t==null?void 0:t.map((h,u)=>n[u]?[h,...n[u]]:[h]):Array.isArray(n==null?void 0:n[0])&&((c=n==null?void 0:n[0])!=null&&c.every(h=>Array.isArray(h)))?r=n==null?void 0:n[0]:Array.isArray(n==null?void 0:n[0])?r=n:r.push(n),r},w_=i=>{const e=[];function t(n){!n||n.length===0||(e.push(n==null?void 0:n.map(r=>({label:r.label}))),n==null||n.forEach(r=>{r!=null&&r.children&&(r==null?void 0:r.children.length)>0&&t(r==null?void 0:r.children)}))}return t(i),e},R_=i=>{const e=[];function t(n,r=[]){!n||n.length===0||(e.push({key:r==null?void 0:r.filter(s=>!Array.isArray(s)),value:n}),n==null||n.forEach(s=>{s!=null&&s.some(a=>Array.isArray(a))&&t(s.find(a=>Array.isArray(a)),s)}))}return t(i),e},C_=i=>{const e=[];function t(n){!n||n.length===0||(e.push(n==null?void 0:n.map(r=>r==null?void 0:r.filter(s=>!Array.isArray(s)))),n==null||n.forEach(r=>{r!=null&&r.some(s=>Array.isArray(s))&&t(r.find(s=>Array.isArray(s)))}))}return t(i),e},P_=i=>{const e=[];function t(n){var r;!n||n.length===0||(n!=null&&n.every(s=>!Array.isArray(s))?e.push(n):(e.push((r=n==null?void 0:n.map(s=>s==null?void 0:s.filter(a=>!Array.isArray(a))))==null?void 0:r[0]),n==null||n.forEach(s=>{s!=null&&s.some(a=>Array.isArray(a))&&t(s.find(a=>Array.isArray(a)))})))}return t(i),e},D_=(i,e)=>{let t;function n(r,s,a=1){var l;if(!r||r.length===0)return;const o=(l=Ae.cloneDeep(s))==null?void 0:l.map(c=>c==null?void 0:c.filter(h=>!Array.isArray(h)));return o!=null&&o.find(c=>Zo(c,r==null?void 0:r.key))?(s==null||s.forEach(c=>{!n(r,c.find(u=>Array.isArray(u)))&&Zo(c.filter(u=>!Array.isArray(u)),r==null?void 0:r.key)&&(t={type:a,contents:c.filter(u=>!Array.isArray(u))})}),!0):!1}return n(i,e,0),t},$o=(i,e)=>{function t(n,r){return!n||n.length===0||n==null?void 0:n.map((a,o)=>{var c,h;let l=a;return l.unshift((c=r==null?void 0:r[o])==null?void 0:c.label),l.some(u=>Array.isArray(u))&&(l[l.length-1]=t(l.find(u=>Array.isArray(u)),(h=r==null?void 0:r[o])==null?void 0:h.children)),l})}return t(i,e)},xa=i=>{var t,n,r,s,a,o,l,c,h,u,d,p,_,v,m,f,b,E,S,L,w,C,P,y,x;const e=i;if((i==null?void 0:i.comp)==="Table"){if((r=(n=(t=i.compData)==null?void 0:t.find(R=>(R==null?void 0:R.key)==="tableIndex"))==null?void 0:n.contents)!=null&&r.every(R=>!(R!=null&&R.children))||!((s=i.compData)!=null&&s.find(R=>(R==null?void 0:R.key)==="tableIndex")))return((l=(o=(a=e.compData)==null?void 0:a.find(R=>(R==null?void 0:R.key)==="tableContents"))==null?void 0:o.contents)==null?void 0:l.length)===1&&((d=(u=(h=(c=e.compData)==null?void 0:c.find(R=>(R==null?void 0:R.key)==="tableContents"))==null?void 0:h.contents)==null?void 0:u[0])!=null&&d.every(R=>Array.isArray(R)))?(e.compData=(p=e.compData)==null?void 0:p.map(R=>{var H;return(R==null?void 0:R.key)==="tableContents"&&(R.contents=(H=R.contents)==null?void 0:H[0]),R}),[e]):[e];{let R=[];const H=e.compData,B=(_=Ae.cloneDeep(H))==null?void 0:_.find(se=>(se==null?void 0:se.key)==="tableIndexColumn"),j=(v=Ae.cloneDeep(H))==null?void 0:v.find(se=>(se==null?void 0:se.key)==="extraButton"),J=(m=Ae.cloneDeep(H))==null?void 0:m.find(se=>(se==null?void 0:se.key)==="rowButton"),W=P_((b=(f=Ae.cloneDeep(H))==null?void 0:f.find(se=>(se==null?void 0:se.key)==="header"))==null?void 0:b.contents),ne=(E=Ae.cloneDeep(H))==null?void 0:E.find(se=>(se==null?void 0:se.key)==="tableIndex"),G=C_((L=(S=Ae.cloneDeep(H))==null?void 0:S.find(se=>(se==null?void 0:se.key)==="tableContents"))==null?void 0:L.contents),fe=$o((C=(w=Ae.cloneDeep(H))==null?void 0:w.find(se=>(se==null?void 0:se.key)==="tableContents"))==null?void 0:C.contents,ne==null?void 0:ne.contents),xe=R_($o((y=(P=Ae.cloneDeep(H))==null?void 0:P.find(se=>(se==null?void 0:se.key)==="tableContents"))==null?void 0:y.contents,ne==null?void 0:ne.contents));if(ne)return(x=w_(ne.contents))==null||x.forEach((se,We)=>{var Y;let Ze=[];Ze.push({key:"tableIndex",contents:se}),Ze.push(B),Ze.push(j),Ze.push(J),Ze.push({key:"tableContents",contents:G[We]}),Ze.push({key:"header",contents:W!=null&&W[We]?[W==null?void 0:W[We]]:[W==null?void 0:W[0]]}),R.push({comp:"Table",compData:Ze,name:"",parentTableContents:((Y=D_(xe[We],fe))==null?void 0:Y.contents)??""})}),R}}else return[e]},Gr=(i,e)=>{let t={};return Array.isArray(i)?i==null||i.forEach((n,r)=>{t[e[r]]=n}):[i].forEach((n,r)=>{t[e[r]]=n}),t},L_=async i=>{let e=[];i==null||i.forEach(t=>{var n;(n=t.compData)==null||n.forEach(r=>{var s;(s=r.contents)==null||s.forEach(a=>{var o;Array.isArray(a)?a==null||a.forEach(l=>{var c;(c=xa(Ae.cloneDeep(l)))==null||c.forEach(async h=>{var u,d,p,_,v;if(l.comp==="Table"){const m=await it.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(h==null?void 0:h.parentTableContents)??""},value:{pageData:{comp:(u=mn(Ae.cloneDeep(h)))==null?void 0:u.comp,compData:(d=mn(Ae.cloneDeep(h)))==null?void 0:d.compData,name:(p=mn(Ae.cloneDeep(h)))==null?void 0:p.name}}}),f=m.data.result,b=await((_=va(Ae.cloneDeep(h)))==null?void 0:_.map(async E=>{var C,P,y,x,R;let S;E.length!==0&&(S=await it.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"data",tableId:f},value:{tableData:Gr(E,(x=bi((y=(P=(C=mn(Ae.cloneDeep(h)))==null?void 0:C.compData)==null?void 0:P.find(H=>(H==null?void 0:H.key)==="header"))==null?void 0:y.contents))==null?void 0:x.filter(H=>H!=="操作"))}}));const w=await((R=(await it.getInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",parentTable:E}})).data.result)==null?void 0:R.map(async H=>await it.updateInsofDataApi({id:H.id,key:{systemKey:H.key.systemKey,pageKey:H.key.pageKey,type:H.key.type,version:H.key.version,parentTable:S.data.result}})));return e.push(w),S}));e.push(m),e.push(b)}else if((h==null?void 0:h.key)==="extraButton"){if(((v=Object.values(h==null?void 0:h.value))==null?void 0:v.length)!==0){const m=await it.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structureMethod",version:1},value:{pageData:h.value}});e.push(m)}}else{const m=await it.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(h==null?void 0:h.parentTableContents)??""},value:{pageData:h}});e.push(m)}})}):(o=xa(Ae.cloneDeep(a)))==null||o.forEach(async l=>{var c,h,u,d,p;if(a.comp==="Table"){const _=await it.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure",version:1,parentTable:(l==null?void 0:l.parentTableContents)??""},value:{pageData:{comp:(c=mn(Ae.cloneDeep(l)))==null?void 0:c.comp,compData:(h=mn(Ae.cloneDeep(l)))==null?void 0:h.compData,name:(u=mn(Ae.cloneDeep(l)))==null?void 0:u.name}}}),v=_.data.result,m=await((d=va(Ae.cloneDeep(l)))==null?void 0:d.map(async f=>{var L,w,C,P,y;let b;(f==null?void 0:f.length)!==0&&(b=await it.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"data",tableId:v},value:{tableData:Gr(f,(P=bi((C=(w=(L=mn(Ae.cloneDeep(l)))==null?void 0:L.compData)==null?void 0:w.find(x=>(x==null?void 0:x.key)==="header"))==null?void 0:C.contents))==null?void 0:P.filter(x=>x!=="操作"))}}));const S=await((y=(await it.getInsofDataApi({key:{parentTable:f,systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structure"}})).data.result)==null?void 0:y.map(async x=>await it.updateInsofDataApi({id:x.id,key:{systemKey:x.key.systemKey,pageKey:x.key.pageKey,type:x.key.type,version:x.key.version,parentTable:x.key.parentTable===""?"":b.data.result}})));return e.push(S),b}));e.push(_),e.push(m)}else if((l==null?void 0:l.key)==="extraButton"){if(((p=Object.values(l==null?void 0:l.value))==null?void 0:p.length)!==0){const _=await it.createInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),pageKey:t.name,type:"structureMethod",version:1},value:{pageData:l.value}});e.push(_)}}else{const _=await it.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(_)}})})})}),await Promise.all(e)},U_=it.useMenuState(Wi.pinia),I_=i=>{var t;const e=Array.isArray(i)?i==null?void 0:i[0]:{};return(t=e==null?void 0:e.contents)==null?void 0:t.map(n=>({...n[0],...n[1]}))},Gl=async(i,e,t="",n)=>{var u,d,p,_,v,m;const r=await it.getInsofDataApi({key:{pageKey:i,systemKey:e,parentTable:t}}),s=await it.getInsofDataApi({key:{pageKey:i,systemKey:e,type:"structureMethod"}}),a=(u=r.data.result)==null?void 0:u.map(f=>f.id),o=a==null?void 0:a.map(f=>it.getInsofDataApi({key:{pageKey:i,systemKey:e,tableId:f}})),l=await Promise.all(o),c=[];l==null||l.forEach(f=>{var S,L,w,C;const b=(S=f.data.result)==null?void 0:S.map(P=>{const y=Array.isArray(P.value.tableData)?P.value.tableData:[P.value.tableData];return y.unshift({id:P.id}),y}),E=(C=(w=(L=f.data.result)==null?void 0:L[0])==null?void 0:w.key)==null?void 0:C.tableId;c.push({key:E,contents:b})});const h=[];return(d=r.data.result)==null||d.forEach(f=>{var S,L,w,C;const b=f.value.pageData,E=(S=Ae.cloneDeep(b.compData))==null?void 0:S.filter(P=>(P==null?void 0:P.key)!=="tableContents");if(E&&(E!=null&&E.find(P=>(P==null?void 0:P.key)==="header"))&&E.push({key:"tableContents",contents:n==="/系统管理/用户管理"?I_(c):Vl((L=c==null?void 0:c.find(P=>(P==null?void 0:P.key)===f.id))==null?void 0:L.contents,(w=E==null?void 0:E.find(P=>(P==null?void 0:P.key)==="header"))==null?void 0:w.contents)}),b.compData=E,b.id=f.id,((C=f.key)==null?void 0:C.type)!=="method")h.push(b);else{let P;P={name:"",compData:[b],comp:"calculator"},h.push(P)}}),((_=(p=s.data.result)==null?void 0:p.map(f=>f.value.pageData))==null?void 0:_.filter(f=>Object.values(f).length>0).length)>0&&h.push({comp:"methodButton",name:"",compData:(m=(v=s.data.result)==null?void 0:v.map(f=>f.value.pageData))==null?void 0:m.filter(f=>Object.values(f).length>0)}),h},N_=async i=>{await it.deleteInsofDataApi({id:i})},F_=async(i,e,t,n,r,s)=>{var a;await it.createInsofDataApi({key:{type:i,pageKey:e,tableId:t,systemKey:n},value:{tableData:Gr(r,(a=bi(s))==null?void 0:a.filter(o=>o!=="操作"))}})},O_=async(i,e,t,n,r,s,a)=>{var o;await it.updateInsofDataApi({key:{type:i,pageKey:e,tableId:t,systemKey:r},value:{tableData:Gr(s,(o=bi(a))==null?void 0:o.filter(l=>l!=="操作"))},id:n})},B_=async(i,e)=>{await it.updateInsofDataApi({value:{pageData:e},id:i})},z_=async(i,e)=>await it.getInsofDataApi({key:i,valueLikes:e}),k_=async()=>{var i,e,t,n,r,s,a,o,l;try{const c=await it.getInsofDataApi({key:{systemKey:sessionStorage.getItem("systemKey"),layer:"superAdmin"}});((i=c==null?void 0:c.data)==null?void 0:i.code)===200&&(U_.setPlatform(((r=(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:r.type)==="制造系统"?"client":"browser"),(l=(o=(a=(s=c==null?void 0:c.data)==null?void 0:s.result)==null?void 0:a[0])==null?void 0:o.key)==null||l.type)}catch(c){return Promise.reject(c)}},H_={class:"table-content"},V_=["onClick"],G_={class:"form-content"},W_={key:0,class:"dialog-footer"},X_={__name:"index",props:{itemData:{type:Array,default:()=>[]},childItemData:{type:Array,default:()=>[]},index:Number,changedContent:{type:Object,default:()=>{}}},emits:["change","contentChange","onButtonClick","contentClick","pageChange"],setup(i,{emit:e}){const t=i,n=e,r=$.ref([]),s=it.useMenuState(),{activeMenuPath:a}=it.storeToRefs(s),o=Jo.useModelComp(Wi.pinia),{extraContents:l}=it.storeToRefs(o),c=$.ref([]),h=$.ref(!1),u=$.ref("");$.ref();const d=$.ref(!0),p=$.ref(0),_=$.ref(!1),v=$.ref(""),m=$.ref(!1),f=$.ref({label:"查看三维模型"}),b=$.ref([]),E=$.ref([]),S=$.ref(!1),L=$.ref([]),w=$.ref([]),C=$.ref(),P=$.ref(),y=Fl(Wi.pinia),x=$.ref(),R=Ol(Wi.pinia),{selectIndex:H,selectMenu:B,selectTitle:j}=it.storeToRefs(R),{selectString:J}=it.storeToRefs(y),W=$.ref(720),ne=()=>{m.value=!1},G=(Z,Q)=>{if(Object.values(Q).length!==0)return Object.values(Q).find(de=>{var Se,oe;return((Se=de==null?void 0:de.toString())==null?void 0:Se.includes(".obj"))||((oe=de==null?void 0:de.toString())==null?void 0:oe.includes(".stl"))})?[...Z,f.value]:Z},fe=Z=>{var oe;J.value===""?Z==null||Z[0]:(Z==null?void 0:Z.find(A=>(A==null?void 0:A.selectLabel)==="("+J.value+")"))??(Z==null||Z.find(A=>!(A!=null&&A.selectLabel)));let Q=Z;(oe=r.value)!=null&&oe.find(A=>A.prop==="index");let de=C.value;const Se=[];return Q==null||Q.forEach((A,ae)=>{var Ye;let Re={};if(Array.isArray(A)){let ie=[];A==null||A.filter(Fe=>!(Fe!=null&&Fe.id)).forEach((Fe,Ee)=>{var Ve,lt,T,g,F;if((Ve=de==null?void 0:de[Ee])!=null&&Ve.prop&&!Array.isArray(Fe)){let q={};q[de[Ee].column]=Fe,l!=null&&l.value&&((lt=l==null?void 0:l.value)==null?void 0:lt.length)>0&&((T=l==null?void 0:l.value)!=null&&T.find(K=>JSON.stringify(K==null?void 0:K[0])===JSON.stringify(q)))&&(ie=(g=l==null?void 0:l.value)==null?void 0:g.find(K=>JSON.stringify(K==null?void 0:K[0])===JSON.stringify(q))),ie&&ie.length>0?Re[de[Ee].prop]=ie!=null&&ie.find(K=>{var V;return((V=Object.keys(K))==null?void 0:V[0])===de[Ee].column})?(F=ie==null?void 0:ie.find(K=>{var V;return((V=Object.keys(K))==null?void 0:V[0])===de[Ee].column}))==null?void 0:F[de[Ee].column]:Fe:Re[de[Ee].prop]=Fe}})}else Re=A;Array.isArray(A)&&A.some(ie=>ie==null?void 0:ie.id)?Se.push(Object.assign(Re,{id:(Ye=A==null?void 0:A.find(ie=>ie.id))==null?void 0:Ye.id})):Re.id?Se.push(Re):Se.push(Object.assign(Re,{id:ae}))}),Se},xe=async Z=>{var oe,A,ae,Re,Ye;let Q={};for(let ie in Z)Z[ie]!==""&&(Q["tableData."+ie]=Z[ie]);const de=await z_({type:"data",tableId:t==null?void 0:t.index,systemKey:sessionStorage.getItem("systemKey"),pageKey:a.value},Q),Se=(ae=(A=(oe=Ae.cloneDeep(de))==null?void 0:oe.data)==null?void 0:A.result)==null?void 0:ae.map(ie=>{var Ee;let Fe=[];return Fe.push({id:ie.id}),Fe.push((Ee=ie==null?void 0:ie.value)==null?void 0:Ee.tableData),Fe});c.value=fe(Vl(Se,(Ye=(Re=Ae.cloneDeep(r.value))==null?void 0:Re.map(ie=>ie.label))==null?void 0:Ye.filter(ie=>ie!=="操作")))},se=async Z=>{var de,Se,oe,A,ae,Re,Ye;let Q=await Gl(a.value,sessionStorage.getItem("systemKey"),Z.id);if(Q=Q==null?void 0:Q.filter(ie=>ie.comp!=="methodButton"),Q&&Q.length>0){const ie=!Array.isArray(j.value)&&((de=j.value)==null?void 0:de.key)!=="main"?[]:j.value;ie.push({key:B.value===""?(Se=Z==null?void 0:Z.id)==null?void 0:Se.toString():B.value+"-"+((oe=Z==null?void 0:Z.id)==null?void 0:oe.toString()),value:Z[(A=Object.keys(Z))==null?void 0:A.filter(Fe=>Fe!=="index"&&Fe!=="id")[0]]}),R.setSelectMenu(B.value===""?(ae=Z==null?void 0:Z.id)==null?void 0:ae.toString():B.value+"-"+((Re=Z==null?void 0:Z.id)==null?void 0:Re.toString())),R.setSelectTitle(ie),R.setSelectIndex((Ye=Z==null?void 0:Z.id)==null?void 0:Ye.toString()),n("pageChange",Q)}},We=Z=>{var Q;(Q=Ae.cloneDeep(t.itemData))==null||Q.map(de=>((de==null?void 0:de.key)==="tableContents"&&(de.contents=Z),de))},Ze=(Z,Q,de)=>{n("contentClick",Z,Q,de,{id:t==null?void 0:t.index})};$.watch(()=>t.changedContent,()=>{var de,Se;if(!t.changedContent)return;let Z=(de=c.value)==null?void 0:de.map(oe=>{var A;return oe.id===((A=t.changedContent)==null?void 0:A.id)&&(oe={...t.changedContent,id:t.changedContent.newId?t.changedContent.newId:t.changedContent.id},delete oe.newId),oe});const Q=(Se=t.itemData)==null?void 0:Se.map(oe=>((oe==null?void 0:oe.key)==="tableContents"&&(oe.contents=Z),oe));c.value=Z,n("contentChange",{contents:Q,index:t.index}),n("change",{content:Z,index:t==null?void 0:t.index,buttonName:"",id:t==null?void 0:t.index})},{deep:!0,immediate:!0});const Y=(Z,Q)=>{var de;if(u.value="",S.value=!0,d.value=!0,n("onButtonClick",Z,Q),Z==="删除"){c.value=(de=Ae.cloneDeep(c.value))==null?void 0:de.filter(oe=>(oe==null?void 0:oe.id)!==(Q==null?void 0:Q.id));const Se=M_(x.value,B.value,Q==null?void 0:Q.id);We(Se),n("change",{content:c.value,singleContent:Q,index:t==null?void 0:t.index,type:"delete",buttonName:Z,column:r.value})}else Z==="新增"?(v.value="新增",Pe(""),m.value=!0):Z==="编辑"?(v.value="编辑",Pe(Q),m.value=!0):Z==="查看"?(v.value="查看",Pe(Q),S.value=!1,d.value=!1,m.value=!0):Z==="查看三维模型"&&(h.value=!0)},le=()=>{h.value=!1},Pe=Z=>{var Se,oe,A;const Q=[];let de=[];for(let ae in Z)Array.isArray(Z==null?void 0:Z[ae])&&de.push(ae);(oe=Wt.getColumnChild((Se=Ae.cloneDeep(r.value))==null?void 0:Se.filter(ae=>(ae==null?void 0:ae.label)!=="操作")))==null||oe.forEach((ae,Re)=>{de.find(Ye=>Ye===(ae==null?void 0:ae.prop))||Q.push({label:(ae==null?void 0:ae.label)??"",name:(ae==null?void 0:ae.prop)??"t"+Re,type:!(ae!=null&&ae.formType)||(ae==null?void 0:ae.formType)===""?"Input":ae==null?void 0:ae.formType,value:(Z==null?void 0:Z[ae==null?void 0:ae.prop])??"",id:(ae==null?void 0:ae.id)??Re,contents:(ae==null?void 0:ae.options)??[],width:1,isFormColHidden:ae==null?void 0:ae.isFormColHidden})}),Z===""||!Z||(u.value=Z==null?void 0:Z.id),w.value=b.value&&((A=b.value)==null?void 0:A.length)>0?b.value:Q};$.onMounted(()=>{});const ve=()=>{let Z,Q=Ae.cloneDeep(c.value);u.value===""?(p.value++,Q.push(Object.assign(P.value,{id:p.value})),Z=Object.assign(P.value,{id:p.value})):Q=Q==null?void 0:Q.map(Se=>((Se==null?void 0:Se.id)===u.value&&(Se=Object.assign(Se,P.value),Z=Se),Se)),c.value=Q;const de=y_(x.value,B.value,Q);We(de),m.value=!1,n("change",{content:de,singleContent:Z,index:t==null?void 0:t.index,buttonName:v.value,column:r.value})},Ue=Z=>{P.value=Z};return $.watch(()=>[t.itemData,J.value,H.value,B.value,l==null?void 0:l.value],()=>{var Ye,ie,Fe,Ee,Ve,lt,T,g,F,q,K,V,De,he,be,Le,ee,Me,Oe,Ne,ce,ke,D,pe,te,ye;const Z=(Ye=Ae.cloneDeep(t.itemData))==null?void 0:Ye.filter(O=>(O==null?void 0:O.key)==="header");(ie=Ae.cloneDeep(t.itemData))==null||ie.filter(O=>(O==null?void 0:O.key)==="tableIndexColumn")[0];const Q=(Fe=Ae.cloneDeep(t.itemData))==null?void 0:Fe.find(O=>(O==null?void 0:O.key)==="page"),de=(Ee=Ae.cloneDeep(t.itemData))==null?void 0:Ee.find(O=>(O==null?void 0:O.key)==="rowButton"),Se=(Ve=Ae.cloneDeep(t.itemData))==null?void 0:Ve.find(O=>(O==null?void 0:O.key)==="extraButton"),oe=(lt=Ae.cloneDeep(t.itemData))==null?void 0:lt.filter(O=>(O==null?void 0:O.key)==="tableContents"),A=(T=Ae.cloneDeep(t.itemData))==null?void 0:T.filter(O=>(O==null?void 0:O.key)==="tableIndex");b.value=(q=(F=(g=Ae.cloneDeep(t.itemData))==null?void 0:g.filter(O=>(O==null?void 0:O.key)==="tableToForm"))==null?void 0:F[0])==null?void 0:q.contents,_.value=(Q==null?void 0:Q.contents)??!1;let ae=[];J.value===""?ae=Z==null?void 0:Z[0]:ae=(Z==null?void 0:Z.find(O=>(O==null?void 0:O.selectLabel)==="("+J.value+")"))??(Z==null?void 0:Z.find(O=>!(O!=null&&O.selectLabel)));let Re=[];if(J.value===""?Re=A==null?void 0:A[0]:Re=(A==null?void 0:A.find(O=>(O==null?void 0:O.selectLabel)==="("+J.value+")"))??(A==null?void 0:A.find(O=>!(O!=null&&O.selectLabel))),((K=ae==null?void 0:ae.contents)==null?void 0:K.length)>0){let O=[];if(ae!=null&&ae.contents.some(Ce=>Array.isArray(Ce)&&(Ce==null?void 0:Ce.find(_e=>_e.children))))B.value===""?O=(De=(V=Wt.getGradeColumns(Ae.cloneDeep(ae==null?void 0:ae.contents)))==null?void 0:V[0])==null?void 0:De.filter(Ce=>!Array.isArray(Ce)):(B.value.split("-"),O=(he=Wt.getGradeColumns(Ae.cloneDeep(ae==null?void 0:ae.contents)))==null?void 0:he[0]);else{const Ce=ae!=null&&ae.contents.some(_e=>Array.isArray(_e))?(be=ae==null?void 0:ae.contents)==null?void 0:be[0]:ae==null?void 0:ae.contents;Ce==null||Ce.forEach((_e,xt)=>{O.push({label:(_e==null?void 0:_e.label)??"",prop:(_e==null?void 0:_e.label)==="操作"?"operate":(_e==null?void 0:_e.prop)??"a"+xt,width:(_e==null?void 0:_e.label)==="操作"?"200":_e!=null&&_e.width?parseInt(_e.width):"",fixed:(_e==null?void 0:_e.fixed)??void 0,sortable:(_e==null?void 0:_e.sortable)??!1,align:(_e==null?void 0:_e.align)??"center",showOverflowTooltip:(_e==null?void 0:_e.showOverflowTooltip)??!0,isNotDrag:(_e==null?void 0:_e.isNotDrag)??!1,isEditCol:(_e==null?void 0:_e.isEditCol)??!1,isOperate:(_e==null?void 0:_e.isOperate)??!1,id:(_e==null?void 0:_e.id)??xt,type:(_e==null?void 0:_e.label)==="操作"?"operate":void 0,formType:(_e==null?void 0:_e.formType)??"",isTableColHidden:_e==null?void 0:_e.isTableColHidden,isFormColHidden:_e==null?void 0:_e.isFormColHidden,options:(_e==null?void 0:_e.options)??[]})})}r.value=O;let X=(ee=(Le=Wt.getAllLeafNodes(Ae.cloneDeep(r.value)))==null?void 0:Le.filter(Ce=>(Ce==null?void 0:Ce.type)!=="operate"))==null?void 0:ee.map((Ce,_e)=>({prop:(Ce==null?void 0:Ce.prop)??"a"+_e,column:Ce.label}));C.value=X;let ue=[];J.value===""?ue=oe==null?void 0:oe[0]:ue=(oe==null?void 0:oe.find(Ce=>(Ce==null?void 0:Ce.selectLabel)==="("+J.value+")"))??(oe==null?void 0:oe.find(Ce=>!(Ce!=null&&Ce.selectLabel)));let Be=Array.isArray((Me=ue==null?void 0:ue.contents)==null?void 0:Me[0])&&((Oe=ue==null?void 0:ue.contents)!=null&&Oe[0].every(Ce=>Array.isArray(Ce)))?(Ne=Ae.cloneDeep(ue==null?void 0:ue.contents))==null?void 0:Ne[0]:Ae.cloneDeep(ue==null?void 0:ue.contents);Re!=null&&Re.contents&&((ce=Re==null?void 0:Re.contents)==null?void 0:ce.length)!==0&&(Be=(ke=Ae.cloneDeep(Be))==null?void 0:ke.map((Ce,_e)=>{if(!Array.isArray(Ce)){let xt={};for(let tn in Ce)tn!=="id"&&tn!=="index"&&(xt[tn]=Ce[tn]);Ce=Object.values(xt)}return Ce}));const ot=!!((D=r.value)!=null&&D.find(Ce=>Ce.prop==="index"));Be=zl(Ae.cloneDeep(Be),Re==null?void 0:Re.contents,ot);const et=[];Be==null||Be.forEach((Ce,_e)=>{var tn;let xt={};if(Array.isArray(Ce)){let ut=[];Ce==null||Ce.filter(At=>!(At!=null&&At.id)).forEach((At,zt)=>{var Ci,In,Pi,Nn,Di,Li;if((Ci=X==null?void 0:X[zt])!=null&&Ci.prop&&!Array.isArray(At)){let Ui={};Ui[X[zt].column]=At,l!=null&&l.value&&((In=l==null?void 0:l.value)==null?void 0:In.length)>0&&((Pi=l==null?void 0:l.value)!=null&&Pi.find(Nt=>JSON.stringify(Nt==null?void 0:Nt[0])===JSON.stringify(Ui)))&&(ut=(Nn=l==null?void 0:l.value)==null?void 0:Nn.find(Nt=>JSON.stringify(Nt==null?void 0:Nt[0])===JSON.stringify(Ui))),ut&&ut.length>0?xt[X[zt].prop]=ut!=null&&ut.find(Nt=>{var Fn;return((Fn=Object.keys(Nt))==null?void 0:Fn[0])===X[zt].column})?(Di=ut==null?void 0:ut.find(Nt=>{var Fn;return((Fn=Object.keys(Nt))==null?void 0:Fn[0])===X[zt].column}))==null?void 0:Di[X[zt].column]:At:xt[X[zt].prop]=At}else Array.isArray(At)&&((Li=X[zt])!=null&&Li.prop?xt[X[zt].prop]=At:xt.children=Bl(At,X))})}else xt=Ce;Array.isArray(Ce)&&Ce.some(ut=>ut==null?void 0:ut.id)?et.push(Object.assign(xt,{id:(tn=Ce==null?void 0:Ce.find(ut=>ut.id))==null?void 0:tn.id})):xt.id?et.push(xt):et.push(Object.assign(xt,{id:_e}))}),c.value=et}else r.value=[],c.value=[];((pe=de==null?void 0:de.contents)==null?void 0:pe.length)>0?E.value=de==null?void 0:de.contents:E.value=[],((te=Se==null?void 0:Se.contents)==null?void 0:te.length)>0?L.value=Se==null?void 0:Se.contents:L.value=[],p.value=((ye=c==null?void 0:c.value)==null?void 0:ye.length)??0,x.value=c.value},{deep:!0,immediate:!0}),(Z,Q)=>{var de;return $.openBlock(),$.createElementBlock("div",H_,[($.openBlock(),$.createBlock(Wt.ssTable,{columns:r.value,key:r.value,tableData:c.value,isShowPagination:_.value,isShowEdit:!1,isShowDelete:!1,onDbClickRow:se,extraButton:L.value,onButtonClick:Q[1]||(Q[1]=Se=>Y(Se,"")),onContentClick:Ze},$.createSlots({headerButton:$.withCtx(Se=>[$.createVNode(Dc,{buttons:Se.buttons,onButtonClick:Q[0]||(Q[0]=oe=>Y(oe,"")),columns:r.value,onFilter:xe},null,8,["buttons","columns"])]),_:2},[((de=E.value)==null?void 0:de.length)>0?{name:"actions",fn:$.withCtx(({item:Se})=>[($.openBlock(!0),$.createElementBlock($.Fragment,null,$.renderList(G(E.value,Se),(oe,A)=>($.openBlock(),$.createElementBlock("div",{key:A},[$.createElementVNode("div",{style:$.normalizeStyle({color:oe==null?void 0:oe.textColor}),class:"extra-button-label",onClick:ae=>Y(oe==null?void 0:oe.label,Se)},$.toDisplayString(oe==null?void 0:oe.label),13,V_)]))),128))]),key:"0"}:void 0]),1032,["columns","tableData","isShowPagination","extraButton"])),$.createVNode(Wt.ssDialog,{title:v.value,visible:m.value,width:W.value,onBeforeDestroy:ne},{default:$.withCtx(()=>[$.createElementVNode("div",G_,[$.createVNode(Wt.ssForm,{rowContents:w.value,isEnableWrap:!1,onChange:Ue,isEdit:d.value},null,8,["rowContents","isEdit"])])]),footer:$.withCtx(()=>[S.value?($.openBlock(),$.createElementBlock("div",W_,[$.createElementVNode("div",{onClick:Q[2]||(Q[2]=Se=>m.value=!1),class:"cancel-button"},$.toDisplayString("取消")),$.createElementVNode("div",{class:"ok-button",onClick:ve},$.toDisplayString("确认"))])):$.createCommentVNode("",!0)]),_:1},8,["title","visible","width"]),$.createVNode(Wt.ssDialog,{visible:h.value,fullScreen:"",onBeforeDestroy:le},{default:$.withCtx(()=>[$.createVNode(Nl,{isShow:h.value},null,8,["isShow"])]),_:1},8,["visible"])])}}},q_=Ma._export_sfc(X_,[["__scopeId","data-v-3458b8f1"]]);exports.IsJson=T_;exports.addTableContents=F_;exports.conStructContents=L_;exports.deleteTableContents=N_;exports.fixFormContents=B_;exports.fixTableContents=O_;exports.getItemData=Gl;exports.loadingSystemType=k_;exports.methodTableToContent=A_;exports.ssTable=q_;exports.tableEveryContents=xa;exports.tableToContents=va;exports.tableToStruct=mn;exports.threeModel=Nl;exports.useFormToTableComp=Fl;exports.useUnit=Ol;