function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = ["assets/howler-BzJY10nd.js","assets/_commonjsHelpers-Cpj98o6Y.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } import{h as fo,p as Zt,F as ki,c as Ci,t as ua,z as ne,J as pi,x as mo,y as go,k as ti,M as jh,N as B2,v as wr,O as cD,Q as wx,R as ps,S as vo,T as dD,C as _x,U as Sx,q as Mn}from"./index-DhgeYuDI.js";import{o as uD,B as Ao}from"./index-4BuJZDJK.js";import{C as Ja}from"./vue3-count-to.esm-BMZ192BS.js";import{_ as zy}from"./index-DZAk9A4j.js";import{e as Wf}from"./index-B9bA2oXO.js";/* empty css */import{_ as F2,a as U2,b as N2}from"./button-icon-ByvyKiiQ.js";import"./omit-CgmmeuJY.js";const k2="/assets/img3-BIZtH8ZX.png",V2="/assets/img4-CVioGhgl.png",j2="/assets/img5-WJyEcHFi.png",G2="/assets/img8-BEdljHQR.png",H2="/assets/img1-TewenZ-t.png",W2="/assets/img2-Chvan6Xs.png",q2="/assets/img6-BoR3fMmO.png",X2="/assets/img7-RAwr14hh.png",Cr=e=>(mo("data-v-daf4835a"),e=e(),go(),e),pD={class:"the-box1"},fD={class:"box1-item"},mD=Cr(()=>ne("img",{src:k2,alt:""},null,-1)),gD={class:"box1-item-info"},vD=Cr(()=>ne("div",null,"机构床位统计",-1)),yD={class:"box1-item-num"},xD={class:"box1-item"},bD=Cr(()=>ne("img",{src:V2,alt:""},null,-1)),wD={class:"box1-item-info"},_D=Cr(()=>ne("div",null,"开放床位数",-1)),SD={class:"box1-item-num"},AD={class:"box1-item"},MD=Cr(()=>ne("img",{src:j2,alt:""},null,-1)),ED={class:"box1-item-info"},CD=Cr(()=>ne("div",null,"在住床位数",-1)),TD={class:"box1-item-num"},PD={class:"box1-item"},DD=Cr(()=>ne("img",{src:G2,alt:""},null,-1)),ID={class:"box1-item-info"},OD=Cr(()=>ne("div",null,"退住数",-1)),RD={class:"box1-item-num"},LD={class:"box1-item"},zD=Cr(()=>ne("img",{src:H2,alt:""},null,-1)),BD={class:"box1-item-info"},FD=Cr(()=>ne("div",null,"社区店",-1)),UD={class:"box1-item-num"},ND={class:"box1-item"},kD=Cr(()=>ne("img",{src:W2,alt:""},null,-1)),VD={class:"box1-item-info"},jD=Cr(()=>ne("div",null,"年体验服务人次",-1)),GD={class:"box1-item-num"},HD={class:"box1-item"},WD=Cr(()=>ne("img",{src:q2,alt:""},null,-1)),qD={class:"box1-item-info"},XD=Cr(()=>ne("div",null,"年服务人次",-1)),YD={class:"box1-item-num"},QD={class:"box1-item"},ZD=Cr(()=>ne("img",{src:X2,alt:""},null,-1)),KD={class:"box1-item-info"},JD=Cr(()=>ne("div",null,"年配餐人次",-1)),$D={class:"box1-item-num"},e3={__name:"box1",props:{overviewStatisticsData:{type:Object,default:{planBedCount:0,presetCount:0}}},setup(e){return(t,i)=>{const r=zy;return Zt(),ki("div",pD,[Ci(r,{wrap:"wrap"},{default:ua(()=>[ne("div",fD,[mD,ne("div",gD,[vD,ne("div",yD,pi(e.overviewStatisticsData.planBedCount),1)])]),ne("div",xD,[bD,ne("div",wD,[_D,ne("div",SD,pi(e.overviewStatisticsData.openBedCount),1)])]),ne("div",AD,[MD,ne("div",ED,[CD,ne("div",TD,pi(e.overviewStatisticsData.checkInCount),1)])]),ne("div",PD,[DD,ne("div",ID,[OD,ne("div",RD,pi(e.overviewStatisticsData.retreatCount),1)])]),ne("div",LD,[zD,ne("div",BD,[FD,ne("div",UD,pi(e.overviewStatisticsData.communityCount),1)])]),ne("div",ND,[kD,ne("div",VD,[jD,ne("div",GD,pi(e.overviewStatisticsData.serviceCount),1)])]),ne("div",HD,[WD,ne("div",qD,[XD,ne("div",YD,pi(e.overviewStatisticsData.homeBasedServiceCount),1)])]),ne("div",QD,[ZD,ne("div",KD,[JD,ne("div",$D,pi(e.overviewStatisticsData.homeBasedCateringCount),1)])])]),_:1})])}}},t3=fo(e3,[["__scopeId","data-v-daf4835a"]]),Tr=e=>(mo("data-v-7144156d"),e=e(),go(),e),i3={class:"the-box1"},r3={class:"box1-item"},s3=Tr(()=>ne("img",{src:H2,alt:""},null,-1)),a3={class:"box1-item-info"},n3=Tr(()=>ne("div",null,"总床位",-1)),o3={class:"box1-item-num"},l3={class:"box1-item"},h3=Tr(()=>ne("img",{src:W2,alt:""},null,-1)),c3={class:"box1-item-info"},d3=Tr(()=>ne("div",null,"预定数",-1)),u3={class:"box1-item-num"},p3={class:"box1-item"},f3=Tr(()=>ne("img",{src:k2,alt:""},null,-1)),m3={class:"box1-item-info"},g3=Tr(()=>ne("div",null,"已入住",-1)),v3={class:"box1-item-num"},y3={class:"box1-item"},x3=Tr(()=>ne("img",{src:V2,alt:""},null,-1)),b3={class:"box1-item-info"},w3=Tr(()=>ne("div",null,"空床位",-1)),_3={class:"box1-item-num"},S3={class:"box1-item"},A3=Tr(()=>ne("img",{src:j2,alt:""},null,-1)),M3={class:"box1-item-info"},E3=Tr(()=>ne("div",null,"入住率",-1)),C3={class:"box1-item-num"},T3={class:"box1-item"},P3=Tr(()=>ne("img",{src:q2,alt:""},null,-1)),D3={class:"box1-item-info"},I3=Tr(()=>ne("div",null,"员工数",-1)),O3={class:"box1-item-num"},R3={class:"box1-item"},L3=Tr(()=>ne("img",{src:X2,alt:""},null,-1)),z3={class:"box1-item-info"},B3=Tr(()=>ne("div",null,"护工数",-1)),F3={class:"box1-item-num"},U3={class:"box1-item"},N3=Tr(()=>ne("img",{src:G2,alt:""},null,-1)),k3={class:"box1-item-info"},V3=Tr(()=>ne("div",null,"退住数",-1)),j3={class:"box1-item-num"},G3={__name:"box1_2",props:{overviewStatisticsData:{type:Object,default:{planBedCount:0,presetCount:0}}},setup(e){return(t,i)=>{const r=zy;return Zt(),ki("div",i3,[Ci(r,{wrap:"wrap"},{default:ua(()=>[ne("div",r3,[s3,ne("div",a3,[n3,ne("div",o3,pi(e.overviewStatisticsData.bedCount),1)])]),ne("div",l3,[h3,ne("div",c3,[d3,ne("div",u3,pi(e.overviewStatisticsData.presetCount),1)])]),ne("div",p3,[f3,ne("div",m3,[g3,ne("div",v3,pi(e.overviewStatisticsData.checkInCount),1)])]),ne("div",y3,[x3,ne("div",b3,[w3,ne("div",_3,pi(e.overviewStatisticsData.emptyBedCount),1)])]),ne("div",S3,[A3,ne("div",M3,[E3,ne("div",C3,pi(e.overviewStatisticsData.occupancyRate),1)])]),ne("div",T3,[P3,ne("div",D3,[I3,ne("div",O3,pi(e.overviewStatisticsData.userCount),1)])]),ne("div",R3,[L3,ne("div",z3,[B3,ne("div",F3,pi(e.overviewStatisticsData.caregiverCount),1)])]),ne("div",U3,[N3,ne("div",k3,[V3,ne("div",j3,pi(e.overviewStatisticsData.retreatCount),1)])])]),_:1})])}}},H3=fo(G3,[["__scopeId","data-v-7144156d"]]),W3=e=>(mo("data-v-83895e41"),e=e(),go(),e),q3={class:"the-box2"},X3=W3(()=>ne("div",{id:"indexBox2BarEcharts",class:"indexBox2BarEcharts"},null,-1)),Y3=[X3],Q3={__name:"box2",props:{box2_data:{type:Object,default:{}}},setup(e){const t=Wf,i=ti(null),r=e;jh(()=>{i.value=r.box2_data,s()});function s(){const a=t.init(document.getElementById("indexBox2BarEcharts"));a.setOption({grid:{right:10,bottom:30,top:20},xAxis:{type:"category",splitLine:{show:!1},axisLine:{show:!1},axisTick:{show:!1},data:i.value.xaxis.map(n=>n),axisLabel:{color:"#A3C2CC",fontSize:16}},yAxis:{type:"value",splitLine:{show:!1},axisLabel:{color:"#A3C2CC",fontSize:16}},tooltip:{show:!0,trigger:"item",azisPointer:{type:""},backgroundColor:"rgba(24, 31, 64, 0.9)",color:"#ffffff",padding:0,borderColor:"transparent"},series:[{data:i.value.series.map(n=>n),type:"bar",showBackground:!0,backgroundStyle:{color:"rgba(40,80,132,0.2)"},barWidth:15,color:"#10E2A1",itemStyle:{color:"#10E2A1",borderRadius:5},label:{normal:{show:!0,position:"top",color:"#ffffff"},formatter:"{@value}"}},{data:i.value.series.map(n=>n),type:"line",color:"#0088FF",smooth:.5,itemStyle:{color:"#0088FF"},lineStyle:{width:4}}]}),window.onresize=function(){a.resize()}}return(a,n)=>(Zt(),ki("div",q3,Y3))}},Z3=fo(Q3,[["__scopeId","data-v-83895e41"]]),K3=e=>(mo("data-v-9995df7e"),e=e(),go(),e),J3={class:"the-box3"},$3=K3(()=>ne("div",{id:"indexBox6PieEchart66s",class:"indexBox6PieEcharts"},null,-1)),eI=[$3],tI={__name:"box3",props:{box3_data:{type:Object,default:{}}},emits:["set_listdata"],setup(e,{emit:t}){const i=Wf;B2();const r=e,s=ti(null);jh(()=>{s.value=r.box3_data,a()});function a(){let n={tooltip:{trigger:"item",show:!1},legend:{show:!1},series:[{type:"pie",radius:["40%","60%"],avoidLabelOverlap:!0,padAngle:2,itemStyle:{borderRadius:0},label:{show:!0,position:"outside",formatter:function(l){return`${l.data.name}${l.data.typeRatio}%`},color:"#C3CED9",fontSize:15},labelLine:{show:!0,length:10,length2:50,minTurnAngle:150,smooth:.5,lineStyle:{width:1,cap:"round",type:"dashed",fontSize:16}},emphasis:{label:{show:!1}},data:s.value.map((l,h)=>{const c=["#32C5FF","#33CC72","#FA6400","#FFCC66","#3399FF"];return{typeRatio:l.typeRatio,value:l.typeCount,name:l.typeName,labelLine:{lineStyle:{color:c[h]}},itemStyle:{color:c[h]},fontSize:16}})}]},o=i.getInstanceByDom(document.getElementById("indexBox6PieEchart66s"));o?o.clear():o=i.init(document.getElementById("indexBox6PieEchart66s")),o.setOption(n),window.onresize=function(){o.resize()}}return(n,o)=>(Zt(),ki("div",J3,eI))}},iI=fo(tI,[["__scopeId","data-v-9995df7e"]]),By="/assets/img-DJ4lsvjZ.png",Fy="/assets/img-name-C7ByjlUk.png",rI="/assets/img-title-C4ykapfs.png",wn=e=>(mo("data-v-1e4f3938"),e=e(),go(),e),sI={class:"the-box6"},aI={class:"box6-title"},nI={class:"box6-title-item"},oI={class:"box6-title-item-num"},lI=wn(()=>ne("img",{src:By,alt:""},null,-1)),hI={class:"box6-title-item-text"},cI=wn(()=>ne("span",{class:"showspan"}," 人",-1)),dI=wn(()=>ne("div",{class:"box6-title-item-type"},[ne("img",{src:Fy,alt:""}),ne("div",{class:"box6-title-item-text"},"户籍")],-1)),uI={class:"box6-title-item"},pI={class:"box6-title-item-num"},fI=wn(()=>ne("img",{src:By,alt:""},null,-1)),mI={class:"box6-title-item-text"},gI=wn(()=>ne("span",{class:"showspan"}," 人",-1)),vI=wn(()=>ne("div",{class:"box6-title-item-type"},[ne("img",{src:Fy,alt:""}),ne("div",{class:"box6-title-item-text"},"非户籍")],-1)),yI={class:"box6-title-item"},xI={class:"box6-title-item-num"},bI=wn(()=>ne("img",{src:By,alt:""},null,-1)),wI={class:"box6-title-item-text"},_I=wn(()=>ne("span",{class:"showspan"}," 人",-1)),SI=wn(()=>ne("div",{class:"box6-title-item-type"},[ne("img",{src:Fy,alt:""}),ne("div",{class:"box6-title-item-text"},"未知")],-1)),AI=cD('
经济来源统计
',1),MI={__name:"box6",props:{box6_data:{type:Object,default:{}}},setup(e){const t=Wf,i=ti(!1),r=ti({}),s=ti([]),a=e;jh(()=>{if(r.value=a.box6_data.household,a.box6_data.economic){let o=a.box6_data.economic,l=[{name:"养老保险",value:o.endowmentInsurance,valueradio:o.endowmentInsuranceRatio},{name:"城市低保",value:o.cityLowIncome,valueradio:o.cityLowIncomeRatio},{name:"子女供养",value:o.childrenSupport,valueradio:o.childrenSupportRatio},{name:"家庭存款",value:o.familyDeposit,valueradio:o.familyDepositRatio},{name:"离退休金",value:o.retirementPay,valueradio:o.retirementPayRatio},{name:"五保",value:o.fiveGuarantees,valueradio:o.fiveGuaranteesRatio},{name:"抚恤金",value:o.pension,valueradio:o.pensionRatio},{name:"商业保险",value:o.commercialInsurance,valueradio:o.commercialInsuranceRatio},{name:"其它",value:o.other,valueradio:o.otherRatio}];s.value=l,i.value=!0,n()}});function n(){console.log(1111);let o={tooltip:{trigger:"item",show:!1},legend:{show:!1},series:[{type:"pie",radius:["40%","60%"],avoidLabelOverlap:!0,padAngle:2,itemStyle:{borderRadius:0},label:{show:!0,position:"outside",formatter:function(h){return`${h.data.name} (${h.data.Ratio}%)`},color:"#C3CED9",fontSize:16},labelLine:{show:!0,length:10,length2:70,minTurnAngle:150,smooth:.5,lineStyle:{width:1,cap:"round",type:"dashed"}},emphasis:{label:{show:!1}},data:s.value.map((h,c)=>{const d=["#32C5FF","#33CC72","#FA6400","#FFCC66","#3399FF","#32C5FF","#33CC72","#FA6400","#FFCC66"];return{value:h.value,name:h.name,Ratio:h.valueradio,labelLine:{lineStyle:{color:d[c]}},itemStyle:{color:d[c]}}})}]},l=t.getInstanceByDom(document.getElementById("indexBox6PieEchart68s"));l=t.init(document.getElementById("indexBox6PieEchart68s")),console.log(o),l.setOption(o),l.resize(),window.onresize=function(){l.resize()}}return(o,l)=>(Zt(),ki("div",sI,[ne("div",aI,[ne("div",nI,[ne("div",oI,[lI,ne("div",hI,[Ci(wr(Ja),{"start-val":0,"end-val":r.value.householdTotal,duration:2600,class:"card-panel-num"},null,8,["end-val"]),cI])]),dI]),ne("div",uI,[ne("div",pI,[fI,ne("div",mI,[Ci(wr(Ja),{"start-val":0,"end-val":r.value.nonHouseholdTotal,duration:2600,class:"card-panel-num"},null,8,["end-val"]),gI])]),vI]),ne("div",yI,[ne("div",xI,[bI,ne("div",wI,[Ci(wr(Ja),{"start-val":0,"end-val":r.value.unknownTotal,duration:2600,class:"card-panel-num"},null,8,["end-val"]),_I])]),SI])]),AI]))}},EI=fo(MI,[["__scopeId","data-v-1e4f3938"]]),CI=e=>(mo("data-v-cb622758"),e=e(),go(),e),TI={class:"the-box7"},PI=CI(()=>ne("div",{id:"indexBox7BarEcharts",class:"indexBox7BarEcharts"},null,-1)),DI=[PI],II={__name:"box7",props:{box7_data:{type:Object,default:{}}},setup(e){const t=Wf,i=ti(null),r=e;jh(()=>{i.value=r.box7_data,s()});function s(){const a=t.init(document.getElementById("indexBox7BarEcharts"));a.setOption({grid:{right:10,bottom:30,top:20},xAxis:{type:"category",splitLine:{show:!1},axisLine:{show:!1},axisTick:{show:!1},data:i.value.xaxis.map(n=>n),axisLabel:{color:"#A3C2CC",fontSize:16}},yAxis:{type:"value",splitLine:{show:!1},axisLabel:{color:"#A3C2CC",fontSize:16}},series:[{data:i.value.series.map(n=>n),type:"bar",showBackground:!0,backgroundStyle:{color:"rgba(40,80,132,0.2)"},barWidth:15,color:"#31B3FF",itemStyle:{color:"#31B3FF",borderRadius:5},label:{normal:{show:!0,position:"top",color:"#ffffff"},formatter:"{@value}"}}]}),window.onresize=function(){a.resize()}}return(a,n)=>(Zt(),ki("div",TI,DI))}},OI=fo(II,[["__scopeId","data-v-cb622758"]]),RI="/assets/img1-B14zFtzx.png",LI="/assets/img2-BClo_7M5.png",zI="/assets/img3-B_b_Fv0N.png",BI="/assets/img4-WEfXPLlm.png",FI="/assets/img5-Coz65H-P.png",UI="/assets/img6-vWKTdQVS.png",yo=e=>(mo("data-v-f0e0c78d"),e=e(),go(),e),NI={class:"the-box8"},kI={class:"change-num"},VI={key:0,class:"btn",src:F2,alt:""},jI={key:1,class:"icon",src:U2,alt:""},GI={key:2,class:"icon",src:N2,alt:""},HI=yo(()=>ne("div",{class:"text"},"本月",-1)),WI={key:0,class:"btn",src:F2,alt:""},qI={key:1,class:"icon",src:U2,alt:""},XI={key:2,class:"icon",src:N2,alt:""},YI=yo(()=>ne("div",{class:"text"},"今日",-1)),QI={class:"box8-item"},ZI=yo(()=>ne("img",{src:RI,alt:""},null,-1)),KI={class:"box8-item-info"},JI={class:"box8-item-num"},$I={class:"box8-item"},eO=yo(()=>ne("img",{src:LI,alt:""},null,-1)),tO={class:"box8-item-info"},iO={class:"box8-item-num"},rO={class:"box8-item"},sO=yo(()=>ne("img",{src:zI,alt:""},null,-1)),aO={class:"box8-item-info"},nO={class:"box8-item-num"},oO={class:"box8-item"},lO=yo(()=>ne("img",{src:BI,alt:""},null,-1)),hO={class:"box8-item-info"},cO={class:"box8-item-num"},dO={class:"box8-item"},uO=yo(()=>ne("img",{src:FI,alt:""},null,-1)),pO={class:"box8-item-info"},fO={class:"box8-item-num"},mO={class:"box8-item"},gO=yo(()=>ne("img",{src:UI,alt:""},null,-1)),vO={class:"box8-item-info"},yO={class:"box8-item-num"},xO={__name:"box8",props:{businessStatisticsDats:{type:Object,default:{}}},setup(e){const t=ti("month"),i=r=>{t.value=r,t.value};return(r,s)=>{const a=zy;return Zt(),ki("div",NI,[ne("div",kI,[ne("div",{class:wx(["change-num-item",{isActive:t.value==="month"}]),onClick:s[0]||(s[0]=n=>i("month"))},[t.value==="month"?(Zt(),ki("img",VI)):ps("",!0),t.value==="month"?(Zt(),ki("img",jI)):(Zt(),ki("img",GI)),HI],2),ne("div",{class:wx(["change-num-item",{isActive:t.value==="day"}]),onClick:s[1]||(s[1]=n=>i("day"))},[t.value==="day"?(Zt(),ki("img",WI)):ps("",!0),t.value==="day"?(Zt(),ki("img",qI)):(Zt(),ki("img",XI)),YI],2)]),Ci(a,{wrap:"wrap"},{default:ua(()=>[ne("div",QI,[ZI,ne("div",KI,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"咨询",1),ne("div",JI,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.consultationCheckInCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",$I,[eO,ne("div",tO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"预订",1),ne("div",iO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.presetCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",rO,[sO,ne("div",aO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"试住",1),ne("div",nO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.tryStayCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",oO,[lO,ne("div",hO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"外出",1),ne("div",cO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.goOutCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",dO,[uO,ne("div",pO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"入住",1),ne("div",fO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.checkInCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",mO,[gO,ne("div",vO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"探视",1),ne("div",yO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.visitCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])])]),_:1})])}}},bO=fo(xO,[["__scopeId","data-v-f0e0c78d"]]);var wO=Object.create,qf=Object.defineProperty,_O=Object.getOwnPropertyDescriptor,SO=Object.getOwnPropertyNames,AO=Object.getPrototypeOf,MO=Object.prototype.hasOwnProperty,EO=(e,t,i)=>t in e?qf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,fl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),CO=(e,t)=>{for(var i in t)qf(e,i,{get:t[i],enumerable:!0})},TO=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of SO(t))!MO.call(e,s)&&s!==i&&qf(e,s,{get:()=>t[s],enumerable:!(r=_O(t,s))||r.enumerable});return e},xo=(e,t,i)=>(i=e!=null?wO(AO(e)):{},TO(t||!e||!e.__esModule?qf(i,"default",{value:e,enumerable:!0}):i,e)),Bc=(e,t,i)=>(EO(e,typeof t!="symbol"?t+"":t,i),i),PO=fl((e,t)=>{(function(i,r){typeof e=="object"?t.exports=r():typeof define=="function"&&define.amd?define(r):i.Alea=r()})(e,function(){return i.importState=function(s){var a=new i;return a.importState(s),a},i;function i(){return function(s){var a=0,n=0,o=0,l=1;s.length==0&&(s=[+new Date]);var h=r();a=h(" "),n=h(" "),o=h(" ");for(var c=0;c>>0,l-=s,l*=s,s=l>>>0,l-=s,s+=l*4294967296}return(s>>>0)*23283064365386963e-26};return a.version="Mash 0.9",a}})}),Y2=fl((e,t)=>{(function(i,r){typeof e=="object"&&typeof t<"u"?r(e):typeof define=="function"&&define.amd?define(["exports"],r):r((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(e,function(i){i.SVD=function(r,s,a,n,o){if(s=s===void 0||s,a=a===void 0||a,o=1e-64/(n=n||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var l,h,c,d,u,p,f,g,m,v,y,x,w=r[0].length,_=r.length;if(_{Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;function i(r){if(r===null||r===!0||r===!1)return NaN;var s=Number(r);return isNaN(s)?s:s<0?Math.ceil(s):Math.floor(s)}t.exports=e.default}),IO=fl((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;function i(r){var s=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()));return s.setUTCFullYear(r.getFullYear()),r.getTime()-s.getTime()}t.exports=e.default}),OO=fl((e,t)=>{function i(a,n){function o(){this.constructor=a}o.prototype=n.prototype,a.prototype=new o}function r(a,n,o,l){this.message=a,this.expected=n,this.found=o,this.location=l,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r)}i(r,Error),r.buildMessage=function(a,n){var o={literal:function(f){return'"'+h(f.text)+'"'},class:function(f){var g="",m;for(m=0;m0){for(m=1,v=1;mke&&(ke=R,Oe=[]),Oe.push(I))}function qt(I,L,Y){return new r(r.buildMessage(I,L),I,L,Y)}function oi(){var I,L,Y,B,J;for(I=R,L=[],Y=St();Y!==o;)L.push(Y),Y=St();if(L!==o)if(Y=K(),Y===o&&(Y=null),Y!==o){for(B=[],J=St();J!==o;)B.push(J),J=St();B!==o?(L=c(Y),I=L):(R=I,I=o)}else R=I,I=o;else R=I,I=o;return I}function K(){var I,L,Y,B,J,Ae;if(I=R,L=ge(),L!==o){for(Y=[],B=R,J=[],Ae=St();Ae!==o;)J.push(Ae),Ae=St();for(J!==o?(Ae=ge(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;){for(Y.push(B),B=R,J=[],Ae=St();Ae!==o;)J.push(Ae),Ae=St();J!==o?(Ae=ge(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o)}Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function ge(){var I,L,Y,B,J,Ae;if(I=R,L=Be(),L!==o){for(Y=[],B=R,J=[],Ae=St();Ae!==o;)J.push(Ae),Ae=St();for(J!==o?(Ae=_e(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;){for(Y.push(B),B=R,J=[],Ae=St();Ae!==o;)J.push(Ae),Ae=St();J!==o?(Ae=_e(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o)}Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function _e(){var I;return I=nt(),I===o&&(I=Et(),I===o&&(I=Yi(),I===o&&(I=$t(),I===o&&(I=Es(),I===o&&(I=xm(),I===o&&(I=N(),I===o&&(I=se(),I===o&&(I=He())))))))),I}function Be(){var I,L,Y,B,J,Ae,za;if(I=R,u.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(p)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=Je(),B!==o?(J=R,Ae=vt(),Ae===o&&(Ae=null),Ae!==o?(za=vi(),za!==o?(Ae=[Ae,za],J=Ae):(R=J,J=o)):(R=J,J=o),J===o&&(J=null),J!==o?(L=f(L,B,J),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function nt(){var I,L;return I=R,g.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(m)),L!==o&&(L=v()),I=L,I}function Et(){var I,L,Y,B;if(I=R,y.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(x)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=vi(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function vi(){var I,L,Y,B,J,Ae;if(I=R,L=Je(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function Yi(){var I,L,Y,B;if(I=R,_.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(b)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=Ks(),B!==o?(L=A(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function Ks(){var I,L,Y,B,J,Ae;if(I=R,L=bt(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=bt(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=bt(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function $t(){var I,L,Y,B;if(I=R,S.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(E)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=Ks(),B!==o?(L=C(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function Es(){var I,L,Y,B;if(I=R,T.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(D)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=Gr(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function Gr(){var I,L,Y,B,J,Ae;if(I=R,L=wl(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=wl(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=wl(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function wl(){var I,L,Y,B,J,Ae;return I=R,L=Je(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=Je(),B!==o?(J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(L=O(L,B,Ae),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function xm(){var I,L,Y,B;if(I=R,P.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(U)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=bm(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function bm(){var I,L,Y,B,J,Ae;if(I=R,L=nc(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=nc(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=nc(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function nc(){var I,L,Y,B;return I=R,L=Je(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=Je(),B!==o?(L=W(L,B),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function N(){var I,L,Y,B;if(I=R,k.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(F)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=le(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function le(){var I,L,Y,B,J,Ae;if(I=R,L=me(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=me(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=me(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function me(){var I,L,Y,B;return I=R,L=Je(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=Je(),B!==o?(L=Z(L,B),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function se(){var I,L,Y,B;if(I=R,X.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(G)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=ve(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function ve(){var I,L,Y,B,J,Ae;if(I=R,L=Je(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function He(){var I,L,Y,B;if(I=R,q.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke($)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=dt(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function dt(){var I,L,Y,B,J,Ae;if(I=R,L=pt(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=pt(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=pt(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function pt(){var I,L,Y,B,J,Ae,za,wm,Qd,_m,Zd,Sm;return I=R,L=zt(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=zt(),B!==o?(J=vt(),J===o&&(J=null),J!==o?(Ae=bt(),Ae!==o?(za=vt(),za!==o?(wm=wt(),wm!==o?(Qd=vt(),Qd===o&&(Qd=null),Qd!==o?(_m=wt(),_m!==o?(Zd=vt(),Zd===o&&(Zd=null),Zd!==o?(Sm=Je(),Sm!==o?(L=Q(L,B,Ae,wm,_m,Sm),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function Je(){var I,L,Y,B;return I=R,L=bt(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=bt(),B!==o?(L=ee(L,B),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function zt(){var I,L;return I=R,L=ns(),L===o&&(L=Cs()),L!==o&&(L=H(L)),I=L,I}function bt(){var I,L,Y,B;return I=R,L=R,Y=At(),Y===o&&(Y=null),Y!==o?(B=ns(),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o),L===o&&(L=R,Y=At(),Y===o&&(Y=null),Y!==o?(B=Cs(),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o)),L!==o&&(L=he(L)),I=L,I}function wt(){var I,L;return I=R,re.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(te)),L!==o&&(L=ae(L)),I=L,I}function vt(){var I,L,Y,B,J;if(I=R,L=[],Y=St(),Y!==o)for(;Y!==o;)L.push(Y),Y=St();else L=o;if(L!==o)if(Y=zi(),Y===o&&(Y=null),Y!==o){for(B=[],J=St();J!==o;)B.push(J),J=St();B!==o?(L=[L,Y,B],I=L):(R=I,I=o)}else R=I,I=o;else R=I,I=o;if(I===o){if(I=R,L=R,Y=zi(),Y!==o){for(B=[],J=St();J!==o;)B.push(J),J=St();B!==o?(Y=[Y,B],L=Y):(R=L,L=o)}else R=L,L=o;L!==o&&(L=de()),I=L}return I}function zi(){var I;return a.charCodeAt(R)===44?(I=pe,R++):(I=o,Ke(be)),I}function ns(){var I,L,Y,B;return I=R,L=R,Y=Ra(),Y!==o?(B=li(),B===o&&(B=null),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o),L===o&&(L=R,Y=Cs(),Y!==o?(B=li(),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o)),L!==o&&(L=Le(L)),I=L,I}function Ra(){var I,L,Y,B,J;return I=R,L=R,Y=Cs(),Y===o&&(Y=null),Y!==o?(a.charCodeAt(R)===46?(B=Me,R++):(B=o,Ke(Ve)),B!==o?(J=Cs(),J!==o?(Y=[Y,B,J],L=Y):(R=L,L=o)):(R=L,L=o)):(R=L,L=o),L===o&&(L=R,Y=Cs(),Y!==o?(a.charCodeAt(R)===46?(B=Me,R++):(B=o,Ke(Ve)),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o)),L!==o&&(L=Le(L)),I=L,I}function li(){var I,L,Y,B,J;return I=R,L=R,Ue.test(a.charAt(R))?(Y=a.charAt(R),R++):(Y=o,Ke(Ce)),Y!==o?(B=At(),B===o&&(B=null),B!==o?(J=Cs(),J!==o?(Y=[Y,B,J],L=Y):(R=L,L=o)):(R=L,L=o)):(R=L,L=o),L!==o&&(L=Le(L)),I=L,I}function At(){var I;return Ee.test(a.charAt(R))?(I=a.charAt(R),R++):(I=o,Ke(Ye)),I}function Cs(){var I,L,Y;if(I=R,L=[],qe.test(a.charAt(R))?(Y=a.charAt(R),R++):(Y=o,Ke(V)),Y!==o)for(;Y!==o;)L.push(Y),qe.test(a.charAt(R))?(Y=a.charAt(R),R++):(Y=o,Ke(V));else L=o;return L!==o&&(L=z(L)),I=L,I}function St(){var I,L;return I=R,oe.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(Se)),L!==o&&(L=de()),I=L,I}function La(I,L){if(!L)return[I];for(var Y=[I],B=0,J=L.length;B{var i=OO().parse;i.parseSVG=i,i.makeAbsolute=r,t.exports=i;function r(s){var a,n={x:0,y:0},o={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return s.forEach(function(l){l.command==="moveto"&&(a=l),l.x0=n.x,l.y0=n.y;for(var h in o)h in l&&(l[h]+=l.relative?l[o[h]]:0);"x"in l||(l.x=n.x),"y"in l||(l.y=n.y),l.relative=!1,l.code=l.code.toUpperCase(),l.command=="closepath"&&(l.x=a.x,l.y=a.y),n=l}),s}}),RO=fl((e,t)=>{t.exports=function(i,r){for(var s=i.split("."),a=r.split("."),n=0;n<3;n++){var o=Number(s[n]),l=Number(a[n]);if(o>l)return 1;if(l>o)return-1;if(!isNaN(o)&&isNaN(l))return 1;if(isNaN(o)&&!isNaN(l))return-1}return 0}}),Gh="149",os={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},LO=0,Ax=1,zO=2,Uy=1,BO=2,Fc=3,Ws=0,rr=1,Ar=2,Oi=0,Jo=1,Mx=2,Ex=3,Cx=4,FO=5,eh=100,UO=101,NO=102,Tx=103,Px=104,kO=200,VO=201,jO=202,GO=203,Z2=204,K2=205,HO=206,WO=207,qO=208,XO=209,YO=210,QO=0,ZO=1,KO=2,Pv=3,JO=4,$O=5,eR=6,tR=7,J2=0,iR=1,rR=2,_a=0,sR=1,aR=2,nR=3,oR=4,lR=5,$2=300,al=301,nl=302,Dv=303,Iv=304,Rd=306,nn=1e3,ai=1001,Ov=1002,_t=1003,Dx=1004,Am=1005,xt=1006,hR=1007,Ch=1008,Er=1009,cR=1010,dR=1011,eM=1012,uR=1013,on=1014,jt=1015,mn=1016,pR=1017,fR=1018,$o=1020,mR=1021,ni=1023,gR=1024,vR=1025,el=1026,ol=1027,wp=1028,yR=1029,Up=1030,xR=1031,tM=1033,Mm=33776,Em=33777,Cm=33778,Tm=33779,Ix=35840,Ox=35841,Rx=35842,Lx=35843,bR=36196,zx=37492,Bx=37496,Fx=37808,Ux=37809,Nx=37810,kx=37811,Vx=37812,jx=37813,Gx=37814,Hx=37815,Wx=37816,qx=37817,Xx=37818,Yx=37819,Qx=37820,Zx=37821,Pm=36492,wR=36283,Kx=36284,Jx=36285,$x=36286,iM=2200,rM=2201,Ny=2202,Np=2300,kp=2301,Dm=2302,lh=2400,hh=2401,Vp=2402,ky=2500,_R=2501,qs=3e3,gt=3001,_n=3200,sM=3201,SR=0,AR=1,pa="srgb",jp="srgb-linear",Im=7680,MR=519,Rv=35044,ER=35048,Lv="300 es",zv=1035,yr=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let i=t.slice(0);for(let r=0,s=i.length;r>8&255]+xr[e>>16&255]+xr[e>>24&255]+"-"+xr[t&255]+xr[t>>8&255]+"-"+xr[t>>16&15|64]+xr[t>>24&255]+"-"+xr[i&63|128]+xr[i>>8&255]+"-"+xr[i>>16&255]+xr[i>>24&255]+xr[r&255]+xr[r>>8&255]+xr[r>>16&255]+xr[r>>24&255]).toLowerCase()}function Ti(e,t,i){return Math.max(t,Math.min(i,e))}function Vy(e,t){return(e%t+t)%t}function CR(e,t,i,r,s){return r+(e-t)*(s-r)/(i-t)}function TR(e,t,i){return e!==t?(i-e)/(t-e):0}function Yc(e,t,i){return(1-i)*e+i*t}function PR(e,t,i,r){return Yc(e,t,1-Math.exp(-i*r))}function DR(e,t=1){return t-Math.abs(Vy(e,t*2)-t)}function IR(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))}function OR(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(e*6-15)+10))}function RR(e,t){return e+Math.floor(Math.random()*(t-e+1))}function LR(e,t){return e+Math.random()*(t-e)}function zR(e){return e*(.5-Math.random())}function BR(e){e!==void 0&&(eb=e);let t=eb+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function FR(e){return e*Xc}function UR(e){return e*cd}function Bv(e){return(e&e-1)===0&&e!==0}function aM(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Gp(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function NR(e,t,i,r,s){let a=Math.cos,n=Math.sin,o=a(i/2),l=n(i/2),h=a((t+r)/2),c=n((t+r)/2),d=a((t-r)/2),u=n((t-r)/2),p=a((r-t)/2),f=n((r-t)/2);switch(s){case"XYX":e.set(o*c,l*d,l*u,o*h);break;case"YZY":e.set(l*u,o*c,l*d,o*h);break;case"ZXZ":e.set(l*d,l*u,o*c,o*h);break;case"XZX":e.set(o*c,l*f,l*p,o*h);break;case"YXY":e.set(l*p,o*c,l*f,o*h);break;case"ZYZ":e.set(l*f,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ln(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Kt(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw new Error("Invalid component type.")}}var Re=Object.freeze({__proto__:null,DEG2RAD:Xc,RAD2DEG:cd,ceilPowerOfTwo:aM,clamp:Ti,damp:PR,degToRad:FR,denormalize:ln,euclideanModulo:Vy,floorPowerOfTwo:Gp,generateUUID:ws,inverseLerp:TR,isPowerOfTwo:Bv,lerp:Yc,mapLinear:CR,normalize:Kt,pingpong:DR,radToDeg:UR,randFloat:LR,randFloatSpread:zR,randInt:RR,seededRandom:BR,setQuaternionFromProperEuler:NR,smootherstep:OR,smoothstep:IR}),j=class{constructor(e=0,t=0){j.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){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Di=class{constructor(){Di.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,i,r,s,a,n,o,l){let h=this.elements;return h[0]=e,h[1]=r,h[2]=n,h[3]=t,h[4]=s,h[5]=o,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let 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){let i=e.elements,r=t.elements,s=this.elements,a=i[0],n=i[3],o=i[6],l=i[1],h=i[4],c=i[7],d=i[2],u=i[5],p=i[8],f=r[0],g=r[3],m=r[6],v=r[1],y=r[4],x=r[7],w=r[2],_=r[5],b=r[8];return s[0]=a*f+n*v+o*w,s[3]=a*g+n*y+o*_,s[6]=a*m+n*x+o*b,s[1]=l*f+h*v+c*w,s[4]=l*g+h*y+c*_,s[7]=l*m+h*x+c*b,s[2]=d*f+u*v+p*w,s[5]=d*g+u*y+p*_,s[8]=d*m+u*x+p*b,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8];return t*a*h-t*n*l-i*s*h+i*n*o+r*s*l-r*a*o}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8],c=h*a-n*l,d=n*o-h*s,u=l*s-a*o,p=t*c+i*d+r*u;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(r*l-h*i)*f,e[2]=(n*i-r*a)*f,e[3]=d*f,e[4]=(h*t-r*o)*f,e[5]=(r*s-n*t)*f,e[6]=u*f,e[7]=(i*o-l*t)*f,e[8]=(a*t-i*s)*f,this}transpose(){let e,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){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,n){let o=Math.cos(s),l=Math.sin(s);return this.set(i*o,i*l,-i*(o*a+l*n)+a+e,-r*l,r*o,-r*(-l*a+o*n)+n+t,0,0,1),this}scale(e,t){return this.premultiply(Om.makeScale(e,t)),this}rotate(e){return this.premultiply(Om.makeRotation(-e)),this}translate(e,t){return this.premultiply(Om.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Om=new Di;function nM(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var kR={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Kd(e,t){return new kR[e](t)}function dd(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function VR(e,t,i){return new Promise(function(r,s){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:s();break;case e.TIMEOUT_EXPIRED:setTimeout(a,i);break;default:r()}}setTimeout(a,i)})}function tl(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function _p(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}var Rm={[pa]:{[jp]:tl},[jp]:{[pa]:_p}},Dr={legacyMode:!0,get workingColorSpace(){return jp},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,i){if(this.legacyMode||t===i||!t||!i)return e;if(Rm[t]&&Rm[t][i]!==void 0){let r=Rm[t][i];return e.r=r(e.r),e.g=r(e.g),e.b=r(e.b),e}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},oM={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},Bi={r:0,g:0,b:0},Ts={h:0,s:0,l:0},Jd={h:0,s:0,l:0};function Lm(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*6*(2/3-i):e}function $d(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}var et=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&i===void 0?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Dr.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=Dr.workingColorSpace){return this.r=e,this.g=t,this.b=i,Dr.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=Dr.workingColorSpace){if(e=Vy(e,1),t=Ti(t,0,1),i=Ti(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Lm(a,s,e+1/3),this.g=Lm(a,s,e),this.b=Lm(a,s,e-1/3)}return Dr.toWorkingColorSpace(this,r),this}setStyle(e,t=pa){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s,a=r[1],n=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,Dr.toWorkingColorSpace(this,t),i(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,Dr.toWorkingColorSpace(this,t),i(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n)){let o=parseFloat(s[1])/360,l=parseFloat(s[2])/100,h=parseFloat(s[3])/100;return i(s[4]),this.setHSL(o,l,h,t)}break}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],a=s.length;if(a===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,Dr.toWorkingColorSpace(this,t),this;if(a===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,Dr.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=pa){let i=oM[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=tl(e.r),this.g=tl(e.g),this.b=tl(e.b),this}copyLinearToSRGB(e){return this.r=_p(e.r),this.g=_p(e.g),this.b=_p(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pa){return Dr.fromWorkingColorSpace($d(this,Bi),e),Ti(Bi.r*255,0,255)<<16^Ti(Bi.g*255,0,255)<<8^Ti(Bi.b*255,0,255)<<0}getHexString(e=pa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Dr.workingColorSpace){Dr.fromWorkingColorSpace($d(this,Bi),t);let i=Bi.r,r=Bi.g,s=Bi.b,a=Math.max(i,r,s),n=Math.min(i,r,s),o,l,h=(n+a)/2;if(n===a)o=0,l=0;else{let c=a-n;switch(l=h<=.5?c/(a+n):c/(2-a-n),a){case i:o=(r-s)/c+(r"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{_l===void 0&&(_l=dd("canvas")),_l.width=e.width,_l.height=e.height;let i=_l.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=_l}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=dd("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==$2)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nn:e.x=e.x-Math.floor(e.x);break;case ai:e.x=e.x<0?0:1;break;case Ov: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 nn:e.y=e.y-Math.floor(e.y);break;case ai:e.y=e.y<0?0:1;break;case Ov: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)}};ci.DEFAULT_IMAGE=null;ci.DEFAULT_MAPPING=$2;ci.DEFAULT_ANISOTROPY=1;var ct=class{constructor(e=0,t=0,i=0,r=1){ct.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,a=e.elements,n=a[0],o=a[4],l=a[8],h=a[1],c=a[5],d=a[9],u=a[2],p=a[6],f=a[10];if(Math.abs(o-h)<.01&&Math.abs(l-u)<.01&&Math.abs(d-p)<.01){if(Math.abs(o+h)<.1&&Math.abs(l+u)<.1&&Math.abs(d+p)<.1&&Math.abs(n+c+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let m=(n+1)/2,v=(c+1)/2,y=(f+1)/2,x=(o+h)/4,w=(l+u)/4,_=(d+p)/4;return m>v&&m>y?m<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(m),r=x/i,s=w/i):v>y?v<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(v),i=x/r,s=_/r):y<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(y),i=w/s,r=_/s),this.set(i,r,s,t),this}let g=Math.sqrt((p-d)*(p-d)+(l-u)*(l-u)+(h-o)*(h-o));return Math.abs(g)<.001&&(g=1),this.x=(p-d)/g,this.y=(l-u)/g,this.z=(h-o)/g,this.w=Math.acos((n+c+f-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Pt=class extends yr{constructor(e=1,t=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ct(0,0,e,t),this.scissorTest=!1,this.viewport=new ct(0,0,e,t);let r={width:e,height:t,depth:1};this.texture=new ci(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps!==void 0?i.generateMipmaps:!1,this.texture.internalFormat=i.internalFormat!==void 0?i.internalFormat:null,this.texture.minFilter=i.minFilter!==void 0?i.minFilter:xt,this.depthBuffer=i.depthBuffer!==void 0?i.depthBuffer:!0,this.stencilBuffer=i.stencilBuffer!==void 0?i.stencilBuffer:!1,this.depthTexture=i.depthTexture!==void 0?i.depthTexture:null,this.samples=i.samples!==void 0?i.samples:0}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,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.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new hM(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},cM=class extends ci{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=_t,this.minFilter=_t,this.wrapR=ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},GR=class extends ci{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=_t,this.minFilter=_t,this.wrapR=ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},dM=class extends Pt{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;let s=this.texture;this.texture=[];for(let a=0;a=0?1:-1,y=1-m*m;if(y>Number.EPSILON){let w=Math.sqrt(y),_=Math.atan2(w,m*v);g=Math.sin(g*_)/w,n=Math.sin(n*_)/w}let x=n*v;if(o=o*g+d*x,l=l*g+u*x,h=h*g+p*x,c=c*g+f*x,g===1-n){let w=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=w,l*=w,h*=w,c*=w}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}static multiplyQuaternionsFlat(e,t,i,r,s,a){let n=i[r],o=i[r+1],l=i[r+2],h=i[r+3],c=s[a],d=s[a+1],u=s[a+2],p=s[a+3];return e[t]=n*p+h*c+o*u-l*d,e[t+1]=o*p+h*d+l*c-n*u,e[t+2]=l*p+h*u+n*d-o*c,e[t+3]=h*p-n*c-o*d-l*u,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){let i=e._x,r=e._y,s=e._z,a=e._order,n=Math.cos,o=Math.sin,l=n(i/2),h=n(r/2),c=n(s/2),d=o(i/2),u=o(r/2),p=o(s/2);switch(a){case"XYZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"YXZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"ZXY":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"ZYX":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"YZX":this._x=d*h*c+l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c-d*u*p;break;case"XZY":this._x=d*h*c-l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],n=t[5],o=t[9],l=t[2],h=t[6],c=t[10],d=i+n+c;if(d>0){let u=.5/Math.sqrt(d+1);this._w=.25/u,this._x=(h-o)*u,this._y=(s-l)*u,this._z=(a-r)*u}else if(i>n&&i>c){let u=2*Math.sqrt(1+i-n-c);this._w=(h-o)/u,this._x=.25*u,this._y=(r+a)/u,this._z=(s+l)/u}else if(n>c){let u=2*Math.sqrt(1+n-i-c);this._w=(s-l)/u,this._x=(r+a)/u,this._y=.25*u,this._z=(o+h)/u}else{let u=2*Math.sqrt(1+c-i-n);this._w=(a-r)/u,this._x=(s+l)/u,this._y=(o+h)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ti(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,a=e._w,n=t._x,o=t._y,l=t._z,h=t._w;return this._x=i*h+a*n+r*l-s*o,this._y=r*h+a*o+s*n-i*l,this._z=s*h+a*l+i*o-r*n,this._w=a*h-i*n-r*o-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,a=this._w,n=a*e._w+i*e._x+r*e._y+s*e._z;if(n<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,n=-n):this.copy(e),n>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;let o=1-n*n;if(o<=Number.EPSILON){let u=1-t;return this._w=u*a+t*this._w,this._x=u*i+t*this._x,this._y=u*r+t*this._y,this._z=u*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(o),h=Math.atan2(l,n),c=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=a*c+this._w*d,this._x=i*c+this._x*d,this._y=r*c+this._y*d,this._z=s*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(s),i*Math.cos(s),t*Math.sin(r))}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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},M=class{constructor(e=0,t=0,i=0){M.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(tb.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(tb.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,n=e.z,o=e.w,l=o*t+a*r-n*i,h=o*i+n*t-s*r,c=o*r+s*i-a*t,d=-s*t-a*i-n*r;return this.x=l*o+d*-s+h*-n-c*-a,this.y=h*o+d*-a+c*-s-l*-n,this.z=c*o+d*-n+l*-a-h*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,a=t.x,n=t.y,o=t.z;return this.x=r*o-s*n,this.y=s*a-i*o,this.z=i*n-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Bm.copy(this).projectOnVector(e),this.sub(Bm)}reflect(e){return this.sub(Bm.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Ti(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}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(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Bm=new M,tb=new lt,Si=class{constructor(e=new M(1/0,1/0,1/0),t=new M(-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){let t=1/0,i=1/0,r=1/0,s=-1/0,a=-1/0,n=-1/0;for(let o=0,l=e.length;os&&(s=h),c>a&&(a=c),d>n&&(n=d)}return this.min.set(t,i,r),this.max.set(s,a,n),this}setFromBufferAttribute(e){let t=1/0,i=1/0,r=1/0,s=-1/0,a=-1/0,n=-1/0;for(let o=0,l=e.count;os&&(s=h),c>a&&(a=c),d>n&&(n=d)}return this.min.set(t,i,r),this.max.set(s,a,n),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Mo),Mo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(oc),eu.subVectors(this.max,oc),Sl.subVectors(e.a,oc),Al.subVectors(e.b,oc),Ml.subVectors(e.c,oc),En.subVectors(Al,Sl),Cn.subVectors(Ml,Al),Eo.subVectors(Sl,Ml);let t=[0,-En.z,En.y,0,-Cn.z,Cn.y,0,-Eo.z,Eo.y,En.z,0,-En.x,Cn.z,0,-Cn.x,Eo.z,0,-Eo.x,-En.y,En.x,0,-Cn.y,Cn.x,0,-Eo.y,Eo.x,0];return!Um(t,Sl,Al,Ml,eu)||(t=[1,0,0,0,1,0,0,0,1],!Um(t,Sl,Al,Ml,eu))?!1:(tu.crossVectors(En,Cn),t=[tu.x,tu.y,tu.z],Um(t,Sl,Al,Ml,eu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Mo.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Mo).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:(Ba[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ba[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ba[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ba[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ba[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ba[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ba[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ba[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ba),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)}},Ba=[new M,new M,new M,new M,new M,new M,new M,new M],Mo=new M,Fm=new Si,Sl=new M,Al=new M,Ml=new M,En=new M,Cn=new M,Eo=new M,oc=new M,eu=new M,tu=new M,Co=new M;function Um(e,t,i,r,s){for(let a=0,n=e.length-3;a<=n;a+=3){Co.fromArray(e,a);let o=s.x*Math.abs(Co.x)+s.y*Math.abs(Co.y)+s.z*Math.abs(Co.z),l=t.dot(Co),h=i.dot(Co),c=r.dot(Co);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}var HR=new Si,lc=new M,Nm=new M,$r=class{constructor(e=new M,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):HR.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;sthis.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;lc.subVectors(e,this.center);let t=lc.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(lc,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Nm.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(lc.copy(e.center).add(Nm)),this.expandByPoint(lc.copy(e.center).sub(Nm))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Fa=new M,km=new M,iu=new M,Tn=new M,Vm=new M,ru=new M,jm=new M,Hh=class{constructor(e=new M,t=new M(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.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Fa)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Fa.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Fa.copy(this.direction).multiplyScalar(t).add(this.origin),Fa.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){km.copy(e).add(t).multiplyScalar(.5),iu.copy(t).sub(e).normalize(),Tn.copy(this.origin).sub(km);let s=e.distanceTo(t)*.5,a=-this.direction.dot(iu),n=Tn.dot(this.direction),o=-Tn.dot(iu),l=Tn.lengthSq(),h=Math.abs(1-a*a),c,d,u,p;if(h>0)if(c=a*o-n,d=a*n-o,p=s*h,c>=0)if(d>=-p)if(d<=p){let f=1/h;c*=f,d*=f,u=c*(c+a*d+2*n)+d*(a*c+d+2*o)+l}else d=s,c=Math.max(0,-(a*d+n)),u=-c*c+d*(d+2*o)+l;else d=-s,c=Math.max(0,-(a*d+n)),u=-c*c+d*(d+2*o)+l;else d<=-p?(c=Math.max(0,-(-a*s+n)),d=c>0?-s:Math.min(Math.max(-s,-o),s),u=-c*c+d*(d+2*o)+l):d<=p?(c=0,d=Math.min(Math.max(-s,-o),s),u=d*(d+2*o)+l):(c=Math.max(0,-(a*s+n)),d=c>0?s:Math.min(Math.max(-s,-o),s),u=-c*c+d*(d+2*o)+l);else d=a>0?-s:s,c=Math.max(0,-(a*d+n)),u=-c*c+d*(d+2*o)+l;return i&&i.copy(this.direction).multiplyScalar(c).add(this.origin),r&&r.copy(iu).multiplyScalar(d).add(km),u}intersectSphere(e,t){Fa.subVectors(e.center,this.origin);let i=Fa.dot(this.direction),r=Fa.dot(Fa)-i*i,s=e.radius*e.radius;if(r>s)return null;let a=Math.sqrt(s-r),n=i-a,o=i+a;return n<0&&o<0?null:n<0?this.at(o,t):this.at(n,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,n,o,l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return l>=0?(i=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(i=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),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),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a=0?(n=(e.min.z-d.z)*c,o=(e.max.z-d.z)*c):(n=(e.max.z-d.z)*c,o=(e.min.z-d.z)*c),i>o||n>r)||((n>i||i!==i)&&(i=n),(o=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Fa)!==null}intersectTriangle(e,t,i,r,s){Vm.subVectors(t,e),ru.subVectors(i,e),jm.crossVectors(Vm,ru);let a=this.direction.dot(jm),n;if(a>0){if(r)return null;n=1}else if(a<0)n=-1,a=-a;else return null;Tn.subVectors(this.origin,e);let o=n*this.direction.dot(ru.crossVectors(Tn,ru));if(o<0)return null;let l=n*this.direction.dot(Vm.cross(Tn));if(l<0||o+l>a)return null;let h=-n*Tn.dot(jm);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)}},we=class{constructor(){we.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,i,r,s,a,n,o,l,h,c,d,u,p,f,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=s,m[5]=a,m[9]=n,m[13]=o,m[2]=l,m[6]=h,m[10]=c,m[14]=d,m[3]=u,m[7]=p,m[11]=f,m[15]=g,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 we().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/El.setFromMatrixColumn(e,0).length(),s=1/El.setFromMatrixColumn(e,1).length(),a=1/El.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),n=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(s),c=Math.sin(s);if(e.order==="XYZ"){let d=a*h,u=a*c,p=n*h,f=n*c;t[0]=o*h,t[4]=-o*c,t[8]=l,t[1]=u+p*l,t[5]=d-f*l,t[9]=-n*o,t[2]=f-d*l,t[6]=p+u*l,t[10]=a*o}else if(e.order==="YXZ"){let d=o*h,u=o*c,p=l*h,f=l*c;t[0]=d+f*n,t[4]=p*n-u,t[8]=a*l,t[1]=a*c,t[5]=a*h,t[9]=-n,t[2]=u*n-p,t[6]=f+d*n,t[10]=a*o}else if(e.order==="ZXY"){let d=o*h,u=o*c,p=l*h,f=l*c;t[0]=d-f*n,t[4]=-a*c,t[8]=p+u*n,t[1]=u+p*n,t[5]=a*h,t[9]=f-d*n,t[2]=-a*l,t[6]=n,t[10]=a*o}else if(e.order==="ZYX"){let d=a*h,u=a*c,p=n*h,f=n*c;t[0]=o*h,t[4]=p*l-u,t[8]=d*l+f,t[1]=o*c,t[5]=f*l+d,t[9]=u*l-p,t[2]=-l,t[6]=n*o,t[10]=a*o}else if(e.order==="YZX"){let d=a*o,u=a*l,p=n*o,f=n*l;t[0]=o*h,t[4]=f-d*c,t[8]=p*c+u,t[1]=c,t[5]=a*h,t[9]=-n*h,t[2]=-l*h,t[6]=u*c+p,t[10]=d-f*c}else if(e.order==="XZY"){let d=a*o,u=a*l,p=n*o,f=n*l;t[0]=o*h,t[4]=-c,t[8]=l*h,t[1]=d*c+f,t[5]=a*h,t[9]=u*c-p,t[2]=p*c-u,t[6]=n*h,t[10]=f*c+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(WR,e,qR)}lookAt(e,t,i){let r=this.elements;return ts.subVectors(e,t),ts.lengthSq()===0&&(ts.z=1),ts.normalize(),Pn.crossVectors(i,ts),Pn.lengthSq()===0&&(Math.abs(i.z)===1?ts.x+=1e-4:ts.z+=1e-4,ts.normalize(),Pn.crossVectors(i,ts)),Pn.normalize(),su.crossVectors(ts,Pn),r[0]=Pn.x,r[4]=su.x,r[8]=ts.x,r[1]=Pn.y,r[5]=su.y,r[9]=ts.y,r[2]=Pn.z,r[6]=su.z,r[10]=ts.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,a=i[0],n=i[4],o=i[8],l=i[12],h=i[1],c=i[5],d=i[9],u=i[13],p=i[2],f=i[6],g=i[10],m=i[14],v=i[3],y=i[7],x=i[11],w=i[15],_=r[0],b=r[4],A=r[8],S=r[12],E=r[1],C=r[5],T=r[9],D=r[13],O=r[2],P=r[6],U=r[10],W=r[14],k=r[3],F=r[7],Z=r[11],X=r[15];return s[0]=a*_+n*E+o*O+l*k,s[4]=a*b+n*C+o*P+l*F,s[8]=a*A+n*T+o*U+l*Z,s[12]=a*S+n*D+o*W+l*X,s[1]=h*_+c*E+d*O+u*k,s[5]=h*b+c*C+d*P+u*F,s[9]=h*A+c*T+d*U+u*Z,s[13]=h*S+c*D+d*W+u*X,s[2]=p*_+f*E+g*O+m*k,s[6]=p*b+f*C+g*P+m*F,s[10]=p*A+f*T+g*U+m*Z,s[14]=p*S+f*D+g*W+m*X,s[3]=v*_+y*E+x*O+w*k,s[7]=v*b+y*C+x*P+w*F,s[11]=v*A+y*T+x*U+w*Z,s[15]=v*S+y*D+x*W+w*X,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],n=e[5],o=e[9],l=e[13],h=e[2],c=e[6],d=e[10],u=e[14],p=e[3],f=e[7],g=e[11],m=e[15];return p*(+s*o*c-r*l*c-s*n*d+i*l*d+r*n*u-i*o*u)+f*(+t*o*u-t*l*d+s*a*d-r*a*u+r*l*h-s*o*h)+g*(+t*l*c-t*n*u-s*a*c+i*a*u+s*n*h-i*l*h)+m*(-r*n*h-t*o*c+t*n*d+r*a*c-i*a*d+i*o*h)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8],c=e[9],d=e[10],u=e[11],p=e[12],f=e[13],g=e[14],m=e[15],v=c*g*l-f*d*l+f*o*u-n*g*u-c*o*m+n*d*m,y=p*d*l-h*g*l-p*o*u+a*g*u+h*o*m-a*d*m,x=h*f*l-p*c*l+p*n*u-a*f*u-h*n*m+a*c*m,w=p*c*o-h*f*o-p*n*d+a*f*d+h*n*g-a*c*g,_=t*v+i*y+r*x+s*w;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let b=1/_;return e[0]=v*b,e[1]=(f*d*s-c*g*s-f*r*u+i*g*u+c*r*m-i*d*m)*b,e[2]=(n*g*s-f*o*s+f*r*l-i*g*l-n*r*m+i*o*m)*b,e[3]=(c*o*s-n*d*s-c*r*l+i*d*l+n*r*u-i*o*u)*b,e[4]=y*b,e[5]=(h*g*s-p*d*s+p*r*u-t*g*u-h*r*m+t*d*m)*b,e[6]=(p*o*s-a*g*s-p*r*l+t*g*l+a*r*m-t*o*m)*b,e[7]=(a*d*s-h*o*s+h*r*l-t*d*l-a*r*u+t*o*u)*b,e[8]=x*b,e[9]=(p*c*s-h*f*s-p*i*u+t*f*u+h*i*m-t*c*m)*b,e[10]=(a*f*s-p*n*s+p*i*l-t*f*l-a*i*m+t*n*m)*b,e[11]=(h*n*s-a*c*s-h*i*l+t*c*l+a*i*u-t*n*u)*b,e[12]=w*b,e[13]=(h*f*r-p*c*r+p*i*d-t*f*d-h*i*g+t*c*g)*b,e[14]=(p*n*r-a*f*r-p*i*o+t*f*o+a*i*g-t*n*g)*b,e[15]=(a*c*r-h*n*r+h*i*o-t*c*o-a*i*d+t*n*d)*b,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,n=e.y,o=e.z,l=s*a,h=s*n;return this.set(l*a+i,l*n-r*o,l*o+r*n,0,l*n+r*o,h*n+i,h*o-r*a,0,l*o-r*n,h*o+r*a,s*o*o+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,a=t._y,n=t._z,o=t._w,l=s+s,h=a+a,c=n+n,d=s*l,u=s*h,p=s*c,f=a*h,g=a*c,m=n*c,v=o*l,y=o*h,x=o*c,w=i.x,_=i.y,b=i.z;return r[0]=(1-(f+m))*w,r[1]=(u+x)*w,r[2]=(p-y)*w,r[3]=0,r[4]=(u-x)*_,r[5]=(1-(d+m))*_,r[6]=(g+v)*_,r[7]=0,r[8]=(p+y)*b,r[9]=(g-v)*b,r[10]=(1-(d+f))*b,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=El.set(r[0],r[1],r[2]).length(),a=El.set(r[4],r[5],r[6]).length(),n=El.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],Ps.copy(this);let o=1/s,l=1/a,h=1/n;return Ps.elements[0]*=o,Ps.elements[1]*=o,Ps.elements[2]*=o,Ps.elements[4]*=l,Ps.elements[5]*=l,Ps.elements[6]*=l,Ps.elements[8]*=h,Ps.elements[9]*=h,Ps.elements[10]*=h,t.setFromRotationMatrix(Ps),i.x=s,i.y=a,i.z=n,this}makePerspective(e,t,i,r,s,a){let n=this.elements,o=2*s/(t-e),l=2*s/(i-r),h=(t+e)/(t-e),c=(i+r)/(i-r),d=-(a+s)/(a-s),u=-2*a*s/(a-s);return n[0]=o,n[4]=0,n[8]=h,n[12]=0,n[1]=0,n[5]=l,n[9]=c,n[13]=0,n[2]=0,n[6]=0,n[10]=d,n[14]=u,n[3]=0,n[7]=0,n[11]=-1,n[15]=0,this}makeOrthographic(e,t,i,r,s,a){let n=this.elements,o=1/(t-e),l=1/(i-r),h=1/(a-s),c=(t+e)*o,d=(i+r)*l,u=(a+s)*h;return n[0]=2*o,n[4]=0,n[8]=0,n[12]=-c,n[1]=0,n[5]=2*l,n[9]=0,n[13]=-d,n[2]=0,n[6]=0,n[10]=-2*h,n[14]=-u,n[3]=0,n[7]=0,n[11]=0,n[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},El=new M,Ps=new we,WR=new M(0,0,0),qR=new M(1,1,1),Pn=new M,su=new M,ts=new M,ib=new we,rb=new lt,ji=class{constructor(e=0,t=0,i=0,r=ji.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],a=r[4],n=r[8],o=r[1],l=r[5],h=r[9],c=r[2],d=r[6],u=r[10];switch(t){case"XYZ":this._y=Math.asin(Ti(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(-h,u),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ti(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(n,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ti(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,s));break;case"ZYX":this._y=Math.asin(-Ti(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ti(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(n,u));break;case"XZY":this._z=Math.asin(-Ti(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(n,s)):(this._x=Math.atan2(-h,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return ib.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ib,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return rb.setFromEuler(this),this.setFromQuaternion(rb,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}};ji.DEFAULT_ORDER="XYZ";var jy=class{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(i=i.concat(a))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hc,e,YR),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hc,QR,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.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()));function s(n,o){return n[o.uuid]===void 0&&(n[o.uuid]=o.toJSON(e)),o.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);let n=this.geometry.parameters;if(n!==void 0&&n.shapes!==void 0){let o=n.shapes;if(Array.isArray(o))for(let l=0,h=o.length;l0){r.children=[];for(let n=0;n0){r.animations=[];for(let n=0;n0&&(i.geometries=n),o.length>0&&(i.materials=o),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),c.length>0&&(i.shapes=c),d.length>0&&(i.skeletons=d),u.length>0&&(i.animations=u),p.length>0&&(i.nodes=p)}return i.object=r,i;function a(n){let o=[];for(let l in n){let h=n[l];delete h.metadata,o.push(h)}return o}}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.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Ds.subVectors(r,t),Na.subVectors(i,t),Gm.subVectors(e,t);let a=Ds.dot(Ds),n=Ds.dot(Na),o=Ds.dot(Gm),l=Na.dot(Na),h=Na.dot(Gm),c=a*l-n*n;if(c===0)return s.set(-2,-1,-1);let d=1/c,u=(l*o-n*h)*d,p=(a*h-n*o)*d;return s.set(1-u-p,p,u)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,ka),ka.x>=0&&ka.y>=0&&ka.x+ka.y<=1}static getUV(e,t,i,r,s,a,n,o){return this.getBarycoord(e,t,i,r,ka),o.set(0,0),o.addScaledVector(s,ka.x),o.addScaledVector(a,ka.y),o.addScaledVector(n,ka.z),o}static isFrontFacing(e,t,i,r){return Ds.subVectors(i,t),Na.subVectors(e,t),Ds.cross(Na).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ds.subVectors(this.c,this.b),Na.subVectors(this.a,this.b),Ds.cross(Na).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return pr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return pr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,s){return pr.getUV(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return pr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return pr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,a,n;Tl.subVectors(r,i),Pl.subVectors(s,i),Hm.subVectors(e,i);let o=Tl.dot(Hm),l=Pl.dot(Hm);if(o<=0&&l<=0)return t.copy(i);Wm.subVectors(e,r);let h=Tl.dot(Wm),c=Pl.dot(Wm);if(h>=0&&c<=h)return t.copy(r);let d=o*c-h*l;if(d<=0&&o>=0&&h<=0)return a=o/(o-h),t.copy(i).addScaledVector(Tl,a);qm.subVectors(e,s);let u=Tl.dot(qm),p=Pl.dot(qm);if(p>=0&&u<=p)return t.copy(s);let f=u*l-o*p;if(f<=0&&l>=0&&p<=0)return n=l/(l-p),t.copy(i).addScaledVector(Pl,n);let g=h*p-u*c;if(g<=0&&c-h>=0&&u-p>=0)return hb.subVectors(s,r),n=(c-h)/(c-h+(u-p)),t.copy(r).addScaledVector(hb,n);let m=1/(g+f+d);return a=f*m,n=d*m,t.copy(i).addScaledVector(Tl,a).addScaledVector(Pl,n)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},KR=0,Ld=class extends yr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:KR++}),this.uuid=ws(),this.name="",this.type="Material",this.blending=Jo,this.side=Ws,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Z2,this.blendDst=K2,this.blendEquation=eh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Pv,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=MR,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Im,this.stencilZFail=Im,this.stencilZPass=Im,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.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}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}let r=this[t];if(r===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Jo&&(i.blending=this.blending),this.side!==Ws&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(i.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(i.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=this.flatShading),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let a=[];for(let n in s){let o=s[n];delete o.metadata,a.push(o)}return a}if(t){let s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.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;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.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++}},gn=class extends Ld{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new et(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.combine=J2,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.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}},Mi=new M,nu=new j,tt=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Rv,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){let o=this.parameters;for(let l in o)o[l]!==void 0&&(e[l]=o[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let o in i){let l=i[o];e.data.attributes[o]=l.toJSON(e.data)}let r={},s=!1;for(let o in this.morphAttributes){let l=this.morphAttributes[o],h=[];for(let c=0,d=l.length;c0&&(r[o]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let n=this.boundingSphere;return n!==null&&(e.data.boundingSphere={center:n.center.toArray(),radius:n.radius}),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;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let l in r){let h=r[l];this.setAttribute(l,h.clone(t))}let s=e.morphAttributes;for(let l in s){let h=[],c=s[l];for(let d=0,u=c.length;d0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;ri.far?null:{distance:h,point:du.clone(),object:e}}function uu(e,t,i,r,s,a,n,o,l){e.getVertexPosition(n,dc),e.getVertexPosition(o,uc),e.getVertexPosition(l,pc);let h=$R(e,t,i,r,dc,uc,pc,Zm);if(h){s&&(lu.fromBufferAttribute(s,n),hu.fromBufferAttribute(s,o),cu.fromBufferAttribute(s,l),h.uv=pr.getUV(Zm,dc,uc,pc,lu,hu,cu,new j)),a&&(lu.fromBufferAttribute(a,n),hu.fromBufferAttribute(a,o),cu.fromBufferAttribute(a,l),h.uv2=pr.getUV(Zm,dc,uc,pc,lu,hu,cu,new j));let c={a:n,b:o,c:l,normal:new M,materialIndex:0};pr.getNormal(dc,uc,pc,c.normal),h.face=c}return h}var Xs=class extends Ge{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};let n=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);let o=[],l=[],h=[],c=[],d=0,u=0;p("z","y","x",-1,-1,i,t,e,a,s,0),p("z","y","x",1,-1,i,t,-e,a,s,1),p("x","z","y",1,1,e,i,t,r,a,2),p("x","z","y",1,-1,e,i,-t,r,a,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(o),this.setAttribute("position",new Ie(l,3)),this.setAttribute("normal",new Ie(h,3)),this.setAttribute("uv",new Ie(c,2));function p(f,g,m,v,y,x,w,_,b,A,S){let E=x/b,C=w/A,T=x/2,D=w/2,O=_/2,P=b+1,U=A+1,W=0,k=0,F=new M;for(let Z=0;Z0?1:-1,h.push(F.x,F.y,F.z),c.push(G/b),c.push(1-Z/A),W+=1}}for(let Z=0;Z0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},bo=class extends kt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new we,this.projectionMatrix=new we,this.projectionMatrixInverse=new we}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}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)}},_r=class extends bo{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=cd*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Xc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return cd*2*Math.atan(Math.tan(Xc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,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=i,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(){let e=this.near,t=e*Math.tan(Xc*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let o=a.fullWidth,l=a.fullHeight;s+=a.offsetX*r/o,t-=a.offsetY*i/l,r*=a.width/o,i*=a.height/l}let n=this.filmOffset;n!==0&&(s+=e*n/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},Ol=-90,Rl=1,rL=class extends kt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i;let r=new _r(Ol,Rl,e,t);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(1,0,0),this.add(r);let s=new _r(Ol,Rl,e,t);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);let a=new _r(Ol,Rl,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(0,1,0),this.add(a);let n=new _r(Ol,Rl,e,t);n.layers=this.layers,n.up.set(0,0,1),n.lookAt(0,-1,0),this.add(n);let o=new _r(Ol,Rl,e,t);o.layers=this.layers,o.up.set(0,1,0),o.lookAt(0,0,1),this.add(o);let l=new _r(Ol,Rl,e,t);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,-1),this.add(l)}update(e,t){this.parent===null&&this.updateMatrixWorld();let i=this.renderTarget,[r,s,a,n,o,l]=this.children,h=e.getRenderTarget(),c=e.toneMapping,d=e.xr.enabled;e.toneMapping=_a,e.xr.enabled=!1;let u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,s),e.setRenderTarget(i,2),e.render(t,a),e.setRenderTarget(i,3),e.render(t,n),e.setRenderTarget(i,4),e.render(t,o),i.texture.generateMipmaps=u,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(h),e.toneMapping=c,e.xr.enabled=d,i.texture.needsPMREMUpdate=!0}},Gy=class extends ci{constructor(e,t,i,r,s,a,n,o,l,h){e=e!==void 0?e:[],t=t!==void 0?t:al,super(e,t,i,r,s,a,n,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},sL=class extends Pt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Gy(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:xt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},r=new Xs(5,5,5),s=new Dt({name:"CubemapFromEquirect",uniforms:Th(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:rr,blending:Oi});s.uniforms.tEquirect.value=t;let a=new Jt(r,s),n=t.minFilter;return t.minFilter===Ch&&(t.minFilter=xt),new rL(1,10,this).update(e,a),t.minFilter=n,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}},Km=new M,aL=new M,nL=new Di,qr=class{constructor(e=new M(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=Km.subVectors(i,t).cross(aL.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let i=e.delta(Km),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(i).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||nL.getNormalMatrix(e),r=this.coplanarPoint(Km).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Ll=new $r,pu=new M,Hy=class{constructor(e=new qr,t=new qr,i=new qr,r=new qr,s=new qr,a=new qr){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){let n=this.planes;return n[0].copy(e),n[1].copy(t),n[2].copy(i),n[3].copy(r),n[4].copy(s),n[5].copy(a),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){let t=this.planes,i=e.elements,r=i[0],s=i[1],a=i[2],n=i[3],o=i[4],l=i[5],h=i[6],c=i[7],d=i[8],u=i[9],p=i[10],f=i[11],g=i[12],m=i[13],v=i[14],y=i[15];return t[0].setComponents(n-r,c-o,f-d,y-g).normalize(),t[1].setComponents(n+r,c+o,f+d,y+g).normalize(),t[2].setComponents(n+s,c+l,f+u,y+m).normalize(),t[3].setComponents(n-s,c-l,f-u,y-m).normalize(),t[4].setComponents(n-a,c-h,f-p,y-v).normalize(),t[5].setComponents(n+a,c+h,f+p,y+v).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Ll.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Ll)}intersectsSprite(e){return Ll.center.set(0,0,0),Ll.radius=.7071067811865476,Ll.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ll)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)0?e.max.x:e.min.x,pu.y=r.normal.y>0?e.max.y:e.min.y,pu.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(pu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function fM(){let e=null,t=!1,i=null,r=null;function s(a,n){i(a,n),r=e.requestAnimationFrame(s)}return{start:function(){t!==!0&&i!==null&&(r=e.requestAnimationFrame(s),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(a){i=a},setContext:function(a){e=a}}}function oL(e,t){let i=t.isWebGL2,r=new WeakMap;function s(h,c){let d=h.array,u=h.usage,p=e.createBuffer();e.bindBuffer(c,p),e.bufferData(c,d,u),h.onUploadCallback();let f;if(d instanceof Float32Array)f=5126;else if(d instanceof Uint16Array)if(h.isFloat16BufferAttribute)if(i)f=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else f=5123;else if(d instanceof Int16Array)f=5122;else if(d instanceof Uint32Array)f=5125;else if(d instanceof Int32Array)f=5124;else if(d instanceof Int8Array)f=5120;else if(d instanceof Uint8Array)f=5121;else if(d instanceof Uint8ClampedArray)f=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:p,type:f,bytesPerElement:d.BYTES_PER_ELEMENT,version:h.version}}function a(h,c,d){let u=c.array,p=c.updateRange;e.bindBuffer(d,h),p.count===-1?e.bufferSubData(d,0,u):(i?e.bufferSubData(d,p.offset*u.BYTES_PER_ELEMENT,u,p.offset,p.count):e.bufferSubData(d,p.offset*u.BYTES_PER_ELEMENT,u.subarray(p.offset,p.offset+p.count)),p.count=-1),c.onUploadCallback()}function n(h){return h.isInterleavedBufferAttribute&&(h=h.data),r.get(h)}function o(h){h.isInterleavedBufferAttribute&&(h=h.data);let c=r.get(h);c&&(e.deleteBuffer(c.buffer),r.delete(h))}function l(h,c){if(h.isGLBufferAttribute){let u=r.get(h);(!u||u.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif`,vL=`#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); 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 ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float R21 = R12; float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`,yL=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture2D( bumpMap, vUv ).x; float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = dFdx( surf_pos.xyz ); vec3 vSigmaY = dFdy( surf_pos.xyz ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,xL=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif`,bL=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,wL=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,_L=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,SL=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,AL=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,ML=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,EL=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,CL=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef USE_CLEARCOAT vec3 clearcoatNormal; #endif }; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float luminance( const in vec3 rgb ) { const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); return dot( weights, rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); }`,TL=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_v0 0.339 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,PL=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,DL=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,IL=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,OL=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,RL=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,LL="gl_FragColor = linearToOutputTexel( gl_FragColor );",zL=`vec4 LinearToLinear( in vec4 value ) { return value; } vec4 LinearTosRGB( in vec4 value ) { 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 ); }`,BL=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,FL=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,UL=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,NL=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,kL=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,VL=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,jL=`#ifdef USE_FOG varying float vFogDepth; #endif`,GL=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,HL=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,WL=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,qL=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,XL=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,YL=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,QL=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ZL=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { #if defined ( PHYSICALLY_CORRECT_LIGHTS ) float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #else if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #endif } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = pointLight.position - geometry.position; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = spotLight.position - geometry.position; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,KL=`#if defined( USE_ENVMAP ) vec3 getIBLIrradiance( const in vec3 normal ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #endif`,JL=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,$L=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,ez=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,tz=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,iz=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULARINTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; #endif #ifdef USE_SPECULARCOLORMAP specularColorFactor *= texture2D( specularColorMap, vUv ).rgb; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEENCOLORMAP material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEENROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; #endif #endif`,rz=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = vec3( 0.0 ); float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE 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 ) { #else 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 ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif #ifdef USE_IRIDESCENCE reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness ); #else reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); #endif reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,sz=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometry.viewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometry, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,az=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometry.normal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif #endif`,nz=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,oz=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,lz=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,hz=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,cz=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,dz=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; #endif`,uz=`#ifdef USE_MAP uniform sampler2D map; #endif`,pz=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,fz=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,mz=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,gz=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,vz=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,yz=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif #endif`,xz=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #else #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif #endif`,bz=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif #endif`,wz=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * faceDirection; bitangent = bitangent * faceDirection; #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`,_z=`#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( TANGENTSPACE_NORMALMAP ) vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; #ifdef USE_TANGENT normal = normalize( vTBN * mapN ); #else normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,Sz=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,Az=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,Mz=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,Ez=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef OBJECTSPACE_NORMALMAP uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); } #endif`,Cz=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,Tz=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; #ifdef USE_TANGENT clearcoatNormal = normalize( vTBN * clearcoatMapN ); #else clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); #endif #endif`,Pz=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`,Dz=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,Iz=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha + 0.1; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Oz=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec2 packDepthToRG( in highp float v ) { return packDepthToRGBA( v ).yx; } float unpackRGToDepth( const in highp vec2 v ) { return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); } vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { return linearClipZ * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * invClipZ - far ); }`,Rz=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,Lz=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,zz=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,Bz=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,Fz=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,Uz=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,Nz=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); 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 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,kz=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,Vz=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,jz=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,Gz=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,Hz=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #endif`,Wz=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,qz=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,Xz=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,Yz=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,Qz=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,Zz=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return toneMappingExposure * color; } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 OptimizedCineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,Kz=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmission = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); #endif`,Jz=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); #ifdef texture2DLodEXT return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #else return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #endif } vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return radiance; } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); } #endif`,$z=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,eB=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,tB=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,iB=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,rB=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,sB=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,aB=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`,nB=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,oB=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE 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 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,lB=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,hB=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,cB=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,dB=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,uB=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,pB=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif }`,fB=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,mB=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,gB=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,vB=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,yB=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include }`,xB=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,bB=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,wB=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,_B=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,SB=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,AB=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,MB=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,EB=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,CB=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,TB=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,PB=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,DB=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,IB=`#define STANDARD #ifdef PHYSICAL #define IOR #define SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULARINTENSITYMAP uniform sampler2D specularIntensityMap; #endif #ifdef USE_SPECULARCOLORMAP uniform sampler2D specularColorMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEENCOLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEENROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif #include #include #include #include #include #include }`,OB=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,RB=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,LB=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,zB=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,BB=`#include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include }`,FB=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,UB=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,NB=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,yt={alphamap_fragment:lL,alphamap_pars_fragment:hL,alphatest_fragment:cL,alphatest_pars_fragment:dL,aomap_fragment:uL,aomap_pars_fragment:pL,begin_vertex:fL,beginnormal_vertex:mL,bsdfs:gL,iridescence_fragment:vL,bumpmap_pars_fragment:yL,clipping_planes_fragment:xL,clipping_planes_pars_fragment:bL,clipping_planes_pars_vertex:wL,clipping_planes_vertex:_L,color_fragment:SL,color_pars_fragment:AL,color_pars_vertex:ML,color_vertex:EL,common:CL,cube_uv_reflection_fragment:TL,defaultnormal_vertex:PL,displacementmap_pars_vertex:DL,displacementmap_vertex:IL,emissivemap_fragment:OL,emissivemap_pars_fragment:RL,encodings_fragment:LL,encodings_pars_fragment:zL,envmap_fragment:BL,envmap_common_pars_fragment:FL,envmap_pars_fragment:UL,envmap_pars_vertex:NL,envmap_physical_pars_fragment:KL,envmap_vertex:kL,fog_vertex:VL,fog_pars_vertex:jL,fog_fragment:GL,fog_pars_fragment:HL,gradientmap_pars_fragment:WL,lightmap_fragment:qL,lightmap_pars_fragment:XL,lights_lambert_fragment:YL,lights_lambert_pars_fragment:QL,lights_pars_begin:ZL,lights_toon_fragment:JL,lights_toon_pars_fragment:$L,lights_phong_fragment:ez,lights_phong_pars_fragment:tz,lights_physical_fragment:iz,lights_physical_pars_fragment:rz,lights_fragment_begin:sz,lights_fragment_maps:az,lights_fragment_end:nz,logdepthbuf_fragment:oz,logdepthbuf_pars_fragment:lz,logdepthbuf_pars_vertex:hz,logdepthbuf_vertex:cz,map_fragment:dz,map_pars_fragment:uz,map_particle_fragment:pz,map_particle_pars_fragment:fz,metalnessmap_fragment:mz,metalnessmap_pars_fragment:gz,morphcolor_vertex:vz,morphnormal_vertex:yz,morphtarget_pars_vertex:xz,morphtarget_vertex:bz,normal_fragment_begin:wz,normal_fragment_maps:_z,normal_pars_fragment:Sz,normal_pars_vertex:Az,normal_vertex:Mz,normalmap_pars_fragment:Ez,clearcoat_normal_fragment_begin:Cz,clearcoat_normal_fragment_maps:Tz,clearcoat_pars_fragment:Pz,iridescence_pars_fragment:Dz,output_fragment:Iz,packing:Oz,premultiplied_alpha_fragment:Rz,project_vertex:Lz,dithering_fragment:zz,dithering_pars_fragment:Bz,roughnessmap_fragment:Fz,roughnessmap_pars_fragment:Uz,shadowmap_pars_fragment:Nz,shadowmap_pars_vertex:kz,shadowmap_vertex:Vz,shadowmask_pars_fragment:jz,skinbase_vertex:Gz,skinning_pars_vertex:Hz,skinning_vertex:Wz,skinnormal_vertex:qz,specularmap_fragment:Xz,specularmap_pars_fragment:Yz,tonemapping_fragment:Qz,tonemapping_pars_fragment:Zz,transmission_fragment:Kz,transmission_pars_fragment:Jz,uv_pars_fragment:$z,uv_pars_vertex:eB,uv_vertex:tB,uv2_pars_fragment:iB,uv2_pars_vertex:rB,uv2_vertex:sB,worldpos_vertex:aB,background_vert:nB,background_frag:oB,backgroundCube_vert:lB,backgroundCube_frag:hB,cube_vert:cB,cube_frag:dB,depth_vert:uB,depth_frag:pB,distanceRGBA_vert:fB,distanceRGBA_frag:mB,equirect_vert:gB,equirect_frag:vB,linedashed_vert:yB,linedashed_frag:xB,meshbasic_vert:bB,meshbasic_frag:wB,meshlambert_vert:_B,meshlambert_frag:SB,meshmatcap_vert:AB,meshmatcap_frag:MB,meshnormal_vert:EB,meshnormal_frag:CB,meshphong_vert:TB,meshphong_frag:PB,meshphysical_vert:DB,meshphysical_frag:IB,meshtoon_vert:OB,meshtoon_frag:RB,points_vert:LB,points_frag:zB,shadow_vert:BB,shadow_frag:FB,sprite_vert:UB,sprite_frag:NB},Pe={common:{diffuse:{value:new et(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Di},uv2Transform:{value:new Di},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new j(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new et(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 et(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Di}},sprite:{diffuse:{value:new et(16777215)},opacity:{value:1},center:{value:new j(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Di}}},ma={basic:{uniforms:Lr([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.fog]),vertexShader:yt.meshbasic_vert,fragmentShader:yt.meshbasic_frag},lambert:{uniforms:Lr([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,Pe.lights,{emissive:{value:new et(0)}}]),vertexShader:yt.meshlambert_vert,fragmentShader:yt.meshlambert_frag},phong:{uniforms:Lr([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,Pe.lights,{emissive:{value:new et(0)},specular:{value:new et(1118481)},shininess:{value:30}}]),vertexShader:yt.meshphong_vert,fragmentShader:yt.meshphong_frag},standard:{uniforms:Lr([Pe.common,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.roughnessmap,Pe.metalnessmap,Pe.fog,Pe.lights,{emissive:{value:new et(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag},toon:{uniforms:Lr([Pe.common,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.gradientmap,Pe.fog,Pe.lights,{emissive:{value:new et(0)}}]),vertexShader:yt.meshtoon_vert,fragmentShader:yt.meshtoon_frag},matcap:{uniforms:Lr([Pe.common,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,{matcap:{value:null}}]),vertexShader:yt.meshmatcap_vert,fragmentShader:yt.meshmatcap_frag},points:{uniforms:Lr([Pe.points,Pe.fog]),vertexShader:yt.points_vert,fragmentShader:yt.points_frag},dashed:{uniforms:Lr([Pe.common,Pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yt.linedashed_vert,fragmentShader:yt.linedashed_frag},depth:{uniforms:Lr([Pe.common,Pe.displacementmap]),vertexShader:yt.depth_vert,fragmentShader:yt.depth_frag},normal:{uniforms:Lr([Pe.common,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,{opacity:{value:1}}]),vertexShader:yt.meshnormal_vert,fragmentShader:yt.meshnormal_frag},sprite:{uniforms:Lr([Pe.sprite,Pe.fog]),vertexShader:yt.sprite_vert,fragmentShader:yt.sprite_frag},background:{uniforms:{uvTransform:{value:new Di},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:yt.background_vert,fragmentShader:yt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:yt.backgroundCube_vert,fragmentShader:yt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yt.cube_vert,fragmentShader:yt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yt.equirect_vert,fragmentShader:yt.equirect_frag},distanceRGBA:{uniforms:Lr([Pe.common,Pe.displacementmap,{referencePosition:{value:new M},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yt.distanceRGBA_vert,fragmentShader:yt.distanceRGBA_frag},shadow:{uniforms:Lr([Pe.lights,Pe.fog,{color:{value:new et(0)},opacity:{value:1}}]),vertexShader:yt.shadow_vert,fragmentShader:yt.shadow_frag}};ma.physical={uniforms:Lr([ma.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new j(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new et(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new j},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new et(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new et(1,1,1)},specularColorMap:{value:null}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag};var fu={r:0,b:0,g:0};function kB(e,t,i,r,s,a,n){let o=new et(0),l=a===!0?0:1,h,c,d=null,u=0,p=null;function f(m,v){let y=!1,x=v.isScene===!0?v.background:null;x&&x.isTexture&&(x=(v.backgroundBlurriness>0?i:t).get(x));let w=e.xr,_=w.getSession&&w.getSession();_&&_.environmentBlendMode==="additive"&&(x=null),x===null?g(o,l):x&&x.isColor&&(g(x,1),y=!0),(e.autoClear||y)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),x&&(x.isCubeTexture||x.mapping===Rd)?(c===void 0&&(c=new Jt(new Xs(1,1,1),new Dt({name:"BackgroundCubeMaterial",uniforms:Th(ma.backgroundCube.uniforms),vertexShader:ma.backgroundCube.vertexShader,fragmentShader:ma.backgroundCube.fragmentShader,side:rr,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(b,A,S){this.matrixWorld.copyPosition(S.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=x.encoding!==gt,(d!==x||u!==x.version||p!==e.toneMapping)&&(c.material.needsUpdate=!0,d=x,u=x.version,p=e.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(h===void 0&&(h=new Jt(new Ea(2,2),new Dt({name:"BackgroundMaterial",uniforms:Th(ma.background.uniforms),vertexShader:ma.background.vertexShader,fragmentShader:ma.background.fragmentShader,side:Ws,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(h)),h.material.uniforms.t2D.value=x,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.toneMapped=x.encoding!==gt,x.matrixAutoUpdate===!0&&x.updateMatrix(),h.material.uniforms.uvTransform.value.copy(x.matrix),(d!==x||u!==x.version||p!==e.toneMapping)&&(h.material.needsUpdate=!0,d=x,u=x.version,p=e.toneMapping),h.layers.enableAll(),m.unshift(h,h.geometry,h.material,0,0,null))}function g(m,v){m.getRGB(fu,pM(e)),r.buffers.color.setClear(fu.r,fu.g,fu.b,v,n)}return{getClearColor:function(){return o},setClearColor:function(m,v=1){o.set(m),l=v,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,g(o,l)},render:f}}function VB(e,t,i,r){let s=e.getParameter(34921),a=r.isWebGL2?null:t.get("OES_vertex_array_object"),n=r.isWebGL2||a!==null,o={},l=m(null),h=l,c=!1;function d(P,U,W,k,F){let Z=!1;if(n){let X=g(k,W,U);h!==X&&(h=X,p(h.object)),Z=v(P,k,W,F),Z&&y(P,k,W,F)}else{let X=U.wireframe===!0;(h.geometry!==k.id||h.program!==W.id||h.wireframe!==X)&&(h.geometry=k.id,h.program=W.id,h.wireframe=X,Z=!0)}F!==null&&i.update(F,34963),(Z||c)&&(c=!1,S(P,U,W,k),F!==null&&e.bindBuffer(34963,i.get(F).buffer))}function u(){return r.isWebGL2?e.createVertexArray():a.createVertexArrayOES()}function p(P){return r.isWebGL2?e.bindVertexArray(P):a.bindVertexArrayOES(P)}function f(P){return r.isWebGL2?e.deleteVertexArray(P):a.deleteVertexArrayOES(P)}function g(P,U,W){let k=W.wireframe===!0,F=o[P.id];F===void 0&&(F={},o[P.id]=F);let Z=F[U.id];Z===void 0&&(Z={},F[U.id]=Z);let X=Z[k];return X===void 0&&(X=m(u()),Z[k]=X),X}function m(P){let U=[],W=[],k=[];for(let F=0;F=0){let $=F[q],Q=Z[q];if(Q===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&(Q=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&(Q=P.instanceColor)),$===void 0||$.attribute!==Q||Q&&$.data!==Q.data)return!0;X++}return h.attributesNum!==X||h.index!==k}function y(P,U,W,k){let F={},Z=U.attributes,X=0,G=W.getAttributes();for(let q in G)if(G[q].location>=0){let $=Z[q];$===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&($=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&($=P.instanceColor));let Q={};Q.attribute=$,$&&$.data&&(Q.data=$.data),F[q]=Q,X++}h.attributes=F,h.attributesNum=X,h.index=k}function x(){let P=h.newAttributes;for(let U=0,W=P.length;U=0){let $=F[G];if($===void 0&&(G==="instanceMatrix"&&P.instanceMatrix&&($=P.instanceMatrix),G==="instanceColor"&&P.instanceColor&&($=P.instanceColor)),$!==void 0){let Q=$.normalized,ee=$.itemSize,H=i.get($);if(H===void 0)continue;let he=H.buffer,re=H.type,te=H.bytesPerElement;if($.isInterleavedBufferAttribute){let ae=$.data,de=ae.stride,pe=$.offset;if(ae.isInstancedInterleavedBuffer){for(let be=0;be0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";A="mediump"}return A==="mediump"&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let n=typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext,o=i.precision!==void 0?i.precision:"highp",l=a(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);let h=n||t.has("WEBGL_draw_buffers"),c=i.logarithmicDepthBuffer===!0,d=e.getParameter(34930),u=e.getParameter(35660),p=e.getParameter(3379),f=e.getParameter(34076),g=e.getParameter(34921),m=e.getParameter(36347),v=e.getParameter(36348),y=e.getParameter(36349),x=u>0,w=n||t.has("OES_texture_float"),_=x&&w,b=n?e.getParameter(36183):0;return{isWebGL2:n,drawBuffers:h,getMaxAnisotropy:s,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:c,maxTextures:d,maxVertexTextures:u,maxTextureSize:p,maxCubemapSize:f,maxAttributes:g,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:y,vertexTextures:x,floatFragmentTextures:w,floatVertexTextures:_,maxSamples:b}}function HB(e){let t=this,i=null,r=0,s=!1,a=!1,n=new qr,o=new Di,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let p=d.length!==0||u||r!==0||s;return s=u,r=d.length,p},this.beginShadows=function(){a=!0,c(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(d,u){i=c(d,u,0)},this.setState=function(d,u,p){let f=d.clippingPlanes,g=d.clipIntersection,m=d.clipShadows,v=e.get(d);if(!s||f===null||f.length===0||a&&!m)a?c(null):h();else{let y=a?0:r,x=y*4,w=v.clippingState||null;l.value=w,w=c(f,u,x,p);for(let _=0;_!==x;++_)w[_]=i[_];v.clippingState=w,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=y}};function h(){l.value!==i&&(l.value=i,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function c(d,u,p,f){let g=d!==null?d.length:0,m=null;if(g!==0){if(m=l.value,f!==!0||m===null){let v=p+g*4,y=u.matrixWorldInverse;o.getNormalMatrix(y),(m===null||m.length0){let h=new sL(l.height/2);return h.fromEquirectangularTexture(e,n),t.set(n,h),n.addEventListener("dispose",s),i(h.texture,n.mapping)}else return null}}return n}function s(n){let o=n.target;o.removeEventListener("dispose",s);let l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function a(){t=new WeakMap}return{get:r,dispose:a}}var Xf=class extends bo{constructor(e=-1,t=1,i=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=i,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,i,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=i,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(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,a=i+e,n=r+t,o=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,n-=h*this.view.offsetY,o=n-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,n,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},ch=4,db=[.125,.215,.35,.446,.526,.582],Uo=20,Jm=new Xf,ub=new et,$m=null,Lo=(1+Math.sqrt(5))/2,zl=1/Lo,pb=[new M(1,1,1),new M(-1,1,1),new M(1,1,-1),new M(-1,1,-1),new M(0,Lo,zl),new M(0,Lo,-zl),new M(zl,0,Lo),new M(-zl,0,Lo),new M(Lo,zl,0),new M(-Lo,zl,0)],fb=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){$m=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=vb(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=gb(),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;e2?m:0,m,m),o.setRenderTarget(r),u&&o.render(d,s),o.render(e,s)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===al||e.mapping===nl;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=vb()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=gb());let s=r?this._cubemapMaterial:this._equirectMaterial,a=new Jt(this._lodPlanes[0],s),n=s.uniforms;n.envMap.value=e;let o=this._cubeSize;mu(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Jm)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;rUo&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Uo}`);let m=[],v=0;for(let b=0;by-ch?r-y+ch:0),_=4*(this._cubeSize-x);mu(t,w,_,3*x,2*x),o.setRenderTarget(t),o.render(c,Jm)}};function qB(e){let t=[],i=[],r=[],s=e,a=e-ch+1+db.length;for(let n=0;ne-ch?l=db[n-e+ch-1]:n===0&&(l=0),r.push(l);let h=1/(o-2),c=-h,d=1+h,u=[c,c,d,c,d,d,c,c,d,d,c,d],p=6,f=6,g=3,m=2,v=1,y=new Float32Array(g*f*p),x=new Float32Array(m*f*p),w=new Float32Array(v*f*p);for(let b=0;b2?0:-1,E=[A,S,0,A+2/3,S,0,A+2/3,S+1,0,A,S,0,A+2/3,S+1,0,A,S+1,0];y.set(E,g*f*b),x.set(u,m*f*b);let C=[b,b,b,b,b,b];w.set(C,v*f*b)}let _=new Ge;_.setAttribute("position",new tt(y,g)),_.setAttribute("uv",new tt(x,m)),_.setAttribute("faceIndex",new tt(w,v)),t.push(_),s>ch&&s--}return{lodPlanes:t,sizeLods:i,sigmas:r}}function mb(e,t,i){let r=new Pt(e,t,i);return r.texture.mapping=Rd,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function mu(e,t,i,r,s){e.viewport.set(t,i,r,s),e.scissor.set(t,i,r,s)}function XB(e,t,i){let r=new Float32Array(Uo),s=new M(0,1,0);return new Dt({name:"SphericalGaussianBlur",defines:{n:Uo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Wy(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:Oi,depthTest:!1,depthWrite:!1})}function gb(){return new Dt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Wy(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:Oi,depthTest:!1,depthWrite:!1})}function vb(){return new Dt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Wy(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:Oi,depthTest:!1,depthWrite:!1})}function Wy(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function YB(e){let t=new WeakMap,i=null;function r(o){if(o&&o.isTexture){let l=o.mapping,h=l===Dv||l===Iv,c=l===al||l===nl;if(h||c)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let d=t.get(o);return i===null&&(i=new fb(e)),d=h?i.fromEquirectangular(o,d):i.fromCubemap(o,d),t.set(o,d),d.texture}else{if(t.has(o))return t.get(o).texture;{let d=o.image;if(h&&d&&d.height>0||c&&d&&s(d)){i===null&&(i=new fb(e));let u=h?i.fromEquirectangular(o):i.fromCubemap(o);return t.set(o,u),o.addEventListener("dispose",a),u.texture}else return null}}}return o}function s(o){let l=0,h=6;for(let c=0;ct.maxTextureSize&&(D=Math.ceil(T/t.maxTextureSize),T=t.maxTextureSize);let O=new Float32Array(T*D*4*g),P=new cM(O,T,D,g);P.type=jt,P.needsUpdate=!0;let U=C*4;for(let W=0;W0)return e;let s=t*i,a=yb[s];if(a===void 0&&(a=new Float32Array(s),yb[s]=a),t!==0){r.toArray(a,0);for(let n=1,o=0;n!==t;++n)o+=i,e[n].toArray(a,o)}return a}function Wi(e,t){if(e.length!==t.length)return!1;for(let i=0,r=e.length;i":" "} ${o}: ${i[n]}`)}return r.join(` `)}function Q4(e){switch(e){case qs:return["Linear","( value )"];case gt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function Mb(e,t,i){let r=e.getShaderParameter(t,35713),s=e.getShaderInfoLog(t).trim();if(r&&s==="")return"";let a=/ERROR: 0:(\d+)/.exec(s);if(a){let n=parseInt(a[1]);return i.toUpperCase()+` `+s+` `+Y4(e.getShaderSource(t),n)}else return s}function Z4(e,t){let i=Q4(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function K4(e,t){let i;switch(t){case sR:i="Linear";break;case aR:i="Reinhard";break;case nR:i="OptimizedCineon";break;case oR:i="ACESFilmic";break;case lR:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function J4(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||e.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Uc).join(` `)}function $4(e){let t=[];for(let i in e){let r=e[i];r!==!1&&t.push("#define "+i+" "+r)}return t.join(` `)}function eF(e,t){let i={},r=e.getProgramParameter(t,35721);for(let s=0;s/gm;function Fv(e){return e.replace(tF,iF)}function iF(e,t){let i=yt[t];if(i===void 0)throw new Error("Can not resolve #include <"+t+">");return Fv(i)}var rF=/#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 Tb(e){return e.replace(rF,sF)}function sF(e,t,i,r){let s="";for(let a=parseInt(t);a0&&(m+=` `),v=[p,f].filter(Uc).join(` `),v.length>0&&(v+=` `)):(m=[Pb(i),"#define SHADER_NAME "+i.shaderName,f,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&i.flatShading===!1?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Uc).join(` `),v=[p,Pb(i),"#define SHADER_NAME "+i.shaderName,f,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==_a?"#define TONE_MAPPING":"",i.toneMapping!==_a?yt.tonemapping_pars_fragment:"",i.toneMapping!==_a?K4("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",yt.encodings_pars_fragment,Z4("linearToOutputTexel",i.outputEncoding),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",` `].filter(Uc).join(` `)),n=Fv(n),n=Eb(n,i),n=Cb(n,i),o=Fv(o),o=Eb(o,i),o=Cb(o,i),n=Tb(n),o=Tb(o),i.isWebGL2&&i.isRawShaderMaterial!==!0&&(y=`#version 300 es `,m=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+m,v=["#define varying in",i.glslVersion===Lv?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Lv?"":"#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(` `)+` `+v);let x=y+m+n,w=y+v+o,_=Ab(s,35633,x),b=Ab(s,35632,w);if(s.attachShader(g,_),s.attachShader(g,b),i.index0AttributeName!==void 0?s.bindAttribLocation(g,0,i.index0AttributeName):i.morphTargets===!0&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g),e.debug.checkShaderErrors){let E=s.getProgramInfoLog(g).trim(),C=s.getShaderInfoLog(_).trim(),T=s.getShaderInfoLog(b).trim(),D=!0,O=!0;if(s.getProgramParameter(g,35714)===!1){D=!1;let P=Mb(s,_,"vertex"),U=Mb(s,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(g,35715)+` Program Info Log: `+E+` `+P+` `+U)}else E!==""?console.warn("THREE.WebGLProgram: Program Info Log:",E):(C===""||T==="")&&(O=!1);O&&(this.diagnostics={runnable:D,programLog:E,vertexShader:{log:C,prefix:m},fragmentShader:{log:T,prefix:v}})}s.deleteShader(_),s.deleteShader(b);let A;this.getUniforms=function(){return A===void 0&&(A=new Sp(s,g)),A};let S;return this.getAttributes=function(){return S===void 0&&(S=eF(s,g)),S},this.destroy=function(){r.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.name=i.shaderName,this.id=X4++,this.cacheKey=t,this.usedTimes=1,this.program=g,this.vertexShader=_,this.fragmentShader=b,this}var dF=0,uF=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),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){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new pF(e),t.set(e,i)),i}},pF=class{constructor(e){this.id=dF++,this.code=e,this.usedTimes=0}};function fF(e,t,i,r,s,a,n){let o=new jy,l=new uF,h=[],c=s.isWebGL2,d=s.logarithmicDepthBuffer,u=s.vertexTextures,p=s.precision,f={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 g(S,E,C,T,D){let O=T.fog,P=D.geometry,U=S.isMeshStandardMaterial?T.environment:null,W=(S.isMeshStandardMaterial?i:t).get(S.envMap||U),k=W&&W.mapping===Rd?W.image.height:null,F=f[S.type];S.precision!==null&&(p=s.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));let Z=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,X=Z!==void 0?Z.length:0,G=0;P.morphAttributes.position!==void 0&&(G=1),P.morphAttributes.normal!==void 0&&(G=2),P.morphAttributes.color!==void 0&&(G=3);let q,$,Q,ee;if(F){let ae=ma[F];q=ae.vertexShader,$=ae.fragmentShader}else q=S.vertexShader,$=S.fragmentShader,l.update(S),Q=l.getVertexShaderID(S),ee=l.getFragmentShaderID(S);let H=e.getRenderTarget(),he=S.alphaTest>0,re=S.clearcoat>0,te=S.iridescence>0;return{isWebGL2:c,shaderID:F,shaderName:S.type,vertexShader:q,fragmentShader:$,defines:S.defines,customVertexShaderID:Q,customFragmentShaderID:ee,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,instancing:D.isInstancedMesh===!0,instancingColor:D.isInstancedMesh===!0&&D.instanceColor!==null,supportsVertexTextures:u,outputEncoding:H===null?e.outputEncoding:H.isXRRenderTarget===!0?H.texture.encoding:qs,map:!!S.map,matcap:!!S.matcap,envMap:!!W,envMapMode:W&&W.mapping,envMapCubeUVHeight:k,lightMap:!!S.lightMap,aoMap:!!S.aoMap,emissiveMap:!!S.emissiveMap,bumpMap:!!S.bumpMap,normalMap:!!S.normalMap,objectSpaceNormalMap:S.normalMapType===AR,tangentSpaceNormalMap:S.normalMapType===SR,decodeVideoTexture:!!S.map&&S.map.isVideoTexture===!0&&S.map.encoding===gt,clearcoat:re,clearcoatMap:re&&!!S.clearcoatMap,clearcoatRoughnessMap:re&&!!S.clearcoatRoughnessMap,clearcoatNormalMap:re&&!!S.clearcoatNormalMap,iridescence:te,iridescenceMap:te&&!!S.iridescenceMap,iridescenceThicknessMap:te&&!!S.iridescenceThicknessMap,displacementMap:!!S.displacementMap,roughnessMap:!!S.roughnessMap,metalnessMap:!!S.metalnessMap,specularMap:!!S.specularMap,specularIntensityMap:!!S.specularIntensityMap,specularColorMap:!!S.specularColorMap,opaque:S.transparent===!1&&S.blending===Jo,alphaMap:!!S.alphaMap,alphaTest:he,gradientMap:!!S.gradientMap,sheen:S.sheen>0,sheenColorMap:!!S.sheenColorMap,sheenRoughnessMap:!!S.sheenRoughnessMap,transmission:S.transmission>0,transmissionMap:!!S.transmissionMap,thicknessMap:!!S.thicknessMap,combine:S.combine,vertexTangents:!!S.normalMap&&!!P.attributes.tangent,vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,vertexUvs:!!S.map||!!S.bumpMap||!!S.normalMap||!!S.specularMap||!!S.alphaMap||!!S.emissiveMap||!!S.roughnessMap||!!S.metalnessMap||!!S.clearcoatMap||!!S.clearcoatRoughnessMap||!!S.clearcoatNormalMap||!!S.iridescenceMap||!!S.iridescenceThicknessMap||!!S.displacementMap||!!S.transmissionMap||!!S.thicknessMap||!!S.specularIntensityMap||!!S.specularColorMap||!!S.sheenColorMap||!!S.sheenRoughnessMap,uvsVertexOnly:!(S.map||S.bumpMap||S.normalMap||S.specularMap||S.alphaMap||S.emissiveMap||S.roughnessMap||S.metalnessMap||S.clearcoatNormalMap||S.iridescenceMap||S.iridescenceThicknessMap||S.transmission>0||S.transmissionMap||S.thicknessMap||S.specularIntensityMap||S.specularColorMap||S.sheen>0||S.sheenColorMap||S.sheenRoughnessMap)&&!!S.displacementMap,fog:!!O,useFog:S.fog===!0,fogExp2:O&&O.isFogExp2,flatShading:!!S.flatShading,sizeAttenuation:S.sizeAttenuation,logarithmicDepthBuffer:d,skinning:D.isSkinnedMesh===!0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:X,morphTextureStride:G,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numClippingPlanes:n.numPlanes,numClipIntersection:n.numIntersection,dithering:S.dithering,shadowMapEnabled:e.shadowMap.enabled&&C.length>0,shadowMapType:e.shadowMap.type,toneMapping:S.toneMapped?e.toneMapping:_a,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Ar,flipSided:S.side===rr,useDepthPacking:!!S.depthPacking,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:S.extensions&&S.extensions.derivatives,extensionFragDepth:S.extensions&&S.extensions.fragDepth,extensionDrawBuffers:S.extensions&&S.extensions.drawBuffers,extensionShaderTextureLOD:S.extensions&&S.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:S.customProgramCacheKey()}}function m(S){let E=[];if(S.shaderID?E.push(S.shaderID):(E.push(S.customVertexShaderID),E.push(S.customFragmentShaderID)),S.defines!==void 0)for(let C in S.defines)E.push(C),E.push(S.defines[C]);return S.isRawShaderMaterial===!1&&(v(E,S),y(E,S),E.push(e.outputEncoding)),E.push(S.customProgramCacheKey),E.join()}function v(S,E){S.push(E.precision),S.push(E.outputEncoding),S.push(E.envMapMode),S.push(E.envMapCubeUVHeight),S.push(E.combine),S.push(E.vertexUvs),S.push(E.fogExp2),S.push(E.sizeAttenuation),S.push(E.morphTargetsCount),S.push(E.morphAttributeCount),S.push(E.numDirLights),S.push(E.numPointLights),S.push(E.numSpotLights),S.push(E.numSpotLightMaps),S.push(E.numHemiLights),S.push(E.numRectAreaLights),S.push(E.numDirLightShadows),S.push(E.numPointLightShadows),S.push(E.numSpotLightShadows),S.push(E.numSpotLightShadowsWithMaps),S.push(E.shadowMapType),S.push(E.toneMapping),S.push(E.numClippingPlanes),S.push(E.numClipIntersection),S.push(E.depthPacking)}function y(S,E){o.disableAll(),E.isWebGL2&&o.enable(0),E.supportsVertexTextures&&o.enable(1),E.instancing&&o.enable(2),E.instancingColor&&o.enable(3),E.map&&o.enable(4),E.matcap&&o.enable(5),E.envMap&&o.enable(6),E.lightMap&&o.enable(7),E.aoMap&&o.enable(8),E.emissiveMap&&o.enable(9),E.bumpMap&&o.enable(10),E.normalMap&&o.enable(11),E.objectSpaceNormalMap&&o.enable(12),E.tangentSpaceNormalMap&&o.enable(13),E.clearcoat&&o.enable(14),E.clearcoatMap&&o.enable(15),E.clearcoatRoughnessMap&&o.enable(16),E.clearcoatNormalMap&&o.enable(17),E.iridescence&&o.enable(18),E.iridescenceMap&&o.enable(19),E.iridescenceThicknessMap&&o.enable(20),E.displacementMap&&o.enable(21),E.specularMap&&o.enable(22),E.roughnessMap&&o.enable(23),E.metalnessMap&&o.enable(24),E.gradientMap&&o.enable(25),E.alphaMap&&o.enable(26),E.alphaTest&&o.enable(27),E.vertexColors&&o.enable(28),E.vertexAlphas&&o.enable(29),E.vertexUvs&&o.enable(30),E.vertexTangents&&o.enable(31),E.uvsVertexOnly&&o.enable(32),S.push(o.mask),o.disableAll(),E.fog&&o.enable(0),E.useFog&&o.enable(1),E.flatShading&&o.enable(2),E.logarithmicDepthBuffer&&o.enable(3),E.skinning&&o.enable(4),E.morphTargets&&o.enable(5),E.morphNormals&&o.enable(6),E.morphColors&&o.enable(7),E.premultipliedAlpha&&o.enable(8),E.shadowMapEnabled&&o.enable(9),E.physicallyCorrectLights&&o.enable(10),E.doubleSided&&o.enable(11),E.flipSided&&o.enable(12),E.useDepthPacking&&o.enable(13),E.dithering&&o.enable(14),E.specularIntensityMap&&o.enable(15),E.specularColorMap&&o.enable(16),E.transmission&&o.enable(17),E.transmissionMap&&o.enable(18),E.thicknessMap&&o.enable(19),E.sheen&&o.enable(20),E.sheenColorMap&&o.enable(21),E.sheenRoughnessMap&&o.enable(22),E.decodeVideoTexture&&o.enable(23),E.opaque&&o.enable(24),S.push(o.mask)}function x(S){let E=f[S.type],C;if(E){let T=ma[E];C=Wh.clone(T.uniforms)}else C=S.uniforms;return C}function w(S,E){let C;for(let T=0,D=h.length;T0?r.push(v):p.transparent===!0?s.push(v):i.push(v)}function l(d,u,p,f,g,m){let v=n(d,u,p,f,g,m);p.transmission>0?r.unshift(v):p.transparent===!0?s.unshift(v):i.unshift(v)}function h(d,u){i.length>1&&i.sort(d||gF),r.length>1&&r.sort(u||Db),s.length>1&&s.sort(u||Db)}function c(){for(let d=t,u=e.length;d=a.length?(n=new Ib,a.push(n)):n=a[s],n}function i(){e=new WeakMap}return{get:t,dispose:i}}function yF(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new M,color:new et};break;case"SpotLight":i={position:new M,direction:new M,color:new et,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new M,color:new et,distance:0,decay:0};break;case"HemisphereLight":i={direction:new M,skyColor:new et,groundColor:new et};break;case"RectAreaLight":i={color:new et,position:new M,halfWidth:new M,halfHeight:new M};break}return e[t.id]=i,i}}}function xF(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let i;switch(t.type){case"DirectionalLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j};break;case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=i,i}}}var bF=0;function wF(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function _F(e,t){let i=new yF,r=xF(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let c=0;c<9;c++)s.probe.push(new M);let a=new M,n=new we,o=new we;function l(c,d){let u=0,p=0,f=0;for(let T=0;T<9;T++)s.probe[T].set(0,0,0);let g=0,m=0,v=0,y=0,x=0,w=0,_=0,b=0,A=0,S=0;c.sort(wF);let E=d!==!0?Math.PI:1;for(let T=0,D=c.length;T0&&(t.isWebGL2||e.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=Pe.LTC_FLOAT_1,s.rectAreaLTC2=Pe.LTC_FLOAT_2):e.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=Pe.LTC_HALF_1,s.rectAreaLTC2=Pe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=u,s.ambient[1]=p,s.ambient[2]=f;let C=s.hash;(C.directionalLength!==g||C.pointLength!==m||C.spotLength!==v||C.rectAreaLength!==y||C.hemiLength!==x||C.numDirectionalShadows!==w||C.numPointShadows!==_||C.numSpotShadows!==b||C.numSpotMaps!==A)&&(s.directional.length=g,s.spot.length=v,s.rectArea.length=y,s.point.length=m,s.hemi.length=x,s.directionalShadow.length=w,s.directionalShadowMap.length=w,s.pointShadow.length=_,s.pointShadowMap.length=_,s.spotShadow.length=b,s.spotShadowMap.length=b,s.directionalShadowMatrix.length=w,s.pointShadowMatrix.length=_,s.spotLightMatrix.length=b+A-S,s.spotLightMap.length=A,s.numSpotLightShadowsWithMaps=S,C.directionalLength=g,C.pointLength=m,C.spotLength=v,C.rectAreaLength=y,C.hemiLength=x,C.numDirectionalShadows=w,C.numPointShadows=_,C.numSpotShadows=b,C.numSpotMaps=A,s.version=bF++)}function h(c,d){let u=0,p=0,f=0,g=0,m=0,v=d.matrixWorldInverse;for(let y=0,x=c.length;y=o.length?(l=new Ob(e,t),o.push(l)):l=o[n],l}function s(){i=new WeakMap}return{get:r,dispose:s}}var xM=class extends Ld{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=_n,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}},AF=class extends Ld{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new M,this.nearDistance=1,this.farDistance=1e3,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.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},MF=`void main() { gl_Position = vec4( position, 1.0 ); }`,EF=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function CF(e,t,i){let r=new Hy,s=new j,a=new j,n=new ct,o=new xM({depthPacking:sM}),l=new AF,h={},c=i.maxTextureSize,d={[Ws]:rr,[rr]:Ws,[Ar]:Ar},u=new Dt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new j},radius:{value:4}},vertexShader:MF,fragmentShader:EF}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ge;f.setAttribute("position",new tt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new Jt(f,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Uy,this.render=function(w,_,b){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let A=e.getRenderTarget(),S=e.getActiveCubeFace(),E=e.getActiveMipmapLevel(),C=e.state;C.setBlending(Oi),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=w.length;Tc||s.y>c)&&(s.x>c&&(a.x=Math.floor(c/U.x),s.x=a.x*U.x,P.mapSize.x=a.x),s.y>c&&(a.y=Math.floor(c/U.y),s.y=a.y*U.y,P.mapSize.y=a.y)),P.map===null){let k=this.type!==Fc?{minFilter:_t,magFilter:_t}:{};P.map=new Pt(s.x,s.y,k),P.map.texture.name=O.name+".shadowMap",P.camera.updateProjectionMatrix()}e.setRenderTarget(P.map),e.clear();let W=P.getViewportCount();for(let k=0;k0||_.map&&_.alphaTest>0){let D=C.uuid,O=_.uuid,P=h[D];P===void 0&&(P={},h[D]=P);let U=P[O];U===void 0&&(U=C.clone(),P[O]=U),C=U}return C.visible=_.visible,C.wireframe=_.wireframe,E===Fc?C.side=_.shadowSide!==null?_.shadowSide:_.side:C.side=_.shadowSide!==null?_.shadowSide:d[_.side],C.alphaMap=_.alphaMap,C.alphaTest=_.alphaTest,C.map=_.map,C.clipShadows=_.clipShadows,C.clippingPlanes=_.clippingPlanes,C.clipIntersection=_.clipIntersection,C.displacementMap=_.displacementMap,C.displacementScale=_.displacementScale,C.displacementBias=_.displacementBias,C.wireframeLinewidth=_.wireframeLinewidth,C.linewidth=_.linewidth,b.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(b.matrixWorld),C.nearDistance=A,C.farDistance=S),C}function x(w,_,b,A,S){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&S===Fc)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,w.matrixWorld);let C=t.update(w),T=w.material;if(Array.isArray(T)){let D=C.groups;for(let O=0,P=D.length;O=1):F.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),W=k>=2);let Z=null,X={},G=e.getParameter(3088),q=e.getParameter(2978),$=new ct().fromArray(G),Q=new ct().fromArray(q);function ee(K,ge,_e){let Be=new Uint8Array(4),nt=e.createTexture();e.bindTexture(K,nt),e.texParameteri(K,10241,9728),e.texParameteri(K,10240,9728);for(let Et=0;Et<_e;Et++)e.texImage2D(ge+Et,0,6408,1,1,0,6408,5121,Be);return nt}let H={};H[3553]=ee(3553,3553,1),H[34067]=ee(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),he(2929),l.setFunc(Pv),Ve(!1),Ue(Ax),he(2884),Le(Oi);function he(K){u[K]!==!0&&(e.enable(K),u[K]=!0)}function re(K){u[K]!==!1&&(e.disable(K),u[K]=!1)}function te(K,ge){return p[K]!==ge?(e.bindFramebuffer(K,ge),p[K]=ge,r&&(K===36009&&(p[36160]=ge),K===36160&&(p[36009]=ge)),!0):!1}function ae(K,ge){let _e=g,Be=!1;if(K)if(_e=f.get(ge),_e===void 0&&(_e=[],f.set(ge,_e)),K.isWebGLMultipleRenderTargets){let nt=K.texture;if(_e.length!==nt.length||_e[0]!==36064){for(let Et=0,vi=nt.length;Et"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,g,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(V,z){return v?new OffscreenCanvas(V,z):dd("canvas")}function x(V,z,oe,Se){let R=1;if((V.width>Se||V.height>Se)&&(R=Se/Math.max(V.width,V.height)),R<1||z===!0)if(typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&V instanceof ImageBitmap){let Te=z?Gp:Math.floor,ke=Te(R*V.width),Oe=Te(R*V.height);g===void 0&&(g=y(ke,Oe));let ue=oe?y(ke,Oe):g;return ue.width=ke,ue.height=Oe,ue.getContext("2d").drawImage(V,0,0,ke,Oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+V.width+"x"+V.height+") to ("+ke+"x"+Oe+")."),ue}else return"data"in V&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+V.width+"x"+V.height+")."),V;return V}function w(V){return Bv(V.width)&&Bv(V.height)}function _(V){return o?!1:V.wrapS!==ai||V.wrapT!==ai||V.minFilter!==_t&&V.minFilter!==xt}function b(V,z){return V.generateMipmaps&&z&&V.minFilter!==_t&&V.minFilter!==xt}function A(V){e.generateMipmap(V)}function S(V,z,oe,Se,R=!1){if(o===!1)return z;if(V!==null){if(e[V]!==void 0)return e[V];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+V+"'")}let Te=z;return z===6403&&(oe===5126&&(Te=33326),oe===5131&&(Te=33325),oe===5121&&(Te=33321)),z===33319&&(oe===5126&&(Te=33328),oe===5131&&(Te=33327),oe===5121&&(Te=33323)),z===6408&&(oe===5126&&(Te=34836),oe===5131&&(Te=34842),oe===5121&&(Te=Se===gt&&R===!1?35907:32856),oe===32819&&(Te=32854),oe===32820&&(Te=32855)),(Te===33325||Te===33326||Te===33327||Te===33328||Te===34842||Te===34836)&&t.get("EXT_color_buffer_float"),Te}function E(V,z,oe){return b(V,oe)===!0||V.isFramebufferTexture&&V.minFilter!==_t&&V.minFilter!==xt?Math.log2(Math.max(z.width,z.height))+1:V.mipmaps!==void 0&&V.mipmaps.length>0?V.mipmaps.length:V.isCompressedTexture&&Array.isArray(V.image)?z.mipmaps.length:1}function C(V){return V===_t||V===Dx||V===Am?9728:9729}function T(V){let z=V.target;z.removeEventListener("dispose",T),O(z),z.isVideoTexture&&f.delete(z)}function D(V){let z=V.target;z.removeEventListener("dispose",D),U(z)}function O(V){let z=r.get(V);if(z.__webglInit===void 0)return;let oe=V.source,Se=m.get(oe);if(Se){let R=Se[z.__cacheKey];R.usedTimes--,R.usedTimes===0&&P(V),Object.keys(Se).length===0&&m.delete(oe)}r.remove(V)}function P(V){let z=r.get(V);e.deleteTexture(z.__webglTexture);let oe=V.source,Se=m.get(oe);delete Se[z.__cacheKey],n.memory.textures--}function U(V){let z=V.texture,oe=r.get(V),Se=r.get(z);if(Se.__webglTexture!==void 0&&(e.deleteTexture(Se.__webglTexture),n.memory.textures--),V.depthTexture&&V.depthTexture.dispose(),V.isWebGLCubeRenderTarget)for(let R=0;R<6;R++)e.deleteFramebuffer(oe.__webglFramebuffer[R]),oe.__webglDepthbuffer&&e.deleteRenderbuffer(oe.__webglDepthbuffer[R]);else{if(e.deleteFramebuffer(oe.__webglFramebuffer),oe.__webglDepthbuffer&&e.deleteRenderbuffer(oe.__webglDepthbuffer),oe.__webglMultisampledFramebuffer&&e.deleteFramebuffer(oe.__webglMultisampledFramebuffer),oe.__webglColorRenderbuffer)for(let R=0;R=l&&console.warn("THREE.WebGLTextures: Trying to use "+V+" texture units while this GPU supports only "+l),W+=1,V}function Z(V){let z=[];return z.push(V.wrapS),z.push(V.wrapT),z.push(V.wrapR||0),z.push(V.magFilter),z.push(V.minFilter),z.push(V.anisotropy),z.push(V.internalFormat),z.push(V.format),z.push(V.type),z.push(V.generateMipmaps),z.push(V.premultiplyAlpha),z.push(V.flipY),z.push(V.unpackAlignment),z.push(V.encoding),z.join()}function X(V,z){let oe=r.get(V);if(V.isVideoTexture&&Ye(V),V.isRenderTargetTexture===!1&&V.version>0&&oe.__version!==V.version){let Se=V.image;if(Se===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Se.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{re(oe,V,z);return}}i.bindTexture(3553,oe.__webglTexture,33984+z)}function G(V,z){let oe=r.get(V);if(V.version>0&&oe.__version!==V.version){re(oe,V,z);return}i.bindTexture(35866,oe.__webglTexture,33984+z)}function q(V,z){let oe=r.get(V);if(V.version>0&&oe.__version!==V.version){re(oe,V,z);return}i.bindTexture(32879,oe.__webglTexture,33984+z)}function $(V,z){let oe=r.get(V);if(V.version>0&&oe.__version!==V.version){te(oe,V,z);return}i.bindTexture(34067,oe.__webglTexture,33984+z)}let Q={[nn]:10497,[ai]:33071,[Ov]:33648},ee={[_t]:9728,[Dx]:9984,[Am]:9986,[xt]:9729,[hR]:9985,[Ch]:9987};function H(V,z,oe){if(oe?(e.texParameteri(V,10242,Q[z.wrapS]),e.texParameteri(V,10243,Q[z.wrapT]),(V===32879||V===35866)&&e.texParameteri(V,32882,Q[z.wrapR]),e.texParameteri(V,10240,ee[z.magFilter]),e.texParameteri(V,10241,ee[z.minFilter])):(e.texParameteri(V,10242,33071),e.texParameteri(V,10243,33071),(V===32879||V===35866)&&e.texParameteri(V,32882,33071),(z.wrapS!==ai||z.wrapT!==ai)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(V,10240,C(z.magFilter)),e.texParameteri(V,10241,C(z.minFilter)),z.minFilter!==_t&&z.minFilter!==xt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let Se=t.get("EXT_texture_filter_anisotropic");if(z.magFilter===_t||z.minFilter!==Am&&z.minFilter!==Ch||z.type===jt&&t.has("OES_texture_float_linear")===!1||o===!1&&z.type===mn&&t.has("OES_texture_half_float_linear")===!1)return;(z.anisotropy>1||r.get(z).__currentAnisotropy)&&(e.texParameterf(V,Se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(z.anisotropy,s.getMaxAnisotropy())),r.get(z).__currentAnisotropy=z.anisotropy)}}function he(V,z){let oe=!1;V.__webglInit===void 0&&(V.__webglInit=!0,z.addEventListener("dispose",T));let Se=z.source,R=m.get(Se);R===void 0&&(R={},m.set(Se,R));let Te=Z(z);if(Te!==V.__cacheKey){R[Te]===void 0&&(R[Te]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,oe=!0),R[Te].usedTimes++;let ke=R[V.__cacheKey];ke!==void 0&&(R[V.__cacheKey].usedTimes--,ke.usedTimes===0&&P(z)),V.__cacheKey=Te,V.__webglTexture=R[Te].texture}return oe}function re(V,z,oe){let Se=3553;(z.isDataArrayTexture||z.isCompressedArrayTexture)&&(Se=35866),z.isData3DTexture&&(Se=32879);let R=he(V,z),Te=z.source;i.bindTexture(Se,V.__webglTexture,33984+oe);let ke=r.get(Te);if(Te.version!==ke.__version||R===!0){i.activeTexture(33984+oe),e.pixelStorei(37440,z.flipY),e.pixelStorei(37441,z.premultiplyAlpha),e.pixelStorei(3317,z.unpackAlignment),e.pixelStorei(37443,0);let Oe=_(z)&&w(z.image)===!1,ue=x(z.image,Oe,!1,c);ue=qe(z,ue);let je=w(ue)||o,ze=a.convert(z.format,z.encoding),Xe=a.convert(z.type),it=S(z.internalFormat,ze,Xe,z.encoding,z.isVideoTexture);H(Se,z,je);let Qe,Ke=z.mipmaps,qt=o&&z.isVideoTexture!==!0,oi=ke.__version===void 0||R===!0,K=E(z,ue,je);if(z.isDepthTexture)it=6402,o?z.type===jt?it=36012:z.type===on?it=33190:z.type===$o?it=35056:it=33189:z.type===jt&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),z.format===el&&it===6402&&z.type!==eM&&z.type!==on&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),z.type=on,Xe=a.convert(z.type)),z.format===ol&&it===6402&&(it=34041,z.type!==$o&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),z.type=$o,Xe=a.convert(z.type))),oi&&(qt?i.texStorage2D(3553,1,it,ue.width,ue.height):i.texImage2D(3553,0,it,ue.width,ue.height,0,ze,Xe,null));else if(z.isDataTexture)if(Ke.length>0&&je){qt&&oi&&i.texStorage2D(3553,K,it,Ke[0].width,Ke[0].height);for(let ge=0,_e=Ke.length;ge<_e;ge++)Qe=Ke[ge],qt?i.texSubImage2D(3553,ge,0,0,Qe.width,Qe.height,ze,Xe,Qe.data):i.texImage2D(3553,ge,it,Qe.width,Qe.height,0,ze,Xe,Qe.data);z.generateMipmaps=!1}else qt?(oi&&i.texStorage2D(3553,K,it,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ue.width,ue.height,ze,Xe,ue.data)):i.texImage2D(3553,0,it,ue.width,ue.height,0,ze,Xe,ue.data);else if(z.isCompressedTexture)if(z.isCompressedArrayTexture){qt&&oi&&i.texStorage3D(35866,K,it,Ke[0].width,Ke[0].height,ue.depth);for(let ge=0,_e=Ke.length;ge<_e;ge++)Qe=Ke[ge],z.format!==ni?ze!==null?qt?i.compressedTexSubImage3D(35866,ge,0,0,0,Qe.width,Qe.height,ue.depth,ze,Qe.data,0,0):i.compressedTexImage3D(35866,ge,it,Qe.width,Qe.height,ue.depth,0,Qe.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qt?i.texSubImage3D(35866,ge,0,0,0,Qe.width,Qe.height,ue.depth,ze,Xe,Qe.data):i.texImage3D(35866,ge,it,Qe.width,Qe.height,ue.depth,0,ze,Xe,Qe.data)}else{qt&&oi&&i.texStorage2D(3553,K,it,Ke[0].width,Ke[0].height);for(let ge=0,_e=Ke.length;ge<_e;ge++)Qe=Ke[ge],z.format!==ni?ze!==null?qt?i.compressedTexSubImage2D(3553,ge,0,0,Qe.width,Qe.height,ze,Qe.data):i.compressedTexImage2D(3553,ge,it,Qe.width,Qe.height,0,Qe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qt?i.texSubImage2D(3553,ge,0,0,Qe.width,Qe.height,ze,Xe,Qe.data):i.texImage2D(3553,ge,it,Qe.width,Qe.height,0,ze,Xe,Qe.data)}else if(z.isDataArrayTexture)qt?(oi&&i.texStorage3D(35866,K,it,ue.width,ue.height,ue.depth),i.texSubImage3D(35866,0,0,0,0,ue.width,ue.height,ue.depth,ze,Xe,ue.data)):i.texImage3D(35866,0,it,ue.width,ue.height,ue.depth,0,ze,Xe,ue.data);else if(z.isData3DTexture)qt?(oi&&i.texStorage3D(32879,K,it,ue.width,ue.height,ue.depth),i.texSubImage3D(32879,0,0,0,0,ue.width,ue.height,ue.depth,ze,Xe,ue.data)):i.texImage3D(32879,0,it,ue.width,ue.height,ue.depth,0,ze,Xe,ue.data);else if(z.isFramebufferTexture){if(oi)if(qt)i.texStorage2D(3553,K,it,ue.width,ue.height);else{let ge=ue.width,_e=ue.height;for(let Be=0;Be>=1,_e>>=1}}else if(Ke.length>0&&je){qt&&oi&&i.texStorage2D(3553,K,it,Ke[0].width,Ke[0].height);for(let ge=0,_e=Ke.length;ge<_e;ge++)Qe=Ke[ge],qt?i.texSubImage2D(3553,ge,0,0,ze,Xe,Qe):i.texImage2D(3553,ge,it,ze,Xe,Qe);z.generateMipmaps=!1}else qt?(oi&&i.texStorage2D(3553,K,it,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ze,Xe,ue)):i.texImage2D(3553,0,it,ze,Xe,ue);b(z,je)&&A(Se),ke.__version=Te.version,z.onUpdate&&z.onUpdate(z)}V.__version=z.version}function te(V,z,oe){if(z.image.length!==6)return;let Se=he(V,z),R=z.source;i.bindTexture(34067,V.__webglTexture,33984+oe);let Te=r.get(R);if(R.version!==Te.__version||Se===!0){i.activeTexture(33984+oe),e.pixelStorei(37440,z.flipY),e.pixelStorei(37441,z.premultiplyAlpha),e.pixelStorei(3317,z.unpackAlignment),e.pixelStorei(37443,0);let ke=z.isCompressedTexture||z.image[0].isCompressedTexture,Oe=z.image[0]&&z.image[0].isDataTexture,ue=[];for(let ge=0;ge<6;ge++)!ke&&!Oe?ue[ge]=x(z.image[ge],!1,!0,h):ue[ge]=Oe?z.image[ge].image:z.image[ge],ue[ge]=qe(z,ue[ge]);let je=ue[0],ze=w(je)||o,Xe=a.convert(z.format,z.encoding),it=a.convert(z.type),Qe=S(z.internalFormat,Xe,it,z.encoding),Ke=o&&z.isVideoTexture!==!0,qt=Te.__version===void 0||Se===!0,oi=E(z,je,ze);H(34067,z,ze);let K;if(ke){Ke&&qt&&i.texStorage2D(34067,oi,Qe,je.width,je.height);for(let ge=0;ge<6;ge++){K=ue[ge].mipmaps;for(let _e=0;_e0&&oi++,i.texStorage2D(34067,oi,Qe,ue[0].width,ue[0].height));for(let ge=0;ge<6;ge++)if(Oe){Ke?i.texSubImage2D(34069+ge,0,0,0,ue[ge].width,ue[ge].height,Xe,it,ue[ge].data):i.texImage2D(34069+ge,0,Qe,ue[ge].width,ue[ge].height,0,Xe,it,ue[ge].data);for(let _e=0;_e=34069&&R<=34074)&&e.framebufferTexture2D(36160,Se,R,r.get(oe).__webglTexture,0),i.bindFramebuffer(36160,null)}function de(V,z,oe){if(e.bindRenderbuffer(36161,V),z.depthBuffer&&!z.stencilBuffer){let Se=33189;if(oe||Ee(z)){let R=z.depthTexture;R&&R.isDepthTexture&&(R.type===jt?Se=36012:R.type===on&&(Se=33190));let Te=Ce(z);Ee(z)?u.renderbufferStorageMultisampleEXT(36161,Te,Se,z.width,z.height):e.renderbufferStorageMultisample(36161,Te,Se,z.width,z.height)}else e.renderbufferStorage(36161,Se,z.width,z.height);e.framebufferRenderbuffer(36160,36096,36161,V)}else if(z.depthBuffer&&z.stencilBuffer){let Se=Ce(z);oe&&Ee(z)===!1?e.renderbufferStorageMultisample(36161,Se,35056,z.width,z.height):Ee(z)?u.renderbufferStorageMultisampleEXT(36161,Se,35056,z.width,z.height):e.renderbufferStorage(36161,34041,z.width,z.height),e.framebufferRenderbuffer(36160,33306,36161,V)}else{let Se=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let R=0;R0&&Ee(V)===!1){let Oe=Te?z:[z];oe.__webglMultisampledFramebuffer=e.createFramebuffer(),oe.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,oe.__webglMultisampledFramebuffer);for(let ue=0;ue0&&Ee(V)===!1){let z=V.isWebGLMultipleRenderTargets?V.texture:[V.texture],oe=V.width,Se=V.height,R=16384,Te=[],ke=V.stencilBuffer?33306:36096,Oe=r.get(V),ue=V.isWebGLMultipleRenderTargets===!0;if(ue)for(let je=0;je0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&z.__useRenderToTexture!==!1}function Ye(V){let z=n.render.frame;f.get(V)!==z&&(f.set(V,z),V.update())}function qe(V,z){let oe=V.encoding,Se=V.format,R=V.type;return V.isCompressedTexture===!0||V.isVideoTexture===!0||V.format===zv||oe!==qs&&(oe===gt?o===!1?t.has("EXT_sRGB")===!0&&Se===ni?(V.format=zv,V.minFilter=xt,V.generateMipmaps=!1):z=lM.sRGBToLinear(z):(Se!==ni||R!==Er)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",oe)),z}this.allocateTextureUnit=F,this.resetTextureUnits=k,this.setTexture2D=X,this.setTexture2DArray=G,this.setTexture3D=q,this.setTextureCube=$,this.rebindTextures=Le,this.setupRenderTarget=Me,this.updateRenderTargetMipmap=Ve,this.updateMultisampleRenderTarget=Ue,this.setupDepthRenderbuffer=be,this.setupFrameBufferTexture=ae,this.useMultisampledRTT=Ee}function DF(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===Er)return 5121;if(a===pR)return 32819;if(a===fR)return 32820;if(a===cR)return 5120;if(a===dR)return 5122;if(a===eM)return 5123;if(a===uR)return 5124;if(a===on)return 5125;if(a===jt)return 5126;if(a===mn)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===mR)return 6406;if(a===ni)return 6408;if(a===gR)return 6409;if(a===vR)return 6410;if(a===el)return 6402;if(a===ol)return 34041;if(a===zv)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===wp)return 6403;if(a===yR)return 36244;if(a===Up)return 33319;if(a===xR)return 33320;if(a===tM)return 36249;if(a===Mm||a===Em||a===Cm||a===Tm)if(n===gt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===Mm)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Em)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===Cm)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===Tm)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===Mm)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Em)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===Cm)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===Tm)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===Ix||a===Ox||a===Rx||a===Lx)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===Ix)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Ox)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===Rx)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===Lx)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===bR)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===zx||a===Bx)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===zx)return n===gt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===Bx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===Fx||a===Ux||a===Nx||a===kx||a===Vx||a===jx||a===Gx||a===Hx||a===Wx||a===qx||a===Xx||a===Yx||a===Qx||a===Zx)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===Fx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===Ux)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===Nx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===kx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===Vx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===jx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===Gx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===Hx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===Wx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===qx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===Xx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===Yx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===Qx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===Zx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Pm)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===Pm)return n===gt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===wR||a===Kx||a===Jx||a===$x)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===Pm)return o.COMPRESSED_RED_RGTC1_EXT;if(a===Kx)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===Jx)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===$x)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===$o?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[a]!==void 0?e[a]:null}return{convert:s}}var IF=class extends _r{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},hn=class extends kt{constructor(){super(),this.isGroup=!0,this.type="Group"}},OF={type:"move"},tg=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new hn,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 hn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new M,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new M),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new hn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new M,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new M),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){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let f of e.hand.values()){let g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}let h=l.joints["index-finger-tip"],c=l.joints["thumb-tip"],d=h.position.distanceTo(c.position),u=.02,p=.005;l.inputState.pinching&&d>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=u-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(OF)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new hn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Ph=class extends ci{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:el,h!==el&&h!==ol)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===el&&(i=on),i===void 0&&h===ol&&(i=$o),super(null,r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:_t,this.minFilter=o!==void 0?o:_t,this.flipY=!1,this.generateMipmaps=!1}},RF=class extends yr{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,c=null,d=null,u=null,p=null,f=t.getContextAttributes(),g=null,m=null,v=[],y=[],x=new Set,w=new Map,_=new _r;_.layers.enable(1),_.viewport=new ct;let b=new _r;b.layers.enable(2),b.viewport=new ct;let A=[_,b],S=new IF;S.layers.enable(1),S.layers.enable(2);let E=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let q=v[G];return q===void 0&&(q=new tg,v[G]=q),q.getTargetRaySpace()},this.getControllerGrip=function(G){let q=v[G];return q===void 0&&(q=new tg,v[G]=q),q.getGripSpace()},this.getHand=function(G){let q=v[G];return q===void 0&&(q=new tg,v[G]=q),q.getHandSpace()};function T(G){let q=y.indexOf(G.inputSource);if(q===-1)return;let $=v[q];$!==void 0&&$.dispatchEvent({type:G.type,data:G.inputSource})}function D(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",O);for(let G=0;G=0&&(y[Q]=null,v[Q].disconnect($))}for(let q=0;q=y.length){y.push($),Q=H;break}else if(y[H]===null){y[H]=$,Q=H;break}if(Q===-1)break}let ee=v[Q];ee&&ee.connect($)}}let P=new M,U=new M;function W(G,q,$){P.setFromMatrixPosition(q.matrixWorld),U.setFromMatrixPosition($.matrixWorld);let Q=P.distanceTo(U),ee=q.projectionMatrix.elements,H=$.projectionMatrix.elements,he=ee[14]/(ee[10]-1),re=ee[14]/(ee[10]+1),te=(ee[9]+1)/ee[5],ae=(ee[9]-1)/ee[5],de=(ee[8]-1)/ee[0],pe=(H[8]+1)/H[0],be=he*de,Le=he*pe,Me=Q/(-de+pe),Ve=Me*-de;q.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(Ve),G.translateZ(Me),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Ue=he+Me,Ce=re+Me,Ee=be-Ve,Ye=Le+(Q-Ve),qe=te*re/Ce*Ue,V=ae*re/Ce*Ue;G.projectionMatrix.makePerspective(Ee,Ye,qe,V,Ue,Ce)}function k(G,q){q===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(q.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(r===null)return;S.near=b.near=_.near=G.near,S.far=b.far=_.far=G.far,(E!==S.near||C!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),E=S.near,C=S.far);let q=G.parent,$=S.cameras;k(S,q);for(let ee=0;ee<$.length;ee++)k($[ee],q);S.matrixWorld.decompose(S.position,S.quaternion,S.scale),G.matrix.copy(S.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let Q=G.children;for(let ee=0,H=Q.length;eeee&&(w.set(Q,Q.lastChangedTime),i.dispatchEvent({type:"planechanged",data:Q}))}}p=null}let X=new fM;X.setAnimationLoop(Z),this.setAnimationLoop=function(G){F=G},this.dispose=function(){}}};function LF(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,pM(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),c(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),d(g,m),m.isMeshPhysicalMaterial&&u(g,m,x)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&n(g,m)):m.isPointsMaterial?o(g,m,v,y):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===rr&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===rr&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let w=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*w}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uv2Transform.value.copy(x.matrix))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function n(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,v,y){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=y*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function c(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function d(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function u(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===rr&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function zF(e,t,i,r){let s={},a={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let w=x.program;r.uniformBlockBinding(y,w)}function h(y,x){let w=s[y.id];w===void 0&&(f(y),w=c(y),s[y.id]=w,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let b=t.render.frame;a[y.id]!==b&&(u(y),a[y.id]=b)}function c(y){let x=d();y.__bindingPointIndex=x;let w=e.createBuffer(),_=y.__size,b=y.usage;return e.bindBuffer(35345,w),e.bufferData(35345,_,b),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,w),w}function d(){for(let y=0;y0){b=w%_;let D=_-b;b!==0&&D-C.boundary<0&&(w+=_-b,E.__offset=w)}w+=C.storage}return b=w%_,b>0&&(w+=_-b),y.__size=w,y.__cache={},this}function g(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function m(y){let x=y.target;x.removeEventListener("dispose",m);let w=n.indexOf(x.__bindingPointIndex);n.splice(w,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete a[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);n=[],s={},a={}}return{bind:l,update:h,dispose:v}}function BF(){let e=dd("canvas");return e.style.display="block",e}function bM(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:BF(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,a=e.antialias!==void 0?e.antialias:!1,n=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,c;i!==null?c=i.getContextAttributes().alpha:c=e.alpha!==void 0?e.alpha:!1;let d=null,u=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=qs,this.physicallyCorrectLights=!1,this.toneMapping=_a,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,x=null,w=-1,_=null,b=new ct,A=new ct,S=null,E=t.width,C=t.height,T=1,D=null,O=null,P=new ct(0,0,E,C),U=new ct(0,0,E,C),W=!1,k=new Hy,F=!1,Z=!1,X=null,G=new we,q=new j,$=new M,Q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ee(){return x===null?T:1}let H=i;function he(N,le){for(let me=0;me0?u=f[f.length-1]:u=null,p.pop(),p.length>0?d=p[p.length-1]:d=null};function vi(N,le,me,se){if(N.visible===!1)return;if(N.layers.test(le.layers)){if(N.isGroup)me=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(le);else if(N.isLight)u.pushLight(N),N.castShadow&&u.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||k.intersectsSprite(N)){se&&$.setFromMatrixPosition(N.matrixWorld).applyMatrix4(G);let He=Ce.update(N),dt=N.material;dt.visible&&d.push(N,He,dt,me,$.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==de.render.frame&&(N.skeleton.update(),N.skeleton.frame=de.render.frame),!N.frustumCulled||k.intersectsObject(N))){se&&$.setFromMatrixPosition(N.matrixWorld).applyMatrix4(G);let He=Ce.update(N),dt=N.material;if(Array.isArray(dt)){let pt=He.groups;for(let Je=0,zt=pt.length;Je0&&Ks(ve,le,me),se&&ae.viewport(b.copy(se)),ve.length>0&&$t(ve,le,me),He.length>0&&$t(He,le,me),dt.length>0&&$t(dt,le,me),ae.buffers.depth.setTest(!0),ae.buffers.depth.setMask(!0),ae.buffers.color.setMask(!0),ae.setPolygonOffset(!1)}function Ks(N,le,me){let se=te.isWebGL2;X===null&&(X=new Pt(1,1,{generateMipmaps:!0,type:re.has("EXT_color_buffer_half_float")?mn:Er,minFilter:Ch,samples:se&&a===!0?4:0})),g.getDrawingBufferSize(q),se?X.setSize(q.x,q.y):X.setSize(Gp(q.x),Gp(q.y));let ve=g.getRenderTarget();g.setRenderTarget(X),g.clear();let He=g.toneMapping;g.toneMapping=_a,$t(N,le,me),g.toneMapping=He,be.updateMultisampleRenderTarget(X),be.updateRenderTargetMipmap(X),g.setRenderTarget(ve)}function $t(N,le,me){let se=le.isScene===!0?le.overrideMaterial:null;for(let ve=0,He=N.length;ve0&&be.useMultisampledRTT(N)===!1?ve=pe.get(N).__webglMultisampledFramebuffer:ve=zt,b.copy(N.viewport),A.copy(N.scissor),S=N.scissorTest}else b.copy(P).multiplyScalar(T).floor(),A.copy(U).multiplyScalar(T).floor(),S=W;if(ae.bindFramebuffer(36160,ve)&&te.drawBuffers&&se&&ae.drawBuffers(N,ve),ae.viewport(b),ae.scissor(A),ae.setScissorTest(S),He){let pt=pe.get(N.texture);H.framebufferTexture2D(36160,36064,34069+le,pt.__webglTexture,me)}else if(dt){let pt=pe.get(N.texture),Je=le||0;H.framebufferTextureLayer(36160,36064,pt.__webglTexture,me||0,Je)}w=-1},this.readRenderTargetPixels=function(N,le,me,se,ve,He,dt){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=pe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&dt!==void 0&&(pt=pt[dt]),pt){ae.bindFramebuffer(36160,pt);try{let Je=N.texture,zt=Je.format,bt=Je.type;if(zt!==ni&&Oe.convert(zt)!==H.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let wt=bt===mn&&(re.has("EXT_color_buffer_half_float")||te.isWebGL2&&re.has("EXT_color_buffer_float"));if(bt!==Er&&Oe.convert(bt)!==H.getParameter(35738)&&!(bt===jt&&(te.isWebGL2||re.has("OES_texture_float")||re.has("WEBGL_color_buffer_float")))&&!wt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=N.width-se&&me>=0&&me<=N.height-ve&&H.readPixels(le,me,se,ve,Oe.convert(zt),Oe.convert(bt),He)}finally{let Je=x!==null?pe.get(x).__webglFramebuffer:null;ae.bindFramebuffer(36160,Je)}}},this.readRenderTargetPixelsAsync=async function(N,le,me,se,ve,He,dt){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let pt=pe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&dt!==void 0&&(pt=pt[dt]),pt){let Je=N.texture,zt=Je.format,bt=Je.type;if(le>=0&&le<=N.width-se&&me>=0&&me<=N.height-ve){ae.bindFramebuffer(H.FRAMEBUFFER,pt);let wt=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,wt),H.bufferData(H.PIXEL_PACK_BUFFER,He.byteLength,H.STREAM_READ),H.readPixels(le,me,se,ve,Oe.convert(zt),Oe.convert(bt),0);let vt=x!==null?pe.get(x).__webglFramebuffer:null;ae.bindFramebuffer(H.FRAMEBUFFER,vt);let zi=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await VR(H,zi,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,wt),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,He),H.deleteBuffer(wt),H.deleteSync(zi),He}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(N,le,me=0){let se=Math.pow(2,-me),ve=Math.floor(le.image.width*se),He=Math.floor(le.image.height*se);be.setTexture2D(le,0),H.copyTexSubImage2D(3553,me,0,0,N.x,N.y,ve,He),ae.unbindTexture()},this.copyTextureToTexture=function(N,le,me,se=0){let ve=le.image.width,He=le.image.height,dt=Oe.convert(me.format),pt=Oe.convert(me.type);be.setTexture2D(me,0),H.pixelStorei(37440,me.flipY),H.pixelStorei(37441,me.premultiplyAlpha),H.pixelStorei(3317,me.unpackAlignment),le.isDataTexture?H.texSubImage2D(3553,se,N.x,N.y,ve,He,dt,pt,le.image.data):le.isCompressedTexture?H.compressedTexSubImage2D(3553,se,N.x,N.y,le.mipmaps[0].width,le.mipmaps[0].height,dt,le.mipmaps[0].data):H.texSubImage2D(3553,se,N.x,N.y,dt,pt,le.image),se===0&&me.generateMipmaps&&H.generateMipmap(3553),ae.unbindTexture()},this.copyTextureToTexture3D=function(N,le,me,se,ve=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let He=N.max.x-N.min.x+1,dt=N.max.y-N.min.y+1,pt=N.max.z-N.min.z+1,Je=Oe.convert(se.format),zt=Oe.convert(se.type),bt;if(se.isData3DTexture)be.setTexture3D(se,0),bt=32879;else if(se.isDataArrayTexture)be.setTexture2DArray(se,0),bt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,se.flipY),H.pixelStorei(37441,se.premultiplyAlpha),H.pixelStorei(3317,se.unpackAlignment);let wt=H.getParameter(3314),vt=H.getParameter(32878),zi=H.getParameter(3316),ns=H.getParameter(3315),Ra=H.getParameter(32877),li=me.isCompressedTexture?me.mipmaps[0]:me.image;H.pixelStorei(3314,li.width),H.pixelStorei(32878,li.height),H.pixelStorei(3316,N.min.x),H.pixelStorei(3315,N.min.y),H.pixelStorei(32877,N.min.z),me.isDataTexture||me.isData3DTexture?H.texSubImage3D(bt,ve,le.x,le.y,le.z,He,dt,pt,Je,zt,li.data):me.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(bt,ve,le.x,le.y,le.z,He,dt,pt,Je,li.data)):H.texSubImage3D(bt,ve,le.x,le.y,le.z,He,dt,pt,Je,zt,li),H.pixelStorei(3314,wt),H.pixelStorei(32878,vt),H.pixelStorei(3316,zi),H.pixelStorei(3315,ns),H.pixelStorei(32877,Ra),ve===0&&se.generateMipmaps&&H.generateMipmap(bt),ae.unbindTexture()},this.initRenderTarget=function(N){pe.get(N).__webglFramebuffer===void 0&&be.setupRenderTarget(N)},this.initTexture=function(N){N.isCubeTexture?be.setTextureCube(N,0):N.isData3DTexture?be.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?be.setTexture2DArray(N,0):be.setTexture2D(N,0),ae.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,ae.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var FF=class extends bM{};FF.prototype.isWebGL1Renderer=!0;var wM=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new et(e),this.near=t,this.far=i}clone(){return new wM(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Jr=class extends kt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.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,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let 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}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},UF=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Rv,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ws()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;ro)continue;d.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(d);_e.far||t.push({distance:_,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,a.start),m=Math.min(f.count,a.start+a.count);for(let v=g,y=m-1;vo)continue;d.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(d);xe.far||t.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},GF=class extends ci{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Da=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,a;t?a=t:a=e*i[s-1];let n=0,o=s-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-a,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===a)return r/(s-1);let h=i[r],c=i[r+1]-h,d=(a-h)/c;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),a=this.getPoint(r),n=t||(s.isVector2?new j:new M);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new M,r=[],s=[],a=[],n=new M,o=new we;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new M)}s[0]=new M,a[0]=new M;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),d<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),a[u]=a[u-1].clone(),n.crossVectors(r[u-1],r[u]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(Ti(r[u-1].dot(r[u]),-1,1));s[u].applyMatrix4(o.makeRotationAxis(n,p))}a[u].crossVectors(r[u],s[u])}if(t===!0){let u=Math.acos(Ti(s[0].dot(s[e]),-1,1));u/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(u=-u);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),a[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Qf=class extends Da{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new j,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(n)/s)+1)*s:o===0&&n===s-1&&(n=s-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%s]:(yu.subVectors(r[0],r[1]).add(r[0]),l=yu);let c=r[n%s],d=r[(n+1)%s];if(this.closed||n+2r.length-2?r.length-1:a+1],c=r[a>r.length-3?r.length-1:a+2];return i.set(Vb(n,o.x,l.x,h.x,c.x),Vb(n,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){let a=r[s]-i,n=this.curves[s],o=n.getLength(),l=o===0?0:1-a/o;return n.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},MM=class extends Ge{constructor(e=[new j(0,-.5),new j(.5,0),new j(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Ti(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,c=new M,d=new j,u=new M,p=new M,f=new M,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-g,u.z=m*0,f.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-g,u.z=m*0,p.copy(u),u.x+=f.x,u.y+=f.y,u.z+=f.z,u.normalize(),o.push(u.x,u.y,u.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),w=Math.cos(y);for(let _=0;_<=e.length-1;_++){c.x=e[_].x*x,c.y=e[_].y,c.z=e[_].x*w,a.push(c.x,c.y,c.z),d.x=v/t,d.y=_/(e.length-1),n.push(d.x,d.y);let b=o[3*_+0]*x,A=o[3*_+1],S=o[3*_+0]*w;l.push(b,A,S)}}for(let v=0;v0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Ie(c,3)),this.setAttribute("normal",new Ie(d,3)),this.setAttribute("uv",new Ie(u,2));function v(){let x=new M,w=new M,_=0,b=(t-e)/i;for(let A=0;A<=s;A++){let S=[],E=A/s,C=E*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,O=D*o+n,P=Math.sin(O),U=Math.cos(O);w.x=C*P,w.y=-E*i+g,w.z=C*U,c.push(w.x,w.y,w.z),x.set(P,b,U).normalize(),d.push(x.x,x.y,x.z),u.push(D,1-E),S.push(p++)}f.push(S)}for(let A=0;A.9&&b<.1&&(y<.2&&(a[v+0]+=1),x<.2&&(a[v+2]+=1),w<.2&&(a[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function u(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new M,y=new M,x=new M,w=new M,_=new j,b=new j,A=new j;for(let S=0,E=0;S80*i){o=h=e[0],l=c=e[1];for(let f=i;fh&&(h=d),u>c&&(c=u);p=Math.max(h-o,c-l),p=p!==0?32767/p:0}return pd(a,n,i,o,l,p,0),n}};function CM(e,t,i,r,s){let a,n;if(s===vU(e,t,i,r)>0)for(a=t;a=t;a-=r)n=jb(a,e[a],e[a+1],n);return n&&Zf(n,n.next)&&(md(n),n=n.next),n}function ll(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Zf(i,i.next)||hi(i.prev,i,i.next)===0)){if(md(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function pd(e,t,i,r,s,a,n){if(!e)return;!n&&a&&dU(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?rU(e,r,s,a):iU(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),md(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=sU(ll(e),t,i),pd(e,t,i,r,s,a,2)):n===2&&aU(e,t,i,r,s,a):pd(ll(e),t,i,r,s,a,1);break}}}function iU(e){let t=e.prev,i=e,r=e.next;if(hi(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,c=sa?s>n?s:n:a>n?a:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&dh(s,o,a,l,n,h,f.x,f.y)&&hi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function rU(e,t,i,r){let s=e.prev,a=e,n=e.next;if(hi(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,c=s.y,d=a.y,u=n.y,p=ol?o>h?o:h:l>h?l:h,m=c>d?c>u?c:u:d>u?d:u,v=Nv(p,f,t,i,r),y=Nv(g,m,t,i,r),x=e.prevZ,w=e.nextZ;for(;x&&x.z>=v&&w&&w.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==n&&dh(o,c,l,d,h,u,x.x,x.y)&&hi(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=p&&w.x<=g&&w.y>=f&&w.y<=m&&w!==s&&w!==n&&dh(o,c,l,d,h,u,w.x,w.y)&&hi(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==n&&dh(o,c,l,d,h,u,x.x,x.y)&&hi(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=y;){if(w.x>=p&&w.x<=g&&w.y>=f&&w.y<=m&&w!==s&&w!==n&&dh(o,c,l,d,h,u,w.x,w.y)&&hi(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function sU(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!Zf(s,a)&&TM(s,r,r.next,a)&&fd(s,a)&&fd(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),md(r),md(r.next),r=e=a),r=r.next}while(r!==e);return ll(r)}function aU(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&fU(n,o)){let l=PM(n,o);n=ll(n,n.next),l=ll(l,l.next),pd(n,t,i,r,s,a,0),pd(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function nU(e,t,i,r){let s=[],a,n,o,l,h;for(a=0,n=t.length;a=i.next.y&&i.next.y!==i.y){let u=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=a&&u>r&&(r=u,s=i.x=i.x&&i.x>=l&&a!==i.x&&dh(ns.x||i.x===s.x&&cU(s,i)))&&(s=i,c=d)),i=i.next;while(i!==o);return s}function cU(e,t){return hi(e.prev,e,t.prev)<0&&hi(t.next,e,e.next)<0}function dU(e,t,i,r){let s=e;do s.z===0&&(s.z=Nv(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,uU(s)}function uU(e){let t,i,r,s,a,n,o,l,h=1;do{for(i=e,e=null,a=null,n=0;i;){for(n++,r=i,o=0,t=0;t0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),a?a.nextZ=s:e=s,s.prevZ=a,a=s;i=r}a.nextZ=null,h*=2}while(n>1);return e}function Nv(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function pU(e){let t=e,i=e;do(t.x=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function fU(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!mU(e,t)&&(fd(e,t)&&fd(t,e)&&gU(e,t)&&(hi(e.prev,e,t.prev)||hi(e,t.prev,t))||Zf(e,t)&&hi(e.prev,e,e.next)>0&&hi(t.prev,t,t.next)>0)}function hi(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Zf(e,t){return e.x===t.x&&e.y===t.y}function TM(e,t,i,r){let s=bu(hi(e,t,i)),a=bu(hi(e,t,r)),n=bu(hi(i,r,e)),o=bu(hi(i,r,t));return!!(s!==a&&n!==o||s===0&&xu(e,i,t)||a===0&&xu(e,r,t)||n===0&&xu(i,e,r)||o===0&&xu(i,t,r))}function xu(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function bu(e){return e>0?1:e<0?-1:0}function mU(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&TM(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function fd(e,t){return hi(e.prev,e,e.next)<0?hi(e,t,e.next)>=0&&hi(e,e.prev,t)>=0:hi(e,t,e.prev)<0||hi(e,e.next,t)<0}function gU(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function PM(e,t){let i=new kv(e.i,e.x,e.y),r=new kv(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function jb(e,t,i,r){let s=new kv(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function md(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function kv(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function vU(e,t,i,r){let s=0;for(let a=t,n=i-r;a2&&e[t-1].equals(e[0])&&e.pop()}function Hb(e,t){for(let i=0;i0)&&u.push(y,x,_),(m!==i-1||o=s)){let n=t[1];e=s)break t}a=i,i=0;break i}break e}for(;i>>1;et;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let n=this.getValueSize();this.times=Dn(i,s,a),this.values=Dn(this.values,s*n,a*n)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let n=0;n!==s;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(a!==null&&a>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,a),e=!1;break}a=o}if(r!==void 0&&LM(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=Dn(this.times),t=Dn(this.values),i=this.getValueSize(),r=this.getInterpolation()===Dm,s=e.length-1,a=1;for(let n=1;n0){e[a]=e[s];for(let n=s*i,o=a*i,l=0;l!==i;++l)t[o+l]=t[n+l];++a}return a!==e.length?(this.times=Dn(e,0,a),this.values=Dn(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=Dn(this.times,0),t=Dn(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Ia.prototype.TimeBufferType=Float32Array;Ia.prototype.ValueBufferType=Float32Array;Ia.prototype.DefaultInterpolation=kp;var Xh=class extends Ia{};Xh.prototype.ValueTypeName="bool";Xh.prototype.ValueBufferType=Array;Xh.prototype.DefaultInterpolation=Np;Xh.prototype.InterpolantFactoryMethodLinear=void 0;Xh.prototype.InterpolantFactoryMethodSmooth=void 0;var FM=class extends Ia{};FM.prototype.ValueTypeName="color";var Xp=class extends Ia{};Xp.prototype.ValueTypeName="number";var _U=class extends Kf{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)lt.slerpFlat(s,0,a,l-n,a,l,o);return s}},Bd=class extends Ia{InterpolantFactoryMethodLinear(e){return new _U(this.times,this.values,this.getValueSize(),e)}};Bd.prototype.ValueTypeName="quaternion";Bd.prototype.DefaultInterpolation=kp;Bd.prototype.InterpolantFactoryMethodSmooth=void 0;var Yh=class extends Ia{};Yh.prototype.ValueTypeName="string";Yh.prototype.ValueBufferType=Array;Yh.prototype.DefaultInterpolation=Np;Yh.prototype.InterpolantFactoryMethodLinear=void 0;Yh.prototype.InterpolantFactoryMethodSmooth=void 0;var Yp=class extends Ia{};Yp.prototype.ValueTypeName="vector";var Vv=class{constructor(e,t=-1,i,r=ky){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=ws(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,n=i.length;a!==n;++a)t.push(AU(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Ia.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let n=0;n1){let c=h[1],d=r[c];d||(r[c]=d=[]),d.push(l)}}let a=[];for(let n in r)a.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,c,d,u,p){if(d.length!==0){let f=[],g=[];zM(d,f,g,u),f.length!==0&&p.push(new h(c,f,g))}},r=[],s=e.name||"default",a=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h{t&&t(s),this.manager.itemEnd(e)},0),s;if(Va[e]!==void 0){Va[e].push({onLoad:t,onProgress:i,onError:r});return}Va[e]=[],Va[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Va[e],c=l.body.getReader(),d=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=d?parseInt(d):0,p=u!==0,f=0,g=new ReadableStream({start(m){v();function v(){c.read().then(({done:y,value:x})=>{if(y)m.close();else{f+=x.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let _=0,b=h.length;_{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),c=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(c);return l.arrayBuffer().then(u=>d.decode(u))}}}).then(l=>{Qp.add(e,l);let h=Va[e];delete Va[e];for(let c=0,d=h.length;c{let h=Va[e];if(h===void 0)throw this.manager.itemError(e),l;delete Va[e];for(let c=0,d=h.length;c{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},CU=class extends Fd{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,a=Qp.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;let n=dd("img");function o(){h(),Qp.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(c){h(),r&&r(c),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){n.removeEventListener("load",o,!1),n.removeEventListener("error",l,!1)}return n.addEventListener("load",o,!1),n.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(n.crossOrigin=this.crossOrigin),s.manager.itemStart(e),n.src=e,n}},TU=class extends Fd{constructor(e){super(e)}load(e,t,i,r){let s=new ci,a=new CU(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(n){s.image=n,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},Ud=class extends kt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new et(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){let 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()),t}},PU=class extends Ud{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new et(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},ng=new we,qb=new M,Xb=new M,Jy=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new j(512,512),this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Hy,this._frameExtents=new j(1,1),this._viewportCount=1,this._viewports=[new ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;qb.setFromMatrixPosition(e.matrixWorld),t.position.copy(qb),Xb.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Xb),t.updateMatrixWorld(),ng.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ng),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(ng)}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.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return 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}},DU=class extends Jy{constructor(){super(new _r(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=cd*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},IU=class extends Ud{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new DU}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Yb=new we,mc=new M,og=new M,OU=class extends Jy{constructor(){super(new _r(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new j(4,2),this._viewportCount=6,this._viewports=[new ct(2,1,1,1),new ct(0,1,1,1),new ct(3,1,1,1),new ct(1,1,1,1),new ct(3,0,1,1),new ct(1,0,1,1)],this._cubeDirections=[new M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),mc.setFromMatrixPosition(e.matrixWorld),i.position.copy(mc),og.copy(i.position),og.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(og),i.updateMatrixWorld(),r.makeTranslation(-mc.x,-mc.y,-mc.z),Yb.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Yb)}},RU=class extends Ud{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new OU}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},LU=class extends Jy{constructor(){super(new Xf(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},zU=class extends Ud{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.shadow=new LU}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},NM=class extends Ge{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},kM=class extends Fd{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new jv(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(d,u){if(t[u]!==void 0)return t[u];let p=d.interleavedBuffers[u],f=s(d,p.buffer),g=Kd(p.type,f),m=new UF(g,p.stride);return m.uuid=p.uuid,t[u]=m,m}function s(d,u){if(i[u]!==void 0)return i[u];let p=d.arrayBuffers[u],f=new Uint32Array(p).buffer;return i[u]=f,f}let a=e.isInstancedBufferGeometry?new NM:new Ge,n=e.data.index;if(n!==void 0){let d=Kd(n.type,n.array);a.setIndex(new tt(d,1))}let o=e.data.attributes;for(let d in o){let u=o[d],p;if(u.isInterleavedBufferAttribute){let f=r(e.data,u.data);p=new Uv(f,u.itemSize,u.offset,u.normalized)}else{let f=Kd(u.type,u.array),g=u.isInstancedBufferAttribute?ud:tt;p=new g(f,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),a.setAttribute(d,p)}let l=e.data.morphAttributes;if(l)for(let d in l){let u=l[d],p=[];for(let f=0,g=u.length;f"u"?Date:performance).now()}var FU=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let n=0;n!==r;++n)i[s+n]=i[n];a=t}else{a+=t;let n=t/a;this._mixBufferRegion(i,s,0,n,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){lt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;lt.multiplyQuaternionsFlat(e,a,e,t,e,i),lt.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let o=t+n;e[o]=e[o]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let n=t+a;e[n]=e[n]+e[i+a]*r}}},$y="\\[\\]\\.:\\/",UU=new RegExp("["+$y+"]","g"),e1="[^"+$y+"]",NU="[^"+$y.replace("\\.","")+"]",kU=/((?:WC+[\/:])*)/.source.replace("WC",e1),VU=/(WCOD+)?/.source.replace("WCOD",NU),jU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",e1),GU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",e1),HU=new RegExp("^"+kU+VU+jU+GU+"$"),WU=["material","materials","bones","map"],qU=class{constructor(e,t,i){let r=i||Xt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Xt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Xt.parseTrackName(t),this.node=Xt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Xt.Composite(e,t,i):new Xt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(UU,"")}static parseTrackName(e){let t=HU.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);WU.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let a=0;a0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case _R:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case ky:default:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(a),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===Ny;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===iM){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,s+=Math.abs(n);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=hh,r.endingEnd=hh):(e?r.endingStart=this.zeroSlopeAtStart?hh:lh:r.endingStart=Vp,t?r.endingEnd=this.zeroSlopeAtEnd?hh:lh:r.endingEnd=Vp)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},YU=new Float32Array(1),QU=class extends yr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let c=0;c!==s;++c){let d=r[c],u=d.name,p=h[u];if(p!==void 0)++p.referenceCount,a[c]=p;else{if(p=a[c],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,u));continue}let f=t&&t._propertyBindings[c].binding.parsedPath;p=new FU(Xt.create(i,u,f),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,u),a[c]=p}n[c].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}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}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))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Jb.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),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)}},$b=new M,_u=new M,_s=class{constructor(e=new M,t=new M){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){$b.subVectors(e,this.start),_u.subVectors(this.end,this.start);let i=_u.dot(_u),r=_u.dot($b)/i;return t&&(r=Ti(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},ew=new M,ZU=class extends kt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ge,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,n=1,o=32;a>-h-14,r[l|256]=1024>>-h-14|32768,s[l]=-h-1,s[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,s[l]=13,s[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,s[l]=24,s[l|256]=24):(r[l]=31744,r[l|256]=64512,s[l]=13,s[l|256]=13)}let a=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;!(h&8388608);)h<<=1,c-=8388608;h&=-8388609,c+=947912704,a[l]=h|c}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)n[l]=l<<23;n[31]=1199570944,n[32]=2147483648;for(let l=33;l<63;++l)n[l]=2147483648+(l-32<<23);n[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:a,exponentTable:n,offsetTable:o}}function tN(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Ti(e,-65504,65504),sn.floatView[0]=e;let t=sn.uint32View[0],i=t>>23&511;return sn.baseTable[i]+((t&8388607)>>sn.shiftTable[i])}function iN(e){let t=e>>10;return sn.uint32View[0]=sn.mantissaTable[sn.offsetTable[t]+(e&1023)]+sn.exponentTable[t],sn.floatView[0]}var rN=Object.freeze({__proto__:null,fromHalfFloat:iN,toHalfFloat:tN});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Gh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Gh);var gc=".",i1=Symbol("target"),jM=Symbol("unsubscribe");function Hv(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function sN(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var va=Array.isArray;function r1(e){return typeof e=="symbol"}var aN={after:(e,t)=>va(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>va(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=gc),r1(t)?e+t.toString():e+t):e,initial:e=>{if(va(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(gc);return t===-1?"":e.slice(0,t)},last:e=>{if(va(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(gc);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(va(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(gc);if(r===-1)t(e);else for(;i{e&&(e=e[i])}),e}},ms=aN;function nN(e){return typeof e=="object"&&typeof e.next=="function"}function oN(e,t,i,r,s){let a=e.next;if(t.name==="entries")e.next=function(){let n=a.call(this);return n.done===!1&&(n.value[0]=s(n.value[0],t,n.value[0],r),n.value[1]=s(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[i1].keys();e.next=function(){let o=a.call(this);return o.done===!1&&(o.value=s(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=a.call(this);return n.done===!1&&(n.value=s(n.value,t,n.value,r)),n};return e}function rw(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&r1(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var lN=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return n===void 0&&(n=s===void 0?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,ms.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let a=this._getOwnPropertyDescriptor(e,t);return a!==void 0&&"set"in a?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Wv(e){return toString.call(e)==="[object Object]"}function Mu(){return!0}function Bl(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var GM=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),hN=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),HM={push:Mu,pop:Mu,shift:Mu,unshift:Mu,copyWithin:Bl,reverse:Bl,sort:Bl,splice:Bl,flat:Bl,fill:Bl},cN=new Set([...GM,...hN,...Object.keys(HM)]);function Eu(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var WM=["keys","values","entries"],qM=new Set(["has","toString"]),XM={add:Eu,clear:Eu,delete:Eu,forEach:Eu},dN=new Set([...qM,...Object.keys(XM),...WM]);function Cu(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var uN=new Set([...qM,"get"]),YM={set:Cu,clear:Cu,delete:Cu,forEach:Cu},pN=new Set([...uN,...Object.keys(YM),...WM]),co=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return GM.has(e)}_shallowClone(e){let t=e;if(Wv(e))t={...e};else if(va(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(va(r)?this._onIsChanged=HM[t]:r instanceof Set?this._onIsChanged=XM[t]:r instanceof Map&&(this._onIsChanged=YM[t]),r):i}update(e,t,i){let r=ms.after(e,this._path);if(t!=="length"){let s=this.clone;ms.walk(r,a=>{s&&s[a]&&(this._clonedCache.has(s[a])||(s[a]=this._shallowClone(s[a])),s=s[a])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],ms.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},sw=class extends co{static isHandledMethod(e){return cN.has(e)}},fN=class extends co{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},aw=class extends co{static isHandledMethod(e){return dN.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},nw=class extends co{static isHandledMethod(e){return pN.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},mN=class extends co{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},gN=class extends co{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},th=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Wv(e)||va(e)||Hv(e)}static isHandledMethod(e,t){return Wv(e)?co.isHandledMethod(t):va(e)?sw.isHandledMethod(t):e instanceof Set?aw.isHandledMethod(t):e instanceof Map?nw.isHandledMethod(t):Hv(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=co;va(e)?r=sw:e instanceof Date?r=fN:e instanceof Set?r=aw:e instanceof Map?r=nw:e instanceof WeakSet?r=mN:e instanceof WeakMap&&(r=gN),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=th.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},vN={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},s1=(e,t,i={})=>{i={...vN,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new lN(s),h=typeof i.onValidate=="function",c=new th(h),d=(y,x,w,_,b)=>!h||c.isCloning||i.onValidate(ms.concat(l.getPath(y),x),w,_,b)===!0,u=(y,x,w,_)=>{!rw(l,i,x)&&!(n&&l.isDetached(y,e))&&p(l.getPath(y),x,w,_)},p=(y,x,w,_,b)=>{c.isCloning?c.update(y,x,_):t(ms.concat(y,x),w,_,b)},f=y=>y&&(y[r]||y),g=(y,x,w,_)=>sN(y)||w==="constructor"||a&&!th.isHandledMethod(x,w)||rw(l,i,w)||l.isGetInvariant(x,w)||n&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,ms.concat(_,w),m,r)),m={get(y,x,w){if(r1(x)){if(x===r||x===i1)return y;if(x===jM&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=Hv(y)?Reflect.get(y,x):Reflect.get(y,x,w);return g(_,y,x)},set(y,x,w,_){w=f(w);let b=y[r]||y,A=b[x];if(s(A,w)&&x in y)return!0;let S=d(y,x,w,A);return S&&l.setProperty(b,x,w,_,A)?(u(y,x,y[x],A),!0):!S},defineProperty(y,x,w){if(!l.isSameDescriptor(w,y,x)){let _=y[x];d(y,x,w.value,_)&&l.defineProperty(y,x,w,_)&&u(y,x,w.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let w=Reflect.get(y,x),_=d(y,x,void 0,w);return _&&l.deleteProperty(y,x,w)?(u(y,x,void 0,w),!0):!_},apply(y,x,w){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,w);if((o===!1||o!==!0&&!o.includes(y.name))&&th.isHandledType(_)){let b=ms.initial(l.getPath(y)),A=th.isHandledMethod(_,y.name);c.start(_,b,w);let S=Reflect.apply(y,c.preferredThisArg(y,x,_),A?w.map(T=>f(T)):w),E=c.isChanged(_,s),C=c.stop();if(th.isHandledType(S)&&A&&(x instanceof Map&&y.name==="get"&&(b=ms.concat(b,w[0])),S=l.getProxy(S,b,m)),E){let T={name:y.name,args:w,result:S},D=c.isCloning?ms.initial(b):b,O=c.isCloning?ms.last(b):"";d(ms.get(e,D),O,_,C,T)?p(D,O,_,C,T):c.undo(_)}return(x instanceof Map||x instanceof Set)&&nN(S)?oN(S,y,x,b,g):S}return Reflect.apply(y,x,w)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};s1.target=e=>e&&e[i1]||e;s1.unsubscribe=e=>e[jM]||e;var ow=s1,yN=typeof global=="object"&&global&&global.Object===Object&&global,QM=yN,xN=typeof self=="object"&&self&&self.Object===Object&&self,bN=QM||xN||Function("return this")(),Qs=bN,wN=Qs.Symbol,As=wN,ZM=Object.prototype,_N=ZM.hasOwnProperty,SN=ZM.toString,vc=As?As.toStringTag:void 0;function AN(e){var t=_N.call(e,vc),i=e[vc];try{e[vc]=void 0;var r=!0}catch{}var s=SN.call(e);return r&&(t?e[vc]=i:delete e[vc]),s}var MN=AN,EN=Object.prototype,CN=EN.toString;function TN(e){return CN.call(e)}var PN=TN,DN="[object Null]",IN="[object Undefined]",lw=As?As.toStringTag:void 0;function ON(e){return e==null?e===void 0?IN:DN:lw&&lw in Object(e)?MN(e):PN(e)}var ml=ON;function RN(e){return e!=null&&typeof e=="object"}var vn=RN,LN="[object Symbol]";function zN(e){return typeof e=="symbol"||vn(e)&&ml(e)==LN}var Nd=zN;function BN(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i0){if(++t>=Ck)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Ik=Dk;function Ok(e){return function(){return e}}var Rk=Ok,Lk=function(){try{var e=vl(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Jp=Lk,zk=Jp?function(e,t){return Jp(e,"toString",{configurable:!0,enumerable:!1,value:Rk(t),writable:!0})}:tE,Bk=zk,Fk=Ik(Bk),Uk=Fk;function Nk(e,t){for(var i=-1,r=e==null?0:e.length;++i-1&&e%1==0&&e-1&&e%1==0&&e<=n5}var l1=o5;function l5(e){return e!=null&&l1(e.length)&&!iE(e)}var sE=l5,h5=Object.prototype;function c5(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||h5;return e===i}var h1=c5;function d5(e,t){for(var i=-1,r=Array(e);++i-1}var YV=XV;function QV(e,t){var i=this.__data__,r=Jf(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var ZV=QV;function Zh(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t0&&i(o)?t>1?pE(o,t-1,i,r,s):f1(s,o):r||(s[s.length]=o)}return s}var Tj=pE;function Pj(e){var t=e==null?0:e.length;return t?Tj(e,1):[]}var Dj=Pj;function Ij(e){return Uk(a5(e,void 0,Dj),e+"")}var fE=Ij,Oj=cE(Object.getPrototypeOf,Object),m1=Oj,Rj="[object Object]",Lj=Function.prototype,zj=Object.prototype,mE=Lj.toString,Bj=zj.hasOwnProperty,Fj=mE.call(Object);function Uj(e){if(!vn(e)||ml(e)!=Rj)return!1;var t=m1(e);if(t===null)return!0;var i=Bj.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&mE.call(i)==Fj}var Nj=Uj;function kj(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var a=Array(s);++r=r?e:gE(e,t,i)}var jj=Vj,Gj="\\ud800-\\udfff",Hj="\\u0300-\\u036f",Wj="\\ufe20-\\ufe2f",qj="\\u20d0-\\u20ff",Xj=Hj+Wj+qj,Yj="\\ufe0e\\ufe0f",Qj="\\u200d",Zj=RegExp("["+Qj+Gj+Xj+Yj+"]");function Kj(e){return Zj.test(e)}var Jj=Kj;function $j(e){return e.split("")}var e6=$j,vE="\\ud800-\\udfff",t6="\\u0300-\\u036f",i6="\\ufe20-\\ufe2f",r6="\\u20d0-\\u20ff",s6=t6+i6+r6,a6="\\ufe0e\\ufe0f",n6="["+vE+"]",Xv="["+s6+"]",Yv="\\ud83c[\\udffb-\\udfff]",o6="(?:"+Xv+"|"+Yv+")",yE="[^"+vE+"]",xE="(?:\\ud83c[\\udde6-\\uddff]){2}",bE="[\\ud800-\\udbff][\\udc00-\\udfff]",l6="\\u200d",wE=o6+"?",_E="["+a6+"]?",h6="(?:"+l6+"(?:"+[yE,xE,bE].join("|")+")"+_E+wE+")*",c6=_E+wE+h6,d6="(?:"+[yE+Xv+"?",Xv,xE,bE,n6].join("|")+")",u6=RegExp(Yv+"(?="+Yv+")|"+d6+c6,"g");function p6(e){return e.match(u6)||[]}var f6=p6;function m6(e){return Jj(e)?f6(e):e6(e)}var _w=m6;function g6(){this.__data__=new $f,this.size=0}var v6=g6;function y6(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var x6=y6;function b6(e){return this.__data__.get(e)}var w6=b6;function _6(e){return this.__data__.has(e)}var S6=_6,A6=200;function M6(e,t){var i=this.__data__;if(i instanceof $f){var r=i.__data__;if(!vd||r.lengtho))return!1;var h=a.get(e),c=a.get(t);if(h&&c)return h==t&&c==e;var d=-1,u=!0,p=i&UH?new OH:void 0;for(a.set(e,t),a.set(t,e);++d=t||A<0||d&&S>=a}function v(){var b=dg();if(m(b))return y(b);o=setTimeout(v,g(b))}function y(b){return o=void 0,u&&r?p(b):(r=s=void 0,n)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function w(){return o===void 0?n:y(dg())}function _(){var b=dg(),A=m(b);if(r=arguments,s=this,l=b,A){if(o===void 0)return f(l);if(d)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),n}return _.cancel=x,_.flush=w,_}var xd=MW;function EW(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var CW=EW;function TW(e,t){return e>t}var PW=TW;function DW(e,t){return t.length<2?e:uE(e,gE(t,0,-1))}var IW=DW;function OW(e,t){return fW(e,t)}var y1=OW;function RW(e,t,i){for(var r=-1,s=e.length;++r1),a}),kd(e,CE(e),i),r&&(i=IE(i,VW|jW|GW,kW));for(var s=t.length;s--;)UW(i,t[s]);return i}),$v=HW;function WW(e,t,i,r){if(!Ys(e))return e;t=Jh(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s-1;);return i}var i8=t8;function r8(e,t,i){if(e=dE(e),e&&(i||t===void 0))return e.slice(0,eE(e)+1);if(!e||!(t=$M(t)))return e;var r=_w(e),s=i8(r,_w(t))+1;return jj(r,0,s).join("")}var s8=r8;function LE(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ms(e,t){return Object.setPrototypeOf(e,t),e}var a8=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),n8=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),o8=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||sm&&"ontouchend"in document,l8=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,h8=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,c8=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},d8=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},u8=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},zE=a8();zE&&u8();var sm=n8(),ec=o8(),p8=l8(),ss=h8(),kw=c8(),f8=Number(d8());function BE(e){return Array.isArray(e)?e:[e]}function FE(e,t){let i=0;for(;it[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Pu(e){return sm?e.metaKey:e.ctrlKey}function m8(e){return e.wheelDeltaY===0||e.deltaY===0?sm&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX||e.wheelDeltaX===-3*window.devicePixelRatio*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY||e.wheelDeltaY===-3*window.devicePixelRatio*e.deltaY:e.deltaMode===0}var at=[],rf={},Nc={},Cp={};function UE(e){at.includes(e)||at.push(e)}function vh(e){delete rf[e.pointerId];for(let t=0;t{VE=e}),Du;function b8(e){if(Du)return Du;async function t(){let i=e??"https://unpkg.com/@splinetool/navmesh-wasm@1.10.53/build",r=vo(()=>import("./navmesh-D1xgHkvw.js"),__vite__mapDeps([])),[s,a]=await Promise.all([r,fetch(`${i}/navmesh.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});VE(o)}return Du=t(),Du}var jE,w8=new Promise(e=>{jE=e}),Iu;function _8(){if(Iu)return Iu;async function e(){let t=await vo(()=>import("./physics-CUo4NZCQ.js"),__vite__mapDeps([]));await t.init(),jE(t)}return Iu=e(),Iu}var $e=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,$e.prototype),r}}add(e,t){var i;return((i=this.runOp({type:1,id:e,data:t}))==null?void 0:i.data)??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,$e.prototype),{data:n,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,$e.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function x1(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&x1(r)}return Object.freeze(e)}function S8(e,t){let i=0;for(;it[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var GE=class extends Error{};function pg(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Qn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let a=e;e=t,t=a}let r=[],s=1/(i+1);for(let a=0;an.id===e);if(s<0)throw new Error("not expected");let a=r[s];return r=[...r],r[s]={...a,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let a=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:a}}Object.setPrototypeOf(r,fr.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:a}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((h,c)=>h.fi-c.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(n=>n.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let d=t;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new GE("cyclic tree");d=this.parent(d)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(d=>d.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let c=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((d,u)=>d.fi-u.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:c,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>S8(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Qn(0,i,i);{let s=r[0].fi;return Qn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(n=>n.fi>s.fi);if(a===void 0){let n=r[r.length-1].fi;return Qn(n,n+i,i)}else return Qn(s.fi,a.fi,i)}}},af;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,a={},n=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");a[l]=n[h],n[h]=s[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}else{let s=r.props,a={},n={...i},o=!1;if(s)for(let l of Object.keys(s)){a[l]=n[l];let h=s[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}}e.runOp=t})(af||(af={}));var We=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,We.prototype)}deepFreeze(){let e=0;for(;ea.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,We.prototype);let t=e;return A8()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((n,o)=>n.fi-o.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(a=>a.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Qn(0,t,t);{let r=i[0].fi;return Qn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>r.fi);if(s===void 0){let a=i[i.length-1].fi;return Qn(a,a+t,t)}else return Qn(r.fi,s.fi,t)}}};function Ih(e){return e&&typeof e=="object"&&e instanceof Ri}var Ri=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=pg(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=pg(o);l[e.path[r-1]]=i,i=l}else{let l=new Ri;l[e.path[r-1]]=i,i=l}}r-=1}let a=Object.setPrototypeOf(i,Ri.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},so;(e=>{function t(s,a){return bd(s,a)??s}e.apply=t;function i(s,a){return _1(s,a)}e.merge=i;function r(s,a){let n=0,o=a.path,l=s;for(;n{let a=s.id,n=bd(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=w1(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:a,data:n,children:o}}else return{...s,id:a,data:n}});if(i)return r}function M8(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=bd(s.data,t[a]);return i=i||n!==void 0,n===void 0&&(n=s.data),{...s,id:a,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function bd(e,t){if(!Ih(t))return t;if(e instanceof fr){let i=w1(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof We)return M8(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=bd(s,t[a]);return i=i||n!==void 0,n===void 0&&(n=s),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof Ri)return _1(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=bd(a,t[s]);r=r||n!==void 0,n===void 0&&(n=a),i[s]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function _1(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Ih(t))return t;if(!Ih(e))return so.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new Ri;for(let s of i){let a=_1(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function E8(e,t){let i={cur:[],result:[],len:0};return e=wd(e,t,i)??e,[e,i.result]}function nf(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function of(e){e&&(e.len-=1)}function C8(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function qE(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=wd(a.data,t,nf(i,n));of(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=qE(a.children,t,i);return h!==void 0?r=!0:h=a.children,{...a,id:n,data:l,children:h}});if(r)return s}function T8(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=wd(a.data,t,nf(i,n));return of(i),r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:n,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function wd(e,t,i){if(e instanceof fr){let r=qE(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof We)return T8(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=wd(a,t,nf(i,n));return of(i),r=r||o!==void 0,o===void 0&&(o=a),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!b1(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"&&a!=="variableId"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=wd(n,t,nf(i,a));of(i),s=s||l!==void 0,l===void 0&&(l=n),r[a]=l}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&C8(i),r}else return}}var lf;(e=>{function t(i,r){let s=Gi.zoom(r,i.path);if(typeof s=="object"){let a={};for(let n of Object.keys(i.props))a[n]=s[n];return{...i,props:a}}else return{...i,props:{}}}e.replaceProps=t})(lf||(lf={}));var tr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){var c;return((c=r(l,h))==null?void 0:c.data)??l}e.applySimple=i;function r(l,h){var u,p;let c=h.path;for(var d=[];;){let f;if(l instanceof Ri&&h.type===0&&(f=l.runOp({...h,path:c.slice(d.length)}),f===null&&(f=void 0)),f===void 0&&d.length===c.length&&(l instanceof fr||l instanceof We||l instanceof $e?f=l.runOp(h):f=af.runOp(l,h)),f!==void 0)if(f!==null){let v=f.data;for(let y=d.length-1;y>=0;y--){let x=c[y],w=d[y];if(w instanceof fr){if(typeof x=="number")throw new Error("illegal arg");v=w.modifyById(x,v)}else if(w instanceof We){if(typeof x=="number")throw new Error("illegal arg");v=w.modifyById(x,v)}else if(w instanceof $e){if(typeof x=="number")throw new Error("illegal arg");v=w.modifyById(x,v)}else if(w instanceof Ri){let _={...w,[x]:v};v=Object.setPrototypeOf(_,Ri.prototype)}else if(typeof w=="object")if(Array.isArray(w)){if(typeof x=="string"&&(x=parseInt(x),isNaN(x)))throw new Error("Invalid path");let _=v;v=[...w],v[x]=_}else v={...w,[x]:v};else return null}return{data:v,actual:{...f.actual,path:c},reverse:{...f.reverse,path:c}}}else return null;let g=c[d.length],m;if(l instanceof fr){if(typeof g=="number")throw new Error("");m=(u=l.get(g))==null?void 0:u.data}else if(l instanceof We){if(typeof g=="number")throw new Error("");m=(p=l.get(g))==null?void 0:p.data}else l!==null&&(m=l[g]);if(m!==void 0)d.push(l),l=m;else return null}}e.apply=r;function s(l,h){for(let c=0;ch.props[c]!==void 0):!1}e.subsumed=o})(tr||(tr={}));var e0;(e=>{function t(){return[]}e.empty=t;function i(h,c){let d=[];for(let u of h){let[p,...f]=u.path;p===c&&d.push({...u,path:f})}return d}e.removePrefix=i;function r(h,c){return h.map(d=>({...d,path:[c,...d.path]}))}e.addPrefix=r;function s(h,c){return[...h,...c]}e.concat=s;function a(h,c){return[...h.filter(d=>!c.some(u=>tr.subsumed(d,u))),...c]}e.compress=a;function n(h,c){return h.every(d=>c.every(u=>tr.commutative(d,u)))}e.commutative=n;function o(h,c){for(let d of c){let u=l(h,d);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,c){var d=h;let u=[],p=[];for(let f of c)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let g,m,v;if(f.type===3?(g=Gi.zoom(d,[...f.path,f.id]),v=tr.apply(d,{...f,type:2})):(g=Gi.zoom(d,[...f.path,f.id,"value"]),v=tr.apply(d,f)),v!==null){d=v.data;let[y,x]=E8(d,{[f.id]:g});d=y;for(let w=0;wA.includes(C)?f.id:E),g=S,b=_.pop()}else{if(b==="alphaOverride"||b==="alpha"){g/=100;let A=g,S=Gi.zoom(d,_.slice(0,_.length-2)),E=S.layers.map(C=>C.id===_[_.length-1]?{...C,data:{...C.data,[b]:A}}:C);Object.setPrototypeOf(E,Object.getPrototypeOf(S.layers)),S.layers=E}m=f.id}u.push({type:0,path:_,props:{[b]:g}}),p.push({type:0,path:_,props:{[b]:m}})}p.push(v.reverse),u.push(v.actual)}}else{let g=tr.apply(d,f);g!==null&&(u.push(g.actual),d=g.data,p.push(g.reverse))}}catch(g){if(g instanceof GE)return null;throw g}return{data:d,actual:u,reverse:p.reverse()}}e.apply=l})(e0||(e0={}));var XE=Symbol(),P8=Symbol(),am=Symbol(),Vd=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof QE);){let a=r._path,n=r._current;if(a!==""&&s.splice(0,0,a),r=r._parent,r===null)return;r.update(a,n)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[am];i&&i(),delete this._children[e]}}}},D8=class extends Vd{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,af.runOp(this._current,e),e.path)}},I8=class extends Vd{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,$e.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},YE={get(e,t){if(t===am)return()=>{e._parent=null};if(t===XE)return e._current;if(t===P8)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let a=i[t],n=nm(e,t,a);return n!==a?(r===void 0&&(r={},e._children=r),r[t]=n,n):a},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},O8={...YE,set(e,t,i){let r={type:0,props:{[t]:wi(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},R8={...YE,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},S1=class extends Vd{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[am]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){var n;let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=(n=t.get(e))==null?void 0:n.data,a=nm(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Gi.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var QE=class extends Vd{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){fg(this.ts,t,e),fg(this.actual,i,e),fg(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function nm(e,t,i){return i instanceof fr?new S1(e,t,i):i instanceof We?new A1(e,t,i):i instanceof $e?new Proxy(new I8(e,t,i),R8):i!==null&&typeof i=="object"?b1(i)?i:new Proxy(new D8(e,t,i),O8):i}function ZE(e){let t=new QE(e);return[nm(t,"",e),t]}function _d(e,t){let[i,r]=ZE(e);return t(i),r.result()}function wi(e){return e instanceof S1||e instanceof A1?e._current:e!==null&&typeof e=="object"?e[XE]:e}var Gi;(e=>{function t(a,n){if(n.length===a.length)for(var o=0;o{delete h[c]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof fr||a instanceof S1)&&typeof n=="string"||(a instanceof We||a instanceof A1)&&typeof n=="string")return a.data(n);if(typeof n=="number"&&Array.isArray(a)||typeof n=="string"&&typeof a=="object"&&a!==null)return a[n]}e.zoomOnce=r;function s(a,n,o=0){for(;o(r0(),this?this.unpack(e,t):hf.prototype.unpack.call(Gw,e,t)));ao=t>-1?t:e.length,ie=0,ya=0,Zn=null,rs=null,Ne=e;try{Nt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Ne=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof hf){if(Yr=this,this.structures)return Bt=this.structures,Ou();(!Bt||Bt.length>0)&&(Bt=[])}else Yr=Gw,(!Bt||Bt.length>0)&&(Bt=[]);return Ou()}unpackMultiple(e,t){let i,r=0;try{Oh=!0;let s=e.length,a=this?this.unpack(e,s):lm.unpack(e,s);if(t){for(t(a);ie=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Ou(){try{if(!Yr.trusted&&!Oh){let t=Bt.sharedLength||0;tao){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Oh)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw Bt.restoreStructures&&Hw(),r0(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function Hw(){for(let e in Bt.restoreStructures)Bt[e]=Bt.restoreStructures[e];Bt.restoreStructures=null}function fi(){let e=Ne[ie++];if(e<160)if(e<128){if(e<64)return e;{let t=Bt[e&63]||Yr.getStructures&&eC()[e&63];return t?(t.read||(t.read=M1(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,Yr.mapsAsObjects){let t={};for(let i=0;i=ie)return Zn.slice(ie-gs,(ie+=t)-gs);if(ya==0&&ao<140){let i=t<16?E1(t):tC(t);if(i!=null)return i}return i0(t)}else{let t;switch(e){case 192:return null;case 193:return rs?(t=fi(),t>0?rs[1].slice(rs.position1,rs.position1+=t):rs[0].slice(rs.position0,rs.position0-=t)):$E;case 194:return!1;case 195:return!0;case 196:return mg(Ne[ie++]);case 197:return t=Nt.getUint16(ie),ie+=2,mg(t);case 198:return t=Nt.getUint32(ie),ie+=4,mg(t);case 199:return To(Ne[ie++]);case 200:return t=Nt.getUint16(ie),ie+=2,To(t);case 201:return t=Nt.getUint32(ie),ie+=4,To(t);case 202:if(t=Nt.getFloat32(ie),Yr.useFloat32>2){let i=C1[(Ne[ie]&127)<<1|Ne[ie+1]>>7];return ie+=4,(i*t+(t>0?.5:-.5)>>0)/i}return ie+=4,t;case 203:return t=Nt.getFloat64(ie),ie+=8,t;case 204:return Ne[ie++];case 205:return t=Nt.getUint16(ie),ie+=2,t;case 206:return t=Nt.getUint32(ie),ie+=4,t;case 207:return Yr.int64AsNumber?(t=Nt.getUint32(ie)*4294967296,t+=Nt.getUint32(ie+4)):t=Nt.getBigUint64(ie),ie+=8,t;case 208:return Nt.getInt8(ie++);case 209:return t=Nt.getInt16(ie),ie+=2,t;case 210:return t=Nt.getInt32(ie),ie+=4,t;case 211:return Yr.int64AsNumber?(t=Nt.getInt32(ie)*4294967296,t+=Nt.getUint32(ie+4)):t=Nt.getBigInt64(ie),ie+=8,t;case 212:if(t=Ne[ie++],t==114)return Qw(Ne[ie++]&63);{let i=kr[t];if(i)return i.read?(ie++,i.read(fi())):i.noBuffer?(ie++,i()):i(Ne.subarray(ie,++ie));throw new Error("Unknown extension "+t)}case 213:return t=Ne[ie],t==114?(ie++,Qw(Ne[ie++]&63,Ne[ie++])):To(2);case 214:return To(4);case 215:return To(8);case 216:return To(16);case 217:return t=Ne[ie++],ya>=ie?Zn.slice(ie-gs,(ie+=t)-gs):B8(t);case 218:return t=Nt.getUint16(ie),ie+=2,ya>=ie?Zn.slice(ie-gs,(ie+=t)-gs):F8(t);case 219:return t=Nt.getUint32(ie),ie+=4,ya>=ie?Zn.slice(ie-gs,(ie+=t)-gs):U8(t);case 220:return t=Nt.getUint16(ie),ie+=2,qw(t);case 221:return t=Nt.getUint32(ie),ie+=4,qw(t);case 222:return t=Nt.getUint16(ie),ie+=2,Xw(t);case 223:return t=Nt.getUint32(ie),ie+=4,Xw(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var z8=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function M1(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>z8.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(fi);return e.highByte===0&&(e.read=Ww(t,e.read)),s()}let r={};for(let s=0,a=e.length;sfunction(){let i=Ne[ie++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=Bt[r]||eC()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=M1(s,e)),s.read()};function eC(){let e=aC(()=>(Ne=null,Yr.getStructures()));return Bt=Yr._mergeStructures(e,Bt)}var i0=om,B8=om,F8=om,U8=om;function om(e){let t;if(e<16&&(t=E1(e)))return t;if(e>64&&t0)return t0.decode(Ne.subarray(ie,ie+=e));let i=ie+e,r=[];for(t="";ie65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=Ki.apply(String,r),r.length=0)}return r.length>0&&(t+=Ki.apply(String,r)),t}function qw(e){let t=new Array(e);for(let i=0;i0){ie=t;return}i[r]=s}return Ki.apply(String,i)}function E1(e){if(e<4)if(e<2){if(e===0)return"";{let t=Ne[ie++];if((t&128)>1){ie-=1;return}return Ki(t)}}else{let t=Ne[ie++],i=Ne[ie++];if((t&128)>0||(i&128)>0){ie-=2;return}if(e<3)return Ki(t,i);let r=Ne[ie++];if((r&128)>0){ie-=3;return}return Ki(t,i,r)}else{let t=Ne[ie++],i=Ne[ie++],r=Ne[ie++],s=Ne[ie++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){ie-=4;return}if(e<6){if(e===4)return Ki(t,i,r,s);{let a=Ne[ie++];if((a&128)>0){ie-=5;return}return Ki(t,i,r,s,a)}}else if(e<8){let a=Ne[ie++],n=Ne[ie++];if((a&128)>0||(n&128)>0){ie-=6;return}if(e<7)return Ki(t,i,r,s,a,n);let o=Ne[ie++];if((o&128)>0){ie-=7;return}return Ki(t,i,r,s,a,n,o)}else{let a=Ne[ie++],n=Ne[ie++],o=Ne[ie++],l=Ne[ie++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){ie-=8;return}if(e<10){if(e===8)return Ki(t,i,r,s,a,n,o,l);{let h=Ne[ie++];if((h&128)>0){ie-=9;return}return Ki(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=Ne[ie++],c=Ne[ie++];if((h&128)>0||(c&128)>0){ie-=10;return}if(e<11)return Ki(t,i,r,s,a,n,o,l,h,c);let d=Ne[ie++];if((d&128)>0){ie-=11;return}return Ki(t,i,r,s,a,n,o,l,h,c,d)}else{let h=Ne[ie++],c=Ne[ie++],d=Ne[ie++],u=Ne[ie++];if((h&128)>0||(c&128)>0||(d&128)>0||(u&128)>0){ie-=12;return}if(e<14){if(e===12)return Ki(t,i,r,s,a,n,o,l,h,c,d,u);{let p=Ne[ie++];if((p&128)>0){ie-=13;return}return Ki(t,i,r,s,a,n,o,l,h,c,d,u,p)}}else{let p=Ne[ie++],f=Ne[ie++];if((p&128)>0||(f&128)>0){ie-=14;return}if(e<15)return Ki(t,i,r,s,a,n,o,l,h,c,d,u,p,f);let g=Ne[ie++];if((g&128)>0){ie-=15;return}return Ki(t,i,r,s,a,n,o,l,h,c,d,u,p,f,g)}}}}}function mg(e){return Yr.copyBuffers?Uint8Array.prototype.slice.call(Ne,ie,ie+=e):Ne.subarray(ie,ie+=e)}function To(e){let t=Ne[ie++];if(kr[t])return kr[t](Ne.subarray(ie,ie+=e));throw new Error("Unknown extension type "+t)}var Yw=new Array(4096);function iC(){let e=Ne[ie++];if(e>=160&&e<192){if(e=e-160,ya>=ie)return Zn.slice(ie-gs,(ie+=e)-gs);if(!(ya==0&&ao<180))return i0(e)}else return ie--,fi();let t=(e<<5^(e>1?Nt.getUint16(ie):e>0?Ne[ie]:0))&4095,i=Yw[t],r=ie,s=ie+e-3,a,n=0;if(i&&i.bytes==e){for(;r{var i=fi();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=Bt[e];return s&&s.isShared&&((Bt.restoreStructures||(Bt.restoreStructures=[]))[e]=s),Bt[e]=i,i.read=M1(i,r),i.read()},rC=typeof self=="object"?self:global;kr[0]=()=>{};kr[0].noBuffer=!0;kr[101]=()=>{let e=fi();return(rC[e[0]]||Error)(e[1])};kr[105]=e=>{let t=Nt.getUint32(ie-4);pn||(pn=new Map);let i=Ne[ie],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};pn.set(t,s);let a=fi();return s.used?Object.assign(r,a):(s.target=a,a)};kr[112]=e=>{let t=Nt.getUint32(ie-4),i=pn.get(t);return i.used=!0,i.target};kr[115]=()=>new Set(fi());var sC=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");kr[116]=e=>{let t=e[0],i=sC[t];if(!i)throw new Error("Could not find typed array for code "+t);return new rC[i](Uint8Array.prototype.slice.call(e,1).buffer)};kr[120]=()=>{let e=fi();return new RegExp(e[0],e[1])};kr[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=ie;ie+=t-4,rs=[fi(),fi()],rs.position0=0,rs.position1=0;let r=ie;ie=i;try{return fi()}finally{ie=r}};kr[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function aC(e){let t=ao,i=ie,r=gs,s=ya,a=Zn,n=pn,o=rs,l=new Uint8Array(Ne.slice(0,ao)),h=Bt,c=Bt.slice(0,Bt.length),d=Yr,u=Oh,p=e();return ao=t,ie=i,gs=r,ya=s,Zn=a,pn=n,rs=o,Ne=l,Oh=u,Bt=h,Bt.splice(0,Bt.length,...c),Yr=d,Nt=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),p}function r0(){Ne=null,pn=null,Bt=null}function N8(e){e.unpack?kr[e.type]=e.unpack:kr[e.type]=e}var C1=new Array(147);for(let e=0;e<256;e++)C1[e]=+("1e"+Math.floor(45.15-e*.30103));var lm=new hf({useRecords:!1});lm.unpack;lm.unpackMultiple;lm.unpack;var k8=new Float32Array(1);new Uint8Array(k8.buffer,0,4);var Tp;try{Tp=new TextEncoder}catch{}var cf,T1,hm=typeof Buffer<"u",gg=hm?Buffer.allocUnsafeSlow:Uint8Array,nC=hm?Buffer:Uint8Array,Zw=hm?4294967296:2144337920,xe,xi,ce=0,$s,ea=null,V8=/[\u0080-\uFFFF]/,yc=Symbol("record-id"),oC=class extends hf{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n=0,o=nC.prototype.utf8Write?function(b,A,S){return xe.utf8Write(b,A,S)}:Tp&&Tp.encodeInto?function(b,A){return Tp.encodeInto(b,xe.subarray(A)).written}:!1,l=this;e||(e={});let h=e&&e.sequential,c=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=c?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let u=e.maxOwnStructures;u==null&&(u=c?32:64),h&&!e.saveStructures&&(this.structures=[]);let p=d>32||u+d>64,f=d+64,g=d+u+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let m=[],v=0,y=0;this.pack=this.encode=function(b,A){if(xe||(xe=new gg(8192),xi=new DataView(xe.buffer,0,8192),ce=0),$s=xe.length-10,$s-ce<2048?(xe=new gg(xe.length),xi=new DataView(xe.buffer,0,xe.length),$s=xe.length-10,ce=0):ce=ce+7&2147483640,t=ce,a=l.structuredClone?new Map:null,l.bundleStrings?(ea=["",""],xe[ce++]=214,xe[ce++]=98,ea.position=ce-t,ce+=4):ea=null,i=l.structures,i){i.uninitialized&&(i=l._mergeStructures(l.getStructures()));let S=i.sharedLength||0;if(S>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let E=0;E$s&&_(ce),l.offset=ce;let S=G8(xe.subarray(t,ce),a.idsToInsert);return a=null,S}return A&H8?(xe.start=t,xe.end=ce,xe):xe.subarray(t,ce)}finally{if(i){if(y<10&&y++,v>1e4)i.transitions=null,y=0,v=0,m.length>0&&(m=[]);else if(m.length>0&&!h){for(let S=0,E=m.length;SS&&(i=i.slice(0,S));let E=xe.subarray(t,ce);return l.saveStructures(i,n)===!1?(l._mergeStructures(l.getStructures()),l.pack(b)):(n=S,E)}}A&W8&&(ce=t)}};let x=b=>{ce>$s&&(xe=_(ce));var A=typeof b,S;if(A==="string"){let E=b.length;if(ea&&E>=8&&E<4096){let D=V8.test(b);ea[D?0:1]+=b,xe[ce++]=193,x(D?-E:E);return}let C;E<32?C=1:E<256?C=2:E<65536?C=3:C=5;let T=E*3;if(ce+T>$s&&(xe=_(ce+T)),E<64||!o){let D,O,P,U=ce+C;for(D=0;D>6|192,xe[U++]=O&63|128):(O&64512)===55296&&((P=b.charCodeAt(D+1))&64512)===56320?(O=65536+((O&1023)<<10)+(P&1023),D++,xe[U++]=O>>18|240,xe[U++]=O>>12&63|128,xe[U++]=O>>6&63|128,xe[U++]=O&63|128):(xe[U++]=O>>12|224,xe[U++]=O>>6&63|128,xe[U++]=O&63|128);S=U-ce-C}else S=o(b,ce+C,T);S<32?xe[ce++]=160|S:S<256?(C<2&&xe.copyWithin(ce+2,ce+1,ce+1+S),xe[ce++]=217,xe[ce++]=S):S<65536?(C<3&&xe.copyWithin(ce+3,ce+2,ce+2+S),xe[ce++]=218,xe[ce++]=S>>8,xe[ce++]=S&255):(C<5&&xe.copyWithin(ce+5,ce+3,ce+3+S),xe[ce++]=219,xi.setUint32(ce,S),ce+=4),ce+=S}else if(A==="number")if(b>>>0===b)b<64?xe[ce++]=b:b<256?(xe[ce++]=204,xe[ce++]=b):b<65536?(xe[ce++]=205,xe[ce++]=b>>8,xe[ce++]=b&255):(xe[ce++]=206,xi.setUint32(ce,b),ce+=4);else if(b>>0===b)b>=-32?xe[ce++]=256+b:b>=-128?(xe[ce++]=208,xe[ce++]=b+256):b>=-32768?(xe[ce++]=209,xi.setInt16(ce,b),ce+=2):(xe[ce++]=210,xi.setInt32(ce,b),ce+=4);else{let E;if((E=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){xe[ce++]=202,xi.setFloat32(ce,b);let C;if(E<4||(C=b*C1[(xe[ce]&127)<<1|xe[ce+1]>>7])>>0===C){ce+=4;return}else ce--}xe[ce++]=203,xi.setFloat64(ce,b),ce+=8}else if(A==="object")if(!b)xe[ce++]=192;else{if(a){let C=a.get(b);if(C){if(!C.id){let T=a.idsToInsert||(a.idsToInsert=[]);C.id=T.push(C)}xe[ce++]=214,xe[ce++]=112,xi.setUint32(ce,C.id),ce+=4;return}else a.set(b,{offset:ce-t})}let E=b.constructor;if(E===Object)w(b,!0);else if(E===Array){S=b.length,S<16?xe[ce++]=144|S:S<65536?(xe[ce++]=220,xe[ce++]=S>>8,xe[ce++]=S&255):(xe[ce++]=221,xi.setUint32(ce,S),ce+=4);for(let C=0;C>8,xe[ce++]=S&255):(xe[ce++]=223,xi.setUint32(ce,S),ce+=4);for(let[C,T]of b)x(C),x(T)}else{for(let C=0,T=cf.length;C(xe=P,P=null,ce+=F,ce>$s&&_(ce),{target:xe,targetView:xi,position:ce-F}),x)}finally{P&&(xe=P,xi=U,ce=W,$s=xe.length-10)}k&&(k.length+ce>$s&&_(k.length+ce),ce=j8(k,xe,ce,O.type));return}}w(b,!b.hasOwnProperty)}}else if(A==="boolean")xe[ce++]=b?195:194;else if(A==="bigint"){if(b=-(BigInt(1)<0)xe[ce++]=207,xi.setBigUint64(ce,b);else if(this.largeBigIntToFloat)xe[ce++]=203,xi.setFloat64(ce,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ce+=8}else if(A==="undefined")this.encodeUndefinedAsNil?xe[ce++]=192:(xe[ce++]=212,xe[ce++]=0,xe[ce++]=0);else if(A==="function")x(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+A)},w=this.useRecords===!1?this.variableMapSize?b=>{let A=Object.keys(b),S=A.length;S<16?xe[ce++]=128|S:S<65536?(xe[ce++]=222,xe[ce++]=S>>8,xe[ce++]=S&255):(xe[ce++]=223,xi.setUint32(ce,S),ce+=4);let E;for(let C=0;C{xe[ce++]=222;let S=ce-t;ce+=2;let E=0;for(let C in b)(A||b.hasOwnProperty(C))&&(x(C),x(b[C]),E++);xe[S+++t]=E>>8,xe[S+t]=E&255}:b=>{let A=Object.keys(b),S,E=s.transitions||(s.transitions=Object.create(null)),C=0;for(let D=0,O=A.length;D=96&&p?(xe[ce++]=((T-=96)&31)+96,xe[ce++]=T>>5):xe[ce++]=T;else{T=s.nextId,T||(T=64),T=g&&(T=f),s.nextId=T+1);let D=A.highByte=T>=96&&p?T-96>>5:-1;E[yc]=T,s[T-64]=A,T=0?(xe[ce++]=(T&31)+96,xe[ce++]=D):xe[ce++]=T):(D>=0?(xe[ce++]=213,xe[ce++]=114,xe[ce++]=(T&31)+96,xe[ce++]=D):(xe[ce++]=212,xe[ce++]=114,xe[ce++]=T),C&&(v+=y*C),m.length>=u&&(m.shift()[yc]=0),m.push(E),x(A))}for(let D=0,O=A.length;D{let A;if(b>16777216){if(b-t>Zw)throw new Error("Packed buffer would be larger than maximum buffer size");A=Math.min(Zw,Math.round(Math.max((b-t)*(b>67108864?1.25:2),4194304)/4096)*4096)}else A=(Math.max(b-t<<2,xe.length-1)>>12)+1<<12;let S=new gg(A);return xi=new DataView(S.buffer,0,A),xe.copy?xe.copy(S,0,t,b):S.set(xe.slice(t,b)),ce-=t,t=0,$s=S.length-10,xe=S}}useBuffer(e){xe=e,xi=new DataView(xe.buffer,xe.byteOffset,xe.byteLength),ce=0}};T1=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,JE];cf=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:a,position:n}=t(6);s[n++]=214,s[n++]=255,a.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:s,targetView:a,position:n}=t(10);s[n++]=215,s[n++]=255,a.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),a.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:a,position:n}=t(3);s[n++]=212,s[n++]=255,s[n++]=255}else{let{target:s,targetView:a,position:n}=t(15);s[n++]=199,s[n++]=12,s[n++]=255,a.setUint32(n,e.getMilliseconds()*1e6),a.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(s[a++]=212,s[a++]=115,s[a++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?Kw(e,16,t):Jw(hm?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==nC&&this.structuredClone?Kw(e,sC.indexOf(i.name),t):Jw(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function Kw(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:a,position:n}=i(4+s);a[n++]=199,a[n++]=s+1}else if(s+1<65536){var{target:a,position:n}=i(5+s);a[n++]=200,a[n++]=s+1>>8,a[n++]=s+1&255}else{var{target:a,position:n,targetView:o}=i(7+s);a[n++]=201,o.setUint32(n,s+1),n+=4}a[n++]=116,a[n++]=t,a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function Jw(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:a}=t(i+5);r[s++]=198,a.setUint32(s,i),s+=4}r.set(e,s)}function j8(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function G8(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((a,n)=>a.offset>n.offset?1:-1);i=t.pop();){let a=i.offset,n=i.id;e.copyWithin(a+r,a,s),r-=6;let o=a+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,s=a}return e}function tc(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");T1.unshift(e.Class),cf.unshift(e)}N8(e)}var lC=new oC({useRecords:!1});lC.pack;lC.pack;var H8=512,W8=1024,$w=new oC({structuredClone:!0});tc({Class:$e.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,$e.prototype),e}});tc({Class:We.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,We.prototype),e}});tc({Class:fr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,fr.prototype),e}});tc({Class:Vw.prototype.constructor,type:4,write(e){return e.id},read(e){return new Vw(e)}});tc({Class:jw.prototype.constructor,type:5,write(e){return e.data},read(e){return new jw(e)}});tc({Class:Ri.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Ri.prototype),e}});function q8(e){var t=0;if(e.length===0)return t;for(let i=0;i{function t(s){return $w.pack(s)}e.serialize=t;function i(s){return $w.unpack(s)}e.deserialize=i;function r(s){return q8(t(s0(s))).toString()}e.checksum=r})(a0||(a0={}));var e_;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(e_||(e_={}));function t_(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var br={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},i_;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,actions:new We}:{type:r,disabled:!1,key:void 0,actions:new We}}e.defaultData=i})(i_||(i_={}));var df;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(df||(df={}));var n0;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:df.propertyDefaultData(s),rOperand:{...df.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,a){return{type:"State",object:s??null,state:a??null}}e.stateDefaultData=r})(n0||(n0={}));var r_;(e=>{function t(i){return i.find(r=>r==="ifActions"||r==="elseActions")!==void 0}e.isConditionalSubActions=t})(r_||(r_={}));var s_;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new We,outActions:new We,condition:n0.distanceDefaultData(r)}}e.defaultData=i})(s_||(s_={}));var a_;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new We,drop:new We}})(a_||(a_={}));var o0;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new We})(o0||(o0={}));var l0;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(l0||(l0={}));var n_;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new We}}e.defaultData=i})(n_||(n_={}));var o_;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new We}}e.defaultData=i})(o_||(o_={}));var l_;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new We}}e.defaultData=i})(l_||(l_={}));var h_;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,target:"character",actions:new We}}e.defaultData=i})(h_||(h_={}));var c_;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,target:"all",triggeringObjects:[],actions:new We,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(c_||(c_={}));var h0;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function s(){let n={size:"mobile",operator:"<",actions:new We},o={size:"tablet",operator:"<",actions:new We},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new We},h=new We;return h.push({id:Re.generateUUID(),fi:0,data:n},{id:Re.generateUUID(),fi:1,data:o},{id:Re.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function a(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new We}}e.defaultBreakpointData=a})(h0||(h0={}));var c0;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new We,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(c0||(c0={}));var d_;(e=>{function t(r){return r.type==="API"}e.is=t;function i(){return{disabled:!1,type:"API",successActions:new We,errorActions:new We,userAPIId:""}}e.defaultData=i})(d_||(d_={}));var u_;(e=>{function t(r){return r.type==="WEBHOOK"}e.is=t;function i(){return{disabled:!1,type:"WEBHOOK",actions:new We,userWebhookId:""}}e.defaultData=i})(u_||(u_={}));var p_;(e=>{function t(r){return r.type==="AIAssistantListener"}e.is=t;function i(){return{disabled:!1,type:"AIAssistantListener",actions:new We,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=i})(p_||(p_={}));var f_;(e=>{function t(r){return r.type==="AIAssistantTrigger"}e.is=t;function i(){return{disabled:!1,description:"",type:"AIAssistantTrigger",actions:new We}}e.defaultData=i})(f_||(f_={}));var ic="personal camera",Jc="a218fcc3-276b-49b9-b485-49037fd14f5f",X8=2960946,as=5526619,cn;(e=>{function t(f,g){return f[0]===g[0]&&f[1]===g[1]}e.isEqual=t;function i(f,g,m){return[f[0]+(g[0]-f[0])*m,f[1]+(g[1]-f[1])*m]}e.lerp=i;function r(f,g){return[f[0]+g[0],f[1]+g[1]]}e.add=r;function s(f,g){return[f[0]-g[0],f[1]-g[1]]}e.sub=s;function a(f,g){return[f[0]*g[0],f[1]*g[1]]}e.multiply=a;function n(f,g){return[f[0]/g[0],f[1]/g[1]]}e.divide=n;function o(f,g){return Math.pow(g[0]-f[0],2)+Math.pow(g[1]-f[1],2)}e.distanceSquared=o;function l(f,g){return Math.sqrt(o(f,g))}e.distance=l;function h(f,g){return f[0]*g[0]+f[1]*g[1]}e.dot=h;function c(f,g){return[f[0]*g,f[1]*g]}e.scalarMultiply=c;function d(f,g,m){let v=e.sub(g,f),y=e.sub(m,f),x=e.dot(v,y)/e.dot(v,v),w=e.scalarMultiply(v,x);return e.add(f,w)}e.projectionOnto=d;function u(f,g,m){return l(f,d(f,g,m))}e.projectionOntoDistance=u;function p(f,g){return[(f[0]+g[0])*.5,(f[1]+g[1])*.5]}e.center=p})(cn||(cn={}));var il;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function a(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=a;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,c){return[l[0]+(h[0]-l[0])*c,l[1]+(h[1]-l[1])*c,l[2]+(h[2]-l[2])*c]}e.lerp=o})(il||(il={}));var uf;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a,r[2]+(s[2]-r[2])*a,r[3]+(s[3]-r[3])*a]}e.lerp=i})(uf||(uf={}));var m_;(e=>{let t=180/Math.PI,i=Math.PI/180;function r(o){return typeof o=="number"?o*t:o}function s(o){return typeof o=="number"?o*i:o}function a(o){return[r(o[0]),r(o[1]),r(o[2])]}e.radToDeg=a;function n(o){return[s(o[0]),s(o[1]),s(o[2])]}e.degToRad=n})(m_||(m_={}));var Rh;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let n=0;n<16;n++)if(s[n]!==a[n])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,a){let n=a.slice(0);for(var o=0,l=a.length;o{function t(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}e.toRgb255a1=i;function r(h){return{r:h.r,g:h.g,b:h.b}}e.clone=r;function s(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}e.fromHex=s;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}e.toHex=a;function n(h,c){return h.r===c.r&&h.g===c.g&&h.b===c.b}e.equals=n;function o(h,c){return h.r.toFixed(2)===c.r.toFixed(2)&&h.g.toFixed(2)===c.g.toFixed(2)&&h.b.toFixed(2)===c.b.toFixed(2)}e.equalsFixed=o;function l(h,c,d){return{r:h.r+(c.r-h.r)*d,g:h.g+(c.g-h.g)*d,b:h.b+(c.b-h.b)*d}}e.lerp=l})(ur||(ur={}));var Ht;(e=>{e.white={...ur.white,a:1},e.transparent={...ur.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}e.from0to1=t;function i(l,h){return{...ur.fromHex(l),a:h}}e.fromHexAndA=i;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}e.toRgb255a1=r;function s(l,h){return ur.equals(l,h)&&l.a===h.a}e.equals=s;function a(l,h){return ur.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)}e.equalsFixed=a;function n(l,h,c){return{r:l.r+(h.r-l.r)*c,g:l.g+(h.g-l.g)*c,b:l.b+(h.b-l.b)*c,a:l.a+(h.a-l.a)*c}}e.lerp=n;function o({r:l,g:h,b:c,a:d}=e.white){return`rgba(${l*255}, ${h*255}, ${c*255}, ${d})`}e.toStyle=o})(Ht||(Ht={}));var d0;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(d0||(d0={}));var Y8=(e=>(e[e.LINEAR=0]="LINEAR",e[e.EASE=1]="EASE",e[e.EASE_IN=2]="EASE_IN",e[e.EASE_OUT=3]="EASE_OUT",e[e.EASE_IN_OUT=4]="EASE_IN_OUT",e[e.CUBIC=5]="CUBIC",e[e.SPRING=6]="SPRING",e))(Y8||{}),u0;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(u0||(u0={}));var p0;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(p0||(p0={}));var Vn;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(Vn||(Vn={}));function g_(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var hl;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(hl||(hl={}));var Lh;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){var r,s;return i.type==="PerspectiveCamera"?((r=i.perspective)==null?void 0:r.zoom)??1:((s=i.orthographic)==null?void 0:s.zoom)??1}e.getZoom=t})(Lh||(Lh={}));var Kn;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(a=>a*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let a={...r};if(hC.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;cC.forEach(l=>{Object.assign(a.radial,{[l]:o[l]??n[l]})})}if(a.linear={...r.linear},s.linear){let n=r.linear,o=s.linear;dC.forEach(l=>{Object.assign(a.linear,{[l]:o[l]??n[l]})})}if(a.grid={...r.grid},s.grid){let n=r.grid,o=s.grid;uC.forEach(l=>{Object.assign(a.grid,{[l]:o[l]??n[l]})})}if(a.toObject={...r.toObject},s.toObject){let n=r.toObject,o=s.toObject;pC.forEach(l=>{Object.assign(a.toObject,{[l]:o[l]??n[l]})})}if(a.randomnessObject={...r.randomnessObject},s.randomnessObject){let n=r.randomnessObject,o=s.randomnessObject;fC.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(Kn||(Kn={}));var f0;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let a=[];r.count!==void 0&&a.push({type:0,path:s,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&a.push({type:0,path:[...s,n],props:o})}return a}e.toOps=i})(f0||(f0={}));var hC=["count"],cC=["radius","start","end","position","scale","rotation"],dC=["position","scale","rotation"],uC=["count","size"],pC=["count","position","scale","rotation"],fC=["strength","scale","rotation","position","movement","seed","freqScale"],m0;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(m0||(m0={}));var g0;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Ht.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ht.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Ht.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(g0||(g0={}));var pf;(e=>(e.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}))(pf||(pf={}));var zh;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(zh||(zh={}));var v0;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(v0||(v0={}));var y0;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(y0||(y0={}));var x0;(e=>e.defaultData={...y0.defaultData,...v0.defaultData})(x0||(x0={}));var v_;(e=>{function t(i,r){var a,n;let s=[];if("material"in i){let o=typeof i.material=="string"?r.materials[i.material]??((a=r.lib.materials[i.material])==null?void 0:a.asset):i.material;o&&s.push(o)}else if("materials"in i)for(let o of i.materials){let l=typeof o=="string"?r.materials[o]??((n=r.lib.materials[o])==null?void 0:n.asset):o;l&&s.push(l)}return s}e.getMaterialData=t})(v_||(v_={}));var ff;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ff||(ff={}));var y_;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="particle"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(y_||(y_={}));function Q8(e){return e.type!=="displace"}var x_;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(x_||(x_={}));var mC=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Z8=["wrapping","image","video","name","minFilter","magFilter"],Ji;(e=>{function t(a,n){let{texture:o,...l}=n;if(Object.assign(a,l),o){let h=a.texture;h&&Object.assign(h,o)}}e.patch=t;function i(a,n){return a==="light"&&n?r(n):s(a)}e.defaultData=i;function r(a){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(a){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...n,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ff.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...n,type:"color",color:ur.fromHex(as)};case"depth":return{...n,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ur.fromHex(6710886),a:1},colorB:{...ur.fromHex(6710886),a:1},colorC:{...ur.fromHex(16777215),a:1},colorD:{...ur.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...n,type:"fresnel",color:Ht.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Ht.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:Ht.fromHexAndA(0,1),contourColor:Ht.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...n,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ur.fromHex(0),a:1},colorB:{...ur.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Ji||(Ji={}));var ir;(e=>{function t(c){return!c.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}e.isMergable=t;function i(c){let d="";return c.layers.forEach(u=>{Object.entries(u.data).forEach(([p,f])=>{d+=`${p}${f}`,Array.isArray(f)?f.forEach(g=>d+=`${g}`):typeof f=="object"?Object.values(f).forEach(g=>{typeof g=="number"?d+=`${g.toFixed(4)}`:d+=`${g}`}):d+=`${f}`})}),d}e.getHash=i;function r(){return{layers:new We}}e.defaultEmptyData=r;function s(c="layer1",d="layer2"){return n("phong",c,d)}e.defaultData=s;function a(c,d){return{...c,name:d}}e.withName=a;function n(c,d="layer1",u="layer2"){let p=new We;return p.push({fi:0,data:Ji.defaultData("light",c),id:d}),p.push({fi:1,data:Ji.defaultData("color"),id:u}),{layers:p}}e.defaultTwoLayerData=n;function o(c){let d=Ji.defaultData("texture");c&&Object.assign(d.texture,{image:c});let u=new We;return u.push({fi:0,data:d,id:"layer1"}),u.push({fi:1,data:{...Ji.defaultData("transmission"),alpha:1},id:"layer2"}),u.push({fi:2,data:{...Ji.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:u}}e.defaultUIObjectMaterial=o;function l(c,d="phong",u="layer1",p="layer2"){let f=Ji.defaultData("texture");Object.assign(f.texture,{image:c});let g=new We;return g.push({fi:0,data:f,id:u}),g.push({fi:1,data:Ji.defaultData("light",d),id:p}),{layers:g}}e.defaultTwoLayerTextureData=l;function h(c,d="phong",u="layer1",p="layer2"){let f=Ji.defaultData("video");Object.assign(f.texture,{video:c});let g=new We;return g.push({fi:0,data:f,id:u}),g.push({fi:1,data:Ji.defaultData("light",d),id:p}),{layers:g}}e.defaultTwoLayerVideoTextureData=h})(ir||(ir={}));var mf;(e=>{function t(){return{points:new We,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(mf||(mf={}));var gf;(e=>{function t(){return{points:new We,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(gf||(gf={}));var gC={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},b0;(e=>{function t(i,r){let s={...i};return yC.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(b0||(b0={}));var vC={shape:gC,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},yC=["depth","offset","angle","twist","startScale","endScale"],vf;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"||r==="InputGeometry"}e.isParametricMesh=i})(vf||(vf={}));var w0;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,b0.merge(s.extrusion,r.extrusion))),s}e.merge=t})(w0||(w0={}));var Gn;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:gf.defaultData(),extrusion:vC};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:mf.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(Gn||(Gn={}));var vg=["width","height","depth"],_0;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:ur.white,near:.1,far:2e3})(_0||(_0={}));var yf;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})(yf||(yf={}));var S0;(e=>e.defaultData={softShadowQuality:"low"})(S0||(S0={}));var A0;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(A0||(A0={}));var M0;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(M0||(M0={}));var Bh;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Bh||(Bh={}));var E0;(e=>e.defaultData={playCamera:ic,gameControlObject:null})(E0||(E0={}));var C0;(e=>e.defaultData={backgroundColor:Ht.fromHexAndA(X8,1),postprocessing:yf.defaultData,fog:_0.defaultData,globalPhysics:Bh.defaultData,ambient:A0.defaultData,ao:M0.defaultData,shadow:S0.defaultData,publish:E0.defaultData})(C0||(C0={}));var T0;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(T0||(T0={}));var b_;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(b_||(b_={}));var Fh;(e=>{e.identity={...d0.identity,hiddenMatrix:Rh.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,a){return{position:(a==null?void 0:a.position)||s.position,rotation:(a==null?void 0:a.rotation)||s.rotation,scale:(a==null?void 0:a.scale)||s.scale,hiddenMatrix:(a==null?void 0:a.hiddenMatrix)||s.hiddenMatrix}}e.merge=i;function r(s,a){return LE({position:il.isEqual(s.position,a.position)?void 0:a.position,rotation:il.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:il.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:Rh.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(Fh||(Fh={}));var Hi;(e=>e.defaultData={states:new We,events:new We,visible:!0,raycastLock:!1,physics:zh.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Fh.identity,cloner:null})(Hi||(Hi={}));var P0;(e=>e.defaultData={type:"Empty",...Hi.defaultData})(P0||(P0={}));var w_;(e=>e.defaultData={type:"ParticleCollider",...T0.defaultData,...Hi.defaultData})(w_||(w_={}));var __;(e=>e.defaultData={type:"Component",...Hi.defaultData})(__||(__={}));var S_;(e=>e.defaultData={type:"Particle",...Hi.defaultData,...pf.defaultData})(S_||(S_={}));var Hn;(e=>e.defaultData={type:"Mesh",...Hi.defaultData,...x0.defaultData})(Hn||(Hn={}));var Sd;(e=>e.defaultData={...Hi.defaultData,...Fh.identity,position:[0,0,Lh.DefaultTargetOffset],...Lh.defaultData})(Sd||(Sd={}));var D0;(e=>{function t(i){return{...Hi.defaultData,...g0.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(D0||(D0={}));var xf;(e=>{function t(r,s,a=0){for(;a{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Hi.defaultData,...s,component:r,overrides:new Ri,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Fh.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Jn||(Jn={}));var Uh;(e=>{e.defaultData={type:"Page",...Hi.defaultData,physics:{...zh.defaultData,fusedBody:!1},...C0.defaultData,camera:Sd.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(Uh||(Uh={}));var I0;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Rh.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:zh.defaultData,states:new We,events:new We,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Lh.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("RectangleGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("BooleanGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")},e.defaultShapeBlendObject={name:"Shape Blend",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("ShapeBlendGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("TextGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")},e.defaultInputObject={name:"Input",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("InputGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")}))(I0||(I0={}));var Wo;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new Ri}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new Ri})))):hl.is(a.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(a,n){if(n===void 0)return a;let o={...a};return"material"in o&&"material"in n&&n.material&&(o.material=_d(o.material,l=>{if(typeof l!="string")for(let[h,c]of Object.entries(n.material.layers)){let d=l.layers.data(h);d&&Ji.patch(d,c)}}).data),o.materials&&n.materials&&(o.materials=_d(o.materials,l=>{var h,c;for(let d=0;d0){let v={path:[...d,"layers",p,"texture"],props:g,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...d,"layers",p],props:m,type:0};l.push(v)}}}for(let[d,u]of Object.entries(n))if(d!=="name")if(d==="cloner")l.push(...f0.toOps(u,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:u.slide,offset:u.offset},type:0});else if(d==="material")c(["material"],u);else if(d==="materials")for(let[p,f]of Object.entries(u))c(["materials",p],f);else if(h[d]===0){if(d==="geometry"&&u.extrusion!==void 0){let p={path:[d,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[d],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[d]=u;return l}e.toOps=r;function s(a,n){var l,h,c,d,u,p;if(n===void 0)return a;let o={...a};if(Object.assign(o,Fh.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:((l=n.pathSnapping)==null?void 0:l.slide)??((h=o.pathSnapping)==null?void 0:h.slide)??0,offset:((c=n.pathSnapping)==null?void 0:c.offset)??((d=o.pathSnapping)==null?void 0:d.offset)??0})}),hl.is(a.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let f=n;((u=f.orthographic)==null?void 0:u.zoom)!==void 0&&(o.orthographic.zoom=f.orthographic.zoom),((p=f.perspective)==null?void 0:p.zoom)!==void 0&&(o.perspective.zoom=f.perspective.zoom),f.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=f.isUpVectorFlipped),f.targetOffset!==void 0&&(o.targetOffset=f.targetOffset)}else if(a.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:w0.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Kn.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Kn.merge(o.cloner,n.cloner)});else if(m0.is(a.type)){let f=n;f.intensity!==void 0&&(o.intensity=f.intensity),f.color!==void 0&&(typeof f.color=="string"?o.color=f.color:o.color=ur.clone(f.color))}return o}e.patch=s})(Wo||(Wo={}));var bf;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(bf||(bf={}));var dn;(e=>e.defaultData={orbitControls:bf.defaultData,playPage:Jc,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(dn||(dn={}));var O0;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(O0||(O0={}));var R0;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(R0||(R0={}));var qo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...O0.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:R0.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(qo||(qo={}));var Ad;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,a){r.scene.objects.traverseFrom(s,(n,o)=>{var l;if(o.type==="Instance"){let h=(l=Sf.getComponentData(r,o.component))==null?void 0:l.data;h&&a(n,o,h.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(Ad||(Ad={}));var Xo;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:D0.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function t(s=!0,a=[]){let n=[],o=I0.defaultMeshObject;s&&(n.push({...e.defaultLight}),n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:o,children:[]})),n.push(...a);let l=new fr;return l.push({fi:1,id:Jc,data:{...Uh.defaultData,name:"Scene 1"},children:n}),l}e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:dn.defaultData,styles:qo.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new fr,publish:dn.defaultData,styles:qo.defaultData()}},e.emptyDataWithPage=function(s=!0){return{objects:t(s),publish:dn.defaultData,styles:qo.defaultData()}},e.emptyData=function(){return{objects:new fr,publish:{...dn.defaultData},styles:qo.defaultData()}};function i(s){return{...e.defaultData,objects:Ms(s,fr.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(Xo||(Xo={}));var $c;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})($c||($c={}));var L0;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new We}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(L0||(L0={}));var A_;(e=>e.defaultData=(t,i="GET")=>({url:t,method:i,name:"New API",headers:new We,queries:new We,autoStart:!0}))(A_||(A_={}));var mr;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function s(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=s;function a(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=a})(mr||(mr={}));var z0;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(z0||(z0={}));var M_;(e=>e.all=[...z0.all,"components"])(M_||(M_={}));var E_;(e=>{function t(){return{images:new $e,videos:new $e,colors:new $e,audios:new $e,particles:new $e,fonts:new $e,materials:new $e,components:new $e,variables:new $e,userAPIs:new $e,userWebhooks:new $e}}e.defaultData=t})(E_||(E_={}));var yn;(e=>{function t(){return{images:new $e,videos:new $e,colors:new $e,audios:new $e,particles:new $e,fonts:new $e,materials:new $e,components:new $e,variables:new $e,userAPIs:new $e,userWebhooks:new $e}}e.defaultData=t})(yn||(yn={}));var vs;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ms(n,$e.prototype)}e.defaultColors=t;function i(){return Ms({},$e.prototype)}e.defaultImages=i;function r(){return{catelogs:new $e,materials:new $e,images:new $e,videos:new $e,colors:new $e,audios:new $e,particles:new $e,fonts:new $e,variables:new We,userAPIs:new $e,userWebhooks:new $e,lib:yn.defaultData()}}e.emptyData=r;function s(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=s;function a(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),c=Math.round(n-l*3600-h*60);return{textValue:[l,h,c]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=a})(vs||(vs={}));var wf;(e=>e.list=["idle","move","jump","run"])(wf||(wf={}));var _f;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","▲"],["rotPosY","◀"],["rotNegX","▼"],["rotNegY","▶"],["jump","Space"],["run","⇧"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new We,move:new We,jump:new We,run:new We},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ht.fromHexAndA(3728051,1)}}))(_f||(_f={}));function C_(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],a=[0,1];for(let o=2;o<10;o++)s.push(s[1]),a.push(1);let n={...Sa(wi(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:a,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...wi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Wn(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function qn(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=ir.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ir.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ir.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Ri.prototype&&t(s.material)})})}function K8(e){Object.assign(e.scene.publish,{orbitControls:{...bf.defaultData,...wi(e.scene.publish.orbitControls)}})}function J8(e){Object.assign(e.scene.publish.settings,{video:{...dn.defaultData.settings.video,...wi(e.scene.publish.settings.video)}})}function $8(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,a]of Object.entries(r))if((mC.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(Z8.includes(n)||typeof o=="boolean")&&delete a[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let a=s;a.material?t(a.material):a.materials&&a.materials.forEach(n=>{t(n)})})})}function e9(e){e.scene.publish.withBackground=!0}function t9(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function i9(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function r9(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function s9(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=wi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=wi(i).booleanExclude!==!0)}})}function a9(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function n9(e){function t(r){Object.setPrototypeOf(r,Ri.prototype),r.texture&&Object.setPrototypeOf(r.texture,Ri.prototype)}function i(r){Object.setPrototypeOf(r,Ri.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(a=>{let n=a;if(n.material){let o=wi(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...wi(t),colors:i,steps:r};Object.assign(t,s)}})}function o9(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function P_(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&yg(r)}):"material"in i&&typeof i.material!="string"&&yg(i.material)}),Object.values(e.shared.materials).forEach(t=>yg(t))}function l9(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function h9(e){e.shared.audios=Ms({},$e.prototype)}function c9(e){e.shared.videos=Ms({},$e.prototype)}function d9(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function u9(e){Object.entries(wi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(wi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function p9(e){e.scene.publish.settings.web.preload=!1}function D_(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function I_(e){e.layers&&e.layers.forEach(t=>{Q8(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function f9(e){e.shared.fonts=Ms({},$e.prototype)}function m9(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function g9(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=ir.defaultTwoLayerData("phong"),n=typeof s.color=="string"?e.shared.colors[s.color]:s.color;a.layers[1].data.color={r:n.r,g:n.g,b:n.b},a.layers[1].data.alpha=s.alpha;let o=m9(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Hi.defaultData,...Hn.defaultData,flatShading:!1,wireframe:!1,geometry:{...Gn.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:a,states:wi(s.states),events:wi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=wi(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function v9(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new We,move:new We,jump:new We}});else{let a=new We;Object.assign(s,{actions:a}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&a.push({fi:0,id:Re.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(c,Sa(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(c,{control1:{...n.control1},control2:{...n.control2}});let d={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},u={state:n.state,...d,...c},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new We({fi:0,id:Re.generateUUID(),data:h},{fi:1,id:Re.generateUUID(),data:u})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function y9(e){e.scene.objects.traverse((t,i)=>{function r(s,a){var l;let n=new We,o=[];if(i.events.forEach((h,c,d)=>{if(h.type==="Audio"&&h.trigger===a){let u;o.push(c),h.interaction==="play"?u={...Sa(h,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in h?h.after:void 0,toggle:"after"in h?h.toggle:void 0,type:"Audio"}:(h.interaction==="pause"||h.interaction==="stop")&&(u={...Sa(h,"interaction","delay","object","playAudio"),type:"Audio"}),u&&n.push({fi:d,id:c,data:u})}}),o.forEach(h=>i.events.delete(h)),n.length){let h=(l=i.events.find(c=>c.type===s))==null?void 0:l.data;h?"actions"in h&&h.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:Re.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function O_(e){var i;let t=(i=e.layers.find(r=>r.type==="light"))==null?void 0:i.data;if((t==null?void 0:t.category)==="basic"){let r=Ji.defaultData("light","phong"),s=t;Object.assign(s,r),s.visible=!1}}function R_(e){Wn(e,O_),qn(e,O_)}function x9(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function b9(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function w9(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=ir.defaultTwoLayerData("phong"))})}function _9(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function S9(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function A9(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function M9(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function E9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function C9(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function T9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=_f.defaultDataThirdPerson.navmesh)})})}function P9(e){e.scene.styles||(e.scene.styles=qo.defaultData())}function L_(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function D9(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),qn(e,L_),Wn(e,L_)}function I9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new We})})})}function O9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","⇧"],["none","Ctrl"]])})})}function z_(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function R9(e,t){if(t<1&&(qn(e,C_),Wn(e,C_),e.schema=1),t<2&&(K8(e),e.schema=2),t<3&&($8(e),e.schema=3),t<4&&(e9(e),e.schema=4),t<5&&(t9(e),e.schema=5),t<6&&(i9(e),e.schema=6),t<7&&(r9(e),e.schema=7),t<8&&(e.schema=8),t<9&&(P_(e),e.schema=9),t<10&&(o9(e),e.schema=10),t<11&&(l9(e),e.schema=11),t<12&&(P_(e),e.schema=12),t<13&&(h9(e),e.schema=13),t<14&&(d9(e),e.schema=14),t<15&&(u9(e),e.schema=15),t<16&&(p9(e),e.schema=16),t<17&&(qn(e,D_),Wn(e,D_),e.schema=17),t<18&&(qn(e,T_),Wn(e,T_),e.schema=18),t<19&&(J8(e),e.schema=19),t<20&&(f9(e),g9(e),e.schema=20),t<21&&(v9(e),y9(e),e.schema=21),t<22&&(R_(e),e.schema=22),t<23&&(x9(e),e.schema=23),t<24&&(b9(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(c9(e),t<25&&(e.schema=25)),t<26&&(s9(e),e.schema=26),t<27&&(a9(e),e.schema=27),t<28&&(R_(e),e.schema=28),t<29&&(n9(e),e.schema=29),t<30&&(w9(e),e.schema=30),t<31&&(_9(e),e.schema=31),t<33&&(S9(e),e.schema=33),t<34&&(A9(e),e.schema=34),t<35&&(M9(e),e.schema=35),t<36&&(E9(e),e.schema=36),t<37&&(C9(e),e.schema=37),t<38&&(qn(e,I_),Wn(e,I_),e.schema=38),t<39&&(T9(e),e.schema=39),t<40&&(P9(e),e.schema=40),t<41&&(D9(e),e.schema=41),t<42&&(I9(e),e.schema=42),t<43&&(O9(e),e.schema=43),t<99){qn(e,z_),Wn(e,z_),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=ic);let i=wi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Jc,r.insertBefore(null,null,[{id:Jc,data:{...Uh.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Sa(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Sa(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Bh.defaultData,...Sa(e.scene.environment,"usePhysics","gravity")},camera:wi(e.scene.ownerCamera)??Uh.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==Xo.TRASH_CAN_ID&&r.move(Jc,n.fi,n.id);let s=0,a=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(a,1)],a+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,zh.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function B_(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function L9(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function z9(e){var t;Array.isArray(wi(e.events))&&((t=e.events)==null||t.forEach(i=>{"disabled"in i||(i.disabled=!1),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress")&&(i.mode=i.mode||"Object")}))}var ih=180/Math.PI;function F_(e){e.rotation=e.rotation.slice(0,3).map(t=>t*ih)}function xC(e){var i,r;F_(e),e.type==="Page"&&F_(e.camera),(i=e.states)==null||i.forEach(s=>{s.rotation===void 0||s.rotation===null||(s.rotation=s.rotation.slice(0,3).map(a=>a*ih))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ih),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ih),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ih,t.extrusion.twist*=ih),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(wi(e.events))&&((r=e.events)==null||r.forEach(s=>{(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="KeyPress"||s.type==="Collision"||s.type==="Trigger")&&(s.runMode=s.toggle?"Toggle":"Repeat")}))}function B9(e){e.shared.variables=Ms({},$e.prototype)}function F9(e){let t=wi(e.shared.variables);e.shared.variables=Ms(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),We.prototype)}var $a=117;function bC(e,t){t(e.data);for(let i of e.children)bC(i,t)}function U9(e){let t=e.schema??104;t!==$a&&t<105&&(bC(e.asset,xC),e.schema=105)}function N9(e){e.shared.particles=Ms({},$e.prototype),e.shared.lib&&(e.shared.lib.particles=yn.defaultData().particles)}function k9(e){e.scene.objects.traverse((t,i)=>{i.type==="Particle"&&typeof i.renderMaterial.size=="number"&&Object.assign(i.renderMaterial,{size:[i.renderMaterial.size,i.renderMaterial.size]})})}function V9(e){e.scene.objects.traverse((t,i)=>{i.type==="Page"&&(i.postprocessing.depthOfField.focusDistance=100,i.postprocessing.depthOfField.focalLength=20,i.postprocessing.depthOfField.bokehScale=5)})}function j9(e){e.scene.objects.traverse((t,i)=>{var r;Array.isArray(wi(i.events))!==!1&&((r=i.events)==null||r.forEach(s=>{var n,o,l,h,c,d,u,p,f,g,m;let a=s.runMode;s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="Collision"||s.type==="Trigger"?(n=s.actions)==null||n.forEach(v=>{v.type==="Transition"&&(v.runMode=a??"Repeat"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode=a==="Toggle"?"Toggle":"Normal")}):s.type==="MouseHover"||s.type==="MousePress"||s.type==="KeyPress"?(o=s.actions)==null||o.forEach(v=>{(v.type==="Transition"||v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Toggle")}):s.type==="GameControl"?(delete s.actions,Object.keys(s.gameActions).forEach(v=>{var y;(y=s.gameActions[v])==null||y.forEach(x=>{x.type==="Transition"&&(x.runMode="Repeat"),x.type==="Animation"&&(x.runMode="Normal")})})):s.type==="DragDrop"?(delete s.actions,(h=(l=s.dragDropActions)==null?void 0:l.drag)==null||h.forEach(v=>{(v.type==="Transition"||v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Toggle")}),(d=(c=s.dragDropActions)==null?void 0:c.drop)==null||d.forEach(v=>{(v.type==="Transition"||v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Toggle")})):s.type==="Resize"?(delete s.actions,(u=s.breakpoints)==null||u.forEach(v=>{var y;(y=v.actions)==null||y.forEach(x=>{(x.type==="Transition"||x.type==="Animation"||x.type==="SwitchCamera")&&(x.runMode="Toggle")})})):s.type==="Start"?(p=s.actions)==null||p.forEach(v=>{v.type==="Transition"&&(v.runMode="Once"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Normal")}):s.type==="VariableChange"||s.type==="Scroll"?(f=s.actions)==null||f.forEach(v=>{v.type==="Transition"&&(v.runMode="Repeat"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Normal")}):s.type==="Conditional"&&(delete s.actions,(g=s.inActions)==null||g.forEach(v=>{v.type==="Transition"&&(v.runMode="Repeat"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Normal")}),(m=s.outActions)==null||m.forEach(v=>{v.type==="Transition"&&(v.runMode="Repeat"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Normal")}))}))})}function G9(e){e.shared.userAPIs=Ms({},$e.prototype),e.shared.userWebhooks=Ms({},$e.prototype),e.shared.lib&&(e.shared.lib.userAPIs=yn.defaultData().userAPIs,e.shared.lib.userWebhooks=yn.defaultData().userWebhooks)}function H9(e){e.scene.publish.settings.videoStatic===void 0&&(e.scene.publish.settings.videoStatic=dn.defaultData.settings.videoStatic)}function wC(e){let t=e.schema??0;if(t!==$a){console.warn("updating from ",t,"to ",$a),R9(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=dn.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(qn(e,B_),Wn(e,B_),e.schema=101),t<102&&(L9(e),e.schema=102),t<104&&(e.shared.catelogs=new $e,e.shared.lib=yn.defaultData(),e.schema=104),t<105&&(B9(e),e.scene.objects.traverse((i,r)=>{xC(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))U9(i);t<106&&(F9(e),e.schema=106),t<107&&(e.shared.lib.variables=yn.defaultData().variables,e.schema=107),t<109&&(N9(e),e.schema=109),t<110&&(k9(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{z9(r)}),e.schema=111),t<112&&(V9(e),e.schema=112),t<113&&(j9(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(G9(e),e.schema=115),t<116&&(H9(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117)}}var Sf;(e=>{e.defaultData={schema:$a,scene:Xo.defaultData,frames:new $e().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",$c.defaultData),shared:{...vs.emptyData(),colors:vs.defaultColors()}},e.emptyDataForImports=function(){let a=Xo.emptyDataWithPage();return{schema:$a,scene:a,frames:new $e().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",$c.defaultData),shared:{...vs.emptyData(),colors:vs.defaultColors(),images:vs.defaultImages()}}},e.emptyData=function(){return{schema:$a,scene:Xo.emptyDataWithPage(),frames:new $e().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",$c.defaultData),shared:vs.emptyData()}},e.clipboard2dData=function(){return{schema:$a,scene:Xo.emptyData(),frames:new $e,shared:vs.emptyData()}},e.collabHelper={...e0,updateSchema(a){return(a.schema??0)<$a?_d(a,wC):(a.schema??0)-$a}};function t(a){let n=e.collabHelper.updateSchema(a);return typeof n=="number"?n===0?a:null:n.data}e.updateSchemaDirectly=t;function i(a){return{...a,shared:{...a.shared,lib:yn.defaultData()}}}e.withoutLib=i;function r(a,n){let o=a.scene.objects.get(n);if(o&&o.data.type==="Component")return o;{let l=a.shared.lib.components[n];if(l)return l.asset}}e.getComponentData=r;function s(a){let n=Object.values(a.shared.userAPIs);for(let o of n){let l=o.headers;for(let h of l)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}e.hasSensitiveData=s})(Sf||(Sf={}));var B0;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(B0||(B0={}));var U_;(e=>{function t(i){return!0}e.is=t})(U_||(U_={}));var Af;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(r,s){return{position:(s==null?void 0:s.position)??r.position,rotation:(s==null?void 0:s.rotation)??r.rotation,scale:(s==null?void 0:s.scale)??r.scale,shear:(s==null?void 0:s.shear)??r.shear}}e.merge=t;function i(r,s){return LE({position:cn.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:cn.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&cn.isEqual(r.shear,s.shear)?void 0:s.shear})}e.diff=i})(Af||(Af={}));var F0;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})(F0||(F0={}));var N_;(e=>e.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(N_||(N_={}));var Mf;(e=>e.defaultData={opacity:1,fill:{color:Ht.fromHexAndA(as,1),enabled:!0},stroke:{color:Ht.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Ht.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ht.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Mf||(Mf={}));var Yo;(e=>{function t(n,o){return{name:o}}e.newEmpty=t;function i(n,o){if(o===void 0)return n;let l={...n},h=["width","height","cornerRadius"];for(let c of h)c in l&&c in o&&o[c]!==void 0&&Object.assign(l,{[c]:o[c]});return l}function r(n,o){if(o===void 0)return n;let l={...n};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}function s(n,o){if(o===void 0)return n;let l={...n};return Object.assign(l,Af.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=s;function a(n,o){let l,h=[];for(let[c,d]of Object.entries(o))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[c]=d);return h}e.toOps=a})(Yo||(Yo={}));var Md;(e=>e.defaultData={...Af.defaultData,...F0.defaultData,states:new We,events:new We,visible:!0,raycastLock:!1})(Md||(Md={}));var Nh;(e=>e.defaultData={...Md.defaultData,...Mf.defaultData})(Nh||(Nh={}));var Ef;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(Ef||(Ef={}));var U0;(e=>e.defaultData={...Nh.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(U0||(U0={}));var Ed;(e=>e.defaultData={...Nh.defaultData,...Ef.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Ed||(Ed={}));var N0;(e=>e.defaultData={...Nh.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(N0||(N0={}));var k0;(e=>e.defaultData={...Nh.defaultData,type:"path2d",path:"",name:"Path"})(k0||(k0={}));var k_;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"||i.type==="path2d"}e.is=t})(k_||(k_={}));var Cf;(e=>e.defaultData={...Md.defaultData,name:"Group",type:"group2d"})(Cf||(Cf={}));var V0;(e=>e.defaultData=()=>({...Md.defaultData,...Ef.defaultData,...Mf.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ht.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ht.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(V0||(V0={}));var rl;(e=>{function t(n){switch(n){case"rectangle2d":return{...Ed.defaultData};case"ellipse2d":return{...U0.defaultData};case"text2d":return{...N0.defaultData};case"vector2d":return{...Ed.defaultData};case"path2d":return{...k0.defaultData};case"frame2d":return{...V0.defaultData()};case"group2d":return{...Cf.defaultData}}}e.defaultData=t;function i(n){return"width"in n&&"height"in n?[typeof n.width=="number"?n.width*.5:0,typeof n.height=="number"?n.height*.5:0]:[0,0]}e.getPivot=i;function r(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"}e.isResizeable=r;function s(n){return n.type==="frame2d"&&n.autoLayout!==void 0}e.isAutoLayoutable=s;function a(n){return n.type==="rectangle2d"||n.type==="frame2d"}e.hasCorners=a})(rl||(rl={}));var j0;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new fr},e.emptyData=function(){return{type:"scene2d",objects:new fr}}))(j0||(j0={}));function Qo(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),a={},n={},o=e[0].morphTargetsRelative,l=new Ge,h=0;for(let c=0;ci&&(i=s,t=r)}return t}function G_(e,t){t.set(e)}function H_(e,t,i){let r,s;for(let a=0;a<3;a++){let n=a+3;r=e[a],s=t[a],i[a]=rs?r:s}}function Lu(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],a=t[e+2*r+1],n=s-a,o=s+a;ni[r+3]&&(i[r+3]=o)}}function xc(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function q9(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new tt(s,1));for(let a=0;as-a);for(let s=0;sl&&(l=A),v&&wf&&(f=w);let S=e[y+2],E=e[y+3],C=S-E,T=S+E;Ch&&(h=T),v&&Sg&&(g=S);let D=e[y+4],O=e[y+5],P=D-O,U=D+O;Pc&&(c=U),v&&Dm&&(m=D)}r[0]=a,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=c,v&&(s[0]=d,s[1]=u,s[2]=p,s[3]=f,s[4]=g,s[5]=m)}function Y9(e,t,i,r){let s=1/0,a=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=t*6,d=(t+i)*6;co&&(o=u);let p=e[c+2];pl&&(l=p);let f=e[c+4];fh&&(h=f)}r[0]=s,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function Q9(e,t,i,r,s){let a=i,n=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;a<=n&&t[a*6+l]=o;)n--;if(ae.candidate-t.candidate,In=new Array(Xa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),zu=new Float32Array(6);function K9(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=j_(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=j_(e),n!==-1&&(o=J9(i,r,s,n));else if(a===2){let l=xc(e),h=1.25*s,c=r*6,d=(r+s)*6;for(let u=0;u<3;u++){let p=t[u],f=(t[u+3]-p)/Xa;if(s=_.candidate?Lu(y,i,_.rightCacheBounds):(Lu(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y=Xa&&(y=Xa-1);let x=In[y];x.count++,Lu(v,i,x.bounds)}let g=In[Xa-1];G_(g.bounds,g.rightCacheBounds);for(let v=Xa-2;v>=0;v--){let y=In[v],x=In[v+1];H_(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;vb&&(b=x),w>b&&(b=w);let A=(b-_)/2,S=v*2;a[p+S+0]=_+A,a[p+S+1]=A+(Math.abs(_)+A)*W9,_t[v+3]&&(t[v+3]=b)}}return a}function e7(e,t){function i(v){u&&u(v/p)}function r(v,y,x,w=null,_=0){if(!f&&_>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),x<=c||_>=l)return i(y+x),v.offset=y,v.count=x,v;let b=K9(v.boundingData,w,n,y,x,d);if(b.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let A=Q9(o,n,y,x,b);if(A===y||A===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=b.axis;let S=new Ru,E=y,C=A-y;v.left=S,S.boundingData=new Float32Array(6),xg(n,E,C,S.boundingData,a),r(S,E,C,a,_+1);let T=new Ru,D=A,O=x-C;v.right=T,T.boundingData=new Float32Array(6),xg(n,D,O,T.boundingData,a),r(T,D,O,a,_+1)}return v}q9(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=$9(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,d=t.strategy,u=t.onProgress,p=e.index.count/3,f=!1,g=[],m=X9(e);if(m.length===1){let v=m[0],y=new Ru;y.boundingData=s,Y9(n,v.offset,v.count,a),r(y,v.offset,v.count,a),g.push(y)}else for(let v of m){let y=new Ru;y.boundingData=new Float32Array(6),xg(n,v.offset,v.count,y.boundingData,a),r(y,v.offset,v.count,a),g.push(y)}return g}function t7(e,t){let i=e7(e,t),r,s,a,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;cMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=x/4,x=h(x,v),s[u+7]=y,x}}}var xn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,a=e.length;sr?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,a=t.length;sr?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};xn.prototype.setFromBox=function(){let e=new M;return function(t,i){let r=i.min,s=i.max,a=1/0,n=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let c=t.dot(e);a=Math.min(c,a),n=Math.max(c,n)}this.min=a,this.max=n}}();var i7=function(){let e=new M,t=new M,i=new M;return function(r,s,a){let n=r.start,o=e,l=s.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let c=i.dot(h),d=h.dot(o),u=h.dot(h),p=i.dot(o),f=o.dot(o)*u-d*d,g,m;f!==0?g=(c*d-p*u)/f:g=0,m=(c+g*d)/u,a.x=g,a.y=m}}(),P1=function(){let e=new j,t=new M,i=new M;return function(r,s,a,n){i7(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,a),s.at(l,n);return}else if(o>=0&&o<=1){l<0?s.at(0,n):s.at(1,n),r.closestPointToPoint(n,!0,a);return}else if(l>=0&&l<=1){o<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let c;l<0?c=s.start:c=s.end;let d=t,u=i;if(r.closestPointToPoint(c,!0,t),s.closestPointToPoint(h,!0,i),d.distanceToSquared(c)<=u.distanceToSquared(h)){a.copy(d),n.copy(c);return}else{a.copy(h),n.copy(u);return}}}}(),r7=function(){let e=new M,t=new M,i=new qr,r=new _s;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let d=a.getPlane(i);if(Math.abs(d.distanceToPoint(o))<=n){let u=d.projectPoint(o,t);if(a.containsPoint(u))return!0}return!1}}(),s7=1e-15;function Fl(e){return Math.abs(e)new M),this.satBounds=new Array(4).fill().map(()=>new xn),this.points=[this.a,this.b,this.c],this.sphere=new $r,this.plane=new qr,this.needsUpdate=!0}intersectsSphere(e){return r7(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,n=s[0],o=a[0];this.getNormal(n),o.setFromPoints(n,r);let l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,r);let c=s[2],d=a[2];c.subVectors(t,i),d.setFromPoints(c,r);let u=s[3],p=a[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};bn.prototype.closestPointToSegment=function(){let e=new M,t=new M,i=new _s;return function(r,s=null,a=null){let{start:n,end:o}=r,l=this.points,h,c=1/0;for(let d=0;d<3;d++){let u=(d+1)%3;i.start.copy(l[d]),i.end.copy(l[u]),P1(i,r,e,t),h=e.distanceToSquared(t),h1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let _=0;_<4;_++){let b=v[_],A=y[_];if(r.setFromPoints(A,i),b.isSeparated(r))return!1}let x=u.satBounds,w=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let _=0;_<4;_++){let b=x[_],A=w[_];if(r.setFromPoints(A,t),b.isSeparated(r))return!1}for(let _=0;_<4;_++){let b=y[_];for(let A=0;A<4;A++){let S=w[A];if(a.crossVectors(b,S),r.setFromPoints(a,t),s.setFromPoints(a,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,y=!1,x=0;for(let O=0;O<3;O++){let P=v[O],U=v[(O+1)%3];h.start.copy(P),h.end.copy(U),h.delta(n);let W=y?c.start:c.end,k=Fl(m.distanceToPoint(P));if(Fl(m.normal.dot(n))&&k){c.copy(h),x=2;break}if((m.intersectLine(h,W)||k)&&!Fl(W.distanceTo(U))){if(x++,y)break;y=!0}}if(x===1&&u.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(x!==2)return!1;let w=u.points,_=!1,b=0;for(let O=0;O<3;O++){let P=w[O],U=w[(O+1)%3];h.start.copy(P),h.end.copy(U),h.delta(o);let W=_?d.start:d.end,k=Fl(g.distanceToPoint(P));if(Fl(g.normal.dot(o))&&k){d.copy(h),b=2;break}if((g.intersectLine(h,W)||k)&&!Fl(W.distanceTo(U))){if(b++,_)break;_=!0}}if(b===1&&this.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(b!==2)return!1;if(c.delta(n),d.delta(o),n.dot(o)<0){let O=d.start;d.start=d.end,d.end=O}let A=c.start.dot(n),S=c.end.dot(n),E=d.start.dot(n),C=d.end.dot(n),T=S0?p.start.copy(c.start):p.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(n)<0?p.end.copy(c.end):p.end.copy(d.end)),!0)}}}();bn.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();bn.prototype.distanceToTriangle=function(){let e=new M,t=new M,i=["a","b","c"],r=new _s,s=new _s;return function(a,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(a,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let c=0;c<3;c++){let d,u=i[c],p=a[u];this.closestPointToPoint(p,e),d=p.distanceToSquared(e),dnew M),this.satAxes=new Array(3).fill().map(()=>new M),this.satBounds=new Array(3).fill().map(()=>new xn),this.alignedSatBounds=new Array(3).fill().map(()=>new xn),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Ta.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){let d=1*l|2*h|4*c,u=r[d];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=c?i.z:t.z,u.applyMatrix4(e)}let s=this.satBounds,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],c=s[l],d=1<new _s),i=new Array(12).fill().map(()=>new _s),r=new M,s=new M;return function(a,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(s),this.closestPointToPoint(s,r),a.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=n*n,c=a.min,d=a.max,u=this.points,p=1/0;for(let g=0;g<8;g++){let m=u[g];s.copy(m).clamp(c,d);let v=m.distanceToSquared(s);if(v0&&h.normal.multiplyScalar(-1));let c={a,b:n,c:o,normal:new M,materialIndex:0};pr.getNormal(Ul,Nl,kl,c.normal),h.face=c,h.faceIndex=a}return h}function _C(e,t,i,r,s){let a=r*3,n=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),{position:h,normal:c,uv:d,uv1:u}=e.attributes,p=n7(i,h,c,d,u,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function o7(e,t,i,r,s,a){for(let n=r,o=r+s;n=0,d,u;c?(d=Td(e),u=Pd(e,o)):(d=Pd(e,o),u=Td(e));let p=Pf(d,a,r,Tf)?H0(d,t,i,r):null;if(p){let g=p.point[h];if(c?g<=a[u+l]:g>=a[u+l+3])return p}let f=Pf(u,a,r,Tf)?H0(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var d7=function(){let e,t,i=[],r=new SC(()=>new Si);return function(...a){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=s(...a);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),n};function s(a,n,o,l,h=null,c=0,d=0){function u(y){let x=y*2,w=no,_=oo;for(;!Xn(x,w);)y=Td(y),x=y*2;return yh(y,_)}function p(y){let x=y*2,w=no,_=oo;for(;!Xn(x,w);)y=Pd(y,_),x=y*2;return yh(y,_)+Cd(x,w)}let f=a*2,g=rc,m=no,v=oo;if(Xn(f,m)){let y=yh(a,v),x=Cd(f,m);return xa(a,g,e),l(y,x,!1,d,c+a,e)}else{let y=Td(a),x=Pd(a,v),w=y,_=x,b,A,S,E;if(h&&(S=e,E=t,xa(w,g,S),xa(_,g,E),b=h(S),A=h(E),As.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(h),b.b.applyMatrix4(h),b.c.applyMatrix4(h),b.needsUpdate=!0;for(let A=w*3,S=(_+w)*3;Anew bn),ed=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),ed.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),a;return t.cloneBuffers?a={roots:r.map(n=>n.slice()),index:s.array.slice()}:a={roots:r,index:s.array},a}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),ed.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,a=new ed(t,{...i,[bg]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new tt(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return a}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[bg]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[bg]||(this._roots=t7(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Si))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s,a,n,o,l=0,h=this._roots;for(let d=0,u=h.length;dw&&(w=C),T_&&(_=T),Db&&(b=D)}return o[d+0]!==v||o[d+1]!==y||o[d+2]!==x||o[d+3]!==w||o[d+4]!==_||o[d+5]!==b?(o[d+0]=v,o[d+1]=y,o[d+2]=x,o[d+3]=w,o[d+4]=_,o[d+5]=b,!0):!1}else{let g=d+8,m=a[d+6],v=g+u,y=m+u,x=p,w=!1,_=!1;e?x||(w=e.has(v),_=e.has(y),x=!w&&!_):(w=!0,_=!0);let b=x||w,A=x||_,S=!1;b&&(S=c(g,u,x));let E=!1;A&&(E=c(m,u,x));let C=S||E;if(C)for(let T=0;T<3;T++){let D=g+T,O=m+T,P=o[D],U=o[D+3],W=o[O],k=o[O+3];o[d+T]=Pk?U:k}return C}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(n,o=0){let l=n*2,h=s[l+15]===65535;if(h){let c=r[n+6],d=s[l+14];e(o,h,new Float32Array(i,n*4,6),c,d)}else{let c=n+8,d=r[n+6],u=r[n+7];e(o,h,new Float32Array(i,n*4,6),u)||(a(c,o+1),a(d,o+1))}}}raycast(e,t=Ws){let i=this._roots,r=this.geometry,s=[],a=t.isMaterial,n=Array.isArray(t),o=r.groups,l=a?t.side:t;for(let h=0,c=i.length;h{let m=p*3;return d(u,m,m+1,m+2,f,g)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=ta.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let d=o;o=(u,p,f,g,m)=>d(u,p,f,g,m)?!0:Y_(u,p,r,l,f,g,s)}else o||(l?o=(d,u,p,f)=>Y_(d,u,r,l,p,f,s):o=(d,u,p)=>p);let h=!1,c=0;for(let d of this._roots){if(kc(d),h=d7(0,r,n,o,a,c),ku(),h)break;c+=d.byteLength}return ta.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,a=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Vl.copy(t).invert();let h=ta.getPrimitive(),c=ta.getPrimitive();if(s){let u=function(p,f,g,m,v,y,x,w){for(let _=g,b=g+m;__g.intersectsBox(u),intersectsRange:(u,p,f,g,m,v)=>(wg.copy(v),wg.applyMatrix4(Vl),e.shapecast({intersectsBounds:y=>wg.intersectsBox(y),intersectsRange:(y,x,w,_,b)=>r(u,p,y,x,g,m,_,b)}))});return ta.releasePrimitive(h),ta.releasePrimitive(c),d}intersectsBox(e,t){return Po.set(e.min,e.max,t),Po.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Po.intersectsBox(i),intersectsTriangle:i=>Po.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Po.set(e.boundingBox.min,e.boundingBox.max,t),Po.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,c=e.index,d=ta.getPrimitive(),u=ta.getPrimitive(),p=Vu,f=p7,g=null,m=null;r&&(g=f7,m=m7);let v=1/0,y=null,x=null;return Vl.copy(t).invert(),bc.matrix.copy(Vl),this.shapecast({boundsTraverseOrder:w=>Po.distanceToBox(w),intersectsBounds:(w,_,b)=>b{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:b=>bc.distanceToBox(b),intersectsBounds:(b,A,S)=>S{for(let S=b*3,E=(b+A)*3;S(wc.copy(e).clamp(h.min,h.max),wc.distanceToSquared(e)),intersectsBounds:(h,c,d)=>d{h.closestPointToPoint(e,wc);let d=e.distanceToSquared(wc);return d{xa(0,new Float32Array(t),Q_),e.union(Q_)}),e}},q0=xo(PO()),g7=.5*(Math.sqrt(3)-1),_c=(3-Math.sqrt(3))/6,v7=1/3,ia=1/6,td=e=>Math.floor(e)|0,Z_=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),Sg=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function y7(e=Math.random){let t=AC(e),i=new Float64Array(t).map(s=>Z_[s%12*2]),r=new Float64Array(t).map(s=>Z_[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*g7,c=td(s+h),d=td(a+h),u=(c+d)*_c,p=c-u,f=d-u,g=s-p,m=a-f,v,y;g>m?(v=1,y=0):(v=0,y=1);let x=g-v+_c,w=m-y+_c,_=g-1+2*_c,b=m-1+2*_c,A=c&255,S=d&255,E=.5-g*g-m*m;if(E>=0){let D=A+t[S],O=i[D],P=r[D];E*=E,n=E*E*(O*g+P*m)}let C=.5-x*x-w*w;if(C>=0){let D=A+v+t[S+y],O=i[D],P=r[D];C*=C,o=C*C*(O*x+P*w)}let T=.5-_*_-b*b;if(T>=0){let D=A+1+t[S+1],O=i[D],P=r[D];T*=T,l=T*T*(O*_+P*b)}return 70*(n+o+l)}}function x7(e=Math.random){let t=AC(e),i=new Float64Array(t).map(a=>Sg[a%12*3]),r=new Float64Array(t).map(a=>Sg[a%12*3+1]),s=new Float64Array(t).map(a=>Sg[a%12*3+2]);return function(a,n,o){let l,h,c,d,u=(a+n+o)*v7,p=td(a+u),f=td(n+u),g=td(o+u),m=(p+f+g)*ia,v=p-m,y=f-m,x=g-m,w=a-v,_=n-y,b=o-x,A,S,E,C,T,D;w>=_?_>=b?(A=1,S=0,E=0,C=1,T=1,D=0):w>=b?(A=1,S=0,E=0,C=1,T=0,D=1):(A=0,S=0,E=1,C=1,T=0,D=1):_e){s=a;break}else e1&&(r=1-r,s=1-s),Is.a.fromBufferAttribute(this.positionAttribute,e*3),Is.b.fromBufferAttribute(this.positionAttribute,e*3+1),Is.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Is.a,r).addScaledVector(Is.b,s).addScaledVector(Is.c,1-(r+s)),Is.getNormal(i),this}},w7=xo(Y2()),_7=new we,S7=new we,A7=new we,cl;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(cl||(cl={}));var D1=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new we,this.copyPreviousMatrix=!0,this.hiddenMatrix=new we,this.matrixWorldRigid=new we,this.shearScale=new we,this.shearScaleInv=new we}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof kt&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)cl.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)cl.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:a}=(0,w7.SVD)(i),n=_7.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=S7.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=A7.copy(o).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new we().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof we?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,a,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},M7=class extends D1(kt){},E7=e=>e.type==="Mesh",gr=class extends M7{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];(i==null?void 0:i.object)!==t&&(i&&this.remove(i),i=new gr(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){var e;return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&((e=this.object.dataPatched.cloner)==null?void 0:e.hideBase)===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return E7(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}},No=new M,ko=new M,xh=new we,MC=[new M(-1,1,1),new M(-1,-1,1),new M(1,-1,1),new M(1,1,1),new M(-1,1,-1),new M(-1,-1,-1),new M(1,-1,-1),new M(1,1,-1)],C7=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],T7=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],K_=(e,t,i)=>{e.updateEntityBoxSize(No,ko),xh.copy(t).multiply(e.matrixWorld),ko.x===0&&ko.y===0&&ko.z===0?i.push(new M(No.x,No.y,No.z).applyMatrix4(xh)):MC.forEach(r=>{i.push(r.clone().multiply(ko).add(No).applyMatrix4(xh))})},J_=class extends Si{constructor(){super(...arguments),this.matrix=new we,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new we().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new M);return}K_(s,t,r)}}):K_(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(xh.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(ko).multiplyScalar(.5),this.getCenter(No),xh.copy(this.matrix).setPosition(No),this.vertices=MC.map(e=>e.clone().multiply(ko).applyMatrix4(xh))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=C7.map(([e,t])=>new _s(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new M))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=T7.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},$n={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},P7=class extends AM{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},X0=.001;function Y0(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=X0}function Ag(e,t){let i=new M(...e.position),r=new M(...e.controlNext.position),s=new M(...t.controlPrevious.position),a=new M(...t.position);return Y0(i,r,a)&&Y0(i,s,a)}function EC(e){let t=e.points.map(c=>new M(...c.data.position)),i=[e.points[0]],r=new M(...i[0].data.position);for(let c=0;cX0&&(g=new Ap(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(v)>X0&&(g=new Ap(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*c+1]=g}for(let c=0;c{c&&h.add(c)}),h}var Tt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(Tt||(Tt={}));var en=e=>Tt.is(e),D7={type:"completeState",isfromEntity:!0},I7=["x","y","z"],Mg=new M,O7=new M().set(0,1,0),I1=e=>class extends D1(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new J_,this._recursiveBBox=new J_,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(Tt.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Tt.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(Tt.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)Wo.toOps(this.data,s.data).forEach(a=>{let n=lf.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Wo.patch(this.data,s),Wo.toOps(this.data,s).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{en(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(Tt.is(i[r]))return i[r];if(Tt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Tt.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)en(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{Tt.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)en(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)en(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)en(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>en(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*Re.RAD2DEG,this.rotation.y*Re.RAD2DEG,this.rotation.z*Re.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return $v(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>(r==null?void 0:r.shared.getVariable(s,[this.uuid,t,I7[a]]))??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(Mg.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(Re.DEG2RAD),this.rotation.setFromVector3(Mg),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Rh.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)Tt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Tt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return $v(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let a=this.data;this.data=i;let n=t,o=Qt(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if((this==null?void 0:this.stateSelection)===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(c=>c===void 0)){let c=this.data;if(c!==void 0){let d=Gi.zoom(c,t.path.slice(2));if(d)for(let u in t.props)t.props[u]===void 0&&u in d&&(h[u]=d[u])}}n={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:c,...d}=l;l=d}if(t.props.material!==void 0&&"material"in l){let{material:c,...d}=l;l=d}let h=Gi.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,Wo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Qt(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let c of Object.keys(t.props)){l[l.length-1]=c;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=t.props[c],d.updateState(so.apply(d.component.data,d.overrideData),r))}}else{let c=r.scene.findInstance([this.uuid,...l]);if(c){let d=Gi.zoom(c.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(d)for(let[p,f]of Object.entries(t.props))f===void 0&&(u===t.props&&(u={...t.props}),u[p]=d[p]);t={...t,props:u}}c.overrideData=xf.resolve(i.overrides,l),c.updateByOp(t,tr.applySimple(c.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let c of Jn.rootOverrideProps)c in t.props&&(h===void 0&&(h={}),h[c]=t.props[c]);h&&(l={...t,props:h})}else for(let h of Jn.rootOverrideProps)if(Qt(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let c=so.filterOp(h.overrideData,l);c&&h.updateByOp(c,tr.applySimple(h.data,c),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let c=so.filterOp(h.overrideData,t);if(c){let d;a===h.data&&t===c?d=i:d=tr.applySimple(h.data,c),h.updateByOp(c,d,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!hl.is(t.props.type)&&$n.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){$n.changeEntityProptotype(this,i,r);for(let s of this.children)Tt.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){var s;if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let a=(s=i.morphTargetInfluences.get(t.path[1]))==null?void 0:s.data.name;a&&this.updateMorphInfluences(a,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",a]))}if(Qt(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Qt(t.path,["cloner"])!==null){let a=tr.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){var f,g,m,v,y;let i=((f=this._updatedPathSnapping)==null?void 0:f.pathId)??this.dataPatched.pathSnapping.pathId,r=((g=this._updatedPathSnapping)==null?void 0:g.slide)??this.dataPatched.pathSnapping.slide??0,s=((m=this._updatedPathSnapping)==null?void 0:m.offset)??this.dataPatched.pathSnapping.offset??0,a=((v=this._updatedPathSnapping)==null?void 0:v.orientation)??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=EC(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let c=null;try{c=l.curves.length?l.getPointAt(h):null}catch{}if(c===null)return;let d=this.parent?(y=this.parent)==null?void 0:y.matrixWorld:new we;n.updateMatrixWorld();let u=new we().multiplyMatrices(d.clone().invert(),n.matrixWorld);c.applyMatrix4(u);let p={position:c.toArray(),rotation:o.rotation};if(a==="tangential"){let x=new we().extractRotation(n.matrixWorld),w=l.getTangentAt(h).applyMatrix4(x).add(c),_=new we().lookAt(c,w,O7),b=Mg.setFromEuler(new ji().setFromRotationMatrix(_)).multiplyScalar(Re.RAD2DEG);p={...p,rotation:b.toArray()}}this.updateTransformState(p),this.traverseEntity(x=>{x._cameraType&&x.dispatchEvent(D7)})}updateVisible(t){var r;if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||((r=this.dataPatched.cloner)==null?void 0:r.hideBase)!==!0),!t)return;let i=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i==null?void 0:i.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof $n.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new $n.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}},CC=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var l,h;let i=(l=e.parameters)==null?void 0:l.radiusTop,r=(h=e.parameters)==null?void 0:h.radiusBottom,s=Object.assign({},(t==null?void 0:t.parameters)??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);s.thetaLength=Re.clamp(s.thetaLength,0,360);let a=s.width/2,n=s.radiusTop??a,o=s.radiusBottom??a;if(n===o?(n=a,o=a):n>o?(n=a,o=o*a/n):(n=n*a/o,o=a),s.shapeBlendNode){n=i??a,o=r??a;let c=Math.max(n,o)*2;s.width=c,s.depth=c}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:n,radiusBottom:o})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:c,cornerRadius:d,cornerSegments:u,hollow:p}=e.parameters,f;return l===0?(f=new Ge,f.setAttribute("position",new Ie([],3))):d||p?f=new TC(h,c,r,s,a,n,o,l*Math.PI/180,d,d,u,p):f=new Qy(h,c,r,s,a,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function On(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function $_(e){return new j(e.y,-e.x)}var TC=class extends Ge{constructor(e,t,i,r,s,a,n,o,l,h,c,d,u=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,a=a!==void 0?a:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,a&&(l=0,h=0);let p=[],f=[],g=[],m=[],v=0,y=i/2,x=new M,w=new M;u&&e==0&&(e=l),u&&t==0&&(t=h);let _=new j(e,y),b=new j(t,-y),A=null,S=null,E=null,C=null,T=_.clone().sub(b),D=0,O=0,P=0;d>0&&(D=Math.min(e,t)*(1-d),O=e-D,P=t-D);let U=_.clone();U.x-=D;let W=Math.PI-T.angle(),k=T.angle(),F=Math.tan(k/2),Z=Math.tan(W/2),X=F+Z,G=d?X:Z,q=d?X:F;if(l=Math.min(l,(e-O)/G,T.length()/X),h=Math.min(h,(t-P)/q,T.length()/X),l>0){let re=l/F;A=_.clone().sub(new j(re,l)),d&&(E=A.clone(),E.x-=D-X*l),_.sub(T.clone().setLength(re))}if(h>0){let re=h/Z;S=b.clone().sub(new j(re,-h)),b.add(T.clone().setLength(re)),d&&(C=S.clone(),C.x-=D-X*h,U.sub(T.clone().setLength(re)))}T=_.clone().sub(b);let $=T.length()<.5,Q=[];for(let re=0;re<=r;re++){let te=[],ae=re/r,de=ae*o+n,pe=new j(Math.sin(de),Math.cos(de));C&&S?(ee(te,ae,pe,W,h,C,-1,!0),ee(te,ae,pe,k,h,S,-1,!1)):S?(H(te,pe,S.x,0,-1),ee(te,ae,pe,k,h,S,-1,!1)):a||H(te,pe,t,P,-1);let be=$_(T).normalize();if(On(be,pe,x),!$)for(let Le=0;Le<=s;Le++){let Me=Le/s,Ve=T.clone().multiplyScalar(Me).add(b);On(Ve,pe,w),f.push(w.x,w.y,w.z),g.push(x.x,x.y,x.z),m.push(ae,.5+w.y/i),te.push(v++)}if(E&&A?(ee(te,ae,pe,W,l,A,1,!1),ee(te,ae,pe,k,l,E,1,!0)):A?(ee(te,ae,pe,W,l,A,1,!1),H(te,pe,A.x,0,1)):a||H(te,pe,e,O,1),d&&!$){let Le=$_(T).multiplyScalar(-1).normalize();On(Le,pe,x);for(let Me=0;Me<=s;Me++){let Ve=Me/s,Ue=T.clone().multiplyScalar(-Ve).add(U);On(Ue,pe,w),f.push(w.x,w.y,w.z),g.push(x.x,x.y,x.z),m.push(ae,.5+w.y/i),te.push(v++)}}d&&!a&&te.push(te[0]),Q.push(te)}for(let re=0;rep.push(Ue,Ce,Ee):(Ue,Ce,Ee)=>p.push(Ue,Ee,Ce),Me=new j((e+t+O+P)/4,0);On(Me,de,be),f.push(be.x,be.y,be.z),g.push(pe.x,0,pe.y),m.push(.5,.5);let Ve=v++;for(let Ue of te){let Ce=f.slice(Ue*3,Ue*3+3);f.push(...Ce),g.push(pe.x,0,pe.y);let Ee=m.slice(Ue*2,Ue*2+2);m.push(...Ee),v++}for(let Ue=Ve+1;Ue0||c>0||l<360?u=new TC(0,t/2,r,s,a,n,o,l*Math.PI/180,h,c,d,0,!0):u=new Zy(t/2,r,s,a,n),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},L7=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:a,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o===0?h=new Xs(t,i,r,s,a,n):h=new z7(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Eg=Math.PI/2,z7=class extends Ge{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let l=[],h=[],c=[],d=[],u=0;p("z","y","x",-1,-1,i,t,e,a,s),p("z","y","x",1,-1,i,t,-e,a,s),p("x","z","y",1,1,e,i,t,r,a),p("x","z","y",1,-1,e,i,-t,r,a),p("x","y","z",1,-1,e,t,i,r,s),p("x","y","z",-1,-1,e,t,-i,r,s),n>0&&(f("z","y","x",-1,-1,1,i,t,e,a),f("z","y","x",1,-1,-1,i,t,e,a),f("z","y","x",-1,1,-1,i,t,e,a),f("z","y","x",1,1,1,i,t,e,a),f("x","y","z",-1,-1,-1,e,t,i,r),f("x","y","z",1,-1,1,e,t,i,r),f("x","y","z",-1,1,1,e,t,i,r),f("x","y","z",1,1,-1,e,t,i,r),f("y","x","z",-1,-1,1,t,e,i,s),f("y","x","z",1,-1,-1,t,e,i,s),f("y","x","z",1,1,1,t,e,i,s),f("y","x","z",-1,1,-1,t,e,i,s),g(1,1,1),g(-1,1,1),g(1,-1,1),g(-1,-1,1),g(1,1,-1),g(-1,1,-1),g(1,-1,-1),g(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new Ie(h,3)),this.setAttribute("normal",new Ie(c,3)),this.setAttribute("uv",new Ie(d,2));function p(m,v,y,x,w,_,b,A,S,E){let C=(_-2*n)/S,T=(b-2*n)/E,D=_/2-n,O=b/2-n,P=A/2,U=S+1,W=E+1,k=0,F=new M;for(let Z=0;Z0?1:-1,c.push(F.x,F.y,F.z),d.push(G/S),d.push(1-Z/E),k+=1}}for(let Z=0;Z0?(S,E,C)=>l.push(S,E,C):(S,E,C)=>l.push(S,C,E);for(let S=0;S<=o;S++){let E=[],C=Eg*(1-S/o),T=Math.cos(C),D=Math.sin(C),O=0;for(let P=0;P<=S;P++){let U=Math.cos(O),W=Math.sin(O);x.x=T*U,x.y=D,x.z=T*W;let k=w.clone().addScaledVector(x,n);h.push(m*k.x,v*k.y,y*k.z),c.push(m*x.x,v*x.y,y*x.z),d.push(0,0),E.push(u++),O+=Eg/S}_.push(E)}let A=_.length-1;for(let S=0;Sy.subVectors(F,Z).normalize(),w=(F,Z)=>Array(F).fill(void 0).map(Z),_=w(e.length/3,(F,Z)=>new M().fromArray(e,Z*3).setLength(r)),b=[],A=1e6;for(let F=0;F<_.length;F++){let Z=_[F],X=[],G,q,$,Q=1e10,ee=-1;for(;(ee=t.indexOf(F,ee+1))!=-1;){let te=ee-ee%3;G=t[te+(ee+1)%3],q=t[te+(ee+2)%3],$=Z.distanceToSquared(_[G]),Q=Math.min(Q,$),X.push([G,q,$])}Q+=1e-6;let H=[],he=0,re=X.length;for(let te=0;tede[0]==q)}b.push(H)}let S=[];{let F=0,Z=0,X,G,q=d==3;for(let $=0;$<=a;$++){X=$*($+1)/2,G=($+1)*($+2)/2;for(let Q=0;Qw(d,()=>u.clone()));for(let F=0;F<_.length;F++){u.copy(_[F]).normalize(),E.copy(u).multiplyScalar(m);let Z=b[F];for(let H=0;HH.add(he),$).multiplyScalar(1/d);for(let H=0;Hte[de]);n.push(...ae.map(de=>[de.x,de.y,de.z]).flat()),l.push(...ae.map(de=>(x(de,E),[y.x,y.y,y.z])).flat())}}let W=[];for(let F=0;FQ%A==F),q=P[F][Z],$=P[X][G];for(let Q=0;Q{n.push(te[0].x,te[0].y,te[0].z),l.push(te[1].x,te[1].y,te[1].z)})}W.push(q[0][0],$[v][0],q[v][0],$[0][0])}}for(;W.length;){let F,Z,X,G;[F,Z]=W.splice(0,2);let q=[F];for(;F!=Z;)q.push(Z),X=W.indexOf(Z),G=X%2,Z=W.splice(X-G,2)[1-G];y.subVectors(q[0],q[1]).cross(u.subVectors(q[0],q[2])).normalize();let $=y.dot(q[0])<0;$&&y.negate();for(let Q=1;Q<=q.length-2;Q++)[q[Q+ +$],q[Q+1-+$],q[0]].forEach(ee=>{n.push(ee.x,ee.y,ee.z),l.push(y.x,y.y,y.z)})}}function c(){let d=new M;for(let b=0;b{E<0&&b.x===1&&(o[A]=b.x-1),S.x===0&&S.z===0&&(o[A]=E/2/Math.PI+.5)};for(let b=0,A=0;b.9&&T<.1&&(A<.2&&(o[b+0]+=1),S<.2&&(o[b+2]+=1),E<.2&&(o[b+4]+=1))}function w(b){return Math.atan2(b.z,-b.x)}function _(b){return Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))}}}static fromJSON(e){return new O1(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},B7=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new PC(t*.5,a,n):new EM(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},PC=class extends O1{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(a,n,o,e,t,i),this.type=o}static fromJSON(e){return new PC(e.radius,e.corner,e.cornerSides)}},Sc=1e-12,R1=class{constructor(e){this.position=new j,this.startPosition=new j,this.uuid=Re.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new R1(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Q0=class extends R1{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Q0(this.parent).copy(this)}},bh=class extends R1{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Q0(this),new Q0(this))}static create(e,t){let i=new bh(e,new j(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;ie,sc=new j,cm=new j,F7=new j,U7=new j,N7=new j,k7=new j,DC=new M,IC=new M;function V7(e){let t=new j;t.addVectors(e.v0,sc.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new j;return i.addVectors(e.v2,cm.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Vs(e.v0,t,i,e.v2)}function Vc(e,t,i=Number.EPSILON){return Math.abs(e-t)Math.PI&&(c*=-1),Vc(h,o)?d=(o+h)*(r/c-.5)*8/3/(n-l):d=(n+l)*(r/c-.5)*8/3/(h-o),s.set(t.x-d*o,t.y+d*n),a.set(i.x+d*h,i.y-d*l),[s,a]}function tS(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function iS(e,t){return Z0(e.position,e.controls[1].position,t.position)&&Z0(e.position,t.controls[0].position,t.position)}function Y7(e,t,i,r,s=.5){let a=sc.subVectors(t,e).multiplyScalar(s).add(e),n=cm.subVectors(i,t).multiplyScalar(s).add(t),o=F7.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=U7.subVectors(n,a).multiplyScalar(s).add(a),c=N7.subVectors(o,n).multiplyScalar(s).add(n),d=o,u=k7.subVectors(c,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,c.x,c.y,d.x,d.y,r.x,r.y]}function Q7(e,t,i=12,r=!0){let s=IC.set(0,0,0),a,n=0;for(let o=0;o1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function Z7(e,t,i,r=12,s=!0){let a=IC.set(0,0,0),n=0,o=[];for(let l=0;l1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function rS(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=sl(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=sl(e[0].roundedCurveCorner,t)*.5),r}function sl(e,t=12){return e&&e instanceof Qf?t*2:e&&(e instanceof Hs||e instanceof SM)?1:e&&e instanceof Yy?t*e.points.length:t}function K7(e,t,i=12,r=!0){let s,a=0;for(let n=0;n1&&!(Vc(e[a-1],e[1],Sc)&&Vc(e[a-2],e[0],Sc))&&(e.push(e[0],e[1]),a++),e}var Cg=new j,J7=new j,$7=new j,eq=new j,tq=new j,iq=new j,mi=class extends qp{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new qr(new M(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Re.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new mi;return r.isClosed=e.isClosed,r.points=e.points.map(s=>bh.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>mi.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;tthis.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,a=this.shapeHoles.length;s0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i=0)return t+a;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=Cg.set(e,t);for(let r=0,s=this.points.length;r=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;es+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=rS(this.points,e,!1),this.roundedCurveDivisions=rS(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return Z7(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),K7(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=sl(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n=this.points.length-1?0:e+1],a=this.curveDivisions,n=a[e];if(tS(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Cg.set(i.x,i.y))/l}let o=0;for(let l=0;l2){let t=0;for(let i=0,r=this.points.length;i0&&!l){let h=s.curveBefore,c=s.curveAfter;if(h===void 0||c===void 0)continue;let d=s.roundedCurveBefore,u=s.roundedCurveAfter,p=h.getLength(),f=c.getLength(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),v=Math.min(g,m),y=1-v/p,x=v/f,w=h.getPointAt(y,Cg),_=c.getPointAt(x,J7);this._subSplitCurve(h,d,y,w,void 0),this._subSplitCurve(c,u,x,void 0,_);let b;if(this.useCubicForRoundedCorners){let A=OC(w,s.position,_)/2,S=Math.tan(A)*w.distanceTo(s.position),[E,C]=W7(w,_,S,$7,eq),T=q7(E,C,s.position),[D,O]=X7(T,w,_,S,tq,iq);b=new Vs(w.clone(),D.clone(),O.clone(),_.clone())}else b=new ho(w.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=b,this.roundedCurves.splice(i+t,0,b),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof Hs)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let a=e,n=t,o=a.getUtoTmapping(i,0),l=Y7(a.v0,a.v1,a.v2,a.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),s!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new mi(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var i;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let r=0;r{let s=new mi;return s.fromJSON(r),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(s,a)=>{a instanceof Vs&&a.v3.equals(s.position)&&s.controls[0].position.copy(a.v2)},r=s=>{let a=[],n,o;for(n=0,o=s.length;n0?s[n-1]:null,u;c instanceof Vs?(u=this.createPoint(c.v0),u.controls[1].position.copy(c.v1)):c instanceof Hs&&(u=this.createPoint(c.v1)),u!==void 0&&(d!==null&&i(u,d),a.push(u))}let l=s[s.length-1],h=!1;return l instanceof Vs?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof Hs&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof qp&&(this.shapeHoles=e.holes.map(s=>{let a=new mi;return a.fromShape(s),a})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){var r;let i=(r=this.getPointByUuid(e))==null?void 0:r.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){var r;let i=(r=this.getPointByUuid(e))==null?void 0:r.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},K0=Math.PI*2;function Tg({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function rq(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function sS(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}function sq(e,t,i,r,s,a,n,o,l,h){let c=Math.pow(s,2),d=Math.pow(a,2),u=Math.pow(n,2),p=Math.pow(o,2),f=c*d-c*p-d*u;f<0&&(f=0),f/=c*p+d*u,f=Math.sqrt(f)*(l===h?-1:1);let g=f*s/a*o,m=f*-a/s*n,v=g+(e+i)/2,y=m+(t+r)/2,x=(n-g)/s,w=(o-m)/a,_=(-n-g)/s,b=(-o-m)/a,A=sS(1,0,x,w),S=sS(x,w,_,b);return!h&&S>0&&(S-=K0),h&&S<0&&(S+=K0),{centerx:v,centery:y,ang1:A,ang2:S}}function aq({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(s===0||a===0)return[];let h=(e-i)/2,c=(t-r)/2;if(h===0&&c===0)return[];s=Math.abs(s),a=Math.abs(a);let d=Math.pow(h,2)/Math.pow(s,2)+Math.pow(c,2)/Math.pow(a,2);d>1&&(s*=Math.sqrt(d),a*=Math.sqrt(d));let u=sq(e,t,i,r,s,a,h,c,n,o),{ang1:p,ang2:f}=u,{centerx:g,centery:m}=u,v=Math.abs(f)/(K0/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x{let{x:w,y:_}=Tg(x[0],s,a,g,m),{x:b,y:A}=Tg(x[1],s,a,g,m),{x:S,y:E}=Tg(x[2],s,a,g,m);return{x1:w,y1:_,x2:b,y2:A,x:S,y:E}})}var Gt;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Gt||(Gt={}));var Pi;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Pi||(Pi={}));function ot(e,t){if(!e)throw t||"Assertion Failed!"}var Ze=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s0?s0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){ot(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s0?(i.s-r.s)*s+(i.s-t.s)*a:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,a){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(n=e.transEval(t,r,i),o=e.transEval(r,i,s),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,s,i),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),Ac=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),ju=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),rh=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),aS=function(){function e(){var t=new rh,i=new Ac,r=new ju(0),s=new ju(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new ju(0),r=new ju(1);t.Sym.sidethis.size||this.leq(r[s].key,r[a].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t>>1,a=i[n].handle,n===0||this.leq(r[a].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,a;for(a=this.nodes.length,this.nodes.length=this.max+1,s=a;s0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;ot(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),Pg=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),lS=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),oq=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new lS,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new lS;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),lq=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,a=i.eUp,n=r.eUp;if(a.Dst===s)return n.Dst===s?Ze.vertLeq(a.Org,n.Org)?Ze.edgeSign(n.Dst,a.Org,n.Org)<=0:Ze.edgeSign(a.Dst,n.Org,a.Org)>=0:Ze.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return Ze.edgeSign(a.Dst,s,a.Org)>=0;var o=Ze.edgeEval(a.Dst,s,a.Org),l=Ze.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&ot(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){ot(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new Pg;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case Gt.ODD:return(i&1)!==0;case Gt.NONZERO:return i!==0;case Gt.POSITIVE:return i>0;case Gt.NEGATIVE:return i<0;case Gt.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,a=e.regionBelow(n),s=a.eUp,s.Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,c,d=!0;h=r;do ot(Ze.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(i).eUp.Rprev),l=i,c=a;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===c.Org;)h.Onext!==c&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(c.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!d&&e.checkForRightSplice(t,l)&&(e.addWinding(h,c),e.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=o,c=h;l.dirty=!0,ot(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Ze.vertL1dist(i,t),a=Ze.vertL1dist(r,t),n=.5*a/(s+a),o=.5*s/(s+a);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(Ze.vertLeq(s.Org,a.Org)){if(Ze.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;Ze.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(Ze.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n;if(ot(!Ze.vertEq(s.Dst,a.Dst)),Ze.vertLeq(s.Dst,a.Dst)){if(Ze.edgeSign(s.Dst,a.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Sym,n),n.Lface.inside=i.inside}else{if(Ze.edgeSign(a.Dst,s.Dst,a.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Lnext,a.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n=s.Org,o=a.Org,l=s.Dst,h=a.Dst,c,d,u=new rh,p,f;if(ot(!Ze.vertEq(h,l)),ot(Ze.edgeSign(l,t.event,n)<=0),ot(Ze.edgeSign(h,t.event,o)>=0),ot(n!==t.event&&o!==t.event),ot(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(c=Math.min(n.t,l.t),d=Math.max(o.t,h.t),c>d))return!1;if(Ze.vertLeq(n,o)){if(Ze.edgeSign(h,n,o)>0)return!1}else if(Ze.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Ze.intersect(l,n,h,o,u),ot(Math.min(n.t,l.t)<=u.t),ot(u.t<=Math.max(o.t,h.t)),ot(Math.min(h.s,l.s)<=u.s),ot(u.s<=Math.max(o.s,n.s)),Ze.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Ze.vertLeq(n,o)?n:o,Ze.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Ze.vertEq(u,n)||Ze.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Ze.vertEq(l,t.event)&&Ze.edgeSign(l,t.event,u)>=0||!Ze.vertEq(h,t.event)&&Ze.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Lnext,a.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=a.Oprev,a=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,a.Onext,s.Rprev,f,!0),!0):(Ze.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Ze.edgeSign(h,t.event,u)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.Oprev,s),s.Org.s=u.s,s.Org.t=u.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,n,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,a;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,a=r.eUp,s.Dst!==a.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(a),r=e.regionBelow(i),a=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==a.Org)if(s.Dst!==a.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||a.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===a.Org&&s.Dst===a.Dst&&(e.addWinding(a,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Ze.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Ze.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,a,a,!0);return}Ze.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,a,n,o,l;if(s=i.eUp,Ze.vertEq(s.Org,r)){ot(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Ze.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}ot(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(ot(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),Ze.edgeGoesLeft(a)||(a=null),e.addRightEdges(t,i,n.Onext,o,a,!0)},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new Pg;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,Ze.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=Ze.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge){if(a===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var c=t.mesh.connect(o.Dnext,i.anEdge);l=c.Sym}a.fixUpperEdge?e.fixUpperEdge(t,a,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);ot(s!==null);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,s){var a=new Pg,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=s,n.Dst.s=i,n.Dst.t=s,t.event=n.Dst,a.eUp=n,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=t.dict.insert(a)},e.initEdgeDict=function(t){t.dict=new oq(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(ot(i.fixUpperEdge),ot(++r===1)),ot(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,Ze.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,a=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)a++;for(a+=8,i=t.pq=new nq(a,Ze.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,a=r.anEdge,ot(a.Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Ze.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),hq=function(){function e(){this.mesh=new aS,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Gt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,a,n,o,l=[0,0,0],h=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[null,null,null],f=[null,null,null],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)a=i.coords[m],h[m]=a,f[m]=i,l[m]=a,p[m]=i;for(i=g.next;i!==g;i=i.next)for(var v=0;v<3;++v)a=i.coords[v],al[v]&&(l[v]=a,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[y],s=p[y],c[0]=r.coords[0]-s.coords[0],c[1]=r.coords[1]-s.coords[1],c[2]=r.coords[2]-s.coords[2],i=g.next;i!==g;i=i.next)d[0]=i.coords[0]-s.coords[0],d[1]=i.coords[1]-s.coords[1],d[2]=i.coords[2]-s.coords[2],u[0]=c[1]*d[2]-c[2]*d[1],u[1]=c[2]*d[0]-c[0]*d[2],u[2]=c[0]*d[1]-c[1]*d[0],n=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],n>o&&(o=n,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,a=0,n=t.next;n!==t;n=n.next)if(s=n.anEdge,!(s.winding<=0))do a+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==n.anEdge);if(a<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,a=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),a=!0),r=this.sUnit,s=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,s[n]=0,s[(n+1)%3]=0,s[(n+2)%3]=i[n]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);a&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.sthis.bmax[0]&&(this.bmax[0]=h.s),h.tthis.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ze.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(Ze.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Ze.edgeGoesLeft(s.Lnext)||Ze.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)a=t.connect(s.Lnext,s),s=a.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Ze.edgeGoesRight(r.Lprev)||Ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)a=t.connect(r,r.Lprev),r=a.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)a=t.connect(s.Lnext,s),s=a.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,a=t.eHead.next;a!==t.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?i:-i:r?t.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var a,n=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){a=c.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=n,++n}this.elementCount=n,i===Pi.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var d=h.n*s;this.vertices[d+0]=h.coords[0],this.vertices[d+1]=h.coords[1],s>2&&(this.vertices[d+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var u=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(c.inside){a=c.anEdge,l=0;do{var h=a.Org;this.elements[u++]=h.n,l++,a=a.Lnext}while(a!==c.anEdge);for(var p=l;p2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==s);this.elements[c++]=a,this.elements[c++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new aS),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,a,n){if(t===void 0&&(t=Gt.ODD),i===void 0&&(i=Pi.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),lq.computeInterior(this,n);var o=this.mesh;return i===Pi.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===Pi.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function eo(e){var t=e.windingRule,i=t===void 0?Gt.ODD:t,r=e.elementType,s=r===void 0?Pi.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,c=h===void 0?[0,0,1]:h,d=e.contours,u=d===void 0?[]:d,p=e.strict,f=p===void 0?!0:p,g=e.debug,m=g===void 0?!1:g;if(!u&&f)throw new Error("Contours can't be empty");if(u){var v=new hq;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;ythis.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} → ${this.size}`),this.realloc(this.size,!0)}},RC=J0;RC.eSize=8*Float32Array.BYTES_PER_ELEMENT;var cq=class{constructor(e=[],t=(i,r)=>ir?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let s=e-1>>1,a=t[s];if(i(r,a)>=0)break;t[e]=a,e=s}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,s=t[e];for(;e=0)break;t[e]=t[a],e=a}t[e]=s}};function dq(e,t,i=1,r=!1){let s=1/0,a=1/0,n=-1/0,o=-1/0;for(let[y,x]of e[0])yn&&(n=y),x>o&&(o=x);let l=n-s,h=o-a,c=Math.max(i,Math.min(l,h));if(c===i){let y=[s,a];return y.distance=0,y.distance}let d=new cq([],(y,x)=>x.max-y.max),u=pq(e),p=new Df(s+l/2,a+h/2,0,e);p.d>u.d&&(u=p);let f=2;function g(y,x,w){let _=new Df(y,x,w,e);if(f++,_.max>u.d+i&&d.push(_),_.d>u.d&&(u=_,r&&console.log(`found best ${Math.round(1e4*_.d)/1e4} after ${f} probes`),u.d>t))return t}let m=c/2;for(let y=s;yt!=c[1]>t&&e<(c[0]-h[0])*(t-h[1])/(c[1]-h[1])+h[0]&&(r=!r),s=Math.min(s,fq(e,t,h,c))}return s===0?0:(r?1:-1)*Math.sqrt(s)}function pq(e){let t=0,i=0,r=0,s=e[0];for(let n=0,o=s.length,l=o-1;n1?(s=r[0],a=r[1]):l>0&&(s+=n*l,a+=o*l)}return n=e-s,o=t-a,n*n+o*o}var z1={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},LC={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},zC={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Dg=(e,t)=>([i,r])=>(r=i?e:e+t)<=r),B1=class extends Ge{constructor(e,t,i=0,r=12,s=3,a=Gt.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(E=>{let C=E.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let O=C[D-1],P=C[D-0];T.push(O,P)}return T}),h=[],c=[];for(let E=0;EE.position)).getSize(new j).length()*.1:h[0].length===0?d=i:i>0?d=dq(h,i):d=1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,d,t/2),this._bevelSegments=Math.floor(s));let u;try{u=eo({windingRule:a,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{u=z1}let p;try{p=eo({windingRule:Gt.ODD,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=LC}if(!u)throw new Error("error generating geometry");let f=u.elementCount;if(p){u.elementCount+=p.elementCount;for(let E=0;Em&&(m=D),Oy&&(y=O)}this._minX=g,this._minY=v,this._width=m-g,this._height=y-v,this._buffer=new RC(this._computeBufferEstimatedSize(u));let x=[],w=[];for(let E=u.elementCount-1;E>=0;E--){let C=E>=f,T=E*2,D=u.elements[T+0],O=u.elements[T+1],P=D+O,U={start:D,count:O,normals:[],continuous:[],concave:[]},W=D,k=P-1,F=D+1,Z=this._shape.roundedCurves.length;do{let Q=W-D,ee=u.vertices[k*2+0],H=u.vertices[k*2+1],he=u.vertices[W*2+0],re=u.vertices[W*2+1],te=u.vertices[F*2+0],ae=u.vertices[F*2+1],de=he-ee,pe=re-H,be=Math.sqrt(de*de+pe*pe);de/=be,pe/=be;let Le=he-te,Me=re-ae,Ve=Math.sqrt(Le*Le+Me*Me);Le/=Ve,Me/=Ve,U.normals[Q*2+0]=-Me,U.normals[Q*2+1]=Le,U.concave[Q]=de*Me-pe*Le>0;let Ue=u.vertexIndices[W];if(Array.isArray(Ue))U.continuous[Q]=!1;else{let[Ce,Ee]=this._shape.getCurveIndexFromVertexId(Ue-1,!0);if(Ee>0&&Ee<1)U.continuous[Q]=!0;else{let Ye=Ee===1?Ce+1:Ce-1;Ye=(Ye+Z)%Z;let qe=Ee===1?0:1,V=this._shape.roundedCurves[Ce].getTangent(Ee),z=this._shape.roundedCurves[Ye].getTangent(qe);U.continuous[Q]=V.dot(z)>.95}}C&&(U.normals[Q*2+0]*=-1,U.normals[Q*2+1]*=-1),[k,W,F]=[W,F,F+1],F>=P&&(F-=O)}while(F!==D+1);let X=[];X.push({bevelI:0,angle:0,size:0,boundary:{vertices:u.vertices.slice(D*2,P*2),vertexCount:O,vertexIndices:new Array(O).fill(!0).map((Q,ee)=>[ee,ee]),elements:[0,O],elementCount:1,mesh:null},reverseMap:[],insetPoints:u.vertices.slice(D*2,P*2)});let G=0;for(let Q=1;Q<=this._bevelSegments;Q++){let ee=Q/this._bevelSegments*Math.PI/2,H=(1-Math.cos(ee))*this._bevel,he=[],re=[],te=0;for(let de=0;deYe&&(qe-=Math.PI*2);let V=qe-Ye;if(U.continuous[de]||C){let z=Ye+V/2,oe=Math.cos(z)*H,Se=Math.sin(z)*H;he[2*te+0]=Le+oe*(C?-1:1),he[2*te+1]=Me+Se*(C?-1:1),re[te]=de,te++}else{let z=Math.max(1,Math.floor(r/4*Math.abs(V)/Math.PI));for(let oe=0;oe<=z;oe++){let Se=Ye+V*(oe/z),R=Math.cos(Se)*H,Te=Math.sin(Se)*H;he[2*te+0]=Le+R,he[2*te+1]=Me+Te,re[te]=de,te++}}}else he[2*te+0]=Le+Ve,he[2*te+1]=Me+Ue,re[te]=de,te++,he[2*te+0]=Le,he[2*te+1]=Me,re[te]=de,te++,he[2*te+0]=Le+Ce,he[2*te+1]=Me+Ee,re[te]=de,te++}let ae=eo({windingRule:Gt.POSITIVE,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[he],edgeCreateCallback:de=>{let pe=de.Org.idx,be=re[pe],Le=re[(pe+1)%re.length];de.idx=[be,Le],de.Sym.idx=[Le,be]},vertexIdCallback:de=>{let pe=de.Lprev.idx;return[pe?pe[1]:0,de.idx?de.idx[0]:0]}});if(!ae)throw console.log("Error"),new Error(`error generating bevel geometry for ${Q}'th loop`);if(!ae.vertexCount){let de=(Q-1)/this._bevelSegments*Math.PI/2;G=(1-Math.sin(de))*this._bevel;break}for(let de=0;de{let he=0,re=Q.boundary.vertexIndices.length;for(;heoe){let R=z/oe,Te=0;for(let ke=1;ke(Te+1)*R&&(Te++,qe=this._buildBevelVert(U,H,(be+Te)%re,Te/(oe-1),Me),x.push(Ee.topN,Ye.topP,qe.topP),n===!1&&x.push(Ye.bottomP,Ee.bottomN,qe.bottomP),Ee=qe)}else{let R=oe/z,Te=0;for(let ke=1;ke(Te+1)*R&&(Te++,Ye=this._buildBevelVert(U,ee,(pe+Te)%he,Te/(z-1),Me),x.push(Ce.topN,Ye.topP,Ee.topN),n===!1&&x.push(Ye.bottomP,Ce.bottomN,Ee.bottomN),Ce=Ye)}pe=(pe+z)%he,be=(be+oe)%re,ae=(ae+1)%te}while(ae!==Le)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(X,U,x),C){let Q=[];for(let ee=x.length-1;ee>=$+2;ee-=3){let H=x[ee-2],he=x[ee-1],re=x[ee-0];Q.push(re,he,H)}x.splice($,x.length-$,...Q)}if(C){let Q=[];for(let ee=X[X.length-1].boundary.vertices.length-1;ee>=1;ee-=2){let H=X[X.length-1].boundary.vertices[ee-1],he=X[X.length-1].boundary.vertices[ee-0];Q.push(H,he)}w.push(Q)}if(!C){let Q=X[X.length-1],ee;try{ee=eo({windingRule:X.length>1?Gt.POSITIVE:Gt.ODD,elementType:Pi.POLYGONS,vertexSize:2,strict:!0,contours:[Q.insetPoints,...w]})}catch{ee=zC}if(!ee)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel0,c=e.continuous[l]||d);let u=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,g=l*2,m=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,w=(v-this._minX)/this._width,_=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(w=s),_=1);let b=e.normals[g+0],A=e.normals[g+1],S=e.normals[m+0],E=e.normals[m+1];if(d){let P=S-b,U=E-A;b=b+P*(1-r),A=A+U*(1-r);let W=Math.sqrt(b*b+A*A);b/=W,A/=W}let C=this.forPathBevel?this._buffer.get(c?1:2):this._buffer.get(c?2:4),T=C*3,D=C*2,O={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=b*u,this._buffer.normals[T+1]=A*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=w,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=b*u,this._buffer.normals[T+4]=A*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=w),c||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),O.topP=C+0,O.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=S*u,this._buffer.normals[T+1]=E*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=w,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=S*u,this._buffer.normals[T+4]=E*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=w)),this.vertexCache[a]=O,O}clone(){let e=new B1(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=rm(this.userData),e}},BC=class extends Ge{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Gt.ODD,this.elementType=Pi.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Gt.ODD,elementType:Pi.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(u=>u.extractShapePointsToFlatArray([],this._curveSegments)),a,n=!0,o=!0,l,h;for(let u=0,p=r.length/2;up&&(p=_),bg&&(g=b)}let m=p-u,v=g-f;for(let y=0,x=c;y0&&n.update());let l=n??new mi(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:a,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:a,windingRule:n}=e.parameters;e.shape.roundness=a;let o;return t<=0?o=new BC(e.shape,s,{windingRule:n}):o=new FC(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},UC=Math.PI*2,F1=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=Re.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof mi?e.shape:new mi,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,c=t*.5,d=i*.5,u=mq(h,c,d,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new Ge,p.setAttribute("position",new Ie([],3))):p=yl.create({shape:h,parameters:{subdivisions:u,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function mq(e,t,i,r,s,a){if(r>=UC)return s>30||s%4===0?(vq(e,t,i,a),Math.round(s/4)):hS(e,r,s,t,i,a);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=aq({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?gq(e,n.x,n.y,h,s,t,i,a):hS(e,r,s,t,i,a)}function gq(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(wh(t,i));for(let h=0,c=r.length;h0?NC(e,a,n,o):e.addPoint(wh(0,0)),l}function hS(e,t,i,r,s,a){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,c=Math.cos(l)*s;e.addPoint(wh(h,c))}return t0?NC(e,r,s,a):e.addPoint(wh(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&kC(e,r,s,a)),1}function vq(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(Gu(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(Gu(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(Gu(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(Gu(s,a-i,s+o,a-i,s-o,a-i)),r>0&&kC(e,t,i,r)}function wh(e,t){return new bh(Re.generateUUID(),new j(e,t))}function Gu(e,t,i,r,s,a){let n=wh(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function NC(e,t,i,r){VC(e,t,i,r).forEach(s=>e.addPoint(s))}function kC(e,t,i,r){let s=VC(e,t,i,r),a=new mi;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function VC(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new j(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=Re.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),c=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(c),l.controls[1].position.copy(h)}),o}var yq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),a=Math.abs(i.depth??r),n=Math.abs(Math.min(r,a))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:a,radius:n,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:a,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:c,cornerSegments:d}=e.parameters,u=new jC(!1,t,i,r,s,a,n,o,l,h,c,d);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},Ig=new mh([0,0,0],1),jC=class extends Ge{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,c=1,d=1){if(super(),a===0)return;let u=e&&a===1;u&&(d=0),c>100&&(c=100),c===0&&(d=0);let p=()=>new M,f=new M,g=p(),m=p(),v=p(),y,x,w,_,b,A,S,E,C=p(),T=p(),D=p(),O=p(),P=p(),U=p(),W=p(),k=p(),F=i-2*o+.001,Z=F/a,X=Math.ceil(n*a),G=X+1,q=F/X,$=-F/2,Q=h+1,ee=2*Math.PI/h,H=Math.PI/2/d,he=.01,re=Math.min((1-c/100)*o,o-he),te=o-re,ae=0,de=2,pe=d*de+de,be=Q*pe/de,Le=be+Q*G,Me=Math.max(0,Q*(G+pe)),[Ve,Ue,Ce]=[3,3,2].map(ue=>Array(Me*ue).fill(0)),Ee=[],Ye=s-o;function qe(ue,je){let ze=Math.PI/2;A=je*q,E=2*Math.PI*(A%Z)/Z+ze,A+=$,S=Math.sin(E)*Ye,b=Math.cos(E)*Ye,e?ue.set(b,S,A):ue.set(b,A,S)}qe(f,-1e-10),qe(g,0),C.copy(f),qe(f,1);let V=f.distanceTo(g),z=u?0:te+re,oe=V*X+2*z,Se=re,R=oe-z;for(let ue=0;ue<=X;ue++){qe(m,ue),k.subVectors(m,C).normalize(),C.copy(m),U.copy(m).setComponent(+e+1,0).normalize(),W.crossVectors(k,U).normalize();let je=ue===0,ze=ue===X,Xe=je?3*Math.PI/2:H,it=je?Se:R,Qe=je?Q:Le,Ke=je?0:Me-Q,qt=k.clone().multiplyScalar(je?-te:te).add(m),oi=k.clone().multiplyScalar(je?-1:1).normalize();for(let K=0;K{Ve[ae*3+_e]=qt.getComponent(_e),Ue[ae*3+_e]=oi.getComponent(_e)}),Ce[ae*2]=+ze,Ce[ae*2+1]=K/h),g.copy(D).multiplyScalar(re),v.addVectors(m,g);for(let _e=0;_e{Ve[ae*3+Et]=g.getComponent(Et),Ue[ae*3+Et]=P.getComponent(Et)});let nt=+je+Math.sin(Be);Ce[ae*2]=(it+te*nt)/oe,Ce[ae*2+1]=K/h}}g.addVectors(m,T),ae=be+ue*Q+K,[0,1,2].forEach(_e=>{Ve[ae*3+_e]=g.getComponent(_e),Ue[ae*3+_e]=D.getComponent(_e)}),Ce[ae*2]=(z+ue*V)/oe,Ce[ae*2+1]=K/h}}let Te=G+2*d+de,[ke,Oe]=[+u,Te-1];for(let ue=ke;ue<=Oe-1;ue++){let je=u&&ue===Oe-1;for(let ze=0;ze{Array.isArray(s)&&(s.x=s[0],s.y=s[1])});let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new qp;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let a=new MM(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},ra=new we,Og=new kt,Hu=new M,If=class extends yr{constructor(){super(),this.uuid=Re.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Di().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i0)for(let d=0;d0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t=0;o--){let l=a[o];this.faces.splice(l,1);for(let h=0,c=this.faceVertexUvs.length;h0,x=f.vertexNormals.length>0,w=f.color.r!==1||f.color.g!==1||f.color.b!==1,_=f.vertexColors.length>0,b=0;if(b=h(b,0,0),b=h(b,1,g),b=h(b,2,m),b=h(b,3,v),b=h(b,4,y),b=h(b,5,x),b=h(b,6,w),b=h(b,7,_),i.push(b),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let A=this.faceVertexUvs[0][p];i.push(u(A[0]),u(A[1]),u(A[2]))}if(y&&i.push(c(f.normal)),x){let A=f.vertexNormals;i.push(c(A[0]),c(A[1]),c(A[2]))}if(w&&i.push(d(f.color)),_){let A=f.vertexColors;i.push(d(A[0]),d(A[1]),d(A[2]))}}function h(p,f,g){return g?p|1<0&&(e.data.colors=a),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new If().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let d=0,u=t.length;d0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Wu.call(new tt(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",cS.call(new tt(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",dS.call(new tt(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",dS.call(new tt(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],a=e.morphTargets[r];for(let n=0,o=a.length;n0){let r=new Ie(e.skinIndices.length*4,4);t.setAttribute("skinIndex",uS.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Ie(e.skinWeights.length*4,4);t.setAttribute("skinWeight",uS.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new Ge,i=e.geometry;if(e.isPoints||e.isLine){let r=new Ie(i.vertices.length*3,3),s=new Ie(i.colors.length*3,3);if(t.setAttribute("position",Wu.call(r,i.vertices)),t.setAttribute("color",cS.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new Ie(i.lineDistances.length,1);t.setAttribute("lineDistance",_q.call(a,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};If.prototype.isGeometry=!0;var wq=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,a=e.faces;for(r=0;r0,a=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let m=0;m0){d=[];for(let m=0;m0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new M,i,r,s,a,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],c=h!==void 0&&h.length>0,d=[],u=new Map;Mq(o,l,d,u);let p=[],f,g,m,v,y,x,w;for(let he of Array.from(u.keys())){for(g=u.get(he),m=new M,y=3/8,x=1/8,w=g.faces.length,w!=2&&(y=.5,x=0,w!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),a=0;a3&&(_=3/(8*i)),b=1-i*Number(_),A=_,i<=2&&(i==2?(b=3/4,A=1/8):i==1||i==0),T=C.clone().multiplyScalar(b),t.set(0,0,0),a=0;a0?(o===void 0||(n==null?void 0:n.subdivisions)!==s)&&(o===void 0&&(o=a),a=new Eq(s).modify(o).toBufferGeometry()):(o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals())}catch{o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals()}return o!==void 0&&Object.assign(a,{originalGeometry:o}),delete e.geometry,Object.assign(a,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new kM(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Fi);let a=100/Fi.x;Object.assign(s.parameters,{width:100,height:Fi.y*a,depth:Fi.z*a}),t(this.build(s))})}},HC=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof mi?e.shape:new mi,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5,d=0,u=0,p=2*Math.PI/r;for(let g=0;g0){{let Me=F.clone().add(Z).multiplyScalar(.5),Ve=x.clone().sub(Me).normalize(),Ue=y.clone().sub(Me).normalize().add(Ve).normalize().multiplyScalar(-1),Ce=q.clone().sub(G);U(Me,Ce,Ue,b.angle())}let be,Le;{let Me=new M;Mc(E,te,Me);let Ve=q.clone().add(X).multiplyScalar(.5);Ve=Pq(Ve,Z,x);let Ue=q.clone().sub(X);[be,Le]=U(Ve,Ue,Me,T,X.y)}{let Me=be,Ve=Me.clone().setY(0).normalize(),Ue=new M(0,-1,0),Ce=Ve.clone().cross(Ue);W(Me,Ve,Ue,Ce)}{let Me=b.angle(),Ve=Math.PI-Me,Ue=x.clone();Ue.y-=a/Math.sin(Me-Math.PI/2);let Ce=new M,Ee=[];for(let qe=0;qei&&b>r?Math.min(w*i/_,w*r/b):_>i?w*i/_:b>r?w*r/b:w}let p=[];p[0]=s[0]===0?0:u(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:u(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:u(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:u(s[3],s[3]+s[0],s[3]+s[2]);let f=c.x,g=d.x,m=d.y,v=c.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let w=0,_=t.points.length;w<_;w++)t.points[w].roundness=p[w],w>0&&p[w]!==p[w-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let x=yl.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},Iq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=Re.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:a=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,c;return h===0?(c=new Ge,c.setAttribute("position",new Ie([],3))):c=new gh(.5*t,s,a,n,o,l,h*Re.DEG2RAD),c.scale(1,i/t,r/t),Object.assign(c,{userData:{...e,type:"SphereGeometry"}})}},Oq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,a=new Ea(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},Rq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:a,cornerSegments:n}=e.parameters,o=new Lq(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},Lq=class extends Ge{constructor(e=1,t=1,i=1,r=90,s=10,a=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;s==0&&(a=1),a=Math.max(1,Math.floor(a)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let c=[],d=Math.PI/2,u=(he=0,re=0,te=0)=>new M(he,re,te),p=u(),f=u(),[g,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[w,_,b]=[u(y,-g,+v),u(y,-g,-v),u(y,+g,-v)],A=(he,re=!1)=>Math.sin(he-Math.PI/(1+ +re)),S=(he,re=!1)=>Math.cos(he-Math.PI/(1+ +re));b.y=Math.sin(r)*t-g;let E=Math.cos(r)*t-v,C=w.z-h;r<=d?(b.z=Math.min(E,C),b.z==C&&(b.y-=(E-C)/Math.tan(d-r))):_.z=Math.min(_.z-E-v,w.z-h),p.subVectors(w,_),f.subVectors(b,_);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),O=T/Math.cos(r/2),P=p.clone().normalize().add(f.normalize()).setLength(O).add(_);p.set(0,A(r,!0),S(r,!0)),c.push([b,p.clone()]);let U=(Math.PI-r)/a;for(let he=0;he<=a;he++){let re=d+r+he*U;p.set(0,Math.sin(re)*D,Math.cos(re)*D),p.add(P),f.set(0,A(re),S(re)),c.push([p.clone(),f.clone()])}c.push([w,u(0,1,0)]);let W=Math.sin(U/2)*D*2,k=c.length-1,F=c[0][0].distanceTo(c[1][0]),Z=c[k-1][0].distanceTo(c[k][0]),X=F+W*a+Z;c[0].push(1);for(let he=0;he<=a;he++)c[he+1].push(1-(F+he*W)/X);c[k].push(0);let[G,q,$]=c[0],Q,ee,H;for(let he=1;he>16&255,g:e>>8&255,b:e&255}}function Wq(e,t,i){return(e<<16)+(t<<8)+i}function qq(e,t,i){return e=Math.round(e),t=Math.round(t),i=Math.round(i),"#"+[e,t,i].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function Xq(e){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,(r,s,a,n)=>String(s+s+a+a+n+n));let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return i?{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16)}:null}var Yq={parseRgba:Vq,hsvToRgb:jq,rgbToHsv:Gq,hexToRgb:Hq,rgbToHex:Wq,rgbToHexString:qq,hexStringToRgb:Xq},Qq=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},Zq=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},fe=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+fe.version}static addUnaryOp(e){return fe.max_unop_len=Math.max(e.length,fe.max_unop_len),fe.unary_ops[e]=1,fe}static addBinaryOp(e,t,i){return fe.max_binop_len=Math.max(e.length,fe.max_binop_len),fe.binary_ops[e]=t,i?fe.right_associative.add(e):fe.right_associative.delete(e),fe}static addIdentifierChar(e){return fe.additional_identifier_chars.add(e),fe}static addLiteral(e,t){return fe.literals[e]=t,fe}static removeUnaryOp(e){return delete fe.unary_ops[e],e.length===fe.max_unop_len&&(fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops)),fe}static removeAllUnaryOps(){return fe.unary_ops={},fe.max_unop_len=0,fe}static removeIdentifierChar(e){return fe.additional_identifier_chars.delete(e),fe}static removeBinaryOp(e){return delete fe.binary_ops[e],e.length===fe.max_binop_len&&(fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops)),fe.right_associative.delete(e),fe}static removeAllBinaryOps(){return fe.binary_ops={},fe.max_binop_len=0,fe}static removeLiteral(e){return delete fe.literals[e],fe}static removeAllLiterals(){return fe.literals={},fe}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new fe(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return fe.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!fe.binary_ops[String.fromCharCode(e)]||fe.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return fe.isIdentifierStart(e)||fe.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(fe.hooks[e]){let i={context:this,node:t};return fe.hooks.run(e,i),i.node}return t}searchHook(e){if(fe.hooks[e]){let t={context:this};return fe.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===fe.SPACE_CODE||e===fe.TAB_CODE||e===fe.LF_CODE||e===fe.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:fe.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index0;){if(fe.binary_ops.hasOwnProperty(e)&&(!fe.isIdentifierStart(this.code)||this.index+e.lengths.right_a&&c.right_a?i>c.prec:i<=c.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:fe.BINARY_EXP,operator:t,left:a,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(s,e)}for(o=r.length-1,e=r[o];o>1;)e={type:fe.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,fe.isDecimalDigit(e)||e===fe.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===fe.SQUOTE_CODE||e===fe.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===fe.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,fe.max_unop_len),i=t.length;i>0;){if(fe.unary_ops.hasOwnProperty(t)&&(!fe.isIdentifierStart(this.code)||this.index+t.length=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(s===fe.COMMA_CODE){if(this.index++,r++,r!==t.length){if(e===fe.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===fe.CBRACK_CODE)for(let a=t.length;a":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops);fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops);var kh=e=>new fe(e).parse(),Jq=Object.getOwnPropertyNames(fe);Jq.forEach(e=>{kh[e]===void 0&&e!=="prototype"&&(kh[e]=fe[e])});kh.Jsep=fe;var $q="ConditionalExpression",eX={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let i=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),t.node={type:$q,test:i,consequent:r,alternate:s},i.operator&&e.binary_ops[i.operator]<=.9){let a=i;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=i}}else this.throwError("Expected :")}})}};kh.plugins.register(eX);function dm(e){return{all:e=e||new Map,on:function(t,i){var r=e.get(t);r?r.push(i):e.set(t,[i])},off:function(t,i){var r=e.get(t);r&&(i?r.splice(r.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var r=e.get(t);r&&r.slice().map(function(s){s(i)}),(r=e.get("*"))&&r.slice().map(function(s){s(t,i)})}}}var qC=class{constructor(e,t,i){var r;this.id=e,this.userAPI=t,this.result=void 0,this.error="null",this.isPrefetched=!1,this.isLoading=!1,this.isLoaded=!1,this.prefetchPromise=new Promise(s=>s()),this.emitter=dm(),this._innerCallUserAPI=async s=>{var a,n,o;this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await aX(this.userAPI,s),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(l){let h=((o=(n=(a=l.message)==null?void 0:a.split("_:_"))==null?void 0:n[0])==null?void 0:o.replace("status:",""))??"null";this.error=h,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0},((r=t==null?void 0:t.integration)==null?void 0:r.type)==="OpenAI"?this.result={content:""}:t.method==="GET"&&t.url!==""&&(this.prefetchPromise=this.prefetch(i)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=xd(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?xd(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(e){await this.callUserAPI(e)}async callUserAPI(e){await this._debouncedCallUserAPI(e)}update(e,t,i=!0){this.userAPI=e,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&i&&this._debouncedPrefetch(t)}retrieveValue(e){if(this.result)try{return Gi.zoom(this.result,e)}catch(t){console.error(t)}}retrieveZoomedKeyValues(e){if(this.result){let t=e&&e.length?Gi.zoom(this.result,e):this.result;if(sX(t))return Object.entries(t);if(rX(t))return t.map((i,r)=>[r.toString(),i]);throw iX(t)?new Error("This path points to a value, use retrieveValue() instead. "+(e==null?void 0:e.join("."))):new Error("Path error"+(e==null?void 0:e.join(".")))}}dispose(){}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}get autostart(){return this.userAPI.autoStart}};function tX(e){let t=new Headers;return e.headers.forEach(i=>{i.data.key!==""&&t.append(i.data.key,i.data.value)}),t}function iX(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function rX(e){return Array.isArray(e)}function sX(e){return typeof e=="object"&&e!==null}async function aX(e,t,i=new AbortController){var l,h,c,d;let r,s=e.url,a=((l=e.proxy)==null?void 0:l.enabled)??!1,n;if(((h=e.integration)==null?void 0:h.type)==="OpenAI"){let u=jc(e.integration.prompt===""?[]:JSON.parse(e.integration.prompt),t),p=e.integration.behavior===""?[]:jc(JSON.parse(e.integration.behavior),t);n=`{ "model": "${e.integration.model}", "messages": [${e.integration.useBehavior?` { "role": "system", "content": "${p}" },`:""} { "role": "user", "content": "${u}" } ] }`}if(a){s=`https://apis.spline.design/file/${e.proxy.fileId}/external-api/request?uuidexternalapi=${e.proxy.proxyId}`;let u;n!==void 0?u=n:e.method==="POST"&&e.body&&(u=jc(JSON.parse(e.body),t)),u!==void 0&&(s+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else((c=e.integration)==null?void 0:c.type)==="OpenAI"?r=n:e.method==="POST"&&e.body&&(r=jc(JSON.parse(e.body),t));let o=await fetch(s,{method:a?"GET":e.method,headers:a?void 0:tX(e),signal:i.signal,body:r});if(!o.ok)throw new Error("status:"+o.status+"_:_"+o.statusText);if(((d=e.integration)==null?void 0:d.type)==="OpenAI"){let u=await o.json();return a&&(u=u.response),{content:u.choices[0].message.content}}else{let u=await o.json();return a&&(u=u.response),u}}var XC=(e,t)=>{if(typeof e=="string"){let i=t.getVariable(e);if(i)return XC(i,t)}return mr.isBoolean(e)?mr.getDisplayedValue(e).toLowerCase():mr.getDisplayedValue(e)},jc=(e,t)=>e.map((i,r)=>{if("text"in i)return i.text;if("type"in i){if(i.type==="paragraph")return(r>0?` `:"")+jc(i.children,t);if(i.type==="variable"){let s=t.getVariable(i.variableId);if(s!==void 0)return XC(s,t)}}return""}).join(""),nX=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],oX=["0","1","2","3","4","5","6","7","8","9","."],lX=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function hX(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))}kh.addBinaryOp("^",11,!0);function YC(e,t,i="number"){let r="";for(let n=0;n{var p;let u=(p=d.events)==null?void 0:p.find(f=>f.id===o.objId);u&&(h=u)}),h!==void 0&&h.data.type==="AIAssistantListener"){let c=l==null?void 0:l.computeAnalysisForListenerEvent(h.data);if(c!==void 0){r+=c;continue}}}r+=(l==null?void 0:l.voice)??0;continue}if("id"in o){let l=e[n-1];if(n>0&&"id"in l){console.error("Two variables in a row",e);return}let h=t.getVariable(o.id),c=mr.getDisplayedValue(h);i==="number"&&mr.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?c=parseFloat(c).toString():i==="boolean"&&mr.isBoolean(h)?c=h?"true":"false":i==="boolean"&&mr.isTextValue(h)&&!Array.isArray(h.textValue)&&(c='"'+c+'"'),r+=c;continue}else if(i==="string"){o.name!=='"'&&(o.name!=="+"||o.escaped)&&(r+=o.name),o.name==="+"&&!o.escaped&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+o.name);continue}if(o.name==="and"){r+="&&";continue}if(o.name==="or"){r+="||";continue}if(o.name==="True"){r+="true";continue}if(o.name==="False"){r+="false";continue}if(i==="boolean"&&!hX(o.name)&&!oX.includes(o.name)&&!nX.includes(o.name)&&!lX.includes(o.name.replace(/\($/g,""))){r+='"'+o.name+'"';continue}r+=o.name}if(i==="string")return r;if(e.length===0){if(i==="number")return 0;if(i==="boolean")return!1}let s;try{s=kh(r)}catch(n){console.error(r,n);return}let a;try{a=Rt(s)}catch(n){console.error(r,s,n)}return a}function Rt(e){switch(e.type){case"BinaryExpression":switch(e.operator){case"==":return+(Rt(e.left)===Rt(e.right));case"!=":return+(Rt(e.left)!==Rt(e.right));case">":return+(Rt(e.left)>Rt(e.right));case">=":return+(Rt(e.left)>=Rt(e.right));case"<":return+(Rt(e.left)=1)try{t=Rt(e.arguments[0])}catch(r){console.warn(r)}if(e.arguments.length>=2)try{i=Rt(e.arguments[1])}catch(r){console.warn(r)}return t=Math.min(i,t),i=Math.max(i,t),t+Math.random()*(i-t)}return Math[e.callee.name].apply(null,e.arguments.map(Rt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+e.type)}}var cX=new we,dX=new we;function uX(e,t,i){let r=[new M,new M,new M],s=[new M,new M,new M];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((a,n)=>{let o=s[n],l=Re.lerp(a.length(),o.length(),i);a.lerp(o,i).setLength(l)}),new we().makeBasis(r[0],r[1],r[2])}var pX=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=(t==null?void 0:t.shapeData)??F1.create({parameters:gC}).userData.shape;return{path:e.path??gf.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:a,extrusion:{...vC,...i.extrusion}}),shapeData:n}}static build(e){if(e.path.points.length>=2){let t=new fX(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new Ge,{userData:{...e,type:"PathGeometry"}})}},fX=class extends Ge{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!kq(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),r=Math.max(0,Math.min(r,1));let s=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(r*s),n=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,n-a+1),s+2),l=[],h=[];for(let k=0;k{l[k]=l[k].clone().lerp(l[F],Z),h[k]=uX(h[k],h[F],Z)},d=0,u=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(u||r===0)&&(d=u,c(0,1,d));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,c(l.length-1,l.length-2,1-p)),i===0){let k=l.length-1;l[k].copy(l[0]),h[k].copy(h[0])}this._applyPathModifiers(h,d,p);let{bevel:g,bevelSides:m}=this.inputs.parameters.extrusion,v=g>0?this.inputs.parameters.extrusion.capType:"flat",y=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(y=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:w,vertices:_}=this._computeShapePoints(y),b=0,A;v==="round"&&(A=new B1(this.inputs.shapeData,2*g,g,y,m,void 0,!0),b=A.getAttribute("position").count);let S=0,E=0;w.sort((k,F)=>k.start-F.start),w.forEach(k=>{k.verticesStart=S,k.verticesCount=k.continuous.reduce((F,Z,X)=>F+(X===0||!Z?2:1),0),E+=k.verticesCount,S=E});let C=E*o,T,D=0;if(this._isOpenEnded()&&v==="flat"){try{T=eo({windingRule:Gt.ODD,elementType:Pi.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:x})}catch{T=zC}D=T.vertexCount}let O=C+2*D+b*2,P=C+2*D,U={positions:new Float32Array(O*3),normals:new Float32Array(O*3),uvs:new Float32Array(O*2)},W=[];if(w.forEach(k=>{this._extrudeRegion(k,_,h,l,U,W,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,C,W,U,h[0],l[0],!1),this._closeEnd(T,C+D,W,U,h[h.length-1],l[l.length-1],!0)),A){U.positions.set(A.getAttribute("position").array,P*3),U.normals.set(A.getAttribute("normal").array,P*3),U.uvs.set(A.getAttribute("uv").array,P*2);for(let X=P;XX+P)),P+=b,U.positions.set(A.getAttribute("position").array,P*3),U.normals.set(A.getAttribute("normal").array,P*3),U.uvs.set(A.getAttribute("uv").array,P*2);let F=W.length;W.push(...A.getIndex().array.map(X=>X+P)),this.setAttribute("position",new tt(U.positions,3)),this.setAttribute("normal",new tt(U.normals,3)),this.setAttribute("uv",new tt(U.uvs,2)),this.setIndex(W);let Z=cX;Z.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(Z,P,O),Z.copy(h[0]).setPosition(l[0]).multiply(dX.makeScale(1,1,-1)),this.applyMatrix4OnRange(Z,P-b,P),this.reverseIndicesOnRange(k,F)}else this.setAttribute("position",new tt(U.positions,3)),this.setAttribute("normal",new tt(U.normals,3)),this.setAttribute("uv",new tt(U.uvs,2)),this.setIndex(W)}_extractPathPoints(){let e=EC(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new M,a=new M,n=new M,o=new M,l=new M(0,1,0);for(let f=0;f0&&(u*=-1);for(let f=1;f{let u=d===0?0:d===r-1?1:(d-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(Re.lerp(s,s+a,u)*Re.DEG2RAD);let p=Re.lerp(n,o,u);h.makeScale(p,p,p),c.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=Gt.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(h=>{let c=h.extractShapePointsToFlatArray([],e),d=[];for(let u=c.length-1;u>=1;u-=2){let p=c[u-1],f=c[u-0];d.push(p,f)}return d}),a;try{a=eo({windingRule:t,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{a=z1}let n;try{n=eo({windingRule:Gt.ODD,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{n=LC}if(!a)throw new Error("error generating geometry");let o=a.elementCount;if(n){a.elementCount+=n.elementCount;for(let h=0;h=0;h--){let c=h>=o,d=h*2,u=a.elements[d+0],p=a.elements[d+1],f=u+p,g={start:u,count:p,normals:[],isHole:c,continuous:[],verticesStart:0,verticesCount:0};l.push(g);let m=u,v=f-1,y=u+1,x=i.roundedCurves.length;do{let w=m-u;a.vertices[v*2+0],a.vertices[v*2+1];let _=a.vertices[m*2+0],b=a.vertices[m*2+1],A=a.vertices[y*2+0],S=a.vertices[y*2+1],E=_-A,C=b-S,T=Math.sqrt(E*E+C*C);E/=T,C/=T,g.normals[w*2+0]=-C,g.normals[w*2+1]=E;let D=a.vertexIndices[m];if(Array.isArray(D))g.continuous[w]=!1;else{let[O,P]=i.getCurveIndexFromVertexId(D-1,!0);if(P>0&&P<1)g.continuous[w]=!0;else{let U=P===1?O+1:O-1;U=(U+x)%x;let W=P===1?0:1,k=i.roundedCurves[O].getTangent(P),F=i.roundedCurves[U].getTangent(W);g.continuous[w]=k.dot(F)>.95}}c&&(g.normals[w*2+0]*=-1,g.normals[w*2+1]*=-1),[v,m,y]=[m,y,y+1],y>=f&&(y-=p)}while(y!==u+1)}return{regions:[r,...s],infos:l,vertices:a.vertices}}_insertVertex(e,t,i,r,s){let a=t*2,n=t*3;e.positions[n+0]=i.x,e.positions[n+1]=i.y,e.positions[n+2]=i.z,e.normals[n+0]=r.x,e.normals[n+1]=r.y,e.normals[n+2]=r.z,e.uvs[a+0]=s.x,e.uvs[a+1]=s.y}_extrudeRegion(e,t,i,r,s,a,n){let o=new M,l=new M,h=new M,c=new M,d=new j;i.forEach((p,f)=>{let g=r[f],m=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v{this.update(e,t),t==null||t.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!(i!=null&&i.isLoaded)){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o,text:l,textTransform:h}=e,c=mr.getDisplayedValue(l),d=h===2?c.toUpperCase():h===3?c.toLowerCase():c,u=yX(e,i,d,t),{shapes:p,charWidths:f,charCoords:g}=i.generateShapes(u,e,t),m=(typeof r=="number"?r:Number(t.getVariable(r)))*.5,v=(typeof s=="number"?s:Number(t.getVariable(s)))*.5,y=p.map(_=>new mi().fromShape(_,!0));this.vectorShapes=y;let x=y.map(_=>yl.create({shape:_,parameters:{depth:a,extrudeBevelSegments:o,extrudeBevelSize:n,windingRule:a<=0?Gt.NONZERO:Gt.ODD,subdivisions:this.isLowResolution&&a>0?vX:gX}})),w=x.length?Qo(x):QC();w.translate(-m,v,0),this.dispose(),this.wrappedText=u,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([_,b])=>{this.setAttribute(_,b)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Ms(new Ge,ey.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}};function yX(e,t,i,r){let s=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,a=[""],n="";for(let o of i)n+=o,o===" "||o===` `?(a[a.length-1]+=n,n="",o===` `&&a.push("")):t.getTextWidth(a[a.length-1]+n,e)>s&&(a[a.length-1].length&&a.push(""),t.getTextWidth(a[a.length-1]+n,e)>s&&(n.length===1?(a[a.length-1]+=n,n=""):(a[a.length-1]+=n.slice(0,-1),n=n[n.length-1],a.push(""))));return a[a.length-1]+=n,a}var ZC,KC=new Promise(e=>{ZC=e}),pS=!1,Yu;function xX(e){if(pS)return;if(Yu)return Yu;async function t(){let i=e??"https://unpkg.com/@splinetool/modelling-wasm@1.10.53/build",r=vo(()=>import("./process-efgVNNca.js"),__vite__mapDeps([])),[s,a]=await Promise.all([r,fetch(`${i}/process.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});ZC(o),pS=!0}return Yu=t(),Yu}var bX=["font"];function Dd(e,t,i,r){var h,c;let s,a,n;e.type==="PathGeometry"?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let d of n){let u=a;for(let p of d)u=u[p];for(s in u){let p=u[s];g_(p)&&!bX.includes(s)&&(u[s]=t.getVariable(p,[r.uuid,"geometry",...d,s]),g_(u[s])&&(u[s]=1))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let d=mi.createFromState(a.shape,a.width,a.height);o.shape=d}else if(a.type==="NonParametricGeometry"){if(a.data.groups&&((h=a.data.groups)==null||h.forEach(d=>d.materialIndex=Math.max(d.materialIndex??0,0))),o.geometry=new kM().parse(a),o.geometry.groups.length===0){let d=o.geometry;d.addGroup(0,Math.max(((c=d.getIndex())==null?void 0:c.count)??0,d.getAttribute("position").count),0)}}else if(a.type==="SubdivGeometry"){let d=new zr(a,i);return d.data=e,d}else{if(a.type==="TextGeometry")return new ey(a,t);if(a.type==="InputGeometry")return new ey(a,t);if(a.type==="UIGeometry")return U1.create({parameters:{width:a.width,height:a.height,cornerRadius:a.cornerRadius,cornerType:a.cornerType}})}let l;try{l=yS(o)}catch(d){console.error(d)}if(!l){let d=mi.createFromState(mf.defaultData(),100,100);o.shape=d,l=yS(o)}return l}var wX=new we;function ty(e,t,i,r){let s=e.position.array,a=e.normal.array,n=wX.makeScale(t,i,r).invert().elements,o,l,h;for(var c=0,d=s.length;c{rt=e});var fS=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),mS=new Uint32Array([0,1,2,3]),gS=new Uint8Array([4]),zr=class extends Ge{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=il.div(t,i);this.subdividedGeometry&&ty(this.subdividedGeometry.attributes,...r),this.originalGeometry&&ty(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(Gl.fromArray(r));let a=Gl.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=zr.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Xs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(zr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new $r,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Qu.setFromBufferAttribute(t),Qu.getCenter(i),e.boundingSphere.radius=i.distanceTo(Qu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Qu.getSize(Gl);let r={width:Gl.x,height:Gl.y,depth:Gl.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n,o=(e==null?void 0:e.phongAngle)??35;i===!1&&(o=-1),t&&(rt.free_bvh(t),rt.free_subdivision_surface(t));try{s=zr.allocate(e,r)}catch(l){console.error(l,e),s=zr.allocate({positionWASM:fS,indexWASM:mS,verticesPerFaceWASM:gS},r)}if(rt.set_destination_refinement_level(s,0),a=zr.buildLevel(s,!0,o),e.subdivisions>0)try{rt.set_destination_refinement_level(s,e.subdivisions),n=zr.buildLevel(s,!1,o)}catch{try{rt.set_destination_refinement_level(s,e.subdivisions-1),n=zr.buildLevel(s,!1,o)}catch{n=null}}else n=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:Dd(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let a,n,o,l;({positions:a,triIndices:l}=um(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2,d=c+e.radialSegments*3;h=[c,d]}return{indices:n,verticesPerFace:o}=JC(a,l,r,h),{positions:a,indices:n,verticesPerFace:o}}static allocate(e,t){var x;let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=fS,r=mS,s=gS);let o=i.length,l=r.length,h=s.length,c=i.length+a.length+n.length,d=r.length+s.length,u=c*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,p=c*Float32Array.BYTES_PER_ELEMENT,f=rt._malloc(u),g=new Float32Array(rt.HEAPF32.buffer,f,c),m=new Uint32Array(rt.HEAPU32.buffer,f+p,d);g.set(i,0),g.set(a,i.length),g.set(n,i.length+a.length),m.set(r,0),m.set(s,r.length);let v;(x=e==null?void 0:e.scaleBaked)!=null&&x.some(w=>w!==1)&&(v=new we().makeScale(...e.scaleBaked)),t&&(v?v.premultiply(t):v=t);let y=v?rt.alloc_subdivision_surface2(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,v.elements):rt.alloc_subdivision_surface(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return rt._free(f),y}static buildLevel(e,t,i,r,s){let a=s?rt.get_mesh_data2(e,t?rt.Level.CONTROL:rt.Level.REFINED,i,s.elements):rt.get_mesh_data(e,t?rt.Level.CONTROL:rt.Level.REFINED,i),n=8,o=rt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,8),h=0,c=rt.HEAPU32[o[h]>>2],d=rt.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let u=rt.HEAPU32[o[h]>>2],p=rt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=rt.HEAPU32[o[h]>>2],g=rt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=rt.HEAPU32[o[h]>>2],v=rt.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new Ge;if(y.setIndex(new mh(v,1)),y.setAttribute("position",new Ie(d,3)),y.setAttribute("normal",new Ie(p,3)),t){y.setAttribute("faceMap",new mh(g,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new tt(x,4))}return rt.free_mesh_data(a),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,rt.free_mesh_data(a)}static freeSubdivPointer(e){rt.free_bvh(e),rt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=rt.get_wireframe_data_for_base_level(e),s=4,a=rt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,4),o=0,l=rt.HEAPU32[a[o]>>2],h=rt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let c=rt.HEAPU32[a[o]>>2],d=rt.HEAPU32.subarray(c>>2,(c>>2)+n[o]);if(t===void 0){let u=new Ge;u.setAttribute("position",new Ie(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f>2,(s>>2)+a),o=n.subarray(3,6),l=0,h=rt.HEAPU32[n[l]>>2],c=new Float32Array(rt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let d=rt.HEAPU32[n[l]>>2],u=new Uint32Array(rt.HEAPU32.subarray(d>>2,(d>>2)+o[l]));l++;let p=rt.HEAPU32[n[l]>>2],f=new Uint8Array(rt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return rt.free_topological_data(s),{positions:c,indices:u,verticesPerFace:f}}},vS=["getX","getY","getZ"];function um(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],o=1e4;for(let h=0;h=360){let u=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%u===0)}let c=0;for(let u=0;u=0;u-=2)e.push(l[u],l[u+1],0),s.push(d++);return a.push(d),{indices:s,verticesPerFace:a}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o.005||r&&r.some((h,c)=>c%2===1?!1:o>=r[c]&&oEX,calcBooleanTopological:()=>MX,freeMeshSet:()=>DX,getMeshSet:()=>CX,hasOpenEdges:()=>TX,transformMeshSet:()=>PX});var $C,_X=new Promise(e=>{$C=e}),Ku;function SX(e){if(Ku)return Ku;async function t(){let i=e??"https://unpkg.com/@splinetool/boolean-wasm@1.10.53/build",r=vo(()=>import("./boolean-Bni0TW63.js"),__vite__mapDeps([])),[s,a]=await Promise.all([r,fetch(`${i}/boolean.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});$C(o)}return Ku=t(),Ku}var Ct,_h;_X.then(e=>Ct=e);function AX(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:a,triIndices:n}=um(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=JC(a,n,e);o=h.length,r=[];for(let c=0,d=0;c>2,(r>>2)+s),n=a.subarray(3,6),o=0,l=Ct.HEAPU32[a[o]>>2],h=new Float32Array(Ct.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let c=Ct.HEAPU32[a[o]>>2],d=new Uint32Array(Ct.HEAPU32.subarray(c>>2,(c>>2)+n[o]));o++;let u=Ct.HEAPU32[a[o]>>2],p=new Uint8Array(Ct.HEAPU32.subarray(u>>2,(u>>2)+n[o]));return Ct.free_mesh_data(r),{positions:h,indices:d,verticesPerFace:p}}function EX(e,t,i,r){_h===void 0&&(_h=Ct.init_csg());let s=eT(e),a=Ct.csg_calc(_h,s,e.length,r,tT(t));Ct._free(s);let n=5,o=Ct.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,5),h=0,c=Ct.HEAPU32[o[h]>>2],d=Ct.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let u=Ct.HEAPU32[o[h]>>2],p=Ct.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ie(d,3)),i.setAttribute("normal",new Ie(p,3));let g=Ct.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new $r),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},Ct.free_mesh_data(a),f}function CX(e,t,i){if(Ct===void 0)return-1;let r,s,a;if(t&&e.userData.positions!==void 0){let m=e.userData;a=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+a);for(let v=0,y=0,x=0;vIX[e.type].create(e);function Hl(e){return e!==null&&"booleanOp"in e}var iT=class extends I1(Jt){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new we}updateVisible(e){super.updateVisible(e),this.visible=!Hl(this.parent)&&this.visible,Hl(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Za.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Hl(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof iT&&(e.freeBooleanPointer(),Hl(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Hl(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Hl(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Ju=new Si;function N1(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;for(let d=t;dl&&(l=u),p>h&&(h=p),f>c&&(c=f)}Ju.min.set(a,n,o),Ju.max.set(l,h,c),Ju.getCenter(r),Ju.getSize(s).multiplyScalar(.5)}var OX=new Ge,RX=new gn,Vr=class extends iT{constructor(e,t){super(OX,RX),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?N1(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},jn=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},jn.uuidContext===null)throw new Error("plz startContext");jn.uuidContext===jn.globalContext?this.uuid="_gid"+jn.uuidContext.nodeContextUuid++:this.uuid="_uid"+jn.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){this.uuidContext===null||this.uuidContext===jn.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,a){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}},Vi=jn;Vi.globalContext={nodeContextUuid:0},Vi.uuidContext=jn.globalContext;var xS=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},LX=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Qr=new LX,Wt=class extends Vi{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=Re.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let a=e.getNodeData(i),n=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return a.name=a.name||super.build(e,t,i),a.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||a.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,a.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},es=class extends Wt{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}},cr=class extends es{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof j?e:new j(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},fs=class extends es{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof M?e:new M(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},vr=class extends et{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},Ka=class extends es{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof vr?e:new vr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},zX=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,bS=/[a-z_0-9]+/gi,De=class extends Wt{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let a,n=0,o=this.src;if(this.includes)for(let h=0;h1?(n=l[1],a=l[2],o=l[3]):(a=this.src,n="f"),this.name=a,this.type=n,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},Ut=rT;Ut.PI="PI",Ut.PI2="PI2",Ut.RECIPROCAL_PI="RECIPROCAL_PI",Ut.RECIPROCAL_PI2="RECIPROCAL_PI2",Ut.LOG2="LOG2",Ut.EPSILON="EPSILON";var FX=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.| )*?)}`,"gim"),UX=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),sT=class extends Wt{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=FX.exec(e);if(t){let i=t[2],r;for(;r=UX.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},k1=class extends Wt{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};Qr.addKeyword("uv",function(){return new k1});Qr.addKeyword("uv2",function(){return new k1(1)});var sh=class extends Wt{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??sh.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case qs:return["Linear"];case gt:return["sRGB"];default:return[]}}generate(e,t){var n;let i=this.input.build(e,"v4"),r=this.getType(e),s=sh.Nodes[this.method],a=e.include(s);if(a===sh.LINEAR_TO_LINEAR)return e.format(i,r,t);if(((n=s.inputs)==null?void 0:n.length)===2){let o=this.factor.build(e,"f");return e.format(a+"( "+i+", "+o+" )",r,t)}else return e.format(a+"( "+i+" )",r,t)}fromEncoding(e){let t=sh.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=sh.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},ba=sh;ba.Nodes={LinearToLinear:new De(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(` `)),sRGBToLinear:new De(["vec4 sRGBToLinear( in vec4 value ) {"," 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.w );","}"].join(` `)),LinearTosRGB:new De(["vec4 LinearTosRGB( in vec4 value ) {"," 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.w );","}"].join(` `))},ba.LINEAR_TO_LINEAR="LinearToLinear",ba.SRGB_TO_LINEAR="sRGBToLinear",ba.LINEAR_TO_SRGB="LinearTosRGB";var ii=class extends De{constructor(e="",t,i,r,s){super(e,s,r,i,t),this.nodeType="Expression"}},an=class extends es{constructor(e=new ci,t,i,r){super("v4",{shared:!0}),this.nodeType="Texture",this.value=e,this.uv=t??new k1,this.bias=i,this.project=r!==void 0?r:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let i=this.getTexture(e,t),r=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a,n;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?n=a+"( "+i+", "+r+", "+s+" )":n=a+"( "+i+", "+r+" )";let o={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(o),this.colorSpace=this.colorSpace??new ba(new ii("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(n),n=this.colorSpace.build(e,l),e.removeContext(),e.format(n,l,t)}},Fe=class extends es{constructor(e){super("f"),this.nodeType="Float",this.value=e??0}generateReadonly(e,t,i,r,s,a){return e.format(this.value+(this.value%1?"":".0"),r,t)}},wS=class extends Wt{constructor(e,t){super(),this.inputs=[],this.nodeType="FunctionCall",this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,i,r,s){r=this.getType(e);let a=this.value,n=a.build(e,t)+"( ",o=[];if(a.inputs){for(let l=0;le.getTypeLength(t)?i:t}generate(e,t){let i=this.getType(e);this.type=i;let r=this.a.build(e,i),s=this.b.build(e,i);return e.format("( "+r+" "+this.op+" "+s+" )",i,t)}},Wr=aT;Wr.ADD="+",Wr.SUB="-",Wr.MUL="*",Wr.DIV="/";var Vt=class extends Wt{constructor(e,t=Vt.ABS,i,r){super(),this.nodeType="Math",this.a=e,typeof t!="string"?this.b=t:r=t,typeof i!="string"?this.c=i:r=i,this.method=r,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Vt.MIX:case Vt.CLAMP:case Vt.REFRACT:case Vt.SMOOTHSTEP:case Vt.FACEFORWARD:return 3;case Vt.MIN:case Vt.MAX:case Vt.MOD:case Vt.STEP:case Vt.REFLECT:case Vt.DISTANCE:case Vt.DOT:case Vt.CROSS:case Vt.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),i=this.b?e.getTypeLength(this.b.getType(e)):0,r=this.c?e.getTypeLength(this.c.getType(e)):0;return t>i&&t>r?this.a.getType(e):i>r?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Vt.LENGTH:case Vt.DISTANCE:case Vt.DOT:return"f";case Vt.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let i,r,s,a=this.a?e.getTypeLength(this.a.getType(e)):0,n=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),h=this.getType(e);switch(this.type=h,this.method){case Vt.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case Vt.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case Vt.CROSS:i=this.a.build(e,"v3"),r=this.b.build(e,"v3");break;case Vt.STEP:i=this.a.build(e,a===1?"f":l),r=this.b.build(e,l);break;case Vt.MIN:case Vt.MAX:case Vt.MOD:i=this.a.build(e,l),r=this.b.build(e,n===1?"f":l);break;case Vt.REFRACT:i=this.a.build(e,l),r=this.b.build(e,l),s=this.c.build(e,"f");break;case Vt.MIX:i=this.a.build(e,l),r=this.b.build(e,l),s=this.c.build(e,o===1?"f":l);break;default:i=this.a.build(e,l),this.b&&(r=this.b.build(e,l)),this.c&&(s=this.c.build(e,l));break}let c=[];c.push(i),r&&c.push(r),s&&c.push(s);let d=this.getNumInputs(e);if(c.length!==d)throw Error(`Arguments not match used in "${this.method}". Require ${d}, currently ${c.length}.`);return e.format(this.method+"( "+c.join(", ")+" )",h,t)}},ft=Vt;ft.RAD="radians",ft.DEG="degrees",ft.EXP="exp",ft.EXP2="exp2",ft.LOG="log",ft.LOG2="log2",ft.SQRT="sqrt",ft.INV_SQRT="inversesqrt",ft.FLOOR="floor",ft.CEIL="ceil",ft.NORMALIZE="normalize",ft.FRACT="fract",ft.SATURATE="saturate",ft.SIN="sin",ft.COS="cos",ft.TAN="tan",ft.ASIN="asin",ft.ACOS="acos",ft.ARCTAN="atan",ft.ABS="abs",ft.SIGN="sign",ft.LENGTH="length",ft.NEGATE="negate",ft.INVERT="invert",ft.MIN="min",ft.MAX="max",ft.MOD="mod",ft.STEP="step",ft.REFLECT="reflect",ft.DISTANCE="distance",ft.DOT="dot",ft.CROSS="cross",ft.POW="pow",ft.MIX="mix",ft.CLAMP="clamp",ft.REFRACT="refract",ft.SMOOTHSTEP="smoothstep",ft.FACEFORWARD="faceforward";var Gc=class extends Wt{constructor(e,t,i){super("v4"),this.nodeType="TextureCubeUV",this.value=e,this.uv=t,this.bias=i}bilinearCubeUV(e,t,i,r){let s=new wS(Gc.Nodes.bilinearCubeUV,[t,i,r]);this.colorSpaceTL=this.colorSpaceTL??new ba(new ii("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new ba(new ii("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new ba(new ii("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new ba(new ii("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new ii(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new ii(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new ii(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new ii(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let n=new ii("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return n.keywords.cubeUV_TL=this.colorSpaceTLExp,n.keywords.cubeUV_TR=this.colorSpaceTRExp,n.keywords.cubeUV_BL=this.colorSpaceBLExp,n.keywords.cubeUV_BR=this.colorSpaceBRExp,n.keywords.cubeUV=s,n}generate(e,t){if(e.isShader("fragment")){let i=this.uv,r=this.bias||e.context.roughness,s=new wS(Gc.Nodes.roughnessToMip,[r]),a=new ft(s,Gc.Nodes.m0,Gc.Nodes.cubeUV_maxMipLevel,ft.CLAMP),n=new ft(a,ft.FLOOR),o=new ft(a,ft.FRACT),l=this.bilinearCubeUV(e,this.value,i,n),h=this.bilinearCubeUV(e,this.value,i,new Wr(n,new Fe(1).setReadonly(!0),Wr.ADD)),c=new ft(l,h,o,ft.MIX);return e.format(c.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},iy=Gc;iy.Nodes=function(){let e=new sT(`struct TextureCubeUVData { vec4 tl; vec4 tr; vec4 br; vec4 bl; vec2 f; }`),t=new Ut("float cubeUV_maxMipLevel 8.0",!0),i=new Ut("float cubeUV_minMipLevel 4.0",!0),r=new Ut("float cubeUV_maxTileSize 256.0",!0),s=new Ut("float cubeUV_minTileSize 16.0",!0),a=new De(`float getFace(vec3 direction) { vec3 absDirection = abs(direction); float face = -1.0; if (absDirection.x > absDirection.z) { if (absDirection.x > absDirection.y) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if (absDirection.z > absDirection.y) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; }`);a.useKeywords=!1;let n=new De(`vec2 getUV(vec3 direction, float face) { vec2 uv; if (face == 0.0) { uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x } else if (face == 1.0) { uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y } else if (face == 2.0) { uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z } else if (face == 3.0) { uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x } else if (face == 4.0) { uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y } else { uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z } return 0.5 * (uv + 1.0); }`);n.useKeywords=!1;let o=new De(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) { float face = getFace(direction); float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0); mipInt = max(mipInt, cubeUV_minMipLevel); float faceSize = exp2(mipInt); float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize); vec2 uv = getUV(direction, face) * (faceSize - 1.0); vec2 f = fract(uv); uv += 0.5 - f; if (face > 2.0) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; if(mipInt < cubeUV_maxMipLevel){ uv.y += 2.0 * cubeUV_maxTileSize; } uv.y += filterInt * 2.0 * cubeUV_minTileSize; uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize); uv *= texelSize; vec4 tl = texture2D(envMap, uv); uv.x += texelSize; vec4 tr = texture2D(envMap, uv); uv.y += texelSize; vec4 br = texture2D(envMap, uv); uv.x -= texelSize; vec4 bl = texture2D(envMap, uv); return TextureCubeUVData( tl, tr, br, bl, f ); }`,[e,a,n,t,i,r,s]);o.useKeywords=!1;let l=new Ut("float r0 1.0",!0),h=new Ut("float v0 0.339",!0),c=new Ut("float m0 -2.0",!0),d=new Ut("float r1 0.8",!0),u=new Ut("float v1 0.276",!0),p=new Ut("float m1 -1.0",!0),f=new Ut("float r4 0.4",!0),g=new Ut("float v4 0.046",!0),m=new Ut("float m4 2.0",!0),v=new Ut("float r5 0.305",!0),y=new Ut("float v5 0.016",!0),x=new Ut("float m5 3.0",!0),w=new Ut("float r6 0.21",!0),_=new Ut("float v6 0.0038",!0),b=new Ut("float m6 4.0",!0),A=[l,h,c,d,u,p,f,g,m,v,y,x,w,_,b],S=new De(`float roughnessToMip(float roughness) { float mip = 0.0; if (roughness >= r1) { mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0; } else if (roughness >= r4) { mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1; } else if (roughness >= r5) { mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4; } else if (roughness >= r6) { mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5; } else { mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25 } return mip; }`,A);return{bilinearCubeUV:o,roughnessToMip:S,m0:c,cubeUV_maxMipLevel:t}}();var ah=class extends Wt{constructor(e){super("v3"),this.nodeType="Normal",this.scope=e??ah.VIEW}getShared(){return this.scope===ah.WORLD}build(e,t,i,r){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,i,r):super.build(e,t,i)}generate(e,t,i,r,s){let a;switch(this.scope){case ah.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case ah.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case ah.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),t)}},Zr=ah;Zr.LOCAL="local",Zr.WORLD="world",Zr.VIEW="view",Zr.NORMAL="normal";Qr.addKeyword("viewNormal",function(){return new Zr(Zr.VIEW)});Qr.addKeyword("localNormal",function(){return new Zr(Zr.NORMAL)});Qr.addKeyword("worldNormal",function(){return new Zr(Zr.WORLD)});var Ya=class extends Wt{constructor(e){super("v3"),this.nodeType="Position",this.scope=e??Ya.LOCAL}getType(){switch(this.scope){case Ya.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Ya.LOCAL:case Ya.WORLD:return!1}return!0}generate(e,t,i,r,s){let a;switch(this.scope){case Ya.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case Ya.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case Ya.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Ya.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),t)}},js=Ya;js.LOCAL="local",js.WORLD="world",js.VIEW="view",js.PROJECTION="projection";Qr.addKeyword("position",function(){return new js});Qr.addKeyword("worldPosition",function(){return new js(js.WORLD)});Qr.addKeyword("viewPosition",function(){return new js(js.VIEW)});var da=class extends Wt{constructor(e){super("v3"),this.nodeType="Reflect",this.scope=e??da.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case da.SPHERE:return"v2"}return this.type}generate(e,t){let i=this.getUnique(e);if(e.isShader("fragment")){let r;switch(this.scope){case da.VECTOR:{let s=new Zr(Zr.VIEW),a=e.context.roughness,n=s.build(e,"v3"),o=new js(js.VIEW).build(e,"v3"),l=a?a.build(e,"f"):void 0,h=`reflect( -normalize( ${o} ), ${n} )`;l&&(h=`normalize( mix( ${h}, ${n}, ${l} * ${l} ) )`);let c=`inverseTransformDirection( ${h}, viewMatrix )`;i?(e.addNodeCode(`vec3 reflectVec = ${c};`),r="reflectVec"):r=c;break}case da.CUBE:{let s=new da(da.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";i?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),r="reflectCubeVec"):r=a;break}case da.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new da(da.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";i?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),r="reflectSphereVec"):r=s;break}}return e.format(r,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},Sh=da;Sh.CUBE="cube",Sh.SPHERE="sphere",Sh.VECTOR="vector";var NX=class extends Wt{constructor(e=new an,t,i){super("v4"),this.nodeType="TextureCube",this.value=e,this.radianceNode=new iy(this.value,t??new Sh(Sh.VECTOR),i),this.irradianceNode=new iy(this.value,new Zr(Zr.WORLD),new Fe(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}},kX=class extends es{constructor(e=new Gy,t,i){super("v4",{shared:!0}),this.nodeType="CubeTexture",this.value=e,this.uv=t??new Sh,this.bias=i}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var l;if(t==="samplerCube")return this.getTexture(e,t);let i=this.getTexture(e,t),r=(l=this.uv)==null?void 0:l.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a;s?a="texCubeBias( "+i+", "+r+", "+s+" )":a="texCube( "+i+", "+r+" )";let n={include:e.isShader("vertex"),ignoreCache:!0},o=this.getType(e);return e.addContext(n),this.colorSpace=this.colorSpace??new ba(new ii("",o)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,o),e.removeContext(),e.format(a,o,t)}},VX=` uniform int frameIndex; uniform vec2 resolution; uniform mat4 previousModelViewMatrix; uniform mat4 previousProjectionMatrix; varying vec4 vCurrentPosition; varying vec4 vPreviousPosition; `,jX=` layout(location = 1) out vec4 gVelocity; uniform int frameIndex; uniform vec2 resolution; varying vec4 vCurrentPosition; varying vec4 vPreviousPosition; const vec2 haltonSequence[16] = vec2[16]( vec2( 0.000000,-0.333334), vec2(-0.500000, 0.333334), vec2( 0.500000,-0.777778), vec2(-0.750000,-0.111112), vec2( 0.250000, 0.555556), vec2(-0.250000,-0.555556), vec2( 0.750000, 0.111112), vec2(-0.875000, 0.777778), vec2(0.125000, -0.925926), vec2(-0.375000, -0.259260), vec2(0.625000, 0.407408), vec2(-0.625000, -0.703704), vec2(0.375000, -0.037038), vec2(-0.125000, 0.629630), vec2(0.875000, -0.481482), vec2(-0.937500, 0.185186)); vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) { const float goldenAngle = 2.399963f; // radians float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount)); float theta = float(sampleIndex) * goldenAngle + angle; float sine = sin(theta); float cosine = cos(theta); return vec2(cosine, sine) * r; } // Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso float getNoiseInterleavedGradient(vec2 screenPos) { vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f); return fract(magic.z * fract(dot(screenPos, magic.xy))); } `,GX=` // TODO: This could be generated CPU side and passed to the shader every frame const vec2 haltonSequence[16] = vec2[16]( vec2( 0.000000,-0.333334), vec2(-0.500000, 0.333334), vec2( 0.500000,-0.777778), vec2(-0.750000,-0.111112), vec2( 0.250000, 0.555556), vec2(-0.250000,-0.555556), vec2( 0.750000, 0.111112), vec2(-0.875000, 0.777778), vec2(0.125000, -0.925926), vec2(-0.375000, -0.259260), vec2(0.625000, 0.407408), vec2(-0.625000, -0.703704), vec2(0.375000, -0.037038), vec2(-0.125000, 0.629630), vec2(0.875000, -0.481482), vec2(-0.937500, 0.185186)); // TODO: Pass correct view size vec2 offset = haltonSequence[frameIndex]; offset.x /= resolution.x; offset.y /= resolution.y; vec4 currentPosition = gl_Position; vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w); // We want to calculate the velocity with unjittered positions // so that things that are not moving get a velocity = 0 vCurrentPosition = currentPosition; vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0); #ifdef OUTLINE_COMPENSATION vPreviousPosition.xy += OUTLINE_COMPENSATION; #endif gl_Position = currentPositionJittered; `,HX=` vec2 oldPos = vPreviousPosition.xy; oldPos /= vPreviousPosition.w; oldPos.xy = (oldPos.xy+1.)/2.0; vec2 newPos = vCurrentPosition.xy; newPos /= vCurrentPosition.w; newPos.xy = (newPos.xy+1.)/2.0; vec2 velocity = (newPos - oldPos); // Discard fully transparent pixels if (gl_FragColor.a <= 0.0) discard; gVelocity = vec4(velocity, 0.0, 1.0); `,WX=` layout(location = 1) out vec4 gVelocity; `,qX=` // Discard fully transparent pixels if (gl_FragColor.a <= 0.0) discard; gVelocity = vec4(0.0, 0.0, 0.0, 1.0); `,_S=["x","y","z","w"],XX=["float","vec2","vec3","vec4"],YX={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},QX={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},nT=class{constructor(){this.includes={consts:{},functions:{},structs:{}},this.cache="",this.slot="",this.shader="",this.context={},this.needsJitter=!0,this.getIncludesCode=function(){function e(t,i){return t.deps.length-i.deps.length}return function(t,i){let r=this.getIncludes(t,i);if(!r)return"";let s="";r=r.sort(e);for(let a=0;a","#include "].join(` `),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(` `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) { accumAlpha += (1.0 - accumAlpha) * alpha; }`,""].join(` `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(e,t){this.addVertexParsCode(VX),this.addFragmentParsCode(jX),this.buildShader("vertex",e),this.buildShader("fragment",t);for(let i=0;i0?i+1:"";this.addVaryCode("varying vec2 vUv"+r+";"),i>0&&this.addVertexParsCode("attribute vec2 uv"+r+";"),this.addVertexFinalCode("vUv"+r+" = uv"+r+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode(` #ifndef SHAPEBLEND vObjectNormal = normal; #else vObjectNormal = objectNormal; #endif `)),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(GX),this.addFragmentFinalCode(HX)),this}buildShader(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")}setMaterial(e,t){return this.defines={},this}addFlow(e,t,i){return this.addSlot(e).addCache(t).addContext(i)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(e){return this.cache=e??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(e){return this.slot=e||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(e,t){this.fragmentVariables[e]===void 0&&(this.addFragmentCode(`${t} ${e};`),this.fragmentVariables[e]="")}addFragmentParsVariable(e,t){this.fragmentParsVariables[e]===void 0&&(this.addFragmentParsCode(`${t} ${e};`),this.fragmentParsVariables[e]="")}addVertexParsVariable(e,t){this.vertexParsVariables[e]===void 0&&(this.addVertexParsCode(`${t} ${e};`),this.vertexParsVariables[e]="")}addVertexCode(e){this.addCode(e,"vertex")}addFragmentCode(e){this.addCode(e,"fragment")}addCode(e,t){this.code[t??this.shader]+=e+` `}addVertexNodeCode(e){this.addNodeCode(e,"vertex")}addFragmentNodeCode(e){this.addNodeCode(e,"fragment")}addNodeCode(e,t){this.nodeCode[t??this.shader]+=e+` `}clearNodeCode(e){e=e??this.shader;let t=this.nodeCode[e];return this.nodeCode[e]="",t}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(e){this.addFinalCode(e,"vertex")}addFragmentFinalCode(e){this.addFinalCode(e,"fragment")}addFinalCode(e,t){this.finalCode[t??this.shader]+=e+` `}addVertexParsCode(e){this.addParsCode(e,"vertex")}addFragmentParsCode(e){this.addParsCode(e,"fragment")}addParsCode(e,t){this.parsCode[t??this.shader]+=e+` `}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return this.caches.indexOf(e)!==-1}isSlot(e){return this.slots.indexOf(e)!==-1}define(e,t){this.defines[e]=t===void 0?1:t}require(e){this.requires[e]=!0}isDefined(e){return this.defines[e]!==void 0}getVar(e,t,i,r="varying",s="V",a=""){let n=this.getVars(r),o=n[e];if(!o){let l=n.length;o={name:i||"node"+s+l+(a?"_"+a:""),type:t},n.push(o),n[e]=o}return o}getTempVar(e,t,i,r){return this.getVar(e,t,i,this.shader,"T",r)}getAttribute(e,t){if(!this.attributes[e]){let i=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(i.name+" = "+e+";"),this.attributes[e]={varying:i,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join(` `)}getVarListCode(e,t){t=t??"";let i="";for(let r=0,s=e.length;r 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } lalpha *= mask; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return col; }`);r=e.include(o);break;case 4:r=e.include(Hc.Nodes.triplanar);break;default:r=e.include(Hc.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let s=[];if(s.push("normal"),s.push(this.texture.generate(e,"t")),s.push(this.textureSize.build(e,"v2")),s.push(this.crop.build(e,"f")),s.push(this.mat.build(e,"mat3")),s.push(this.size.build(e,"v2")),s.push(this.blending.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),this.projection.value===4){let a=`${i}_writeUvs`,n=a+"0",o=a+"1",l=a+"2",h=`${i}_triplanarWeights`;e.addFragmentVariable(n,"vec2"),e.addFragmentVariable(o,"vec2"),e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(h,"vec3"),s.push(n),s.push(o),s.push(l),s.push(h)}else{let a=`${i}_writeUvs`;e.addFragmentVariable(a,"vec2"),s.push(a)}return e.format(r+"("+s.join(",")+")",this.getType(e),t)}},j1=Hc;j1.Nodes=function(){let e=new De(` vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) { vec3 posN = normalize(position); float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); float scaledHeight = position.y / (size.y * 0.5); float v = (scaledHeight / 2.) + .5; vec2 calculatedUv = vec2(u,v); vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; writeUv = uvs; vec2 df = fwidth(uvs); if(df.x > 0.5) df.x = 0.; #ifdef GL_EXT_shader_texture_lod vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #else vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #endif vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } lalpha *= mask; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return col; } `),t=new De(` vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) { vec3 posN = normalize(vPosition); float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); float v = 0.5 + asin(posN.y) / 3.1415; vec2 calculatedUv = vec2(u,v); vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; writeUv = uvs; vec2 df = fwidth(uvs); if(df.x > 0.5) df.x = 0.; #ifdef GL_EXT_shader_texture_lod vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #else vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #endif vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } lalpha *= mask; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return col; } `),i=new De(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) { vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; writeUv = uvs; vec4 tmp = texture2D( tex, uvs ); vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } lalpha *= mask; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return col; }`),r=new De(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) { vec3 p = position; vec2 uv0 = (1.0 + p.xy) / 2.0; vec2 uv1 = (1.0 + p.zy) / 2.0; vec2 uv2 = (1.0 + p.xz) / 2.0; uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; uv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; // Range from 3 to 128 seems to be good float exponent = (1.0 - blending) * 125.0 + 3.0; vec3 n = vObjectNormal; vec3 weights = abs(normalize(n)); weights = pow(weights, vec3(exponent)); weights /= dot(weights, vec3(1.0)); // Write out all sets of UVs that we generated writeUvs0 = uv0; writeUvs1 = uv1; writeUvs2 = uv2; writeWeights = weights; // Derivatives for LOD vec2 df0 = fwidth(uv0); vec2 df1 = fwidth(uv1); vec2 df2 = fwidth(uv2); if (df0.x > 0.5) df0.x = 0.0; if (df1.x > 0.5) df1.x = 0.0; if (df2.x > 0.5) df2.x = 0.0; #ifdef GL_EXT_shader_texture_lod vec4 tmp = texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z + texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x + texture2DLodEXT(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y; #else vec4 tmp = textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z + textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x + textureLod(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y; #endif vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; // Apply cropping across all 3 planes if ( crop > 0.5 ) { if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) { lalpha = 0.0; } if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) { lalpha = 0.0; } if ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) { lalpha = 0.0; } } lalpha *= mask; calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return col;//n * 0.5 + 0.5; } `);return{cylindrical:e,spherical:t,uv:i,triplanar:r}}();var Wc=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d){super("v3"),this.nodeType="Depth",this.gradientType=e,this.smooth=t,this.near=i,this.far=r,this.isVector=s,this.isWorldSpace=a,this.origin=n,this.direction=o,this.colors=l,this.steps=h,this.isMask=d,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let i=`g${this.uuid.toString().replace(/-/g,"")}`,r=new De(`vec3 ${i}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${i}_MAX_COLORS], float steps[${i}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) { vec4 color = colors[0]; #ifdef ${i}_IS_VECTOR #ifdef ${i}_LINEAR #ifdef ${i}_WORLDSPACE float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far); #else float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far); #endif #else #ifdef ${i}_WORLDSPACE float depth = vectorSphericalWorldSpaceDepth(origin, near, far); #else float depth = vectorSphericalObjectSpaceDepth(origin, near, far); #endif #endif #else float dist = length(vWPosition - cameraPosition); float depth = ( dist - near ) / ( far - near ); #endif float p; #ifdef ${i}_SMOOTH for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) { p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); } #else for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) { p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0); color = mix(color, colors[i], p); } #endif float lalpha = alpha * color.a * mask; calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return color.rgb; }`,[Wc.Nodes.vectorLinearWorldSpaceDepth,Wc.Nodes.vectorLinearObjectSpaceDepth,Wc.Nodes.vectorSphericalObjectSpaceDepth,Wc.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${i}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${i}_SMOOTH`),this.isVector.value>.5&&e.define(`${i}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${i}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${i}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let s=e.include(r),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(s+"("+a.join(",")+")",this.getType(e),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},dT=Wc;dT.Nodes=function(){let e=new De(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) { vec3 n = normalize(direction); float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z)); return ( dist - near ) / ( far - near ); }`),t=new De(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) { vec3 n = normalize(direction); float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z)); return ( dist - near ) / ( far - near ); }`),i=new De(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) { float dist = length(vWPosition - origin); return ( dist - near ) / ( far - near ); }`),r=new De(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) { float dist = length(position - origin); return ( dist - near ) / ( far - near ); }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:i,vectorSphericalObjectSpaceDepth:r}}();var JX=class extends Wt{constructor(e,t,i,r,s,a,n,o){super("v3"),this.nodeType="Fresnel",this.color=e,this.bias=t,this.scale=i,this.intensity=r,this.factor=s,this.isMask=o,this.alpha=a,this.mode=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=new De(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) { float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity ); float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask; calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return color; }`),r=e.include(i),s=[];return s.push(this.color.build(e,"c")),s.push(this.bias.build(e,"f")),s.push(this.scale.build(e,"f")),s.push(this.intensity.build(e,"f")),s.push(this.factor.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),e.format(r+"("+s.join(",")+")",this.getType(e),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},uT=class extends Wt{constructor(e,t,i,r,s,a,n,o,l){super("v3"),this.nodeType="Gradient",this.gradientType=e,this.smooth=t,this.colors=i,this.steps=r,this.offset=s,this.morph=a,this.angle=n,this.isMask=l,this.alpha=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(uT.Nodes.gradient),r=[];return r.push(this.gradientType.build(e,"i")),r.push(this.smooth.build(e,"b")),r.push(this.colors.build(e,"v4[]")),r.push(this.steps.build(e,"f[]")),r.push(this.offset.build(e,"v2")),r.push(this.morph.build(e,"v2")),r.push(this.angle.build(e,"f")),r.push(this.isMask.build(e,"b")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},pT=uT;pT.Nodes=function(){return{gradient:new De(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) { vec4 color = colors[0]; vec2 m = morph / vUv.xy; vec2 rot = vec2( 0.5 + m.x, m.y ); vec2 dt = vec2( cos( angle ) * rot.x - sin( angle ) * rot.y, sin( angle ) * rot.x + cos( angle ) * rot.y ); vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0; float t = dot( pt, dt ) / dot( dt, dt ); if ( gradientType == 1 ) { t = distance ( ( vUv + morph ) * 3.0, ( vUv + offset ) + 1.0 ) + angle; } else if ( gradientType == 2 ) { float polar = atan( vUv.x + morph.x - 0.5 + offset.x, vUv.y + morph.y - 0.5 + offset.y ) * -1.0; t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) ); } float p; if (smoothed) { for ( int i = 1; i < GRAD_MAX; i++ ) { p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); } } else { for ( int i = 1; i < GRAD_MAX; i++ ) { p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); color = mix(color, colors[i], p); } } float lalpha = alpha * color.a * mask; calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return color.xyz; }`)}}();var fT=class extends Wt{constructor(e,t,i,r,s){super("v3"),this.nodeType="Matcap",this.texture=e,this.isMask=r,this.alpha=t,this.mode=i,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=s}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=e.include(fT.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let r=[];return r.push(this.texture.generate(e,"t")),r.push("normal"),r.push(this.isMask.build(e,"b")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),r.push(this.calpha),r.push(this.rotation.build(e,"f")),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},mT=fT;mT.Nodes=function(){return{matcap:new De(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) { vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ); uv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * uv; uv = uv * 0.495 + 0.5; vec4 matcapColor = texture2D( matcapTex, uv ); float lalpha = alpha * mask; calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return matcapColor.rgb; }`)}}();var Xr=function(){let e=new De(`vec3 random3(vec3 c) { float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0))); vec3 r; r.z = fract(512.0*j); j *= .125; r.x = fract(512.0*j); j *= .125; r.y = fract(512.0*j); return r-0.5; }`),t=new De(`float simplexFast(vec3 p) { vec3 s = floor(p + dot(p, vec3(F3))); mediump vec3 x = p - s + dot(s, vec3(G3)); mediump vec3 hs = s; mediump vec3 e = step(vec3(0.0), x - x.yzx); mediump vec3 i1 = e*(1.0 - e.zxy); mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e); mediump vec3 x1 = x - i1 + G3; mediump vec3 x2 = x - i2 + 2.0*G3; mediump vec3 x3 = x - 1.0 + 3.0*G3; mediump vec4 w, d; w.x = dot(x, x); w.y = dot(x1, x1); w.z = dot(x2, x2); w.w = dot(x3, x3); w = max(0.6 - w, 0.0); d.x = dot(random3(hs), x); d.y = dot(random3(hs + i1), x1); d.z = dot(random3(hs + i2), x2); d.w = dot(random3(hs + 1.0), x3); w *= w; w *= w; d *= w; return dot(d, vec4(52.0)); }`,[e]);t.keywords.F3=new Ut("float F3 0.3333333"),t.keywords.G3=new Ut("float G3 0.1666667");let i=new De(`float simplexPrecise(vec3 p) { vec3 s = floor(p + dot(p, vec3(F3))); vec3 x = p - s + dot(s, vec3(G3)); vec3 e = step(vec3(0.0), x - x.yzx); vec3 i1 = e*(1.0 - e.zxy); vec3 i2 = 1.0 - e.zxy*(1.0 - e); vec3 x1 = x - i1 + G3; vec3 x2 = x - i2 + 2.0*G3; vec3 x3 = x - 1.0 + 3.0*G3; vec4 w, d; w.x = dot(x, x); w.y = dot(x1, x1); w.z = dot(x2, x2); w.w = dot(x3, x3); w = max(0.6 - w, 0.0); d.x = dot(random3(s), x); d.y = dot(random3(s + i1), x1); d.z = dot(random3(s + i2), x2); d.w = dot(random3(s + 1.0), x3); w *= w; w *= w; d *= w; return dot(d, vec4(52.0)); }`,[e]);i.keywords.F3=new Ut("float F3 0.3333333"),i.keywords.G3=new Ut("float G3 0.1666667");let r=new De(`float simplexFractal(vec3 m) { mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4); mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63); mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56); return 0.5333333 * simplexFast(m * rot1) + 0.2666667 * simplexFast(2.0 * m * rot2) + 0.1333333 * simplexFast(4.0 * m * rot3) + 0.0666667 * simplexFast(8.0 * m); }`,[t]),s=new De("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),a=new De("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),n=new De(`float simplexAshima(vec3 v) { const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); vec3 i = floor(v + dot(v, C.yyy) ); vec3 x0 = v - i + dot(i, C.xxx) ; vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min( g.xyz, l.zxy ); vec3 i2 = max( g.xyz, l.zxy ); vec3 x1 = x0 - i1 + 1.0 * C.xxx; vec3 x2 = x0 - i2 + 2.0 * C.xxx; vec3 x3 = x0 - 1. + 3.0 * C.xxx; i = mod(i, 289.0 ); vec4 p = permute( permute( permute( i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); float n_ = 1.0/7.0; // N=7 vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N) vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) vec4 x = x_ *ns.x + ns.yyyy; vec4 y = y_ *ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4( x.xy, y.xy ); vec4 b1 = vec4( x.zw, y.zw ); vec4 s0 = floor(b0)*2.0 + 1.0; vec4 s1 = floor(b1)*2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; vec3 p0 = vec3(a0.xy,h.x); vec3 p1 = vec3(a0.zw,h.y); vec3 p2 = vec3(a1.xy,h.z); vec3 p3 = vec3(a1.zw,h.w); vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); }`,[s,a]),o=new De("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new De("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[o]),h=new De(`float noise(vec3 p){ vec3 a = floor(p); vec3 d = p - a; d = d * d * (3.0 - 2.0 * d); vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0); vec4 k1 = perm(b.xyxy); vec4 k2 = perm(k1.xyxy + b.zzww); vec4 c = k2 + a.zzzz; vec4 k3 = perm(c); vec4 k4 = perm(c + 1.0); vec4 o1 = fract(k3 * (1.0 / 41.0)); vec4 o2 = fract(k4 * (1.0 / 41.0)); vec4 o3 = o2 * d.z + o1 * (1.0 - d.z); vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); return o4.y * d.y + o4.x * (1.0 - d.y); }`,[l]),c=new De(`float fbm(vec3 x) { float v = 0.0; float a = 0.5; vec3 shift = vec3(100); for (int i = 0; i < NUM_OCTAVES; ++i) { v += a * noise(x); x = x * 2.0 + shift; a *= 0.5; } return v; }`,[h]);c.keywords.NUM_OCTAVES=new Ut("int NUM_OCTAVES 5");let d=new De("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),u=new De(`float perlin(vec3 P){ vec3 Pi0 = floor(P); vec3 Pi1 = Pi0 + vec3(1.0); Pi0 = mod(Pi0, 289.0); Pi1 = mod(Pi1, 289.0); vec3 Pf0 = fract(P); vec3 Pf1 = Pf0 - vec3(1.0); vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); vec4 iy = vec4(Pi0.yy, Pi1.yy); vec4 iz0 = Pi0.zzzz; vec4 iz1 = Pi1.zzzz; vec4 ixy = permute(permute(ix) + iy); vec4 ixy0 = permute(ixy + iz0); vec4 ixy1 = permute(ixy + iz1); vec4 gx0 = ixy0 / 7.0; vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5; gx0 = fract(gx0); vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0); vec4 sz0 = step(gz0, vec4(0.0)); gx0 -= sz0 * (step(0.0, gx0) - 0.5); gy0 -= sz0 * (step(0.0, gy0) - 0.5); vec4 gx1 = ixy1 / 7.0; vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5; gx1 = fract(gx1); vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1); vec4 sz1 = step(gz1, vec4(0.0)); gx1 -= sz1 * (step(0.0, gx1) - 0.5); gy1 -= sz1 * (step(0.0, gy1) - 0.5); vec3 g000 = vec3(gx0.x,gy0.x,gz0.x); vec3 g100 = vec3(gx0.y,gy0.y,gz0.y); vec3 g010 = vec3(gx0.z,gy0.z,gz0.z); vec3 g110 = vec3(gx0.w,gy0.w,gz0.w); vec3 g001 = vec3(gx1.x,gy1.x,gz1.x); vec3 g101 = vec3(gx1.y,gy1.y,gz1.y); vec3 g011 = vec3(gx1.z,gy1.z,gz1.z); vec3 g111 = vec3(gx1.w,gy1.w,gz1.w); vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); g000 *= norm0.x; g010 *= norm0.y; g100 *= norm0.z; g110 *= norm0.w; vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); g001 *= norm1.x; g011 *= norm1.y; g101 *= norm1.z; g111 *= norm1.w; float n000 = dot(g000, Pf0); float n100 = dot(g100, vec3(Pf1.x, Pf0.yz)); float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)); float n110 = dot(g110, vec3(Pf1.xy, Pf0.z)); float n001 = dot(g001, vec3(Pf0.xy, Pf1.z)); float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)); float n011 = dot(g011, vec3(Pf0.x, Pf1.yz)); float n111 = dot(g111, Pf1); vec3 fade_xyz = fade(Pf0); vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z); vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y); float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); return 2.2 * n_xyz; }`,[s,a,d]),p=new De(`float hashwithoutsine13(vec3 p3) { p3 = fract(p3 * .1031); p3 += dot(p3, p3.yzx + 33.33); return fract((p3.x + p3.y) * p3.z); }`),f=new De(`vec3 hashwithoutsine33(vec3 p3) { p3 = fract(p3 * vec3(.1031, .1030, .0973)); p3 += dot(p3, p3.yxz+33.33); return fract((p3.xxy + p3.yxx)*p3.zyx); }`),g=new De(`float metric(in vec3 p) { // L2 return length(p); // Chebyshev // vec3 a = abs(p); // return max(a.x, max(a.y, a.z)); }`),m=new De(`float smin( float a, float b, float k ) { float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k); float correction = k * h * (1.0 - h); return mix(b, a, h) - correction; }`),v=new De(`float smax( float a, float b, float k ) { float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k); float correction = k * h * (1.0 - h); return mix(a, b, h) + correction; }`),y=new De(`float remap(float value, float input_min, float input_max, float output_min, float output_max) { // Compute width of each interval float input_width = input_max - input_min; float output_width = output_max - output_min; // Convert input range into a 0-1 range float scaled = (value - input_min) / input_width; // Convert the 0-1 range into a value in output range return output_min + (scaled * output_width); }`),x=new De(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality) { // Integer and fractional parts of this point's coordinates ivec3 p = ivec3(floor(x)); vec3 f = fract(x); // Different variables that we will use to construct noise: // // f1: distance to the closest feature point // f2: distance to the second closest feature point // e: distance to the closest edge (cell boundary) // // We also compute "smooth" versions of all of the above quantites, essentially // replacing "hard" minimums with "smooth" minimums (described by IQ) float f1_smooth = 8.0; float f1 = 8.0; float f2_smooth = 8.0; float f2 = 8.0; float e_smooth = 8.0; float e = 8.0; // Variables stored from closest cell ivec3 mb; vec3 mr; int steps = quality; for (int x = -steps; x <= steps; x++) for (int y = -steps; y <= steps; y++) for (int z = -steps; z <= steps; z++) { ivec3 b = ivec3(x, y, z); vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; float d = length(r); f1_smooth = smin(d, f1_smooth, smoothness); // Store un-smoothed distances too if (d < f1) { f2 = f1; f1 = d; mb = ivec3(x, y, z); mr = r; } else if (d < f2) { f2 = d; } } // Second pass for edge distance // skip for styles don't need if (style != 0 && style != 5 && style != 7) for (int x = -steps; x <= steps; x++) for (int y = -steps; y <= steps; y++) for (int z = -steps; z <= steps; z++) { // Start search at the cell that contains the closest point to "x" (found in 1st pass) ivec3 b = mb + ivec3(x, y, z); vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; float d1 = dot(0.5 * (mr + r), (r - mr)); // IQ normalizes "r - mr" but that breaks things for the smooth version? float d2 = dot(0.5 * (mr + r), normalize(r - mr)); e_smooth = smin(d1, e_smooth, smoothness); e = min(e, d2); // Also compute a smooth version of F2 in this pass { ivec3 b = ivec3(x, y, z); if (b != mb) { vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; float d = length(r); f2_smooth = smin(d, f2_smooth, smoothness); } } } // Different visualization modes if (style == 0) { return f1_smooth; } if (style == 1) { return f2_smooth; } if (style == 2) { return f2_smooth - f1_smooth; // "Pebbles" also cool //return step(0.2, f2_smooth - f1_smooth); } if (style == 3) { // This one is really good for rock / stone effects float a = f1; float b = f2; float k = 3.0; float h = max(k - abs(a - b), 0.0) / k; float final = min(a, b) - h * h * k * (1.0 / 4.0); return final; } if (style == 4) { // Some random adjustments to make this style stand out more return exp(5.0 * e_smooth); } if (style == 5) { return pow(f1_smooth, 3.0); } if (style == 6) { const float eps = 0.0125; // Thicker lines as the user increases the smoothness slider float thickness = smoothness * 0.25 + eps; // Blurrier lines as the user increases the smoothness slider float blur = pow(smoothness, 3.0) * 0.25 + eps; return smoothstep( thickness - thickness * blur, thickness + thickness * blur, e ); } if (style == 7) { return hashwithoutsine13(vec3(p + mb) + seed); } } `,[p,f,g,m,v,y]);return{simplexFast:t,simplexPrecise:i,simplexFractal:r,simplexAshima:n,fbm:c,perlin:u,voronoi:x}}(),gT=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d,u,p,f,g,m,v,y){super("v3"),this.nodeType="Noise",this.scale=e,this.size=t,this.move=i,this.fA=r,this.fB=s,this.distortion=a,this.colorA=n,this.colorB=o,this.colorC=l,this.colorD=h,this.noiseType=d,this.voronoiStyle=p,this.highCut=f,this.lowCut=g,this.smoothness=m,this.seed=v,this.quality=y,this.isMask=u,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,i,r,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=["simplexFast","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseType.value],n=a=="voronoi"?` float v = ${a}(st + move, voronoiStyle, smoothness, seed, quality); // Apply clipping to colors v = remap(v, lowCut, highCut, 0.0, 1.0); v = smax(v, 0.0, smoothness * 0.25); v = smin(v, 1.0, smoothness * 0.25); // Note that the voronoi mode only uses colors "A" and "C" from the UI vec4 color = mix(colorA, colorC, v); `:` vec3 q = vec3(${a}(st), ${a}(st + vec3(1.0)), ${a}(st + vec3(1.0))); vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move), ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), ${a}(st * q)); float f = ${a}(st + r); vec4 color; color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0)); color = mix(color, colorC, clamp(length(q), 0.0, 1.0)); color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0)); `,o=new De(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha) { // Prevent scale of zero scale = max(abs(scale), 0.001); vec3 st = position / size; st /= scale; ${n} float lalpha = alpha * color.a * mask; calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return clamp(color, 0.0, 1.0).rgb; }`,[Xr.simplexFast,Xr.simplexFractal,Xr.simplexAshima,Xr.fbm,Xr.perlin,Xr.voronoi]),l=e.include(o),h=[];return h.push(this.scale.build(e,"f")),h.push(this.size.build(e,"v3")),h.push(this.move.build(e,"f")),h.push(this.fA.build(e,"v2")),h.push(this.fB.build(e,"v2")),h.push(this.distortion.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.colorC.build(e,"v4")),h.push(this.colorD.build(e,"v4")),h.push(this.voronoiStyle.build(e,"i")),h.push(this.highCut.build(e,"f")),h.push(this.lowCut.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.seed.build(e,"f")),h.push(this.quality.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(l+"("+h.join(",")+")",this.getType(e),t)}};gT.numOctaves=5;var vT=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d,u,p,f,g){super("v3"),this.nodeType="Outline",this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=i,this.contourWidth=r,this.contourThreshold=s,this.outlineThreshold=a,this.contourFrequency=n,this.outlineSmoothing=o,this.contourDirection=l,this.positionalLines=h,this.compensation=c,this.resolution=d,this.normalMap=u,this.depthMap=p,this.pixelRatio=f,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let i=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${i}_offset`),this.firstTime){let r=this.outlineWidth.build(e,"f"),s=this.resolution.build(e,"v2"),a=this.compensation.build(e,"b"),n=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(r,"uniform float"),e.addVertexParsVariable(s,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(n,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(` vID = randomColor.r; vec2 ${i}_offset = vec2(0.0); if (${a}) { vec4 ${i}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0)); // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the // normals face the camera directly. So we hackily fix this by offsetting the normal // by a tiny amount. vec3 ${i}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001; ${i}_offset = normalize(${i}_clipNormal.xy) / ${s} * (${r} / 2.0) * ${i}_clipPosition.w * 2.0 * ${n}; ${i}_clipPosition.xy += ${i}_offset; // TODO(MAX): To handle multiple outline layers, we only want to extrude // if this offset is the biggest of all the potential offsets gl_Position = ${i}_clipPosition; } `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=e.include(vT.Nodes.outline),s=[];return s.push(this.outlineColor.build(e,"c")),s.push(this.contourColor.build(e,"c")),s.push(this.outlineWidth.build(e,"f")),s.push(this.contourWidth.build(e,"f")),s.push(this.contourThreshold.build(e,"f")),s.push(this.outlineThreshold.build(e,"f")),s.push(this.contourFrequency.build(e,"f")),s.push(this.outlineSmoothing.build(e,"f")),s.push(this.contourDirection.build(e,"v3")),s.push(this.positionalLines.build(e,"b")),s.push(this.resolution.build(e,"v2")),s.push(this.normalMap.getTexture(e,"t")),s.push(this.depthMap.getTexture(e,"t")),s.push(this.pixelRatio.build(e,"f")),s.push(this.compensation.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),this.firstTime=!this.firstTime,e.format(r+"("+s.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},yT=vT;yT.Nodes=function(){let e=new De(` float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio) { vec2 halton = haltonSequence[frameIndex]; float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); float temporalAngle = temporalOffset * PI2; vec2 texelSize = (vec2(1.0) / resolution); vec2 offsetSize = texelSize * outlineWidth * pixelRatio; vec2 uvSamples[9]; vec4 normalSamples[9]; uvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize); uvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize); uvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize); uvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize); uvSamples[4] = uv; uvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize); uvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize); uvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize); uvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize); normalSamples[0] = texture2D(t, uvSamples[0]); normalSamples[1] = texture2D(t, uvSamples[1]); normalSamples[2] = texture2D(t, uvSamples[2]); normalSamples[3] = texture2D(t, uvSamples[3]); normalSamples[4] = texture2D(t, uvSamples[4]); normalSamples[5] = texture2D(t, uvSamples[5]); normalSamples[6] = texture2D(t, uvSamples[6]); normalSamples[7] = texture2D(t, uvSamples[7]); normalSamples[8] = texture2D(t, uvSamples[8]); float depthBias = 0.0001; // TODO(MAX): Can we somehow reduce the number of conditionals here with MATH?! if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb); vec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb); float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v)); return edgeNormal; } `);return{outline:new De(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) { vec3 result = outlineColor; float resultAlpha = 0.0; vec3 N = normalize(vWNormal); vec2 nuv = (gl_FragCoord.xy / resolution); float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio); resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample); //resultAlpha = 1.0; //result = vec3(sobelSample); float t = 1.0 - contourThreshold; if(positionalLines) { vec3 NDir = position * contourDirection; float NT = NDir.x + NDir.y + NDir.z; float f = fract(NT * contourFrequency * 0.01); float df = fwidth(NT * contourFrequency); float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f); if (g < 1.0 && resultAlpha == 0.0) { result = contourColor; resultAlpha = 1.0; } } else { vec3 NDir = N * contourDirection; float NT = NDir.x + NDir.y + NDir.z; float df = fwidth(NT * contourThreshold); float f = sin(NT * 1.0 * contourFrequency); float g = smoothstep(0.0, df * contourWidth, 1.0 - f); if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) { result = contourColor; resultAlpha = 1.0 - g; } } float lalpha = alpha * resultAlpha * mask; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return result; }`,[e])}}();var Qa=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d,u,p,f,g,m,v){super("v3"),this.nodeType="Pattern",this.style=e,this.projection=t,this.axis=i,this.blending=r,this.offset=s,this.colorA=a,this.colorB=n,this.frequency=o,this.size=l,this.variation=h,this.smoothness=c,this.zigzag=d,this.rotation=u,this.vertical=p,this.horizontal=f,this.sides=g,this.isMask=v,this.alpha=m,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let i;switch(this.style.value){case 0:i="circle";break;case 1:i="ring";break;case 2:i="polygon";break;case 3:i="xcross";break;case 4:i="diamond";break;case 5:i="checkerboard";break;case 6:i="line";break;case 7:i="wave";break;default:i="circle";break}let r=`g${this.uuid.toString().replace(/-/g,"")}`,s=new De(`float hashwithoutsine12(vec2 p) { vec3 p3 = fract(vec3(p.xyx) * .1031); p3 += dot(p3, p3.yzx + 33.33); return fract((p3.x + p3.y) * p3.z); }`),a=new De(`vec2 rotate_uv(in vec2 uv, float a, bool repeat) { const float mid = 0.5; float radians = a * (PI / 180.0); vec2 rotated = vec2( cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid, cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid ); return repeat ? fract(rotated): rotated; }`),n="";if(this.projection.value===4){let c=this.style.value===2?`${i}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,d=this.style.value===2?`${i}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,u=this.style.value===2?`${i}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`;n=` vec3 p = position; float factor = 0.0125; vec2 uv0 = fract(p.xy * factor); vec2 uv1 = fract(p.zy * factor); vec2 uv2 = fract(p.xz * factor); uv0 = rotate_uv(uv0 + offset, rotation, true); uv1 = rotate_uv(uv1 + offset, rotation, true); uv2 = rotate_uv(uv2 + offset, rotation, true); float d0 = ${c}; float d1 = ${d}; float d2 = ${u}; // Range from 3 to 128 seems to be good float exponent = (1.0 - blending) * 125.0 + 3.0; vec3 n = vObjectNormal; vec3 weights = abs(normalize(n)); weights = pow(weights, vec3(exponent)); weights /= dot(weights, vec3(1.0)); d0 *= weights.z; d1 *= weights.x; d2 *= weights.y; float draw = d0 + d1 + d2; vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y; `}else{let c=this.style.value===2?`${i}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,d="";this.axis.value===0?d=`float radius = length(p); float theta = atan(p.y, p.z); float phi = acos(p.x / radius);`:this.axis.value===1?d=`float radius = length(p); float theta = atan(p.x, p.z); float phi = acos(p.y / radius);`:(this.axis.value,d=`float radius = length(p); float theta = atan(p.y, p.x); float phi = acos(p.z / radius);`);let u="";switch(this.projection.value){case 0:u="custom_uv = vUv.st;";break;case 1:break;case 2:u=` vec3 p = position; ${d} custom_uv = vec2(theta, phi); custom_uv /= PI; `;break}n=` vec2 custom_uv; ${u} custom_uv += offset; custom_uv = fract(custom_uv); custom_uv = rotate_uv(custom_uv, rotation, true); float draw = ${c}; `}let o=new De(`vec3 ${r}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) { const float TWO_PI = PI * 2.0; float smoothness_remapped = pow(smoothness, 5.0); ${n} // Construct final output color vec4 color = mix(colorA, colorB, draw); color.a = clamp(color.a, 0.0, 1.0); // Apply cuts color.a *= step(vertical.x, custom_uv.y) * step(custom_uv.y, vertical.y); color.a *= step(horizontal.x, abs(custom_uv.x)) * step(abs(custom_uv.x), horizontal.y); // Accumulate alpha float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask; calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return clamp(color, 0.0, 1.0).rgb; }`,[a,s,Qa.DrawFunctions.circle,Qa.DrawFunctions.ring,Qa.DrawFunctions.polygon,Qa.DrawFunctions.cross,Qa.DrawFunctions.diamond,Qa.DrawFunctions.checkerboard,Qa.DrawFunctions.line,Qa.DrawFunctions.wave]),l=e.include(o),h=[];return h.push("normal"),h.push(this.blending.build(e,"f")),h.push(this.style.build(e,"i")),h.push(this.offset.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.frequency.build(e,"v2")),h.push(this.size.build(e,"f")),h.push(this.variation.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.zigzag.build(e,"f")),h.push(this.rotation.build(e,"f")),h.push(this.vertical.build(e,"v2")),h.push(this.horizontal.build(e,"v2")),h.push(this.sides.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(l+"("+h.join(",")+")",this.getType(e),t)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),t)}},xT=Qa;xT.DrawFunctions=function(){let e=new De(`float hashwithoutsine12(vec2 p) { vec3 p3 = fract(vec3(p.xyx) * 0.1031); p3 += dot(p3, p3.yzx + 33.33); return fract((p3.x + p3.y) * p3.z); }`),t=new De(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) { // Create tiles in UV-space uv *= frequency; // Integer coords vec2 i = floor(uv); // Offset every other row based on zigzag param, then compute fractional coords float row_offset = mod(i.y, 2.0); uv.x += row_offset * zigzag; vec2 f = fract(uv); // Rotate the tile itself: // const float mid = 0.5; // f = vec2( // cos(rotation) * (f.x - mid) + sin(rotation) * (f.y - mid) + mid, // cos(rotation) * (f.y - mid) - sin(rotation) * (f.x - mid) + mid // ); // f = fract(f); f = f * 2.0 - 1.0; // Recompute integer coords after shifting - then, random value per tile i = floor(uv); float rand = (hashwithoutsine12(i) * 5.0 + 1.0); float jitter = mix(1.0, rand, variation); f *= jitter; return f; }`,[e]),i=new De(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); return smoothstep( -smoothness, smoothness, length(f) - size ); }`,[t]),r=new De(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); float d = length(f); const float inner_width = 0.5; float outer = smoothstep(-smoothness, smoothness, d - size); float inner = smoothstep(-smoothness, smoothness, d - size * inner_width); return outer + (1.0 - inner); }`,[t]),s=new De(`float sdf_ngon(in vec2 p, in float r, in int n) { float an = (PI * 2.0) / float(n); float he = r * tan(0.5 * an); // Rotate to first sector p = -p.yx; float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an); vec2 cs = vec2(cos(bn), sin(bn)); p = mat2(cs.x, -cs.y, cs.y, cs.x)*p; // Side of polygon return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r); } float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) { vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides)); }`,[t]),a=new De(`float sdf_cross(in vec2 p, in vec2 b, float r ) { p = abs(p); p = (p.y > p.x) ? p.yx : p.xy; vec2 q = p - b; float k = max(q.y, q.x); vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k); return sign(k) * length(max(w, 0.0)) + r; } // Avoid namespace conflicts float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness)); }`,[t]),n=new De(`float ndot(vec2 a, vec2 b) { return a.x*b.x - a.y*b.y; } float sdf_diamond(in vec2 p, in vec2 b) { p = abs(p); float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0); float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h)); return d * sign(p.x * b.y + p.y * b.x - b.x * b.y); } float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size))); }`,[t]),o=new De(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { uv *= frequency; vec2 i = floor(uv); float offset = mod(i.y, 2.0); uv.x += offset + zigzag * offset; float x = floor(uv.x); return mod(x, 2.0); }`),l=new De(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation); // Different approach for variation param here float row = floor(uv * frequency).y; float rand = hashwithoutsine12(vec2(row)); float s = mix(size, size * rand, variation); return smoothstep( s - smoothness, s + smoothness, abs(f.y) ); }`,[t]),h=new De(`// Uses bisection float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) { // Convert all data to a primitive cosine wave p = c * (p - vec2(d, a)); const float TWO_PI = PI * 2.0; // Reduce to principal half cycle p.x = mod(p.x, TWO_PI); if (p.x > PI) { p.x = TWO_PI - p.x; } // Find zero of derivative (minimize distance) float xa = 0.0; float xb = TWO_PI; // 24 bit precision for (int i = 0; i < 24; i++) { float x = 0.5 * (xa + xb); float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x)); if (y < 0.0) xa = x; else xb = x; } float x = 0.5 * (xa + xb); // Compute distance vec2 q = vec2(x, b * c * cos(x)); return length(p - q) / c; } float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { float repeat = frequency.x; uv *= repeat; vec2 i = floor(uv); float row_offset = mod(i.y, 2.0); uv.x += row_offset * zigzag; vec2 f = vec2(uv.x, fract(uv.y)); // Generalized cosine: y(x) = a + b * cos(cx + d) const float amplitude = 0.125; float wave_frequency = frequency.y * 0.1; float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0); // Different approach for variation param here float rand = hashwithoutsine12(vec2(i.y)); float s = mix(size, size * rand, variation); return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5); }`);return{tileAndCenter:t,circle:i,ring:r,polygon:s,cross:a,diamond:n,checkerboard:o,line:l,wave:h}}();var bT=class extends Wt{constructor(e,t,i,r,s,a,n,o){super("v3"),this.nodeType="Rainbow",this.filmThickness=e,this.movement=t,this.wavelengths=i,this.noiseStrength=r,this.noiseScale=s,this.offset=a,this.isMask=o,this.alpha=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(bT.Nodes.rainbow),r=[];return r.push(this.filmThickness.build(e,"f")),r.push(this.movement.build(e,"f")),r.push(this.wavelengths.build(e,"v3")),r.push(this.noiseStrength.build(e,"f")),r.push(this.noiseScale.build(e,"f")),r.push(this.offset.build(e,"v3")),r.push(this.isMask.build(e,"b")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},wT=bT;wT.Nodes=function(){let e=new De(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) { float f = 0.0; if (noiseStrength != 0.0) { vec3 st = position / noiseScale; float noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0)); f = noise * noiseStrength; } vec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0; float angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal)); mediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement); return .5 + .5 * color; }`,[Xr.simplexFast]);return{rainbow:new De(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) { mediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0); float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0); float lalpha = alpha * rainbowContribution * mask; calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); return res; }`,[e])}}();var _T=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h){super("v3"),this.nodeType="Toon",this.positioning=e,this.colors=t,this.steps=i,this.source=r,this.isWorldSpace=s,this.noiseStrength=a,this.noiseScale=n,this.shadowColor=o,this.offset=l,this.alpha=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let i=e.include(_T.Nodes.toon),r=[];return r.push(this.positioning.build(e,"i")),r.push(this.colors.build(e,"v4[]")),r.push(this.steps.build(e,"f[]")),r.push(this.source.build(e,"v3")),r.push(this.isWorldSpace.build(e,"b")),r.push(this.noiseStrength.build(e,"f")),r.push(this.noiseScale.build(e,"f")),r.push(this.shadowColor.build(e,"v4")),r.push(this.offset.build(e,"v3")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ST=_T;ST.Nodes=function(){let e=new De(`float rand(float n) { return fract(sin(n) * 43758.5453123); }`),t=new De(`float hash1(float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }`),i=new De(`float valueNoise(vec3 x) { const vec3 step = vec3(110, 241, 171); vec3 i = floor(x); vec3 f = fract(x); // For performance, compute the base input to a 1D hash from the integer part of the argument and the // incremental change to the 1D based on the 3D -> 1D wrapping float n = dot(i, step); vec3 u = f * f * (3.0 - 2.0 * f); return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x), mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y), mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x), mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z); }`,[t]),r=new De(`vec3 hash3(vec3 x) { x = vec3(dot(x,vec3(127.1, 311.7, 74.7)), dot(x,vec3(269.5, 183.3, 246.1)), dot(x,vec3(113.5, 271.9, 124.6))); return fract(sin(x)*43758.5453123); }`),s=new De(`vec3 voronoiNoise(in vec3 x) { vec3 p = floor(x); vec3 f = fract(x); float id = 0.0; vec2 res = vec2(100.0); for(int k=-1; k<=1; k++) for(int j=-1; j<=1; j++) for(int i=-1; i<=1; i++) { vec3 b = vec3(float(i), float(j), float(k)); // Comment out the "+ hash(p + b);" part below to get "square" cells vec3 r = vec3(b) - f + hash3(p + b); float d = dot(r, r); if (d < res.x) { id = dot(p + b, vec3(1.0, 57.0, 113.0)); res = vec2(d, res.x); } else if (d < res.y) { res.y = d; } } return vec3(sqrt(res), abs(id)); } `,[r]);return{toon:new De(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) { float t = 0.0; float shadow = 1.0; if (positioning == 0) { // Can't do this mode if lighting is "none" #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD)) // Algorithm from Chapter 10 of Graphics Shaders const vec3 weights = vec3(0.2125, 0.7154, 0.0721); vec3 lpos; vec3 l; float dproduct; #if (NUM_POINT_LIGHTS > 0) #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0) PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for (int i = 0; i < NUM_POINT_LIGHTS; i++) { // Light positions are in view-space for some reason? lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz; l = normalize(lpos - worldPosition); dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; // TODO: we want to use "intensity" but it isn't available in the shader code //dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights); t = max(t, dproduct); // Accumulate shadow contribution #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS) pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX]; shadow *= getPointShadow( pointShadowMap[UNROLLED_LOOP_INDEX], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[UNROLLED_LOOP_INDEX], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar); #endif } #pragma unroll_loop_end #endif #if NUM_DIR_LIGHTS > 0 #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0) DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for (int i = 0; i < NUM_DIR_LIGHTS; i++) { // Use the direction vector for directional lights instead l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz; dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; t = max(t, dproduct); // Accumulate shadow contribution #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS) directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX]; shadow *= getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[UNROLLED_LOOP_INDEX], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]); #endif } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHTS > 0 #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0) SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for (int i = 0; i < NUM_SPOT_LIGHTS; i++) { lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz; l = normalize(lpos - worldPosition); dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; t = max(t, dproduct); // Accumulate shadow contribution #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS) spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX]; shadow *= getShadow( UNROLLED_LOOP_INDEX, spotShadowMap[UNROLLED_LOOP_INDEX], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[UNROLLED_LOOP_INDEX]); #endif } #pragma unroll_loop_end #endif t = clamp(t, 0.0, 1.0); #endif } else if (positioning == 1) { vec3 origin = mix(position, worldPosition, float(isWorldSpace)); vec3 direction = normalize(source - origin); t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5; } else { vec3 origin = worldPosition; vec3 source = cameraPosition - offset; vec3 direction = normalize(source - origin); t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5; } if (noiseStrength > 0.0) { // Distort with noise vec3 st = position / noiseScale; // Voronoi "smooth" noise float noise = 1.0 - voronoiNoise(st).x; // Voronoi cellular noise //float noise = 1.0 - rand(voronoiNoise(st).z); // Position warp noise // vec3 offset = vec3( // simplexFast(st), // simplexFast(st + vec3(111.1, 143.89, 217.19)), // simplexFast(st + vec3(171.1, 247.89, 117.23)) // ); // st += offset; // float noise = valueNoise(st); t += noise * noiseStrength; } t = clamp(t, 0.0, 1.0); // Compute ramp color float p; vec4 color = colors[0]; for (int i = 1; i < COLORS_MAX; i++) { p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0); color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); } // Incorporate custom shadow color if (positioning == 0) { vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a); color.rgb = mix(blendedShadow, color.rgb, shadow); } // Accumulate alpha as usual float lalpha = alpha * color.a * mask; calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0); accumAlpha += (1.0 - accumAlpha) * lalpha; return color.xyz; }`,[Xr.simplexFast,e,i,s])}}();var $X=function(){return{textureBicubic:new De(`float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } // g0 and g1 are the two amplitude functions float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } // h0 and h1 are the two offset functions float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); }`)}}();function eY(e,t){return e>=t?new j(t/e,1):new j(1,e/t)}var AT=class extends Wt{constructor(e,t,i,r,s,a,n,o){super("v3"),this.nodeType="Transmission",this.thickness=e,this.ior=t,this.roughness=i,this.transmissionSamplerSize=r,this.transmissionSamplerMap=s,this.transmissionDepthMap=a,this.aspectRatio=n,this.alpha=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,st.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let i=e.include(AT.Nodes.transmission),r=[];return r.push(this.thickness.build(e,"f")),r.push(this.ior.build(e,"f")),r.push(this.roughness.build(e,"f")),r.push(this.transmissionSamplerSize.build(e,"v2")),r.push(this.transmissionSamplerMap.getTexture(e,"t")),r.push(this.transmissionDepthMap.getTexture(e,"t")),r.push(this.aspectRatio.build(e,"v2")),r.push("normal"),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},MT=AT;MT.Nodes=function(){let e=new De(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) { // Slightly modified version of this: // https://www.shadertoy.com/view/ltScRG // Special case for blur == 0.0 if (lod == 0.0) { #ifdef TEXTURE_LOD_EXT return texture2DLodEXT( sp, U, 0.0).rgb; #else return textureLod( sp, U, 0.0).rgb; #endif } vec2 texelSize = vec2(1.0) / resolution; vec2 halton = haltonSequence[frameIndex]; float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); float temporalAngle = temporalOffset * PI2; vec3 res = vec3(0.0); vec2 uv = vec2(0.0); vec2 offset = vec2(0.0); vec2 vogelSample = vec2(0.0); for (int i = 0; i < NUM_SAMPLES; i++) { vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize; offset = vogelSample * scale * (lod * 10.0); // TODO: used to be hardcoded to 20 uv = U + offset; float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod)); if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) { uv = unrefractedU; lod = lod > 4.0 ? lod : lod / 2.0; } res += textureLod(sp, uv, lod).rgb; } return res / float(NUM_SAMPLES); }`),t=new De(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) { // Direction of refracted light. vec3 refractionVector = refract( -v, n, 1.0 / ior ); // Compute rotation-independant scaling of the model matrix. vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); // The thickness is specified in local space return normalize( refractionVector ) * thickness * modelScale; }`),i=new De(`float applyIorToRoughness( float roughness, float ior ) { // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and // an IOR of 1.5 results in the default amount of microfacet refraction. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); }`),r=new De(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) { // Threejs exports do not pass a depth map to this shader, so we have to fallback to the "Threejs method of blurring" - see // also the code in convertTransmission.ts, which runs during export #ifdef IS_THREEJS_EXPORT float lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior); return textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb; #else float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); float lod = applyIorToRoughness(roughness, ior); return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio); #endif }`,[$X.textureBicubic,i,e]),s=new De(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; // Project refracted vector on the framebuffer, while mapping to normalized device coordinates. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 ); vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w; unrefractedCoords += 1.0; unrefractedCoords /= 2.0; // Sample framebuffer to get pixel the refracted ray hits. return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio ); }`,[r,t]);return{transmission:new De(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) { vec3 v = vec3(0.); if (isOrthographic) { v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { v = normalize(vWPosition - cameraPosition); } vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio ); float lalpha = alpha * mask; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * alpha; return transmission; }`,[s])}}();var ay=(e=>(e.NOISE="noise",e.MAP="map",e))(ay||{}),ET=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c){super("v3"),this.displacementTypeIndex=new Yt(0),this.nodeType="VertexDisplacement",this.intensity=e,this.movementOrTexture=t,Object.values(ay)[this.displacementTypeIndex.value]==="map"&&(this.mat=new oT(this.movementOrTexture.value.matrix)),this.cropOrOffset=i,this.scale=h,this.noiseFunctionIndex=c,this.voronoiStyle=r,this.smoothness=s,this.seed=a,this.highCut=n,this.lowCut=o,this.quality=l}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let i,r=[];switch(r.push("displaced_position"),r.push("displaced_normal"),Object.values(ay)[this.displacementTypeIndex.value]){case"map":{i=e.include(ET.Nodes.map),r.push(this.movementOrTexture.getTexture(e,"t")),r.push("uv"),r.push(this.cropOrOffset.build(e,"f")),this.mat&&r.push(this.mat.build(e,"mat3"));break}case"noise":{let s=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],a=new De(`vec3 orthogonal(vec3 v) { return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); }`),n=s=="voronoi"?` float v = ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality); v = remap(v, lowCut, highCut, 0.0, 1.0); v = smax(v, 0.0, smoothness * 0.25); v = smin(v, 1.0, smoothness * 0.25); return p + n * v * intensity; `:` return p + n * ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity; `,o=new De(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) { ${n} }`,[Xr.simplexPrecise,Xr.simplexFractal,Xr.simplexAshima,Xr.fbm,Xr.perlin,Xr.voronoi]),l=new De(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) { vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality); vec3 tangent1 = orthogonal(normal); vec3 tangent2 = normalize(cross(normal, tangent1)); // TODO(Max): The distance to the neighbors was originally scaled by 0.1. // This caused some small oval/circular visual artifacts in the lighting. // For now, simply using neighbors further away betters the problem, // but we should figure out the underlying cause when we have some time. // Maybe its related to how we calculate the tangent and bitangent? vec3 nearby1 = position + tangent1; vec3 nearby2 = position + tangent2; vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality); vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality); displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); return displaced_position; }`,[o,a]);i=e.include(l),r.push(this.scale.build(e,"f")),r.push(this.cropOrOffset.build(e,"v3")),r.push(this.movementOrTexture.build(e,"f")),r.push(this.voronoiStyle.build(e,"i")),r.push(this.smoothness.build(e,"f")),r.push(this.seed.build(e,"f")),r.push(this.highCut.build(e,"f")),r.push(this.lowCut.build(e,"f")),r.push(this.quality.build(e,"i"));break}}return r.push(this.intensity.build(e,"f")),r.push("displaced_normal"),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},CT=ET;CT.Nodes=function(){let e=new De(`vec3 orthogonal(vec3 v) { return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); }`),t=new De(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) { vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset; vec4 tmp = texture2D(tex, uvs); vec3 col = tmp.rgb; if (crop > 0.5) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { return 0.0; } } return col.r; }`);return{map:new De(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) { vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity; vec3 tangent1 = normalize(orthogonal(normal)); vec3 tangent2 = normalize(cross(normal, tangent1)); vec3 nearby1 = position + tangent1 * 0.1; vec3 nearby2 = position + tangent2 * 0.1; vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); return displaced_position; }`,[e,t])}}();var st={normalRenderTarget:new an,normalRenderTargetDepth:new an,transmissionRenderTarget:new an,aspectRatio:new cr,transmissionSize:new cr(2048,2048),transmissionRenderTargetDepth:new an,aoRenderTarget:new an,aoEnabled:new Br,pixelRatioNode:new Fe(1),resolution:new cr,penumbraSize:new Bo(5,.5),frameIndex:new Yt(0),transmissionLod:new Yt(2)};for(let e of Object.values(st))e.isRenderGlobal=!0;var TT={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.53/build/ui.wasm"},G1=class extends Vi{constructor(){super("basic"),this.nodeType="Basic",this.color=new gi(as),this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include "].join(` `));let r=["#include ","#include ",` #include #include #if !defined( USE_LAYER_DISPLACE ) #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #if defined( USE_LAYER_DISPLACE ) vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #if !defined( USE_LAYER_DISPLACE ) #include #endif /* !USE_LAYER_DISPLACE */ `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include ","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include "),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(` `)}else{this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let i=this.color.flow(e,"c",{slot:"color"}),r=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=r!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include ","#include ","varying vec3 vViewPosition;","#include "].join(` `));let n=["#include ",i.code];r&&n.push(r.code,"#ifdef ALPHATEST"," if ( "+r.result+" <= ALPHATEST ) discard;","#endif"),a?n.push(a.code,`vec3 outgoingLight = ${i.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`):n.push(`vec3 finalColor = ${i.result};`);let o="1.0";this.mask&&(this.mask.analyze(e),o=`luminance(${this.mask.flow(e,"v3").result})`),r?n.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${r.result} * ${o} );`):n.push("gl_FragColor = vec4("+i.result+", 1.0 );"),s&&n.push(`gl_FragColor.a *= ${s.result};`),n.push("#include ","#include "),t=n.join(` `)}return t}},tY=class extends Vi{constructor(){super("lambert"),this.nodeType="Lambert",this.color=new gi(as),this.emissive=new gi(0),this.emissiveIntensity=new Fe(1),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa,this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0),this.occlusion=new Br(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog,Pe.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let r=["#include ","#include ",` #include #include #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = objectNormal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #ifndef USE_LAYER_DISPLACE #include #endif `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include ","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include ",` vec3 diffuse = vec3( 1.0 ); GeometricContext geometry; geometry.position = mvPosition.xyz; geometry.normal = normalize( transformedNormal ); geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); `),r.push(` GeometricContext backGeometry; backGeometry.position = geometry.position; backGeometry.normal = -geometry.normal; backGeometry.viewDir = geometry.viewDir; vLightFront = vec3( 0.0 ); vIndirectFront = vec3( 0.0 ); #ifdef DOUBLE_SIDED vLightBack = vec3( 0.0 ); vIndirectBack = vec3( 0.0 ); #endif IncidentLight directLight; float dotNL; vec3 directLightColor_Diffuse; vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal ); #ifdef DOUBLE_SIDED vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal ); #endif #if NUM_POINT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { getPointLightInfo( pointLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { getSpotLightInfo( spotLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_DIR_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { getDirectionalLightInfo( directionalLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_HEMI_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); #ifdef DOUBLE_SIDED vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal ); #endif } #pragma unroll_loop_end #endif `," #include "," #include "),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(` `)}else{e.mergeUniform({penumbraSize:st.penumbraSize}),e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({aoMap:st.aoRenderTarget}),e.mergeUniform({aoEnabled:st.aoEnabled}),this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),r=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),a=this.occlusion.flow(e,"b",{slot:"occlusion"}),n=this.shadingAlpha.flow(e,"f"),o=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,c=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include ","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let d=["#include ",` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx, viewdy)); bool isFrontFacing = (dot(normal, faceNormal) >= 0.0); `,"#include "];d.push(i.code,"vec3 diffuseColor = "+i.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),h&&d.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),d.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include ","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),r&&d.push(r.code,"reflectedLight.directDiffuse += "+r.result+" * "+s.result+";"),d.push("vec3 ao = aoEnabled && "+a.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),d.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * ${u} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result} * ${u}, ${o.result} ); outgoingLight *= ao; } `),l&&d.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c&&d.push(`gl_FragColor.a *= ${c.result};`),d.push("#include ","#include ","#include "),t=d.join(` `)}return t}},Vh=function(){let e=new De(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) { // Gradient of UVs w.r.t. X coordinate (in screen-space) vec2 dSTdx = dFdx(bumpMapUv); // Gradient of UVs w.r.t. Y coordinate (in screen-space) vec2 dSTdy = dFdy(bumpMapUv); // Forward differencing float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb); float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll; float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll; return vec2( dBx, dBy ); }`),t=new De(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = dFdx( surf_pos.xyz ); vec3 vSigmaY = dFdy( surf_pos.xyz ); vec3 vN = surf_norm; // normalized vN = normalize(vN); vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); R1 = normalize(R1); R2 = normalize(R2); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * vN - vGrad ); }`);return{dHdxy:e,perturbNormalArb:t}}(),iY=class extends Vi{constructor(){super("phong"),this.nodeType="Phong",this.color=new gi(as),this.specular=new gi(1118481),this.shininess=new Fe(30),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa,this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0),this.occlusion=new Br(!0)}get category(){return"phong"}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog,Pe.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let r=["#include ","#include ",` #include #include #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = objectNormal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #ifndef USE_LAYER_DISPLACE #include #endif `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include ","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(` `)}else{e.mergeUniform({penumbraSize:st.penumbraSize}),e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({aoMap:st.aoRenderTarget}),e.mergeUniform({aoEnabled:st.aoEnabled}),this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),s=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),n=this.shadingAlpha.flow(e,"f"),o=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,c=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;","uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let d=["#include ",` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(Vh.dHdxy),e.include(Vh.perturbNormalArb);let p=this.bumpMap.texture.flow(e,"t"),f=this.bumpMap.flow(e,"v3"),g=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",m="";this.bumpMap.projection.value===4?m=` vec3 bumpNormal = vec3(0.0); { vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; vec2 grad0 = dHdxy(${p.result}, uv0, ${g}); vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); vec2 grad1 = dHdxy(${p.result}, uv1, ${g}); vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); vec2 grad2 = dHdxy(${p.result}, uv2, ${g}); vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; bumpNormal = normalize(bumpNormal); } normal = bumpNormal; `:m=` vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; vec2 grad = dHdxy(${p.result}, bumpMapCachedUv, ${g}); normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); `,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates ${f.result}; ${m} `)}d.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",s.code," vec3 specular = "+s.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),h&&d.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),d.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),d.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * ${u} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result} * ${u}, ${o.result} ); outgoingLight *= ao; } `),l&&d.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result});`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c&&d.push(`gl_FragColor.a *= ${c.result};`),d.push("#include ","#include ","#include "),t=d.join(` `)}return t}},rY=class extends Vi{constructor(){super("standard"),this.nodeType="Standard",this.color=new gi(as),this.roughness=new Fe(.3),this.metalness=new Fe(0),this.reflectivity=new Fe(.5),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa,this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0),this.occlusion=new Br(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog,Pe.lights])),Pe.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let r=["#include ","#include ",` #include #include #if !defined( USE_LAYER_DISPLACE ) #include #endif vec3 displaced_position = position; vec3 displaced_normal = objectNormal; #if defined( USE_LAYER_DISPLACE ) vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #if !defined( USE_LAYER_DISPLACE ) #include #endif /* !USE_LAYER_DISPLACE */ `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include ","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include ","#include "),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(` `)}else{e.mergeUniform({penumbraSize:st.penumbraSize}),e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({aoMap:st.aoRenderTarget}),e.mergeUniform({aoEnabled:st.aoEnabled});let i={gamma:!0};this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color",context:i}),this.roughness.analyze(e),this.metalness.analyze(e);let r=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let s=this.color.flow(e,"c",{slot:"color",context:i}),a=this.roughness.flow(e,"f"),n=this.metalness.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),h=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,u=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let p=["#include "," #include ",` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(Vh.dHdxy),e.include(Vh.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),m=this.bumpMap.flow(e,"v3"),v=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",y="";this.bumpMap.projection.value===4?y=` vec3 bumpNormal = vec3(0.0); { vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; vec2 grad0 = dHdxy(${g.result}, uv0, ${v}); vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); vec2 grad1 = dHdxy(${g.result}, uv1, ${v}); vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); vec2 grad2 = dHdxy(${g.result}, uv2, ${v}); vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; bumpNormal = normalize(bumpNormal); } normal = bumpNormal; `:y=` vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; vec2 grad = dHdxy(${g.result}, bumpMapCachedUv, ${v}); normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); `,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates ${m.result}; ${y} `)}if(p.push(s.code," vec3 diffuseColor = "+s.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",n.code," float metalnessFactor = "+n.result+";"),this.roughnessMap){let g=this.roughnessMap.texture.flow(e,"t"),m=this.roughnessMap.flow(e,"v3"),v="";this.roughnessMap.projection.value===4?v=` float roughnessChange = 1.0; { vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0; vec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1; vec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2; vec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; float r0 = luminance(texture(${g.result}, uv0).rgb) * roughnessScale; float r1 = luminance(texture(${g.result}, uv1).rgb) * roughnessScale; float r2 = luminance(texture(${g.result}, uv2).rgb) * roughnessScale; roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y); } float roughnessFactor = roughnessChange * ${a.result}; `:v=` vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs; vec4 vals = texture(${g.result}, roughnessMapCachedUv); float roughnessFactor = luminance(vals.rgb) * ${a.result}; `,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates ${m.result}; const float roughnessScale = 1.0; ${v} `)}else p.push(a.code," float roughnessFactor = "+a.result+";");c&&p.push(c.code,"#ifdef ALPHATEST"," if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),p.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),p.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),u?p.push(u.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+u.result+" ) ), diffuseColor, metalnessFactor );"):p.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),p.push("#include "),p.push("#include "),p.push("vec3 ao = aoEnabled && "+r.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),p.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * ${f} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result} * ${f}, ${l.result} ); outgoingLight *= ao; } `),h&&p.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),c?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&p.push(`gl_FragColor.a *= ${d.result};`),p.push("#include ","#include ","#include "),t=p.join(` `)}return t}},sY=class extends Vi{constructor(){super("toon"),this.nodeType="Toon",this.color=new gi(as),this.specular=new gi(1118481),this.shininess=new Fe(30),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa,this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog,Pe.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include ","#include ","#include "].join(` `));let r=["#include ","#include ",` #include #include #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = objectNormal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `,"#include ",` #ifndef USE_LAYER_DISPLACE #include #endif `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include ","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include "," #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(` `)}else{e.mergeUniform({penumbraSize:st.penumbraSize}),e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({aoMap:st.aoRenderTarget}),e.mergeUniform({aoEnabled:st.aoEnabled}),this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),r=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),n=this.shadingBlend.flow(e,"i"),o=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,l=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=l!==void 0,e.addParsCode(["uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include ","#include ","#include ","#include ","#include ","#include ",` varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon #define Material_LightProbeLOD( material ) (0) `,"#include ","#include ","#include "].join(` `));let c=["#include ",` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `," ToonMaterial material;"];if(this.bumpMap){e.include(Vh.dHdxy),e.include(Vh.perturbNormalArb);let u=this.bumpMap.texture.flow(e,"t"),p=this.bumpMap.flow(e,"v3"),f=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",g="";this.bumpMap.projection.value===4?g=` vec3 bumpNormal = vec3(0.0); { vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; vec2 grad0 = dHdxy(${u.result}, uv0, ${f}); vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); vec2 grad1 = dHdxy(${u.result}, uv1, ${f}); vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); vec2 grad2 = dHdxy(${u.result}, uv2, ${f}); vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; bumpNormal = normalize(bumpNormal); } normal = bumpNormal; `:g=` vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; vec2 grad = dHdxy(${u.result}, bumpMapCachedUv, ${f}); normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); `,c.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates ${p.result}; ${g} `)}c.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",r.code," vec3 specular = "+r.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),l&&c.push(l.code,"#ifdef ALPHATEST","if ( "+l.result+" <= ALPHATEST ) discard;","#endif"),c.push("material.diffuseColor = diffuseColor;"),c.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),c.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let d="1.0";this.mask&&(this.mask.analyze(e),d=`luminance(${this.mask.flow(e,"v3").result})`),c.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * ${d} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${d}, ${n.result} ); } `),o&&c.push(o.code,`outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),l?c.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):c.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&c.push(`gl_FragColor.a *= ${h.result};`),c.push("#include ","#include ","#include "),t=c.join(` `)}return t}},aY=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let s of Object.values(r))for(let a of Object.values(s))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(s=>{i.onloadend=a=>{var n;r=(n=a.target)==null?void 0:n.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=oY(e),this.img.onload=t,await new Promise(r=>{this.img.onload=()=>{t(),r(null)}})}getTexture(e,t=1008,i=1006){var s,a;let r=(a=(s=this._cache[e])==null?void 0:s[t])==null?void 0:a[i];if(r)return r;{let n;return this.isBuffer?n=this.img.texture:this.isVideo?n=new jF(this.img,void 0,e,e):n=new ci(this.img,void 0,e,e,i,t),this.loaded&&(n.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][i]=n,n}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let r of Object.values(i))r&&(r.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[s,a]of Object.entries(r))a==null||a.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][s]=void 0)}dispose(){super.dispose(),this.disposeTextures()}},Yn=class extends PT{};function cY(e,t){var i=fY(t);return i.formatToParts?uY(i,e):pY(i,e)}var dY={year:0,month:1,day:2,hour:3,minute:4,second:5};function uY(e,t){try{for(var i=e.formatToParts(t),r=[],s=0;s=0&&(r[a]=parseInt(i[s].value,10))}return r}catch(n){if(n instanceof RangeError)return[NaN];throw n}}function pY(e,t){var i=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(i);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var kg={};function fY(e){if(!kg[e]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),i=t==="06/25/2014, 00:00:00"||t==="‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";kg[e]=i?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return kg[e]}function DT(e,t,i,r,s,a,n){var o=new Date(0);return o.setUTCFullYear(e,t,i),o.setUTCHours(r,s,a,n),o}var MS=36e5,mY=6e4,Vg={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function IT(e,t,i){var r,s;if(!e||(r=Vg.timezoneZ.exec(e),r))return 0;var a;if(r=Vg.timezoneHH.exec(e),r)return a=parseInt(r[1],10),ES(a)?-(a*MS):NaN;if(r=Vg.timezoneHHMM.exec(e),r){a=parseInt(r[1],10);var n=parseInt(r[2],10);return ES(a,n)?(s=Math.abs(a)*MS+n*mY,a>0?-s:s):NaN}if(yY(e)){t=new Date(t||Date.now());var o=i?t:gY(t),l=ny(o,e),h=i?l:vY(t,l,e);return-h}return NaN}function gY(e){return DT(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function ny(e,t){var i=cY(e,t),r=DT(i[0],i[1]-1,i[2],i[3]%24,i[4],i[5],0).getTime(),s=e.getTime(),a=s%1e3;return s-=a>=0?a:1e3+a,r-s}function vY(e,t,i){var r=e.getTime(),s=r-t,a=ny(new Date(s),i);if(t===a)return t;s-=a-t;var n=ny(new Date(s),i);return a===n?a:Math.max(a,n)}function ES(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59)}var CS={};function yY(e){if(CS[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),CS[e]=!0,!0}catch{return!1}}var xY=xo(DO(),1),TS=xo(IO(),1),bY=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,wY=bY,jg=36e5,PS=6e4,_Y=2,Fr={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:wY};function SY(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return new Date(NaN);var i=t||{},r=i.additionalDigits==null?_Y:(0,xY.default)(i.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var s=AY(e),a=MY(s.date,r),n=a.year,o=a.restDateString,l=EY(o,n);if(isNaN(l))return new Date(NaN);if(l){var h=l.getTime(),c=0,d;if(s.time&&(c=CY(s.time),isNaN(c)))return new Date(NaN);if(s.timeZone||i.timeZone){if(d=IT(s.timeZone||i.timeZone,new Date(h+c)),isNaN(d))return new Date(NaN)}else d=(0,TS.default)(new Date(h+c)),d=(0,TS.default)(new Date(h+c+d));return new Date(h+c+d)}else return new Date(NaN)}function AY(e){var t={},i=Fr.dateTimePattern.exec(e),r;if(i?(t.date=i[1],r=i[3]):(i=Fr.datePattern.exec(e),i?(t.date=i[1],r=i[2]):(t.date=null,r=e)),r){var s=Fr.timeZone.exec(r);s?(t.time=r.replace(s[1],""),t.timeZone=s[1].trim()):t.time=r}return t}function MY(e,t){var i=Fr.YYY[t],r=Fr.YYYYY[t],s;if(s=Fr.YYYY.exec(e)||r.exec(e),s){var a=s[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(s=Fr.YY.exec(e)||i.exec(e),s){var n=s[1];return{year:parseInt(n,10)*100,restDateString:e.slice(n.length)}}return{year:null}}function EY(e,t){if(t===null)return null;var i,r,s,a;if(e.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(i=Fr.MM.exec(e),i)return r=new Date(0),s=parseInt(i[1],10)-1,IS(t,s)?(r.setUTCFullYear(t,s),r):new Date(NaN);if(i=Fr.DDD.exec(e),i){r=new Date(0);var n=parseInt(i[1],10);return DY(t,n)?(r.setUTCFullYear(t,0,n),r):new Date(NaN)}if(i=Fr.MMDD.exec(e),i){r=new Date(0),s=parseInt(i[1],10)-1;var o=parseInt(i[2],10);return IS(t,s,o)?(r.setUTCFullYear(t,s,o),r):new Date(NaN)}if(i=Fr.Www.exec(e),i)return a=parseInt(i[1],10)-1,OS(t,a)?DS(t,a):new Date(NaN);if(i=Fr.WwwD.exec(e),i){a=parseInt(i[1],10)-1;var l=parseInt(i[2],10)-1;return OS(t,a,l)?DS(t,a,l):new Date(NaN)}return null}function CY(e){var t,i,r;if(t=Fr.HH.exec(e),t)return i=parseFloat(t[1].replace(",",".")),Gg(i)?i%24*jg:NaN;if(t=Fr.HHMM.exec(e),t)return i=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),Gg(i,r)?i%24*jg+r*PS:NaN;if(t=Fr.HHMMSS.exec(e),t){i=parseInt(t[1],10),r=parseInt(t[2],10);var s=parseFloat(t[3].replace(",","."));return Gg(i,r,s)?i%24*jg+r*PS+s*1e3:NaN}return null}function DS(e,t,i){t=t||0,i=i||0;var r=new Date(0);r.setUTCFullYear(e,0,4);var s=r.getUTCDay()||7,a=t*7+i+1-s;return r.setUTCDate(r.getUTCDate()+a),r}var TY=[31,28,31,30,31,30,31,31,30,31,30,31],PY=[31,29,31,30,31,30,31,31,30,31,30,31];function OT(e){return e%400===0||e%4===0&&e%100!==0}function IS(e,t,i){if(t<0||t>11)return!1;if(i!=null){if(i<1)return!1;var r=OT(e);if(r&&i>PY[t]||!r&&i>TY[t])return!1}return!0}function DY(e,t){if(t<1)return!1;var i=OT(e);return!(i&&t>366||!i&&t>365)}function OS(e,t,i){return!(t<0||t>52||i!=null&&(i<0||i>6))}function Gg(e,t,i){return!(e!=null&&(e<0||e>=25)||t!=null&&(t<0||t>=60)||i!=null&&(i<0||i>=60))}function IY(e,t,i){var r=SY(e,i),s=IT(t,r,!0),a=new Date(r.getTime()-s),n=new Date(0);return n.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),n.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),n}function Nr(e,t){return t.color(e)}function RS(e=new Date,t){let i=t.format,r=e.getSeconds(),s=e;t&&t.timeZone!==null&&(s=IY(new Date,t.timeZone));let a=s.getHours(),n=s.getMinutes(),o;t.format12h24h==="12ampm"&&(o=a>=12?"PM":"AM");let l=a;t.format12h24h!=="24"&&(l=a%12,l===0&&(l=12));let h,c;switch(i){case"HH:mm:ss":h=[l,n,r];break;case"HH:mm":h=[l,n];break;case"HH":h=[l],o=void 0;break;case"mm":h=[n],o=void 0;break;case"ss":h=[r],o=void 0;break;case"year":c=s.getFullYear();break;case"month":c=s.getMonth()+1;break;case"dayOfYear":c=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":c=s.getDate();break;case"secondOfDay":c=a*60*60+n*60+r;break;default:console.error("Unknown time format",i),c=0;break}return h!==void 0?{textValue:h,suffix:o}:c}function OY(e,t){switch(e.type){case"fresnel":return zY(e,t);case"gradient":return BY(e,t);case"depth":return FY(e,t);case"normal":return UY(e,t);case"noise":return NY(e,t);case"rainbow":return kY(e,t);case"toon":return VY(e,t);case"outline":return jY(e,t);case"transmission":return GY(e,t);case"color":return LY(e,t);case"pattern":return HY(e,t)}}function RY(e){return{type:e.type}}function Zs(e,t){let{alpha:i,mode:r,isMask:s}=e,a=typeof i=="string"?(Number(t.getVariable(i))??100)/100:i;return{...RY(e),alpha:a,mode:r,isMask:s}}function LY(e,t){return{...Zs(e,t),color:Nr(e.color,t)}}function zY(e,t){let{bias:i,scale:r,intensity:s,factor:a,color:n}=e;return{...Zs(e,t),color:Nr(n,t),bias:i,scale:r,intensity:s,factor:a}}function BY(e,t){let{gradientType:i,smooth:r,colors:s,steps:a,angle:n,offset:o,morph:l}=e;return{...Zs(e,t),gradientType:i,smooth:r,colors:s.map(h=>new ct(h[0],h[1],h[2],h[3])),num:s.length,steps:a,offset:new j(...o),morph:new j(...l),angle:n}}function FY(e,t){let{gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:o,direction:l,colors:h,steps:c,smooth:d}=e;return{...Zs(e,t),gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:new M(...o),direction:l?new M(...l):new M(1,0,0),colors:h.map(u=>u!==void 0?new ct(u[0],u[1],u[2],u[3]):new ct(0,0,0,0)),steps:c.slice(0,h.length),smooth:d}}function UY(e,t){let{cnormal:i}=e;return{...Zs(e,t),cnormal:new M(i[0],i[1],i[2])}}function NY(e,t){return{...Zs(e,t),scale:e.scale,move:e.move,fA:new j(...e.fA),fB:new j(...e.fB),size:new M(...e.size),distortion:new j(...e.distortion),colorA:Nr(e.colorA,t),colorB:Nr(e.colorB,t),colorC:Nr(e.colorC,t),colorD:Nr(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function kY(e,t){return{...Zs(e,t),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new M(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new M(...e.offset)}}function VY(e,t){return{...Zs(e,t),positioning:e.positioning,colors:e.colors.map(i=>new ct(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new M(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:Nr(e.shadowColor,t),offset:new M(...e.offset)}}function jY(e,t){return{...Zs(e,t),outlineColor:Nr(e.outlineColor,t),contourColor:Nr(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new M(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function GY(e,t){return{...Zs(e,t),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function HY(e,t){return{...Zs(e,t),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new j(...e.offset),colorA:Nr(e.colorA,t),colorB:Nr(e.colorB,t),frequency:new j(...e.frequency),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new j(...e.vertical),horizontal:new j(...e.horizontal),sides:e.sides}}var Of=class extends vr{},WY={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},qY={depth:["colors"]};function XY(e,t,i){var a,n;if(t==="isMask")return!0;let r=WY[e.type],s=qY[e.type];if(s!==void 0){let o=e.color;if(s.includes(t)){let l=(n=(a=o[t])==null?void 0:a.value)==null?void 0:n.length;if(l!==void 0&&l!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function RT(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let s=!1,a=e;if("image"in a){let n=a.image,o=t.image(n),l=r;l.image instanceof Yn||l.image.deref(),l.image=o}if("video"in a){let n=a.video,o=t.video(n),l=r;l.image instanceof Yn||l.image.deref(),l.image=o}if("wrapping"in a){let n=r;n.wrap=a.wrapping}if("minFilter"in a){let n=r;n.minFilter=a.minFilter}if("magFilter"in a){let n=r;n.magFilter=a.magFilter}if("rotation"in a&&i.uniforms[`f${i.id}_rotation`])return i.uniforms[`f${i.id}_rotation`].value=(a.rotation??0)*Re.DEG2RAD,s;if("repeat"in a||"offset"in a||"rotation"in a){let n="mat",o=i.uniforms[`f${i.id}_${n}`];"repeat"in a&&(o.repeat=a.repeat),"offset"in a&&(o.offset=a.offset),"rotation"in a&&(o.rotation=a.rotation??0),o.updateMatrix()}return s}function YY(e,t,i,r){let s=!1;for(let[a,n]of Object.entries(e)){if(a==="bumpMap"||a==="roughnessMap"){s=!0;continue}if(!a||n===void 0)continue;if(zT(a,i,r,t)){a==="visible"&&i.type==="light"&&(s=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${a}`];if(o&&!(o instanceof V1))switch(s=s||XY(i,a,n),o.constructor){case gi:if(typeof n=="string"){let l=t.getColor(n);l&&(o.value=l);break}else{let l=n;o.value instanceof Of?o.value=new vr(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case Ka:if(typeof n=="string"){let l=t.getColor(n);l&&(o.value=l);break}else{let l=n;o.value instanceof Of?o.value=new vr(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case cr:{let l=n;o.value.setX(l[0]),o.value.setY(l[1]);break}case fs:{let l=n;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case an:{RT(n,t,i);break}case Fo:{o.value=n.map(l=>new ct(...l));break}default:{o.value=n;break}}}return s}var dl=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?e*100:e,i)??100)/100))??1,jd=class{constructor(e,t,i,r,s){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let a in r)this.uniforms[`f${this.id}_${a}`]=r[a];for(let a in i)zT(a,this,i,s)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return fa.createLightLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let s=i.type==="texture"?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.video(i.texture.video),a=new ry(s,i.texture.wrapping,i.texture.minFilter??1008,i.texture.magFilter??1006),n=new ZX(s),o=new KX(i.texture.repeat,i.texture.offset,i.texture.rotation??0),l=new Fe(i.crop?1:0),h=new Yt(i.projection??0),c=new Yt(["x","y","z"].indexOf(i.axis)??0),d=new Yt(i.side??0),u=new cr(i.size?new j(i.size[0],i.size[1]):new j(100,100)),p=new Fe(i.blending??0),f=new Fe(dl(i.alpha,r)),g=new Yt(i.mode??0),m=new Br(i.isMask??!1),v=new j1(a,n,l,h,c,d,u,p,o,f,g,m),y=new ii(v.calpha,"f");return new ui(e,t,i,{texture:a,textureSize:n,crop:l,projection:h,axis:c,side:d,size:u,blending:p,mat:o,alpha:f,mode:g,isMask:m},v,g,y,m,r)}else if(i.type==="matcap"){let s=r.image(i.texture.image),a=new ry(s,i.texture.wrapping,i.texture.minFilter??1008,i.texture.magFilter??1006),n=new Fe(dl(i.alpha,r)),o=new Yt(i.mode??0),l=new Br(i.isMask??!1),h=new Fe((i.texture.rotation??0)*Re.DEG2RAD),c=new mT(a,n,o,l,h),d=new ii(c.calpha,"f");return new ui(e,t,i,{texture:a,alpha:n,mode:o,isMask:l,rotation:h},c,o,d,l,r)}else if(i.type==="displace")if(i.displacementType==="noise"){let s=new fs(new M(...i.offset)),a=new Fe(i.scale??10),n=new Fe(i.intensity??8),o=new Fe(i.movement??1),l=new Yt(i.noiseType??0),h=new Yt(i.voronoiStyle??0),c=new Fe(i.smoothness??.5),d=new Fe(i.seed??0),u=new Fe(i.highCut??1),p=new Fe(i.lowCut??0),f=new Yt(i.quality??1),g=new CT(n,o,s,h,c,d,u,p,f,a,l);return new LT(e,t,i,{offset:s,scale:a,intensity:n,movement:o,noiseType:l,voronoiStyle:h,smoothness:c,seed:d,highCut:u,lowCut:p,quality:f},g,r)}else throw new Error;else return KY(e,t,i,r)}updateByOp(e,t,i){let r=e;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props||"noiseType"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):YY(r.props,i.shared,this,t)}else if(r.path[0]==="texture")return"texture"in t||"video"in t?RT(r.props,i.shared,this):!0;return!1}dispose(){if(QY(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Yn||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},ui=class extends jd{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,l),this.params=r,this.color=s,this.mode=a,this.alpha=n,this.isMask=o}},LT=class extends jd{constructor(e,t,i,r,s,a){super(e,t,i,r,a),this.position=s}},fa=class extends jd{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.node=r}static createLightLayer(e,t,i,r){let s,a=new Fe(dl(i.alpha,r)),n=new Yt(i.mode),o=new Fe(i.bumpMapIntensity),l=new Fe(dl(i.alphaOverride,r)),h;if(!i.visible)s=new G1,h={};else if(i.category==="lambert"){s=new tY;let c=new gi(r.color(i.emissive)??0),d=new Br(i.occlusion??!0);h={emissive:c,occlusion:d},s.emissive=c,s.occlusion=d}else if(i.category==="toon"){s=new sY;let c=new Fe(i.shininess??30),d=new gi(r.color(i.specular)??1118481);h={shininess:c,specular:d},s.shininess=c,s.specular=d}else if(i.category==="physical"){s=new rY;let c=new Fe(i.roughness??.3),d=new Fe(i.metalness??0),u=new Fe(i.reflectivity??.5),p=new Br(i.occlusion??!0);h={roughness:c,metalness:d,reflectivity:u,occlusion:p},s.roughness=c,s.metalness=d,s.reflectivity=u,s.occlusion=p}else{s=new iY;let c=new Fe(i.shininess??30),d=new gi(i.specular!==void 0?r.color(i.specular)??1118481:1118481),u=new Br(i.occlusion??!0);h={shininess:c,specular:d,occlusion:u},s.shininess=c,s.specular=d,s.occlusion=u}return s.alpha=new Fe(1),s.shadingAlpha=a,s.shadingBlend=n,s.bumpMapIntensity=o,s.alphaOverride=l,h.alpha=s.shadingAlpha,h.mode=s.shadingBlend,h.bumpMapIntensity=s.bumpMapIntensity,h.alphaOverride=s.alphaOverride,new fa(e,t,i,s,h,r)}get category(){return this.node.category}};function QY(e){let t=e instanceof jd?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function hs(e){return{alpha:new Fe(e.alpha??1),mode:new Yt(e.mode??0),isMask:new Br(e.isMask??!1)}}function ZY(e,t,i,r,s){switch(e.type){case"color":{let a=new gi(r.color??as),n=hs(r),o=new sy(a,n.alpha),l=new ii(o.calpha,"f");return new ui(t,i,e,{color:a,...n},o,n.mode,l,n.isMask,s)}case"fresnel":{let a=new gi(r.color??16777215),n=new Fe(r.bias??.1),o=new Fe(r.scale??1),l=new Fe(r.intensity??2),h=new Fe(r.factor??1),c=hs(r),d=new JX(a,n,o,l,h,c.alpha,c.mode,c.isMask),u=new ii(d.calpha,"f");return new ui(t,i,e,{color:a,bias:n,scale:o,intensity:l,factor:h,...c},d,c.mode,u,c.isMask,s)}case"rainbow":{let a=new Fe(r.filmThickness??30),n=new Fe(r.movement??0),o=new fs(r.wavelengths??new M(0,0,0)),l=new Fe(r.noiseStrength??0),h=new Fe(r.noiseScale??1),c=new fs(r.offset??new M(0,0,0)),d=hs(r),u=new wT(a,n,o,l,h,c,d.alpha,d.isMask),p=new ii(u.calpha,"f");return new ui(t,i,e,{filmThickness:a,movement:n,wavelengths:o,noiseStrength:l,noiseScale:h,offset:c,...d},u,d.mode,p,d.isMask,s)}case"transmission":{let a=new Fe(r.thickness??10),n=new Fe(r.ior??1.5),o=new Fe(r.roughness??.5),l=st.transmissionSize,h=st.transmissionRenderTarget,c=st.transmissionRenderTargetDepth,d=window.innerWidth,u=window.innerHeight,p=d>=u?new cr(u/d,1):new cr(1,d/u),f=hs(r),g=new MT(a,n,o,l,h,c,p,f.alpha),m=new ii(g.calpha,"f");return new ui(t,i,e,{thickness:a,ior:n,roughness:o,aspectRatio:p,...f},g,f.mode,m,f.isMask,s)}case"toon":{let a=new Yt(r.positioning??0),n;r.colors?n=new Fo(r.colors.length,r.colors):(n=new Fo(10,new ct(0,0,0,1)),n.value[1]=new ct(1,1,1,1));let o;r.steps?o=new Bo(r.steps.length,r.steps):(o=new Bo(10,1),o.value[0]=0);let l=new fs(r.source??new M(0,0,0)),h=new Br(r.isWorldSpace??!0),c=new Fe(r.noiseStrength??0),d=new Fe(r.noiseScale??1),u=new Ka(r.shadowColor),p=new fs(r.offset??new M(0,0,0)),f=hs(r),g=new ST(a,n,o,l,h,c,d,u,p,f.alpha),m=new ii(g.calpha,"f");return new ui(t,i,e,{positioning:a,colors:n,steps:o,source:l,isWorldSpace:h,noiseStrength:c,noiseScale:d,shadowColor:u,offset:p,...f},g,f.mode,m,f.isMask,s)}case"outline":{let a=new gi(r.outlineColor??16777215),n=new gi(r.contourColor??16777215),o=new Fe(r.outlineWidth??.1),l=new Fe(r.contourWidth??.1),h=new Fe(r.outlineThreshold??.1),c=new Fe(r.contourThreshold??.1),d=new Fe(r.outlineSmoothing??.1),u=new Fe(r.contourFrequency??.1),p=new fs(r.contourDirection??new M(0,1,0)),f=new Br(r.positionalLines??!1),g=new Br(r.compensation??!0),m=st.normalRenderTarget,v=st.normalRenderTargetDepth,y=st.pixelRatioNode,x=st.resolution,w=hs(r),_=new yT(a,n,o,l,h,c,d,u,p,f,g,x,m,v,y,w.alpha),b=new ii(_.calpha,"f");return new ui(t,i,e,{outlineColor:a,contourColor:n,outlineWidth:o,contourWidth:l,outlineThreshold:h,contourThreshold:c,outlineSmoothing:d,contourFrequency:u,contourDirection:p,positionalLines:f,compensation:g,...w},_,w.mode,b,w.isMask,s)}case"depth":{let a=new Yt(r.gradientType??0),n=new Br(r.smooth??!1),o=new Fe(r.near??50),l=new Fe(r.far??200),h=new Fe(r.isVector??1),c=new Fe(r.isWorldSpace??0),d=new fs(r.origin??new M),u=new fs(r.direction??new M),p;r.colors?p=new Fo(r.colors.length,r.colors):(p=new Fo(2,new ct(0,0,0,1)),p.value[1]=new ct(1,1,1,1));let f;r.steps?f=new Bo(r.steps.length,r.steps):(f=new Bo(2,1),f.value[0]=0);let g=hs(r),m=new dT(a,n,o,l,h,c,d,u,p,f,g.alpha,g.isMask),v=new ii(m.calpha,"f");return new ui(t,i,e,{gradientType:a,smooth:n,near:o,far:l,isVector:h,isWorldSpace:c,origin:d,direction:u,colors:p,steps:f,...g},m,g.mode,v,g.isMask,s)}case"noise":{let a=new Fe(r.scale??1),n=new fs(r.size??new M(100,100,100)),o=new Fe(r.move??1),l=new cr(r.fA??new j(1.7,9.2)),h=new cr(r.fB??new j(8.3,2.8)),c=new cr(r.distortion??new j(1,1)),d=new Ka(r.colorA),u=new Ka(r.colorB),p=new Ka(r.colorC),f=new Ka(r.colorD),g=new Yt(r.noiseType??0),m=new Yt(r.voronoiStyle??0),v=new Fe(r.highCut??1),y=new Fe(r.lowCut??0),x=new Fe(r.smoothness??.5),w=new Fe(r.seed??.5),_=new Yt(r.quality??1),b=hs(r),A=new gT(a,n,o,l,h,c,d,u,p,f,b.alpha,g,b.isMask,m,v,y,x,w,_),S=new ii(A.calpha,"f");return new ui(t,i,e,{scale:a,size:n,move:o,fA:l,fB:h,distortion:c,colorA:d,colorB:u,colorC:p,colorD:f,noiseType:g,...b,voronoiStyle:m,highCut:v,lowCut:y,smoothness:x,seed:w,quality:_},A,b.mode,S,b.isMask,s)}case"normal":{let a=new fs(r.cnormal??new M(1,1,1)),n=hs(r),o=new cT(a,n.alpha),l=new ii(o.calpha,"f");return new ui(t,i,e,{cnormal:a,...n},o,n.mode,l,n.isMask,s)}case"gradient":{let a=new Yt(r.gradientType??0),n=new Br(r.smooth??!1),o;r.colors?o=new Fo(r.colors.length,r.colors):(o=new Fo(10,new ct(0,0,0,1)),o.value[1]=new ct(1,1,1,1));let l;r.steps?l=new Bo(r.steps.length,r.steps):(l=new Bo(10,1),l.value[0]=0);let h=new cr(r.offset??new j(0,0)),c=new cr(r.morph??new j(0,0)),d=new Fe(r.angle??0),u=hs(r),p=new pT(a,n,o,l,h,c,d,u.alpha,u.isMask),f=new ii(p.calpha,"f");return new ui(t,i,e,{gradientType:a,smooth:n,colors:o,steps:l,offset:h,morph:c,angle:d,...u},p,u.mode,f,u.isMask,s)}case"pattern":{let a=new Yt(r.style??0),n=new Yt(r.projection??0),o=new Yt(["x","y","z"].indexOf(r.axis)??0),l=new Fe(r.blending??0),h=new cr(r.offset??new j(0,0)),c=new Ka(r.colorA),d=new Ka(r.colorB),u=new cr(r.frequency??new j(10,10)),p=new Fe(r.size??.5),f=new Fe(r.variation??0),g=new Fe(r.smoothness??.5),m=new Fe(r.zigzag??0),v=new Fe(r.rotation??0),y=new cr(r.vertical??new j(0,1)),x=new cr(r.horizontal??new j(0,1)),w=new Yt(r.sides??6),_=hs(r),b=new xT(a,n,o,l,h,c,d,u,p,f,g,m,v,y,x,w,_.alpha,_.isMask),A=new ii(b.calpha,"f");return new ui(t,i,e,{style:a,projection:n,axis:o,blending:l,offset:h,colorA:c,colorB:d,frequency:u,size:p,variation:f,smoothness:g,zigzag:m,rotation:v,vertical:y,horizontal:x,sides:w,..._},b,_.mode,A,_.isMask,s)}default:{let a=new gi(1,0,0,1),n=hs(r),o=new sy(a,n.alpha),l=new ii(o.calpha,"f");return new ui(t,i,e,{color:a,...n},o,n.mode,l,n.isMask,s)}}}function KY(e,t,i,r){let s=OY(i,r);return ZY(i,e,t,s,r)}function zT(e,t,i,r){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let s=t.uniforms[`f${t.id}_intensity`];return s?(s.value=i.intensity*(i.visible?1:0),s):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let s=t.uniforms[`f${t.id}_alpha`];if(!s)return;if(s.value=dl(i.alpha,r)*(i.visible?1:0),i.type==="outline"&&e==="visible"){let a=t.uniforms[`f${t.id}_compensation`];a&&(a.value=i.compensation&&i.visible)}return s}}function ph(e,t){let i=0,r=e.layers.find(s=>s.data.type==="light");if(r){let s=r.data,a=Number(t.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?a/100:s.alphaOverride)<1)return!0}for(let s of e.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let a=s.data.visible?s.data.alpha:0;if(typeof a=="string"&&(a=Math.max(0,Math.min(1,Number(t.getVariable(a)??100)/100))),a===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let n of s.data.colors)if(n[3]<1){a=n[3];break}}else if(a===1&&s.data.type==="noise"){let n=t.color(s.data.colorA).a,o=t.color(s.data.colorB).a,l=t.color(s.data.colorC).a,h=t.color(s.data.colorD).a,c=Math.min(n,Math.min(o,Math.min(l,h)));c<1&&(a=c)}i+=(1-i)*a}}return i<1}var uo=class extends Dt{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.shadersPatchedForShapeBlend=!1,this.nodeContextUuid=0,this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},JY=class extends uo{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i,r){return this.root.getFlavor(e,t,i,r)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},H1=class extends uo{constructor(e,t,i=!0){super(),this.data=e,this.allowVariableSaves=i,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.needsJitter=t.shared.needsJitter,Vi.startContext(this),this.reset0(e,t),Vi.endContext(this)}get nodeMaterial(){return this}getFlavor(e,t,i,r){let s=i?6:(e?3:0)+t;if(s+=(((r==null?void 0:r.resolutionLevel)??0)-(r!=null&&r.useChildrenColors?4:0))*7,s===0)return this;this.flavors===void 0&&(this.flavors=[]),s-=1;let a=this.flavors[s];return a===void 0&&(a=new JY(e,t,i,this),a.needsJitter=this.needsJitter,this.flavors[s]=a,a.flatShading=e,a.side=t,a.updateAfterBuild(),r&&(a.defines.SHAPEBLEND=r.resolutionLevel,a.defines.SHAPEBLEND_C=r.useChildrenColors?1:0)),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){var e;return((e=this.lightLayer.getNode("occlusion"))==null?void 0:e.value)??!1}reset(e,t,i=!1){Vi.startContext(this),(this.data!==e||i)&&this.reset0(e,t),Vi.endContext(this)}reset0(e,t){this.data=e;let i=e.layers??ir.defaultTwoLayerData("phong").layers;try{this.layers=i.map(r=>jd.create(this.layerIdGen++,r.id,r.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=ph(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")this.transparent=ph(this.data,i.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let r=e[1],s=e[2];if(r&&s){let a=this.layers.find(n=>n.uuid===r);a!=null&&a.hasValue(s)&&(s==="alpha"?(this.transparent=ph(this.data,i.shared),a.setValue(s,Math.max(0,Math.min(Number(t)/100,1)))):a.setValue(s,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof fa),this.lightLayer===void 0&&(this.lightLayer=new fa(0,"",{...Ji.defaultData("light","phong"),visible:!1},new G1,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(s=>s instanceof fa);if(!e)return;let t=e.data,i=t.bumpMap,r=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let s=0;sn.uuid===s);if(a){let n=t.layers.data(s),o;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?o={...e.props,alpha:dl(e.props.alpha,r,["material",this.uuid,"layer",s,"alpha"])}:o={...e.props,alphaOverride:dl(e.props.alphaOverride,r,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...o?{props:o}:{},path:e.path.slice(2)},n,i)&&this.reset0(t,i)}}}else this.reset0(t,i);Vi.endContext(this)}applyMasks(){for(let e=0;e0){let i=e-1,r=this.layers[i];r instanceof fa?r.node.mask=new Wr(t.color,t.alpha,Wr.MUL):r instanceof ui&&(r.isMask.value||(r.color.mask=new Wr(t.color,t.alpha,Wr.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof ui),t=this.layers.findIndex(i=>i instanceof fa);if(e!==-1&&ei instanceof fa);if(this.layers.length>t+1){for(let i=t+1;it instanceof LT);if(e.length>0){let t=e[0].position;for(let i=1;iMath.min(Math.max(r,s),a);for(let r of this.layers)if(r.type==="displace"){let s=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=s}}updateFrame(e){for(let t=0;te.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ui){let t=e.params.texture;if(t instanceof ry&&!t.image.loaded)return!1}return!0}};Object.defineProperties(uo.prototype,{properties:{get:function(){return this.fragment.properties}}});var oy=class extends H1{constructor(e,t,i){super(e,t,!1),this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}},LS=new Map;function $Y(e){if(typeof e=="string")return e;let t=LS.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},LS.set(e,t)),t.url}var BT,eQ=new Promise(e=>{BT=e}),zS=!1,$u;function tQ(){if(zS)return;if($u)return $u;async function e(){await vo(()=>import("./howler-BzJY10nd.js").then(t=>t.h),__vite__mapDeps([0,1])),BT(window!==void 0?window:global),zS=!0}return $u=e(),$u}var FT;eQ.then(e=>FT=e);function BS(e,t){e.forEach(i=>{"dragDropActions"in i.data?(t.push(...i.data.dragDropActions.drag),t.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(t.push(...i.data.inActions),t.push(...i.data.outActions)):"gameActions"in i.data?(t.push(...i.data.gameActions.idle),t.push(...i.data.gameActions.move),t.push(...i.data.gameActions.jump),t.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{t.push(...r.data.actions)}):"actions"in i.data&&(t.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(t.push(...r.data.ifActions),t.push(...r.data.elseActions))}))})}function iQ(e){let t=!1,i=[];return e.scene.objects.traverse((r,s)=>{if(s.type==="Page"&&s.uiScene!==void 0&&s.uiScene.objects.traverse((a,n)=>{if(n.events===void 0||Array.isArray(n.events)===!1)return!0;BS(n.events,i),t=t||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;BS(s.events,i),t=t||i.some(a=>a.data.type==="Audio")}),t}var qc=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof e=="string"?s={src:e}:s={src:$Y(e),format:"wav"},this.sound=new FT.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},rQ=class{constructor(){this.type="ShapePath",this.color=new et,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Wp,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){var i;return(i=this.currentPath)==null||i.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){var s;return(s=this.currentPath)==null||s.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){var n;return(n=this.currentPath)==null||n.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){var t;return(t=this.currentPath)==null||t.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(p,f,g,m){let v=p.x,y=f.x,x=g.x,w=m.x,_=p.y,b=f.y,A=g.y,S=m.y,E=(w-x)*(_-A)-(S-A)*(v-x),C=(y-v)*(_-A)-(b-_)*(v-x),T=(S-A)*(y-v)-(w-x)*(b-_),D=E/T,O=C/T;if(T===0&&E!==0||D<=0||D>=1||O<0||O>1)return null;if(E===0&&T===0){for(let P=0;P<2;P++)if(r(P===0?g:m,p,f),t.loc===e.ORIGIN){let U=P===0?g:m;return{x:U.x,y:U.y,t:t.t}}else if(t.loc===e.BETWEEN){let U=+(v+t.t*(y-v)).toPrecision(10),W=+(_+t.t*(b-_)).toPrecision(10);return{x:U,y:W,t:t.t}}return null}else{for(let W=0;W<2;W++)if(r(W===0?g:m,p,f),t.loc===e.ORIGIN){let k=W===0?g:m;return{x:k.x,y:k.y,t:t.t}}let P=+(v+D*(y-v)).toPrecision(10),U=+(_+D*(b-_)).toPrecision(10);return{x:P,y:U,t:D}}}function r(p,f,g){let m=g.x-f.x,v=g.y-f.y,y=p.x-f.x,x=p.y-f.y,w=m*x-y*v;if(p.x===f.x&&p.y===f.y){t.loc=e.ORIGIN,t.t=0;return}if(p.x===g.x&&p.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(w<-Number.EPSILON){t.loc=e.LEFT;return}if(w>Number.EPSILON){t.loc=e.RIGHT;return}if(m*y<0||v*x<0){t.loc=e.BEHIND;return}if(Math.sqrt(m*m+v*v)S.t<=A.t+Number.EPSILON&&S.t>=A.t-Number.EPSILON)===void 0&&(g.push(A),m.push(new j(A.x,A.y)))}}return m}function a(p,f,g){let m=new j;f.getCenter(m);let v=[];return g.forEach(y=>{y.boundingBox.containsPoint(m)&&s(p,y.points).forEach(x=>{v.push({identifier:y.identifier,isCW:y.isCW,point:x})})}),v.sort((y,x)=>y.point.x-x.point.x),v}function n(p,f,g,m,v){(v==null||v==="")&&(v="nonzero");let y=new j;p.boundingBox.getCenter(y);let x=[new j(g,y.y),new j(m,y.y)],w=a(x,p.boundingBox,f);w.sort((C,T)=>C.point.x-T.point.x);let _=[],b=[];w.forEach(C=>{C.identifier===p.identifier?_.push(C):b.push(C)});let A=_[0].point.x,S=[],E=0;for(;E0&&S[S.length-1]===b[E].identifier?S.pop():S.push(b[E].identifier),E++;if(S.push(p.identifier),v==="evenodd"){let C=S.length%2===0,T=S[S.length-2];return{identifier:p.identifier,isHole:C,for:T}}else if(v==="nonzero"){let C=!0,T=null,D=null;for(let O=0;O{let f=p.getPoints(),g=-999999999,m=999999999,v=-999999999,y=999999999;for(let x=0;xg&&(g=w.y),w.yv&&(v=w.x),w.x=y&&(l=y-1),f.length&&c.push({curves:p.curves,points:f,isCW:DM.isClockWise(f),identifier:o++,boundingBox:new t1(new j(y,m),new j(v,g))})});let d=c.map(p=>{var f;return n(p,c,l,h,(f=this.userData)==null?void 0:f.style.fillRule)}),u=[];return c.forEach(p=>{let f=d[p.identifier];if(f&&!f.isHole){let g=new qp;g.curves=p.curves,d.filter(m=>(m==null?void 0:m.isHole)&&m.for===p.identifier).forEach(m=>{if(m){let v=c[m.identifier],y=new Wp;y.curves=v.curves,g.holes.push(y)}}),u.push(g)}}),u}},UT=!1,NT,FS=new Promise(e=>{NT=e}),US=!1,ep;function sQ(){if(UT=!0,US)return;if(ep)return ep;async function e(){let t=await vo(()=>import("./opentype-QeDitGAm.js"),__vite__mapDeps([]));NT(t),US=!0}return ep=e(),ep}var aQ=class{async load(e,t,i=()=>{}){let{load:r}=await FS;r(e,(s,a)=>{s||!a?i(s??"Something went wrong"):t(a)})}async parse(e){let{parse:t,Bidi:i}=await FS;try{let r=t(e),s=new i,a=n=>r.charToGlyphIndex(n.char);return s.registerModifier("glyphIndex",null,a),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function nQ(e){return await(await fetch(e)).arrayBuffer()}var oQ=new aQ;async function NS(e){let t,i,r=!1;if(e.url?(t=await nQ(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength)),t)if(UT){let s=await oQ.parse(t);if(s)return{font:s.font,url:i,intercepted:r,arr:t,bidi:s.bidi}}else return{font:void 0,url:i,intercepted:r,arr:t,bidi:null}}function lQ(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var hQ=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=NS(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=NS(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,a=[],n=0,o=i.length===s.length;for(let l=0;lt.length&&(m=!0);a.push({char:c,index:h,replacements:f,replacementChars:Array.from(u)}),n++}}return a}generateShapes(e,t,i){var v;if(!this._isLoaded)return;let r=this.font,s=t.fontSize/this.unitsPerEm,a=t.fontSize*t.lineHeight,n=e.map(y=>this.getTextWidth(y,t)),o=typeof t.width=="string"?Number(i.getVariable(t.width)):t.width,l=typeof t.height=="string"?Number(i.getVariable(t.height)):t.height,h=this.getCharWidth(` `,t),c=t.horizontalAlign===1?h:0,d=this.getLineInitialOffsetX(n[0],o,t.horizontalAlign,e[0],h),u=this.getLineInitialOffsetY(a,e.length,l,s,t.verticalAlign),p=[],f=e.map(y=>[]),g=e.map(y=>[]);for(let y=0;y{let U=C.index===0?` `:C.unicode?String.fromCharCode(C.unicode):void 0,W=b[S],k=0;if(U===` `)k=c;else if(U===" ")k=A;else{let F=this.createPath(C,s,T,D,t);F&&(k=F.offsetX,p.push(F.path))}if(W.replacements.length===1)g[y].push([T,D]),f[y].push(k);else{let F=W.replacements.map(q=>(r.glyphs.get(q).advanceWidth??0)*s),Z=F.reduce((q,$)=>q+=$,0),X=F.map(q=>q/Z),G=T;for(let q=0;q=0&&(e-=s),i===3?t*.5-e*.5:i===2?t-e:0}getLineInitialOffsetY(e,t,i,r,s){let a=t*e,n=Math.abs(this.ascender-this.descender)*r,o=e-n,l=-this.ascender*r-o/2;return s===3?-(i-a-l):s===2?-(i*.5-a*.5-l):l}createPath(e,t,i,r,s){var l;let a=e.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!a){console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");return}let n=new rQ,o=(e.advanceWidth??1)*t;if(e)for(let h of a.commands){let c=(l=n.currentPath)==null?void 0:l.currentPoint;if(!(c&&h.type!=="Z"&&c.x===h.x&&-c.y===h.y))switch(h.type){case"M":n.moveTo(h.x,-h.y);break;case"L":n.lineTo(h.x,-h.y);break;case"Q":n.quadraticCurveTo(h.x1,-h.y1,h.x,-h.y);break;case"C":n.bezierCurveTo(h.x1,-h.y1,h.x2,-h.y2,h.x,-h.y);break}}return n.subPaths.forEach(h=>{let c=cQ(h.curves);c!==void 0&&h.currentPoint.distanceTo(c)>0&&h.lineTo(c.x,c.y)}),{offsetX:o,path:n}}getCharWidth(e,t){var i;return((i=this.font)==null?void 0:i.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing}))??0}getTextWidth(e,t){var i;return((i=this.font)==null?void 0:i.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing}))??0}computeSpaceWidthForLine(e,t,i,r){let s=this.getCharWidth(" ",i),a=e[t];if(a){let n=this.countSpaces(a.trimEnd());if(i.horizontalAlign===4&&t{this.disposeObject(this.objects.get(e)),this.objects.delete(e)}),this.unreachable.clear()}dispose(){this.objects.forEach(e=>{this.disposeObject(e)}),this.objects.clear()}},kS=class extends dQ{constructor(e){super(),this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,i){let r=Dd(e,t,this.flatShading,i);return r.computeBoundingSphere(),r}},uQ={markNeedsUpdateRendererDirty:()=>{}},Dp=1e3,VS=512*Dp;function pQ(e,t){let i=typeof e;return!!((t==="string"||t==="number")&&i===t||t==="boolean"&&(e==="true"||e==="false"||e===!0||e===!1)||t==="image"&&i==="string"&&e.startsWith("http"))}var fQ="https://hooks.spline.design",mQ=`${fQ}/events?hashFile=`,gQ=class{constructor(e,t){this.id=e,this.userWebhook=t,this.result=void 0,this._connected=!1,this.emitter=dm(),this.reconnectWaitFor=Dp,this._onError=i=>{var r,s,a;(r=this.eventSource)==null||r.removeEventListener("message",this._onMessage),(s=this.eventSource)==null||s.removeEventListener("error",this._onError),(a=this.eventSource)==null||a.removeEventListener("open",this._onConnected),this._scheduleReconnect()},this._onConnected=i=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Dp,this._connected=!0},this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Dp,this._connected=!1},this._onMessage=i=>{let r=i.data,s;try{s=JSON.parse(r)}catch(a){console.error("Error parsing webhook message",a)}if(s){let a=!1;this.userWebhook.parametersSchemas.forEach(({data:n})=>{s[n.name]!==void 0&&pQ(s[n.name],n.type)&&(this.result===void 0&&(this.result={}),this.result[n.name]=s[n.name],a=!0)}),a&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(mQ+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){var e,t,i,r;(e=this.eventSource)==null||e.removeEventListener("message",this._onMessage),(t=this.eventSource)==null||t.removeEventListener("error",this._onError),(i=this.eventSource)==null||i.removeEventListener("open",this._onConnected),(r=this.eventSource)==null||r.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>VS&&(this.reconnectWaitFor=VS),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(e){this.userWebhook=e}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(e=>e.data.name)}getParameterValue(e){var t;if(this.getParametersKeys().includes(e)){if(this.result)return(t=this.result)==null?void 0:t[e];for(let i of this.userWebhook.parametersSchemas)if(i.data.name===e)return L0.defaultParameterValueByType(i.data.type)}}},jS=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],vQ=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],lo=[],W1=[];for(let e=1;e<=8;e++)for(let t=0;tlo[t]>Rf[0]&&lo[t]lo[t]>Rf[0]&&lo[t]=0;v--)if(g>u[v]){p[v]=Math.max(p[v],m);break}}l=p,h=r==="voice"?GS:lo,c=r==="voice"?yQ:W1}else l=Array.from(i),h=l.map((u,p)=>o*p),c=h.map(u=>`${u.toFixed(2)} Hz`);let d=l.map(u=>Math.max(0,Math.min((u-s)/(a-s),1)));return{values:new Float32Array(d),frequencies:h,labels:c}}},bQ="gpt-4o-realtime-preview-2024-12-17",wQ=()=>"https://relayserver.spline.design/";async function _Q(e){try{return(await(await fetch(wQ()+"session?uuidfile="+e)).json()).token}catch(t){console.error("Token generation error:",t)}}var SQ=class{constructor(e){this.value=0,this.frequencies=new Float32Array(0);let t=new AudioContext;this.source=t.createMediaStreamSource(e),this.analyser=t.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(e=-100,t=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return xQ.getFrequencies(this.analyser,44100,void 0,"voice",e,t)}update(){let e=this.getFrequencies(),t=e.values.reduce((i,r)=>i+r,0)/e.values.length;this.value=t,this.frequencies=e.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},HS=class{constructor(e,t,i){this.data=e,this.id=t,this.shared=i,this.emitter=dm(),this.rafId=0,this.voice=0,this.frequencies=new Float32Array([0]),this.events=[],this.isConnected=!1,this.isToolsAdded=!1,this.tools=[],this.onMessage=r=>{var a;let s=JSON.parse(r.data);if(this.appendEvent(s),s.type==="session.created"&&this.onSessionCreated(),s.type==="response.done"&&((a=s.response)==null?void 0:a.output)){for(let n of s.response.output)if(n.type==="function_call")for(let[o,l]of this.tools)n.name===o.name&&(l(JSON.parse(n.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}},this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()},this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})},this.animate=()=>{if(this.rafId=requestAnimationFrame(this.animate),this.isConnected&&this.analyser){this.analyser.update();let r=this.analyser.value,s=this.analyser.frequencies;this.voice=r,this.frequencies=s,this.emitter.emit("voice",{value:r,frequencies:s})}}}update(e){this.data=e}setColorByName(e,t){let i=this.shared.getColorByName(e);if(i){let{id:r}=i,{r:s,g:a,b:n}=Yq.hexStringToRgb(t)??{r:0,g:0,b:0};this.shared.updateColor(r,{r:s/255,g:a/255,b:n/255})}}async connect(){if(this.isConnected)return;let e=await _Q(this.data.integration.hash);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=s=>{let a=s.streams[0];this.audioElement.srcObject=a,this.analyser=new SQ(a)};let t=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(t.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let i=await this.pc.createOffer();await this.pc.setLocalDescription(i);let r={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime?model=${bQ}`,{method:"POST",body:i.sdp,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(r),this.animate()}appendEvent(e){this.events=[e,...this.events]}sendClientEvent(e){this.dc?(e.event_id=e.event_id||crypto.randomUUID(),this.dc.send(JSON.stringify(e)),this.appendEvent(e)):console.error("Failed to send message - no data channel available",e)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:s})=>{this.setColorByName("Voice Assistant Color",s)});let e=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${e}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:s,value:a})=>{let n=this.shared.getVariableByName(s);if(n){let o=this.shared.getVariable(n.id),l;typeof o=="number"?l=parseFloat(a):typeof o=="boolean"?l=a.toLowerCase()==="true":l={textValue:a},this.shared.updateVariable(n.id,l)}});let t=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${t}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:s,value:a})=>{this.setColorByName(s,a)});let i=this.shared.scene,r=[];i.traverseEntity(s=>{s.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:n}=a.data;r.push(n)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(r)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:s,direction:a})=>{this.emitter.emit("trigger_event",{description:s,direction:a})}),this.sendClientEvent({type:"session.update",session:{tools:this.tools.map(([s])=>s)}})}registerTool(e,t){this.tools.push([e,t])}disconnect(){var e,t,i,r,s,a;cancelAnimationFrame(this.rafId),(e=this.analyser)==null||e.disconnect(),this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,(t=this.dc)==null||t.removeEventListener("message",this.onMessage),(i=this.dc)==null||i.removeEventListener("open",this.onOpen),(r=this.dc)==null||r.close(),(s=this.pc)==null||s.getSenders().forEach(n=>{n.track&&n.track.stop()}),(a=this.pc)==null||a.close(),this.pc=void 0}computeAnalysisForListenerEvent(e){if(e.analysis==="range"){let t=this.frequencies.slice(...e.analysisRange);return t.reduce((i,r)=>i+r,0)/t.length}return e.analysis==="single"?this.frequencies[e.analysisSingle]:this.voice}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}};function ly(e){return"variable_"+e}var AQ=class extends hY{constructor(e){super(),this.shared=e}create(e){return new PT(e,this.shared)}},q1=class{constructor(e,t={},i=!0,r=!1){if(this.data=e,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new kS(!0),this.geometryCache2=new kS(!1),this.imageHolderCache=new AQ(this),this.thisContext={scene:uQ,shared:this},this.deletedMaterial=new oy(ir.defaultTwoLayerData("phong"),this.thisContext,""),this.deletedImage=new Yn(B0.emptyImage,this),this.deletedVideo=new Yn(ff.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},t.images)for(let[s,a]of Object.entries(t.images))this.addImage(s,a);if(t.videos)for(let[s,a]of Object.entries(t.videos))this.addVideo(s,a);if(t.audios)for(let[s,a]of Object.entries(t.audios))this.addAudio(s,a);if(t.particles)for(let[s,a]of Object.entries(t.particles))this.addParticle(s,a);this.reset(e)}setRequestRender(e){this._requestRender=e}getImageLoadPromises(){return Object.values(this.images).map(e=>e.loadPromise)}setEntityOpContext(e){this.entityOpContext=e}reset(e,t=!1,i=!1){this.data=e,this.resetLib(e.lib);for(let{id:r,data:s}of e.variables)this.addVariableHolder(r,s),t&&this.updateVariableHolder(r,s);for(let[r,s]of Object.entries(e.userAPIs))this.addUserAPI(r,s);for(let[r,s]of Object.entries(e.userWebhooks))this.addUserWebhook(r,s);if(!i){for(let[r,s]of Object.entries(e.images))this.addImage(r,s);for(let[r,s]of Object.entries(e.videos))this.addVideo(r,s)}for(let[r,s]of Object.entries(e.colors))this.addColor(r,s);for(let[r,s]of Object.entries(e.materials))this.addMaterial(r,s);for(let[r,s]of Object.entries(e.audios))this.addAudio(r,s);for(let[r,s]of Object.entries(e.particles))this.addParticle(r,s);for(let[r,s]of Object.entries(e.fonts))this.addFont(r,s)}addMaterial(e,t){if(this.materials[e]){let i=this.materials[e];i.reset(t,this.thisContext),i.dispose()}else{let i=new oy(t,this.thisContext,e);this.materials[e]=i}}deleteMaterial(e){this.materials[e]&&(this.materials[e].nodeMaterialDispose(),delete this.materials[e])}getMaterial(e){return this.materials[e]}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return typeof e=="string"?this.getMaterialOrDeletedPlaceholder(e):e==null?(console.error("material is undefined or null"),this.deletedMaterial):new H1(e,this.thisContext)}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[e].updateSrc(t.data),!0):(this.images[e]=new Yn(t,this),!1)}deleteImage(e){let t=this.images[e];t&&(t.dispose(),delete this.images[e])}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return typeof e=="string"?this.getImage(e):this.imageHolderCache.load(e)}addUIBuffer(e,t){return this.uiBuffers[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[e].updateSrc(t),!0):(this.uiBuffers[e]=new Yn(t,this),!1)}uiBuffer(e){return this.uiBuffers[e]}addVideo(e,t){return this.videos[e]?(this.videos[e].updateSrc(t.data),!0):(this.videos[e]=new Yn(t,this),!1)}deleteVideo(e){let t=this.videos[e];t&&(t.dispose(),delete this.videos[e])}getVideo(e){return this.videos[e]??this.deletedVideo}video(e){return typeof e=="string"?this.getVideo(e):this.imageHolderCache.load(e)}addColor(e,t){return this.colors[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new Of(t.r,t.g,t.b,t.a):this.colors[e]=new Of(t.r,t.g,t.b,1),!1)}updateColor(e,t){if(this.colors[e]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[e];return this.colors[e].r=t.r??i.r,this.colors[e].g=t.g??i.g,this.colors[e].b=t.b??i.b,this.colors[e].a=t.a??i.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}getColorNames(){return Object.values(this.data.colors).map(e=>e.name)}getColorByName(e){for(let t in this.data.colors)if(this.data.colors[t].name===e)return{color:this.colors[t],id:t}}color(e){let t;if(typeof e=="string"){let i=this.getColor(e);i?t=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new vr(0,0,0,0))}else return"a"in e?new vr(e.r,e.g,e.b,e.a):new vr(e.r,e.g,e.b,1);return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof qc)return t;{let i=new qc({src:t.data});return this.audios[e]=i,i}}addParticle(e,t){this.particles[e]=t}getParticle(e){return this.particles[e]}deleteParticle(e){this.particles[e]&&delete this.particles[e]}deleteAudio(e){let t=this.audios[e];t&&(t instanceof qc&&t.dispose(),delete this.audios[e])}addFont(e,t){this.fonts[e]=new hQ(t),this.fonts[e].loadingPromise.then(()=>this.requestRender())}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof qc&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(e,t){if(this.variables[e]===void 0){let i=t.value;if(this.enableLocalStorageForPersistentVariables&&t.persistent){let r=localStorage.getItem(ly(e));i=r!==null?JSON.parse(r):t.value}return this.variables[e]={value:i,locations:[],persistent:t.persistent},"dynamicVariableType"in t&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0),!0}return this.variables[e].value=t.value,!1}resetDynamicVariablePlayState(){for(let e in this.variables)this.variables[e].dynamicVariablePlayState!==void 0&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(e,t){this.updateVariable(e,t.value)}updateVariable(e,t){if(this.variables[e]===void 0)return!1;this.variables[e].value=t,this.enableLocalStorageForPersistentVariables&&this.variables[e].persistent&&localStorage.setItem(ly(e),JSON.stringify(t));let i=t;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene;for(let s=this.variables[e].locations.length-1;s>=0;s--){let a=this.variables[e].locations[s];if(a[0]==="material"){let n=a[1],o=i,l={scene:r,shared:this},h=a.slice(2);r.traverseMaterial(d=>{let u=d.root??d;u.uuid===n&&u.onVariableUpdate(h,o,l)});let c=this.materials[n];c&&c.onVariableUpdate(h,o,l)}else{let n=r.find(a[0]);if(n===void 0){this.variables[e].locations.splice(s,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let o=1;o{let c=h.dataPatched;h.chooseGeoemtryCache(this).forceDelete(c.geometry),h.createGeometryDelayed(this.entityOpContext),h.onVariableUpdate(!0),h.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&n.updateMorphInfluences(a[2],i)}}return this.requestRender(),!0}deleteVariable(e){this.variables[e]&&delete this.variables[e]}getVariable(e,t){var i,r,s;if(Array.isArray(e)){if(e[0]==="mouse")return((i=this.mouseProperty)==null?void 0:i[e[1]])??0;if(e[0]==="raycast")return((r=this.raycastProperty)==null?void 0:r[e[1]])??0;let a=this.entityOpContext.scene.find(e[0]);if(e[1]==="width"||e[1]==="height"||e[1]==="depth")return a.geometry.userData.parameters[e[1]];for(let n=1;nGi.equal(l,t));o!==void 0&&o!==-1&&n.locations.splice(o,1)}if(typeof e=="string"){let a=e,n=e;do{if(n=a,this.variables[a]===void 0)break;let o=this.variables[a].value;t&&this.variables[n]!==void 0&&this.variables[n].locations.push(t),a=o}while(typeof a=="string");return a}else return e}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(e=>e.data.name)}getVariableByName(e){for(let t of this.data.variables)if(t.data.name===e)return{variable:t.data,id:t.id}}getDynamicVariablePlayState(e){var t;return(t=this.variables[e])==null?void 0:t.dynamicVariablePlayState}setDynamicVariablePlayState(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariablePlayState=t)}getDynamicVariableToggleIsForward(e){var t;return(t=this.variables[e])==null?void 0:t.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariableToggleIsForward=t)}resetLib(e){for(let[t,i]of Object.entries(e.images))this.addImage(t,i.asset);for(let[t,i]of Object.entries(e.audios))this.addAudio(t,i.asset);for(let[t,i]of Object.entries(e.particles))this.addParticle(t,i.asset);for(let[t,i]of Object.entries(e.colors))this.addColor(t,i.asset);for(let[t,i]of Object.entries(e.fonts))this.addFont(t,i.asset);for(let[t,i]of Object.entries(e.materials))this.addMaterial(t,i.asset);for(let[t,i]of Object.entries(e.videos))this.addVideo(t,i.asset);for(let[t,i]of Object.entries(e.variables))this.addVariableHolder(t,i.asset)}updateLibByOp(e,t){e.path[0]==="images"?e.path.length===1&&e.type===1?this.addImage(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteImage(e.id):e.path[0]==="videos"?e.path.length===1&&e.type===1?this.addVideo(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVideo(e.id):e.path[0]==="audios"?e.path.length===1&&e.type===1?this.addAudio(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteAudio(e.id):e.path[0]==="particles"?e.path.length===1&&e.type===1?this.addParticle(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteParticle(e.id):e.path[0]==="colors"?e.path.length===1&&e.type===1?this.addColor(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteColor(e.id):e.path[0]==="materials"?e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteMaterial(e.id):e.path[0]==="fonts"?e.path.length===1&&e.type===1?this.addFont(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteFont(e.id):e.path[0]==="variables"?e.path.length===1&&e.type===1?this.addVariableHolder(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVariable(e.id):e.path[0]==="components"&&t.updateByLibOp(e,this)}updateByOp(e,t,i){var r;if(this.data=t,e.path[0]==="images")e.path.length===2&&e.type===0?e.props.data&&this.getImage(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addImage(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteImage(e.id);else if(e.path[0]==="videos")e.path.length===2&&e.type===0?e.props.data&&this.getVideo(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addVideo(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteVideo(e.id);else if(e.path[0]==="audios")e.path.length===2&&e.type===0?e.props.data&&this.addAudio(e.path[1],t.audios[e.path[1]]):e.path.length===1&&e.type===1?this.addAudio(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteAudio(e.id);else if(e.path[0]==="particles")e.path.length===2&&e.type===0?e.props.data&&this.addParticle(e.path[1],t.particles[e.path[1]]):e.path.length===1&&e.type===1?this.addParticle(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteParticle(e.id);else if(e.path[0]==="colors")e.path.length===2&&e.type===0?this.updateColor(e.path[1],e.props):e.path.length===1&&e.type===1?this.addColor(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteColor(e.id);else if(e.path[0]==="materials")e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data):e.path.length===1&&e.type===2?this.deleteMaterial(e.id):e.path.length>1&&this.getMaterial(e.path[1]).updateByOp(tr.drop(e,2),t.materials[e.path[1]],{shared:this,scene:i});else if(e.path[0]==="fonts")e.path.length===2&&e.type===0?this.updateFont(e.path[1],e,i):e.path.length===1&&e.type===1?this.addFont(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteFont(e.id);else if(e.path[0]==="variables")e.path.length===2&&e.type===0?"value"in e.props?this.updateVariable(e.path[1],e.props.value):"persistent"in e.props&&(this.variables[e.path[1]].persistent=e.props.persistent):e.path.length===1&&e.type===4?this.addVariableHolder(e.id,e.data):e.path.length===1&&e.type===5&&this.deleteVariable(e.id);else if(e.path[0]==="userAPIs"){if(e.path.length===1&&e.type===1)this.addUserAPI(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserAPI(e.id);else if(typeof e.path[1]=="string"){let s=t.userAPIs[e.path[1]];if(s){let a=e.type===0&&e.props.debounce===void 0,n=this.getUserAPI(e.path[1]);n instanceof HS?n.update(s):n==null||n.update(s,this,a)}}}else if(e.path[0]==="userWebhooks"){if(e.path.length===1&&e.type===1)this.addUserWebhook(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserWebhook(e.id);else if(typeof e.path[1]=="string"){let s=t.userWebhooks[e.path[1]];s&&((r=this.getUserWebhook(e.path[1]))==null||r.update(s))}}else e.path[0]==="lib"&&this.updateLibByOp(tr.drop(e,1),i)}updateFont(e,t,i){if(t.props.url){let r=this.getFont(e),s={...this.data.fonts[e],url:t.props.url};r.update(s),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(e,this)}}addUserAPI(e,t){var i,r;return this.userAPIs[e]?(this.userAPIs[e].update(t,this),!0):((i=this.openAIRealtime)==null?void 0:i.id)===e?(this.openAIRealtime.update(t),!0):((r=t.integration)==null?void 0:r.type)==="VoiceAssistant"?(this.openAIRealtime=new HS(t,e,this),!1):(this.userAPIs[e]=new qC(e,t,this),!1)}getUserAPI(e){var t;return((t=this.openAIRealtime)==null?void 0:t.id)===e?this.openAIRealtime:this.userAPIs[e]}getUserAPIs(){return this.userAPIs}deleteUserAPI(e){let t=this.userAPIs[e];t&&(t.dispose(),delete this.userAPIs[e])}addUserWebhook(e,t){return this.userWebhooks[e]?(this.userWebhooks[e].update(t),!0):(this.userWebhooks[e]=new gQ(e,t),!1)}getUserWebhook(e){return this.userWebhooks[e]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(e){let t=this.userWebhooks[e];t&&(t.dispose(),delete this.userWebhooks[e])}get scene(){return this.entityOpContext.scene}};new q1(vs.emptyData());var xl=class extends Vr{updateByPatchedOp(e,t,i){if(super.updateByPatchedOp(e,t,i),L8(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[r,s]of Object.entries(e.props)){let a=i.shared.material(s);this.material[Number(r)]=a}else if(Qt(e.path,["material"])&&this.material instanceof uo)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(tr.drop(e,1),t.material,i);else if(Qt(e.path,["materials","*"])&&Array.isArray(this.material)){let r=e.path[1];if("materials"in t&&rt.shared.material(n).getFlavor(i.flatShading,i.side,i.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe)],t.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let n=0;n{e instanceof uo&&(e instanceof oy||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}},WS=new M,qS=new ct,XS=new ct,MQ=new M,YS=new we,Ii=class extends xl{constructor(e,t,i){super(e,t),this.data=t,this.isSkinnedMesh=!1,this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new we().fromArray(t.bindMatrix),this.bindMatrixInverse=new we)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Ge&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof q1){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return vf.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return vf.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Qt(e.path,["geometry"])&&this.updateByPatchedOpGeometry(tr.drop(e,1),t.geometry,i)}removeInteractionGeometry(e){var t;(t=this.localGeometry)==null||t.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){var r;this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let s=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...s};this.localGeometry=Dd(h,t,this.data.flatShading,this)}let a,n,o;s.scaleBaked?[a,n,o]=s.scaleBaked:{width:a,height:n,depth:o}=s;let l=this.localGeometry.userData;l.sxPrev!==void 0&&ty(this.localGeometry.attributes,a/l.sxPrev,n/l.syPrev,o/l.szPrev),l.sxPrev=a,l.syPrev=n,l.szPrev=o}else{let s={...this.data.geometry,...e};(r=this.localGeometry)==null||r.dispose(),this.localGeometry=Dd(s,t,this.data.flatShading,this)}}refreshAttachedClonersInteractions(){for(let e of this.attachedSurfaceCloners)e.update()}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,i){var s;let r=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof zr&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),r||((s=i.scene)==null||s.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:s}}of i)this.updateMorphInfluences(r,t.shared.getVariable(s,[this.uuid,"morphTargetInfluences",r]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=t)}updateGeometryGroupsIfNeeded(){var e;Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(((e=this.geometry.getIndex())==null?void 0:e.count)??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,t){let i=this.geometry.userData.parameters;this.is2DType?e.set(0,0,i.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?e.fromArray(i.centerOffset):e.setScalar(0),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new ct,i=this.geometry.attributes.skinWeight;for(let r=0,s=i.count;r{for(let c of l.normals)l.result.add(c);l.result.divideScalar(l.normals.length)});for(let l=0;l{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Id=class extends Ii{constructor(e,t,i){super(e,t,i),this.data=t,this.hiddenMatrixOld=new we,this.smoothShading=!0,this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let i=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(e){var a,n,o;if(this.skipReactionUpdate===!0)return;let t=(a=this.localGeometry)==null?void 0:a.uuid,{originalGeometry:i,subdividedGeometry:r,subdivPointer:s}=zr.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=s,i!==void 0&&((n=this.originalGeometry)==null||n.dispose(),this.originalGeometry=i),r!==void 0&&((o=this.subdividedGeometry)==null||o.dispose(),this.subdividedGeometry=r??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,X1(this),Y1(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),e.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(r=>r.getFlavor(!1,r.side,r.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){zr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&zr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=zr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,Vr.prototype.raycast.call(this,e,t),this.localGeometry=i}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new $r,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;sa.setFromBufferAttribute(t),sa.getCenter(i),e.boundingSphere.radius=i.distanceTo(sa.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),sa.getSize(Ec),this.hasNonUniformScale&&Ec.divide(this.scale);let r={width:Ec.x,height:Ec.y,depth:Ec.z};return this.geometry.userData.parameters=r,r}updateBoundingSphere(e){let t=this.originalGeometry;sa.min.set(e[0],e[2],e[4]),sa.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(sa.min.applyMatrix4(this.shearScaleInv),sa.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new $r);let i=t.boundingSphere.center;sa.getCenter(i),t.boundingSphere.radius=i.distanceTo(sa.max)}freeSubdivPointer(){var e,t;this.subdivPointer&&(zr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,(e=this.originalGeometry)==null||e.dispose(),(t=this.subdividedGeometry)==null||t.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),this.localGeometry&&this.createGeometryByControls(t)}},QS=-1,PQ=1,DQ={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},IQ={polygon_center:0,edge:1,vertex:2},tp=(e,t)=>(i,r)=>!t||i===0||e===0?0:e*r/100,mt=(e,t)=>{let i=Math.abs(t),r=i*-1;return(e-QS)*(i-r)/(PQ-QS)+r},OQ=new M,ip=new M,RQ=new M,LQ=new M;function Ah(e,t){let i=RQ.fromArray(e),r=LQ.fromArray(t);ip.copy(r).sub(i);let s=ip.length();return ip.normalize().multiplyScalar(s*.5),OQ.copy(i).add(ip).toArray()}var ys=new pr,rp=new M,Lf=new M,Vo=new M;function zQ(e){let t=[];for(let i=0;i<=e.index.count;i++)if(rp.fromArray(e.index.array,i*3),ys.setFromAttributeAndIndices(e.attributes.position,rp.x,rp.y,rp.z),ys.getNormal(Lf),ys.getMidpoint(Vo),!(isNaN(Vo.x)||isNaN(Vo.y)||isNaN(Vo.z))){let{a:r,b:s,c:a}=ys,n=r.toArray(),o=s.toArray(),l=a.toArray(),h=r.distanceTo(s),c=s.distanceTo(a),d=a.distanceTo(r),u=Ah(n,o),p=Ah(o,l),f=Ah(l,n),g=[h,c,d],m=Math.max(...g),v=g.filter(w=>Math.round(w)===Math.round(m)).length>1,y=[],x=ys.getMidpoint(Vo).toArray();m===h&&!v&&(y=[p,f,f],x=u),m===c&&!v&&(y=[u,f,f],x=p),m===d&&!v&&(y=[u,p,p],x=f),v&&(y=[u,p,f]),t.push({vertices:[n,o,l],faceCenters:y,midpoint:x,norm:ys.getNormal(Lf).toArray()})}return t}function BQ(e){let t=[],{position:i}=e.attributes;for(let r=0;r.5*(1-Math.cos(e*Math.PI)),NQ=class{constructor(){this.perlin=new Array(4096)}noise(e,t=0,i=0){if(this.perlin==null){this.perlin=new Array(4096);for(let m=0;m<4096;m++)this.perlin[m]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),i<0&&(i=-i);let r=Math.floor(e),s=Math.floor(t),a=Math.floor(i),n=e-r,o=t-s,l=i-a,h,c,d=0,u=.5,p,f,g;for(let m=0;m=1&&(r++,n--),o>=1&&(s++,o--),l>=1&&(a++,l--)}return d}noiseSeed(e){let t=(()=>{let i,r;return{setSeed(s){r=i=(s??Math.random()*4294967296)>>>0},getSeed(){return i},rand(){return r=(1664525*r+1013904223)%4294967296,r/4294967296}}})();t.setSeed(e),this.perlin=new Array(4096);for(let i=0;i<4096;i++)this.perlin[i]=t.rand()}},kQ=NQ,ZS=new M,KS=new we,JS=new Hh;function $S(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var Q1=class extends Ii{constructor(e,t,i){super(e,t,i),this.data=t}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){var t;let e=this.dataPatched;return((t=this.font)==null?void 0:t.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign))??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){var e;return(((e=this.font)==null?void 0:e.ascender)??1)*this.fontScale}get descender(){var e;return(((e=this.font)==null?void 0:e.descender)??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,t){let{matrixWorld:i}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(KS.copy(i).invert(),JS.copy(e.ray).applyMatrix4(KS),JS.intersectBox(this.singleBBox,ZS))){let r=ZS.applyMatrix4(i),s=e.ray.origin.distanceTo(r);t.push({distance:s,point:r.clone(),object:this})}}},Or=1e-4,aa,kT,VT,jT,eA=new M,tA=new M;KC.then(e=>{aa=e,kT=[aa.get_face_center,aa.get_edge_midpoint,aa.get_vertex_position],VT=[aa.get_face_normal,aa.get_edge_normal,aa.get_vertex_normal],jT=[aa.face_count,aa.edge_count,aa.vertex_count]});var VQ=new we,jQ=new we,Rn=new M,sp=new M,Cc=new M,Wg=new M,GQ=new M,HQ=new M,WQ=class{constructor(e,t){this.data=e,this.is3D=t,this.perlin=new kQ,e.noiseType==="perlin"?(this.perlin.noiseSeed(e.seed),t?this.noise=(i,r,s)=>this.perlin.noise(i,r,s):this.noise=i=>this.perlin.noise(i)):t?this.noise=x7((0,q0.default)(e.seed)):this.noise=y7((0,q0.default)(e.seed))}},bs=class extends D1(kt){constructor(e,t){super(),this.parameters=t,this.objectForSample=void 0,this._pendingMediaLoad=!1,this.random=null,this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let t of this.children)t instanceof gr&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof gr&&t.object===e&&(t.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"){if(!this.parameters.toObject.object)t=0;else if(e===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.parameters.type==="toObject"&&this.objectForSample){let i=this.children;if(i.length===t)return;if(i.length0){let d=Math.round(n.length*t.count/100);this._updateCount(d)}else{let d=this.objectForSample.geometry.getAttribute("position");if(!d||isNaN(d.count)||d.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let o=new b7(this.objectForSample).build(),l=DQ[t.axis],h=this.children;o.setRandomGenerator((0,q0.default)(this.object.uuid+t.seed));for(let[d,u]of h.entries()){let p=d*(r.freqScale/10)+r.movement,f=s.noise(p,p,p),g=d+1,m=a(g,mt(f,r.rotation[0])),v=a(g,mt(f,r.rotation[1])),y=a(g,mt(f,r.rotation[2]));t.spreadType==="random"?o.sample(Cc,Wg):(n.length&&(Cc.fromArray(n[d].pos),Wg.fromArray(n[d].norm)),this.objectForSample instanceof Id&&Cc.applyMatrix4(VQ.copy(this.objectForSample.matrixWorld).invert())),Cc.applyMatrix4(this.object.hiddenMatrix.clone().invert()),u.position.copy(Cc),Rn.fromArray(l);let x=t.align==="normal"?Wg:this.object.getWorldDirection(HQ),w=sp.fromArray(t.position);sp.x+=a(g,mt(f,r.position[0])),sp.y+=a(g,mt(f,r.position[1])),sp.z+=a(g,mt(f,r.position[2]));let _=Math.acos(x.dot(Rn)),b=GQ.crossVectors(Rn,x).normalize(),A=jQ.makeRotationAxis(b,_),S=x.clone().cross(this.object.up).normalize(),E=S.clone().cross(x).normalize(),C=new we().makeBasis(S,x,E),T=new M(Rn.y,Rn.z,Rn.x).normalize(),D=T.clone().cross(Rn).normalize(),O=new we().makeBasis(T,Rn,D).invert(),P=new we().multiplyMatrices(C,O);u.rotation.setFromRotationMatrix(P),w.applyMatrix4(A),u.position.add(w),u.rotation.x=u.rotation.x+i.x+m,u.rotation.y=u.rotation.y+i.y+v,u.rotation.z=u.rotation.z+i.z+y,u.scale.setScalar(1),u.scale.x=u.scale.x+t.scale[0]+a(g,mt(f,r.scale[0]))||Or,u.scale.y=u.scale.y+t.scale[1]+a(g,mt(f,r.scale[1]))||Or,u.scale.z=u.scale.z+t.scale[2]+a(g,mt(f,r.scale[2]))||Or,u.scale.multiply(this.object.scale),u.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType,t=new Map,i=(s,a)=>{let n=Math.round(s[0]*1e4)+"_"+Math.round(s[1]*1e4)+"_"+Math.round(s[2]*1e4),o=t.get(n);o?(o.pos[0]+=s[0],o.pos[1]+=s[1],o.pos[2]+=s[2],o.norm[0]+=a[0],o.norm[1]+=a[1],o.norm[2]+=a[2],o.count+=1):t.set(n,{pos:[...s],norm:[...a],count:1})};if(e==="random")return[];if(this.objectForSample instanceof Id){let s=this.objectForSample,a=IQ[e],n=jT[a],o=kT[a],l=VT[a],h=n(s.subdivPointerNew);for(let c=0;c<=h-1;c++){let d=o(s.subdivPointerNew,c),u=l(s.subdivPointerNew,c);eA.fromArray(d).applyMatrix4(s.matrixWorld),tA.fromArray(u),i(eA.toArray(),tA.toArray())}}else(this.objectForSample.geometry.index?zQ(this.objectForSample.geometry):BQ(this.objectForSample.geometry)).forEach((s,a)=>{e==="polygon_center"&&i(s.midpoint,s.norm),e==="vertex"&&(i(s.vertices[0],s.norm),i(s.vertices[1],s.norm),i(s.vertices[2],s.norm)),e==="edge"&&(i(s.faceCenters[0],s.norm),i(s.faceCenters[1],s.norm),i(s.faceCenters[2],s.norm))});let r=Array.from(t.values());for(let s of r)s.pos[0]/=s.count,s.pos[1]/=s.count,s.pos[2]/=s.count,s.norm[0]/=s.count,s.norm[1]/=s.count,s.norm[2]/=s.count;return r}updateState(e,t){var i;if(this.parameters=rm(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),(i=this.object.parent)==null||i.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let r=t.find(this.parameters.toObject.object);r instanceof Vr?this.objectForSample=r:this.objectForSample=void 0,this.matrix=new we,this.hiddenMatrix=new we,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,r&&r.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}},Gd=e=>{var t;return t=class extends e{},t.geometryHelper=new Xs(30,30,30),t},ap=new Hh,qg=new $r,iA=new we,Hd=(e,t,i,r,s=!1,a=e)=>{let n=t,o=a.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),qg.copy(n.boundingSphere),qg.applyMatrix4(o),i.ray.intersectsSphere(qg)===!1||(iA.copy(o).invert(),ap.copy(i.ray).applyMatrix4(iA),n.boundingBox!==null&&ap.intersectsBox(n.boundingBox)===!1))return;let l,h,c,d,u=n.index,p=n.attributes.position,f=n.drawRange,g,m;if(s===!1){let y=Math.max(0,f.start),x=Math.min(u.count,f.start+f.count);for(g=y,m=x;gE)continue;b.applyMatrix4(a.matrixWorld);let P=i.ray.origin.distanceTo(b);Pi.far||r.push({distance:P,point:_.clone().applyMatrix4(a.matrixWorld),object:e})}}function v(y,x,w,_,b,A,S){let E=new M,C=new M,T=new M,D=new M,O=new M;if(E.fromBufferAttribute(_,b),C.fromBufferAttribute(_,A),T.fromBufferAttribute(_,S),w.intersectTriangle(E,C,T,!1,D)===null)return null;O.copy(D),O.applyMatrix4(y.matrixWorld);let P=x.ray.origin.distanceTo(O);return Px.far?null:{faceIndex:1,distance:P,point:O.clone(),object:y}}},np=new M,cs=new bo,qQ=class extends zd{constructor(e){let t=new Ge,i=new wo({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={},n=new et(15711266),o=new et(15711266),l=new et(2857471);h("n1","n2",n),h("n2","n4",n),h("n4","n3",n),h("n3","n1",n),h("f1","f2",n),h("f2","f4",n),h("f4","f3",n),h("f3","f1",n),h("n1","f1",n),h("n2","f2",n),h("n3","f3",n),h("n4","f4",n),h("p","n1",o),h("p","n2",o),h("p","n3",o),h("p","n4",o),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l);function h(d,u,p){c(d,p),c(u,p)}function c(d,u){r.push(0,0,0),s.push(u.r,u.g,u.b),a[d]===void 0&&(a[d]=[]),a[d].push(r.length/3-1)}t.setAttribute("position",new Ie(r,3)),t.setAttribute("color",new Ie(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,t=this.pointMap;cs.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,r=1,s=.8;Os("n1",t,e,cs,-i,-r,s),Os("n2",t,e,cs,i,-r,s),Os("n3",t,e,cs,-i,r,s),Os("n4",t,e,cs,i,r,s);let a=s;Os("f1",t,e,cs,-i,-r,a),Os("f2",t,e,cs,i,-r,a),Os("f3",t,e,cs,-i,r,a),Os("f4",t,e,cs,i,r,a);let n=a,o=.5;Os("u1",t,e,cs,i*.7*o,r*1.1,n),Os("u2",t,e,cs,-i*.7*o,r*1.1,n),Os("u3",t,e,cs,0,r*(1.1+.9*o),n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Os(e,t,i,r,s,a,n){np.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;he.is=t=>"objectHelper"in t)(hy||(hy={}));var ac=(e,t)=>class extends I1(e){constructor(){super(...arguments),this.objectHelper=new t(this),this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof Kp&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Xs?(i.setScalar(0),r.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,r)}hideGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof Kp&&(r.visible=!1)}}},op=790,Wl=new M,Xg=new M,Yg=new lt,Qg=new M,Tc=new M,Zg=new M,Mr=class extends ac(bo,XQ){constructor(e="",t={...Sd.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=Lh.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this.super_Entity(e,t),this.previousProjectionMatrix=new we,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Xf(i*-.5,i*.5,r*.5,r*-.5,-5e4,1e4),this.perspCamera=new _r(45,i/r,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,i){typeof e=="number"&&(e=new M(e,t,i)),super.lookAt(e),this.getWorldPosition(Wl),this.targetOffset=Wl.distanceTo(e)}getTarget(e=new M){return this.getWorldDirection(Xg),this.getWorldPosition(Wl),Xg.multiplyScalar(this.targetOffset),e.copy(Wl).add(Xg),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Wl),Wl.distanceTo(e)}updateUp(){this.getWorldQuaternion(Yg),Qg.set(0,0,1).applyQuaternion(Yg),Tc.copy(kt.DEFAULT_UP),this.isUpVectorFlipped&&Tc.negate(),Tc.applyQuaternion(Yg),Zg.copy(kt.DEFAULT_UP).projectOnPlane(Qg),this.angleOffsetFromUp=Zg.angleTo(Tc),this.angleOffsetFromUp*=Zg.cross(Tc).dot(Qg)>=0?1:-1}updateTransformState(e,t){let i=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let t=e.getWorldPosition(new M),i=e.getWorldDirection(new M).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let t=this.getWorldDirection(new M).multiplyScalar(this.targetOffset);return{position:e.clone().sub(t),target:e}}getViewToObject(e){let t=new M;return e.getWorldPosition(t),this.getViewToTarget(t)}setViewplaneSize(e,t,i=!1){if(this.aspect=e/t,i){let r=e>t?this.aspect:1,s=e>t?1:this.aspect;this.left=-op*.5*r,this.right=op*.5*r,this.top=op*.5*(1/s),this.bottom=-op*.5*(1/s)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,i,r,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,i,r,s,a):this.orthoCamera.setViewOffset(e,t,i,r,s,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return $v(t,e)}updateCameraSubtype(e,t){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(i,t.zoom),t.near!==void 0&&this.setNear(i,t.near),t.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},ql=new we,YQ=new we;function rA(e){let t=!1;return e.scene.objects.traverse((i,r)=>{var s;((s=r.geometry)==null?void 0:s.type)==="BooleanGeometry"&&(t=!0)}),t}var ul=class extends xl{constructor(e,t,i){super(e,t),this.data=t,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new Ge,this.onAfterRender=(r,s,a,n,o,l)=>{super.onAfterRender(r,s,a,n,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){var r;if(this.booleanMeshSetAddress!==-1&&!e)return;for(let s=0;s0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){ql.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Za.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;Za.transformMeshSet(a.booleanMeshSetAddress,ql),a.booleanMatrixInvOld.copy(ql).invert(),a.booleanWasTransformed=!1}else a instanceof ul&&a.needsTransformForDownstream===!0?(Za.transformMeshSet(a.booleanMeshSetAddress,ql),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Za.transformMeshSet(a.booleanMeshSetAddress,YQ.multiplyMatrices(ql,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(ql).invert(),a.booleanWasTransformed=!1)}catch(n){console.error(n),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Za.hasOpenEdges(a.booleanMeshSetAddress)===!1||s===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new Ie([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Za.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new Ge,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=Za.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,X1(this),Y1(this)}dispose(){super.dispose(),this.geometry.dispose()}},zf;(e=>{function t(i){return Tt.is(i)&&i instanceof Ud}e.is=t})(zf||(zf={}));var Z1=(e,t)=>class extends ac(e,t){updateState_Light(i,r){this.updateState_Entity(i,r),i.color!==void 0&&(this.color=r.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity),i.depth!==void 0&&(this.shadow.camera.far=i.depth,this.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows)}},Ns=e=>e instanceof Vr,un=e=>e!==null&&e instanceof ul,QQ=e=>e instanceof Mr,ZQ=e=>zf.is(e),cy=e=>hy.is(e),KQ=new M(1,1,1),sA=new M,JQ=new M,aA=new lt,Wd=class extends Gd($U){constructor(e,t=15){super(t),this.object=e,this.dummy=new hn,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){Hd(this.object,Wd.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(sA,aA,JQ),this.matrix.compose(sA,aA,KQ),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}},Mh=class extends ac(hn,Wd){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t),"buffer"in e&&Object.keys(e).length===1&&t.scene.reloadSplats()}},id=class extends ac(hn,Wd){constructor(e,t,i){super(),this.super_Entity(e,t),this.context=i,this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t)}},GT={RED:0,GREEN:1,BLUE:2,ALPHA:3},qd="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",$Q=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale;uniform vec4 kernel64[32];varying vec2 vUv;void main(){ #ifdef FOREGROUND vec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale; #else float CoC=texture2D(cocBuffer,vUv).g*scale; #endif if(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{ #ifdef FOREGROUND vec2 step=texelSize*max(CoC,CoCNearFar.g*scale); #else vec2 step=texelSize*CoC; #endif vec4 acc=vec4(0.0);for(int i=0;i<32;++i){vec4 kernel=kernel64[i];vec2 uv=step*kernel.xy+vUv;acc+=texture2D(inputBuffer,uv);uv=step*kernel.zw+vUv;acc+=texture2D(inputBuffer,uv);}gl_FragColor=acc/64.0;}}`,lp=class extends Dt{constructor(e=!1,t=!1){super({name:"BokehMaterial",defines:{PASS:e?"2":"1"},uniforms:{kernel64:new ye(null),kernel16:new ye(null),inputBuffer:new ye(null),cocBuffer:new ye(null),texelSize:new ye(new j),scale:new ye(1)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:$Q,vertexShader:qd}),this.toneMapped=!1,t&&(this.defines.FOREGROUND="1"),this.generateKernel()}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}set cocBuffer(e){this.uniforms.cocBuffer.value=e}setCoCBuffer(e){this.uniforms.cocBuffer.value=e}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}getScale(e){return this.uniforms.scale.value=e}setScale(e){this.uniforms.scale.value=e}generateKernel(){let e=2.39996323,t=new Float32Array(128),i=new Float32Array(32),r=0,s=0;for(let o=0;o<80;++o){let l=o*e,h=Math.sqrt(o)/Math.sqrt(80),c=h*Math.cos(l),d=h*Math.sin(l);o%5===0?(i[s++]=c,i[s++]=d):(t[r++]=c,t[r++]=d)}let a=[],n=[];for(let o=0;o<128;)a.push(new ct(t[o++],t[o++],t[o++],t[o++]));for(let o=0;o<32;)n.push(new ct(i[o++],i[o++],i[o++],i[o++]));this.uniforms.kernel64.value=a,this.uniforms.kernel16.value=n}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}};function nA(e,t,i){return e*(t-i)-t}function dy(e,t,i){return Math.min(Math.max((e+t)/(t-i),0),1)}var eZ=`#include #include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform float focusDistance;uniform float focusRange;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }void main(){float depth=readDepth(vUv); #ifdef PERSPECTIVE_CAMERA float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar); #else float linearDepth=depth; #endif float signedDistance=linearDepth-focusDistance;float magnitude=smoothstep(0.0,focusRange,abs(signedDistance));gl_FragColor.rg=magnitude*vec2(step(signedDistance,0.0),step(0.0,signedDistance));}`,tZ=class extends Dt{constructor(e){super({name:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new ye(null),focusDistance:new ye(0),focusRange:new ye(0),cameraNear:new ye(.3),cameraFar:new ye(1e3)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:eZ,vertexShader:qd}),this.toneMapped=!1,this.uniforms.focalLength=this.uniforms.focusRange,this.adoptCameraSettings(e)}get near(){return this.uniforms.cameraNear.value}get far(){return this.uniforms.cameraFar.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=_n){this.depthBuffer=e,this.depthPacking=t}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(e){this.uniforms.focusDistance.value=e}get worldFocusDistance(){return-nA(this.focusDistance,this.near,this.far)}set worldFocusDistance(e){this.focusDistance=dy(-e,this.near,this.far)}getFocusDistance(e){this.uniforms.focusDistance.value=e}setFocusDistance(e){this.uniforms.focusDistance.value=e}get focalLength(){return this.focusRange}set focalLength(e){this.focusRange=e}get focusRange(){return this.uniforms.focusRange.value}set focusRange(e){this.uniforms.focusRange.value=e}get worldFocusRange(){return-nA(this.focusRange,this.near,this.far)}set worldFocusRange(e){this.focusRange=dy(-e,this.near,this.far)}getFocalLength(e){return this.focusRange}setFocalLength(e){this.focusRange=e}adoptCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof _r?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},iZ=`#include #include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25; #include #include }`,rZ="uniform vec2 texelSize;uniform vec2 halfTexelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize*vec2(kernel)+halfTexelSize)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}",oA=class extends Dt{constructor(e=new j){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new ye(null),texelSize:new ye(new j),halfTexelSize:new ye(new j),kernel:new ye(0),scale:new ye(1)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:iZ,vertexShader:rZ}),this.toneMapped=!1,this.setTexelSize(e.x,e.y)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.inputBuffer=e}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}getScale(){return this.uniforms.scale.value}setScale(e){this.uniforms.scale.value=e}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(e){this.uniforms.kernel.value=e}setKernel(e){this.kernel=e}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t),this.uniforms.halfTexelSize.value.set(e,t).multiplyScalar(.5)}setSize(e,t){let i=this.uniforms;i.texelSize.value.set(1/e,1/t),i.halfTexelSize.value.copy(i.texelSize.value).multiplyScalar(.5)}},sZ=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel; #include }`,aZ=class extends Dt{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new ye(null),opacity:new ye(1)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:sZ,vertexShader:qd}),this.toneMapped=!1}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}getOpacity(e){return this.uniforms.opacity.value}setOpacity(e){this.uniforms.opacity.value=e}},nZ=`varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1; #if THREE_REVISION < 143 #define luminance(v) linearToRelativeLuminance(v) #endif #if EDGE_DETECTION_MODE != 0 varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5; #endif #if EDGE_DETECTION_MODE == 1 #include #endif #if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1 #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);} #elif PREDICATION_MODE == 2 uniform sampler2D predicationBuffer;vec3 gatherNeighbors(){float p=texture2D(predicationBuffer,vUv).r;float pLeft=texture2D(predicationBuffer,vUv0).r;float pTop=texture2D(predicationBuffer,vUv1).r;return vec3(p,pLeft,pTop);} #endif #if PREDICATION_MODE != 0 vec2 calculatePredicatedThreshold(){vec3 neighbours=gatherNeighbors();vec2 delta=abs(neighbours.xx-neighbours.yz);vec2 edges=step(PREDICATION_THRESHOLD,delta);return PREDICATION_SCALE*EDGE_THRESHOLD*(1.0-PREDICATION_STRENGTH*edges);} #endif #if EDGE_DETECTION_MODE != 0 uniform sampler2D inputBuffer; #endif void main(){ #if EDGE_DETECTION_MODE == 0 const vec2 threshold=vec2(DEPTH_THRESHOLD); #elif PREDICATION_MODE != 0 vec2 threshold=calculatePredicatedThreshold(); #else const vec2 threshold=vec2(EDGE_THRESHOLD); #endif #if EDGE_DETECTION_MODE == 0 vec3 neighbors=gatherNeighbors();vec2 delta=abs(neighbors.xx-vec2(neighbors.y,neighbors.z));vec2 edges=step(threshold,delta);if(dot(edges,vec2(1.0))==0.0){discard;}gl_FragColor=vec4(edges,0.0,1.0); #elif EDGE_DETECTION_MODE == 1 float l=luminance(texture2D(inputBuffer,vUv).rgb);float lLeft=luminance(texture2D(inputBuffer,vUv0).rgb);float lTop=luminance(texture2D(inputBuffer,vUv1).rgb);vec4 delta;delta.xy=abs(l-vec2(lLeft,lTop));vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}float lRight=luminance(texture2D(inputBuffer,vUv2).rgb);float lBottom=luminance(texture2D(inputBuffer,vUv3).rgb);delta.zw=abs(l-vec2(lRight,lBottom));vec2 maxDelta=max(delta.xy,delta.zw);float lLeftLeft=luminance(texture2D(inputBuffer,vUv4).rgb);float lTopTop=luminance(texture2D(inputBuffer,vUv5).rgb);delta.zw=abs(vec2(lLeft,lTop)-vec2(lLeftLeft,lTopTop));maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges.xy*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0); #elif EDGE_DETECTION_MODE == 2 vec4 delta;vec3 c=texture2D(inputBuffer,vUv).rgb;vec3 cLeft=texture2D(inputBuffer,vUv0).rgb;vec3 t=abs(c-cLeft);delta.x=max(max(t.r,t.g),t.b);vec3 cTop=texture2D(inputBuffer,vUv1).rgb;t=abs(c-cTop);delta.y=max(max(t.r,t.g),t.b);vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}vec3 cRight=texture2D(inputBuffer,vUv2).rgb;t=abs(c-cRight);delta.z=max(max(t.r,t.g),t.b);vec3 cBottom=texture2D(inputBuffer,vUv3).rgb;t=abs(c-cBottom);delta.w=max(max(t.r,t.g),t.b);vec2 maxDelta=max(delta.xy,delta.zw);vec3 cLeftLeft=texture2D(inputBuffer,vUv4).rgb;t=abs(c-cLeftLeft);delta.z=max(max(t.r,t.g),t.b);vec3 cTopTop=texture2D(inputBuffer,vUv5).rgb;t=abs(c-cTopTop);delta.w=max(max(t.r,t.g),t.b);maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0); #endif }`,oZ=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1; #if EDGE_DETECTION_MODE != 0 varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5; #endif void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,0.0);vUv1=vUv+texelSize*vec2(0.0,-1.0); #if EDGE_DETECTION_MODE != 0 vUv2=vUv+texelSize*vec2(1.0,0.0);vUv3=vUv+texelSize*vec2(0.0,1.0);vUv4=vUv+texelSize*vec2(-2.0,0.0);vUv5=vUv+texelSize*vec2(0.0,-2.0); #endif gl_Position=vec4(position.xy,1.0,1.0);}`,pm={DEPTH:0,LUMA:1,COLOR:2},lZ={DISABLED:0,DEPTH:1,CUSTOM:2},hZ=class extends Dt{constructor(e=new j,t=pm.COLOR){super({name:"EdgeDetectionMaterial",defines:{THREE_REVISION:Gh.replace(/\D+/g,""),LOCAL_CONTRAST_ADAPTATION_FACTOR:"2.0",EDGE_THRESHOLD:"0.1",DEPTH_THRESHOLD:"0.01",PREDICATION_MODE:"0",PREDICATION_THRESHOLD:"0.01",PREDICATION_SCALE:"2.0",PREDICATION_STRENGTH:"1.0",DEPTH_PACKING:"0"},uniforms:{inputBuffer:new ye(null),depthBuffer:new ye(null),predicationBuffer:new ye(null),texelSize:new ye(e)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:nZ,vertexShader:oZ}),this.toneMapped=!1,this.edgeDetectionMode=t}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=_n){this.depthBuffer=e,this.depthPacking=t}get edgeDetectionMode(){return Number(this.defines.EDGE_DETECTION_MODE)}set edgeDetectionMode(e){this.defines.EDGE_DETECTION_MODE=e.toFixed(0),this.needsUpdate=!0}getEdgeDetectionMode(){return this.edgeDetectionMode}setEdgeDetectionMode(e){this.edgeDetectionMode=e}get localContrastAdaptationFactor(){return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR)}set localContrastAdaptationFactor(e){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=e.toFixed("6"),this.needsUpdate=!0}getLocalContrastAdaptationFactor(){return this.localContrastAdaptationFactor}setLocalContrastAdaptationFactor(e){this.localContrastAdaptationFactor=e}get edgeDetectionThreshold(){return Number(this.defines.EDGE_THRESHOLD)}set edgeDetectionThreshold(e){this.defines.EDGE_THRESHOLD=e.toFixed("6"),this.defines.DEPTH_THRESHOLD=(e*.1).toFixed("6"),this.needsUpdate=!0}getEdgeDetectionThreshold(){return this.edgeDetectionThreshold}setEdgeDetectionThreshold(e){this.edgeDetectionThreshold=e}get predicationMode(){return Number(this.defines.PREDICATION_MODE)}set predicationMode(e){this.defines.PREDICATION_MODE=e.toFixed(0),this.needsUpdate=!0}getPredicationMode(){return this.predicationMode}setPredicationMode(e){this.predicationMode=e}set predicationBuffer(e){this.uniforms.predicationBuffer.value=e}setPredicationBuffer(e){this.uniforms.predicationBuffer.value=e}get predicationThreshold(){return Number(this.defines.PREDICATION_THRESHOLD)}set predicationThreshold(e){this.defines.PREDICATION_THRESHOLD=e.toFixed("6"),this.needsUpdate=!0}getPredicationThreshold(){return this.predicationThreshold}setPredicationThreshold(e){this.predicationThreshold=e}get predicationScale(){return Number(this.defines.PREDICATION_SCALE)}set predicationScale(e){this.defines.PREDICATION_SCALE=e.toFixed("6"),this.needsUpdate=!0}getPredicationScale(){return this.predicationScale}setPredicationScale(e){this.predicationScale=e}get predicationStrength(){return Number(this.defines.PREDICATION_STRENGTH)}set predicationStrength(e){this.defines.PREDICATION_STRENGTH=e.toFixed("6"),this.needsUpdate=!0}getPredicationStrength(){return this.predicationStrength}setPredicationStrength(e){this.predicationStrength=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},cZ=`#include #include #include #define packFloatToRGBA(v) packDepthToRGBA(v) #define unpackRGBAToFloat(v) unpackRGBAToDepth(v) #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv; #if THREE_REVISION < 143 #define luminance(v) linearToRelativeLuminance(v) #endif #if THREE_REVISION >= 137 vec4 sRGBToLinear(const in vec4 value){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);} #endif float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }float getViewZ(const in float depth){ #ifdef PERSPECTIVE_CAMERA return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); #else return orthographicDepthToViewZ(depth,cameraNear,cameraFar); #endif }FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0; #ifdef ENCODE_OUTPUT #include #endif #include }`,dZ="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEADvoid main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORTgl_Position=vec4(position.xy,1.0,1.0);}",Rs={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"},uy=class extends Dt{constructor(e,t,i,r,s=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:Gh.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new ye(null),depthBuffer:new ye(null),resolution:new ye(new j),texelSize:new ye(new j),cameraNear:new ye(.3),cameraFar:new ye(1e3),aspect:new ye(1),time:new ye(0)},blending:Oi,depthWrite:!1,depthTest:!1,dithering:s}),this.toneMapped=!1,e&&this.setShaderParts(e),t&&this.setDefines(t),i&&this.setUniforms(i),this.adoptCameraSettings(r)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=_n){this.depthBuffer=e,this.depthPacking=t}setShaderParts(e){return this.fragmentShader=cZ.replace(Rs.FRAGMENT_HEAD,e.get(Rs.FRAGMENT_HEAD)).replace(Rs.FRAGMENT_MAIN_UV,e.get(Rs.FRAGMENT_MAIN_UV)).replace(Rs.FRAGMENT_MAIN_IMAGE,e.get(Rs.FRAGMENT_MAIN_IMAGE)),this.vertexShader=dZ.replace(Rs.VERTEX_HEAD,e.get(Rs.VERTEX_HEAD)).replace(Rs.VERTEX_MAIN_SUPPORT,e.get(Rs.VERTEX_MAIN_SUPPORT)),this.needsUpdate=!0,this}setDefines(e){for(let t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(let t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(let t of e)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(e){this.encodeOutput!==e&&(e?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(e){return this.encodeOutput}setOutputEncodingEnabled(e){this.encodeOutput=e}get time(){return this.uniforms.time.value}set time(e){this.uniforms.time.value=e}setDeltaTime(e){this.uniforms.time.value+=e}adoptCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof _r?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){let i=this.uniforms;i.resolution.value.set(e,t),i.texelSize.value.set(1/e,1/t),i.aspect.value=e/t}static get Section(){return Rs}},uZ=`#include #if THREE_REVISION < 143 #define luminance(v) linearToRelativeLuminance(v) #endif #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef RANGE uniform vec2 range; #elif defined(THRESHOLD) uniform float threshold;uniform float smoothing; #endif varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb); #ifdef RANGE float low=step(range.x,l);float high=step(l,range.y);l*=low*high; #elif defined(THRESHOLD) l=smoothstep(threshold,threshold+smoothing,l); #endif #ifdef COLOR gl_FragColor=vec4(texel.rgb*l,l); #else gl_FragColor=vec4(l); #endif }`,pZ=class extends Dt{constructor(e=!1,t=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:Gh.replace(/\D+/g,"")},uniforms:{inputBuffer:new ye(null),threshold:new ye(0),smoothing:new ye(1),range:new ye(null)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:uZ,vertexShader:qd}),this.toneMapped=!1,this.colorOutput=e,this.luminanceRange=t}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get threshold(){return this.uniforms.threshold.value}set threshold(e){this.smoothing>0||e>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=e}getThreshold(){return this.threshold}setThreshold(e){this.threshold=e}get smoothing(){return this.uniforms.smoothing.value}set smoothing(e){this.threshold>0||e>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=e}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(e){this.smoothing=e}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(e){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(e){e?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(e){return this.colorOutput}setColorOutputEnabled(e){this.colorOutput=e}get useRange(){return this.luminanceRange!==null}set useRange(e){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(e){e!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=e,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(e){this.luminanceRange=e}},fZ=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef MASK_PRECISION_HIGH uniform mediump sampler2D maskTexture; #else uniform lowp sampler2D maskTexture; #endif #if MASK_FUNCTION != 0 uniform float strength; #endif varying vec2 vUv;void main(){ #if COLOR_CHANNEL == 0 float mask=texture2D(maskTexture,vUv).r; #elif COLOR_CHANNEL == 1 float mask=texture2D(maskTexture,vUv).g; #elif COLOR_CHANNEL == 2 float mask=texture2D(maskTexture,vUv).b; #else float mask=texture2D(maskTexture,vUv).a; #endif #if MASK_FUNCTION == 0 #ifdef INVERTED mask=step(mask,0.0); #else mask=1.0-step(mask,0.0); #endif #else mask=clamp(mask*strength,0.0,1.0); #ifdef INVERTED mask=1.0-mask; #endif #endif #if MASK_FUNCTION == 2 gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask); #else gl_FragColor=mask*texture2D(inputBuffer,vUv); #endif }`,HT={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},mZ=class extends Dt{constructor(e=null){super({name:"MaskMaterial",uniforms:{maskTexture:new ye(e),inputBuffer:new ye(null),strength:new ye(1)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:fZ,vertexShader:qd}),this.toneMapped=!1,this.setColorChannel(GT.RED),this.setMaskFunction(HT.DISCARD)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}set maskTexture(e){this.uniforms.maskTexture.value=e,delete this.defines.MASK_PRECISION_HIGH,e.type!==Er&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}setMaskTexture(e){this.maskTexture=e}set colorChannel(e){this.defines.COLOR_CHANNEL=e.toFixed(0),this.needsUpdate=!0}setColorChannel(e){this.colorChannel=e}set maskFunction(e){this.defines.MASK_FUNCTION=e.toFixed(0),this.needsUpdate=!0}setMaskFunction(e){this.maskFunction=e}get inverted(){return this.defines.INVERTED!==void 0}set inverted(e){this.inverted&&!e?delete this.defines.INVERTED:e&&(this.defines.INVERTED="1"),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(e){this.inverted=e}get strength(){return this.uniforms.strength.value}set strength(e){this.uniforms.strength.value=e}getStrength(){return this.strength}setStrength(e){this.strength=e}},gZ=`#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize) #if __VERSION__ < 300 #define round(v) floor(v + 0.5) #endif #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;iend&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;iend&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){ #if !defined(DISABLE_CORNER_DETECTION) vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,1)).r;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).r;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,-2)).r;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,-2)).r;weights*=clamp(factor,0.0,1.0); #endif }void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){ #if !defined(DISABLE_CORNER_DETECTION) vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(1,0)).g;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).g;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(-2,0)).g;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(-2,1)).g;weights*=clamp(factor,0.0,1.0); #endif }void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){ #if !defined(DISABLE_DIAG_DETECTION) weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){ #endif vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOffset[1].y;d.x=coords.x;float e1=texture2D(inputBuffer,coords.xy).r;coords.z=searchXRight(vOffset[0].zw,vOffset[2].y);d.y=coords.z;d=round(resolution.xx*d+-vPixCoord.xx);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.zy,vec2(1,0)).r;weights.rg=area(sqrtD,e1,e2,subsampleIndices.y);coords.y=vUv.y;detectHorizontalCornerPattern(weights.rg,coords.xyzy,d); #if !defined(DISABLE_DIAG_DETECTION) }else{e.r=0.0;} #endif }if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`,vZ="uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}",yZ=class extends Dt{constructor(e=new j,t=new j){super({name:"SMAAWeightsMaterial",defines:{MAX_SEARCH_STEPS_INT:"16",MAX_SEARCH_STEPS_FLOAT:"16.0",MAX_SEARCH_STEPS_DIAG_INT:"8",MAX_SEARCH_STEPS_DIAG_FLOAT:"8.0",CORNER_ROUNDING:"25",CORNER_ROUNDING_NORM:"0.25",AREATEX_MAX_DISTANCE:"16.0",AREATEX_MAX_DISTANCE_DIAG:"20.0",AREATEX_PIXEL_SIZE:"(1.0 / vec2(160.0, 560.0))",AREATEX_SUBTEX_SIZE:"(1.0 / 7.0)",SEARCHTEX_SIZE:"vec2(66.0, 33.0)",SEARCHTEX_PACKED_SIZE:"vec2(64.0, 16.0)"},uniforms:{inputBuffer:new ye(null),searchTexture:new ye(null),areaTexture:new ye(null),resolution:new ye(t),texelSize:new ye(e)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:gZ,vertexShader:vZ}),this.toneMapped=!1}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(e){this.uniforms.searchTexture.value=e}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(e){this.uniforms.areaTexture.value=e}setLookupTextures(e,t){this.searchTexture=e,this.areaTexture=t}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(e){let t=Math.min(Math.max(e,0),112);this.defines.MAX_SEARCH_STEPS_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setOrthogonalSearchSteps(e){this.orthogonalSearchSteps=e}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(e){let t=Math.min(Math.max(e,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(e){this.diagonalSearchSteps=e}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(e){e?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(e){this.diagonalDetection=e}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(e){let t=Math.min(Math.max(e,0),100);this.defines.CORNER_ROUNDING=t.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(t/100).toFixed("4"),this.needsUpdate=!0}setCornerRounding(e){this.cornerRounding=e}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(e){e?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(e){this.cornerDetection=e}setSize(e,t){let i=this.uniforms;i.texelSize.value.set(1/e,1/t),i.resolution.value.set(e,t)}},xZ=new bo,Ln=null;function bZ(){if(Ln===null){let e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]);Ln=new Ge,Ln.setAttribute!==void 0?(Ln.setAttribute("position",new tt(e,3)),Ln.setAttribute("uv",new tt(t,2))):(Ln.addAttribute("position",new tt(e,3)),Ln.addAttribute("uv",new tt(t,2)))}return Ln}var jr=class{constructor(e="Pass",t=new Jr,i=xZ){this.name=e,this.renderer=null,this.scene=t,this.camera=i,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){let t=this.getFullscreenMaterial();t!==null&&(t.needsUpdate=!0),this.rtt=!e}}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(e){let t=this.screen;t!==null?t.material=e:(t=new Jt(bZ(),e),t.frustumCulled=!1,this.scene===null&&(this.scene=new Jr),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=_n){}render(e,t,i,r,s){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,i){}dispose(){for(let e of Object.keys(this)){let t=this[e];if(t!==null&&typeof t=="object"&&typeof t.dispose=="function"){if(t instanceof Jr||t===this.renderer)continue;this[e].dispose()}}}},py=class extends jr{constructor(e,t=!0){super("CopyPass"),this.fullscreenMaterial=new aZ,this.needsSwap=!1,this.renderTarget=e,e===void 0&&(this.renderTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=t}get resize(){return this.autoResize}set resize(e){this.autoResize=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(e){this.autoResize=e}render(e,t,i,r,s){this.fullscreenMaterial.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){this.autoResize&&this.renderTarget.setSize(e,t)}initialize(e,t,i){i!==void 0&&(this.renderTarget.texture.type=i,i!==Er?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":e.outputEncoding===gt&&(this.renderTarget.texture.encoding=gt))}},wZ=class extends jr{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(e,t,i,r,s){let a=e.state.buffers.stencil;a.setLocked(!1),a.setTest(!1)}},Kg=new et,K1=class extends jr{constructor(e=!0,t=!0,i=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=e,this.depth=t,this.stencil=i,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(e,t,i){this.color=e,this.depth=t,this.stencil=i}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(e){this.overrideClearColor=e}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(e){this.overrideClearAlpha=e}render(e,t,i,r,s){let a=this.overrideClearColor,n=this.overrideClearAlpha,o=e.getClearAlpha(),l=a!==null,h=n>=0;l?(Kg.copy(e.getClearColor(Kg)),e.setClearColor(a,h?n:o)):h&&e.setClearAlpha(n),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),l?e.setClearColor(Kg,o):h&&e.setClearAlpha(o)}},zn=-1,Kr=class extends yr{constructor(e,t=zn,i=zn,r=1){super(),this.resizable=e,this.base=new j(1,1),this.preferred=new j(t,i),this.target=this.preferred,this.s=r}get width(){let{base:e,preferred:t,scale:i}=this,r;return t.width!==zn?r=t.width:t.height!==zn?r=Math.round(t.height*(e.width/Math.max(e.height,1))):r=Math.round(e.width*i),r}set width(e){this.preferredWidth=e}get height(){let{base:e,preferred:t,scale:i}=this,r;return t.height!==zn?r=t.height:t.width!==zn?r=Math.round(t.width/Math.max(e.width/Math.max(e.height,1),1)):r=Math.round(e.height*i),r}set height(e){this.preferredHeight=e}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(e){this.s!==e&&(this.s=e,this.preferred.setScalar(zn),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getScale(){return this.scale}setScale(e){this.scale=e}get baseWidth(){return this.base.width}set baseWidth(e){this.base.width!==e&&(this.base.width=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseWidth(){return this.base.width}setBaseWidth(e){this.base.width!==e&&(this.base.width=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get baseHeight(){return this.base.height}set baseHeight(e){this.base.height!==e&&(this.base.height=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(e){this.baseHeight=e}setBaseSize(e,t){(this.base.width!==e||this.base.height!==t)&&(this.base.set(e,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get preferredWidth(){return this.preferred.width}set preferredWidth(e){this.preferred.width!==e&&(this.preferred.width=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(e){this.preferredWidth=e}get preferredHeight(){return this.preferred.height}set preferredHeight(e){this.preferred.height!==e&&(this.preferred.height=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(e){this.preferredHeight=e}setPreferredSize(e,t){(this.preferred.width!==e||this.preferred.height!==t)&&(this.preferred.set(e,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}copy(e){this.base.set(e.getBaseWidth(),e.getBaseHeight()),this.preferred.set(e.getPreferredWidth(),e.getPreferredHeight()),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height)}static get AUTO_SIZE(){return zn}},Jg=!1,lA=class{constructor(e=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(e),this.meshCount=0,this.replaceMaterial=t=>{if(t.isMesh){let i;if(t.material.flatShading)switch(t.material.side){case Ar:i=this.materialsFlatShadedDoubleSide;break;case rr:i=this.materialsFlatShadedBackSide;break;default:i=this.materialsFlatShaded;break}else switch(t.material.side){case Ar:i=this.materialsDoubleSide;break;case rr:i=this.materialsBackSide;break;default:i=this.materials;break}this.originalMaterials.set(t,t.material),t.isSkinnedMesh?t.material=i[2]:t.isInstancedMesh?t.material=i[1]:t.material=i[0],++this.meshCount}}}setMaterial(e){if(this.disposeMaterials(),this.material=e,e!==null){let t=this.materials=[e.clone(),e.clone(),e.clone()];for(let i of t)i.uniforms=Object.assign({},e.uniforms),i.side=Ws;t[2].skinning=!0,this.materialsBackSide=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.side=rr,r}),this.materialsDoubleSide=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.side=Ar,r}),this.materialsFlatShaded=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.flatShading=!0,r}),this.materialsFlatShadedBackSide=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.flatShading=!0,r.side=rr,r}),this.materialsFlatShadedDoubleSide=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.flatShading=!0,r.side=Ar,r})}}render(e,t,i){let r=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,Jg){let s=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),e.render(t,i);for(let a of s)a[0].material=a[1];this.meshCount!==s.size&&s.clear()}else{let s=t.overrideMaterial;t.overrideMaterial=this.material,e.render(t,i),t.overrideMaterial=s}e.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let e=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of e)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return Jg}static set workaroundEnabled(e){Jg=e}},_Z=class extends jr{constructor(e,t,i=null){super("RenderPass",e,t),this.needsSwap=!1,this.clearPass=new K1,this.overrideMaterialManager=i===null?null:new lA(i),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}get renderToScreen(){return super.renderToScreen}set renderToScreen(e){super.renderToScreen=e,this.clearPass.renderToScreen=e}get overrideMaterial(){let e=this.overrideMaterialManager;return e!==null?e.material:null}set overrideMaterial(e){let t=this.overrideMaterialManager;e!==null?t!==null?t.setMaterial(e):this.overrideMaterialManager=new lA(e):t!==null&&(t.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(e){this.overrideMaterial=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getSelection(){return this.selection}setSelection(e){this.selection=e}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(e){this.ignoreBackground=e}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(e){this.skipShadowMapUpdate=e}getClearPass(){return this.clearPass}render(e,t,i,r,s){let a=this.scene,n=this.camera,o=this.selection,l=n.layers.mask,h=a.background,c=e.shadowMap.autoUpdate,d=this.renderToScreen?null:t;o!==null&&n.layers.set(o.getLayer()),this.skipShadowMapUpdate&&(e.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(a.background=null),this.clearPass.enabled&&this.clearPass.render(e,t),e.setRenderTarget(d),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(e,a,n):e.render(a,n),n.layers.mask=l,a.background=h,e.shadowMap.autoUpdate=c}},hA=class extends jr{constructor(e,t,{resolutionScale:i=1,width:r=Kr.AUTO_SIZE,height:s=Kr.AUTO_SIZE,renderTarget:a}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new _Z(e,t,new xM({depthPacking:sM}));let n=this.renderPass;n.skipShadowMapUpdate=!0,n.ignoreBackground=!0;let o=n.getClearPass();o.overrideClearColor=new et(16777215),o.overrideClearAlpha=1,this.renderTarget=a,this.renderTarget===void 0&&(this.renderTarget=new Pt(1,1,{minFilter:_t,magFilter:_t,stencilBuffer:!1}),this.renderTarget.texture.name="DepthPass.Target");let l=this.resolution=new Kr(this,r,s,i);l.addEventListener("change",h=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,i,r,s){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t),this.renderTarget.setSize(i.width,i.height)}},Ot={SKIP:0,ADD:1,ALPHA:2,AVERAGE:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,EXCLUSION:8,LIGHTEN:9,MULTIPLY:10,DIVIDE:11,NEGATION:12,NORMAL:13,OVERLAY:14,REFLECT:15,SCREEN:16,SOFT_LIGHT:17,SUBTRACT:18},SZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x+y,1.0)*opacity+x*(1.0-opacity);}",AZ="vec3 blend(const in vec3 x,const in vec3 y,const in float opacity){return y*opacity+x*(1.0-opacity);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){float a=min(y.a,opacity);return vec4(blend(x.rgb,y.rgb,a),max(x.a,a));}",MZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",EZ="float blend(const in float x,const in float y){return(y==0.0)?y:max(1.0-(1.0-x)/y,0.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",CZ="float blend(const in float x,const in float y){return(y==1.0)?y:min(x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",TZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",PZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",DZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y-2.0*x*y)*opacity+x*(1.0-opacity);}",IZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",OZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",RZ="float blend(const in float x,const in float y){return(y>0.0)?min(x/y,1.0):1.0;}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",LZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-abs(1.0-x-y))*opacity+x*(1.0-opacity);}",zZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",BZ="float blend(const in float x,const in float y){return(x<0.5)?(2.0*x*y):(1.0-2.0*(1.0-x)*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",FZ="float blend(const in float x,const in float y){return(y==1.0)?y:min(x*x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",UZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}",NZ="float blend(const in float x,const in float y){return(y<0.5)?(2.0*x*y+x*x*(1.0-2.0*y)):(sqrt(x)*(2.0*y-1.0)+2.0*x*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",kZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x+y-1.0,0.0)*opacity+x*(1.0-opacity);}",VZ=new Map([[Ot.SKIP,null],[Ot.ADD,SZ],[Ot.ALPHA,AZ],[Ot.AVERAGE,MZ],[Ot.COLOR_BURN,EZ],[Ot.COLOR_DODGE,CZ],[Ot.DARKEN,TZ],[Ot.DIFFERENCE,PZ],[Ot.EXCLUSION,DZ],[Ot.LIGHTEN,IZ],[Ot.MULTIPLY,OZ],[Ot.DIVIDE,RZ],[Ot.NEGATION,LZ],[Ot.NORMAL,zZ],[Ot.OVERLAY,BZ],[Ot.REFLECT,FZ],[Ot.SCREEN,UZ],[Ot.SOFT_LIGHT,NZ],[Ot.SUBTRACT,kZ]]),jZ=class extends yr{constructor(e,t=1){super(),this.f=e,this.opacity=new ye(t)}getOpacity(){return this.opacity.value}setOpacity(e){this.opacity.value=e}get blendFunction(){return this.f}set blendFunction(e){this.f=e,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(e){this.blendFunction=e}getShaderCode(){return VZ.get(this.blendFunction)}},Aa={NONE:0,DEPTH:1,CONVOLUTION:2},Oa=class extends yr{constructor(e,t,{attributes:i=Aa.NONE,blendFunction:r=Ot.SCREEN,defines:s=new Map,uniforms:a=new Map,extensions:n=null,vertexShader:o=null}={}){super(),this.name=e,this.renderer=null,this.attributes=i,this.fragmentShader=t,this.vertexShader=o,this.defines=s,this.uniforms=a,this.extensions=n,this.blendMode=new jZ(r),this.blendMode.addEventListener("change",l=>this.setChanged())}getName(){return this.name}setRenderer(e){this.renderer=e}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(e){this.fragmentShader=e,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(e){this.vertexShader=e,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(e,t=_n){}update(e,t,i){}setSize(e,t){}initialize(e,t,i){}dispose(){for(let e of Object.keys(this)){let t=this[e];if(t!==null&&typeof t=="object"&&typeof t.dispose=="function"){if(t instanceof Jr||t===this.renderer)continue;this[e].dispose()}}}};function cA(e,t,i){for(let r of t){let s="$1"+e+r.charAt(0).toUpperCase()+r.slice(1),a=new RegExp("([^\\.])(\\b"+r+"\\b)","g");for(let n of i.entries())n[1]!==null&&i.set(n[0],n[1].replace(a,s))}}function GZ(e,t,i,r,s,a,n){let o=new Map([["fragment",t.getFragmentShader()],["vertex",t.getVertexShader()]]),l=o.get("fragment")!==void 0&&/mainImage/.test(o.get("fragment")),h=o.get("fragment")!==void 0&&/mainUv/.test(o.get("fragment")),c=[],d=[],u=!1,p=!1;if(o.get("fragment")===void 0)console.error("Missing fragment shader",t);else if(h&&n&Aa.CONVOLUTION)console.error("Effects that transform UV coordinates are incompatible with convolution effects",t);else if(!l&&!h)console.error("The fragment shader contains neither a mainImage nor a mainUv function",t);else{let f=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,g=uy.Section;if(h){let v=` ${e}MainUv(UV); `;i.set(g.FRAGMENT_MAIN_UV,i.get(g.FRAGMENT_MAIN_UV)+v),u=!0}if(o.get("vertex")!==null&&/mainSupport/.test(o.get("vertex"))){let v=` ${e}MainSupport(`;v+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(o.get("vertex"))?`vUv); `:`); `,i.set(g.VERTEX_MAIN_SUPPORT,i.get(g.VERTEX_MAIN_SUPPORT)+v),c=c.concat([...o.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(y=>y[1])),d=d.concat(c).concat([...o.get("vertex").matchAll(f)].map(y=>y[1]))}d=d.concat([...o.get("fragment").matchAll(f)].map(v=>v[1])),d=d.concat([...t.defines.keys()].map(v=>v.replace(/\([\w\s,]*\)/g,""))),d=d.concat([...t.uniforms.keys()]),t.uniforms.forEach((v,y)=>a.set(e+y.charAt(0).toUpperCase()+y.slice(1),v)),t.defines.forEach((v,y)=>s.set(e+y.charAt(0).toUpperCase()+y.slice(1),v)),cA(e,d,s),cA(e,d,o);let m=t.blendMode;if(r.set(m.blendFunction,m),l){let v=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,y=`${e}MainImage(color0, UV, `;n&Aa.DEPTH&&v.test(o.get("fragment"))&&(y+="depth, ",p=!0),y+=`color1); `;let x=e+"BlendOpacity";a.set(x,m.opacity),y+=`color0 = blend${m.blendFunction}(color0, color1, ${x}); `,i.set(g.FRAGMENT_MAIN_IMAGE,i.get(g.FRAGMENT_MAIN_IMAGE)+y),y=`uniform float ${x}; `,i.set(g.FRAGMENT_HEAD,i.get(g.FRAGMENT_HEAD)+y)}i.set(g.FRAGMENT_HEAD,i.get(g.FRAGMENT_HEAD)+o.get("fragment")+` `),o.get("vertex")!==null&&i.set(g.VERTEX_HEAD,i.get(g.VERTEX_HEAD)+o.get("vertex")+` `)}return{varyings:c,transformedUv:u,readDepth:p}}var Bf=class extends jr{constructor(e,...t){super("EffectPass"),this.fullscreenMaterial=new uy(null,null,null,e),this.effects=t.sort((i,r)=>r.attributes-i.attributes),this.skipRendering=!1,this.uniformCount=0,this.varyingCount=0,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(e){this.fullscreenMaterial.encodeOutput=e}get dithering(){return this.fullscreenMaterial.dithering}set dithering(e){let t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}verifyResources(){let e=this.renderer.capabilities,t=Math.min(e.maxFragmentUniforms,e.maxVertexUniforms);this.uniformCount>t&&console.warn("The current rendering context doesn't support more than "+t+" uniforms, but "+this.uniformCount+" were defined"),t=e.maxVaryings,this.varyingCount>t&&console.warn("The current rendering context doesn't support more than "+t+" varyings, but "+this.varyingCount+" were defined")}updateMaterial(){let e=uy.Section,t=new Map([[e.FRAGMENT_HEAD,""],[e.FRAGMENT_MAIN_UV,""],[e.FRAGMENT_MAIN_IMAGE,""],[e.VERTEX_HEAD,""],[e.VERTEX_MAIN_SUPPORT,""]]),i=new Map,r=new Map,s=new Map,a=new Set,n=0,o=0,l=0,h=!1,c=!1;for(let u of this.effects)if(u.blendMode.blendFunction===Ot.SKIP)l|=u.getAttributes()&Aa.DEPTH;else if(l&u.getAttributes()&Aa.CONVOLUTION)console.error("Convolution effects cannot be merged",u);else{l|=u.getAttributes();let p="e"+n++,f=GZ(p,u,t,i,r,s,l);if(o+=f.varyings.length,h=h||f.transformedUv,c=c||f.readDepth,u.extensions!==null)for(let g of u.extensions)a.add(g)}let d=/\bblend\b/g;for(let u of i.values()){let p=u.getShaderCode().replace(d,`blend${u.blendFunction}`);t.set(e.FRAGMENT_HEAD,t.get(e.FRAGMENT_HEAD)+p+` `)}l&Aa.DEPTH?(c&&t.set(e.FRAGMENT_MAIN_IMAGE,`float depth = readDepth(UV); `+t.get(e.FRAGMENT_MAIN_IMAGE)),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,h?(t.set(e.FRAGMENT_MAIN_UV,`vec2 transformedUv = vUv; `+t.get(e.FRAGMENT_MAIN_UV)),r.set("UV","transformedUv")):r.set("UV","vUv"),t.forEach((u,p,f)=>f.set(p,u.trim().replace(/^#/,` #`))),this.uniformCount=s.size,this.varyingCount=o,this.skipRendering=n===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderParts(t).setExtensions(a).setUniforms(s).setDefines(r)}recompile(){this.updateMaterial(),this.verifyResources()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e,t=_n){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(let i of this.effects)i.setDepthTexture(e,t)}render(e,t,i,r,s){for(let a of this.effects)a.update(e,t,r);if(!this.skipRendering||this.renderToScreen){let a=this.fullscreenMaterial;a.inputBuffer=t.texture,a.time+=r,e.setRenderTarget(this.renderToScreen?null:i),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(let i of this.effects)i.setSize(e,t)}initialize(e,t,i){this.renderer=e;for(let r of this.effects)r.initialize(e,t,i),r.addEventListener("change",s=>this.handleEvent(s));this.updateMaterial(),this.verifyResources(),i!==void 0&&i!==Er&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(let e of this.effects)e.dispose()}handleEvent(e){switch(e.type){case"change":this.recompile();break}}},HZ=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],J1=class extends jr{constructor({resolutionScale:e=.5,width:t=Kr.AUTO_SIZE,height:i=Kr.AUTO_SIZE,kernelSize:r=fm.LARGE}={}){super("KawaseBlurPass"),this.renderTargetA=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let s=this.resolution=new Kr(this,t,i,e);s.addEventListener("change",a=>this.setSize(s.baseWidth,s.baseHeight)),this.blurMaterial=new oA,this.ditheredBlurMaterial=new oA,this.ditheredBlurMaterial.uniforms.scale=this.blurMaterial.uniforms.scale,this.ditheredBlurMaterial.dithering=!0,this.dithering=!1,this.kernelSize=r}getResolution(){return this.resolution}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get scale(){return this.blurMaterial.scale}set scale(e){this.blurMaterial.scale=e}getScale(){return this.blurMaterial.scale}setScale(e){this.blurMaterial.scale=e}getKernelSize(){return this.kernelSize}setKernelSize(e){this.kernelSize=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,i,r,s){let a=this.scene,n=this.camera,o=this.renderTargetA,l=this.renderTargetB,h=HZ[this.kernelSize],c=this.blurMaterial,d=t,u,p;for(this.fullscreenMaterial=c,u=0,p=h.length-1;uthis.setSize(a.baseWidth,a.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(e,t,i,r,s){let a=this.fullscreenMaterial;a.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t),this.renderTarget.setSize(i.width,i.height)}initialize(e,t,i){i!==void 0&&i!==Er&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},qZ=class extends jr{constructor(e,t){super("MaskPass",e,t),this.needsSwap=!1,this.clearPass=new K1(!1,!1,!0),this.inverse=!1}get inverted(){return this.inverse}set inverted(e){this.inverse=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(e){this.inverted=e}render(e,t,i,r,s){let a=e.getContext(),n=e.state.buffers,o=this.scene,l=this.camera,h=this.clearPass,c=this.inverted?0:1,d=1-c;n.color.setMask(!1),n.depth.setMask(!1),n.color.setLocked(!0),n.depth.setLocked(!0),n.stencil.setTest(!0),n.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),n.stencil.setFunc(a.ALWAYS,c,4294967295),n.stencil.setClear(d),n.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?h.render(e,null):(h.render(e,t),h.render(e,i))),this.renderToScreen?(e.setRenderTarget(null),e.render(o,l)):(e.setRenderTarget(t),e.render(o,l),e.setRenderTarget(i),e.render(o,l)),n.color.setLocked(!1),n.depth.setLocked(!1),n.stencil.setLocked(!1),n.stencil.setFunc(a.EQUAL,1,4294967295),n.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),n.stencil.setLocked(!0)}},xs=class extends jr{constructor(e,t="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=e,this.inputBufferUniform=null,this.setInput(t)}setInput(e){if(this.inputBufferUniform=null,this.fullscreenMaterial!==null){let t=this.fullscreenMaterial.uniforms;t!==void 0&&t[e]!==void 0&&(this.inputBufferUniform=t[e])}}render(e,t,i,r,s){this.inputBufferUniform!==null&&t!==null&&(this.inputBufferUniform.value=t.texture),e.setRenderTarget(this.renderToScreen?null:i),e.render(this.scene,this.camera)}initialize(e,t,i){i!==void 0&&i!==Er&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},$g=1/1e3,XZ=1e3,YZ=class{constructor(){this.previousTime=0,this.currentTime=0,this.delta=0,this.fixedDelta=1e3/60,this.elapsed=0,this.timescale=1,this.fixedDeltaEnabled=!1,this.autoReset=!1}setFixedDeltaEnabled(e){return this.fixedDeltaEnabled=e,this}isAutoResetEnabled(e){return this.autoReset}setAutoResetEnabled(e){return typeof document<"u"&&document.hidden!==void 0&&(e?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this.autoReset=e),this}getDelta(){return this.delta*$g}getFixedDelta(){return this.fixedDelta*$g}setFixedDelta(e){return this.fixedDelta=e*XZ,this}getElapsed(){return this.elapsed*$g}getTimescale(){return this.timescale}setTimescale(e){return this.timescale=e,this}update(e){return this.fixedDeltaEnabled?this.delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=e!==void 0?e:performance.now(),this.delta=this.currentTime-this.previousTime),this.delta*=this.timescale,this.elapsed+=this.delta,this}reset(){return this.delta=0,this.elapsed=0,this.currentTime=performance.now(),this}handleEvent(e){document.hidden||(this.currentTime=performance.now())}dispose(){this.setAutoResetEnabled(!1)}},fm={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5},QZ=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D map; #else uniform lowp sampler2D map; #endif uniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=clamp(texture2D(map,uv)*intensity,0.0,1.0);}`,ZZ=class extends Oa{constructor({blendFunction:e=Ot.SCREEN,luminanceThreshold:t=.9,luminanceSmoothing:i=.025,resolutionScale:r=.5,intensity:s=1,width:a=Kr.AUTO_SIZE,height:n=Kr.AUTO_SIZE,kernelSize:o=fm.LARGE}={}){super("BloomEffect",QZ,{blendFunction:e,uniforms:new Map([["map",new ye(null)],["intensity",new ye(s)]])}),this.renderTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="Bloom.Target",this.renderTarget.texture.generateMipmaps=!1,this.uniforms.get("map").value=this.renderTarget.texture,this.luminancePass=new WZ({renderTarget:this.renderTarget,colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothingFactor=i,this.blurPass=new J1({resolutionScale:r,width:a,height:n,kernelSize:o});let l=this.blurPass.getResolution();l.addEventListener("change",h=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}get resolution(){return this.blurPass.resolution}getResolution(){return this.blurPass.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get dithering(){return this.blurPass.dithering}set dithering(e){this.blurPass.dithering=e}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(e){this.blurPass.kernelSize=e}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(e){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(e){this.uniforms.get("intensity").value=e}getIntensity(){return this.intensity}setIntensity(e){this.intensity=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}update(e,t,i){let r=this.renderTarget;this.luminancePass.enabled?(this.luminancePass.render(e,t,r),this.blurPass.render(e,r,r)):this.blurPass.render(e,t,r)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t),this.renderTarget.setSize(i.width,i.height),this.luminancePass.resolution.copy(i)}initialize(e,t,i){this.blurPass.initialize(e,t,i),i!==void 0&&(this.renderTarget.texture.type=i,e.outputEncoding===gt&&(this.renderTarget.texture.encoding=gt))}},KZ="uniform float brightness;uniform float contrast;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=inputColor.rgb+vec3(brightness-0.5);if(contrast>0.0){color/=vec3(1.0-contrast);}else{color*=vec3(1.0+contrast);}outputColor=vec4(min(color+vec3(0.5),1.0),inputColor.a);}",JZ=class extends Oa{constructor({blendFunction:e=Ot.NORMAL,brightness:t=0,contrast:i=0}={}){super("BrightnessContrastEffect",KZ,{blendFunction:e,uniforms:new Map([["brightness",new ye(t)],["contrast",new ye(i)]])})}get brightness(){return this.uniforms.get("brightness").value}set brightness(e){this.uniforms.get("brightness").value=e}getBrightness(e){return this.brightness}setBrightness(e){this.brightness=e}get contrast(){return this.uniforms.get("contrast").value}set contrast(e){this.uniforms.get("contrast").value=e}getContrast(e){return this.contrast}setContrast(e){this.contrast=e}},$Z="void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}",eK=class extends Oa{constructor(e=Ot.NORMAL){super("ColorAverageEffect",$Z,{blendFunction:e})}},tK="varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;outputColor=vec4(ra.x,inputColor.g,ba.x,max(max(ra.y,ba.y),inputColor.a));}",iK="uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vec2 shift=offset*vec2(1.0,aspect);vUvR=uv+shift;vUvB=uv-shift;}",rK=class extends Oa{constructor({blendFunction:e=Ot.NORMAL,offset:t=new j(.001,5e-4)}={}){super("ChromaticAberrationEffect",tK,{vertexShader:iK,blendFunction:e,attributes:Aa.CONVOLUTION,uniforms:new Map([["offset",new ye(t)]])})}get offset(){return this.uniforms.get("offset").value}set offset(e){this.uniforms.get("offset").value=e}getOffset(){return this.offset}setOffset(e){this.offset=e}},sK=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer; #else uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer; #endif uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}`,aK=class extends Oa{constructor(e,{blendFunction:t=Ot.NORMAL,worldFocusDistance:i,worldFocusRange:r,focusDistance:s=0,focalLength:a=.1,focusRange:n=a,bokehScale:o=1,width:l=Kr.AUTO_SIZE,height:h=Kr.AUTO_SIZE}={}){super("DepthOfFieldEffect",sK,{blendFunction:t,attributes:Aa.DEPTH,uniforms:new Map([["nearColorBuffer",new ye(null)],["farColorBuffer",new ye(null)],["nearCoCBuffer",new ye(null)],["scale",new ye(1)]])}),this.camera=e,this.renderTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="DoF.Intermediate",this.renderTarget.texture.generateMipmaps=!1,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name="DoF.Masked.Far",this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name="DoF.Bokeh.Near",this.uniforms.get("nearColorBuffer").value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name="DoF.Bokeh.Far",this.uniforms.get("farColorBuffer").value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.name="DoF.CoC",this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name="DoF.CoC.Blurred",this.uniforms.get("nearCoCBuffer").value=this.renderTargetCoCBlurred.texture,this.cocPass=new xs(new tZ(e));let c=this.cocMaterial;c.focusDistance=s,c.focusRange=n,i!==void 0&&(c.worldFocusDistance=i),r!==void 0&&(c.worldFocusRange=r),this.blurPass=new J1({kernelSize:fm.MEDIUM,width:l,height:h});let d=this.blurPass.getResolution();d.addEventListener("change",p=>this.setSize(d.getBaseWidth(),d.getBaseHeight())),this.maskPass=new xs(new mZ(this.renderTargetCoC.texture));let u=this.maskPass.fullscreenMaterial;u.maskFunction=HT.MULTIPLY,u.colorChannel=GT.GREEN,this.bokehNearBasePass=new xs(new lp(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new xs(new lp(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new xs(new lp(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new xs(new lp(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null,this.bokehScale=o}get cocTexture(){return this.renderTargetCoC.texture}get cocMaterial(){return this.cocPass.fullscreenMaterial}get circleOfConfusionMaterial(){return this.cocMaterial}getCircleOfConfusionMaterial(){return this.circleOfConfusionMaterial}getBlurPass(){return this.blurPass}get resolution(){return this.blurPass.getResolution()}getResolution(){return this.blurPass.getResolution()}get bokehScale(){return this.uniforms.get("scale").value}set bokehScale(e){let t=[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];for(let i of t)i.fullscreenMaterial.setScale(e);this.maskPass.fullscreenMaterial.setStrength(e),this.uniforms.get("scale").value=e}getBokehScale(){return this.bokehScale}setBokehScale(e){this.bokehScale=e}getTarget(){return this.target}setTarget(e){this.target=e}calculateFocusDistance(e){let t=this.camera,i=t.position.distanceTo(e);return dy(-i,t.near,t.far)}setDepthTexture(e,t=_n){this.circleOfConfusionMaterial.depthBuffer=e,this.circleOfConfusionMaterial.depthPacking=t}update(e,t,i){let r=this.renderTarget,s=this.renderTargetCoC,a=this.renderTargetCoCBlurred,n=this.renderTargetMasked;if(this.target!==null){let o=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.focusDistance=o}this.cocPass.render(e,null,s),this.blurPass.render(e,s,a),this.maskPass.render(e,t,n),this.bokehFarBasePass.render(e,n,r),this.bokehFarFillPass.render(e,r,this.renderTargetFar),this.bokehNearBasePass.render(e,t,r),this.bokehNearFillPass.render(e,r,this.renderTargetNear)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t);let r=i.width,s=i.height,a=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];a.push(this.renderTargetCoC,this.renderTargetMasked),a.forEach(n=>n.setSize(e,t)),a=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],a.forEach(n=>n.setSize(r,s)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(n=>n.fullscreenMaterial.setSize(r,s))}initialize(e,t,i){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(r=>r.initialize(e,t,i)),this.blurPass.initialize(e,t,Er),i!==void 0&&(this.renderTarget.texture.type=i,this.renderTargetNear.texture.type=i,this.renderTargetFar.texture.type=i,this.renderTargetMasked.texture.type=i,e.outputEncoding===gt&&(this.renderTarget.texture.encoding=gt,this.renderTargetNear.texture.encoding=gt,this.renderTargetFar.texture.encoding=gt,this.renderTargetMasked.texture.encoding=gt))}};new M;new we;var nK="uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}",oK=class extends Oa{constructor({blendFunction:e=Ot.NORMAL,hue:t=0,saturation:i=0}={}){super("HueSaturationEffect",nK,{blendFunction:e,uniforms:new Map([["hue",new ye(new M)],["saturation",new ye(i)]])}),this.hue=t}get saturation(){return this.uniforms.get("saturation").value}set saturation(e){this.uniforms.get("saturation").value=e}getSaturation(){return this.saturation}setSaturation(e){this.saturation=e}get hue(){let e=this.uniforms.get("hue").value;return Math.acos((e.x*3-1)/2)}set hue(e){let t=Math.sin(e),i=Math.cos(e);this.uniforms.get("hue").value.set((2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3)}getHue(){return this.hue}setHue(e){this.hue=e}};new et;var lK=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time)); #ifdef PREMULTIPLY outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a); #else outputColor=vec4(noise,inputColor.a); #endif }`,hK=class extends Oa{constructor({blendFunction:e=Ot.SCREEN,premultiply:t=!1}={}){super("NoiseEffect",lK,{blendFunction:e}),this.premultiply=t}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(e){this.premultiply!==e&&(e?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(e){this.premultiply=e}},cK="uniform bool active;uniform vec2 d;void mainUv(inout vec2 uv){if(active){uv=vec2(d.x*(floor(uv.x/d.x)+0.5),d.y*(floor(uv.y/d.y)+0.5));}}",dK=class extends Oa{constructor(e=30){super("PixelationEffect",cK,{uniforms:new Map([["active",new ye(!1)],["d",new ye(new j)]])}),this.resolution=new j,this.d=0,this.granularity=e}get granularity(){return this.d}set granularity(e){let t=Math.floor(e);t%2>0&&(t+=1),this.d=t,this.uniforms.get("active").value=t>0,this.setSize(this.resolution.width,this.resolution.height)}getGranularity(){return this.granularity}setGranularity(e){this.granularity=e}setSize(e,t){this.resolution.set(e,t),this.uniforms.get("d").value.setScalar(this.d).divide(this.resolution)}};new M;new M;var dA="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC",uA="data:image/png;base64,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",uK="uniform sampler2D weightMap;varying vec2 vOffset0;varying vec2 vOffset1;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 a;a.x=texture2D(weightMap,vOffset0).a;a.y=texture2D(weightMap,vOffset1).g;a.wz=texture2D(weightMap,uv).rb;vec4 color=inputColor;if(dot(a,vec4(1.0))>=1e-5){bool h=max(a.x,a.z)>max(a.y,a.w);vec4 blendingOffset=vec4(0.0,a.y,0.0,a.w);vec2 blendingWeight=a.yw;movec(bvec4(h),blendingOffset,vec4(a.x,0.0,a.z,0.0));movec(bvec2(h),blendingWeight,a.xz);blendingWeight/=dot(blendingWeight,vec2(1.0));vec4 blendingCoord=blendingOffset*vec4(texelSize,-texelSize)+uv.xyxy;color=blendingWeight.x*texture2D(inputBuffer,blendingCoord.xy);color+=blendingWeight.y*texture2D(inputBuffer,blendingCoord.zw);}outputColor=color;}",pK="varying vec2 vOffset0;varying vec2 vOffset1;void mainSupport(const in vec2 uv){vOffset0=uv+texelSize*vec2(1.0,0.0);vOffset1=uv+texelSize*vec2(0.0,1.0);}",jo={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3},WT=class extends Oa{constructor({preset:e=jo.MEDIUM,edgeDetectionMode:t=pm.COLOR,predicationMode:i=lZ.DISABLED}={}){super("SMAAEffect",uK,{vertexShader:pK,blendFunction:Ot.NORMAL,attributes:Aa.CONVOLUTION|Aa.DEPTH,uniforms:new Map([["weightMap",new ye(null)]])});let r,s;arguments.length>1&&(r=arguments[0],s=arguments[1],arguments.length>2&&(e=arguments[2]),arguments.length>3&&(t=arguments[3])),this.renderTargetEdges=new Pt(1,1,{minFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetEdges.texture.name="SMAA.Edges",this.renderTargetWeights=this.renderTargetEdges.clone(),this.renderTargetWeights.texture.name="SMAA.Weights",this.uniforms.get("weightMap").value=this.renderTargetWeights.texture,this.clearPass=new K1(!0,!1,!1),this.clearPass.overrideClearColor=new et(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new xs(new hZ),this.edgeDetectionMaterial.edgeDetectionMode=t,this.edgeDetectionMaterial.predicationMode=i,this.weightsPass=new xs(new yZ);let a=new UM;a.onLoad=()=>{let n=new ci(r);n.name="SMAA.Search",n.magFilter=_t,n.minFilter=_t,n.generateMipmaps=!1,n.needsUpdate=!0,n.flipY=!0,this.weightsMaterial.searchTexture=n;let o=new ci(s);o.name="SMAA.Area",o.magFilter=xt,o.minFilter=xt,o.generateMipmaps=!1,o.needsUpdate=!0,o.flipY=!1,this.weightsMaterial.areaTexture=o,this.dispatchEvent({type:"load"})},a.itemStart("search"),a.itemStart("area"),r!==void 0&&s!==void 0?(a.itemEnd("search"),a.itemEnd("area")):typeof Image<"u"&&(r=new Image,s=new Image,r.addEventListener("load",()=>a.itemEnd("search")),s.addEventListener("load",()=>a.itemEnd("area")),r.src=dA,s.src=uA),this.applyPreset(e)}get edgesTexture(){return this.renderTargetEdges.texture}getEdgesTexture(){return this.edgesTexture}get weightsTexture(){return this.renderTargetWeights.texture}getWeightsTexture(){return this.weightsTexture}get edgeDetectionMaterial(){return this.edgeDetectionPass.fullscreenMaterial}get colorEdgesMaterial(){return this.edgeDetectionMaterial}getEdgeDetectionMaterial(){return this.edgeDetectionMaterial}get weightsMaterial(){return this.weightsPass.fullscreenMaterial}getWeightsMaterial(){return this.weightsMaterial}setEdgeDetectionThreshold(e){this.edgeDetectionMaterial.edgeDetectionThreshold=e}setOrthogonalSearchSteps(e){this.weightsMaterial.orthogonalSearchSteps=e}applyPreset(e){let t=this.edgeDetectionMaterial,i=this.weightsMaterial;switch(e){case jo.LOW:t.edgeDetectionThreshold=.15,i.orthogonalSearchSteps=4,i.diagonalDetection=!1,i.cornerDetection=!1;break;case jo.MEDIUM:t.edgeDetectionThreshold=.1,i.orthogonalSearchSteps=8,i.diagonalDetection=!1,i.cornerDetection=!1;break;case jo.HIGH:t.edgeDetectionThreshold=.1,i.orthogonalSearchSteps=16,i.diagonalSearchSteps=8,i.cornerRounding=25,i.diagonalDetection=!0,i.cornerDetection=!0;break;case jo.ULTRA:t.edgeDetectionThreshold=.05,i.orthogonalSearchSteps=32,i.diagonalSearchSteps=16,i.cornerRounding=25,i.diagonalDetection=!0,i.cornerDetection=!0;break}}setDepthTexture(e,t=_n){this.edgeDetectionMaterial.depthBuffer=e,this.edgeDetectionMaterial.depthPacking=t}update(e,t,i){this.clearPass.render(e,this.renderTargetEdges),this.edgeDetectionPass.render(e,t,this.renderTargetEdges),this.weightsPass.render(e,this.renderTargetEdges,this.renderTargetWeights)}setSize(e,t){this.edgeDetectionMaterial.setSize(e,t),this.weightsMaterial.setSize(e,t),this.renderTargetEdges.setSize(e,t),this.renderTargetWeights.setSize(e,t)}dispose(){let{searchTexture:e,areaTexture:t}=this.weightsMaterial;e!==null&&t!==null&&(e.dispose(),t.dispose()),super.dispose()}static get searchImageDataURL(){return dA}static get areaImageDataURL(){return uA}},fK=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb; #if VIGNETTE_TECHNIQUE == 0 float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset)); #else vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord)); #endif outputColor=vec4(color,inputColor.a);}`,hp={DEFAULT:0,ESKIL:1},mK=class extends Oa{constructor({blendFunction:e=Ot.NORMAL,technique:t=hp.DEFAULT,eskil:i=!1,offset:r=.5,darkness:s=.5}={}){super("VignetteEffect",fK,{blendFunction:e,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new ye(r)],["darkness",new ye(s)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(e){this.technique!==e&&(this.defines.set("VIGNETTE_TECHNIQUE",e.toFixed(0)),this.setChanged())}get eskil(){return this.technique===hp.ESKIL}set eskil(e){this.technique=e?hp.ESKIL:hp.DEFAULT}getTechnique(){return this.technique}setTechnique(e){this.technique=e}get offset(){return this.uniforms.get("offset").value}set offset(e){this.uniforms.get("offset").value=e}getOffset(){return this.offset}setOffset(e){this.offset=e}get darkness(){return this.uniforms.get("darkness").value}set darkness(e){this.uniforms.get("darkness").value=e}getDarkness(){return this.darkness}setDarkness(e){this.darkness=e}},Sn=class{constructor(e,t){this.enabled=!1,this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(i){this.effect.blendMode.opacity.value=i},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(i){this.effect.blendMode.setBlendFunction(Number(i))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=Ot.NORMAL}},gK=class extends Sn{constructor(){super(ZZ),this.blendFunction=Ot.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}},vK=class extends Sn{constructor(){super(JZ)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}},yK=class extends Sn{constructor(){super(rK),this.effect.offset=new j(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}},xK=class extends Sn{constructor(){super(eK)}},bK=class extends Sn{constructor(){super(oK),this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}},wK=class extends Sn{constructor(){super(hK),this.blendFunction=Ot.OVERLAY}},_K=class extends Sn{constructor(){super(mK)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}},SK=class extends Sn{constructor(e){super(aK)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e/2e3}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=this.isPerspectiveCamera?e/2e3:(e+992)/2e3}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}setCamera(e){let t=!1;(e.isPerspectiveCamera&&this.isPerspectiveCamera===!1||!e.isPerspectiveCamera&&this.isPerspectiveCamera===!0)&&(t=!0),e.isPerspectiveCamera?(this.effect.circleOfConfusionMaterial.adoptCameraSettings(e.perspCamera),this.isPerspectiveCamera=!0):(this.effect.circleOfConfusionMaterial.adoptCameraSettings(e),this.isPerspectiveCamera=!1),t&&this.effect.setChanged()}},AK=class extends Sn{constructor(){super(dK)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}},MK=`#define GLSLIFY 1 varying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}`,EK=`#define GLSLIFY 1 #include varying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution; #define USE_YCOCG #define USE_CATMULL_ROM const float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){ #ifdef USE_YCOCG vec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a); #else return texture(tex,uv); #endif }vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){ #ifdef CHOOSE_LONGEST_MOTION_VECTOR float longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose; #else float closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv); #ifdef USE_CATMULL_ROM vec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution); #else vec4 previousColor=sample_color(historyBuffer,previousPixelPos); #endif #ifdef USE_YCOCG previousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a); #endif vec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5); #ifdef USE_YCOCG vec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center; #endif vec4 previousColorClipped=clamp(previousColor,cmin,cmax); #ifdef LUMINANCE_DIFFERENCES #ifdef USE_YCOCG float lum0=currentColor.r;float lum1=previousColorClipped.r; #else float lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb); #endif float unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback)); #else const float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha); #endif #ifdef USE_YCOCG gl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a); #else gl_FragColor=result; #endif }`,CK=`#define GLSLIFY 1 varying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}`,TK=`#define GLSLIFY 1 layout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}`,fy=class extends Dt{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new ye(null)},blending:Oi,depthWrite:!1,depthTest:!1,vertexShader:CK,fragmentShader:TK})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}},PK=class extends jr{constructor(){super("TAAResolvePass"),this.MRTCompatible=!0,this.needsSwap=!1,this.passThroughMaterial=new fy,this.resolutionVector=new j,this.resolveMaterial=new Dt({name:"TAAResolveMaterial",uniforms:{inputBuffer:new ye(null),historyBuffer:new ye(null),velocityBuffer:new ye(null),depthBuffer:new ye(null),resolution:new ye(new j)},blending:Oi,depthWrite:!1,depthTest:!1,vertexShader:MK,fragmentShader:EK}),this.historyRenderTarget=new Pt(1024,1024,{minFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.historyRenderTarget.texture.name="TAA.History",this.resultRenderTarget=new Pt(1024,1024,{minFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.resultRenderTarget.texture.name="TAA.Output"}setSize(e,t){this.historyRenderTarget.setSize(e,t),this.resultRenderTarget.setSize(e,t)}render(e,t){this.fullscreenMaterial=this.resolveMaterial,this.resolveMaterial.uniforms.inputBuffer.value=t.texture[0],this.resolveMaterial.uniforms.velocityBuffer.value=t.texture[1],this.resolveMaterial.uniforms.depthBuffer.value=t.depthTexture,this.resolveMaterial.uniforms.historyBuffer.value=this.historyRenderTarget.texture,this.resolveMaterial.uniforms.resolution.value.set(t.width,t.height),e.setRenderTarget(this.resultRenderTarget),e.render(this.scene,this.camera),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(this.historyRenderTarget),e.render(this.scene,this.camera);let i=this.renderToScreen?null:t;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(i),e.render(this.scene,this.camera)}dispose(){this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}},DK=class extends jr{constructor(e,t,i){super("TransmissionPass",void 0,t),this.MRTCompatible=!0,this.depthPass=new hA(e,t,{renderTarget:i.transmissionDepthTarget}),this.passThroughMaterial=new fy,this.splineScene=e,this.needsSwap=!1}updatePasses(e){this.passThroughMaterial=new fy,this.depthPass=new hA(this.splineScene,this.camera,{renderTarget:e.transmissionDepthTarget})}setCamera(e){this.camera=e}setScene(e){this.splineScene=e}render(e,t,i){let r=this.camera.layers.mask,s=e;s.setRenderTarget(s.transmissionRenderTarget),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=t.texture[0],s.clear(),s.render(this.scene,this.camera),this.camera.layers.disable(3),this.depthPass.render(e,t,i),s.shadowMap.needsUpdate=!1,s.shadowMap.autoUpdate=!1;let a=this.renderToScreen?null:t;this.camera.layers.set(3),e.setRenderTarget(a),e.render(this.splineScene,this.camera),this.camera.layers.mask=r}},pA=new Jr,IK=new Dt({transparent:!0,vertexShader:` void main() { gl_Position = vec4(0.0); } `,fragmentShader:` layout(location = 1) out vec4 gVelocity; void main() { gl_FragColor = vec4(0.0); gVelocity = vec4(0.0); } `}),my=class extends jr{constructor(e,t,i){super("OpaquePass",t??pA,i),this.MRTCompatible=!0,this.originalMaterials=[],this.hasTransmissionPass=!1,this.clear=!0,this.clearColorOnly=!1,this.clearDepth=!1,this.needsSwap=!1,this.MRTCompatible=e}setCamera(e){this.camera=e}setScene(e){this.scene=e??pA}getScene(){return this.scene}render(e,t){this.camera.layers.enable(3),this.hasTransmissionPass&&(this.originalMaterials.length=0,this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof Vr&&(this.originalMaterials.push([r,r.material]),r.material=IK)}),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0),this.camera.layers.enable(8);let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clearColorOnly&&e.clear(!0,!1,!0),this.clear&&e.clear(),e.render(this.scene,this.camera),this.clearDepth&&e.clear(!1,!0,!1),this.hasTransmissionPass&&this.originalMaterials.forEach(r=>{r[0].material=r[1]})}},OK=class{constructor(e,{depthBuffer:t=!0,stencilBuffer:i=!1,multisampling:r=0,frameBufferType:s=0}={}){this.renderer=e,this.helperStartIndex=0,this.copyPass=new py,this.depthTexture=null,this.timer=new YZ,this._width=1,this._height=1,this.passes=[],this.helperPasses=[],this.autoRenderToScreen=!0,this.inputBuffer=this.createBuffer(t,i,s,r,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(t,i,s,r,!1," input buffer single"),this.inputBufferSingle.texture.dispose(),this.inputBufferSingle.depthTexture.dispose(),this.inputBufferSingle.texture=this.inputBuffer.texture[0],this.inputBufferSingle.depthTexture=this.inputBuffer.depthTexture,this.outputBuffer=this.inputBuffer.clone(),this.outputBuffer.name="output buffer mrt",this.outputBufferSingle=this.createBuffer(t,i,s,r,!1,"output buffer single"),this.outputBufferSingle.texture.dispose(),this.outputBufferSingle.depthTexture.dispose(),this.outputBufferSingle.texture=this.outputBuffer.texture[0],this.outputBufferSingle.depthTexture=this.outputBuffer.depthTexture,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){let t=this.inputBuffer,i=this.multisampling;i>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):i!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("creating new input buffer"),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e,!0,"new input buffer"),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){var t;if(this.renderer=e,e!==null){let i=e.getSize(new j),r=((t=e.getContext().getContextAttributes())==null?void 0:t.alpha)??!1,s=this.inputBuffer.texture[0].type;s===Er&&e.outputEncoding===gt&&(this.inputBuffer.texture[0].encoding=gt,this.outputBuffer.texture[0].encoding=gt,this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("doing some kinda dispose??")),e.autoClear=!1,this.setSize(i.width,i.height,!1);for(let a of this.passes)a.initialize(e,r,s)}}replaceRenderer(e,t=!0){let i=this.renderer,r=i.domElement.parentNode;return this.setRenderer(e),t&&r!==null&&(r.removeChild(i.domElement),r.appendChild(e.domElement)),i}createDepthTexture(){let e=this.depthTexture=new Ph(this._width,this._height);return this.inputBuffer.depthTexture=e,this.inputBuffer.stencilBuffer?(e.format=ol,e.type=$o):e.type=on,e}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,i,r,s,a){let n=this.renderer,o=n===null?new j:n.getDrawingBufferSize(new j),l={minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai,stencilBuffer:t,depthBuffer:e},h;return r>0?(h=new Pt(o.width,o.height,l),h.samples=r):(s?(h=new dM(o.width,o.height,2,l),h.texture[1].type=mn):h=new Pt(o.width,o.height,l),h.depthTexture=new Ph(2048,2048),h.depthTexture.type=jt),i===Er&&n!==null&&n.outputEncoding===gt&&(Array.isArray(h.texture)?h.texture.forEach(c=>c.encoding=gt):h.texture.encoding=gt),Array.isArray(h.texture)?h.texture.forEach((c,d)=>{c.name=`EffectComposer.Buffer ${s} ${d}`,c.generateMipmaps=!1}):(h.texture.name=`EffectComposer.Buffer ${s}`,h.texture.generateMipmaps=!1),h.name=a,h}addPass(e,t){var o;let i=this.passes,r=this.renderer,s=r.getDrawingBufferSize(new j),a=((o=r.getContext().getContextAttributes())==null?void 0:o.alpha)??!1,n;if(e.MRTCompatible&&(n=this.inputBuffer.texture[0].type),e.MRTCompatible||(n=this.inputBuffer.texture.type),e.setRenderer(r),e.setSize(s.width,s.height),e.initialize(r,a,n),this.autoRenderToScreen&&(i.length>0&&(i[i.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),t!==void 0?i.splice(t,0,e):i.push(e),this.autoRenderToScreen&&(i[i.length-1].renderToScreen=!0),e.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let l=this.createDepthTexture();for(e of i)e.setDepthTexture(l)}else e.setDepthTexture(this.depthTexture)}setHelperStartIndex(e){this.helperStartIndex=e}removePass(e){let t=this.passes,i=t.indexOf(e);if(i!==-1&&t.splice(i,1).length>0){if(this.depthTexture!==null){let r=(s,a)=>s||a.needsDepthTexture;t.reduce(r,!1)||e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null)}this.autoRenderToScreen&&i===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){let e=this.passes;e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){let t=this.renderer,i=this.copyPass,r=this.inputBuffer,s=this.outputBuffer,a=this.inputBufferSingle,n=this.outputBufferSingle,o=!1,l,h,c,d;e===void 0&&(e=this.timer.update().getDelta());for(let u of this.passes)u.enabled&&(u.MRTCompatible?u.render(t,r,s,e,o):u.render(t,a,n,e,o),u.needsSwap&&(o&&(i.renderToScreen=u.renderToScreen,l=t.getContext(),h=t.state.buffers.stencil,h.setFunc(l.NOTEQUAL,1,4294967295),i.render(t,r,s,e,o),h.setFunc(l.EQUAL,1,4294967295)),c=r,d=a,r=s,a=n,s=c,n=d),u instanceof qZ?o=!0:u instanceof wZ&&(o=!1))}setSize(e,t,i){let r=this.renderer;if(this._width=e,this._height=t,e===void 0||t===void 0){let a=r.getSize(new j);e=a.width,t=a.height}r.setSize(e,t,i);let s=r.getDrawingBufferSize(new j);this.inputBuffer.setSize(s.width,s.height),this.outputBuffer.setSize(s.width,s.height),this.inputBufferSingle.setSize(s.width,s.height),this.outputBufferSingle.setSize(s.width,s.height);for(let a of this.passes)a.setSize(s.width,s.height)}reset(){let e=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(e)}dispose(){for(let e of this.passes)e.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.inputBufferSingle!==null&&this.inputBufferSingle.dispose(),this.outputBufferSingle!==null&&this.outputBufferSingle.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}},RK=new Dt({name:"CombineMaterial",uniforms:{inputBufferA:new ye(null),inputBufferB:new ye(null)},blending:Oi,depthWrite:!1,depthTest:!1,vertexShader:` varying vec2 vUv; void main() { gl_Position = vec4(position.xy, 1.0, 1.0); vUv = position.xy * 0.5 + 0.5; } `,fragmentShader:` varying vec2 vUv; uniform sampler2D inputBufferA; uniform sampler2D inputBufferB; // TODO: Why do we need these when postpro of framemode is enabled??? layout(location = 1) out vec4 gVelocity; void main() { vec4 resA = texture2D(inputBufferA, vUv); vec4 resB = texture2D(inputBufferB, vUv); float a = resA.a + resB.a * ( 1.0 - resA.a ); vec4 res; res.rgb = resA.rgb + (resB.rgb * (1.0 - resA.a)); res.a = resA.a + resB.a * (1.0 - resA.a); gl_FragColor = res; gVelocity = vec4(0.0); } `}),LK=class extends jr{constructor(e){super("HelperPass",void 0,e),this.MRTCompatible=!1,this.fullscreenMaterial=RK,this.helperPass=new my(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new my(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1;let t=new WT({preset:jo.LOW,edgeDetectionMode:pm.COLOR});this.effectPass=new Bf(this.camera,t),this.rt=new Pt(10,10,{minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai,depthBuffer:!0})}setSize(e,t){this.rt.setSize(e,t),this.effectPass.setSize(e,t)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}setCamera(e){this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}initialize(e,t,i){super.initialize(e,t,i),this.effectPass.initialize(e,t,i)}dispose(){super.dispose(),this.rt.dispose(),this.effectPass.dispose()}render(e,t,i){this.rt.depthTexture=t.depthTexture;let r=e.getClearAlpha();e.setClearAlpha(0),this.helperPass.clearDepth=!0,this.helperPass.clearColorOnly=!0,this.helperPass.render(e,this.rt),this.helperPassOnTop.render(e,this.rt),this.effectPass.renderToScreen=!1,this.effectPass.render(e,this.rt,i),this.fullscreenMaterial.uniforms.inputBufferA.value=i.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=t.texture,e.setClearAlpha(r),e.setRenderTarget(null),e.clear(),e.render(this.scene,this.camera)}},zK=`#define GLSLIFY 1 #include #include out vec3 n;void main(){ #include #include #include #include #include #include #include #include vec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}`,BK=`#define GLSLIFY 1 in vec3 n;void main(){gl_FragColor=vec4(n,1.0);}`,FK=`#define GLSLIFY 1 out vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}`,UK=`#define GLSLIFY 1 in vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_blue_noise_in_disk;uniform sampler2D texture_color_pass;uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_factor=smoothstep(fog_near,fog_far,view_space_p.z);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}`,NK=`#define GLSLIFY 1 out vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}`,kK=`#define GLSLIFY 1 in vec2 v_uv;uniform sampler2D texture_ao_lrez;uniform sampler2D texture_depth_lrez;uniform sampler2D texture_depth_hrez;uniform float near;uniform float far;float linearize_depth(float depth_sampled){float z=depth_sampled*2.0-1.0;return(2.0*near*far)/(far+near-z*(far-near));}vec2 nearest_depth_filter(in vec2 uv){vec2 resolution=vec2(textureSize(texture_depth_lrez,0));vec2 texel_size=1.0/resolution;vec2 offset=uv-0.5*texel_size;float d_hrez=texture(texture_depth_hrez,uv).r;float a=abs(d_hrez-texture(texture_depth_lrez,offset).r);float b=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,0.0)).r);float c=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(0.0,texel_size.y)).r);float d=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,texel_size.y)).r);float min_diff=min(a,min(b,min(c,d)));if(min_diff==a)return offset;if(min_diff==b)return offset+vec2(texel_size.x,0.0);if(min_diff==c)return offset+vec2(0.0,texel_size.y);if(min_diff==d)return offset+vec2(texel_size.x,texel_size.y);}void main(){ #ifdef DEBUG float d_lrez=texture(texture_depth_lrez,v_uv).r;float d_hrez=texture(texture_depth_hrez,v_uv).r;float output_d=mix(linearize_depth(d_lrez)/far,linearize_depth(d_hrez)/far,step(0.5,v_uv.x));gl_FragColor=vec4(vec3(output_d),1.0); #else vec2 filtered_uv=nearest_depth_filter(v_uv);vec4 ao=texture(texture_ao_lrez,filtered_uv);gl_FragColor=vec4(ao.rgb,1.0);gl_FragColor=ao; #endif }`,Pc=[[.478712,.875764],[-.337956,-.793959],[-.955259,-.028164],[.864527,.325689],[.209342,-.395657],[-.106779,.672585],[.156213,.235113],[-.413644,-.082856],[-.415667,.323909],[.141896,-.93998],[.954932,-.182516],[-.766184,.410799],[-.434912,-.458845],[.415242,-.078724],[.728335,-.491777],[-.058086,-.066401],[.20299,.686837],[-.808362,-.556402],[.507386,-.640839],[-.723494,-.22924],[.48974,.317826],[-.622663,.765301],[-.01064,.929347],[.663146,.647618],[-.096674,-.413835],[.525945,-.321063],[-.122533,.366019],[.195235,-.687983],[-.563203,.098748],[.418563,.561335],[-.378595,.800367],[.826922,.001024],[-.085372,-.766651],[-.92192,.183673],[-.590008,-.721799],[.167751,-.164393],[.032961,-.56253],[.6329,-.107059],[-.46408,.569669],[-.173676,-.958758],[-.242648,-.234303],[-.275362,.157163],[.382295,-.795131],[.562955,.115562],[.190586,.470121],[.770764,-.297576],[.237281,.93105],[-.666642,-.455871],[-.905649,-.298379],[.33952,.157829],[.701438,-.7041],[-.062758,.160346],[-.220674,.957141],[.642692,.432706],[-.77339,-.015272],[-.671467,.24688],[.158051,.062859],[.806009,.527232],[-.05762,-.247071],[.333436,-.51671],[-.550658,-.315773],[-.652078,.589846],[.008818,.530556],[-.210004,.519896]],VK=new Dt({vertexShader:zK,fragmentShader:BK}),Xl=new Dt({vertexShader:NK,fragmentShader:kK,uniforms:{texture_ao_lrez:new ye(null),texture_depth_lrez:new ye(null),texture_depth_hrez:new ye(null),near:new ye(null),far:new ye(null)}}),jK=class extends jr{constructor(e,t){super("AmbientOcclusionPass",void 0,t),this.fogEnabled=!1,this.fogNear=1,this.fogFar=1e3,this.frameIndex=0,this._runHalfRes=!0,this._width=1,this._height=1;let i=1024,r=1024;this.gBuffer=new Pt(i,r,{type:ec?mn:jt,depthTexture:new Ph(i,r),minFilter:xt,magFilter:xt}),this.depthBufferHighRes=new Pt(i,r,{depthTexture:new Ph(i,r)}),this.aoBuffer=new Pt(i,r,{minFilter:xt,magFilter:xt}),this.splineScene=e,this.splineCamera=t;let s=new Float32Array(Pc.length*2);for(let n=0;n with size float rectangle(vec2 st, vec2 size) { size = vec2(0.5) - size * 0.5; vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y)); uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y)); return uv.x * uv.y; } uniform vec2 uSize; uniform float uScale; uniform float uDPR; uniform float uCurrent; uniform vec3 uSceneColor; void main() { vec2 screenUv = gl_FragCoord.xy / uResolution.xy; screenUv *= 1.0 / uDPR; vec2 center = vec2(0.5, -0.5); vec2 outsideUv = screenUv; outsideUv += center; outsideUv -= uCoords.xy / uResolution.xy; outsideUv = (outsideUv - 0.5) + 0.5; outsideUv -= center; vec2 s = (uSize / uResolution) * uScale; float isOutside = 1.0 - rectangle(outsideUv, s); vec2 mid = vec2(0.5); vec2 insideUv = (screenUv - mid + s * mid) / s; vec4 background = texture2D(tInput, screenUv); vec4 image = texture2D(tMap, insideUv); gl_FragColor = mix(image, background, isOutside); } `,WK=class extends xs{constructor(){super(new Dt({vertexShader:GK,fragmentShader:HK,uniforms:{tInput:new ye(null),tMap:new ye(null),uResolution:new ye(new j),uSize:new ye(new j),uCoords:new ye(new j),uScale:new ye(1),uSceneColor:new ye(new et(16711680)),uDPR:new ye(1),uCurrent:new ye(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(e){this.uniforms.tMap.value=e}},qK=` void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,XK=` uniform sampler2D toScene; uniform sampler2D fromScene; uniform vec2 resolution; uniform vec2 uResolution; uniform float uDPR; uniform float mixRatio; uniform sampler2D tMixTexture; uniform int useTexture; uniform float threshold; void main() { vec2 screenUv = gl_FragCoord.xy / uResolution.xy; screenUv *= 1.0 / uDPR; vec4 texel1 = texture2D( fromScene, screenUv ); vec4 texel2 = texture2D( toScene, screenUv ); if (useTexture==1) { vec4 transitionTexel = texture2D( tMixTexture, screenUv ); float r = mixRatio * (1.0 + threshold * 2.0) - threshold; float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0); gl_FragColor = mix( texel1, texel2, mixf ); } else { gl_FragColor = mix( texel1, texel2, mixRatio ); } } `,YK=[],QK=class extends xs{constructor(){super(new Dt({vertexShader:qK,fragmentShader:XK,uniforms:{toScene:new ye(null),fromScene:new ye(null),uResolution:new ye(new j),uDPR:new ye(1),mixRatio:new ye(0),threshold:new ye(.1),useTexture:new ye(0),tMixTexture:{value:YK[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(e){this.uniforms.fromScene.value=e}},ZK=` void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,KK=` uniform sampler2D inputBuffer; uniform sampler2D blurredInputBuffer; uniform sampler2D overlay; uniform float blurIntensity; uniform vec2 uResolution; uniform float uDPR; void main() { vec2 screenUv = gl_FragCoord.xy / uResolution.xy; screenUv *= 1.0 / uDPR; vec4 texel1 = texture2D( overlay, screenUv ); vec4 texel2 = texture2D( inputBuffer, screenUv ); vec4 texel3 = texture2D( blurredInputBuffer, screenUv ); float blurMask2 = max(sign(texel1.a), 0.0) * blurIntensity; gl_FragColor = mix( mix(texel2, texel3, blurMask2), texel1, texel1.a ); } `,JK=class extends xs{constructor(){super(new Dt({vertexShader:ZK,fragmentShader:KK,uniforms:{inputBuffer:new ye(null),blurredInputBuffer:new ye(null),overlay:new ye(null),uResolution:new ye(new j),uDPR:new ye(1),blurIntensity:new ye(0)}})),this._blurEnabled=!1,this.blurTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai}),this.blurPass=new J1({width:window.innerWidth,height:window.innerHeight,kernelSize:fm.HUGE,resolutionScale:.25}),this.blurPass.renderToScreen=!1,this.uniforms.blurredInputBuffer.value=this.blurTarget.texture}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.overlay.value}set texture(e){this.uniforms.overlay.value=e}setResolution(e,t,i=1){this.uniforms.uResolution.value.set(e,t),this.uniforms.uDPR.value=i,this.blurPass.setSize(e,t),this.blurTarget.setSize(e,t),this.blurPass.setSize(e,t)}get uiCanvas(){return this._uiCanvas}set uiCanvas(e){this._uiCanvas=e,e.texture&&(this.uniforms.overlay.value=e.texture);let t=e.frame;if(t){let i=t.data.backgroundBlur,r=i.radius;this._blurEnabled=i.enabled,this.uniforms.blurIntensity.value=this._blurEnabled?1:0,this.blurPass.scale=r/3}}render(e,t,i,r,s){this._blurEnabled&&(this.blurPass.setDepthTexture(this.getDepthTexture()),this.blurPass.render(e,t,this.blurTarget,r,s)),super.render(e,t,i,r,s)}},$K=` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,eJ=` uniform sampler2D tInput; uniform sampler2D tOverlayImage; varying vec2 vUv; uniform vec2 uResolution; uniform vec2 uRightBottom; uniform vec2 uImageSize; uniform float uScale; uniform float uDPR; vec3 blendNormal(vec3 base, vec3 blend) { return blend; } vec3 blendNormal(vec3 base, vec3 blend, float opacity) { return (blendNormal(base, blend) * opacity + base * (1.0 - opacity)); } vec4 drawFixedSizeImage(sampler2D image, vec2 screenUV, vec2 imageSize, vec2 imageCoords, vec2 screenSize, float dpr) { vec2 uv = (screenUV * screenSize * dpr - imageCoords) / (imageSize * dpr); if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) { return vec4(0.0); } return texture2D(image, uv); } void main() { vec2 screenUV = gl_FragCoord.xy / (uResolution.xy * uDPR); vec2 imageCoords = vec2(uResolution.x * uDPR - uImageSize.x * uScale * uDPR - uRightBottom.x * uDPR, uRightBottom.y * uDPR); vec4 background = texture2D(tInput, screenUV); vec4 image = drawFixedSizeImage(tOverlayImage, screenUV, uImageSize * uScale, imageCoords, uResolution, uDPR); gl_FragColor = vec4(blendNormal(background.rgb, image.rgb, image.a), max(background.a, image.a)); } `,tJ=class extends xs{constructor(){super(new Dt({vertexShader:$K,fragmentShader:eJ,uniforms:{tInput:new ye(null),tOverlayImage:new ye(null),uResolution:new ye(new j),uImageSize:new ye(new j),uRightBottom:new ye(new j(20,20)),uScale:new ye(.25),uDPR:new ye(1)}}),"tInput")}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tOverlayImage.value}set texture(e){this.uniforms.tOverlayImage.value=e,this.uniforms.uImageSize.value.set(e.image.width,e.image.height)}};function fA(e,t){return t&&t.enabled&&e.push(t.effect),e}var iJ=e=>Object.values(Ot).includes(e)?e:Ot.NORMAL,rJ=class extends yr{constructor(e,t){super(),this._needsDOFResize=t,this.postprocessingState=yf.defaultData,this._scene=new Jr,this._camera=new Mr,this.effects=new Map,this.blueNoiseTexture=new Ur,this._renderToScreen=!0,this._isUIOverlayEnabled=!1,this.clock=new BU,this.renderer=e,this.debug=!1,this.effects.set("bloom",new gK),this.effects.set("chromaticAberration",new yK),this.effects.set("vignette",new _K),this.effects.set("noise",new wK),this.effects.set("colorAverage",new xK),this.effects.set("hueSaturation",new bK),this.effects.set("brightnessContrast",new vK),this.effects.set("depthOfField",new SK),this.effects.set("pixelation",new AK),this.effectComposer=new OK(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new my(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new DK(this.scene,this.camera,this.renderer),this.aoPass=new jK(this.scene,this.camera),this.taaPass=new PK,this.taaPass.renderToScreen=!1,this.helperPass=new LK(this.camera),this.helperPass.renderToScreen=!1,this.stylesOverlayPass=new WK,this.stylesOverlayPass.enabled=!1,this.uiOverlayPass=new JK,this.uiOverlayPass.enabled=!1,this.logoOverlayPass=new tJ,this.logoOverlayPass.enabled=!1,this.sceneTransitionPass=new QK,this.sceneTransitionPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.stylesOverlayPass.texture=e,this.stylesOverlayPass.enabled=!0):this.stylesOverlayPass.enabled=!1}get overlayTexture(){return this.stylesOverlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){let t=this._camera!==e;this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),t&&this.transmissionPass.updatePasses(this.renderer),this.aoPass.setCamera(e),this.helperPass.setCamera(e),this.effects.get("depthOfField").setCamera(e)}updateRenderToScreen(){let e=!1;for(let t=this.effectComposer.passes.length-1;t>=0;t--){let i=this.effectComposer.passes[t];if(i.enabled===!0&&!e&&this._renderToScreen){i.renderToScreen=!0,e=!0;continue}i.renderToScreen=!1}}get isUIOverlayEnabled(){return this._isUIOverlayEnabled}disableUIOverlay(){this._isUIOverlayEnabled=!1}enableUIOverlay(){this._isUIOverlayEnabled=!0}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new Ur(e,128,128),this.blueNoiseTexture.wrapS=nn,this.blueNoiseTexture.wrapT=nn,this.blueNoiseTexture.minFilter=_t,this.blueNoiseTexture.magFilter=_t,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,t,i,r,s,a,n,o){this.aoPass.enabled=e,this.aoPass.radius=t,this.aoPass.bias=i,this.aoPass.aoColor=r,this.aoPass.fogEnabled=s,this.aoPass.fogNear=a,this.aoPass.fogFar=n,this.aoPass.runHalfRes!==!o&&(this.aoPass.runHalfRes=!o)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){var e,t,i;if((e=this.uvEffectPass)==null||e.dispose(),(t=this.effectPass)==null||t.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let r=[this.effects.get("pixelation")].reduce(fA,[]);r.length>0&&(this.uvEffectPass=new Bf(this.camera,...r),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let s=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("depthOfField"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(fA,[]);if(s.length>0&&(this.effectPass=new Bf(this.camera,...s),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass),this._needsDOFResize&&((i=this.effects.get("depthOfField"))==null?void 0:i.enabled)&&window!==void 0)){let a=this.renderer.viewportWidth,n=this.renderer.viewportHeight;this.renderer.setSize(a-1,n-1),this.renderer.setSize(a,n)}}this.effectComposer.addPass(this.stylesOverlayPass),this.effectComposer.addPass(this.uiOverlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.logoOverlayPass)}_initCopyPass(){if(this._savePass)return;let e=new j;this.renderer.getDrawingBufferSize(e),this._rt=new Pt(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:nn,wrapT:nn}),this._rt.samples=0,this._savePass=new py(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new py(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?t.removePass(this._savePass):t.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}set sceneTransitionFromTexture(e){e!==this.sceneTransitionPass.texture&&(e!==null?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}setWatermark(e){this.logoOverlayPass.enabled=e!==null,e&&(this.logoOverlayPass.texture=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let a=s[1],n=this.effects.get(s[0]);if(n){n.enabled!==a.enabled&&(r=!0),n.enabled=a.enabled;for(let[o,l]of Object.entries(a))o==="blendFunction"?n.blendFunction=iJ(l):n[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof ct?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof ct?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){var e,t;(e=this.uvEffectPass)==null||e.dispose(),(t=this.effectPass)==null||t.dispose(),this.effectComposer.dispose()}},sJ=e=>` // PCSS implementation based on: // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/ // NOTE: This number affects how big the shadow blur can // possibly get. Bigger number == bigger blur, but less precise results const float gPenumbraFilterSize = 80.0; const int gPenumbraSamples = ${e}; const int gShadowSamples = ${e}; const float gShadowSamplesRpc = 1.0f / float(gShadowSamples); #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif /* #if NUM_RECT_AREA_LIGHTS > 0 // TODO (abelnation): create uniforms for area light shadows #endif */ float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius) { float penumbra = 1.0; float blockerDepthAvg = 0.0; float blockerCount = 0.0; #pragma unroll_loop_start for(int i = 0; i < gPenumbraSamples; i ++) { vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar; float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ); if(depth < compare + 0.0001) { blockerDepthAvg += depth; blockerCount++; } } #pragma unroll_loop_end if (blockerCount > 0.0) { blockerDepthAvg /= blockerCount; // Compute penumbra penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg); penumbra *= penumbra; penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows return clamp(penumbra, 0.00, 1.0); } return 0.0; } float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius) { float shadow = 0.0f; // NOTE: When using TAA, we should use screen space interleaved gradient noise vec2 halton = haltonSequence[frameIndex]; float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); float temporalAngle = temporalOffset * PI2; float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.); float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius); if (penumbra == -1.0) { return 1.0; } #pragma unroll_loop_start for (int i = 0; i < gShadowSamples; i++) { vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; // Overall blurring offset vec2 offset = vogelSample * (shadowRadius * 2.); // Penumbra offset offset += vogelSample * (penumbra * texelScalar); shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) ); } #pragma unroll_loop_end return shadow * gShadowSamplesRpc; } float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); // Hard Shadow if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; // if ( something && something ) breaks ATI OpenGL shader compiler // if ( all( something, something ) ) using this instead bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); bool inFrustum = all( inFrustumVec ); bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); bool frustumTest = all( frustumTestVec ); if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else // no percentage-closer filtering: shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } // cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D // vector suitable for 2D texture mapping. This code uses the following layout for the // 2D texture: // // xzXZ // y Y // // Y - Positive y direction // y - Negative y direction // X - Positive x direction // x - Negative x direction // Z - Positive z direction // z - Negative z direction // // Source and test bed: // https://gist.github.com/tschw/da10c43c467ce8afd0c4 vec2 cubeToUV( vec3 v, float texelSizeY ) { // Number of texels to avoid at the edge of each square vec3 absV = abs( v ); // Intersect unit cube float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; // Apply scale to avoid seams // two texels less per square (one texel will do for NEAREST) v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); // Unwrap // space: -1 ... 1 range for each square // // #X## dim := ( 4 , 2 ) // # # center := ( 1 , 1 ) vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } // Transform to UV space // scale := 0.5 / dim // translate := ( center + 0.5 ) / dim return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); // for point lights, the uniform @vShadowCoord is re-purposed to hold // the vector from the light to the world-space position of the fragment. vec3 lightToPosition = shadowCoord.xyz; // dp = normalized distance from light to fragment position float compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp? compare += shadowBias; // bd3D = base direction 3D vec3 bd3D = normalize( lightToPosition ); vec2 halton = haltonSequence[frameIndex]; float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); float temporalAngle = temporalOffset * PI2; #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM ) for (int i = 0; i < gShadowSamples; i++) { vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; // Overall blurring offset vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.); // NOTE: Removed for now // Penumbra offset //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize); shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare ); } return shadow * gShadowSamplesRpc; #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) for (int i = 0; i < 16; i++) { vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; // Overall blurring offset vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.); shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare ); } return shadow * (1.0 / 16.0); #else // no percentage-closer filtering return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare ); #endif } #endif `,aJ=yt.lights_fragment_begin,nJ=yt.shadowmask_pars_fragment,mA=null,oJ=e=>{switch(e){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},lJ=(e="medium")=>{if(mA===e)return!1;mA=e;let t=oJ(e);yt.shadowmap_pars_fragment=sJ(t);let i=aJ.slice();i=i.replace("getShadow( spotShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX + 3, spotShadowMap[ i ]"),i=i.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),yt.lights_fragment_begin=i;let r=nJ.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),yt.shadowmask_pars_fragment=r,!0},hJ=` attribute vec3 randomColor; varying vec3 vNormal; flat out vec3 vColor; #include #include void main() { #include #include #include #include vec3 transformed = vec3(position); #include #include vNormal = normal; vColor = randomColor; gl_Position = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0)); } `,cJ=` uniform float depthContrast; varying vec3 vNormal; flat in vec3 vColor; void main() { vec3 normal = (normalize(vNormal)).rgb; float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5; vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4); gl_FragColor = vec4(resultColor, vColor.r); gl_FragColor = vec4(resultColor, vColor.r); } `,ev=new Dt({vertexShader:hJ,fragmentShader:cJ,uniforms:{depthContrast:{value:1}}}),gA=new ci,vA=new j,dJ=class extends bM{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new j,this.dummyCamera=new Mr,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.isXRCopyPassSet=!1,this.clear=(s=!0,a=!0,n=!0)=>{let o=this.getContext(),l=0;s&&(l|=o.COLOR_BUFFER_BIT),a&&(l|=o.DEPTH_BUFFER_BIT),n&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.pipeline=new rJ(this,(e==null?void 0:e.needsDOFResize)??!1),this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Uy,this.dummyCamera.matrixAutoUpdate=!1,this.domElement.removeAttribute("data-engine");let r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio!==s&&(this._pixelRatio=s,t(s))},this.setSize=(s,a,n=!0)=>{var o,l;(this.viewportWidth!==s||this.viewportHeight!==a)&&(this.viewportWidth=s,this.viewportHeight=a,i(s,a,n),(o=this.normalRenderTarget)==null||o.setSize(s*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(s,a),(l=this.transmissionDepthTarget)==null||l.setSize(s*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(s,a,n))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new Pt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai,depthBuffer:!1}))}_resizeTransmission(e,t){var i,r;(i=this.transmissionRenderTarget)==null||i.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),(r=this.aoRenderTarget)==null||r.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return st.transmissionLod.value===1}set hdTransmission(e){st.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new Pt(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:Ch,magFilter:xt,wrapS:ai,wrapT:ai,depthBuffer:!1}),this.transmissionDepthTarget=new Pt(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:_t,magFilter:_t,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new Pt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:_t,magFilter:_t,type:jt,depthTexture:new Ph(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t,i){this.normalRenderTarget&&(this.setClearColor(0),i.layers.enable(8),i.layers.disable(0),i.layers.disable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),i instanceof Mr?ev.uniforms.depthContrast.value=(i.far-i.near)/1e4:ev.uniforms.depthContrast.value=1,t.overrideMaterial=ev,this.render(t,i),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?_y:null,i.layers.enable(0),i.layers.enable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,s=t.width,a=this.viewportWidth/this.viewportHeight;s{st.penumbraSize.value[f]=p}),st.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?st.resolution.value.set(this.resolution.x,this.resolution.y):st.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(st.normalRenderTarget.value=a,st.normalRenderTargetDepth.value=gA):l.needsNormal()&&(this.createNormalRenderTarget(),st.normalRenderTarget.value=this.normalRenderTarget.texture,st.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(l,n,t));let h=n.data.ao,c=h.occlusion;if(c&&(this.createAORenderTarget(),st.aoRenderTarget.value=this.aoRenderTarget.texture),st.aoEnabled.value=c,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,n.aoColor,n.fog!==null,n.backupFog.near,n.backupFog.far,h.aoFullRes&&!ec),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture),this.pipeline.isUIOverlayEnabled&&((u=n.uiCanvas)==null?void 0:u.enabled)&&n.uiCanvas.texture&&n.uiCanvas.texture.image.width>0){let p=this.getSize(vA),f=this.getPixelRatio();(n.uiCanvas.width!==this.viewportWidth||n.uiCanvas.height!==this.viewportHeight||n.uiCanvas.dpr!==f)&&n.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},f),n.uiCanvas.render(this),this.pipeline.uiOverlayPass.uiCanvas=n.uiCanvas,this.pipeline.uiOverlayPass.enabled=!0,this.pipeline.uiOverlayPass.setResolution(p.x,p.y,f),this.pipeline.updateRenderToScreen()}else this.pipeline.uiOverlayPass.enabled=!1,this.pipeline.updateRenderToScreen();if(this.pipeline.logoOverlayPass.enabled){let p=this.getSize(vA),f=this.getPixelRatio();this.pipeline.logoOverlayPass.uniforms.uResolution.value.set(p.x,p.y),this.pipeline.logoOverlayPass.uniforms.uDPR.value=f}let d=!1;if(s!==void 0)st.transmissionRenderTarget.value=s,st.transmissionRenderTargetDepth.value=gA,this.pipeline.setTransmissionPassEnabled(!1);else{let p=l.needsTransmission();p&&(this.transmissionRenderTarget===void 0&&(d=!0),this.createTransmissionRenderTarget(),st.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,st.aspectRatio.value=eY(this.viewportWidth,this.viewportHeight),st.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(p)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=n,this.pipeline.camera=t,d&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==n.postprocessing&&(this.pipeline.updatePostprocessing(n.postprocessing),!i&&!r&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.shapeBlendIntances.forEach(p=>{p.onBeforeShadowPass(this)}),n.overrideMaterial=l.wireframeState?_y:null,this.pipeline.render(),st.frameIndex.value=(st.frameIndex.value+1)%16,t instanceof Mr&&t.copyHistory(),n.visible=o}renderFromSceneForSceneTransitionPass(e,t,i){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i,this.pipeline.renderToScreen=!0;let r=this.pipeline.sceneTransitionPass.uniforms;r.uDPR.value=window.devicePixelRatio,r.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){var e,t,i,r,s,a;this._superDispose(),this.pipeline.dispose(),(e=this.aoRenderTarget)==null||e.dispose(),(t=this.transmissionRenderTarget)==null||t.dispose(),(i=this.transmissionDepthTarget)==null||i.dispose(),(r=this.normalRenderTarget)==null||r.dispose(),(a=(s=this.normalRenderTarget)==null?void 0:s.depthTexture)==null||a.dispose()}},qT=class extends Gd(JU){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Hd(this.object,qT.geometryHelper,e,t)}},XT=class extends Gd(KU){constructor(e,t=15,i=6710886){super(e,t,i),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Hd(this.object,XT.geometryHelper,e,t)}},gy=class extends Gd(ZU){constructor(e,t=6710886){super(e,t),this.object=e,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Hd(this.object,gy.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=gy._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,a=this.cone.material.length;s0?Ff(i,e-1):[null,null];(e>0&&i.length?i[a].charAt(n):null)===` `&&(r++,s=0),this.current.start=e,this.current.end=void 0;let[o,l]=tv(this.object,r,s),{AD:h,descender:c}=this.object,d=c+h*.5,{width:u,height:p,depth:f}=this.object.geometry.userData.parameters,g=typeof u=="string"?0:u,m=typeof p=="string"?0:p;this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.set(o-g*.5,l+d+m*.5,f),this.hideSelectionMesh(),this.showCaretMesh()}setSelection(e,t){if(this.object===void 0)return;let i=this.object.wrappedText;this.current.start=e,this.current.end=t;let r=[],s=[],a=uJ(i,e,t),{lineHeight:n,AD:o,descender:l}=this.object,h=l+o*.5-n*.5;for(let[m,v,y]of a)if(v!==y){let[x,w]=tv(this.object,m,v),[_,b]=tv(this.object,m,y);w+=h,b+=h,b+=n;let A=r.length/3;r.push(x,w,0),r.push(_,w,0),r.push(_,b,0),r.push(x,b,0),s.push(A+0,A+1,A+2),s.push(A+2,A+3,A+0)}let c=new Ge;c.setIndex(s),c.setAttribute("position",new Ie(r,3));let{width:d,height:u,depth:p}=this.object.geometry.userData.parameters,f=typeof d=="string"?0:d,g=typeof u=="string"?0:u;this.selectionMesh.geometry.dispose(),this.selectionMesh.geometry=c,this.selectionMesh.position.x=-f*.5,this.selectionMesh.position.y=g*.5,this.selectionMesh.position.z=p,this.showSelectionMesh(),this.hideCaretMesh()}getSelectionFromPosition(e,t,i="previous"){if(this.object===void 0||this.object.font===void 0)return;let r=this.object.wrappedText,s=r.length,a=this.object.lineHeight,n=s*a,{height:o,verticalAlign:l}=this.object.geometry.userData.parameters,h=typeof o=="string"?0:o,c=0;l===3?c=h-n:l===2&&(c=h*.5-n*.5);let d=Math.min(Math.floor(Math.max(Math.min(-t-c,n),0)/a),s-1),u=this.object.charCoords[d],p=this.object.charWidths[d],f=0,g=!1;if(i==="previous"){for(let m=0;m0){f=m,g=!0;break}}else if(i==="closest"){let m=1/0;for(let v=0;v=v&&er+=s.length,0)+i}showSelectionMesh(){this.selectionMesh.material.opacity=this._selectionVisibleAlpha}hideSelectionMesh(){this.selectionMesh.material.opacity=0}showCaretMesh(){this.caretMesh.material.opacity=this._caretVisibleAlpha}hideCaretMesh(){this.caretMesh.material.opacity=0}};function tv(e,t,i){let{charCoords:r,charWidths:s,initialOffsetY:a,lineHeight:n}=e;if(r[t]&&r[t].length===0||r.length===0){let c=0,{horizontalAlign:d}=e.data.geometry,u=e.wrappedText,{width:p}=e.geometry.userData.parameters;return u.length===1&&u[0].length===0&&(d===3?c=p*.5:d===2&&(c=p)),[c,a-n*t]}let o=r[t];if(o===void 0||o.length===0)return[0,0];let[l,h]=o[Math.min(i,o.length-1)];return i>=o.length&&(l+=s[t][i-1]),[l,h]}function Ff(e,t){var r;let i=0;for(let s=0;s=e[r].length&&(r++,s=0);for(let l=r;l<=a;l++){let h=e[l],c=l===r?s:0,d=l===a?n:h.length;o.push([l,c,d])}return o}function pJ(e,t){let i=ur.fromHex(3223857),r=.8;for(let s of e.layers){if(s.data.type==="light"||s.data.type==="displace"||s.data.type==="fresnel"||s.data.type==="matcap"||s.data.type==="texture"||s.data.type==="toon"||s.data.type==="outline"||s.data.type==="transmission"||s.data.type==="noise")continue;let a=typeof s.data.alpha=="string"?Number(t.getVariable(s.data.alpha)):s.data.alpha;if(s.data.type==="color"&&a>.3){i=fJ(s.data.color,t),r=a;break}else if((s.data.type==="depth"||s.data.type==="gradient")&&a>.3){let n=mJ(s.data);i={r:n[0],g:n[1],b:n[2]},r=typeof s.data.alpha=="string"?1:s.data.alpha;break}}return{...i,a:r}}function fJ(e,t){return typeof e=="string"?t.data.colors[e]:e}function mJ(e){return e.colors[0]}function gJ(e,t){e.shadow.camera.right=t/2,e.shadow.camera.left=-t/2,e.shadow.camera.top=t/2,e.shadow.camera.bottom=-t/2,e.shadow.needsUpdate=!0}var ZT=class extends Z1(zU,qT){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new Zp(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof Zp&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&gJ(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}},yA=new M,xA=new M,bA=new lt,KT=class extends Z1(IU,YT){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=Re.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new Zp(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof Zp&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),xA.setFromMatrixPosition(this.matrixWorld),bA.setFromRotationMatrix(this.matrixWorld),yA.copy(this.up).applyQuaternion(bA).negate().multiplyScalar(this.distance),this.target.position.copy(xA).add(yA),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function vJ(e){let t=(e[0][0]+e[1][1])/2,i=(e[0][0]-e[1][1])/2,r=(e[1][0]+e[0][1])/2,s=(e[1][0]-e[0][1])/2,a=Math.sqrt(t*t+s*s),n=Math.sqrt(i*i+r*r),o=a+n,l=a-n,h=Math.atan2(r,i),c=Math.atan2(s,t),d=(c-h)/2,u=(c+h)/2,p=[[Math.cos(u),Math.sin(u)],[-Math.sin(u),Math.cos(u)]],f=[[o,0],[0,l]],g=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]];return p[0][0]*=-1,p[0][1]*=-1,g[0][0]*=-1,g[1][0]*=-1,[p,f,g]}function Ip(e,t){return[[e[0][0]*t[0][0]+e[0][1]*t[1][0],e[0][0]*t[0][1]+e[0][1]*t[1][1]],[e[1][0]*t[0][0]+e[1][1]*t[1][0],e[1][0]*t[0][1]+e[1][1]*t[1][1]]]}function wA(e){return[[e[0][0],e[1][0]],[e[0][1],e[1][1]]]}function yJ(e){let[t,i,r]=vJ(e),s=Ip(t,wA(r)),a=Ip(Ip(r,i),wA(r)),n=Math.atan2(s[1][0],s[0][0]),o=[a[0][0],a[1][1]],l=[a[0][1]/a[1][1],a[1][0]/a[0][0]];return{rotation:n,scale:o,shear:l}}function xJ({rotation:e,scale:t,shear:i}){let r=Math.cos(e),s=Math.sin(e),a=[[r,-s],[s,r]],n=[[t[0],i[0]*t[1]],[i[1]*t[0],t[1]]],o=Ip(a,n);return[o[0][0],o[1][0],o[0][1],o[1][1]]}var Lt;(e=>{function t(){return[1,0,0,0,1,0,0,0,1]}e.identity=t;function i(b,A=e.identity()){for(let S=0,E=b.length;S=r[0]&&e<=s[0]&&t>=r[1]&&t<=s[1]}applyTransforms(e){e.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Lt.compose(this.position,this.scale,_J(this.rotation),rl.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(e,t,i){let r=this.parent;t&&r!==null&&r!==void 0&&r.updateWorldMatrix(e,!0,!1),e&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Lt.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Lt.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return rl.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{e.resetBBoxNeedsUpdateSelf()})}updateTransformState(e){let t=!1;e.position!==void 0&&(t=!0,this.position=e.position),e.rotation!==void 0&&(t=!0,this.rotation=e.rotation),e.scale!==void 0&&(t=!0,this.scale=e.scale),e.shear!==void 0&&(t=!0,this.shear=e.shear),t&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(e,t,i){e.type===0&&e.props.visible!==void 0&&(this.visible=e.props.visible),this.data=t,this.data=t;let r=e,s=Qt(e.path,["states","*"]);if(s!==null){if(e.type===0){let[a]=s;if((this==null?void 0:this.stateSelection)===a){let n={...e.props};if(delete n.name,Object.values(e.props).some(o=>o===void 0)){let o=this.data;if(o!==void 0){let l=Gi.zoom(o,e.path.slice(2));if(l)for(let h in e.props)e.props[h]===void 0&&h in l&&(n[h]=l[h])}}r={...e,props:n,path:e.path.slice(2)}}}}else if(e.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(e.props.name!==void 0&&a.name){let{name:o,...l}=a;a=l}let n=Gi.removeOverridden(e.path,e.props,a);r={...e,props:n}}}this.updateByPatchedOpBase(r,Yo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i)}changeSelectedState(e,t,i=!1){if(!(this.data.states.length===0&&!i)){for(let r of this.data.states)Yo.toOps(this.data,r.data).forEach(s=>{let a=lf.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,t)});if(e!==null){let r=this.data.states.data(e);r&&(this.dataPatched=Yo.patch(this.data,r),Yo.toOps(this.data,r).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,t)}))}i&&this.updateTransformState(this.dataPatched),this.stateSelection=e}}updateState(e,t){e.name!==void 0&&(this.name=e.name),e.visible!==void 0&&(this.visible=e.visible),this.updateTransformState(e)}updateByPatchedOpBase(e,t,i){this.dataPatched=t,this.updateByPatchedOp(e,t,i)}updateByPatchedOp(e,t,i){e.path.length===0&&e.type===0&&this.updateState(e.props,i),this.requestRender()}traverseFrameAncestors(e){this.traverseAncestors(t=>{t.data.type==="frame2d"&&e(t)})}traverseAncestors(e){let t=this.parent;for(;t;)e(t),t=t.parent}requestRender(){this.traverseFrameAncestors(e=>{e.requestRender()})}clone(e){let t=new ar(this.uuid,this.data,e);return t.parent=void 0,t}addEventListener(e,t){this.emitter.on(e,t)}removeEventListener(e,t){this.emitter.off(e,t)}dispatchEvent(e){this.emitter.emit(e.type,{...e,target:e.target??this})}traverseSortNextHelper(){let e=this.parent;if(e){let t=e.children;if(t){let i=t.indexOf(this)+1;return t[i]?t[i]:e.traverseSortNextHelper()}}}sortNext(){let e=this.children;return e&&e.length>0&&e[0]?e[0]:this.traverseSortNextHelper()}isDescendantOf(e){e instanceof ar&&(e=e.uuid);let t=this;for(;t.parent;){if(t.parent.uuid===e)return!0;t=t.parent}return!1}},ks=class extends ar{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.context=i,this.children=[]}add(e){e.parent&&e.parent instanceof ks&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let i of this.children)i instanceof ks?i.traverse(e):t=e(i)}intersectsChildrenHelper(e,t,i,r,s){for(let a of this.children)if(a.intersects(e,t,i,!1)&&(s.push(a),r)||a instanceof ks&&a.intersectsChildrenHelper(e,t,i,r,s))return!0;return!1}intersectsChildren(e,t,i,r=!1,s=[],a=!1){return this.intersectsChildrenHelper(e,t,i,r,s),s}intersectsChildrenHelperReverse(e,t,i,r,s){for(let a of this.children)if(a instanceof ks&&a.intersectsChildrenHelperReverse(e,t,i,r,s)||a.intersects(e,t,i,!1)&&(s.push(a),r))return!0;return!1}intersectsChildrenReverse(e,t,i,r=!1,s=[],a=!1){return this.intersectsChildrenHelperReverse(e,t,i,r,s),s}updateWorldMatrix(e,t,i){if(super.updateWorldMatrix(e,t,i),i&&this.children)for(let r of this.children)r.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(i=>{i.uuid===e&&(t=i)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new ks(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}},po=class extends ks{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.updateState(t,i)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new po(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}};function SJ(e,t){let[[i,r],[s,a]]=e,[[n,o],[l,h]]=t,c=(i-s)*(o-h)-(r-a)*(n-l);if(c===0)return!1;let d=((i-n)*(o-h)-(r-o)*(n-l))/c,u=-((i-s)*(r-o)-(r-a)*(i-n))/c;return d>=0&&d<=1&&u>=0&&u<=1}var JT=[[-1,1],[-1,-1],[1,-1],[1,1]],_A=(e,t,i)=>{let r=e.getCenter(),s=e.getHalfSize(),a=Lt.append(t,e.worldMatrix);s[0]===0&&s[1]===0?i.push(Lt.apply(r,a)):JT.forEach(n=>{let o=[n[0]*s[0]+r[0],n[1]*s[1]+r[1]];i.push(Lt.apply(o,a))})},vy=class{constructor(){this.matrix=Lt.identity(),this.min=[1/0,1/0],this.max=[-1/0,-1/0],this.vertices=[],this.edges=[]}setFromObjectSize(e,t=!1){e.updateWorldMatrix(),this.makeEmpty(),Lt.copy(e.worldMatrix,this.matrix);let i=Lt.invert(e.worldMatrix);this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];i===!0&&e instanceof ks?e.traverse(s=>{s.visible&&_A(s,t,r)}):_A(e,t,r),this.setFromPoints(r)}setFromSize(e,t,i){this.makeEmpty(),Lt.copy(i,this.matrix),this.expandBySize(e,t,i)}expandBySize(e,t,i){[Lt.apply([0,0],i),Lt.apply([0,t],i),Lt.apply([e,t],i),Lt.apply([e,0],i)].forEach(r=>this.expandByPoint(r))}getCenter(){let[e,t]=this.min,[i,r]=this.getHalfSize();return Lt.apply([e+i,t+r],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(e){this.makeEmpty();for(let t of e)this.expandByPoint(t)}expandByPoint(e){this.min=[Math.min(this.min[0],e[0]),Math.min(this.min[1],e[1])],this.max=[Math.max(this.max[0],e[0]),Math.max(this.max[1],e[1])]}computeVertices(){let[e,t]=this.getHalfSize(),i=this.getCenter(),[r,s,a,n]=Lt.getAbcdef(this.matrix),o=Lt.create(r,s,a,n,i[0],i[1]);this.vertices=JT.map(([l,h])=>Lt.apply([l*e,h*t],o))}computeEdges(){this.edges=[];for(let e=0,t=this.vertices.length;e=i[0]&&e<=r[0]&&t>=i[1]&&t<=r[1]}containsPoint(e){let[t,i]=e,[r,s]=this.min,[a,n]=this.max;return t>=r&&t<=a&&i>=s&&i<=n}intersectsBBox2D(e){for(let t=0,i=this.edges.length;t{$T=e}),SA=!1,cp;function MJ(){if(SA)return;if(cp)return cp;async function e(){let t=await vo(()=>import("./ui-L7l3pL7d.js"),__vite__mapDeps([]));$T(t.default??t),SA=!0}return cp=e(),cp}function AA(e){let t=!1;return e.scene.objects.traverse((i,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var ut,iv;async function EJ(e){let t=await AJ;ut||(iv||(iv=t({locateFile:()=>e})),ut=await iv)}var MA=Lt.identity(),eP=class{constructor(e,t=1){this.canvas=e,this._dpr=t,this._width=0,this._height=0,this._strokeMode="inside",this._layerBlur=0,this._backgroundBlur=0,this._dropShadowBlur=0,this._dropShadowOffsetX=0,this._dropShadowOffsetY=0,this._dropShadowColor=Ht.transparent,this._innerShadowBlur=0,this._innerShadowOffsetX=0,this._innerShadowOffsetY=0,this._innerShadowSpread=0,this._innerShadowColor=Ht.transparent,this._fonts=new Map,this._isSizeDirty=!1;try{let i=e.getBoundingClientRect();e.width=i.width*t,e.height=i.height*t}catch{console.log(e.width,t)}this._currentM3Transform=MA,this._currentTransform=new Float32Array(MA)}get dpr(){return this._dpr}set dpr(e){this._dpr=e,this._isSizeDirty=!0}async init(){var e,t;if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await EJ(this.wasmURL),this._surface=ut.MakeWebGLCanvasSurface(this.canvas),this.ctx=(e=this._surface)==null?void 0:e.getCanvas(),this._paint=new ut.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(ut.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(ut.PaintStyle.Stroke),(t=this.ctx)==null||t.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(e){this._currentM3Transform=e,this._currentTransform.set(e)}async loadFont(e,t){let i=await(await fetch(e)).arrayBuffer();this.registerFont(i,t)}registerFont(e,t){if(this._fonts.has(t))return;let i=ut.FontMgr.FromData(e);if(i)this._fonts.set(t,i);else throw new Error("Invalid font data for "+t)}get width(){return this._width}get height(){return this._height}set strokeColor(e){this._paintStroke&&this._paintStroke.setColor(dp(e),ut.ColorSpace.DISPLAY_P3)}set fillColor(e){this._paintFill&&this._paintFill.setColor(dp(e),ut.ColorSpace.DISPLAY_P3)}set lineWidth(e){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?e:e*2)}set strokeMode(e){this._strokeMode=e}set dropShadowBlur(e){this._dropShadowBlur=e}set dropShadowColor(e){this._dropShadowColor=e}set dropShadowOffsetX(e){this._dropShadowOffsetX=e}set dropShadowOffsetY(e){this._dropShadowOffsetY=e}set innerShadowBlur(e){this._innerShadowBlur=e}set innerShadowColor(e){this._innerShadowColor=e}set innerShadowOffsetX(e){this._innerShadowOffsetX=e}set innerShadowOffsetY(e){this._innerShadowOffsetY=e}set innerShadowSpread(e){this._innerShadowSpread=e}set layerBlur(e){this._layerBlur=e}set backgroundBlur(e){this._backgroundBlur=e}clear(){var e;(e=this.ctx)==null||e.clear(ut.TRANSPARENT)}save(){var e;(e=this.ctx)==null||e.save()}restore(){var e;(e=this.ctx)==null||e.restore()}beginPath(){var e;(e=this._currentPath)==null||e.delete(),this._currentPath=new ut.Path}closePath(){let e=this._currentPath;if(e){if(e.isEmpty())return;let t=e.getBounds();(t[3]-t[1]||t[2]-t[0])&&e.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(e,t,i,r,s=0,a=0,n=0,o=0){var h,c;let l=ut.XYWHRect(e,t,i,r);if(s===0&&a===0&&o===0&&n===0)(h=this.ctx)==null||h.clipRect(l,ut.ClipOp.Intersect,!0);else{let d=ut.RRectXY(l,s,s);d[4]=d[5]=s,d[6]=d[7]=a,d[8]=d[9]=n,d[10]=d[11]=o,(c=this.ctx)==null||c.clipRRect(d,ut.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let e=Lt.invert(this.currentTransform);this.ctx.concat(e);let t=Lt.translate(Lt.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(t),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(e,t,i=!0){var r,s,a,n;if(this.ctx&&this._currentPath){let o,l=!1;if(i&&this._hasDropShadow()){let h=e.copy();h.setColor(dp(this._dropShadowColor));let c;this._dropShadowBlur>0&&(c=ut.MaskFilter.MakeBlur(ut.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(((r=this.camera)==null?void 0:r.scale)??1),!1),h.setMaskFilter(c)),this.ctx.save(),this.ctx.clipPath(this._currentPath,ut.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),t(h),this.ctx.restore(),h.delete(),c==null||c.delete()}if(this._backgroundBlur>0&&i){this.ctx.save(),this.ctx.clipPath(this._currentPath,ut.ClipOp.Intersect,!0);let h=ut.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,ut.TileMode.Clamp,null),c=e.copy();c.setImageFilter(h),c.setAlphaf(1);let d=this._currentPath.computeTightBounds();this.ctx.saveLayer(c,d,null,ut.SaveLayerInitWithPrevious),this.ctx.drawColor(e.getColor()),this.ctx.restore(),this.ctx.restore(),c.delete(),h.delete(),l=!0}if(this._layerBlur>0){let h=e.copy();o=ut.MaskFilter.MakeBlur(ut.BlurStyle.Normal,this._layerBlur*this.dpr*(((s=this.camera)==null?void 0:s.scale)??1),!1),h.setMaskFilter(o),t(h),h.delete(),o.delete(),l=!0}if(l||t(e),i&&this._hasInnerShadow()){let h=new ut.Paint;h.setAntiAlias(!0),h.setStyle(ut.PaintStyle.Fill),h.setColor(dp(this._innerShadowColor));let c;this._innerShadowBlur>0&&(c=ut.MaskFilter.MakeBlur(ut.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(((a=this.camera)==null?void 0:a.scale)??1),!1),h.setMaskFilter(c));let d=this._currentPath.computeTightBounds(),[u,p,f,g]=d,m=f-u,v=g-p;this.ctx.save(),this.ctx.clipPath(this._currentPath,ut.ClipOp.Intersect,!0),this.ctx.saveLayer(h,d,null,ut.SaveLayerInitWithPrevious),(n=this.ctx)==null||n.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(ut.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+m+Math.abs(this._innerShadowOffsetX*2),2e3+v+Math.abs(this._innerShadowOffsetY*2)),h),h.setBlendMode(ut.BlendMode.Clear),this.ctx.drawPath(this._currentPath,h),this.ctx.restore(),this.ctx.restore(),h.delete(),c==null||c.delete()}}}_paintInner(e,t=!0){if(this.ctx&&this._currentPath&&e){let i=this.ctx,r=this._currentPath;this._applyEffectsToPaint(e,s=>{let a=!1;!t&&this._strokeMode!=="center"&&(i.save(),i.clipPath(r,this._strokeMode==="outside"?ut.ClipOp.Difference:ut.ClipOp.Intersect,!0),a=!0),i.drawPath(r,s),a&&i.restore()},t)}}_hasDropShadow(){var e;return((e=this._dropShadowColor)==null?void 0:e.a)>0}_hasInnerShadow(){var e;return((e=this._innerShadowColor)==null?void 0:e.a)>0}path(e){var t;(t=this._currentPath)==null||t.addPath(ut.Path.MakeFromSVGString(e))}ellipse(e,t,i,r,s,a,n,o){var h;if(!EA([e,t,i,r])||!this._currentPath)return;if(i<0||r<0)throw Error("radii cannot be negative");let l=ut.XYWHRect(e-i,t-r,i*2,r*2);(h=this._currentPath)==null||h.addOval(l)}rect(e,t,i,r,s=0,a=0,n=0,o=0){var h,c;let l=ut.XYWHRect(e,t,i,r);if(EA(l))if(s===0&&a===0&&o===0&&n===0)(h=this._currentPath)==null||h.addRect(l);else{let d=ut.RRectXY(l,s,s);d[4]=d[5]=s,d[6]=d[7]=a,d[8]=d[9]=n,d[10]=d[11]=o,(c=this._currentPath)==null||c.addRRect(d)}}getHorizontalAlign(e){switch(e){case 2:return ut.TextAlign.Right;case 3:return ut.TextAlign.Center;case 4:return ut.TextAlign.Justify;case 1:default:return ut.TextAlign.Left}}drawTextInner(e,t,i,[r,s,a,n],o,l,h=!0){let c=0,{ctx:d}=this;if(!d)return c;let u=l.copy(),p=l.copy();return p.setAlphaf(0),this._applyEffectsToPaint(u,f=>{t.pushPaintStyle(i,f,p),t.addText(e);let g=t.build();g.layout(a);let m=s;o===2?m+=(n-g.getHeight())/2:o===3&&(m+=n-g.getHeight()),d.drawParagraph(g,r,m),c=g.getHeight(),t.reset(),g.delete()},h),u.delete(),p.delete(),c}drawText(e,t){let i=0,r=this._fonts.get(t.font),{ctx:s,_paintFill:a,_paintStroke:n}=this;if(r&&s){let o=new ut.TextStyle({fontFamilies:[t.font],fontSize:t.fontSize,heightMultiplier:t.lineHeight,letterSpacing:t.letterSpacing}),l=new ut.ParagraphStyle({textStyle:o,textAlign:this.getHorizontalAlign(t.horizontalAlign)}),h=ut.XYWHRect(t.x,t.y,t.width,t.height),c=ut.ParagraphBuilder.Make(l,r);a&&(i=this.drawTextInner(e,c,o,h,t.verticalAlign,a,!0)),n&&(i=this.drawTextInner(e,c,o,h,t.verticalAlign,n,!1)),c.delete()}return{height:i}}render(){var e;(e=this._surface)==null||e.flush()}moveTo(e,t){var i;(i=this._currentPath)==null||i.moveTo(e,t)}lineTo(e,t){var i;(i=this._currentPath)==null||i.lineTo(e,t)}bezierCurveTo(e,t,i,r,s,a){var n;(n=this._currentPath)==null||n.cubicTo(e,t,i,r,s,a)}quadraticCurveTo(e,t,i,r){var s;(s=this._currentPath)==null||s.quadTo(e,t,i,r)}setTransform(e,t=!1){var s,a,n,o,l;if(!this.ctx)return;let i=this.ctx.getTotalMatrix(),r=Lt.invert(i);if(r&&this.ctx.concat(r),(s=this.ctx)==null||s.scale(this.dpr,this.dpr),((a=this.camera)==null?void 0:a.enabled)&&((n=this.ctx)==null||n.concat(this.camera.worldMatrix),t)){let h=Lt.getScale(this.camera.worldMatrix);(o=this.ctx)==null||o.scale(1/h[0],1/h[1])}(l=this.ctx)==null||l.concat(e),this.currentTransform=e}transform(e){var t;(t=this.ctx)==null||t.concat(e)}setSize(e,t){var i;!this._isSizeDirty&&e===this._width&&t===this._height||(this._isSizeDirty=!1,this._width=e,this._height=t,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this.canvas.width=e*this.dpr,this.canvas.height=t*this.dpr,this._surface&&(this._surface=ut.MakeWebGLCanvasSurface(this.canvas),this.ctx=(i=this._surface)==null?void 0:i.getCanvas()))}};function EA(e){for(let t=0;t0?this.stroke.color:Ht.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ht.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ht.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.type===0&&(Qt(e.path,["fill"])?this.fill.update(e.props):Qt(e.path,["stroke"])?this.stroke.update(e.props):Qt(e.path,["dropShadow"])?this.dropShadow.update(e.props):Qt(e.path,["innerShadow"])?this.innerShadow.update(e.props):Qt(e.path,["layerBlur"])?this.layerBlur.update(e.props):Qt(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let t=new er(this.uuid,this.data,e);return t.parent=void 0,t}},$1=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.width=0,this.height=0,this.updateState(t,i)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return wJ(e,t,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new $1(this.uuid,this.data,e);return t.parent=void 0,t}},Xd=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.width=0,this.height=0,this.cornerRadius=[0,0,0,0],this.updateState(t,i)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new Xd(this.uuid,this.data,e);return t.parent=void 0,t}},ex=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this._textHeight=0,this._textHeightDirty=!0,this.width=0,this.height=0,this.updateState(t,i)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ht.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ht.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){var a;(a=this._fontHolder)!=null&&a.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let t=this.data.textTransform,i=this.data.text.textValue.toString(),r=t===2?i.toUpperCase():t===3?i.toLowerCase():i,{height:s}=e.drawText(r,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=s}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new ex(this.uuid,this.data,e);return t.parent=void 0,t}},tP=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.curves=[],this.extremasBBox={min:[0,0],max:[0,0]},this.updateState(t,i)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(r=>Uf.extremas(r)),t=[1/0,1/0],i=[-1/0,-1/0];for(let r=0,s=e.length;ri[0]&&(i[0]=a[1][0]),a[1][1]>i[1]&&(i[1]=a[1][1])}return this.extremasBBox.min=[t[0],t[1]],this.extremasBBox.max=[i[0],i[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let i=1,r=this.data.points.length;i{function t(n){let o=n.start,l=n.cp1,h=n.cp2,c=n.end,d=[3*(l[0]-o[0]),3*(l[1]-o[1])],u=[3*(h[0]-l[0]),3*(h[1]-l[1])],p=[3*(c[0]-h[0]),3*(c[1]-h[1])],f={start:d,cp:u,end:p};return n.derivative=f,f.derivative=yy.derive(f),f}e.derive=t;function i(n,o,l,h=!1){let c=n-2*o+l;if(c!==0){let d=-Math.sqrt(Math.abs(o*o-n*l)),u=-n+o,p=-(d+u)/c,f=-(-d+u)/c;return[p,f]}else if(o!==l&&c===0)return[(2*o-l)/(2*(o-l))];return[]}function r(n){let o=n.derivative??e.derive(n),l=o.start,h=o.cp,c=o.end;return[i(l[0],h[0],c[0]),i(l[1],h[1],c[1])]}e.droot=r;function s(n){let[o,l]=e.droot(n),h=[n.start[0],n.end[0]],c=[n.start[1],n.end[1]];for(let d of o)h.push(e.compute(n,Math.min(1,Math.max(0,d)))[0]);for(let d of l)c.push(e.compute(n,Math.min(1,Math.max(0,d)))[1]);return h.sort((d,u)=>d-u),c.sort((d,u)=>d-u),[[h[0],c[0]],[h[h.length-1],c[c.length-1]]]}e.extremas=s;function a(n,o){if(o===0)return[...n.start];if(o===1)return[...n.end];let l=1-o,h=l*l,c=o*o,d=h*l,u=h*o*3,p=l*c*3,f=o*c;return[d*n.start[0]+u*n.cp1[0]+p*n.cp2[0]+f*n.end[0],d*n.start[1]+u*n.cp1[1]+p*n.cp2[1]+f*n.end[1]]}e.compute=a})(Uf||(Uf={}));var yy;(e=>{function t(s){let a=s.start,n=s.cp,o=s.end,l=[2*(n[0]-a[0]),2*(n[1]-a[1])],h=[2*(o[0]-n[0]),2*(o[1]-n[1])],c={start:l,end:h};return c.derivative=xy.derive(c),s.derivative=c,c}e.derive=t;function i(s){let a=s.derivative??e.derive(s),n=a.start,o=a.end;return[n[0]!==o[0]?n[0]/(n[0]-o[0]):0,n[1]!==o[1]?n[1]/(n[1]-o[1]):0]}e.droot=i;function r(s,a){if(a===0)return[...s.start];if(a===1)return[...s.end];let n=1-a,o=n*n,l=a*a,h=o,c=n*a*2,d=l;return[h*s.start[0]+c*s.cp[0]+d*s.end[0],h*s.start[1]+c*s.cp[1]+d*s.end[1]]}e.compute=r})(yy||(yy={}));var xy;(e=>{function t(r){let s=r.start,a=r.end,n=[a[0]-s[0],a[1]-s[1]];return r.derivative=n,r.derivative}e.derive=t;function i(r,s){if(s===0)return[...r.start];if(s===1)return[...r.end];let a=r.start,n=r.end;return[a[0]+(n[0]-a[0])*s,a[1]+(n[1]-a[1])*s]}e.compute=i})(xy||(xy={}));var Ma=class extends ks{constructor(e,t,i){super(e,t,i),this.uuid=e,this.width=0,this.height=0,this.clipped=!0,this.background=new Xd(e+"-background",Ed.defaultData,i),this.background.parent=this,this.updateState(t,i)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){var e;super.updateLocalMatrix(),(e=this.background)==null||e.updateLocalMatrix()}updateWorldMatrix(e,t,i){var r;super.updateWorldMatrix(e,t,i),(r=this.background)==null||r.updateWorldMatrix(e,t,i)}draw(e){if(!this.visible)return;e.save();let t=this.width,i=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=i,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,i,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.type===0&&(Qt(e.path,["fill"])?this.fill.update(e.props):Qt(e.path,["stroke"])?this.stroke.update(e.props):Qt(e.path,["dropShadow"])?this.dropShadow.update(e.props):Qt(e.path,["innerShadow"])?this.innerShadow.update(e.props):Qt(e.path,["layerBlur"])?this.layerBlur.update(e.props):Qt(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new Ma(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}},PJ=xo(Q2(),1),mm=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this._pathBBox=new DOMRect,this.path="",this.updateState(t,i),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new mm(this.uuid,this.data,e);return t.parent=void 0,t}};function DJ(e,t=1,i=1){if(t<=0||i<=0)return e;let r=(0,PJ.parseSVG)(e).map(s=>{let a={...s};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*i),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*i),"y2"in a&&(a.y2=a.y2*i),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*i),a});return IJ(r)}function IJ(e){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],i;return e.map(r=>{let s=[];t.forEach(n=>{if(n in r){let o=r[n]*1;s.length&&o>=0&&s.push(","),s.push(o)}});let a=(i===r.code?s[0]<0?"":",":r.code)+s.join("");return i=r.code,a}).join("")}function OJ(e,t,i){switch(t.type){case"ellipse2d":return new $1(e,t,i);case"rectangle2d":return new Xd(e,t,i);case"text2d":return new ex(e,t,i);case"vector2d":return new tP(e,t,i);case"path2d":return new mm(e,t,i);case"frame2d":return new Ma(e,t,i);case"group2d":default:return new po(e,t,i)}}var iP=class{constructor(e,t,i){this.uuid=e,this.data=t,this.group=new po(iP.GROUP_ID,{...Cf.defaultData},i),this.createChildrenObjects(t.objects,this.group,i)}createObject(e,t,i,r,s,a){let n=OJ(e,t,a);n&&(r.add(n),r.children.splice(s,0,r.children.pop()),n.updateWorldMatrix(),i.length>0&&(n instanceof po||n instanceof Ma)&&this.createChildrenObjects(i,n,a))}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}draw(e){this.group.draw(e)}updateEntityByOp(e,t,i,r){let s=this.find(e);if(s)try{s.updateByOp(t,i,{shared:r})}catch(a){console.error(a)}}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this.group:this.find(e.parent);i!==void 0&&i instanceof ks&&(this.createObject(e.id,e.data,e.children,i,e.localIndex,t),i.requestRender())}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i!==void 0&&i.parent!==void 0&&i.parent instanceof ks){let r=i.parent;i.resetBBoxNeedsUpdate(),r==null||r.remove(i),r==null||r.requestRender()}}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i!==void 0){let r=i.parent,s=e.parent===null?this:this.find(e.parent);if(s instanceof ks||s===this){s.add(i);let a=e.localIndex;s.children.splice(a,0,s.children.pop()),i.updateWorldMatrix(!0,!1,!0),r==null||r.requestRender(),i.requestRender()}i.resetBBoxNeedsUpdate()}}}add(e){this.group.add(e)}remove(e){this.group.remove(e)}traverse(e){this.group.traverse(t=>{t!==this.group&&e(t)})}intersectsChildren(e,t,i,r=!1,s=[]){return this.group.intersectsChildren(e,t,i,r,s,!0)}intersectsChildrenReverse(e,t,i,r=!1,s=[]){return this.group.intersectsChildrenReverse(e,t,i,r,s,!0)}find(e){return this.group.find(e)}get children(){return this.group.children}project(e,t){return this.group.project(e,t)}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this.group;){let s=r;r=r.parent;let a=r.children.indexOf(s);i.splice(0,0,a)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>FE(i.sortKey,r.sortKey)),t.map(i=>i.entity)}},tx=iP;tx.GROUP_ID="scene2d";function rP({constraints:e,newParentWidth:t,newParentHeight:i,initialParentWidth:r,initialParentHeight:s,objectInitialWidth:a,objectInitialHeight:n,objectInitialPosition:o}){let{horizontalConstraint:l,verticalConstraint:h}=e,c=t-r,d=i-s,u=a,p=n,f=o[0],g=o[1];if(l!==0){if(l===1)f+=c;else if(l===3)f+=c/2;else if(l===2)u=Math.max(1,u+c);else if(l===4){let m=t/r;u*=m,f*=m}}if(h!==0){if(h===1)g+=d;else if(h===3)g+=d/2;else if(h===2)p=Math.max(1,p+d);else if(h===4){let m=i/s;p*=m,g*=m}}return{width:u,height:p,position:[f,g]}}xo(Q2(),1);var RJ=` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,LJ=` uniform sampler2D tDiffuse; varying vec2 vUv; void main() { vec4 texel = texture2D( tDiffuse, vUv ); gl_FragColor = texel; }`,zJ=new Xf(-1,1,1,-1,0,1),BJ=class extends Ge{constructor(){super(),this.setAttribute("position",new Ie([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ie([0,2,0,0,2,0],2))}},FJ=new BJ,UJ=class{constructor(e){this._mesh=new Jt(FJ,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,zJ)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},sP=new Dt({defines:{},uniforms:{tDiffuse:new ye(null)},vertexShader:RJ,fragmentShader:LJ}),NJ=new UJ(sP),rv=null,sv=null,kJ=()=>(rv===null&&(rv=document.createElement("canvas")),rv),VJ=e=>(sv===null&&(sv=new eP(e)),sv),jJ=Lt.identity(),aP=class{constructor(e,t,i,r){this.uuid=e,this.width=t,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()},this._innerApplySize=()=>{let s=this.width,a=this.height,n=this.dpr;this.renderer.dpr=this.isScreenSpace?n:Math.floor(2048/Math.max(s,a)),this.renderer.setSize(s,a)},this.onFrameOverrideObjectEvent=s=>{var a,n;if(((a=s.target)==null?void 0:a.uuid)!==void 0){let o=(n=this.frameRoot)==null?void 0:n.find(s.target.uuid);o&&o.dispatchEvent({...s,target:o})}},this.scene2d=new tx(Re.generateUUID(),j0.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=kJ(),this.renderer=VJ(this.canvas),this.promise=this.init(),this.renderTarget=new Pt(1,1,{type:mn,stencilBuffer:!1,depthBuffer:!1}),r.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=r.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new GF(this.canvas)),this._canvasTexture}async init(){this.renderer instanceof eP&&(this.renderer.wasmURL=TT.skiaWasmUrl),await this.renderer.init()}render(e){var t,i;if(this.isFrameDirty){this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),(t=this.frameOverride)==null||t.draw(this.renderer),this.renderer.render(),sP.uniforms.tDiffuse.value=this.canvasTexture,this.canvasTexture.needsUpdate=!0;let r=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.clear(),NJ.render(e),e.setRenderTarget(r),(i=this.textureHolder)==null||i.setNeedsUpdate(!0)}}updateEntity2DByOp(e,t,i,r){this.scene2d.updateEntityByOp(e,t,i,r),this.applySize()}updateTreeByOp(e,t){this.scene2d.updateTreeByOp(e,t),this.applySize()}applyOverrides(e){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let t=(e==null?void 0:e.width)??this.width,i=(e==null?void 0:e.height)??this.height;this.frameOverride.width=t,this.frameOverride.height=i,this.frameOverride.localMatrix=jJ,this.isScreenSpace&&(this.frameOverride.fill.color=Ht.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:t,height:i},nP({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(e,t=window.devicePixelRatio){var o,l;let i=Math.max(1,(e==null?void 0:e.width)??this.width),r=Math.max(1,(e==null?void 0:e.height)??this.height);this.dpr=t,this.width=i,this.height=r,this._innerApplySize();let s=1,a=512,n=512;(i*t{s.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(s=>{s.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),(r=this.frame)==null||r.requestRender(),t}get frame(){return this.frameOverride}get frameId(){var e;return(e=this.frame)==null?void 0:e.uuid}find(e){return this.scene2d.find(e)}get texture(){var e;return(e=this.textureHolder)==null?void 0:e.getTexture(1001)}disposeFrameOverride(){var e,t,i;(e=this.frameOverride)==null||e.removeEventListener("render",this.onRenderRequestedDownstream),(t=this.frameOverride)==null||t.traverse(r=>{r.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),(i=this.frameOverride)==null||i.traverse(r=>{r.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function nP({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:a}){if(e instanceof Ma&&t instanceof Ma||e instanceof po&&t instanceof po)for(let n=0,o=e.children.length;n{var i,r;(i=this.uiCanvas)==null||i.applyFrame(e),(r=this.uiCanvas)==null||r.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Nr(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof ul&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof xl)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&lJ(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let i=this.scene;i.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Nr(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Nr(e.aoColor,t))}updateByOp(e,t,i,r){let s=this.data.uiFrame;super.updateByOp(e,t,i,r);let a=t;Qt(e.path,["fog"])?this.updateFog(a.fog,i.shared):Qt(e.path,["ao"])?this.updateAo(a.ao,i.shared):Qt(e.path,["ambient"])?this.updateAmbientLight(a.ambient,i.shared):Qt(e.path,["shadow"])?this.updateShadow(a.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||s!==a.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Nr(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){var e;return((e=this.scene)==null?void 0:e.find(this.data.publish.playCamera))??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof ZT&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize??.5,e+=1),i instanceof KT&&i.visible&&e<2&&(this.penumbraSizeArrayCache[3+t]=i.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;Tt.is(s)&&(s.visible||a!=null&&a.object.data.visible)&&((Ns(s)||cy(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),wy(s,e,t,!0)),i(s))}};return i(this),t}updateEntity2DByOp(e,t,i,r){var s;(s=this.uiCanvas)==null||s.updateEntity2DByOp(e,t,i,r)}},qJ=class extends Z1(RU,XT){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let s=new M(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),a=new M(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),n=new Si(s,a),o=new Kp(n,new et(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let e in this.gizmos){let t=this.gizmos[e];if(t instanceof Kp){let i=this.shadow.camera,r=new M(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new M(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);t.box.set(r,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},XJ=class extends Ii{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?N1(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},ix=class extends Ii{constructor(e,t,i){super(e,t,i),this._shapeId=null,this._context=i}updateState(e,t){super.updateState(e,t),this.updateShape(),this.refreshAttachedCloners(t)}updateShape(){var r;let e={...this.data.geometry.extrusion.shape};for(let s in e)typeof e[s]=="string"&&(e[s]=this._context.shared.getVariable(e[s],[this.uuid,"geometry","extrusion","shape",s]));let t;if(e.type==="Custom"){let s=e.shapeId;if(s!==this._shapeId&&this.detachShape(),s){this._shapeId=s;let a=this._context.scene.find(s);a!=null&&a.data&&(a.attachedPaths.add(this),t=(r=a.geometry.userData)==null?void 0:r.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let s;switch(e.type){case"Rectangle":s=U1;break;case"Ellipse":s=F1;break;case"Polygon":s=HC;break;case"Star":s=WC;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=s.create({parameters:e}).userData.shape}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build())}detachShape(){var e;this._shapeId!==null&&((e=this._context.scene.find(this._shapeId))==null||e.attachedPaths.delete(this))}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?N1(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},rx=class extends Q1{constructor(e,t,i){super(e,t,i),this.data=t}},Eh=class extends ac(hn,Wd){constructor(e,t,i){super(),t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,i)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let i=Sf.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(i){let r,s;for(let a of Jn.rootOverrideProps)e[a]===void 0?(r===void 0&&(r={...e}),r[a]=i.data[a]):(s===void 0&&(s={}),s[a]=e[a],r===void 0&&(r={...e}),r[a]=so.apply(i.data[a],e[a]));return this.overrideData=s,r}else return{...Hi.defaultData,...e,...Sa(Hi.defaultData,Jn.rootOverrideProps)}}updateByOp(e,t,i,r){let s;if(this.isInstanceRoot&&!r){if(t=this.transformAssignData(t,i),e.type===0&&e.path.length===0&&this.component)for(let a of Jn.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Jn.rootOverrideProps.includes(e.path[0])){let a=e.path[0];s===void 0&&(s={...e,path:[],props:{[a]:t[a]}})}}super.updateByOp(s??e,t,i,r)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let i=e.scene.find(t.component)??null,r=!1;if(i!==this.oldComponent){if(this.oldComponent){let s=0;for(let a of this.children)if(Tt.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),sx(a),s+=1;else break;this.children.splice(0,s)}r=!0}if(i){let s={};oP(e,[this.uuid],t.overrides,this,i,i,0,r,s);for(let a of this.children)if(Tt.is(a)){let n=a.data;n.type==="Empty"&&n.animations&&a.traverseEntity(o=>{let l=o.dataPatched;if(o instanceof Ii&&l.bones&&l.boneInverses){let h=o.dataPatched;if(h.bones&&h.boneInverses){let c=h.bones.map(p=>e.scene.find(s[p])),d=h.boneInverses.map(p=>new we().fromArray(p)),u=new qy(c,d);o.bind(u,o.bindMatrix)}}else o.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function sx(e){if(e.component){let t=e.component.instances.indexOf(e);t>=0&&e.component.instances.splice(t,1);for(let i of e.children)Tt.is(i)&&sx(i)}}function PA(e,t,i,r){return e.component===t&&y1(e.identity,r)?e.overrideData===i?2:1:0}function oP(e,t,i,r,s,a,n,o,l){if(n>50)return!1;if(r.component!==s){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}s.instances.find(c=>c===r)||s.instances.push(r),r.component=s}s instanceof Eh&&s.isInstanceRoot&&s.expandInstanceChildren(e);let h=0;for(let c of s.children)if(Tt.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],u=xf.resolve(i,d,1);u!=null&&!(u instanceof Ri)&&(Object.setPrototypeOf(u,Ri.prototype),console.error("wrong prototype"));let p=null,f;if(!o){let g=r.children[h];if(p=Tt.is(g)?g:null,p!==null){let m=PA(p,c,u,d);f=m>=1?p.stateSelection:void 0,m!==2&&(p=null)}if(p===null&&(p=e.scene.findInstance(d)??null,p!==null)){let m=PA(p,c,u,d);if(f=m>=1?p.stateSelection:void 0,m!==2)p=null;else{let v=p.parent.children.indexOf(p);p.parent.children.splice(v,1),r.children.splice(h,0,p),p.parent===r?v<=h&&console.error("not possible"):(p.parent=r,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),e.pendingDeletes.delete(p))}}}if(p===null){let g=u?so.apply(c.data,u):c.data;hl.is(g.type)&&(g={...g,type:"Empty"}),p=$n.createEntity(d,g,e),p.overrideData=u,r.add(p),r.children.splice(r.children.length-1,1),r.children.splice(h,0,p),p.updateState(p.data,e),f&&p.changeSelectedState(f,e),e.scene.registerInstanceAndSetUuid(p)}if(p.isBone){let g=p.identity[p.identity.length-1];l[g]=p.uuid}h+=1,oP(e,t,i,p,c,a,n+1,o,l)}if(!o){let c=h;for(;;){let d=r.children[h];if(Tt.is(d))e.pendingDeletes.add(d);else break;h+=1}r.children.splice(c,h-c)}return!0}var YJ=class extends ac(_M,Wd){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(e,t){this.updateState_Entity(e,t)}},Sr=class extends Ii{constructor(e,t,i){super(e,t,i),this.onBeforeRender=r=>{this.uiCanvas.render(r)},this.uiCanvas=new aP(e+"-canvas",t.geometry.width,t.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,t){let i=(e==null?void 0:e.width)??this.dataPatched.geometry.width,r=(e==null?void 0:e.height)??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){var i;let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),(i=this.localGeometry)==null||i.dispose(),this.localGeometry=Dd(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let i=t.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,t,i,r){this.uiCanvas.updateEntity2DByOp(e,t,i,r),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):Qt(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){var e;return(e=this.frame)==null?void 0:e.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}},QJ=class{constructor(e,t,i){this.variables=[],this.currentTextureIndex=0;let r=jt,s=new Jr,a=new bo;a.position.z=1;let n={passThruTexture:{value:null}},o=c(u(),n),l=new Jt(new Ea(2,2),o);s.add(l),this.setDataType=function(p){return r=p,this},this.addVariable=function(p,f,g){let m=this.createShaderMaterial(f),v={name:p,initialValueTexture:g,material:m,dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:_t,magFilter:_t};return this.variables.push(v),v},this.setVariableDependencies=function(p,f){p.dependencies=f},this.init=function(){if(i.capabilities.isWebGL2===!1&&i.extensions.has("OES_texture_float")===!1)return"No OES_texture_float support for float textures.";if(i.capabilities.maxVertexTextures===0)return"No support for vertex shader textures.";for(let p=0;pe){s=a;break}else e1&&(s=1-s,a=1-a),or.a.fromBufferAttribute(this.positionAttribute,e*3),or.b.fromBufferAttribute(this.positionAttribute,e*3+1),or.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(or.a,s).addScaledVector(or.b,a).addScaledVector(or.c,1-(s+a)),i!==void 0&&or.getNormal(i),r!==void 0&&this.colorAttribute!==void 0&&(or.a.fromBufferAttribute(this.colorAttribute,e*3),or.b.fromBufferAttribute(this.colorAttribute,e*3+1),or.c.fromBufferAttribute(this.colorAttribute,e*3+2),up.set(0,0,0).addScaledVector(or.a,s).addScaledVector(or.b,a).addScaledVector(or.c,1-(s+a)),r.r=up.x,r.g=up.y,r.b=up.z),this}};function KJ(e){let t=new Float32Array(e*e*2);for(let i=0;i .5) { float isColliding = step(0.5, collisionFlag); // 1.0 if collisionFlag > 0.5, otherwise 0.0 float bounceOffset = 3.0 * isColliding; // Becomes 3.0 if colliding, 0.0 otherwise vec3 collisionAdjustedVelocity = velocity * (1.0 + bounceOffset); // Update position based on collision or normal movement vec3 fpsVelocity = velocity * min(uFPSRatio, 5.0); position += mix(fpsVelocity, collisionAdjustedVelocity, isColliding); // EMISSION RATE - BIRTH // if (isSpawning == 1.0) { // Better Approach to avoid If statement vec3 newPosition = applyQuaternionToVector(uWorldQuaternion, originalPosition) + uWorldOffset; originalPosition = mix(originalPosition, newPosition, isSpawning); position = mix(position, originalPosition, isSpawning);; timeStart = mix(timeStart, uTime, isSpawning); // Calculate timeLeft for life normalization float timeLeft = max(lifeTime - (uTime - timeStart), 0.0); float life_Normalize = timeLeft / lifeTime; // Use isActive to blend between the calculated color and black vec4 activeColor = vec4(position, life_Normalize); // if (isActive == 1.0) { gl_FragColor = mix(vec4(0.0), activeColor, isActive); } `,r$=` vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 permute(vec4 x) { return mod289(((x*34.0)+1.0)*x); } vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } vec3 fade(vec3 t) { return t*t*t*(t*(t*6.0-15.0)+10.0); } float snoise(vec3 v) { const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); vec3 i = floor(v + dot(v, C.yyy) ); vec3 x0 = v - i + dot(i, C.xxx) ; vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min( g.xyz, l.zxy ); vec3 i2 = max( g.xyz, l.zxy ); vec3 x1 = x0 - i1 + C.xxx; vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y // Permutations i = mod289(i); vec4 p = permute( permute( permute( i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); // Gradients: 7x7 points over a square, mapped onto an octahedron. // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) float n_ = 0.142857142857; // 1.0/7.0 vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) vec4 x = x_ *ns.x + ns.yyyy; vec4 y = y_ *ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4( x.xy, y.xy ); vec4 b1 = vec4( x.zw, y.zw ); vec4 s0 = floor(b0)*2.0 + 1.0; vec4 s1 = floor(b1)*2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; vec3 p0 = vec3(a0.xy,h.x); vec3 p1 = vec3(a0.zw,h.y); vec3 p2 = vec3(a1.xy,h.z); vec3 p3 = vec3(a1.zw,h.w); //Normalise gradients vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; // Mix final noise value vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); } vec3 snoiseVec3( vec3 x ){ float s = snoise(vec3( x )); float s1 = snoise(vec3( x.y - 19.1 , x.z + 33.4 , x.x + 47.2 )); float s2 = snoise(vec3( x.z + 74.2 , x.x - 124.5 , x.y + 99.4 )); vec3 c = vec3( s , s1 , s2 ); return c; } vec3 curlNoise( vec3 p, float seed){ p += seed; const float e = .1; vec3 dx = vec3( e , 0.0 , 0.0 ); vec3 dy = vec3( 0.0 , e , 0.0 ); vec3 dz = vec3( 0.0 , 0.0 , e ); vec3 p_x0 = snoiseVec3( p - dx ); vec3 p_x1 = snoiseVec3( p + dx ); vec3 p_y0 = snoiseVec3( p - dy ); vec3 p_y1 = snoiseVec3( p + dy ); vec3 p_z0 = snoiseVec3( p - dz ); vec3 p_z1 = snoiseVec3( p + dz ); float x = p_y1.z - p_y0.z - p_z1.y + p_z0.y; float y = p_z1.x - p_z0.x - p_x1.z + p_x0.z; float z = p_x1.y - p_x0.y - p_y1.x + p_y0.x; const float divisor = 1.0 / ( 2.0 * e ); return normalize( vec3( x , y , z ) * divisor ); } // Classic Perlin noise float cnoise(vec3 P) { vec3 Pi0 = floor(P); // Integer part for indexing vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1 Pi0 = mod289(Pi0); Pi1 = mod289(Pi1); vec3 Pf0 = fract(P); // Fractional part for interpolation vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0 vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); vec4 iy = vec4(Pi0.yy, Pi1.yy); vec4 iz0 = Pi0.zzzz; vec4 iz1 = Pi1.zzzz; vec4 ixy = permute(permute(ix) + iy); vec4 ixy0 = permute(ixy + iz0); vec4 ixy1 = permute(ixy + iz1); vec4 gx0 = ixy0 * (1.0 / 7.0); vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5; gx0 = fract(gx0); vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0); vec4 sz0 = step(gz0, vec4(0.0)); gx0 -= sz0 * (step(0.0, gx0) - 0.5); gy0 -= sz0 * (step(0.0, gy0) - 0.5); vec4 gx1 = ixy1 * (1.0 / 7.0); vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5; gx1 = fract(gx1); vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1); vec4 sz1 = step(gz1, vec4(0.0)); gx1 -= sz1 * (step(0.0, gx1) - 0.5); gy1 -= sz1 * (step(0.0, gy1) - 0.5); vec3 g000 = vec3(gx0.x,gy0.x,gz0.x); vec3 g100 = vec3(gx0.y,gy0.y,gz0.y); vec3 g010 = vec3(gx0.z,gy0.z,gz0.z); vec3 g110 = vec3(gx0.w,gy0.w,gz0.w); vec3 g001 = vec3(gx1.x,gy1.x,gz1.x); vec3 g101 = vec3(gx1.y,gy1.y,gz1.y); vec3 g011 = vec3(gx1.z,gy1.z,gz1.z); vec3 g111 = vec3(gx1.w,gy1.w,gz1.w); vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); g000 *= norm0.x; g010 *= norm0.y; g100 *= norm0.z; g110 *= norm0.w; vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); g001 *= norm1.x; g011 *= norm1.y; g101 *= norm1.z; g111 *= norm1.w; float n000 = dot(g000, Pf0); float n100 = dot(g100, vec3(Pf1.x, Pf0.yz)); float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)); float n110 = dot(g110, vec3(Pf1.xy, Pf0.z)); float n001 = dot(g001, vec3(Pf0.xy, Pf1.z)); float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)); float n011 = dot(g011, vec3(Pf0.x, Pf1.yz)); float n111 = dot(g111, Pf1); vec3 fade_xyz = fade(Pf0); vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z); vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y); float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); return 2.2 * n_xyz; } vec3 fbm_vec3(vec3 p, float frequency, float offset) { return vec3( cnoise((p+vec3(offset))*frequency), cnoise((p+vec3(offset+20.0))*frequency), cnoise((p+vec3(offset-30.0))*frequency) ); } `,s$=` #ifdef USE_COLLIDER float restitution = max(uBounce * 2., .01); // Energy Loss // SPHERE COLLIDER // ************************************************************** #ifdef USE_SPHERE_COLLIDER // Convert collider size to radii (assuming uColliderSize is the diameter in each axis) vec3 radii = uColliderSize; // Adjust position relative to collider vec3 relPos = position - uColliderPos; // Apply rotation of the collider to the relative position relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); // Scale relative position by radii (for ellipsoid collision detection) vec3 scaledPos = relPos / radii; // Calculate ellipsoidal distance float dist = length(scaledPos); // Distance in terms of ellipsoid // Check for collision if (dist <= 1. + particleSize / length(radii) && collisionFlag == 0.0) { // Compute the normal at the collision point, accounting for particle size vec3 adjustedPos = scaledPos * (1.0 + particleSize / length(radii)); // Compute the normal at the collision point vec3 normal = ellipsoidNormal(adjustedPos, radii); // Rotate the normal back to world space normal = applyQuaternionToVector(uColliderQuaternion, normal); // Reflect the velocity vector off the normal velocity = reflect(velocity, normal) * restitution; collisionFlag = 1.0; } else { collisionFlag = 0.0; } #endif // BOX COLLIDER or PLANE COLLIDER // ************************************************************** #ifdef USE_BOX_COLLIDER // Box dimensions and repulsion variables vec3 boxHalfSize = uColliderSize / 2.0; // Convert world position to box's local space vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); // Collision detection vec3 localDistance = abs(localPos) - boxHalfSize; float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z)); // Collision Detected if (distToSurface <= particleSize * 0.5 && collisionFlag == 0.0) { // Find the nearest face normal for bounce direction vec3 normal; if (localDistance.x > localDistance.y && localDistance.x > localDistance.z) { normal = vec3(sign(localPos.x), 0.0, 0.0); } else if (localDistance.y > localDistance.z) { normal = vec3(0.0, sign(localPos.y), 0.0); } else { normal = vec3(0.0, 0.0, sign(localPos.z)); } // Rotate normal back to world space normal = applyQuaternionToVector(uColliderQuaternion, normal); // Reflect velocity and apply repulsion force velocity = reflect(velocity, normal) * restitution; collisionFlag = 1.0; } else { collisionFlag = 0.0; } #endif #endif // END COLLIDER `,a$=` #ifdef USE_ATTRACTOR #ifdef USE_SPHERE_COLLIDER // Convert collider size to radii (assuming uColliderSize is the diameter in each axis) vec3 radii = uColliderSize; // Adjust position relative to collider vec3 relPos = position - uColliderPos; // Apply rotation of the collider to the relative position relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); // Scale relative position by radii (for ellipsoid collision detection) vec3 scaledPos = relPos / radii; // Calculate ellipsoidal distance float distToSurface = length(scaledPos); // Distance in terms of ellipsoid float insideCheck = 1.0; #endif #ifdef USE_BOX_COLLIDER // Box dimensions vec3 boxHalfSize = uColliderSize / 2.0; // Convert world position to box's local space vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); vec3 localDistance = abs(localPos) - boxHalfSize; float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z)); float insideCheck = particleSize; #endif // Apply vortex force inside the Helper #ifdef USE_FORCE_LOCAL_SPACE if (distToSurface <= insideCheck ) { // Define parameters for the attractor field #ifdef USE_SPHERE_COLLIDER float attractorStrength = (1.0 - distToSurface ) * uForceIntensity; // Adjust as needed #endif #ifdef USE_BOX_COLLIDER float attractorStrength = max((1.0 - insideCheck / distToSurface), 0.) * uForceIntensity; // Adjust as needed #endif float attractorDamping = uForceDamping; // Adjust as needed (higher values will attenuate velocity more) // Use the same radii calculation code as for the collider vec3 attractorRadii = uColliderSize; // Adjust position relative to attractor center vec3 relPos = position - uColliderPos; // Apply rotation of the collider to the relative position relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); // Scale relative position by radii (for ellipsoid attraction) vec3 scaledPos = relPos / attractorRadii; // Calculate ellipsoidal distance as attractor radius float attractorRadius = length(scaledPos); // Calculate the distance from the attractor center vec3 relativePosition = position - uColliderPos; // Calculate the force vector towards the attractor center vec3 attractorForce = normalize(relativePosition) * attractorStrength; // Apply the attractor force to the particle velocity -= attractorForce; // Attenuate the particle's velocity velocity *= attractorDamping; } #else // Calculate the distance from the attractor center vec3 relativePosition = position - uColliderPos; // Calculate the force vector towards the attractor center vec3 attractorForce = normalize(relativePosition) * uForceIntensity; // Apply the attractor force to the particle velocity -= attractorForce; // Attenuate the particle's velocity velocity *= uForceDamping; #endif #endif `,n$=` #ifdef USE_VORTEX // Box dimensions vec3 boxHalfSize = uColliderSize / 2.0; // Convert world position to box's local space vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); vec3 localDistance = abs(localPos) - boxHalfSize; float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z)); // Apply vortex force inside the box if (distToSurface <= particleSize) { float vortexStrength = uForceIntensity; vec3 localTopCenter = vec3(0.0, 0., 0.0); // Transform the local top center to the world space vec3 vortexCenter = uColliderPos + applyQuaternionToVector(uColliderQuaternion, localTopCenter); // Calculate the vector from particle to vortex center vec3 vortexVector = vortexCenter - position; // Calculate the rotation axis from the inverse of the collider's quaternion and the fixed up vector // Note: important to add a tiny z component to the up vector to avoid instability vec3 upVector = vec3(0.0, 1.0, 0.01); vec3 rotationAxis = cross(upVector, applyQuaternionToVector(uColliderQuaternion, vortexVector)); rotationAxis = normalize(rotationAxis); // Add rotational component to velocity float rotationSpeed = length(vortexVector * vortexStrength * 3.0) ; vec3 rotationVelocity = rotationAxis * rotationSpeed; // velocity += rotationVelocity * 0.005 ; velocity = rotationVelocity * 0.005 ; // Calculate vortex force // vec3 vortexForce = normalize(vortexVector) * uSpeed * .1 ; // Apply the vortex force to the particle vec3 originDirection = applyQuaternionToVector(uWorldQuaternion, directions); velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5); } #endif `,o$=` // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU uniform sampler2D uOriginalPosition; uniform sampler2D uDirections; uniform vec3 uDirectionsAxis; uniform vec4 uWorldQuaternion; uniform vec3 uGravity; uniform float uNoiseStrength; // Variation of the noise uniform float uNoiseScale; // Scale of the noise uniform float uNoiseSeed; // Seed of the noise uniform float particleSize; uniform float uSpeed; // update speed of the particles uniform float uRandomMassFactor; // COLLIDER uniform vec3 uColliderPos; // Collider Position uniform vec3 uColliderSize; // Collider Dimension uniform vec4 uColliderQuaternion; // Collider Rotation uniform vec4 uColliderQuaternionInvert; // Collider Rotation uniform float uBounce; // Bounce factor uniform float uForceDamping; uniform float uForceIntensity; `+r$+` float rand(vec2 co){ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453); } vec3 applyQuaternionToVector( vec4 q, vec3 v ){ return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v ); } vec3 applyForce(vec3 force, float mass) { vec3 acceleration = force / mass; return acceleration; } vec4 conjugate(vec4 q) { return vec4(q.w, -q.x, -q.y, -q.z); } // Function to compute the normal of the ellipsoid at a given point vec3 ellipsoidNormal(vec3 p, vec3 radii) { return normalize(p / (radii * radii)); } float friction = .3; void main() { vec2 vUv = gl_FragCoord.xy / resolution.xy; vec3 position = texture2D( uCurrentPosition, vUv ).xyz; vec3 originalPosition = texture2D( uOriginalPosition, vUv ).xyz; float timeLeft = texture2D( uCurrentPosition, vUv ).w; vec3 directions = texture2D( uDirections, vUv ).xyz; vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz; float mass = rand(originalPosition.xy) * 0.5 + 0.5; float isSpawning = texture2D( uCurrentEmissionRate, vUv ).x; // 1. = spawning, 0. = not spawning float isActive = texture2D( uCurrentEmissionRate, vUv ).y; // 1. = active, 0. = not active float collisionFlag =texture2D( uCurrentVelocity, vUv ).w; // Indicate collision // Randomness Mass mass = (1.0 - (uRandomMassFactor * mass)); if (isActive == 1.0) { // ************************************************************** // FORCES NOISES // ************************************************************** #ifdef USE_CURL_NOISE if (uNoiseScale > 0.0 ) { velocity = curlNoise(position * uNoiseScale * .002, uNoiseSeed) * ( uNoiseStrength + 1.0) * .05 * uSpeed; } // Variation of the noise Over Time if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) { velocity += curlNoise( position, uNoiseSeed) * uNoiseStrength * 0.05 * uSpeed; } #endif // ************************************************************** #ifdef USE_SIMPLEX_NOISE if (uNoiseScale > 0.0 ) { velocity = vec3(snoise(position * uNoiseScale * .001) * ( uNoiseStrength + 1.0) * .1); velocity *= uSpeed; } // Variation of the noise Over Time if (uNoiseStrength > 0.0 && uNoiseScale == 0.0) { velocity += vec3(snoise(position * uNoiseStrength * .001) * .05 * uSpeed); } #endif // ************************************************************** #ifdef USE_FBM_NOISE if (uNoiseScale > 0.0 ) { velocity = fbm_vec3(position * uNoiseScale * .001, ( uNoiseStrength + 1.0), uNoiseSeed); velocity *= uSpeed; } // Variation of the noise Over Time if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) { velocity += fbm_vec3(position * uNoiseStrength * .001, ( uNoiseStrength + 1.0), uNoiseSeed) * .1 * uSpeed; } #endif // COLLIDER ${s$} // ATTRACTION ${a$} // VORTEX ${n$} } // End isActive // SPAWN BIRTH // ************************************************************** // if (isSpawning == 1.) #ifdef USE_NORMALS velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, directions) * uSpeed, isSpawning); #else velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, uDirectionsAxis) * uSpeed, isSpawning); #endif // if (collisionFlag == 0.0) velocity += applyForce(uGravity, mass * .5) * (1.0 - collisionFlag); gl_FragColor = vec4(velocity, collisionFlag); } `,lP=` // Linear Fade In float linearFadeIn(float t) { return t; } // linear fade out float linearFadeOut(float t) { return 1.0 - t; } float linearInOut(float t) { return t < 0.5 ? t : (1.0 - t); } // lerp float lerp(float a, float b, float t) { return a + (b - a) * t; } // Ease In Out Quart float exponentialInOut(float t) { return t < 0.4 ? lerp(0.0, 1.0, t / 0.4) : t > 0.6 ? lerp(1.0, 0.0, (t - 0.6) / 0.4) : 1.0; } // constant float constant(float t) { return 1.0; } `,l$=` float rand(vec3 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } vec3 applyQuaternionToVector( vec4 q, vec3 v ){ return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v ); } vec3 applyForce(vec3 force, float mass) { vec3 acceleration = force / mass; return acceleration; } `,h$=` vec3 rgb2xyz (in vec3 rgb) { float r = rgb.r; float g = rgb.g; float b = rgb.b; r = r > 0.04045 ? pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); g = g > 0.04045 ? pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); b = b > 0.04045 ? pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); float x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); float y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); float z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); vec3 xyz = vec3( (r * 0.4124) + (g * 0.3576) + (b * 0.1805) * 100.0, (r * 0.2126) + (g * 0.7152) + (b * 0.0722) * 100.0, (r * 0.0193) + (g * 0.1192) + (b * 0.9505) * 100.0 ); return(xyz); } vec3 xyz2lab (in vec3 xyz) { float x = xyz.x / 95.047; float y = xyz.y / 100.0; float z = xyz.z / 108.883; x = x > 0.008856 ? pow(x, 1.0 / 3.0) : (7.787 * x) + (16.0 / 116.0); y = y > 0.008856 ? pow(y, 1.0 / 3.0) : (7.787 * y) + (16.0 / 116.0); z = z > 0.008856 ? pow(z, 1.0 / 3.0) : (7.787 * z) + (16.0 / 116.0); vec3 lab = vec3((116.0 * y) - 16.0, 500.0 * (x - y), 200.0 * (y - z)); return(lab); } vec3 rgb2lab(in vec3 rgb) { vec3 xyz = rgb2xyz(rgb); vec3 lab = xyz2lab(xyz); return(lab); } vec3 xyz2rgb (in vec3 xyz) { float x = xyz.x / 100.0; float y = xyz.y / 100.0; float z = xyz.z / 100.0; float r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); float g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); float b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); r = r > 0.0031308 ? ((1.055 * pow(r, 1.0 / 2.4)) - 0.055) : r * 12.92; g = g > 0.0031308 ? ((1.055 * pow(g, 1.0 / 2.4)) - 0.055) : g * 12.92; b = b > 0.0031308 ? ((1.055 * pow(b, 1.0 / 2.4)) - 0.055) : b * 12.92; r = min(max(0.0, r), 1.0); g = min(max(0.0, g), 1.0); b = min(max(0.0, b), 1.0); return(vec3(r, g, b)); } vec3 lab2xyz (in vec3 lab) { float l = lab.x; float a = lab.y; float b = lab.z; float y = (l + 16.0) / 116.0; float x = a / 500.0 + y; float z = y - b / 200.0; float y2 = pow(y, 3.0); float x2 = pow(x, 3.0); float z2 = pow(z, 3.0); y = y2 > 0.008856 ? y2 : (y - 16.0 / 116.0) / 7.787; x = x2 > 0.008856 ? x2 : (x - 16.0 / 116.0) / 7.787; z = z2 > 0.008856 ? z2 : (z - 16.0 / 116.0) / 7.787; x *= 95.047; y *= 100.0; z *= 108.883; return(vec3(x, y, z)); } vec3 lab2rgb (in vec3 lab) { vec3 xyz = lab2xyz(lab); vec3 rgb = xyz2rgb(xyz); return(rgb); } `,c$=` uniform sampler2D uPosition; uniform float uSize; uniform float uSizeEnd; uniform vec3 uWorldOffset; uniform vec4 uWorldQuaternion; // Billboard Behavior - Currently at Zero, but we can change that uniform float uRotation; uniform float uRotationEnd; uniform vec2 center; // Randomness uniform float uRandScaleFactor; uniform float uRandRotationFactor; attribute vec2 ref; varying float v_LifeLeft; // normalized lifetime 1 to 0 varying vec2 vUv; varying vec2 vRef; ${l$} ${lP} `,d$=({easeSize:e="linearFadeOut"})=>` vUv = uv; vRef = ref; // Normalized LifeTime 1 to 0 float lifeLeft = texture2D(uPosition, ref).w; v_LifeLeft = lifeLeft; // Position From DataTexture Simulation vec3 pos = texture2D(uPosition, ref).rgb - uWorldOffset; // Apply World Quaternion pos = applyQuaternionToVector(uWorldQuaternion, pos); #ifdef USE_SIZE_END // Scaled Over Time float t = 1. - lifeLeft; float currentSize = mix(uSize, uSizeEnd, t); // Linearly interpolate between uSize and uSizeEnd vec3 scaledPosition = position * vec3(currentSize); #else // Change Size Behavior over LifeTime float easeSize = ${e}(1. - lifeLeft); // Scaled Over Time vec3 scaledPosition = position * vec3(uSize * easeSize); #endif // Billboard Behavior vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); // Randomness float randRef = rand(ref); scale *= (1.0 - (uRandScaleFactor * randRef)); // Rotation float randRotation = 2.0 * PI * ( uRandRotationFactor * randRef); float originalRotation = (1.0 - uRotation) * 2.0 * PI; float originalRotationEnd = (1.0 - uRotationEnd) * 2.0 * PI; // OverTime float finalRotation = mix(originalRotation + randRotation, originalRotationEnd + randRotation, lifeLeft); vec2 alignedPosition = ( scaledPosition.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( finalRotation ) * alignedPosition.x - sin( finalRotation ) * alignedPosition.y; rotatedPosition.y = sin( finalRotation ) * alignedPosition.x + cos( finalRotation ) * alignedPosition.y; mat4 instanceMatrix = mat4( vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(pos.x, pos.y, pos.z, 1.0) ); mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; `,u$=` uniform vec4 uColor; // start color uniform vec4 uColor2; // end color uniform sampler2D uTexture; // texture varying float v_LifeLeft; // normalized lifetime 1 to 0 varying vec2 vUv; varying vec2 vRef; float random(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } `+lP+` ${h$} `,p$=({easeOpacity:e="linearFadeOut"})=>` // if Particle is dead, hide it if (v_LifeLeft <= 0.005 ) { discard; } #ifdef USE_RANDOM_COLORING float randVal = random(vRef); // Generate a random value based on the reference vec4 color = mix(uColor, uColor2, randVal); // Interpolate between the two colors #else vec4 color = mix(uColor, uColor2, 1. - v_LifeLeft); #endif // Opacity over Life Time float finalAlpha = ${e}(1. - v_LifeLeft); vec4 textureColor = texture2D(uTexture, vUv).rgba; finalColor = textureColor.rgb * color.rgb; finalAlpha = color.a * textureColor.a * finalAlpha; gl_FragColor = vec4(finalColor, finalAlpha); `,f$=class extends Dt{constructor(e,t){super(),this.needsJitter=!0,this.type="ParticleMaterial",this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],Vi.startContext(Vi.globalContext),this.lightLayer=new fa(0,"",{...Ji.defaultData("light","phong"),visible:!1},new G1,{},t.shared),Vi.endContext(Vi.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new nT;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(WX),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(qX),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(c$),e.addFragmentParsCode(u$),e.addVertexFinalCode(d$({easeSize:this.easeSize})),e.addFragmentFinalCode(p$({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}},av=class{constructor(e,t,i,r){this.type="SphereEmitterShape",this.targetMesh=void 0,this.size=e,this.type=i,this.textureSize=JJ(t);let s=1;this.targetMesh=(r==null?void 0:r.geometry.type)==="BufferGeometry"||(r==null?void 0:r.type)==="Mesh"&&r&&r.geometry.hasAttribute("position")&&r.geometry.hasAttribute("normal")?r:this.getMesh(i,s);let{positions:a,dataTexture:n,dataTextureNormals:o}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(i,s));this.positionsTexture=n,this.positionsAttribute=a,this.directionsTexture=o}createPositions(e,t){let{positions:i,normals:r}=$J(t,e*e),s=DA(i,e),a=DA(r,e);return{dataTexture:s,positions:i,dataTextureNormals:a}}getMesh(e,t){let i=null;switch(e){case"SphereEmitterShape":{i=new gh(t*.5,32,32);break}case"TorusEmitterShape":{i=new OM(t*.5,.3,15,40);break}case"ConeEmitterShape":{i=new Zy(t,t,15);break}case"BoxEmitterShape":{i=new Xs(t,t,t);break}case"PlaneEmitterShape":{i=new Ea(t,t),i.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{i=new gh(t,32,32);break}default:{i=new gh(t,32,32);break}}return new Jt(i,new gn({color:16711680}))}applyToShader(e,t){this.size=new M().fromArray(t.size),e.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function nh(e){let t={...e},i=pf.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...i.shape,...t.shape},s={...i.renderMaterial,...t.renderMaterial};return{...i,...t,shape:r,renderMaterial:s}}var m$=` // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU uniform sampler2D uIndex; // Texture with corresponding index uniform float uLastIndexEmitted; // Last emitted index uniform float uParticlesToEmit; // Number of particles to emit on that frame uniform float uTime; void main() { vec2 vUv = gl_FragCoord.xy / resolution.xy; float particleIndex = texture(uIndex, vUv).x; float timeLeft = texture2D( uCurrentPosition, vUv ).w; float isActive = texture2D( uCurrentEmissionRate, vUv ).g; // 1. = active, 0. = not active float timeStart = texture2D( uCurrentEmissionRate, vUv ).b; // ********** Detect Colision to Create a flag and use it in position ********** // We are doing this here, so // ********** Emit Particles ********** // X = isSpawning 0.0 or 1.0 // Y = isActive 0.0 or 1.0 // Check if the vertex index is between the first value and the last value // if (particleIndex >= uLastIndexEmitted && particleIndex < uLastIndexEmitted + uParticlesToEmit) { // // Emit a particle by writing 1 to the red channel of the color output // // r: 1. == emit the particle // // g: 1. == particle is now active // timeStart = uTime; // gl_FragColor = vec4(1.0, 1.0, timeStart, 1.0); // } else { // // The Particle is either already emitted or not in the range of the particles to emit // // Do not emit a particle by writing 0 to the red channel of the color output // gl_FragColor = vec4(0.0, isActive, timeStart, 1.0); // } // Determine if the particle is within the emission range float emitLowerBound = step(uLastIndexEmitted, particleIndex); float emitUpperBound = step(particleIndex, uLastIndexEmitted + uParticlesToEmit - 1.0); float emitParticle = emitLowerBound * emitUpperBound; // 1.0 if in range, 0.0 otherwise // Set timeStart and color timeStart = mix(timeStart, uTime, emitParticle); gl_FragColor = vec4(emitParticle, mix(isActive, 1.0, emitParticle), timeStart, 1.0); } `,nv=10,g$=class extends kt{constructor(e,t){super(),this.type="ParticleEmitter",this.debugMode=!1,this.worldSpace=!0,this.rootObject=null,this.gpuCompute=null,this.positionSimRT=null,this.velocitySimRT=null,this.emissionRateSimRT=null,this.emitterShape=void 0,this.isEmitting=!1,this.hasBeenReset=!1,this.emittedParticlesAmount=0,this.lastEmitTime=0,this.globalTime=0,this.targetFPS=60,this.previousRatio=1,this.lerpFactor=.4,this.particlesAmount=0,this.noiseStrength=0,this.noiseScale=0,this.isBillboardBased=!0,this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1},this.textureLoader=new TU,this.currentWorldPosition=new M,this.systemQuaternion=new lt,this.worldGravity=new M(0,0,0),this.directionAxis=new M(0,0,0),this.colliderV3=new M(0,0,0),this.colliderQuaternion=new lt(0,0,0,1),this.matrixAutoUpdate=!0,this.renderer=e,this.system=t,this.shared=t.context.shared;let i=t.data;this.material=new f$(i.renderMaterial,t.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:i.renderMaterial.color},uColor2:{value:i.renderMaterial.color2},uPosition:{value:new M(0,0,0)},uEmissionData:{value:new M(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new M(0,0,0)},uWorldQuaternion:{value:new ct(0,0,0,1)},uRandScaleFactor:{value:i.randomScale??0},uRandRotationFactor:{value:i.randomRotation??0},uRotation:{value:i.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:i.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,i.renderMaterial.texture),this.init(i)}setTexture(e,t){let i=t.data;if(typeof t=="string"){let r=this.shared.image(t),s=new ci(r.img);s.needsUpdate=!0,e.uTexture.value=s;return}if(typeof i!="string"){let r=new Image;r.onload=()=>{let n=new ci(r);n.needsUpdate=!0,e.uTexture.value=n};let s=new Blob([i],{type:"image/*"}),a=URL.createObjectURL(s);r.src=a}}updateGeometryAttributes(e,t){var r;let i=KJ(t);!((r=this.emitterShape)!=null&&r.positionsAttribute)||e.geometry.setAttribute("ref",new ud(i,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,t){var n;if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let i=1e3/t,r=this.targetFPS/i,s=this.previousRatio+(r-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=s,this.previousRatio=s;let a=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=a,this.material.uniforms.uPosition.value=(n=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT))==null?void 0:n.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],t=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&t&&this.init(nh({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let i=e.data.size;this.colliderV3.fromArray(i),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,t){if(!this.velocitySimRT||!this.positionSimRT)return;t[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),t[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let i=(r,s)=>{let a=[...this.system.data.shape.size];a[r]=s,this.updateParticleState({shape:{...this.system.data.shape,size:a}})};t[2]==="shape_size_0"&&i(0,e),t[2]==="shape_size_1"&&i(1,e),t[2]==="shape_size_2"&&i(2,e),t[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/nv),t[2]==="gravity"&&this.worldGravity.set(0,e/100,0),t[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),t[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),t[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){var t,i,r;if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(nh(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/nv),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),((t=e.renderMaterial)==null?void 0:t.size)!==void 0){let s=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(s)}if(((i=e.renderMaterial)==null?void 0:i.spriteRotation)!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let s=e.shape.size??this.system.data.shape.size,a=[Number(this.shared.getVariable(s[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(s[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(s[2],[this.uuid,"particles","shape_size_2"]))],n={...nh(this.system.data).shape,size:a};(r=this.emitterShape)==null||r.applyToShader(this.positionSimRT.material.uniforms,n)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let s=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(s),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let t=[Number(e[0])*Re.DEG2RAD,Number(e[1])*Re.DEG2RAD,Number(e[2])*Re.DEG2RAD],i=new ji(t[0],t[1],t[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(i).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:t,rootObjectType:i,colliderEntityId:r,shape:s,emitTimeDuration:a,emitTimeCycle:n,life:o,directionMode:l,noiseType:h}=e;return t!==void 0||i!==void 0||r||r===null||n!==void 0||s!==void 0||o!==void 0||a!==void 0||l!==void 0||h!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn("The maximum number of particles is limited to 100000."),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let t=setInterval(()=>{if(this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(t)},100);if(!this.emitterShape)return;let i=new QJ(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),r=this.updateSimulationDefinition(e),s=i.addVariable("uCurrentPosition",r+i$,this.emitterShape.positionsTexture),a=i.addVariable("uCurrentVelocity",r+o$,this.emitterShape.directionsTexture),n=i.addVariable("uCurrentEmissionRate",m$,t$(this.emitterShape.textureSize));i.setVariableDependencies(s,[s,a,n]),i.setVariableDependencies(a,[s,a,n]),i.setVariableDependencies(n,[s,a,n]);let o=e$({size:this.emitterShape.textureSize}),l={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new M(0,0,0)},uWorldQuaternion:{value:new ct(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new M(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};s.material.uniforms=l;let h=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(h),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let c=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),d={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new ct(0,0,0,1)},uColliderPos:{value:new M(0,0,0)},uColliderSize:{value:new M(0,0,0)},uForceIntensity:{value:c?c.forceIntensity:0},uForceDamping:{value:c?c.forceDambing:0},uColliderQuaternion:{value:new ct(0,0,0,1)},uColliderQuaternionInvert:{value:new ct(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/nv}};a.material.uniforms=d;let u={uIndex:{value:o},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};n.material.uniforms=u;let p=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],f={...nh(this.system.data).shape,size:p};this.emitterShape.applyToShader(s.material.uniforms,f),i.init(),this.gpuCompute=i,this.positionSimRT=s,this.velocitySimRT=a,this.emissionRateSimRT=n,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let t=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),i=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),r=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[t,i,r]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let i=this.system.getColliderData(e.colliderEntityId);switch(i==null?void 0:i.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let r=i==null?void 0:i.colliderType;r==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),r==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),(i==null?void 0:i.forceRange)==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let t="";for(let[i,r]of Object.entries(this.simFeaturesDefinition))r&&(t+=`#define ${i} `);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let i=new M(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let r=null;return this.system.context.scene.traverseEntity(s=>{s.uuid===e.fromMeshId&&(r=s)}),r?new av(i,t,e.type,r):new av(i,t,"SphereEmitterShape")}else return new av(i,t,e.type)}createPrimaryEmitter(e){let t,i=e*e;return t=new VF(new Ea(1,1,1),this.material,i),this.updateGeometryAttributes(t,e),this.material.needsUpdate=!0,t.onBeforeRender=()=>{this.applyWorldSpace()},t}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:i=0}){return Math.ceil(e*(t+i))}dispose(){var e,t,i;!this.gpuCompute||((t=(e=this.rootObject)==null?void 0:e.parent)==null||t.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),(i=this.emitterShape)==null||i.dispose())}GoEmitSomeParticles(e,t){let i=e-this.lastEmitTime,r=1/t;if(i>=r){let s=Math.max(1,Math.floor(i/r));return this.lastEmitTime=e,this.emittedParticlesAmount+s>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=s,s}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(r))},this.context=i,this.data={...t,...nh(t)},this.geometry.setAttribute("position",new Ie([],3)),this.material=new gn({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new g$(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let t=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||t)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),t||this.start(this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let i=this.actualTime/1e3;this.emitter.update(i,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(i=>i.identity===e);return t?t.data:null}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Qt(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...tr.drop(e,1).props}}),Qt(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...tr.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){var t;if(this.currentLoopTime=0,e){this.timeoutId=window.setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,(t=this.emitter)==null||t.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){var e;this.stopped=!0,this.currentLoopTime=0,(e=this.emitter)==null||e.stopEmitting(),clearTimeout(this.timeoutId)}reset(){var e;this.started=!1,this.stopped=!1,(e=this.emitter)==null||e.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function v$(){try{let e=window.location.href;if(e.includes("reducesubdiv=")){let t=e.indexOf("reducesubdiv=")+13;return parseInt(e.slice(t,t+1))}}catch{}}var ov=v$();function y$(e,t,i){var s;ov!==void 0&&(((s=t==null?void 0:t.geometry)==null?void 0:s.subdivisions)??0)>ov&&(console.log("reducing subdivisions",t.name,t.geometry.subdivisions),t.geometry.subdivisions=ov);let r;return t.geometry.type==="TextGeometry"?new Q1(e,t,i):t.geometry.type==="InputGeometry"?new rx(e,t,i):(t.geometry.type==="SubdivGeometry"?r=new Id(e,t,i):t.geometry.type==="PathGeometry"?r=new ix(e,t,i):t.geometry.type==="VectorGeometry"?r=new XJ(e,t,i):t.geometry.type==="BooleanGeometry"?r=new ul(e,t,i):t.geometry.type==="ShapeBlendGeometry"?r=new pl(e,t,i):t.geometry.type==="UIGeometry"?r=new Sr(e,t,i):r=new Ii(e,t,i),r)}function ax(e,t,i){return console.assert(t.type!==void 0),t.type==="Mesh"?y$(e,t,i):t.type==="Empty"?new Mh(e,t):t.type==="Particle"?new rd(e,t,i):t.type==="ParticleCollider"?new id(e,t,i):t.type==="Splat"?new Mh(e,t):t.type==="Bone"?new YJ(e,t):t.type==="Page"?new $i(e,t,i):t.type==="PointLight"?new qJ(e,t,i):t.type==="SpotLight"?new KT(e,t,i):t.type==="DirectionalLight"?new ZT(e,t,i):t.type==="Component"||t.type==="Instance"?new Eh(e,t,i):hl.is(t.type)?new Mr(e,t):(console.error(t),new Mh(e,t))}$n.createEntity=ax;function x$(e,t,i){let r=ax(e.identity,t,i),s=e.children,a=e.attachedPaths,n=e.parent,o=e.component,l=e.instances,h=e.overrideData,c=e.uuid,d=e.stateSelection;e.dispose();for(let u of Object.keys(e))delete e[u];Object.setPrototypeOf(e,Object.getPrototypeOf(r));for(let u of Object.keys(r))e[u]=r[u];e.children=[...e.children,...s],e.attachedPaths=a,e.parent=n,e.component=o,e.instances=l,e.uuid=c,e.overrideData=h,e.updateState(e.data,i),d&&e.changeSelectedState(d,i),e.resetBBoxNeedsUpdate()}$n.changeEntityProptotype=x$;$n.Cloner=bs;function b$(e,t,i,r){e.updateByOp(t,i,r,!1)}var Go=5,sd=new Ge;sd.setAttribute("position",new tt(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));var Op=class extends yU{constructor(e){super({...e,depthTest:!1,depthWrite:!1,glslVersion:Lv,vertexShader:` precision highp float; in vec3 position; void main() { gl_Position = vec4(position, 1); } `})}customProgramCacheKey(){return""}};function w$(){return{shapeInput:()=>` const float posRowCoord = ${.5/Go}; // vec4: px py pz opType const float quatRowCoord = ${1.5/Go}; // vec4: qx qy qz qw const float param1RowCoord = ${2.5/Go};// vec4: type param1 param2 param3 const float param2RowCoord = ${3.5/Go};// vec4: blendRange roundness scale param4 const float colorRowCoord = ${4.5/Go}; // vec4: r g b a uniform sampler2D shapesDataTexture; vec4 shapePos(float iin) { vec4 r = texture(shapesDataTexture, vec2(iin, posRowCoord)); return r; } vec4 shapeQuat(float iin) { vec4 r = texture(shapesDataTexture, vec2(iin, quatRowCoord)); return r; } vec4 shapeParams1(float iin) { vec4 r = texture(shapesDataTexture, vec2(iin, param1RowCoord)); return r; } vec4 shapeParams2(float iin) { vec4 r = texture(shapesDataTexture, vec2(iin, param2RowCoord)); return r; } vec4 shapeColor(float iin) { vec4 r = texture(shapesDataTexture, vec2(iin, colorRowCoord)); return r; } `,getxyzi:` // this code must complement lookup float xi = mod(gl_FragCoord.x - 0.5, VOXEL_RESOLUTION); float yi = mod(gl_FragCoord.y - 0.5, VOXEL_RESOLUTION); float zi = floor((gl_FragCoord.x - 0.5) * INV_VOXEL_RESOLUTION) + floor((gl_FragCoord.y - 0.5) * INV_VOXEL_RESOLUTION) * Z_LAYERS_PER_ROW; `,lookup:` uniform sampler2D potentialPassTexture; uniform sampler2D voxelPassTexture; // includes normal (in xyz) and key (in w) // box or marching cube lookup value in value texture, integer box coord inputs // this code must complement codebits.getxyzi vec4 look(float xi, float yi, float zi, sampler2D rt) {// range 0 .. numv etc vec2 uv = vec2( mod(zi, Z_LAYERS_PER_ROW) + (xi + 0.5) / VOXEL_RESOLUTION, floor(zi / Z_LAYERS_PER_ROW) + (yi + 0.5) / VOXEL_RESOLUTION ); uv /= Z_LAYERS_PER_ROW; return texture(rt, uv); } `,getpart:` float getpart(inout float a, float b) { float t = floor(a/b); float r = a - t*b; a = t; return r; } `,triTable:new Float32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,1,8,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,9,9,2,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,2,8,10,2,8,9,10,-1,-1,-1,-1,-1,-1,-1,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,0,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,1,11,9,1,11,8,9,-1,-1,-1,-1,-1,-1,-1,1,10,3,3,10,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,10,0,10,8,0,10,11,8,-1,-1,-1,-1,-1,-1,-1,0,9,3,9,11,3,9,10,11,-1,-1,-1,-1,-1,-1,-1,10,8,9,11,8,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,4,3,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,4,1,7,4,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,2,1,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,3,4,0,3,10,2,1,-1,-1,-1,-1,-1,-1,-1,10,2,9,2,0,9,7,4,8,-1,-1,-1,-1,-1,-1,-1,9,10,2,7,9,2,3,7,2,4,9,7,-1,-1,-1,-1,7,4,8,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,11,4,2,11,4,0,2,-1,-1,-1,-1,-1,-1,-1,1,0,9,7,4,8,11,3,2,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,9,2,11,9,1,2,9,-1,-1,-1,-1,1,10,3,10,11,3,4,8,7,-1,-1,-1,-1,-1,-1,-1,10,11,1,11,4,1,4,0,1,4,11,7,-1,-1,-1,-1,8,7,4,11,0,9,10,11,9,3,0,11,-1,-1,-1,-1,11,7,4,9,11,4,10,11,9,-1,-1,-1,-1,-1,-1,-1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,9,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,0,0,5,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,8,5,3,8,5,1,3,-1,-1,-1,-1,-1,-1,-1,10,2,1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,10,2,1,5,9,4,-1,-1,-1,-1,-1,-1,-1,10,2,5,2,4,5,2,0,4,-1,-1,-1,-1,-1,-1,-1,5,10,2,5,2,3,4,5,3,8,4,3,-1,-1,-1,-1,4,5,9,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,11,8,0,5,9,4,-1,-1,-1,-1,-1,-1,-1,4,5,0,5,1,0,11,3,2,-1,-1,-1,-1,-1,-1,-1,5,1,2,8,5,2,11,8,2,5,8,4,-1,-1,-1,-1,11,3,10,3,1,10,4,5,9,-1,-1,-1,-1,-1,-1,-1,5,9,4,1,8,0,1,10,8,10,11,8,-1,-1,-1,-1,0,4,5,11,0,5,10,11,5,3,0,11,-1,-1,-1,-1,8,4,5,10,8,5,11,8,10,-1,-1,-1,-1,-1,-1,-1,8,7,9,9,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,9,3,5,9,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,7,0,7,1,0,7,5,1,-1,-1,-1,-1,-1,-1,-1,3,5,1,7,5,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,9,7,5,9,2,1,10,-1,-1,-1,-1,-1,-1,-1,2,1,10,0,5,9,0,3,5,3,7,5,-1,-1,-1,-1,2,0,8,5,2,8,7,5,8,2,5,10,-1,-1,-1,-1,5,10,2,3,5,2,7,5,3,-1,-1,-1,-1,-1,-1,-1,5,9,7,9,8,7,2,11,3,-1,-1,-1,-1,-1,-1,-1,7,5,9,2,7,9,0,2,9,11,7,2,-1,-1,-1,-1,11,3,2,8,1,0,8,7,1,7,5,1,-1,-1,-1,-1,1,2,11,7,1,11,5,1,7,-1,-1,-1,-1,-1,-1,-1,8,5,9,7,5,8,3,1,10,11,3,10,-1,-1,-1,-1,0,7,5,9,0,5,0,11,7,10,0,1,0,10,11,-1,0,10,11,3,0,11,0,5,10,7,0,8,0,7,5,-1,5,10,11,5,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,0,9,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,8,9,1,6,10,5,-1,-1,-1,-1,-1,-1,-1,5,6,1,1,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,1,6,2,1,8,0,3,-1,-1,-1,-1,-1,-1,-1,5,6,9,6,0,9,6,2,0,-1,-1,-1,-1,-1,-1,-1,8,9,5,2,8,5,6,2,5,8,2,3,-1,-1,-1,-1,11,3,2,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,11,0,2,11,5,6,10,-1,-1,-1,-1,-1,-1,-1,9,1,0,11,3,2,6,10,5,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,9,1,2,11,9,11,8,9,-1,-1,-1,-1,11,3,6,3,5,6,3,1,5,-1,-1,-1,-1,-1,-1,-1,11,8,0,5,11,0,1,5,0,6,11,5,-1,-1,-1,-1,6,11,3,6,3,0,5,6,0,9,5,0,-1,-1,-1,-1,9,5,6,11,9,6,8,9,11,-1,-1,-1,-1,-1,-1,-1,6,10,5,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,3,7,4,10,5,6,-1,-1,-1,-1,-1,-1,-1,0,9,1,6,10,5,7,4,8,-1,-1,-1,-1,-1,-1,-1,5,6,10,7,9,1,3,7,1,4,9,7,-1,-1,-1,-1,2,1,6,1,5,6,8,7,4,-1,-1,-1,-1,-1,-1,-1,5,2,1,6,2,5,4,0,3,7,4,3,-1,-1,-1,-1,7,4,8,5,0,9,5,6,0,6,2,0,-1,-1,-1,-1,9,3,7,4,9,7,9,2,3,6,9,5,9,6,2,-1,2,11,3,4,8,7,5,6,10,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,7,4,0,2,4,11,7,2,-1,-1,-1,-1,9,1,0,8,7,4,11,3,2,6,10,5,-1,-1,-1,-1,1,2,9,2,11,9,11,4,9,4,11,7,6,10,5,-1,7,4,8,5,11,3,1,5,3,6,11,5,-1,-1,-1,-1,11,1,5,6,11,5,11,0,1,4,11,7,11,4,0,-1,9,5,0,5,6,0,6,3,0,3,6,11,7,4,8,-1,9,5,6,11,9,6,9,7,4,9,11,7,-1,-1,-1,-1,9,4,10,10,4,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,4,10,9,4,3,8,0,-1,-1,-1,-1,-1,-1,-1,1,0,10,0,6,10,0,4,6,-1,-1,-1,-1,-1,-1,-1,1,3,8,6,1,8,4,6,8,10,1,6,-1,-1,-1,-1,9,4,1,4,2,1,4,6,2,-1,-1,-1,-1,-1,-1,-1,8,0,3,9,2,1,9,4,2,4,6,2,-1,-1,-1,-1,4,2,0,6,2,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,4,2,8,6,2,4,-1,-1,-1,-1,-1,-1,-1,9,4,10,4,6,10,3,2,11,-1,-1,-1,-1,-1,-1,-1,2,8,0,11,8,2,10,9,4,6,10,4,-1,-1,-1,-1,2,11,3,6,1,0,4,6,0,10,1,6,-1,-1,-1,-1,1,4,6,10,1,6,1,8,4,11,1,2,1,11,8,-1,4,6,9,6,3,9,3,1,9,3,6,11,-1,-1,-1,-1,1,11,8,0,1,8,1,6,11,4,1,9,1,4,6,-1,6,11,3,0,6,3,4,6,0,-1,-1,-1,-1,-1,-1,-1,8,4,6,8,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,7,10,8,7,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,7,0,7,10,0,10,9,0,10,7,6,-1,-1,-1,-1,7,6,10,7,10,1,8,7,1,0,8,1,-1,-1,-1,-1,7,6,10,1,7,10,3,7,1,-1,-1,-1,-1,-1,-1,-1,6,2,1,8,6,1,9,8,1,7,6,8,-1,-1,-1,-1,9,6,2,1,9,2,9,7,6,3,9,0,9,3,7,-1,0,8,7,6,0,7,2,0,6,-1,-1,-1,-1,-1,-1,-1,2,3,7,2,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,3,2,8,6,10,9,8,10,7,6,8,-1,-1,-1,-1,7,0,2,11,7,2,7,9,0,10,7,6,7,10,9,-1,0,8,1,8,7,1,7,10,1,10,7,6,11,3,2,-1,1,2,11,7,1,11,1,6,10,1,7,6,-1,-1,-1,-1,6,9,8,7,6,8,6,1,9,3,6,11,6,3,1,-1,1,9,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,6,0,7,0,11,3,0,6,11,-1,-1,-1,-1,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,8,1,3,8,6,7,11,-1,-1,-1,-1,-1,-1,-1,2,1,10,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,8,0,3,7,11,6,-1,-1,-1,-1,-1,-1,-1,0,9,2,9,10,2,7,11,6,-1,-1,-1,-1,-1,-1,-1,7,11,6,3,10,2,3,8,10,8,9,10,-1,-1,-1,-1,3,2,7,7,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,7,0,6,7,0,2,6,-1,-1,-1,-1,-1,-1,-1,6,7,2,7,3,2,9,1,0,-1,-1,-1,-1,-1,-1,-1,2,6,1,6,8,1,8,9,1,6,7,8,-1,-1,-1,-1,6,7,10,7,1,10,7,3,1,-1,-1,-1,-1,-1,-1,-1,6,7,10,10,7,1,7,8,1,8,0,1,-1,-1,-1,-1,7,3,0,10,7,0,9,10,0,7,10,6,-1,-1,-1,-1,10,6,7,8,10,7,9,10,8,-1,-1,-1,-1,-1,-1,-1,4,8,6,6,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,3,6,0,3,6,4,0,-1,-1,-1,-1,-1,-1,-1,11,6,8,6,4,8,1,0,9,-1,-1,-1,-1,-1,-1,-1,6,4,9,3,6,9,1,3,9,6,3,11,-1,-1,-1,-1,4,8,6,8,11,6,1,10,2,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,0,3,11,6,0,6,4,0,-1,-1,-1,-1,8,11,4,11,6,4,9,2,0,9,10,2,-1,-1,-1,-1,3,9,10,2,3,10,3,4,9,6,3,11,3,6,4,-1,3,2,8,2,4,8,2,6,4,-1,-1,-1,-1,-1,-1,-1,2,4,0,2,6,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,4,3,2,6,4,2,8,3,4,-1,-1,-1,-1,4,9,1,2,4,1,6,4,2,-1,-1,-1,-1,-1,-1,-1,3,1,8,1,6,8,6,4,8,1,10,6,-1,-1,-1,-1,0,1,10,6,0,10,4,0,6,-1,-1,-1,-1,-1,-1,-1,3,6,4,8,3,4,3,10,6,9,3,0,3,9,10,-1,4,9,10,4,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,9,4,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,5,9,4,6,7,11,-1,-1,-1,-1,-1,-1,-1,1,0,5,0,4,5,11,6,7,-1,-1,-1,-1,-1,-1,-1,6,7,11,4,3,8,4,5,3,5,1,3,-1,-1,-1,-1,4,5,9,2,1,10,11,6,7,-1,-1,-1,-1,-1,-1,-1,7,11,6,10,2,1,3,8,0,5,9,4,-1,-1,-1,-1,11,6,7,10,4,5,10,2,4,2,0,4,-1,-1,-1,-1,8,4,3,4,5,3,5,2,3,2,5,10,6,7,11,-1,3,2,7,2,6,7,9,4,5,-1,-1,-1,-1,-1,-1,-1,4,5,9,6,8,0,2,6,0,7,8,6,-1,-1,-1,-1,2,6,3,6,7,3,0,5,1,0,4,5,-1,-1,-1,-1,8,2,6,7,8,6,8,1,2,5,8,4,8,5,1,-1,4,5,9,6,1,10,6,7,1,7,3,1,-1,-1,-1,-1,10,6,1,6,7,1,7,0,1,0,7,8,4,5,9,-1,10,0,4,5,10,4,10,3,0,7,10,6,10,7,3,-1,10,6,7,8,10,7,10,4,5,10,8,4,-1,-1,-1,-1,5,9,6,9,11,6,9,8,11,-1,-1,-1,-1,-1,-1,-1,11,6,3,3,6,0,6,5,0,5,9,0,-1,-1,-1,-1,8,11,0,11,5,0,5,1,0,11,6,5,-1,-1,-1,-1,3,11,6,5,3,6,1,3,5,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,5,9,8,11,9,6,5,11,-1,-1,-1,-1,3,11,0,11,6,0,6,9,0,9,6,5,10,2,1,-1,5,8,11,6,5,11,5,0,8,2,5,10,5,2,0,-1,3,11,6,5,3,6,3,10,2,3,5,10,-1,-1,-1,-1,9,8,5,8,2,5,2,6,5,2,8,3,-1,-1,-1,-1,6,5,9,0,6,9,2,6,0,-1,-1,-1,-1,-1,-1,-1,8,5,1,0,8,1,8,6,5,2,8,3,8,2,6,-1,6,5,1,6,1,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,3,1,10,6,1,6,8,3,9,6,5,6,9,8,-1,0,1,10,6,0,10,0,5,9,0,6,5,-1,-1,-1,-1,8,3,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,5,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,11,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,5,7,11,0,3,8,-1,-1,-1,-1,-1,-1,-1,7,11,5,11,10,5,0,9,1,-1,-1,-1,-1,-1,-1,-1,5,7,10,7,11,10,1,8,9,1,3,8,-1,-1,-1,-1,2,1,11,1,7,11,1,5,7,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,2,1,5,7,1,11,2,7,-1,-1,-1,-1,5,7,9,7,2,9,2,0,9,7,11,2,-1,-1,-1,-1,2,5,7,11,2,7,2,9,5,8,2,3,2,8,9,-1,10,5,2,5,3,2,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,2,8,2,5,8,5,7,8,5,2,10,-1,-1,-1,-1,1,0,9,3,10,5,7,3,5,2,10,3,-1,-1,-1,-1,2,8,9,1,2,9,2,7,8,5,2,10,2,5,7,-1,5,3,1,5,7,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,1,7,0,5,7,1,-1,-1,-1,-1,-1,-1,-1,3,0,9,5,3,9,7,3,5,-1,-1,-1,-1,-1,-1,-1,7,8,9,7,9,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,5,8,10,5,8,11,10,-1,-1,-1,-1,-1,-1,-1,4,0,5,0,11,5,11,10,5,0,3,11,-1,-1,-1,-1,9,1,0,10,4,8,11,10,8,5,4,10,-1,-1,-1,-1,4,11,10,5,4,10,4,3,11,1,4,9,4,1,3,-1,1,5,2,5,8,2,8,11,2,8,5,4,-1,-1,-1,-1,11,4,0,3,11,0,11,5,4,1,11,2,11,1,5,-1,5,2,0,9,5,0,5,11,2,8,5,4,5,8,11,-1,5,4,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,2,2,5,3,5,4,3,4,8,3,-1,-1,-1,-1,2,10,5,4,2,5,0,2,4,-1,-1,-1,-1,-1,-1,-1,2,10,3,10,5,3,5,8,3,8,5,4,9,1,0,-1,2,10,5,4,2,5,2,9,1,2,4,9,-1,-1,-1,-1,5,4,8,3,5,8,1,5,3,-1,-1,-1,-1,-1,-1,-1,5,4,0,5,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,4,8,3,5,8,5,0,9,5,3,0,-1,-1,-1,-1,5,4,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,11,4,11,9,4,11,10,9,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,9,4,7,11,9,11,10,9,-1,-1,-1,-1,11,10,1,4,11,1,0,4,1,11,4,7,-1,-1,-1,-1,4,1,3,8,4,3,4,10,1,11,4,7,4,11,10,-1,7,11,4,4,11,9,11,2,9,2,1,9,-1,-1,-1,-1,4,7,9,7,11,9,11,1,9,1,11,2,3,8,0,-1,4,7,11,2,4,11,0,4,2,-1,-1,-1,-1,-1,-1,-1,4,7,11,2,4,11,4,3,8,4,2,3,-1,-1,-1,-1,10,9,2,9,7,2,7,3,2,9,4,7,-1,-1,-1,-1,7,10,9,4,7,9,7,2,10,0,7,8,7,0,2,-1,10,7,3,2,10,3,10,4,7,0,10,1,10,0,4,-1,2,10,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,3,1,7,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,1,8,0,1,7,8,-1,-1,-1,-1,3,0,4,3,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,10,9,8,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,10,9,11,-1,-1,-1,-1,-1,-1,-1,10,1,0,8,10,0,11,10,8,-1,-1,-1,-1,-1,-1,-1,10,1,3,10,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,1,9,11,1,8,11,9,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,9,2,1,9,11,2,-1,-1,-1,-1,11,2,0,11,0,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,9,8,10,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,8,1,0,8,10,1,-1,-1,-1,-1,2,10,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]),numTrisTable:new Float32Array([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,2,3,4,4,3,3,4,4,3,4,5,5,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,2,3,3,4,3,4,2,3,3,4,4,5,4,5,3,2,3,4,4,3,4,5,3,2,4,5,5,4,5,2,4,1,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,2,4,3,4,3,5,2,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,3,4,4,3,4,5,5,4,4,3,5,2,5,4,2,1,2,3,3,4,3,4,4,5,3,4,4,5,2,3,3,2,3,4,4,5,4,5,5,2,4,3,5,4,3,2,4,1,3,4,4,5,4,5,3,4,4,5,5,2,3,4,2,1,2,3,3,2,3,4,2,1,3,2,4,1,2,1,1,0])}}var Rp=new bo,_$=class{constructor(){this.pyramidPassScene=new Jr,this.pyramidPassMaterial=new Op({name:"PyramidPass"}),this.pyramidPassUniforms={inputTexture:{value:void 0},inputWidth:{value:0},inputHeight:{value:0},inputShiftX:{value:0},outputShiftX:{value:0}},this.pyramidTopLevelReadPixelBuffer=new Float32Array(4);let e=` precision highp float; precision highp sampler2D; layout(location = 0) out vec4 pc_FragColor; uniform sampler2D inputTexture; uniform float inputWidth; uniform float inputHeight; uniform float inputShiftX; uniform float outputShiftX; const vec2 half_unit_coord = vec2(0.5); const vec4 one = vec4(1.0); void main() { vec2 inputSize = vec2(inputWidth, inputHeight); vec2 input_pixel_uv = 1. / inputSize; vec2 coord = gl_FragCoord.xy - half_unit_coord; coord.x -= outputShiftX; coord = coord * 2. + half_unit_coord; coord.x += inputShiftX; // sample bottom left corner vec2 input_uv = coord / inputSize; float bl = texture(inputTexture, input_uv).r; // sample bottom right corner input_uv.x += input_pixel_uv.x; float br = texture(inputTexture, input_uv).r; // sample top right corner input_uv.y += input_pixel_uv.y; float tr = texture(inputTexture, input_uv).r; // sample top left corner input_uv.x -= input_pixel_uv.x; float tl = texture(inputTexture, input_uv).r; pc_FragColor.a = bl; pc_FragColor.b = pc_FragColor.a + br; pc_FragColor.g = pc_FragColor.b + tr; pc_FragColor.r = pc_FragColor.g + tl; } `;this.pyramidPassMaterial.fragmentShader=e,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let t=new Jt(sd,this.pyramidPassMaterial);t.frustumCulled=!1,this.pyramidPassScene.add(t)}renderPyramid(e,t,i,r,s){new t1().min.setScalar(0);let a=t.length-1,n=new ct;i.getViewport(n),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let o=a-1;for(let h=o;h>=0;h--){let c=h%2===o%2?s[0]:s[1],d=h===o?r:h%2===o%2?s[1]:s[0];this.pyramidPassUniforms.inputTexture.value=Array.isArray(d.texture)?d.texture[1]:d.texture,this.pyramidPassUniforms.inputWidth.value=d.width,this.pyramidPassUniforms.inputHeight.value=d.height,i.setRenderTarget(c);let u=t[h],p=i.getPixelRatio();i.setViewport(this.pyramidPassUniforms.outputShiftX.value/p,0,u/p,u/p),h===2&&e%2!==0&&i.setViewport(this.pyramidPassUniforms.outputShiftX.value/p,0,3/p,3/p),i.render(this.pyramidPassScene,Rp);let f=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=f,hthis.pyramidTopLevelReadPixelBuffer[0])}},Ls=24,hr=96,na=w$(),ja=2,hP=class extends Ii{constructor(e,t,i){super(e,t,i),this.data=t,this.needsRebuild=!0,this.customDepthMaterialNeedsUpdate=!1,this._npart=-1,this.spatialn=1,this.drawRangeNeedsForceUpdate=!0,this._resolutionLevel=-1,this.resolution=64,this.spatialDivisions=25,this.zLayersPerRow=8,this.basePyramidSize=512,this.pyramidTexture1Width=341,this.pyramidTexture1Height=256,this.pyramidTexture2Width=170,this.pyramidTexture2Height=128,this.numLevels=9,this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512],this.bboxSize=0,this.bboxOffset=0,this.shapesDataTexture={value:void 0},this.spatialscene=new Jr,this.potentialPassScene=new Jr,this.voxelPassScene=new Jr,this._spatialPassRenderTargets=[],this._potentialPassRenderTargets=[],this._voxelPassRenderTargets=[],this._pyramidRenderTargets=[],this.geometry=new Ge,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new Jt(sd,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let r=new Ur(na.triTable,16,256,wp,jt);r.needsUpdate=!0;let s=new Ur(na.numTrisTable,256,1,wp,jt);s.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:s}},this.voxelMesh=new Jt(sd,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new Jt(sd,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:r},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=a=>{if(C$.call(this),this.npart===0){this.geometry.drawRange.count=0;return}let n=this.material.root;if(!n.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(n),n.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new Dt({vertexShader:n.vertexShader,fragmentShader:` #include void main() { gl_FragColor = packDepthToRGBA(gl_FragCoord.z); } `,uniforms:n.uniforms,defines:this.material.defines}),this.isMeshDepthMaterial=!0,this.customDistanceMaterial=new Dt({vertexShader:n.vertexShader,fragmentShader:` #include #include uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; // World-space position varying vec3 vWPosition; void main() { float dist = length(vWPosition - referencePosition); dist = (dist - nearDistance) / (farDistance - nearDistance); dist = saturate(dist); // Required by Three.js for this to work gl_FragColor = packDepthToRGBA( dist ); }`,uniforms:{nearDistance:{value:0},farDistance:{value:0},referencePosition:{value:new M},opacity:{value:0},...n.uniforms},defines:this.material.defines});let h=this.customDistanceMaterial;h.referencePosition=new M,h.nearDistance=0,h.farDistance=0,h.opacity=1,h.isMeshDistanceMaterial=!0}if(this.spatialPassUniforms.npart.value=this.npart,this.spatialPassUniforms.spatialn.value=this.spatialn,this.potentialPassUniforms.npart.value=this.npart,this.potentialPassUniforms.spatialn.value=this.spatialn,this.needsRebuild){this.needsRebuild=!1,this.spatialMesh.material.defines.RES=this.resolutionLevel,this.spatialMesh.material.needsUpdate=!0,this.potentialMesh.material.defines.RES=this.resolutionLevel,this.potentialPassUniforms.spatialPassTexture.value=this.spatialPassRenderTarget.texture,this.potentialMesh.material.needsUpdate=!0,this.voxelMesh.material.defines.RES=this.resolutionLevel,this.voxelMesh.material.needsUpdate=!0,this.voxelPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.voxelPassTexture.value=this.voxelPassRenderTarget.texture[0],this.material.defines.RES=this.resolutionLevel,this.material.defines.LEVELS=this.pyramidLevelSizes.length,this.material.defines.LOOP=this.pyramidLevelSizes.length%2===0?this.pyramidLevelSizes.length-3:this.pyramidLevelSizes.length-2,this.material.defines.HALF=this.pyramidLevelSizes.length%2===0?1:0,this.material.needsUpdate=!0;let h=this.pyramidLevelSizes.length%2===0?0:1,c=this.pyramidLevelSizes.length%2===0?1:0;this.marchPassUniforms.pyramidTexture2.value=this.pyramidRenderTarget[h].texture,this.marchPassUniforms.pyramidTexture2Size.value=new j(this.pyramidRenderTarget[h].width,this.pyramidRenderTarget[h].height),this.marchPassUniforms.pyramidTexture1.value=this.pyramidRenderTarget[c].texture,this.marchPassUniforms.pyramidTexture1Size.value=new j(this.pyramidRenderTarget[c].width,this.pyramidRenderTarget[c].height),Object.assign(this.material.uniforms,this.marchPassUniforms)}let o=a.shadowMap.enabled;a.shadowMap.enabled=!1;let l=a.getRenderTarget();a.setRenderTarget(this.spatialPassRenderTarget),a.render(this.spatialscene,Rp),a.setRenderTarget(this.potentialPassRenderTarget),a.render(this.potentialPassScene,Rp),a.setRenderTarget(this.voxelPassRenderTarget),a.render(this.voxelPassScene,Rp),hP.streamCompaction.renderPyramid(this.resolutionLevel,this.pyramidLevelSizes,a,this.voxelPassRenderTarget,this.pyramidRenderTarget).then(h=>{this.material.wireframe&&(h*3>this.geometry.attributes.position.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.dispose(),this.geometry=new Ge,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.geometry.attributes.position=new tt(new Float32Array(h*3*2),3)),(h*3>this.geometry.drawRange.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.drawRange.count=Math.floor(h*1.2)*3),this.drawRangeNeedsForceUpdate=!1}),a.shadowMap.enabled=o,a.setRenderTarget(l)}}set npart(e){e!==this._npart&&(this.drawRangeNeedsForceUpdate=!0,this._npart=e,this.spatialn=Math.ceil(e/(4*Ls)))}get npart(){return this._npart}set resolutionLevel(e){let t=Math.min(8,Math.max(5,e));if(t!==this._resolutionLevel){switch(this._resolutionLevel=t,this.resolution=Math.pow(2,t),this.resolutionLevel){case 5:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192],this.bboxSize=31*8*ja,this.bboxOffset=8*ja*-1/2;break;case 6:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512],this.bboxSize=63*4*ja,this.bboxOffset=4*ja*-1/2;break;case 7:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192,384,768,1536],this.bboxSize=127*2*ja,this.bboxOffset=2*ja*-1/2;break;case 8:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096],this.bboxSize=255*ja,this.bboxOffset=ja*-1/2;break}this.pyramidTexture1Width=0,this.pyramidTexture2Width=0,this.pyramidTexture1Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-2],this.pyramidTexture2Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-3];for(let i=this.pyramidLevelSizes.length-2;i>=0;i--)(this.pyramidLevelSizes.length-2)%2===i%2?this.pyramidTexture1Width+=this.pyramidLevelSizes[i]:this.pyramidTexture2Width+=this.pyramidLevelSizes[i];this.basePyramidSize=this.pyramidLevelSizes[this.pyramidLevelSizes.length-1],this.zLayersPerRow=this.basePyramidSize/this.resolution,this.numLevels=this.pyramidLevelSizes.length-1,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.needsRebuild=!0,this.customDepthMaterialNeedsUpdate=!0}}get resolutionLevel(){return this._resolutionLevel}get spatialPassRenderTarget(){let e=this._spatialPassRenderTargets[this.resolutionLevel];return e||(e=new Pt(this.spatialDivisions*this.spatialn,this.spatialDivisions**2,{format:ni,type:jt,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:_t,magFilter:_t}),this._spatialPassRenderTargets[this.resolutionLevel]=e),e}get potentialPassRenderTarget(){let e=this._potentialPassRenderTargets[this.resolutionLevel];return e||(e=new Pt(this.basePyramidSize,this.basePyramidSize,{format:ni,type:jt,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:_t,magFilter:_t}),this._potentialPassRenderTargets[this.resolutionLevel]=e),e}get voxelPassRenderTarget(){let e=this._voxelPassRenderTargets[this.resolutionLevel];return e||(e=new dM(this.basePyramidSize,this.basePyramidSize,2,{stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:_t,magFilter:_t}),e.texture[0].format=ni,e.texture[0].type=jt,e.texture[1].format=wp,e.texture[1].type=jt,this._voxelPassRenderTargets[this.resolutionLevel]=e),e}get pyramidRenderTarget(){let e=this._pyramidRenderTargets[this.resolutionLevel];if(!e){let t=new Pt(this.pyramidTexture1Width,this.pyramidTexture1Height,{format:ni,type:jt,stencilBuffer:!1,depthBuffer:!1,magFilter:_t,minFilter:_t}),i=new Pt(this.pyramidTexture2Width,this.pyramidTexture2Height,{format:ni,type:jt,stencilBuffer:!1,depthBuffer:!1,magFilter:_t,minFilter:_t});e=[t,i],this._pyramidRenderTargets[this.resolutionLevel]=e}return e}updateState(e,t){let i=this.material;super.updateState(e,t),i!==this.material&&(this.needsRebuild=!0),e.geometry&&(this.resolutionLevel=e.geometry.resolutionLevel,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]}),e.wireframe&&!this.geometry.getAttribute("position")?this.geometry.setAttribute("position",new tt(new Float32Array(this.geometry.drawRange.count*3),3)):!e.wireframe&&this.geometry.getAttribute("position")&&this.geometry.deleteAttribute("position")}spatialPassMaterial(){let e=` precision highp float; out vec4 pc_FragColor; const float spatialDivisions = ${this.spatialDivisions}.; uniform float span; uniform float npart; uniform float spatialn; ${na.shapeInput()} vec3 low, high; // range of current div; subset of -1 .. 1 with span border // lookup one element/channel's worth of spheres for current division // stating with low sphere number lowi // gives a key to which spheres from lowi..lowi+23 are active within given div (low..high) float spatialKey(float lowi) { float t = 0.; for (float ii = ${Ls-1}.; ii >= 0.; ii--) { float i = ii + lowi; float iin = (i + 0.5) / ${hr}.; vec4 shape = shapePos(iin); vec3 d = shape.xyz; float op = shape.w; t *= 2.; t += ( low.x < d.x && d.x < high.x && low.y < d.y && d.y < high.y && low.z < d.z && d.z < high.z && i < npart || op == -2. // always include if op is -2, which is the intersection operation ) ? 1. : 0.; } return t; } ${na.getpart} void main() { // spatialial fragment shader // find active div vec3 div; // which div is current // out holds x=> x, lowi faster moving and y=> z, y faster moving float yz = float(gl_FragCoord.y - 0.5); // contains z, y faster moving div.y = getpart(yz, spatialDivisions); div.z = yz; // getpart(yz, spatialDivisions.z); // what's left, should be the same as getpart float lx = float(gl_FragCoord.x - 0.5); // contains x, lowi faster moving float lowi = getpart(lx, spatialn) * ${4*Ls}.; div.x = lx; low = div / spatialDivisions * 2. - 1. - span; high = (div+1.) / spatialDivisions * 2. - 1. + span; // find active range of spheres pc_FragColor.x = spatialKey(lowi); pc_FragColor.y = spatialKey(lowi+${Ls}.); pc_FragColor.z = spatialKey(lowi+${2*Ls}.); pc_FragColor.w = spatialKey(lowi+${3*Ls}.); } `;return new Op({name:"Spatial Pass",fragmentShader:e,uniforms:this.spatialPassUniforms})}potentialPassMaterial(){let e=` precision highp float; out vec4 pc_FragColor; ${na.shapeInput()} uniform sampler2D spatialPassTexture; const float res = float(RES); const float VOXEL_RESOLUTION = pow(2., res); const float Z_LAYERS_PER_ROW = ceil(pow(2., res / 2.)); const float VOXEL_RESOLUTION_SUB1 = VOXEL_RESOLUTION - 1.; const float INV_VOXEL_RESOLUTION = 1.0 / VOXEL_RESOLUTION; uniform float npart; uniform float spatialn; const float spatialDivisions = ${this.spatialDivisions}.; const float spatialDivisions2 = spatialDivisions * spatialDivisions; const float spatialDivisionsSub1 = spatialDivisions - 1.; ${na.getpart} vec3 packRGBAToVec3(vec4 color) { uint r = uint(color.r * 255.); uint g = uint(color.g * 255.); uint combined = (r << 8) | g; return vec3(float(combined) * 0.00001525902, color.b, color.a); // 1/65535 } void applyQuaternionToVector(in vec4 q, inout vec3 v) { v += 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v); } /** * SDF functions (reference: https://iquilezles.org/articles/distfunctions/) */ // branchless version of "Smooth Union, Subtraction and Intersection - bound, bound, bound" in above reference float smoothOperation(float op, float sdf, float d, float k) { // union: op = 1 => signSubtract = 1, signIntersection = 1 // subtract: op = -1 => signSubtract = -1, signIntersection = 1 // intersection: op = -2 => signSubtract = -1, signIntersection = -1 float signSubtract = clamp(op, -1., 1.); float signIntersection = 2. * (op - signSubtract) + 1.; float h = clamp( 0.5 + signSubtract * 0.5 * (sdf - signSubtract * signIntersection * d) / k, 0.0, 1.0 ); return mix(sdf, signSubtract * signIntersection * d, h) - signSubtract * k * h * (1.0 - h); } float sdSphere( vec3 p, float s ) { return length(p)-s; } float sdEllipsoid( vec3 p, vec3 r ) { float k0 = length(p/r); float k1 = length(p/(r*r)); return k0*(k0-1.0)/k1; } float sdBox( vec3 p, vec3 b ) { vec3 q = abs(p) - b; return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); } float sdTorus( vec3 p, vec2 t ) { vec2 q = vec2(length(p.xy)-t.x,p.z); return length(q)-t.y; } float sdCappedTorus( vec3 p, vec2 sc, float ra, float rb) { p.x = abs(p.x); float k = (sc.y*p.x>sc.x*p.y) ? dot(p.xy,sc) : length(p.xy); return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb; } float dot2( in vec2 v ) { return dot(v,v); } float sdCappedCone( vec3 p, float h, float r1, float r2 ) { vec2 q = vec2( length(p.xz), p.y ); vec2 k1 = vec2(r2,h); vec2 k2 = vec2(r2-r1,2.0*h); vec2 ca = vec2(q.x-min(q.x,(q.y<0.0)?r1:r2), abs(q.y)-h); vec2 cb = q - k1 + k2*clamp( dot(k1-q,k2)/dot2(k2), 0.0, 1.0 ); float s = (cb.x<0.0 && ca.y<0.0) ? -1.0 : 1.0; return s*sqrt( min(dot2(ca),dot2(cb)) ); } float sdCappedCylinder( vec3 p, float h, float r ) { vec2 d = abs(vec2(length(p.xz),p.y)) - vec2(r,h); return min(max(d.x,d.y),0.0) + length(max(d,0.0)); } float maxBlend = 0.0; // compute potential from A (=24) spheres, using the bit flags in 'activeKey' // to avoid lookup/compute for inactive spheres // return field potential, side effect updates track, // compute and return +ve and -ve values separately void fillSpatialInner( float ii, float activeKey, vec3 corner, inout float sdf, inout float colorDivisor, inout vec4 trackColor ) { for (float i = 0.; i < ${Ls}.; i++) { if (activeKey < 1.) break; // activeKey exhausted, no more active spheres activeKey *= 0.5; if (fract(activeKey) < 0.5) continue; float iin = (i + ii + 0.5) * ${1/hr}; vec4 shape = shapePos(iin); vec4 quat = shapeQuat(iin); vec4 params1 = shapeParams1(iin); vec4 params2 = shapeParams2(iin); vec3 p = corner - shape.xyz; applyQuaternionToVector(quat, p); p /= params2.z; // scale float d; // d in -1..1 coordinates switch (int(params1.x)) { case 0: d = sdSphere(p, params1.y); break; case 1: d = sdEllipsoid(p, params1.yzw); break; case 2: d = sdBox(p, params1.yzw); break; case 3: d = sdCappedCylinder(p, params1.y, params1.z); break; case 4: d = sdCappedCone(p, params1.y, params1.z, params1.w); break; case 5: d = sdTorus(p, params1.yz); break; case 6: d = sdCappedTorus(p, params1.yz, params1.w, params2.w); break; } d -= params2.y; // rounded edge d *= params2.z; // scale float k = params2.x; float op = shape.w; sdf = smoothOperation(shape.w, sdf, d, k); float isNegativeOne = step(-1.5, op) * step(op, -0.5); // 1 when op == -1, 0 otherwise float colorCull = smoothstep(maxBlend, 0., -d); float cullFactor = mix(1.0, colorCull, isNegativeOne); trackColor *= cullFactor; colorDivisor *= cullFactor; maxBlend = max(maxBlend, k); k += 2. * INV_VOXEL_RESOLUTION; // avoid division by zero, and other color artifacts with very small k float nearness = smoothstep(k, 0., d); vec4 color = shapeColor(iin); nearness *= float(color.a >= 0.); colorDivisor += nearness; trackColor += color * nearness; } } vec3 div; // compute potential from all spheres; collect +ve and =ve values separately // work in blocks of A*4 (=96) spheres, using the bit flags in 4 float channel 'activeKey' values // TODO check if extra vec3 output useful, not really used at present float fillSpatial(vec3 corner, inout vec4 trackColor) { float sdf = 1e3; // hack: initialize to large value float colorDivisor = 0.; // spatialPassTexture holds x=> lowi, x faster moving and y=> z, y faster moving float divyz = (div.y + div.z * spatialDivisions + 0.5) / (spatialDivisions2); for (float ii = 0.; ii < spatialn; ii++) { float i = ii * ${4*Ls}.; vec4 activeKey = texture(spatialPassTexture, vec2((div.x * spatialn + ii + 0.5)/(spatialn * spatialDivisions), divyz)); fillSpatialInner(i, activeKey.x, corner, sdf, colorDivisor, trackColor); fillSpatialInner(i+${Ls}., activeKey.y, corner, sdf, colorDivisor, trackColor); fillSpatialInner(i+${2*Ls}., activeKey.z, corner, sdf, colorDivisor, trackColor); fillSpatialInner(i+${3*Ls}., activeKey.w, corner, sdf, colorDivisor, trackColor); } trackColor /= colorDivisor; return mix(sdf, 0.0, step(1e20 - 0.1, sdf)); } void main() { ${na.getxyzi} // get xi yi zi from 2d position vec3 xyzi = vec3(xi,yi,zi); vec3 corner = xyzi / VOXEL_RESOLUTION_SUB1 * 2. - 1.; // -1..1 coords div = floor(xyzi / VOXEL_RESOLUTION_SUB1 * spatialDivisionsSub1); vec4 c = vec4(0.); float t = fillSpatial(corner, c); pc_FragColor = vec4(t, packRGBAToVec3(c)); // RGB texture } `;return new Op({name:"PotentialPass",fragmentShader:e,uniforms:this.potentialPassUniforms})}voxelPassMaterial(){let e=` precision highp float; layout(location = 0) out vec4 pc_FragColor; layout(location = 1) out vec4 numTris; const float res = float(RES); const float VOXEL_RESOLUTION = pow(2., res); const float VOXEL_RESOLUTION_SUB1 = VOXEL_RESOLUTION - 1.; const float Z_LAYERS_PER_ROW = ceil(pow(2., res / 2.)); const float INV_VOXEL_RESOLUTION = 1.0 / VOXEL_RESOLUTION; uniform sampler2D numTrisTable; // 256 x 1 float keyi(float f000, float f100, float f010, float f110, float f001, float f101, float f011, float f111) { return (float(f000 < 0.) * 1.) + (float(f100 < 0.) * 2.) + (float(f010 < 0.) * 8.) + (float(f110 < 0.) * 4.) + (float(f001 < 0.) * 16.) + (float(f101 < 0.) * 32.) + (float(f011 < 0.) * 128.) + (float(f111 < 0.) * 64.); } ${na.lookup} vec3 compNormi(float xi, float yi, float zi) { float dx = look(xi + 1., yi, zi, potentialPassTexture).r - look(xi - 1., yi, zi, potentialPassTexture).r; float dy = look(xi, yi + 1., zi, potentialPassTexture).r - look(xi, yi - 1., zi, potentialPassTexture).r; float dz = look(xi, yi, zi + 1., potentialPassTexture).r - look(xi, yi, zi - 1., potentialPassTexture).r; // if we allow (common) 0,0,0 case through then NaN can spread // eg r = vec4(compNorm i(???), 1.) will pollute r.w if (dx == 0.0 && dy == 0.0 && dz == 0.0) { return vec3(0.199, 0.299, 0.399); } return normalize(vec3(dx, dy, dz)); } void main() { ${na.getxyzi} // get xi yi zi from 2d vec3 normal = compNormi(xi, yi, zi); // even if our key is -1 this may be needed by a neighbouring voxel if (xi >= VOXEL_RESOLUTION_SUB1 || yi >= VOXEL_RESOLUTION_SUB1 || zi >= VOXEL_RESOLUTION_SUB1) { pc_FragColor = vec4(normal, 0.); numTris = vec4(0.); return; } float f000 = look(xi, yi, zi, potentialPassTexture).r, f100 = look(xi+1., yi, zi, potentialPassTexture).r, f010 = look(xi, yi+1., zi, potentialPassTexture).r, f110 = look(xi+1., yi+1., zi, potentialPassTexture).r, f001 = look(xi, yi, zi+1., potentialPassTexture).r, f101 = look(xi+1., yi, zi+1., potentialPassTexture).r, f011 = look(xi, yi+1., zi+1., potentialPassTexture).r, f111 = look(xi+1., yi+1., zi+1., potentialPassTexture).r; float key = keyi(f000, f100, f010, f110, f001, f101, f011, f111); pc_FragColor = vec4(normal, key); numTris = texture(numTrisTable, vec2((key + 0.5) / 256., 0.5)); } `;return new Op({name:"VoxelPass",fragmentShader:e,uniforms:this.voxelPassUniforms})}patchVertexShaderForShapeBlend(e){let t=` #ifdef SHAPEBLEND precision highp sampler2D; uniform float isol; uniform sampler2D triTable; // 256 x 16 uniform sampler2D pyramidTexture1; uniform vec2 pyramidTexture1Size; uniform sampler2D pyramidTexture2; uniform vec2 pyramidTexture2Size; const vec2 halfPixelOffset = vec2(0.5, 0.5); const vec2 rShift = vec2(0., 1.); const vec2 gShift = vec2(1., 1.); const vec2 bShift = vec2(1., 0.); const float res = float(RES); const float VOXEL_RESOLUTION = pow(2., res); const float Z_LAYERS_PER_ROW = ceil(pow(2., res / 2.)); const float INV_VOXEL_RESOLUTION = 1.0 / VOXEL_RESOLUTION; const float scale_factor = ${ja}.; #if SHAPEBLEND == 5 const float levelShiftX[7] = float[7](4., 6., 12., 24., 48., 96., 192.); const float scale = 8. * scale_factor; const vec3 originOffset = vec3(16.); #elif SHAPEBLEND == 7 const float levelShiftX[10] = float[10](4., 6., 12., 24., 48., 96., 192., 384., 768., 1536.); const float scale = 2. * scale_factor; const vec3 originOffset = vec3(64.); #elif SHAPEBLEND == 8 const float levelShiftX[11] = float[11](4., 8., 16., 32., 64., 128., 256., 512., 1024., 2048., 4096.); const float scale = scale_factor; const vec3 originOffset = vec3(128.); #else const float levelShiftX[8] = float[8](4., 8., 16., 32., 64., 128., 256., 512.); const float scale = 4. * scale_factor; const vec3 originOffset = vec3(32.); #endif ${na.lookup} const vec3 offsets[24] = vec3[]( vec3(0., 0., 0.), vec3(1., 0., 0.), vec3(1., 0., 0.), vec3(1., 1., 0.), vec3(0., 1., 0.), vec3(1., 1., 0.), vec3(0., 0., 0.), vec3(0., 1., 0.), vec3(0., 0., 1.), vec3(1., 0., 1.), vec3(1., 0., 1.), vec3(1., 1., 1.), vec3(0., 1., 1.), vec3(1., 1., 1.), vec3(0., 0., 1.), vec3(0., 1., 1.), vec3(0., 0., 0.), vec3(0., 0., 1.), vec3(1., 0., 0.), vec3(1., 0., 1.), vec3(1., 1., 0.), vec3(1., 1., 1.), vec3(0., 1., 0.), vec3(0., 1., 1.) ); vec2 computeShiftedPosition1(vec2 xy, float levelOriginX) { vec2 xyShifted = xy; xyShifted.x += levelOriginX; return (xyShifted + halfPixelOffset) / pyramidTexture1Size; } vec2 computeShiftedPosition2(vec2 xy, float levelOriginX) { vec2 xyShifted = xy; xyShifted.x += levelOriginX; return (xyShifted + halfPixelOffset) / pyramidTexture2Size; } vec4 unpackVec3ToRGBA(vec3 vec) { uint combined = uint(vec.x * 65535.0 + 0.5); // Add 0.5 for rounding float g = float(combined & uint(0xFF)) * 0.00392156862; // 1/255 float r = float((combined >> 8) & uint(0xFF)) * 0.00392156862; return vec4(r, g, vec.y, vec.z); } out vec4 marchColor; // end of marchvertPre #endif `,i=` #ifdef SHAPEBLEND float triIndex = floor(float(gl_VertexID/3)); float vertexIndex = float(gl_VertexID); // Initial pyramid lookup float levelOriginX1 = pyramidTexture1Size.x - 2.; float levelOriginX2 = pyramidTexture2Size.x - 1.; vec2 xy = vec2(0.); vec4 lookUp = texture(pyramidTexture2, computeShiftedPosition2(xy, levelOriginX2)); // Early exit check if (triIndex >= lookUp.r) return; // Optimize loop variables float start = 0.; vec4 triIndexVec = vec4(triIndex); // Main position computation loop for (int i = 0; i < LOOP;) { // Compute boundaries vec4 ends = lookUp + vec4(start); vec4 starts = vec4(ends.gba, start); vec4 check = vec4(greaterThanEqual(triIndexVec, starts)) * vec4(lessThan(triIndexVec, ends)); // Update position xy *= 2.; xy += check.r * rShift + check.g * gShift + check.b * bShift; // Update loop variables start = dot(check, starts); levelOriginX2 -= levelShiftX[i]; // Update lookup lookUp = texture(pyramidTexture1, computeShiftedPosition1(xy, levelOriginX1)); i++; ends = lookUp + vec4(start); starts = vec4(ends.gba, start); check = vec4(greaterThanEqual(triIndexVec, starts)) * vec4(lessThan(triIndexVec, ends)); // Update position xy *= 2.; xy += check.r * rShift + check.g * gShift + check.b * bShift; // Update loop variables start = dot(check, starts); levelOriginX1 -= levelShiftX[i]; // Update lookup lookUp = texture(pyramidTexture2, computeShiftedPosition2(xy, levelOriginX2)); i++; } #if HALF == 1 vec4 ends = lookUp + vec4(start); vec4 starts = vec4(ends.gba, start); vec4 check = vec4(greaterThanEqual(triIndexVec, starts)) * vec4(lessThan(triIndexVec, ends)); // Update position xy *= 2.; xy += check.r * rShift + check.g * gShift + check.b * bShift; // Update loop variables start = dot(check, starts); #endif // Compute final coordinates vec3 gridPos; gridPos.x = mod(xy.x, VOXEL_RESOLUTION); gridPos.y = mod(xy.y, VOXEL_RESOLUTION); gridPos.z = floor(xy.x * INV_VOXEL_RESOLUTION) + floor(xy.y * INV_VOXEL_RESOLUTION) * Z_LAYERS_PER_ROW; // Vertex key computation vertexIndex -= start * 3.; float vk = vertexIndex * 0.0625 + 0.03125; // Optimized division by 16 and addition of 1/32 // Voxel lookup and edge computation vec4 voxel = look(gridPos.x, gridPos.y, gridPos.z, voxelPassTexture); float key = (voxel.w + 0.5) * 0.00390625; // Optimized division by 256 // Edge lookup and offset computation float edgeNum = texture(triTable, vec2(vk, key)).x; int edgeIndex = int(edgeNum) * 2; // Compute edge positions vec3 p1 = gridPos + offsets[edgeIndex]; vec3 p2 = gridPos + offsets[edgeIndex + 1]; // Compute potentials and normals vec4 potential1 = look(p1.x, p1.y, p1.z, potentialPassTexture); vec4 potential2 = look(p2.x, p2.y, p2.z, potentialPassTexture); // Final position and normal computation float mu = potential1.r / (potential1.r - potential2.r); marchColor = mix( unpackVec3ToRGBA(potential1.gba), unpackVec3ToRGBA(potential2.gba), mu ); transformed = p1 + (p2 - p1) * mu; transformed -= originOffset; transformed *= scale; vec4 data1 = look(p1.x, p1.y, p1.z, voxelPassTexture); vec4 data2 = look(p2.x, p2.y, p2.z, voxelPassTexture); objectNormal = normalize(mix(data1.xyz, data2.xyz, mu)); transformedNormal = normalMatrix * objectNormal; #ifndef FLAT_SHADED vNormal = transformedNormal; #endif #endif `;e.vertexShader=t+e.vertexShader.replace("#include ",i+` #include `);let r=e.fragmentShader.match(/vec3 diffuseColor[^\n]*\n/);if(!r)return;let s=` #ifdef SHAPEBLEND_C #if SHAPEBLEND_C == 1 ${r[0].replace(/nodeU0,/g,"marchColor.rgb,").replace(/nodeU\d+(?=,g_uid\d+_calpha\))/g,"marchColor.a")} #else ${r[0]} #endif #else ${r[0]} #endif `;e.fragmentShader=`in vec4 marchColor; `+e.fragmentShader.replace(r[0],s),Object.assign(e.uniforms,this.marchPassUniforms)}initDebugPass(e){console.log("fboToDebug.width",e.width,e.height),this.geometry=new Ea(e.width,e.height),this.geometry.userData={parameters:{width:4,height:4}};let t={inputTexture:{value:Array.isArray(e.texture)?e.texture[1]:e.texture},pyramidTextureSize:{value:void 0}},i=r=>{r.vertexShader=` precision highp float; varying vec2 vUv; void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); vUv = uv; } `,r.fragmentShader=` layout(location = 1) out vec4 gVelocity; precision highp float; uniform sampler2D inputTexture; varying vec2 vUv; uniform vec2 pyramidTextureSize; void main() { // Sample the input texture using UV coordinates gl_FragColor = texture(inputTexture, vUv); gVelocity = vec4(0.0); } `,t.pyramidTextureSize.value=new j(this.pyramidRenderTarget.width,this.pyramidRenderTarget.height),Object.assign(r.uniforms,t)};this.material.shapeBlendhack=i,this.material.root.shapeBlendhack=i}},pl=hP;pl.streamCompaction=new _$;var S$=new we,A$=new we,Yl=new lt,Bn=new M,pp=new M,M$=new lt;function E$(e,t=0){let i=this.children.length;for(;i--;){let r=this.children[i];cl.is(r)&&cP.call(r,e,t+1)}}function cP(e,t=0){if(e(this,t)!==!0){let i=this.children.length;for(;i--;){let r=this.children[i];cl.is(r)&&cP.call(r,e,t+1)}}}function C$(){if(this.shapesDataTexture.value===void 0){let n=new Ur(new Float32Array(4*hr*Go),hr,Go,ni,jt);this.shapesDataTexture.value=n}let e=this.shapesDataTexture.value,t=e.image.data;e.needsUpdate=!0;let i=0,r=this.data.geometry.blendRange,s=S$.copy(this.matrixWorld).invert(),a=0;E$.call(this,n=>{var v;if(n.visible===!1)return!0;let o;if(n instanceof bs||n instanceof id||n instanceof rd)return;n instanceof gr?o=n.object:o=n;let l=(v=n.data)==null?void 0:v.cloner;if(Tt.is(n)&&l&&!l.hideBase&&l.type!=="radial"&&l.disabled!==!0||!(o instanceof Ii))return;let h=o.geometry.userData.parameters,c=h.shapeBlendNode;if(c===void 0)return;if(A$.multiplyMatrices(s,n.matrixWorld).decompose(pp,Yl,Bn),h.type==="TorusGeometry"&&h.arc!==360){let y=h.arc*Math.PI/180;y=y/4,Yl.multiply(M$.set(0,0,Math.sin(y),Math.cos(y)))}let d=c.overrideGlobalBlend?c.blendRange:r;d=d/this.bboxSize*2,t[a*4]=(pp.x-this.bboxOffset)/this.bboxSize*2,t[a*4+1]=(pp.y-this.bboxOffset)/this.bboxSize*2,t[a*4+2]=(pp.z-this.bboxOffset)/this.bboxSize*2,t[a*4+3]=c.operation===0?1:c.operation===2?-1:-2,t[hr*4+a*4]=-Yl.x,t[hr*4+a*4+1]=-Yl.y,t[hr*4+a*4+2]=-Yl.z,t[hr*4+a*4+3]=Yl.w;let u=new Float32Array(4),p=0;if(h.type==="SphereGeometry")h.width===h.height&&h.width===h.depth?u[0]=0:u[0]=1,u[1]=h.width/this.bboxSize,u[2]=h.height/this.bboxSize,u[3]=h.depth/this.bboxSize,i=Math.max(i,u[1]*Bn.x+d,u[2]*Bn.x+d,u[3]*Bn.x+d);else if(h.type==="CubeGeometry"){p=h.cornerRadius;let y=h.width,x=h.height,w=h.depth;u[0]=2,u[1]=(y-2*p)/this.bboxSize,u[2]=(x-2*p)/this.bboxSize,u[3]=(w-2*p)/this.bboxSize,i=Math.max(i,Math.sqrt(y**2+x**2+w**2)/this.bboxSize*Bn.x+d)}else if(h.type==="CylinderGeometry"){p=h.cornerRadius;let y=h.height,x=h.radiusBottom,w=h.radiusTop;if(w>=x){let _=Math.atan2(w-x,y),b=(Math.PI/2-_)/2;w-=p/Math.tan(b),x-=p*Math.tan(b)}else if(x>w){let _=Math.atan2(x-w,y),b=(Math.PI/2-_)/2;w-=p*Math.tan(b),x-=p/Math.tan(b)}u[1]=(h.height-2*p)/this.bboxSize,x===w?(u[0]=3,u[2]=x/this.bboxSize*2):(u[0]=4,u[2]=x/this.bboxSize*2,u[3]=w/this.bboxSize*2),i=Math.max(i,u[1]*4*Bn.x+d)}else if(h.type==="TorusGeometry"){if(u[0]=5,u[1]=(h.width-h.depth)/this.bboxSize,u[2]=h.depth/this.bboxSize,h.arc!==360){u[0]=6,u[3]=u[1],t[hr*12+a*4+3]=u[2];let y=2*Math.atan2(u[2]/2,u[1]),x=h.arc*Math.PI/180/2-y;u[1]=Math.sin(x),u[2]=Math.cos(x)}i=Math.max(i,h.width*Bn.x/this.bboxSize+d)}t.set(u,hr*8+a*4),t[hr*12+a*4]=d,t[hr*12+a*4+1]=p/this.bboxSize*2,t[hr*12+a*4+2]=Bn.x;let f=o.material,g=f.uniforms.nodeU0.node.value,m=f.uniforms.nodeU1.value;c.operation!==0&&!c.useColor&&(m=-1),t[hr*16+a*4]=g.r,t[hr*16+a*4+1]=g.g,t[hr*16+a*4+2]=g.b,t[hr*16+a*4+3]=m,m<1&&this.material.defines.SHAPEBLEND_C===1&&(this.material.transparent=!0),a++}),this.npart=a,this.spatialPassUniforms.span.value=i*1.4}var dP=512;function IA(e,t){let i=!1,r=e.layers.mask&dP,s=t.getLayersOfType("transmission"),a=t.getLayersOfType("outline");return a.length>0&&(e.layers.set(8),s.length>0&&e.layers.enable(3),i=!0,Y1(e),X1(e)),s.length===0&&a.length===0&&e.layers.set(0),r&&e.layers.set(9),e instanceof xl&&e.needsAO&&e.layers.enable(5),i}function OA(e,t){if(!t.layers)return!1;let i=e.layers.mask&dP,r=!1,s=t.getLayersOfType("transmission").filter(n=>n.data.visible),a=t.getLayersOfType("outline").filter(n=>n.data.visible);return s.length>0&&(e.layers.set(3),a.length>0&&e.layers.enable(8),r=!0),s.length===0&&a.length===0&&e.layers.set(0),i&&e.layers.set(9),e.needsAO&&e.layers.enable(5),r}function T$(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof xl)if(Array.isArray(i.material))for(let r=0;r{if(i instanceof xl)if(Array.isArray(i.material))for(let r=0;r0&&i.push({...c[0],object:r?a:e})}}var R$=class{constructor(){this._constraints=new Map}setConstraint(e,t){t===null?this._constraints.delete(e):this._constraints.set(e,t)}removeDependencies(e){this._constraints.delete(e)}applyConstraints(e){let t=new Set;this._constraints.forEach((i,r)=>{let s=[r,i],a=i;for(;this._constraints.has(a);){if(a=this._constraints.get(a),s.includes(a)){console.warn(`circular dependency detected: ${s.join(" -> ")}`);break}t.has(a)||s.push(a)}for(let n=s.length-2;n>=0;n--)if(!t.has(s[n])){let o=e.find(s[n]);o?o.applyPathSnapping(e):console.warn(`missing entity ${s[n]}`),t.add(s[n])}})}findDependency(e,t){let i=e;for(;this._constraints.has(i);)if(i=this._constraints.get(i),i===t)return!0;return!1}},L$="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL",to=class{};Bc(to,"DepthMapRange",65536),Bc(to,"MemoryPageSize",65536),Bc(to,"BytesPerFloat",4),Bc(to,"BytesPerInt",4);function z$(e){let t,i,r,s,a,n,o,l,h,c,d,u,p,f,g,m;function v(T){let D=new Float64Array(c,n,16);for(let P=0;P<16;P++)D[P]=T[P];let O;if(r>1){t.exports.sortIndexes(s,a,h,n,o,l,u.DepthMapRange,r);let P=new Uint32Array(r);O=P.buffer,P.set(new Uint32Array(c,l,r))}else if(r===1){let P=new Uint32Array(r);P[0]=new Uint32Array(c,s,i)[0],O=P.buffer}else O=new ArrayBuffer(0);e.postMessage({sortDone:!0,indexesBuffer:O},[O])}function y(T,D,O){let P=new Float32Array(c,a,i*3);r=0;let U=new Uint32Array(c,s,i);for(let W=0;WG.enabled&&G.mode==="Include").map(G=>G.type==="Box"?b(G):E(G)),X=k.filter(G=>G.enabled&&G.mode==="Exclude").map(G=>G.type==="Box"?b(G):E(G));for(let G=O[W];Gk.enabled&&k.mode==="Include").map(k=>k.type==="Box"?b(k):E(k)),U=D.filter(k=>k.enabled&&k.mode==="Exclude").map(k=>k.type==="Box"?b(k):E(k)),W=T.length;for(let k=0;k{let k=_(T,D,O,W.invRotationMatrix,W.cropCenter);return Array.isArray(W)?S(k.x,k.y,k.z,W):C(k.x,k.y,k.z,W)})}function _(T,D,O,P,U){let W=T-U[0],k=D-U[1],F=O-U[2],Z=1/(P[3]*W+P[7]*k+P[11]*F+P[15]);return{x:(P[0]*W+P[4]*k+P[8]*F+P[12])*Z+U[0],y:(P[1]*W+P[5]*k+P[9]*F+P[13])*Z+U[1],z:(P[2]*W+P[6]*k+P[10]*F+P[14])*Z+U[2]}}function b(T){let D=T.cropSize[0]/2,O=T.cropSize[1]/2,P=T.cropSize[2]/2,U=[T.cropCenter[0]-D,T.cropCenter[1]-O,T.cropCenter[2]-P,T.cropCenter[0]+D,T.cropCenter[1]+O,T.cropCenter[2]+P],W=A(T.cropRotation);return Object.assign(U,{invRotationMatrix:W,cropCenter:T.cropCenter})}function A(T){let D=[],O=T[0]*Math.PI/180,P=T[1]*Math.PI/180,U=T[2]*Math.PI/180,W=Math.cos(O),k=Math.sin(O),F=Math.cos(P),Z=Math.sin(P),X=Math.cos(U),G=Math.sin(U),q=W*X,$=W*G,Q=k*X,ee=k*G;return D[0]=F*X,D[1]=-F*G,D[2]=Z,D[4]=$+Q*Z,D[5]=q-ee*Z,D[6]=-k*F,D[8]=ee-q*Z,D[9]=Q+$*Z,D[10]=W*F,D[12]=0,D[13]=0,D[14]=0,D[3]=0,D[7]=0,D[11]=0,D[15]=1,D}function S(T,D,O,P){return T>=P[0]&&T<=P[3]&&D>=P[1]&&D<=P[4]&&O>=P[2]&&O<=P[5]}function E(T){let D=2/T.cropSize[0],O=2/T.cropSize[1],P=2/T.cropSize[2],U=A(T.cropRotation);return{invRadiusX:D,invRadiusY:O,invRadiusZ:P,cropCenter:T.cropCenter,invRotationMatrix:U}}function C(T,D,O,P){let U=(T-P.cropCenter[0])*P.invRadiusX,W=(D-P.cropCenter[1])*P.invRadiusY,k=(O-P.cropCenter[2])*P.invRadiusZ;return U*U+W*W+k*k<=1}e.onmessage=T=>{if(T.data.getCroppedIndexes){let D=new Uint32Array(x(new Float32Array(T.data.positions),T.data.crops)).buffer;e.postMessage({outOfBoundsIndexes:D},[D])}else if(T.data.positions)d=T.data.positions,p=new Float32Array(d),g=T.data.meshMatrixWorlds,m=T.data.cropsArray,f=T.data.meshIndexIntervals,y(g,m,f),e.postMessage({sortSetupComplete:!0});else if(T.data.sort||T.data.newMatrixWorlds||T.data.newCropsArray)(T.data.newMatrixWorlds||T.data.newCropsArray)&&(m=T.data.newCropsArray||m,g=T.data.newMatrixWorlds||g,y(g,m,f)),v(T.data.sort.view,T.data.sort.cameraPosition);else if(T.data.init){u=T.data.init.Constants,i=T.data.init.splatCount;let D=u.BytesPerInt,O=u.BytesPerFloat*3,P=new Uint8Array(T.data.init.sorterWasmBytes),U=D+O,W=i*U,k=i*u.BytesPerInt*2+u.DepthMapRange*u.BytesPerInt*2,F=u.MemoryPageSize*32,Z=W+k+F,X=Math.floor(Z/u.MemoryPageSize)+1,G={module:{},env:{memory:new WebAssembly.Memory({initial:X*2,maximum:X*3,shared:!0})}};WebAssembly.compile(P).then(q=>WebAssembly.instantiate(q,G)).then(q=>{t=q,s=0,a=i*D,n=a+i*O,h=n+16*u.BytesPerFloat*2,o=h+i*u.BytesPerInt,l=o+u.DepthMapRange*u.BytesPerInt,c=G.env.memory.buffer,e.postMessage({sortSetupPhase1Complete:!0})})}}}function B$(e){let t=new Worker(URL.createObjectURL(new Blob(["(",z$.toString(),")(self)"],{type:"application/javascript"}))),i=atob(L$),r=new Uint8Array(i.length);for(let s=0;s{if(r.visible===!1)return!0;r.type==="Splat"&&(t=!0)}),t}var Lp=class extends Jt{constructor(e,t,i,r,s=!1,a=1,n,o){super(i,r),this.splatCount=t,this.meshIndexIntervals=n,this.meshMatrixWorlds=o,this.splatBuffers=e,this.geometry=i,this.material=r,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=s,this.devicePixelRatio=a,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,i=!1,r=1,s,a){let n=Lp.buildGeomtery(t),o=Lp.buildMaterial(s);return new Lp(e,t,n,o,i,r,s,a)}static buildMaterial(e){let t=` precision highp float; #include attribute uint splatIndex; uniform highp sampler2D covariancesTexture; uniform highp usampler2D centersColorsTexture; uniform vec2 focal; uniform vec2 viewport; uniform vec2 basisViewport; uniform vec2 covariancesTextureSize; uniform vec2 centersColorsTextureSize; uniform highp sampler2D meshMatrixWorldsTexture; uniform uint meshIndexIntervals[257]; uniform float orthoZoom; varying vec4 vColor; varying vec2 vUv; varying vec2 vPosition; const vec4 encodeNorm4 = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0); const uvec4 mask4 = uvec4(uint(0x000000FF), uint(0x0000FF00), uint(0x00FF0000), uint(0xFF000000)); const uvec4 shift4 = uvec4(0, 8, 16, 24); vec4 uintToRGBAVec (uint u) { uvec4 urgba = mask4 & u; urgba = urgba >> shift4; vec4 rgba = vec4(urgba) * encodeNorm4; return rgba; } vec2 getDataUV(in int stride, in int offset, in vec2 dimensions) { vec2 samplerUV = vec2(0.0, 0.0); float d = float(splatIndex * uint(stride) + uint(offset)) / dimensions.x; samplerUV.y = float(floor(d)) / dimensions.y; samplerUV.x = fract(d); return samplerUV; } void main () { uvec4 sampledCenterColor = texture(centersColorsTexture, getDataUV(1, 0, centersColorsTextureSize)); vec3 splatCenter = uintBitsToFloat(uvec3(sampledCenterColor.gba)); vColor = uintToRGBAVec(sampledCenterColor.r); vPosition = position.xy * 2.0; uint meshIndex; for (int i = 1; i < 257; i++) { if (splatIndex < meshIndexIntervals[i]) { meshIndex = uint(i - 1); break; } } float strideMulmeshIndex = float(4u*meshIndex); float meshMatrixWorldsTextureLength = float(256*4); mat4 modelMat = mat4( texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+0.0)/meshMatrixWorldsTextureLength, 0)), texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+1.0)/meshMatrixWorldsTextureLength, 0)), texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+2.0)/meshMatrixWorldsTextureLength, 0)), texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+3.0)/meshMatrixWorldsTextureLength, 0)) ); mat4 modelViewMat = viewMatrix * modelMat; vec4 viewCenter = modelViewMat * vec4(splatCenter, 1.0); vec4 clipCenter = projectionMatrix * viewCenter; vec2 sampledCovarianceA = texture(covariancesTexture, getDataUV(3, 0, covariancesTextureSize)).rg; vec2 sampledCovarianceB = texture(covariancesTexture, getDataUV(3, 1, covariancesTextureSize)).rg; vec2 sampledCovarianceC = texture(covariancesTexture, getDataUV(3, 2, covariancesTextureSize)).rg; vec3 cov3D_M11_M12_M13 = vec3(sampledCovarianceA.rg, sampledCovarianceB.r); vec3 cov3D_M22_M23_M33 = vec3(sampledCovarianceB.g, sampledCovarianceC.rg); // Compute the 2D covariance matrix from the upper-right portion of the 3D covariance matrix mat3 Vrk = mat3( cov3D_M11_M12_M13.x, cov3D_M11_M12_M13.y, cov3D_M11_M12_M13.z, cov3D_M11_M12_M13.y, cov3D_M22_M23_M33.x, cov3D_M22_M23_M33.y, cov3D_M11_M12_M13.z, cov3D_M22_M23_M33.y, cov3D_M22_M23_M33.z ); float s = 1.0 / (viewCenter.z * viewCenter.z); mat3 W = transpose(mat3(modelViewMat)); mat3 T = orthoZoom > 0.0 ? W : W * mat3( focal.x / viewCenter.z, 0., -(focal.x * viewCenter.x) * s, 0., focal.y / viewCenter.z, -(focal.y * viewCenter.y) * s, 0., 0., 0. ); mat3 cov2Dm = transpose(T) * Vrk * T; cov2Dm[0][0] += 0.3; cov2Dm[1][1] += 0.3; // We are interested in the upper-left 2x2 portion of the projected 3D covariance matrix because // we only care about the X and Y values. We want the X-diagonal, cov2Dm[0][0], // the Y-diagonal, cov2Dm[1][1], and the correlation between the two cov2Dm[0][1]. We don't // need cov2Dm[1][0] because it is a symetric matrix. vec3 cov2Dv = vec3(cov2Dm[0][0], cov2Dm[0][1], cov2Dm[1][1]); vec3 ndcCenter = clipCenter.xyz / clipCenter.w; // We now need to solve for the eigen-values and eigen vectors of the 2D covariance matrix // so that we can determine the 2D basis for the splat. This is done using the method described // here: https://people.math.harvard.edu/~knill/teaching/math21b2004/exhibits/2dmatrices/index.html // // This is a different approach than in the original work at INRIA. In that work they compute the // max extents of the 2D covariance matrix in screen space to form an axis aligned bounding rectangle // which forms the geometry that is actually rasterized. They then use the inverse 2D covariance // matrix (called 'conic') to determine fragment opacity. float a = cov2Dv.x; float d = cov2Dv.z; float b = cov2Dv.y; float D = a * d - b * b; float trace = a + d; float traceOver2 = 0.5 * trace; float term2 = sqrt(trace * trace / 4.0 - D); float eigenValue1 = traceOver2 + term2; float eigenValue2 = max(traceOver2 - term2, 0.00); // prevent negative eigen value const float maxSplatSize = 1024.0; vec2 eigenVector1 = normalize(vec2(b, eigenValue1 - a)); // since the eigen vectors are orthogonal, we derive the second one from the first vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x); vec2 basisVector1 = eigenVector1 * min(sqrt(2.0 * eigenValue1), maxSplatSize); vec2 basisVector2 = eigenVector2 * min(sqrt(2.0 * eigenValue2), maxSplatSize); vec2 ndcOffset = vec2(vPosition.x * basisVector1 + vPosition.y * basisVector2) * basisViewport; if (orthoZoom > 0.0) { ndcOffset *= orthoZoom; } gl_Position = vec4(ndcCenter.xy + ndcOffset, ndcCenter.z, 1.0); }`,i=` precision highp float; #include uniform vec3 debugColor; varying vec4 vColor; varying vec2 vUv; varying vec2 vPosition; layout(location = 1) out vec4 gVelocity; void main () { // compute the negative squared distance from the center of the splat to the // current fragment in the splat's local space. float A = -dot(vPosition, vPosition); if (A < -4.0) discard; vec3 color = vColor.rgb; A = exp(A) * vColor.a; gl_FragColor = vec4(color.rgb, A); gVelocity = vec4(0.0); // so it is ignored by TAA }`,r={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new j},viewport:{type:"v2",value:new j},basisViewport:{type:"v2",value:new j},debugColor:{type:"v3",value:new et},covariancesTextureSize:{type:"v2",value:new j(1024,1024)},centersColorsTextureSize:{type:"v2",value:new j(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Dt({uniforms:r,vertexShader:t,fragmentShader:i,transparent:!0,alphaTest:1,blending:Jo,depthTest:!0,depthWrite:!1,side:Ar})}static buildGeomtery(e){let t=new Ge;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),r=new tt(i,3);t.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=new NM().copy(t),a=new Uint32Array(e),n=new ud(a,1,!1);return n.setUsage(ER),s.setAttribute("splatIndex",n),s.instanceCount=e,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(e,e+s*4).set(r.colorsA),e+=s*4,this.centers.subarray(t,t+s*3).set(r.decoded.xyz.denormDequant().data),t+=s*3,this.covariances.subarray(i,i+s*6).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=s*6}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new j(4096,1024);for(;t.x*t.y*20&&(fp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(fp),this.material.uniforms.basisViewport.value.set(2/fp.x,2/fp.y),this.material.uniforms.focal.value.set(t,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}},uP,U$=new Promise(e=>{uP=e}),LA=!1,mp;function N$(){if(LA)return;if(mp)return mp;async function e(){let t=await vo(()=>import("./gaussian-splat-compression-CuwKY2Va.js"),__vite__mapDeps([]));uP(t),LA=!0}return mp=e(),mp}var pP;U$.then(e=>pP=e);var k$=class{constructor(e={}){Bc(this,"updateView",function(){let t=new we,i=[],r=new M(0,0,-1),s=new M(0,0,-1),a=new M,n=new M;return function(o=!1,l){let h=this.updateMatrixWorldsInWorkerIfNeeded(),c=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(l.quaternion);let u=!1,p=!1;if(s.dot(r)<=.95&&(u=!0),n.copy(l.position).sub(a).length()>=1&&(p=!0),!u&&!p&&!h&&!c&&!this.needsInitialRender)return}this.needsInitialRender=!1,a.copy(l.position),r.copy(s),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...h?{newMatrixWorlds:this.meshMatrixWorlds}:{},...c?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}()),this.scene=e.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new we().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(e,t){let i=new j;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(e.getSize(i),this.cameraFocalLengthX=t.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=t.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,t.isPerspectiveCamera?-1:t.zoom*this.devicePixelRatio))}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new M().fromArray(e.position)),e.orientation&&(e.orientation=new lt().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&t.push(a)}),this.splatMesh&&this.splatMesh.dispose(),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=t.map(a=>a.matrixWorld.clone()),this.cropsArray=t.map(a=>a.data.crops.map(n=>n.data));let i=t.map(a=>new pP.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),r=0,s=[0];for(let a of i)r+=a.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;tt.equals(this.meshMatrixWorldsOld[i]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{var r;t.data.crops.forEach((s,a)=>{this.cropsArray[i][a]===void 0?(e=!0,this.cropsArray[i][a]=s.data):Object.entries(s.data).forEach(([n,o])=>{var l;Array.isArray(o)&&o.some((h,c)=>h!==this.cropsArray[i][a][n][c])?(e=!0,this.cropsArray[i][a][n]=o):o!==((l=this.cropsArray[i][a])==null?void 0:l[n])&&(e=!0,this.cropsArray[i][a][n]=o)})}),t.data.crops.length!==((r=this.cropsArray[i])==null?void 0:r.length)&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new M,r=new lt,s=!1,a=1,n,o){this.splatMesh=Lp.buildMesh(e,t,s,a,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=t,this.splatMesh.onBeforeRender=(l,h,c)=>this.update(l,c)}setupSortWorker(e){this.sortWorker=B$(e),this.sortWorker.onmessage=t=>{var i;t.data.sortDone?(this.sortRunning=!1,(i=this.splatMesh)==null||i.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(e,t){this.splatMesh!==null&&(this.updateSplatMeshUniforms(e,t),this.updateView(!1,t))}getSplatMesh(){return this.splatMesh}},_y=new gn;_y.wireframe=!0;var zA=new M,nx=class extends Jr{constructor(e,t){super(),this.data=e,this.sharedAssets=t,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.shapeBlendIntances=[],this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new R$,this.invisibleObjects=new Mh("jflkdsafjasdifjaslk",{...P0.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new $i("fdasfa",{...Uh.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=P$(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=T$(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof $i&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let a=r.children.indexOf(s);i.splice(0,0,a)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>FE(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===ic)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof $i&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof $i&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{t===void 0&&i instanceof Sr&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof $i&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{var t;(t=e.cloner)==null||t.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){var i;if(e.path.length===0&&e.type===7){let r=e.parent===null?this:this.find(e.parent);if(r===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,r,e.localIndex,t);s.updateVisible(this),s.resetBBoxNeedsUpdate(),Ns(s)&&un(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");r.traverseEntity(a=>{a instanceof pl&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(n=>n!==a))}),this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(r),this.markPenumbraSizeDirty(),r.parent.remove(r),un(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ns(r)&&(r.freeBooleanPointer(),s instanceof ul&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r instanceof ix&&r.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),this.pathConstraints.removeDependencies(r.uuid),r.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),(i=r.cloner)==null||i.resetOnMove(),this.markToExpandCloner(r);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(r),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(this),r.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let n=e.localIndex;a.children.splice(n,0,a.children.pop()),Ns(r)&&(r.invalidateUpstreamBooleanData(),un(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof ul&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){var t;this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let i of this.children)i instanceof $i&&(i.visible=i.uuid===e,i.visible&&(this.activePage=i,this.activePage.onActive(this)));this.activePage!==((t=this.splatViewer)==null?void 0:t.activePage)&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{b$(s,t,i,{scene:this,shared:r}),s instanceof Ii&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}updateEntity2DByOp(e,t,i,r,s,a=[]){e.updateEntityByOp(t,i,r,s),this.traverseEntity(n=>{(n instanceof Sr||n instanceof $i)&&(a.includes(n.frameId??"")||n.frameId===t)&&n.updateEntity2DByOp(t,i,r,s)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{r instanceof Mr&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Tt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Tt.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,a,n){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(l=>{l.data=_d(l.data,h=>{let c=h.events.data(n.id),d=l.goUp(a);if(d){let u=[...BE(d.identity),e].join("-"),p=this.entityIdentityToEntity[u];if(p){let f=p.uuid,g=Gi.zoom(c,t);g[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,a){e.forEach(n=>{n.data.type==="Transition"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Animation"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Conditional"&&(this.rewriteActions(n.data.ifActions,[...t,n.id,"ifActions"],i,r,s,a),this.rewriteActions(n.data.elseActions,[...t,n.id,"elseActions"],i,r,s,a))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Eh&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=_d(a.data,n=>{a.isInstanceRoot||(n.events.delete(r.id),s=!0)}).data}),s===!1)for(let a of wf.list)this.rewriteActions(r.data.gameActions[a],["gameActions",a],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if(s instanceof Eh&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(a=>{i.addClip(a)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),sx(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof Eh&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)Tt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let a of s.children){let n=a.cloner;if(Tt.is(a)&&!a.raycastLock&&(a.visible||n!=null&&n.object.data.visible))if(t===!0&&a.isInstanceRoot){let o=[];if(e.intersectObject(a,!0,o),o.length){let l=o[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let h=a.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(Ns(a)||cy(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),wy(a,e,i)),r(a)}};return r(this.activePage),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;Tt.is(s)&&(s.visible||a!=null&&a.object.data.visible)&&((Ns(s)||cy(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),wy(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)Tt.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Tt.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Tt.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof Ii&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s,t);let a=i.invalidateDownstreamBooleanData();un(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)cl.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Tt.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,a){var l;let n={scene:this,shared:a},o=ax(e,t,n);return o instanceof pl&&this.shapeBlendIntances.push(o),o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,a)),o.updateState(t,n),o instanceof Ii&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),(l=t.pathSnapping)!=null&&l.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(h=>{let c=h.dataPatched;if(h instanceof Ii&&c.bones&&c.boneInverses){let d=c.bones.map(f=>this.find(f)),u=c.boneInverses.map(f=>new we().fromArray(f)),p=new qy(d,u);h.bind(p,h.bindMatrix)}else h.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,s=e.length;r{if(t instanceof Vr)if(Array.isArray(t.material))for(let i=0;i{r instanceof Mr&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(){this.splatViewer=new k$({scene:this}),this.reloadSplats()}reloadSplats(){var e;(e=this.splatViewer)==null||e.loadSplat()}},zp=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},V$=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return G$(Math.atan2(r,i))},j$=(e,t,i)=>{let r={x:0,y:0};return i=Sy(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},Sy=e=>e*(Math.PI/180),G$=e=>e*(180/Math.PI),H$=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,hv=new Map,BA=e=>{hv.has(e)&&clearTimeout(hv.get(e)),hv.set(e,setTimeout(e,100))},Nf=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a{let r=t.split(/[ ,]+/g),s;for(let a=0;a(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),UA=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},Ay=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},ox=(e,t,i)=>{let r=mP(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let a="";for(let n=0,o=t.length;n{let i=mP(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},mP=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},cv=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},q$=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},My=(e,t)=>{if(e.length)for(let i=0,r=e.length;i({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(gP="ontouchstart"in window,vP=!!window.PointerEvent,yP=!!window.MSPointerEvent);var gP,vP,yP,Dc={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},fh,Od={};vP?fh=Dc.pointer:yP?fh=Dc.MSPointer:gP?(fh=Dc.touch,Od=Dc.mouse):fh=Dc.mouse;function bl(){}bl.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};bl.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;ai&&t-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t0?n="up":n="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:a,y:n,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+a,e),h.y||this.trigger("plain:"+n,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var Y$=Xi;function Ai(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=Ai.id,Ai.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Ai.prototype=new lx;Ai.constructor=Ai;Ai.id=0;Ai.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r