index-77d0e8dc.js 656 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207
  1. var gh=Object.defineProperty;var _h=(n,e,t)=>e in n?gh(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ct=(n,e,t)=>(_h(n,typeof e!="symbol"?e+"":e,t),t);import{d as Xd,c as Zs,aN as vh,u as ut,r as Kt,a as $r,aO as xh,aP as Dl,w as co,aG as Sh,I as Ll,aI as Yd,aQ as Po,f as Jt,o as Pn,h as ms,k as at,n as Gs,l as Et,K as qd,L as jd,i as gn,t as $d,q as rc,s as yh,O as La,_ as Zd,aR as Mh,p as mn,N as Zr,a3 as Eh,z as oc,P as Do,R as bh,aS as wh,aT as Th,a7 as Ah}from"./index-32c39055.js";import{e as Ia,B as Ch,C as Rh,D as Ph,E as Dh,F as Lh,G as ac}from"./case-de2e9213.js";import{b as Ih,c as Uh}from"./quisk-5962c204.js";import{m as Nh}from"./mitt-f7ef348c.js";import{s as Oh}from"./file-serve-dfea9462.js";import"./scene-3c8ec63c.js";import"./scrollbar-5051cfce.js";import"./upload-8c2ee168.js";import"./pagging-ff0d698d.js";import"./index-343523a6.js";import"./pagging-58a38392.js";import"./sys-e4ad01b3.js";import"./REG-6dcdd243.js";function lc(n){return n!==null&&typeof n=="object"&&"constructor"in n&&n.constructor===Object}function Il(n,e){n===void 0&&(n={}),e===void 0&&(e={}),Object.keys(e).forEach(t=>{typeof n[t]>"u"?n[t]=e[t]:lc(e[t])&&lc(n[t])&&Object.keys(e[t]).length>0&&Il(n[t],e[t])})}const Kd={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector(){return null},querySelectorAll(){return[]},getElementById(){return null},createEvent(){return{initEvent(){}}},createElement(){return{children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName(){return[]}}},createElementNS(){return{}},importNode(){return null},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function Rs(){const n=typeof document<"u"?document:{};return Il(n,Kd),n}const Fh={document:Kd,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle(){return{getPropertyValue(){return""}}},Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia(){return{}},requestAnimationFrame(n){return typeof setTimeout>"u"?(n(),null):setTimeout(n,0)},cancelAnimationFrame(n){typeof setTimeout>"u"||clearTimeout(n)}};function dn(){const n=typeof window<"u"?window:{};return Il(n,Fh),n}function Bh(n){return n===void 0&&(n=""),n.trim().split(" ").filter(e=>!!e.trim())}function zh(n){const e=n;Object.keys(e).forEach(t=>{try{e[t]=null}catch{}try{delete e[t]}catch{}})}function Ua(n,e){return e===void 0&&(e=0),setTimeout(n,e)}function uo(){return Date.now()}function kh(n){const e=dn();let t;return e.getComputedStyle&&(t=e.getComputedStyle(n,null)),!t&&n.currentStyle&&(t=n.currentStyle),t||(t=n.style),t}function Hh(n,e){e===void 0&&(e="x");const t=dn();let i,s,r;const o=kh(n);return t.WebKitCSSMatrix?(s=o.transform||o.webkitTransform,s.split(",").length>6&&(s=s.split(", ").map(a=>a.replace(",",".")).join(", ")),r=new t.WebKitCSSMatrix(s==="none"?"":s)):(r=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=r.toString().split(",")),e==="x"&&(t.WebKitCSSMatrix?s=r.m41:i.length===16?s=parseFloat(i[12]):s=parseFloat(i[4])),e==="y"&&(t.WebKitCSSMatrix?s=r.m42:i.length===16?s=parseFloat(i[13]):s=parseFloat(i[5])),s||0}function lr(n){return typeof n=="object"&&n!==null&&n.constructor&&Object.prototype.toString.call(n).slice(8,-1)==="Object"}function Gh(n){return typeof window<"u"&&typeof window.HTMLElement<"u"?n instanceof HTMLElement:n&&(n.nodeType===1||n.nodeType===11)}function ln(){const n=Object(arguments.length<=0?void 0:arguments[0]),e=["__proto__","constructor","prototype"];for(let t=1;t<arguments.length;t+=1){const i=t<0||arguments.length<=t?void 0:arguments[t];if(i!=null&&!Gh(i)){const s=Object.keys(Object(i)).filter(r=>e.indexOf(r)<0);for(let r=0,o=s.length;r<o;r+=1){const a=s[r],l=Object.getOwnPropertyDescriptor(i,a);l!==void 0&&l.enumerable&&(lr(n[a])&&lr(i[a])?i[a].__swiper__?n[a]=i[a]:ln(n[a],i[a]):!lr(n[a])&&lr(i[a])?(n[a]={},i[a].__swiper__?n[a]=i[a]:ln(n[a],i[a])):n[a]=i[a])}}}return n}function cr(n,e,t){n.style.setProperty(e,t)}function Jd(n){let{swiper:e,targetPosition:t,side:i}=n;const s=dn(),r=-e.translate;let o=null,a;const l=e.params.speed;e.wrapperEl.style.scrollSnapType="none",s.cancelAnimationFrame(e.cssModeFrameID);const c=t>r?"next":"prev",d=(h,f)=>c==="next"&&h>=f||c==="prev"&&h<=f,u=()=>{a=new Date().getTime(),o===null&&(o=a);const h=Math.max(Math.min((a-o)/l,1),0),f=.5-Math.cos(h*Math.PI)/2;let g=r+f*(t-r);if(d(g,t)&&(g=t),e.wrapperEl.scrollTo({[i]:g}),d(g,t)){e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[i]:g})}),s.cancelAnimationFrame(e.cssModeFrameID);return}e.cssModeFrameID=s.requestAnimationFrame(u)};u()}function $n(n,e){e===void 0&&(e="");const t=[...n.children];return n instanceof HTMLSlotElement&&t.push(...n.assignedElements()),e?t.filter(i=>i.matches(e)):t}function Vh(n,e){const t=e.contains(n);return!t&&e instanceof HTMLSlotElement?[...e.assignedElements()].includes(n):t}function ho(n){try{console.warn(n);return}catch{}}function Na(n,e){e===void 0&&(e=[]);const t=document.createElement(n);return t.classList.add(...Array.isArray(e)?e:Bh(e)),t}function Wh(n,e){const t=[];for(;n.previousElementSibling;){const i=n.previousElementSibling;e?i.matches(e)&&t.push(i):t.push(i),n=i}return t}function Xh(n,e){const t=[];for(;n.nextElementSibling;){const i=n.nextElementSibling;e?i.matches(e)&&t.push(i):t.push(i),n=i}return t}function gi(n,e){return dn().getComputedStyle(n,null).getPropertyValue(e)}function cc(n){let e=n,t;if(e){for(t=0;(e=e.previousSibling)!==null;)e.nodeType===1&&(t+=1);return t}}function Yh(n,e){const t=[];let i=n.parentElement;for(;i;)e?i.matches(e)&&t.push(i):t.push(i),i=i.parentElement;return t}function dc(n,e,t){const i=dn();return t?n[e==="width"?"offsetWidth":"offsetHeight"]+parseFloat(i.getComputedStyle(n,null).getPropertyValue(e==="width"?"margin-right":"margin-top"))+parseFloat(i.getComputedStyle(n,null).getPropertyValue(e==="width"?"margin-left":"margin-bottom")):n.offsetWidth}let Lo;function qh(){const n=dn(),e=Rs();return{smoothScroll:e.documentElement&&e.documentElement.style&&"scrollBehavior"in e.documentElement.style,touch:!!("ontouchstart"in n||n.DocumentTouch&&e instanceof n.DocumentTouch)}}function Qd(){return Lo||(Lo=qh()),Lo}let Io;function jh(n){let{userAgent:e}=n===void 0?{}:n;const t=Qd(),i=dn(),s=i.navigator.platform,r=e||i.navigator.userAgent,o={ios:!1,android:!1},a=i.screen.width,l=i.screen.height,c=r.match(/(Android);?[\s\/]+([\d.]+)?/);let d=r.match(/(iPad).*OS\s([\d_]+)/);const u=r.match(/(iPod)(.*OS\s([\d_]+))?/),h=!d&&r.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f=s==="Win32";let g=s==="MacIntel";const _=["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"];return!d&&g&&t.touch&&_.indexOf(`${a}x${l}`)>=0&&(d=r.match(/(Version)\/([\d.]+)/),d||(d=[0,1,"13_0_0"]),g=!1),c&&!f&&(o.os="android",o.android=!0),(d||h||u)&&(o.os="ios",o.ios=!0),o}function eu(n){return n===void 0&&(n={}),Io||(Io=jh(n)),Io}let Uo;function $h(){const n=dn(),e=eu();let t=!1;function i(){const a=n.navigator.userAgent.toLowerCase();return a.indexOf("safari")>=0&&a.indexOf("chrome")<0&&a.indexOf("android")<0}if(i()){const a=String(n.navigator.userAgent);if(a.includes("Version/")){const[l,c]=a.split("Version/")[1].split(" ")[0].split(".").map(d=>Number(d));t=l<16||l===16&&c<2}}const s=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(n.navigator.userAgent),r=i(),o=r||s&&e.ios;return{isSafari:t||r,needPerspectiveFix:t,need3dFix:o,isWebView:s}}function Zh(){return Uo||(Uo=$h()),Uo}function Kh(n){let{swiper:e,on:t,emit:i}=n;const s=dn();let r=null,o=null;const a=()=>{!e||e.destroyed||!e.initialized||(i("beforeResize"),i("resize"))},l=()=>{!e||e.destroyed||!e.initialized||(r=new ResizeObserver(u=>{o=s.requestAnimationFrame(()=>{const{width:h,height:f}=e;let g=h,_=f;u.forEach(m=>{let{contentBoxSize:p,contentRect:b,target:y}=m;y&&y!==e.el||(g=b?b.width:(p[0]||p).inlineSize,_=b?b.height:(p[0]||p).blockSize)}),(g!==h||_!==f)&&a()})}),r.observe(e.el))},c=()=>{o&&s.cancelAnimationFrame(o),r&&r.unobserve&&e.el&&(r.unobserve(e.el),r=null)},d=()=>{!e||e.destroyed||!e.initialized||i("orientationchange")};t("init",()=>{if(e.params.resizeObserver&&typeof s.ResizeObserver<"u"){l();return}s.addEventListener("resize",a),s.addEventListener("orientationchange",d)}),t("destroy",()=>{c(),s.removeEventListener("resize",a),s.removeEventListener("orientationchange",d)})}function Jh(n){let{swiper:e,extendParams:t,on:i,emit:s}=n;const r=[],o=dn(),a=function(d,u){u===void 0&&(u={});const h=o.MutationObserver||o.WebkitMutationObserver,f=new h(g=>{if(e.__preventObserver__)return;if(g.length===1){s("observerUpdate",g[0]);return}const _=function(){s("observerUpdate",g[0])};o.requestAnimationFrame?o.requestAnimationFrame(_):o.setTimeout(_,0)});f.observe(d,{attributes:typeof u.attributes>"u"?!0:u.attributes,childList:e.isElement||(typeof u.childList>"u"?!0:u).childList,characterData:typeof u.characterData>"u"?!0:u.characterData}),r.push(f)},l=()=>{if(e.params.observer){if(e.params.observeParents){const d=Yh(e.hostEl);for(let u=0;u<d.length;u+=1)a(d[u])}a(e.hostEl,{childList:e.params.observeSlideChildren}),a(e.wrapperEl,{attributes:!1})}},c=()=>{r.forEach(d=>{d.disconnect()}),r.splice(0,r.length)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",l),i("destroy",c)}var Qh={on(n,e,t){const i=this;if(!i.eventsListeners||i.destroyed||typeof e!="function")return i;const s=t?"unshift":"push";return n.split(" ").forEach(r=>{i.eventsListeners[r]||(i.eventsListeners[r]=[]),i.eventsListeners[r][s](e)}),i},once(n,e,t){const i=this;if(!i.eventsListeners||i.destroyed||typeof e!="function")return i;function s(){i.off(n,s),s.__emitterProxy&&delete s.__emitterProxy;for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];e.apply(i,o)}return s.__emitterProxy=e,i.on(n,s,t)},onAny(n,e){const t=this;if(!t.eventsListeners||t.destroyed||typeof n!="function")return t;const i=e?"unshift":"push";return t.eventsAnyListeners.indexOf(n)<0&&t.eventsAnyListeners[i](n),t},offAny(n){const e=this;if(!e.eventsListeners||e.destroyed||!e.eventsAnyListeners)return e;const t=e.eventsAnyListeners.indexOf(n);return t>=0&&e.eventsAnyListeners.splice(t,1),e},off(n,e){const t=this;return!t.eventsListeners||t.destroyed||!t.eventsListeners||n.split(" ").forEach(i=>{typeof e>"u"?t.eventsListeners[i]=[]:t.eventsListeners[i]&&t.eventsListeners[i].forEach((s,r)=>{(s===e||s.__emitterProxy&&s.__emitterProxy===e)&&t.eventsListeners[i].splice(r,1)})}),t},emit(){const n=this;if(!n.eventsListeners||n.destroyed||!n.eventsListeners)return n;let e,t,i;for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return typeof r[0]=="string"||Array.isArray(r[0])?(e=r[0],t=r.slice(1,r.length),i=n):(e=r[0].events,t=r[0].data,i=r[0].context||n),t.unshift(i),(Array.isArray(e)?e:e.split(" ")).forEach(l=>{n.eventsAnyListeners&&n.eventsAnyListeners.length&&n.eventsAnyListeners.forEach(c=>{c.apply(i,[l,...t])}),n.eventsListeners&&n.eventsListeners[l]&&n.eventsListeners[l].forEach(c=>{c.apply(i,t)})}),n}};function ef(){const n=this;let e,t;const i=n.el;typeof n.params.width<"u"&&n.params.width!==null?e=n.params.width:e=i.clientWidth,typeof n.params.height<"u"&&n.params.height!==null?t=n.params.height:t=i.clientHeight,!(e===0&&n.isHorizontal()||t===0&&n.isVertical())&&(e=e-parseInt(gi(i,"padding-left")||0,10)-parseInt(gi(i,"padding-right")||0,10),t=t-parseInt(gi(i,"padding-top")||0,10)-parseInt(gi(i,"padding-bottom")||0,10),Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Object.assign(n,{width:e,height:t,size:n.isHorizontal()?e:t}))}function tf(){const n=this;function e(v,A){return parseFloat(v.getPropertyValue(n.getDirectionLabel(A))||0)}const t=n.params,{wrapperEl:i,slidesEl:s,size:r,rtlTranslate:o,wrongRTL:a}=n,l=n.virtual&&t.virtual.enabled,c=l?n.virtual.slides.length:n.slides.length,d=$n(s,`.${n.params.slideClass}, swiper-slide`),u=l?n.virtual.slides.length:d.length;let h=[];const f=[],g=[];let _=t.slidesOffsetBefore;typeof _=="function"&&(_=t.slidesOffsetBefore.call(n));let m=t.slidesOffsetAfter;typeof m=="function"&&(m=t.slidesOffsetAfter.call(n));const p=n.snapGrid.length,b=n.slidesGrid.length;let y=t.spaceBetween,S=-_,C=0,T=0;if(typeof r>"u")return;typeof y=="string"&&y.indexOf("%")>=0?y=parseFloat(y.replace("%",""))/100*r:typeof y=="string"&&(y=parseFloat(y)),n.virtualSize=-y,d.forEach(v=>{o?v.style.marginLeft="":v.style.marginRight="",v.style.marginBottom="",v.style.marginTop=""}),t.centeredSlides&&t.cssMode&&(cr(i,"--swiper-centered-offset-before",""),cr(i,"--swiper-centered-offset-after",""));const D=t.grid&&t.grid.rows>1&&n.grid;D?n.grid.initSlides(d):n.grid&&n.grid.unsetSlides();let R;const E=t.slidesPerView==="auto"&&t.breakpoints&&Object.keys(t.breakpoints).filter(v=>typeof t.breakpoints[v].slidesPerView<"u").length>0;for(let v=0;v<u;v+=1){R=0;let A;if(d[v]&&(A=d[v]),D&&n.grid.updateSlide(v,A,d),!(d[v]&&gi(A,"display")==="none")){if(t.slidesPerView==="auto"){E&&(d[v].style[n.getDirectionLabel("width")]="");const O=getComputedStyle(A),L=A.style.transform,k=A.style.webkitTransform;if(L&&(A.style.transform="none"),k&&(A.style.webkitTransform="none"),t.roundLengths)R=n.isHorizontal()?dc(A,"width",!0):dc(A,"height",!0);else{const X=e(O,"width"),B=e(O,"padding-left"),G=e(O,"padding-right"),z=e(O,"margin-left"),J=e(O,"margin-right"),se=O.getPropertyValue("box-sizing");if(se&&se==="border-box")R=X+z+J;else{const{clientWidth:ae,offsetWidth:Ce}=A;R=X+B+G+z+J+(Ce-ae)}}L&&(A.style.transform=L),k&&(A.style.webkitTransform=k),t.roundLengths&&(R=Math.floor(R))}else R=(r-(t.slidesPerView-1)*y)/t.slidesPerView,t.roundLengths&&(R=Math.floor(R)),d[v]&&(d[v].style[n.getDirectionLabel("width")]=`${R}px`);d[v]&&(d[v].swiperSlideSize=R),g.push(R),t.centeredSlides?(S=S+R/2+C/2+y,C===0&&v!==0&&(S=S-r/2-y),v===0&&(S=S-r/2-y),Math.abs(S)<1/1e3&&(S=0),t.roundLengths&&(S=Math.floor(S)),T%t.slidesPerGroup===0&&h.push(S),f.push(S)):(t.roundLengths&&(S=Math.floor(S)),(T-Math.min(n.params.slidesPerGroupSkip,T))%n.params.slidesPerGroup===0&&h.push(S),f.push(S),S=S+R+y),n.virtualSize+=R+y,C=R,T+=1}}if(n.virtualSize=Math.max(n.virtualSize,r)+m,o&&a&&(t.effect==="slide"||t.effect==="coverflow")&&(i.style.width=`${n.virtualSize+y}px`),t.setWrapperSize&&(i.style[n.getDirectionLabel("width")]=`${n.virtualSize+y}px`),D&&n.grid.updateWrapperSize(R,h),!t.centeredSlides){const v=[];for(let A=0;A<h.length;A+=1){let O=h[A];t.roundLengths&&(O=Math.floor(O)),h[A]<=n.virtualSize-r&&v.push(O)}h=v,Math.floor(n.virtualSize-r)-Math.floor(h[h.length-1])>1&&h.push(n.virtualSize-r)}if(l&&t.loop){const v=g[0]+y;if(t.slidesPerGroup>1){const A=Math.ceil((n.virtual.slidesBefore+n.virtual.slidesAfter)/t.slidesPerGroup),O=v*t.slidesPerGroup;for(let L=0;L<A;L+=1)h.push(h[h.length-1]+O)}for(let A=0;A<n.virtual.slidesBefore+n.virtual.slidesAfter;A+=1)t.slidesPerGroup===1&&h.push(h[h.length-1]+v),f.push(f[f.length-1]+v),n.virtualSize+=v}if(h.length===0&&(h=[0]),y!==0){const v=n.isHorizontal()&&o?"marginLeft":n.getDirectionLabel("marginRight");d.filter((A,O)=>!t.cssMode||t.loop?!0:O!==d.length-1).forEach(A=>{A.style[v]=`${y}px`})}if(t.centeredSlides&&t.centeredSlidesBounds){let v=0;g.forEach(O=>{v+=O+(y||0)}),v-=y;const A=v>r?v-r:0;h=h.map(O=>O<=0?-_:O>A?A+m:O)}if(t.centerInsufficientSlides){let v=0;g.forEach(O=>{v+=O+(y||0)}),v-=y;const A=(t.slidesOffsetBefore||0)+(t.slidesOffsetAfter||0);if(v+A<r){const O=(r-v-A)/2;h.forEach((L,k)=>{h[k]=L-O}),f.forEach((L,k)=>{f[k]=L+O})}}if(Object.assign(n,{slides:d,snapGrid:h,slidesGrid:f,slidesSizesGrid:g}),t.centeredSlides&&t.cssMode&&!t.centeredSlidesBounds){cr(i,"--swiper-centered-offset-before",`${-h[0]}px`),cr(i,"--swiper-centered-offset-after",`${n.size/2-g[g.length-1]/2}px`);const v=-n.snapGrid[0],A=-n.slidesGrid[0];n.snapGrid=n.snapGrid.map(O=>O+v),n.slidesGrid=n.slidesGrid.map(O=>O+A)}if(u!==c&&n.emit("slidesLengthChange"),h.length!==p&&(n.params.watchOverflow&&n.checkOverflow(),n.emit("snapGridLengthChange")),f.length!==b&&n.emit("slidesGridLengthChange"),t.watchSlidesProgress&&n.updateSlidesOffset(),n.emit("slidesUpdated"),!l&&!t.cssMode&&(t.effect==="slide"||t.effect==="fade")){const v=`${t.containerModifierClass}backface-hidden`,A=n.el.classList.contains(v);u<=t.maxBackfaceHiddenSlides?A||n.el.classList.add(v):A&&n.el.classList.remove(v)}}function nf(n){const e=this,t=[],i=e.virtual&&e.params.virtual.enabled;let s=0,r;typeof n=="number"?e.setTransition(n):n===!0&&e.setTransition(e.params.speed);const o=a=>i?e.slides[e.getSlideIndexByData(a)]:e.slides[a];if(e.params.slidesPerView!=="auto"&&e.params.slidesPerView>1)if(e.params.centeredSlides)(e.visibleSlides||[]).forEach(a=>{t.push(a)});else for(r=0;r<Math.ceil(e.params.slidesPerView);r+=1){const a=e.activeIndex+r;if(a>e.slides.length&&!i)break;t.push(o(a))}else t.push(o(e.activeIndex));for(r=0;r<t.length;r+=1)if(typeof t[r]<"u"){const a=t[r].offsetHeight;s=a>s?a:s}(s||s===0)&&(e.wrapperEl.style.height=`${s}px`)}function sf(){const n=this,e=n.slides,t=n.isElement?n.isHorizontal()?n.wrapperEl.offsetLeft:n.wrapperEl.offsetTop:0;for(let i=0;i<e.length;i+=1)e[i].swiperSlideOffset=(n.isHorizontal()?e[i].offsetLeft:e[i].offsetTop)-t-n.cssOverflowAdjustment()}const uc=(n,e,t)=>{e&&!n.classList.contains(t)?n.classList.add(t):!e&&n.classList.contains(t)&&n.classList.remove(t)};function rf(n){n===void 0&&(n=this&&this.translate||0);const e=this,t=e.params,{slides:i,rtlTranslate:s,snapGrid:r}=e;if(i.length===0)return;typeof i[0].swiperSlideOffset>"u"&&e.updateSlidesOffset();let o=-n;s&&(o=n),e.visibleSlidesIndexes=[],e.visibleSlides=[];let a=t.spaceBetween;typeof a=="string"&&a.indexOf("%")>=0?a=parseFloat(a.replace("%",""))/100*e.size:typeof a=="string"&&(a=parseFloat(a));for(let l=0;l<i.length;l+=1){const c=i[l];let d=c.swiperSlideOffset;t.cssMode&&t.centeredSlides&&(d-=i[0].swiperSlideOffset);const u=(o+(t.centeredSlides?e.minTranslate():0)-d)/(c.swiperSlideSize+a),h=(o-r[0]+(t.centeredSlides?e.minTranslate():0)-d)/(c.swiperSlideSize+a),f=-(o-d),g=f+e.slidesSizesGrid[l],_=f>=0&&f<=e.size-e.slidesSizesGrid[l],m=f>=0&&f<e.size-1||g>1&&g<=e.size||f<=0&&g>=e.size;m&&(e.visibleSlides.push(c),e.visibleSlidesIndexes.push(l)),uc(c,m,t.slideVisibleClass),uc(c,_,t.slideFullyVisibleClass),c.progress=s?-u:u,c.originalProgress=s?-h:h}}function of(n){const e=this;if(typeof n>"u"){const d=e.rtlTranslate?-1:1;n=e&&e.translate&&e.translate*d||0}const t=e.params,i=e.maxTranslate()-e.minTranslate();let{progress:s,isBeginning:r,isEnd:o,progressLoop:a}=e;const l=r,c=o;if(i===0)s=0,r=!0,o=!0;else{s=(n-e.minTranslate())/i;const d=Math.abs(n-e.minTranslate())<1,u=Math.abs(n-e.maxTranslate())<1;r=d||s<=0,o=u||s>=1,d&&(s=0),u&&(s=1)}if(t.loop){const d=e.getSlideIndexByData(0),u=e.getSlideIndexByData(e.slides.length-1),h=e.slidesGrid[d],f=e.slidesGrid[u],g=e.slidesGrid[e.slidesGrid.length-1],_=Math.abs(n);_>=h?a=(_-h)/g:a=(_+g-f)/g,a>1&&(a-=1)}Object.assign(e,{progress:s,progressLoop:a,isBeginning:r,isEnd:o}),(t.watchSlidesProgress||t.centeredSlides&&t.autoHeight)&&e.updateSlidesProgress(n),r&&!l&&e.emit("reachBeginning toEdge"),o&&!c&&e.emit("reachEnd toEdge"),(l&&!r||c&&!o)&&e.emit("fromEdge"),e.emit("progress",s)}const No=(n,e,t)=>{e&&!n.classList.contains(t)?n.classList.add(t):!e&&n.classList.contains(t)&&n.classList.remove(t)};function af(){const n=this,{slides:e,params:t,slidesEl:i,activeIndex:s}=n,r=n.virtual&&t.virtual.enabled,o=n.grid&&t.grid&&t.grid.rows>1,a=u=>$n(i,`.${t.slideClass}${u}, swiper-slide${u}`)[0];let l,c,d;if(r)if(t.loop){let u=s-n.virtual.slidesBefore;u<0&&(u=n.virtual.slides.length+u),u>=n.virtual.slides.length&&(u-=n.virtual.slides.length),l=a(`[data-swiper-slide-index="${u}"]`)}else l=a(`[data-swiper-slide-index="${s}"]`);else o?(l=e.filter(u=>u.column===s)[0],d=e.filter(u=>u.column===s+1)[0],c=e.filter(u=>u.column===s-1)[0]):l=e[s];l&&(o||(d=Xh(l,`.${t.slideClass}, swiper-slide`)[0],t.loop&&!d&&(d=e[0]),c=Wh(l,`.${t.slideClass}, swiper-slide`)[0],t.loop&&!c===0&&(c=e[e.length-1]))),e.forEach(u=>{No(u,u===l,t.slideActiveClass),No(u,u===d,t.slideNextClass),No(u,u===c,t.slidePrevClass)}),n.emitSlidesClasses()}const Kr=(n,e)=>{if(!n||n.destroyed||!n.params)return;const t=()=>n.isElement?"swiper-slide":`.${n.params.slideClass}`,i=e.closest(t());if(i){let s=i.querySelector(`.${n.params.lazyPreloaderClass}`);!s&&n.isElement&&(i.shadowRoot?s=i.shadowRoot.querySelector(`.${n.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{i.shadowRoot&&(s=i.shadowRoot.querySelector(`.${n.params.lazyPreloaderClass}`),s&&s.remove())})),s&&s.remove()}},Oo=(n,e)=>{if(!n.slides[e])return;const t=n.slides[e].querySelector('[loading="lazy"]');t&&t.removeAttribute("loading")},Oa=n=>{if(!n||n.destroyed||!n.params)return;let e=n.params.lazyPreloadPrevNext;const t=n.slides.length;if(!t||!e||e<0)return;e=Math.min(e,t);const i=n.params.slidesPerView==="auto"?n.slidesPerViewDynamic():Math.ceil(n.params.slidesPerView),s=n.activeIndex;if(n.params.grid&&n.params.grid.rows>1){const o=s,a=[o-e];a.push(...Array.from({length:e}).map((l,c)=>o+i+c)),n.slides.forEach((l,c)=>{a.includes(l.column)&&Oo(n,c)});return}const r=s+i-1;if(n.params.rewind||n.params.loop)for(let o=s-e;o<=r+e;o+=1){const a=(o%t+t)%t;(a<s||a>r)&&Oo(n,a)}else for(let o=Math.max(s-e,0);o<=Math.min(r+e,t-1);o+=1)o!==s&&(o>r||o<s)&&Oo(n,o)};function lf(n){const{slidesGrid:e,params:t}=n,i=n.rtlTranslate?n.translate:-n.translate;let s;for(let r=0;r<e.length;r+=1)typeof e[r+1]<"u"?i>=e[r]&&i<e[r+1]-(e[r+1]-e[r])/2?s=r:i>=e[r]&&i<e[r+1]&&(s=r+1):i>=e[r]&&(s=r);return t.normalizeSlideIndex&&(s<0||typeof s>"u")&&(s=0),s}function cf(n){const e=this,t=e.rtlTranslate?e.translate:-e.translate,{snapGrid:i,params:s,activeIndex:r,realIndex:o,snapIndex:a}=e;let l=n,c;const d=f=>{let g=f-e.virtual.slidesBefore;return g<0&&(g=e.virtual.slides.length+g),g>=e.virtual.slides.length&&(g-=e.virtual.slides.length),g};if(typeof l>"u"&&(l=lf(e)),i.indexOf(t)>=0)c=i.indexOf(t);else{const f=Math.min(s.slidesPerGroupSkip,l);c=f+Math.floor((l-f)/s.slidesPerGroup)}if(c>=i.length&&(c=i.length-1),l===r&&!e.params.loop){c!==a&&(e.snapIndex=c,e.emit("snapIndexChange"));return}if(l===r&&e.params.loop&&e.virtual&&e.params.virtual.enabled){e.realIndex=d(l);return}const u=e.grid&&s.grid&&s.grid.rows>1;let h;if(e.virtual&&s.virtual.enabled&&s.loop)h=d(l);else if(u){const f=e.slides.filter(_=>_.column===l)[0];let g=parseInt(f.getAttribute("data-swiper-slide-index"),10);Number.isNaN(g)&&(g=Math.max(e.slides.indexOf(f),0)),h=Math.floor(g/s.grid.rows)}else if(e.slides[l]){const f=e.slides[l].getAttribute("data-swiper-slide-index");f?h=parseInt(f,10):h=l}else h=l;Object.assign(e,{previousSnapIndex:a,snapIndex:c,previousRealIndex:o,realIndex:h,previousIndex:r,activeIndex:l}),e.initialized&&Oa(e),e.emit("activeIndexChange"),e.emit("snapIndexChange"),(e.initialized||e.params.runCallbacksOnInit)&&(o!==h&&e.emit("realIndexChange"),e.emit("slideChange"))}function df(n,e){const t=this,i=t.params;let s=n.closest(`.${i.slideClass}, swiper-slide`);!s&&t.isElement&&e&&e.length>1&&e.includes(n)&&[...e.slice(e.indexOf(n)+1,e.length)].forEach(a=>{!s&&a.matches&&a.matches(`.${i.slideClass}, swiper-slide`)&&(s=a)});let r=!1,o;if(s){for(let a=0;a<t.slides.length;a+=1)if(t.slides[a]===s){r=!0,o=a;break}}if(s&&r)t.clickedSlide=s,t.virtual&&t.params.virtual.enabled?t.clickedIndex=parseInt(s.getAttribute("data-swiper-slide-index"),10):t.clickedIndex=o;else{t.clickedSlide=void 0,t.clickedIndex=void 0;return}i.slideToClickedSlide&&t.clickedIndex!==void 0&&t.clickedIndex!==t.activeIndex&&t.slideToClickedSlide()}var uf={updateSize:ef,updateSlides:tf,updateAutoHeight:nf,updateSlidesOffset:sf,updateSlidesProgress:rf,updateProgress:of,updateSlidesClasses:af,updateActiveIndex:cf,updateClickedSlide:df};function hf(n){n===void 0&&(n=this.isHorizontal()?"x":"y");const e=this,{params:t,rtlTranslate:i,translate:s,wrapperEl:r}=e;if(t.virtualTranslate)return i?-s:s;if(t.cssMode)return s;let o=Hh(r,n);return o+=e.cssOverflowAdjustment(),i&&(o=-o),o||0}function ff(n,e){const t=this,{rtlTranslate:i,params:s,wrapperEl:r,progress:o}=t;let a=0,l=0;const c=0;t.isHorizontal()?a=i?-n:n:l=n,s.roundLengths&&(a=Math.floor(a),l=Math.floor(l)),t.previousTranslate=t.translate,t.translate=t.isHorizontal()?a:l,s.cssMode?r[t.isHorizontal()?"scrollLeft":"scrollTop"]=t.isHorizontal()?-a:-l:s.virtualTranslate||(t.isHorizontal()?a-=t.cssOverflowAdjustment():l-=t.cssOverflowAdjustment(),r.style.transform=`translate3d(${a}px, ${l}px, ${c}px)`);let d;const u=t.maxTranslate()-t.minTranslate();u===0?d=0:d=(n-t.minTranslate())/u,d!==o&&t.updateProgress(n),t.emit("setTranslate",t.translate,e)}function pf(){return-this.snapGrid[0]}function mf(){return-this.snapGrid[this.snapGrid.length-1]}function gf(n,e,t,i,s){n===void 0&&(n=0),e===void 0&&(e=this.params.speed),t===void 0&&(t=!0),i===void 0&&(i=!0);const r=this,{params:o,wrapperEl:a}=r;if(r.animating&&o.preventInteractionOnTransition)return!1;const l=r.minTranslate(),c=r.maxTranslate();let d;if(i&&n>l?d=l:i&&n<c?d=c:d=n,r.updateProgress(d),o.cssMode){const u=r.isHorizontal();if(e===0)a[u?"scrollLeft":"scrollTop"]=-d;else{if(!r.support.smoothScroll)return Jd({swiper:r,targetPosition:-d,side:u?"left":"top"}),!0;a.scrollTo({[u?"left":"top"]:-d,behavior:"smooth"})}return!0}return e===0?(r.setTransition(0),r.setTranslate(d),t&&(r.emit("beforeTransitionStart",e,s),r.emit("transitionEnd"))):(r.setTransition(e),r.setTranslate(d),t&&(r.emit("beforeTransitionStart",e,s),r.emit("transitionStart")),r.animating||(r.animating=!0,r.onTranslateToWrapperTransitionEnd||(r.onTranslateToWrapperTransitionEnd=function(h){!r||r.destroyed||h.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onTranslateToWrapperTransitionEnd),r.onTranslateToWrapperTransitionEnd=null,delete r.onTranslateToWrapperTransitionEnd,r.animating=!1,t&&r.emit("transitionEnd"))}),r.wrapperEl.addEventListener("transitionend",r.onTranslateToWrapperTransitionEnd))),!0}var _f={getTranslate:hf,setTranslate:ff,minTranslate:pf,maxTranslate:mf,translateTo:gf};function vf(n,e){const t=this;t.params.cssMode||(t.wrapperEl.style.transitionDuration=`${n}ms`,t.wrapperEl.style.transitionDelay=n===0?"0ms":""),t.emit("setTransition",n,e)}function tu(n){let{swiper:e,runCallbacks:t,direction:i,step:s}=n;const{activeIndex:r,previousIndex:o}=e;let a=i;if(a||(r>o?a="next":r<o?a="prev":a="reset"),e.emit(`transition${s}`),t&&r!==o){if(a==="reset"){e.emit(`slideResetTransition${s}`);return}e.emit(`slideChangeTransition${s}`),a==="next"?e.emit(`slideNextTransition${s}`):e.emit(`slidePrevTransition${s}`)}}function xf(n,e){n===void 0&&(n=!0);const t=this,{params:i}=t;i.cssMode||(i.autoHeight&&t.updateAutoHeight(),tu({swiper:t,runCallbacks:n,direction:e,step:"Start"}))}function Sf(n,e){n===void 0&&(n=!0);const t=this,{params:i}=t;t.animating=!1,!i.cssMode&&(t.setTransition(0),tu({swiper:t,runCallbacks:n,direction:e,step:"End"}))}var yf={setTransition:vf,transitionStart:xf,transitionEnd:Sf};function Mf(n,e,t,i,s){n===void 0&&(n=0),t===void 0&&(t=!0),typeof n=="string"&&(n=parseInt(n,10));const r=this;let o=n;o<0&&(o=0);const{params:a,snapGrid:l,slidesGrid:c,previousIndex:d,activeIndex:u,rtlTranslate:h,wrapperEl:f,enabled:g}=r;if(!g&&!i&&!s||r.destroyed||r.animating&&a.preventInteractionOnTransition)return!1;typeof e>"u"&&(e=r.params.speed);const _=Math.min(r.params.slidesPerGroupSkip,o);let m=_+Math.floor((o-_)/r.params.slidesPerGroup);m>=l.length&&(m=l.length-1);const p=-l[m];if(a.normalizeSlideIndex)for(let C=0;C<c.length;C+=1){const T=-Math.floor(p*100),D=Math.floor(c[C]*100),R=Math.floor(c[C+1]*100);typeof c[C+1]<"u"?T>=D&&T<R-(R-D)/2?o=C:T>=D&&T<R&&(o=C+1):T>=D&&(o=C)}if(r.initialized&&o!==u&&(!r.allowSlideNext&&(h?p>r.translate&&p>r.minTranslate():p<r.translate&&p<r.minTranslate())||!r.allowSlidePrev&&p>r.translate&&p>r.maxTranslate()&&(u||0)!==o))return!1;o!==(d||0)&&t&&r.emit("beforeSlideChangeStart"),r.updateProgress(p);let b;o>u?b="next":o<u?b="prev":b="reset";const y=r.virtual&&r.params.virtual.enabled;if(!(y&&s)&&(h&&-p===r.translate||!h&&p===r.translate))return r.updateActiveIndex(o),a.autoHeight&&r.updateAutoHeight(),r.updateSlidesClasses(),a.effect!=="slide"&&r.setTranslate(p),b!=="reset"&&(r.transitionStart(t,b),r.transitionEnd(t,b)),!1;if(a.cssMode){const C=r.isHorizontal(),T=h?p:-p;if(e===0)y&&(r.wrapperEl.style.scrollSnapType="none",r._immediateVirtual=!0),y&&!r._cssModeVirtualInitialSet&&r.params.initialSlide>0?(r._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{f[C?"scrollLeft":"scrollTop"]=T})):f[C?"scrollLeft":"scrollTop"]=T,y&&requestAnimationFrame(()=>{r.wrapperEl.style.scrollSnapType="",r._immediateVirtual=!1});else{if(!r.support.smoothScroll)return Jd({swiper:r,targetPosition:T,side:C?"left":"top"}),!0;f.scrollTo({[C?"left":"top"]:T,behavior:"smooth"})}return!0}return r.setTransition(e),r.setTranslate(p),r.updateActiveIndex(o),r.updateSlidesClasses(),r.emit("beforeTransitionStart",e,i),r.transitionStart(t,b),e===0?r.transitionEnd(t,b):r.animating||(r.animating=!0,r.onSlideToWrapperTransitionEnd||(r.onSlideToWrapperTransitionEnd=function(T){!r||r.destroyed||T.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onSlideToWrapperTransitionEnd),r.onSlideToWrapperTransitionEnd=null,delete r.onSlideToWrapperTransitionEnd,r.transitionEnd(t,b))}),r.wrapperEl.addEventListener("transitionend",r.onSlideToWrapperTransitionEnd)),!0}function Ef(n,e,t,i){n===void 0&&(n=0),t===void 0&&(t=!0),typeof n=="string"&&(n=parseInt(n,10));const s=this;if(s.destroyed)return;typeof e>"u"&&(e=s.params.speed);const r=s.grid&&s.params.grid&&s.params.grid.rows>1;let o=n;if(s.params.loop)if(s.virtual&&s.params.virtual.enabled)o=o+s.virtual.slidesBefore;else{let a;if(r){const h=o*s.params.grid.rows;a=s.slides.filter(f=>f.getAttribute("data-swiper-slide-index")*1===h)[0].column}else a=s.getSlideIndexByData(o);const l=r?Math.ceil(s.slides.length/s.params.grid.rows):s.slides.length,{centeredSlides:c}=s.params;let d=s.params.slidesPerView;d==="auto"?d=s.slidesPerViewDynamic():(d=Math.ceil(parseFloat(s.params.slidesPerView,10)),c&&d%2===0&&(d=d+1));let u=l-a<d;if(c&&(u=u||a<Math.ceil(d/2)),i&&c&&s.params.slidesPerView!=="auto"&&!r&&(u=!1),u){const h=c?a<s.activeIndex?"prev":"next":a-s.activeIndex-1<s.params.slidesPerView?"next":"prev";s.loopFix({direction:h,slideTo:!0,activeSlideIndex:h==="next"?a+1:a-l+1,slideRealIndex:h==="next"?s.realIndex:void 0})}if(r){const h=o*s.params.grid.rows;o=s.slides.filter(f=>f.getAttribute("data-swiper-slide-index")*1===h)[0].column}else o=s.getSlideIndexByData(o)}return requestAnimationFrame(()=>{s.slideTo(o,e,t,i)}),s}function bf(n,e,t){e===void 0&&(e=!0);const i=this,{enabled:s,params:r,animating:o}=i;if(!s||i.destroyed)return i;typeof n>"u"&&(n=i.params.speed);let a=r.slidesPerGroup;r.slidesPerView==="auto"&&r.slidesPerGroup===1&&r.slidesPerGroupAuto&&(a=Math.max(i.slidesPerViewDynamic("current",!0),1));const l=i.activeIndex<r.slidesPerGroupSkip?1:a,c=i.virtual&&r.virtual.enabled;if(r.loop){if(o&&!c&&r.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&r.cssMode)return requestAnimationFrame(()=>{i.slideTo(i.activeIndex+l,n,e,t)}),!0}return r.rewind&&i.isEnd?i.slideTo(0,n,e,t):i.slideTo(i.activeIndex+l,n,e,t)}function wf(n,e,t){e===void 0&&(e=!0);const i=this,{params:s,snapGrid:r,slidesGrid:o,rtlTranslate:a,enabled:l,animating:c}=i;if(!l||i.destroyed)return i;typeof n>"u"&&(n=i.params.speed);const d=i.virtual&&s.virtual.enabled;if(s.loop){if(c&&!d&&s.loopPreventsSliding)return!1;i.loopFix({direction:"prev"}),i._clientLeft=i.wrapperEl.clientLeft}const u=a?i.translate:-i.translate;function h(p){return p<0?-Math.floor(Math.abs(p)):Math.floor(p)}const f=h(u),g=r.map(p=>h(p));let _=r[g.indexOf(f)-1];if(typeof _>"u"&&s.cssMode){let p;r.forEach((b,y)=>{f>=b&&(p=y)}),typeof p<"u"&&(_=r[p>0?p-1:p])}let m=0;if(typeof _<"u"&&(m=o.indexOf(_),m<0&&(m=i.activeIndex-1),s.slidesPerView==="auto"&&s.slidesPerGroup===1&&s.slidesPerGroupAuto&&(m=m-i.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),s.rewind&&i.isBeginning){const p=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(p,n,e,t)}else if(s.loop&&i.activeIndex===0&&s.cssMode)return requestAnimationFrame(()=>{i.slideTo(m,n,e,t)}),!0;return i.slideTo(m,n,e,t)}function Tf(n,e,t){e===void 0&&(e=!0);const i=this;if(!i.destroyed)return typeof n>"u"&&(n=i.params.speed),i.slideTo(i.activeIndex,n,e,t)}function Af(n,e,t,i){e===void 0&&(e=!0),i===void 0&&(i=.5);const s=this;if(s.destroyed)return;typeof n>"u"&&(n=s.params.speed);let r=s.activeIndex;const o=Math.min(s.params.slidesPerGroupSkip,r),a=o+Math.floor((r-o)/s.params.slidesPerGroup),l=s.rtlTranslate?s.translate:-s.translate;if(l>=s.snapGrid[a]){const c=s.snapGrid[a],d=s.snapGrid[a+1];l-c>(d-c)*i&&(r+=s.params.slidesPerGroup)}else{const c=s.snapGrid[a-1],d=s.snapGrid[a];l-c<=(d-c)*i&&(r-=s.params.slidesPerGroup)}return r=Math.max(r,0),r=Math.min(r,s.slidesGrid.length-1),s.slideTo(r,n,e,t)}function Cf(){const n=this;if(n.destroyed)return;const{params:e,slidesEl:t}=n,i=e.slidesPerView==="auto"?n.slidesPerViewDynamic():e.slidesPerView;let s=n.clickedIndex,r;const o=n.isElement?"swiper-slide":`.${e.slideClass}`;if(e.loop){if(n.animating)return;r=parseInt(n.clickedSlide.getAttribute("data-swiper-slide-index"),10),e.centeredSlides?s<n.loopedSlides-i/2||s>n.slides.length-n.loopedSlides+i/2?(n.loopFix(),s=n.getSlideIndex($n(t,`${o}[data-swiper-slide-index="${r}"]`)[0]),Ua(()=>{n.slideTo(s)})):n.slideTo(s):s>n.slides.length-i?(n.loopFix(),s=n.getSlideIndex($n(t,`${o}[data-swiper-slide-index="${r}"]`)[0]),Ua(()=>{n.slideTo(s)})):n.slideTo(s)}else n.slideTo(s)}var Rf={slideTo:Mf,slideToLoop:Ef,slideNext:bf,slidePrev:wf,slideReset:Tf,slideToClosest:Af,slideToClickedSlide:Cf};function Pf(n){const e=this,{params:t,slidesEl:i}=e;if(!t.loop||e.virtual&&e.params.virtual.enabled)return;const s=()=>{$n(i,`.${t.slideClass}, swiper-slide`).forEach((u,h)=>{u.setAttribute("data-swiper-slide-index",h)})},r=e.grid&&t.grid&&t.grid.rows>1,o=t.slidesPerGroup*(r?t.grid.rows:1),a=e.slides.length%o!==0,l=r&&e.slides.length%t.grid.rows!==0,c=d=>{for(let u=0;u<d;u+=1){const h=e.isElement?Na("swiper-slide",[t.slideBlankClass]):Na("div",[t.slideClass,t.slideBlankClass]);e.slidesEl.append(h)}};if(a){if(t.loopAddBlankSlides){const d=o-e.slides.length%o;c(d),e.recalcSlides(),e.updateSlides()}else ho("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");s()}else if(l){if(t.loopAddBlankSlides){const d=t.grid.rows-e.slides.length%t.grid.rows;c(d),e.recalcSlides(),e.updateSlides()}else ho("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");s()}else s();e.loopFix({slideRealIndex:n,direction:t.centeredSlides?void 0:"next"})}function Df(n){let{slideRealIndex:e,slideTo:t=!0,direction:i,setTranslate:s,activeSlideIndex:r,byController:o,byMousewheel:a}=n===void 0?{}:n;const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:c,allowSlidePrev:d,allowSlideNext:u,slidesEl:h,params:f}=l,{centeredSlides:g}=f;if(l.allowSlidePrev=!0,l.allowSlideNext=!0,l.virtual&&f.virtual.enabled){t&&(!f.centeredSlides&&l.snapIndex===0?l.slideTo(l.virtual.slides.length,0,!1,!0):f.centeredSlides&&l.snapIndex<f.slidesPerView?l.slideTo(l.virtual.slides.length+l.snapIndex,0,!1,!0):l.snapIndex===l.snapGrid.length-1&&l.slideTo(l.virtual.slidesBefore,0,!1,!0)),l.allowSlidePrev=d,l.allowSlideNext=u,l.emit("loopFix");return}let _=f.slidesPerView;_==="auto"?_=l.slidesPerViewDynamic():(_=Math.ceil(parseFloat(f.slidesPerView,10)),g&&_%2===0&&(_=_+1));const m=f.slidesPerGroupAuto?_:f.slidesPerGroup;let p=m;p%m!==0&&(p+=m-p%m),p+=f.loopAdditionalSlides,l.loopedSlides=p;const b=l.grid&&f.grid&&f.grid.rows>1;c.length<_+p?ho("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):b&&f.grid.fill==="row"&&ho("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const y=[],S=[];let C=l.activeIndex;typeof r>"u"?r=l.getSlideIndex(c.filter(L=>L.classList.contains(f.slideActiveClass))[0]):C=r;const T=i==="next"||!i,D=i==="prev"||!i;let R=0,E=0;const v=b?Math.ceil(c.length/f.grid.rows):c.length,O=(b?c[r].column:r)+(g&&typeof s>"u"?-_/2+.5:0);if(O<p){R=Math.max(p-O,m);for(let L=0;L<p-O;L+=1){const k=L-Math.floor(L/v)*v;if(b){const X=v-k-1;for(let B=c.length-1;B>=0;B-=1)c[B].column===X&&y.push(B)}else y.push(v-k-1)}}else if(O+_>v-p){E=Math.max(O-(v-p*2),m);for(let L=0;L<E;L+=1){const k=L-Math.floor(L/v)*v;b?c.forEach((X,B)=>{X.column===k&&S.push(B)}):S.push(k)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),D&&y.forEach(L=>{c[L].swiperLoopMoveDOM=!0,h.prepend(c[L]),c[L].swiperLoopMoveDOM=!1}),T&&S.forEach(L=>{c[L].swiperLoopMoveDOM=!0,h.append(c[L]),c[L].swiperLoopMoveDOM=!1}),l.recalcSlides(),f.slidesPerView==="auto"?l.updateSlides():b&&(y.length>0&&D||S.length>0&&T)&&l.slides.forEach((L,k)=>{l.grid.updateSlide(k,L,l.slides)}),f.watchSlidesProgress&&l.updateSlidesOffset(),t){if(y.length>0&&D){if(typeof e>"u"){const L=l.slidesGrid[C],X=l.slidesGrid[C+R]-L;a?l.setTranslate(l.translate-X):(l.slideTo(C+Math.ceil(R),0,!1,!0),s&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-X,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-X))}else if(s){const L=b?y.length/f.grid.rows:y.length;l.slideTo(l.activeIndex+L,0,!1,!0),l.touchEventsData.currentTranslate=l.translate}}else if(S.length>0&&T)if(typeof e>"u"){const L=l.slidesGrid[C],X=l.slidesGrid[C-E]-L;a?l.setTranslate(l.translate-X):(l.slideTo(C-E,0,!1,!0),s&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-X,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-X))}else{const L=b?S.length/f.grid.rows:S.length;l.slideTo(l.activeIndex-L,0,!1,!0)}}if(l.allowSlidePrev=d,l.allowSlideNext=u,l.controller&&l.controller.control&&!o){const L={slideRealIndex:e,direction:i,setTranslate:s,activeSlideIndex:r,byController:!0};Array.isArray(l.controller.control)?l.controller.control.forEach(k=>{!k.destroyed&&k.params.loop&&k.loopFix({...L,slideTo:k.params.slidesPerView===f.slidesPerView?t:!1})}):l.controller.control instanceof l.constructor&&l.controller.control.params.loop&&l.controller.control.loopFix({...L,slideTo:l.controller.control.params.slidesPerView===f.slidesPerView?t:!1})}l.emit("loopFix")}function Lf(){const n=this,{params:e,slidesEl:t}=n;if(!e.loop||n.virtual&&n.params.virtual.enabled)return;n.recalcSlides();const i=[];n.slides.forEach(s=>{const r=typeof s.swiperSlideIndex>"u"?s.getAttribute("data-swiper-slide-index")*1:s.swiperSlideIndex;i[r]=s}),n.slides.forEach(s=>{s.removeAttribute("data-swiper-slide-index")}),i.forEach(s=>{t.append(s)}),n.recalcSlides(),n.slideTo(n.realIndex,0)}var If={loopCreate:Pf,loopFix:Df,loopDestroy:Lf};function Uf(n){const e=this;if(!e.params.simulateTouch||e.params.watchOverflow&&e.isLocked||e.params.cssMode)return;const t=e.params.touchEventsTarget==="container"?e.el:e.wrapperEl;e.isElement&&(e.__preventObserver__=!0),t.style.cursor="move",t.style.cursor=n?"grabbing":"grab",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1})}function Nf(){const n=this;n.params.watchOverflow&&n.isLocked||n.params.cssMode||(n.isElement&&(n.__preventObserver__=!0),n[n.params.touchEventsTarget==="container"?"el":"wrapperEl"].style.cursor="",n.isElement&&requestAnimationFrame(()=>{n.__preventObserver__=!1}))}var Of={setGrabCursor:Uf,unsetGrabCursor:Nf};function Ff(n,e){e===void 0&&(e=this);function t(i){if(!i||i===Rs()||i===dn())return null;i.assignedSlot&&(i=i.assignedSlot);const s=i.closest(n);return!s&&!i.getRootNode?null:s||t(i.getRootNode().host)}return t(e)}function hc(n,e,t){const i=dn(),{params:s}=n,r=s.edgeSwipeDetection,o=s.edgeSwipeThreshold;return r&&(t<=o||t>=i.innerWidth-o)?r==="prevent"?(e.preventDefault(),!0):!1:!0}function Bf(n){const e=this,t=Rs();let i=n;i.originalEvent&&(i=i.originalEvent);const s=e.touchEventsData;if(i.type==="pointerdown"){if(s.pointerId!==null&&s.pointerId!==i.pointerId)return;s.pointerId=i.pointerId}else i.type==="touchstart"&&i.targetTouches.length===1&&(s.touchId=i.targetTouches[0].identifier);if(i.type==="touchstart"){hc(e,i,i.targetTouches[0].pageX);return}const{params:r,touches:o,enabled:a}=e;if(!a||!r.simulateTouch&&i.pointerType==="mouse"||e.animating&&r.preventInteractionOnTransition)return;!e.animating&&r.cssMode&&r.loop&&e.loopFix();let l=i.target;if(r.touchEventsTarget==="wrapper"&&!Vh(l,e.wrapperEl)||"which"in i&&i.which===3||"button"in i&&i.button>0||s.isTouched&&s.isMoved)return;const c=!!r.noSwipingClass&&r.noSwipingClass!=="",d=i.composedPath?i.composedPath():i.path;c&&i.target&&i.target.shadowRoot&&d&&(l=d[0]);const u=r.noSwipingSelector?r.noSwipingSelector:`.${r.noSwipingClass}`,h=!!(i.target&&i.target.shadowRoot);if(r.noSwiping&&(h?Ff(u,l):l.closest(u))){e.allowClick=!0;return}if(r.swipeHandler&&!l.closest(r.swipeHandler))return;o.currentX=i.pageX,o.currentY=i.pageY;const f=o.currentX,g=o.currentY;if(!hc(e,i,f))return;Object.assign(s,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=f,o.startY=g,s.touchStartTime=uo(),e.allowClick=!0,e.updateSize(),e.swipeDirection=void 0,r.threshold>0&&(s.allowThresholdMove=!1);let _=!0;l.matches(s.focusableElements)&&(_=!1,l.nodeName==="SELECT"&&(s.isTouched=!1)),t.activeElement&&t.activeElement.matches(s.focusableElements)&&t.activeElement!==l&&(i.pointerType==="mouse"||i.pointerType!=="mouse"&&!l.matches(s.focusableElements))&&t.activeElement.blur();const m=_&&e.allowTouchMove&&r.touchStartPreventDefault;(r.touchStartForcePreventDefault||m)&&!l.isContentEditable&&i.preventDefault(),r.freeMode&&r.freeMode.enabled&&e.freeMode&&e.animating&&!r.cssMode&&e.freeMode.onTouchStart(),e.emit("touchStart",i)}function zf(n){const e=Rs(),t=this,i=t.touchEventsData,{params:s,touches:r,rtlTranslate:o,enabled:a}=t;if(!a||!s.simulateTouch&&n.pointerType==="mouse")return;let l=n;if(l.originalEvent&&(l=l.originalEvent),l.type==="pointermove"&&(i.touchId!==null||l.pointerId!==i.pointerId))return;let c;if(l.type==="touchmove"){if(c=[...l.changedTouches].filter(T=>T.identifier===i.touchId)[0],!c||c.identifier!==i.touchId)return}else c=l;if(!i.isTouched){i.startMoving&&i.isScrolling&&t.emit("touchMoveOpposite",l);return}const d=c.pageX,u=c.pageY;if(l.preventedByNestedSwiper){r.startX=d,r.startY=u;return}if(!t.allowTouchMove){l.target.matches(i.focusableElements)||(t.allowClick=!1),i.isTouched&&(Object.assign(r,{startX:d,startY:u,currentX:d,currentY:u}),i.touchStartTime=uo());return}if(s.touchReleaseOnEdges&&!s.loop){if(t.isVertical()){if(u<r.startY&&t.translate<=t.maxTranslate()||u>r.startY&&t.translate>=t.minTranslate()){i.isTouched=!1,i.isMoved=!1;return}}else if(d<r.startX&&t.translate<=t.maxTranslate()||d>r.startX&&t.translate>=t.minTranslate())return}if(e.activeElement&&e.activeElement.matches(i.focusableElements)&&e.activeElement!==l.target&&l.pointerType!=="mouse"&&e.activeElement.blur(),e.activeElement&&l.target===e.activeElement&&l.target.matches(i.focusableElements)){i.isMoved=!0,t.allowClick=!1;return}i.allowTouchCallbacks&&t.emit("touchMove",l),r.previousX=r.currentX,r.previousY=r.currentY,r.currentX=d,r.currentY=u;const h=r.currentX-r.startX,f=r.currentY-r.startY;if(t.params.threshold&&Math.sqrt(h**2+f**2)<t.params.threshold)return;if(typeof i.isScrolling>"u"){let T;t.isHorizontal()&&r.currentY===r.startY||t.isVertical()&&r.currentX===r.startX?i.isScrolling=!1:h*h+f*f>=25&&(T=Math.atan2(Math.abs(f),Math.abs(h))*180/Math.PI,i.isScrolling=t.isHorizontal()?T>s.touchAngle:90-T>s.touchAngle)}if(i.isScrolling&&t.emit("touchMoveOpposite",l),typeof i.startMoving>"u"&&(r.currentX!==r.startX||r.currentY!==r.startY)&&(i.startMoving=!0),i.isScrolling||l.type==="touchmove"&&i.preventTouchMoveFromPointerMove){i.isTouched=!1;return}if(!i.startMoving)return;t.allowClick=!1,!s.cssMode&&l.cancelable&&l.preventDefault(),s.touchMoveStopPropagation&&!s.nested&&l.stopPropagation();let g=t.isHorizontal()?h:f,_=t.isHorizontal()?r.currentX-r.previousX:r.currentY-r.previousY;s.oneWayMovement&&(g=Math.abs(g)*(o?1:-1),_=Math.abs(_)*(o?1:-1)),r.diff=g,g*=s.touchRatio,o&&(g=-g,_=-_);const m=t.touchesDirection;t.swipeDirection=g>0?"prev":"next",t.touchesDirection=_>0?"prev":"next";const p=t.params.loop&&!s.cssMode,b=t.touchesDirection==="next"&&t.allowSlideNext||t.touchesDirection==="prev"&&t.allowSlidePrev;if(!i.isMoved){if(p&&b&&t.loopFix({direction:t.swipeDirection}),i.startTranslate=t.getTranslate(),t.setTransition(0),t.animating){const T=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});t.wrapperEl.dispatchEvent(T)}i.allowMomentumBounce=!1,s.grabCursor&&(t.allowSlideNext===!0||t.allowSlidePrev===!0)&&t.setGrabCursor(!0),t.emit("sliderFirstMove",l)}let y;if(new Date().getTime(),i.isMoved&&i.allowThresholdMove&&m!==t.touchesDirection&&p&&b&&Math.abs(g)>=1){Object.assign(r,{startX:d,startY:u,currentX:d,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,i.startTranslate=i.currentTranslate;return}t.emit("sliderMove",l),i.isMoved=!0,i.currentTranslate=g+i.startTranslate;let S=!0,C=s.resistanceRatio;if(s.touchReleaseOnEdges&&(C=0),g>0?(p&&b&&!y&&i.allowThresholdMove&&i.currentTranslate>(s.centeredSlides?t.minTranslate()-t.slidesSizesGrid[t.activeIndex+1]-(s.slidesPerView!=="auto"&&t.slides.length-s.slidesPerView>=2?t.slidesSizesGrid[t.activeIndex+1]+t.params.spaceBetween:0)-t.params.spaceBetween:t.minTranslate())&&t.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),i.currentTranslate>t.minTranslate()&&(S=!1,s.resistance&&(i.currentTranslate=t.minTranslate()-1+(-t.minTranslate()+i.startTranslate+g)**C))):g<0&&(p&&b&&!y&&i.allowThresholdMove&&i.currentTranslate<(s.centeredSlides?t.maxTranslate()+t.slidesSizesGrid[t.slidesSizesGrid.length-1]+t.params.spaceBetween+(s.slidesPerView!=="auto"&&t.slides.length-s.slidesPerView>=2?t.slidesSizesGrid[t.slidesSizesGrid.length-1]+t.params.spaceBetween:0):t.maxTranslate())&&t.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:t.slides.length-(s.slidesPerView==="auto"?t.slidesPerViewDynamic():Math.ceil(parseFloat(s.slidesPerView,10)))}),i.currentTranslate<t.maxTranslate()&&(S=!1,s.resistance&&(i.currentTranslate=t.maxTranslate()+1-(t.maxTranslate()-i.startTranslate-g)**C))),S&&(l.preventedByNestedSwiper=!0),!t.allowSlideNext&&t.swipeDirection==="next"&&i.currentTranslate<i.startTranslate&&(i.currentTranslate=i.startTranslate),!t.allowSlidePrev&&t.swipeDirection==="prev"&&i.currentTranslate>i.startTranslate&&(i.currentTranslate=i.startTranslate),!t.allowSlidePrev&&!t.allowSlideNext&&(i.currentTranslate=i.startTranslate),s.threshold>0)if(Math.abs(g)>s.threshold||i.allowThresholdMove){if(!i.allowThresholdMove){i.allowThresholdMove=!0,r.startX=r.currentX,r.startY=r.currentY,i.currentTranslate=i.startTranslate,r.diff=t.isHorizontal()?r.currentX-r.startX:r.currentY-r.startY;return}}else{i.currentTranslate=i.startTranslate;return}!s.followFinger||s.cssMode||((s.freeMode&&s.freeMode.enabled&&t.freeMode||s.watchSlidesProgress)&&(t.updateActiveIndex(),t.updateSlidesClasses()),s.freeMode&&s.freeMode.enabled&&t.freeMode&&t.freeMode.onTouchMove(),t.updateProgress(i.currentTranslate),t.setTranslate(i.currentTranslate))}function kf(n){const e=this,t=e.touchEventsData;let i=n;i.originalEvent&&(i=i.originalEvent);let s;if(i.type==="touchend"||i.type==="touchcancel"){if(s=[...i.changedTouches].filter(C=>C.identifier===t.touchId)[0],!s||s.identifier!==t.touchId)return}else{if(t.touchId!==null||i.pointerId!==t.pointerId)return;s=i}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(i.type)&&!(["pointercancel","contextmenu"].includes(i.type)&&(e.browser.isSafari||e.browser.isWebView)))return;t.pointerId=null,t.touchId=null;const{params:o,touches:a,rtlTranslate:l,slidesGrid:c,enabled:d}=e;if(!d||!o.simulateTouch&&i.pointerType==="mouse")return;if(t.allowTouchCallbacks&&e.emit("touchEnd",i),t.allowTouchCallbacks=!1,!t.isTouched){t.isMoved&&o.grabCursor&&e.setGrabCursor(!1),t.isMoved=!1,t.startMoving=!1;return}o.grabCursor&&t.isMoved&&t.isTouched&&(e.allowSlideNext===!0||e.allowSlidePrev===!0)&&e.setGrabCursor(!1);const u=uo(),h=u-t.touchStartTime;if(e.allowClick){const C=i.path||i.composedPath&&i.composedPath();e.updateClickedSlide(C&&C[0]||i.target,C),e.emit("tap click",i),h<300&&u-t.lastClickTime<300&&e.emit("doubleTap doubleClick",i)}if(t.lastClickTime=uo(),Ua(()=>{e.destroyed||(e.allowClick=!0)}),!t.isTouched||!t.isMoved||!e.swipeDirection||a.diff===0&&!t.loopSwapReset||t.currentTranslate===t.startTranslate&&!t.loopSwapReset){t.isTouched=!1,t.isMoved=!1,t.startMoving=!1;return}t.isTouched=!1,t.isMoved=!1,t.startMoving=!1;let f;if(o.followFinger?f=l?e.translate:-e.translate:f=-t.currentTranslate,o.cssMode)return;if(o.freeMode&&o.freeMode.enabled){e.freeMode.onTouchEnd({currentPos:f});return}const g=f>=-e.maxTranslate()&&!e.params.loop;let _=0,m=e.slidesSizesGrid[0];for(let C=0;C<c.length;C+=C<o.slidesPerGroupSkip?1:o.slidesPerGroup){const T=C<o.slidesPerGroupSkip-1?1:o.slidesPerGroup;typeof c[C+T]<"u"?(g||f>=c[C]&&f<c[C+T])&&(_=C,m=c[C+T]-c[C]):(g||f>=c[C])&&(_=C,m=c[c.length-1]-c[c.length-2])}let p=null,b=null;o.rewind&&(e.isBeginning?b=o.virtual&&o.virtual.enabled&&e.virtual?e.virtual.slides.length-1:e.slides.length-1:e.isEnd&&(p=0));const y=(f-c[_])/m,S=_<o.slidesPerGroupSkip-1?1:o.slidesPerGroup;if(h>o.longSwipesMs){if(!o.longSwipes){e.slideTo(e.activeIndex);return}e.swipeDirection==="next"&&(y>=o.longSwipesRatio?e.slideTo(o.rewind&&e.isEnd?p:_+S):e.slideTo(_)),e.swipeDirection==="prev"&&(y>1-o.longSwipesRatio?e.slideTo(_+S):b!==null&&y<0&&Math.abs(y)>o.longSwipesRatio?e.slideTo(b):e.slideTo(_))}else{if(!o.shortSwipes){e.slideTo(e.activeIndex);return}e.navigation&&(i.target===e.navigation.nextEl||i.target===e.navigation.prevEl)?i.target===e.navigation.nextEl?e.slideTo(_+S):e.slideTo(_):(e.swipeDirection==="next"&&e.slideTo(p!==null?p:_+S),e.swipeDirection==="prev"&&e.slideTo(b!==null?b:_))}}function fc(){const n=this,{params:e,el:t}=n;if(t&&t.offsetWidth===0)return;e.breakpoints&&n.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:s,snapGrid:r}=n,o=n.virtual&&n.params.virtual.enabled;n.allowSlideNext=!0,n.allowSlidePrev=!0,n.updateSize(),n.updateSlides(),n.updateSlidesClasses();const a=o&&e.loop;(e.slidesPerView==="auto"||e.slidesPerView>1)&&n.isEnd&&!n.isBeginning&&!n.params.centeredSlides&&!a?n.slideTo(n.slides.length-1,0,!1,!0):n.params.loop&&!o?n.slideToLoop(n.realIndex,0,!1,!0):n.slideTo(n.activeIndex,0,!1,!0),n.autoplay&&n.autoplay.running&&n.autoplay.paused&&(clearTimeout(n.autoplay.resizeTimeout),n.autoplay.resizeTimeout=setTimeout(()=>{n.autoplay&&n.autoplay.running&&n.autoplay.paused&&n.autoplay.resume()},500)),n.allowSlidePrev=s,n.allowSlideNext=i,n.params.watchOverflow&&r!==n.snapGrid&&n.checkOverflow()}function Hf(n){const e=this;e.enabled&&(e.allowClick||(e.params.preventClicks&&n.preventDefault(),e.params.preventClicksPropagation&&e.animating&&(n.stopPropagation(),n.stopImmediatePropagation())))}function Gf(){const n=this,{wrapperEl:e,rtlTranslate:t,enabled:i}=n;if(!i)return;n.previousTranslate=n.translate,n.isHorizontal()?n.translate=-e.scrollLeft:n.translate=-e.scrollTop,n.translate===0&&(n.translate=0),n.updateActiveIndex(),n.updateSlidesClasses();let s;const r=n.maxTranslate()-n.minTranslate();r===0?s=0:s=(n.translate-n.minTranslate())/r,s!==n.progress&&n.updateProgress(t?-n.translate:n.translate),n.emit("setTranslate",n.translate,!1)}function Vf(n){const e=this;Kr(e,n.target),!(e.params.cssMode||e.params.slidesPerView!=="auto"&&!e.params.autoHeight)&&e.update()}function Wf(){const n=this;n.documentTouchHandlerProceeded||(n.documentTouchHandlerProceeded=!0,n.params.touchReleaseOnEdges&&(n.el.style.touchAction="auto"))}const nu=(n,e)=>{const t=Rs(),{params:i,el:s,wrapperEl:r,device:o}=n,a=!!i.nested,l=e==="on"?"addEventListener":"removeEventListener",c=e;!s||typeof s=="string"||(t[l]("touchstart",n.onDocumentTouchStart,{passive:!1,capture:a}),s[l]("touchstart",n.onTouchStart,{passive:!1}),s[l]("pointerdown",n.onTouchStart,{passive:!1}),t[l]("touchmove",n.onTouchMove,{passive:!1,capture:a}),t[l]("pointermove",n.onTouchMove,{passive:!1,capture:a}),t[l]("touchend",n.onTouchEnd,{passive:!0}),t[l]("pointerup",n.onTouchEnd,{passive:!0}),t[l]("pointercancel",n.onTouchEnd,{passive:!0}),t[l]("touchcancel",n.onTouchEnd,{passive:!0}),t[l]("pointerout",n.onTouchEnd,{passive:!0}),t[l]("pointerleave",n.onTouchEnd,{passive:!0}),t[l]("contextmenu",n.onTouchEnd,{passive:!0}),(i.preventClicks||i.preventClicksPropagation)&&s[l]("click",n.onClick,!0),i.cssMode&&r[l]("scroll",n.onScroll),i.updateOnWindowResize?n[c](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",fc,!0):n[c]("observerUpdate",fc,!0),s[l]("load",n.onLoad,{capture:!0}))};function Xf(){const n=this,{params:e}=n;n.onTouchStart=Bf.bind(n),n.onTouchMove=zf.bind(n),n.onTouchEnd=kf.bind(n),n.onDocumentTouchStart=Wf.bind(n),e.cssMode&&(n.onScroll=Gf.bind(n)),n.onClick=Hf.bind(n),n.onLoad=Vf.bind(n),nu(n,"on")}function Yf(){nu(this,"off")}var qf={attachEvents:Xf,detachEvents:Yf};const pc=(n,e)=>n.grid&&e.grid&&e.grid.rows>1;function jf(){const n=this,{realIndex:e,initialized:t,params:i,el:s}=n,r=i.breakpoints;if(!r||r&&Object.keys(r).length===0)return;const o=n.getBreakpoint(r,n.params.breakpointsBase,n.el);if(!o||n.currentBreakpoint===o)return;const l=(o in r?r[o]:void 0)||n.originalParams,c=pc(n,i),d=pc(n,l),u=n.params.grabCursor,h=l.grabCursor,f=i.enabled;c&&!d?(s.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),n.emitContainerClasses()):!c&&d&&(s.classList.add(`${i.containerModifierClass}grid`),(l.grid.fill&&l.grid.fill==="column"||!l.grid.fill&&i.grid.fill==="column")&&s.classList.add(`${i.containerModifierClass}grid-column`),n.emitContainerClasses()),u&&!h?n.unsetGrabCursor():!u&&h&&n.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(y=>{if(typeof l[y]>"u")return;const S=i[y]&&i[y].enabled,C=l[y]&&l[y].enabled;S&&!C&&n[y].disable(),!S&&C&&n[y].enable()});const g=l.direction&&l.direction!==i.direction,_=i.loop&&(l.slidesPerView!==i.slidesPerView||g),m=i.loop;g&&t&&n.changeDirection(),ln(n.params,l);const p=n.params.enabled,b=n.params.loop;Object.assign(n,{allowTouchMove:n.params.allowTouchMove,allowSlideNext:n.params.allowSlideNext,allowSlidePrev:n.params.allowSlidePrev}),f&&!p?n.disable():!f&&p&&n.enable(),n.currentBreakpoint=o,n.emit("_beforeBreakpoint",l),t&&(_?(n.loopDestroy(),n.loopCreate(e),n.updateSlides()):!m&&b?(n.loopCreate(e),n.updateSlides()):m&&!b&&n.loopDestroy()),n.emit("breakpoint",l)}function $f(n,e,t){if(e===void 0&&(e="window"),!n||e==="container"&&!t)return;let i=!1;const s=dn(),r=e==="window"?s.innerHeight:t.clientHeight,o=Object.keys(n).map(a=>{if(typeof a=="string"&&a.indexOf("@")===0){const l=parseFloat(a.substr(1));return{value:r*l,point:a}}return{value:a,point:a}});o.sort((a,l)=>parseInt(a.value,10)-parseInt(l.value,10));for(let a=0;a<o.length;a+=1){const{point:l,value:c}=o[a];e==="window"?s.matchMedia(`(min-width: ${c}px)`).matches&&(i=l):c<=t.clientWidth&&(i=l)}return i||"max"}var Zf={setBreakpoint:jf,getBreakpoint:$f};function Kf(n,e){const t=[];return n.forEach(i=>{typeof i=="object"?Object.keys(i).forEach(s=>{i[s]&&t.push(e+s)}):typeof i=="string"&&t.push(e+i)}),t}function Jf(){const n=this,{classNames:e,params:t,rtl:i,el:s,device:r}=n,o=Kf(["initialized",t.direction,{"free-mode":n.params.freeMode&&t.freeMode.enabled},{autoheight:t.autoHeight},{rtl:i},{grid:t.grid&&t.grid.rows>1},{"grid-column":t.grid&&t.grid.rows>1&&t.grid.fill==="column"},{android:r.android},{ios:r.ios},{"css-mode":t.cssMode},{centered:t.cssMode&&t.centeredSlides},{"watch-progress":t.watchSlidesProgress}],t.containerModifierClass);e.push(...o),s.classList.add(...e),n.emitContainerClasses()}function Qf(){const n=this,{el:e,classNames:t}=n;!e||typeof e=="string"||(e.classList.remove(...t),n.emitContainerClasses())}var ep={addClasses:Jf,removeClasses:Qf};function tp(){const n=this,{isLocked:e,params:t}=n,{slidesOffsetBefore:i}=t;if(i){const s=n.slides.length-1,r=n.slidesGrid[s]+n.slidesSizesGrid[s]+i*2;n.isLocked=n.size>r}else n.isLocked=n.snapGrid.length===1;t.allowSlideNext===!0&&(n.allowSlideNext=!n.isLocked),t.allowSlidePrev===!0&&(n.allowSlidePrev=!n.isLocked),e&&e!==n.isLocked&&(n.isEnd=!1),e!==n.isLocked&&n.emit(n.isLocked?"lock":"unlock")}var np={checkOverflow:tp},mc={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function ip(n,e){return function(i){i===void 0&&(i={});const s=Object.keys(i)[0],r=i[s];if(typeof r!="object"||r===null){ln(e,i);return}if(n[s]===!0&&(n[s]={enabled:!0}),s==="navigation"&&n[s]&&n[s].enabled&&!n[s].prevEl&&!n[s].nextEl&&(n[s].auto=!0),["pagination","scrollbar"].indexOf(s)>=0&&n[s]&&n[s].enabled&&!n[s].el&&(n[s].auto=!0),!(s in n&&"enabled"in r)){ln(e,i);return}typeof n[s]=="object"&&!("enabled"in n[s])&&(n[s].enabled=!0),n[s]||(n[s]={enabled:!1}),ln(e,i)}}const Fo={eventsEmitter:Qh,update:uf,translate:_f,transition:yf,slide:Rf,loop:If,grabCursor:Of,events:qf,breakpoints:Zf,checkOverflow:np,classes:ep},Bo={};class Cn{constructor(){let e,t;for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];s.length===1&&s[0].constructor&&Object.prototype.toString.call(s[0]).slice(8,-1)==="Object"?t=s[0]:[e,t]=s,t||(t={}),t=ln({},t),e&&!t.el&&(t.el=e);const o=Rs();if(t.el&&typeof t.el=="string"&&o.querySelectorAll(t.el).length>1){const d=[];return o.querySelectorAll(t.el).forEach(u=>{const h=ln({},t,{el:u});d.push(new Cn(h))}),d}const a=this;a.__swiper__=!0,a.support=Qd(),a.device=eu({userAgent:t.userAgent}),a.browser=Zh(),a.eventsListeners={},a.eventsAnyListeners=[],a.modules=[...a.__modules__],t.modules&&Array.isArray(t.modules)&&a.modules.push(...t.modules);const l={};a.modules.forEach(d=>{d({params:t,swiper:a,extendParams:ip(t,l),on:a.on.bind(a),once:a.once.bind(a),off:a.off.bind(a),emit:a.emit.bind(a)})});const c=ln({},mc,l);return a.params=ln({},c,Bo,t),a.originalParams=ln({},a.params),a.passedParams=ln({},t),a.params&&a.params.on&&Object.keys(a.params.on).forEach(d=>{a.on(d,a.params.on[d])}),a.params&&a.params.onAny&&a.onAny(a.params.onAny),Object.assign(a,{enabled:a.params.enabled,el:e,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal(){return a.params.direction==="horizontal"},isVertical(){return a.params.direction==="vertical"},activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:a.params.allowSlideNext,allowSlidePrev:a.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:a.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:a.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),a.emit("_swiper"),a.params.init&&a.init(),a}getDirectionLabel(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}getSlideIndex(e){const{slidesEl:t,params:i}=this,s=$n(t,`.${i.slideClass}, swiper-slide`),r=cc(s[0]);return cc(e)-r}getSlideIndexByData(e){return this.getSlideIndex(this.slides.filter(t=>t.getAttribute("data-swiper-slide-index")*1===e)[0])}recalcSlides(){const e=this,{slidesEl:t,params:i}=e;e.slides=$n(t,`.${i.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const i=this;e=Math.min(Math.max(e,0),1);const s=i.minTranslate(),o=(i.maxTranslate()-s)*e+s;i.translateTo(o,typeof t>"u"?0:t),i.updateActiveIndex(),i.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter(i=>i.indexOf("swiper")===0||i.indexOf(e.params.containerModifierClass)===0);e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter(i=>i.indexOf("swiper-slide")===0||i.indexOf(t.params.slideClass)===0).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach(i=>{const s=e.getSlideClasses(i);t.push({slideEl:i,classNames:s}),e.emit("_slideClass",i,s)}),e.emit("_slideClasses",t)}slidesPerViewDynamic(e,t){e===void 0&&(e="current"),t===void 0&&(t=!1);const i=this,{params:s,slides:r,slidesGrid:o,slidesSizesGrid:a,size:l,activeIndex:c}=i;let d=1;if(typeof s.slidesPerView=="number")return s.slidesPerView;if(s.centeredSlides){let u=r[c]?Math.ceil(r[c].swiperSlideSize):0,h;for(let f=c+1;f<r.length;f+=1)r[f]&&!h&&(u+=Math.ceil(r[f].swiperSlideSize),d+=1,u>l&&(h=!0));for(let f=c-1;f>=0;f-=1)r[f]&&!h&&(u+=r[f].swiperSlideSize,d+=1,u>l&&(h=!0))}else if(e==="current")for(let u=c+1;u<r.length;u+=1)(t?o[u]+a[u]-o[c]<l:o[u]-o[c]<l)&&(d+=1);else for(let u=c-1;u>=0;u-=1)o[c]-o[u]<l&&(d+=1);return d}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:i}=e;i.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(o=>{o.complete&&Kr(e,o)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses();function s(){const o=e.rtlTranslate?e.translate*-1:e.translate,a=Math.min(Math.max(o,e.maxTranslate()),e.minTranslate());e.setTranslate(a),e.updateActiveIndex(),e.updateSlidesClasses()}let r;if(i.freeMode&&i.freeMode.enabled&&!i.cssMode)s(),i.autoHeight&&e.updateAutoHeight();else{if((i.slidesPerView==="auto"||i.slidesPerView>1)&&e.isEnd&&!i.centeredSlides){const o=e.virtual&&i.virtual.enabled?e.virtual.slides:e.slides;r=e.slideTo(o.length-1,0,!1,!0)}else r=e.slideTo(e.activeIndex,0,!1,!0);r||s()}i.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t){t===void 0&&(t=!0);const i=this,s=i.params.direction;return e||(e=s==="horizontal"?"vertical":"horizontal"),e===s||e!=="horizontal"&&e!=="vertical"||(i.el.classList.remove(`${i.params.containerModifierClass}${s}`),i.el.classList.add(`${i.params.containerModifierClass}${e}`),i.emitContainerClasses(),i.params.direction=e,i.slides.forEach(r=>{e==="vertical"?r.style.width="":r.style.height=""}),i.emit("changeDirection"),t&&i.update()),i}changeLanguageDirection(e){const t=this;t.rtl&&e==="rtl"||!t.rtl&&e==="ltr"||(t.rtl=e==="rtl",t.rtlTranslate=t.params.direction==="horizontal"&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}mount(e){const t=this;if(t.mounted)return!0;let i=e||t.params.el;if(typeof i=="string"&&(i=document.querySelector(i)),!i)return!1;i.swiper=t,i.parentNode&&i.parentNode.host&&i.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);const s=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let o=(()=>i&&i.shadowRoot&&i.shadowRoot.querySelector?i.shadowRoot.querySelector(s()):$n(i,s())[0])();return!o&&t.params.createElements&&(o=Na("div",t.params.wrapperClass),i.append(o),$n(i,`.${t.params.slideClass}`).forEach(a=>{o.append(a)})),Object.assign(t,{el:i,wrapperEl:o,slidesEl:t.isElement&&!i.parentNode.host.slideSlots?i.parentNode.host:o,hostEl:t.isElement?i.parentNode.host:i,mounted:!0,rtl:i.dir.toLowerCase()==="rtl"||gi(i,"direction")==="rtl",rtlTranslate:t.params.direction==="horizontal"&&(i.dir.toLowerCase()==="rtl"||gi(i,"direction")==="rtl"),wrongRTL:gi(o,"display")==="-webkit-box"}),!0}init(e){const t=this;if(t.initialized||t.mount(e)===!1)return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(),t.attachEvents();const s=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&s.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),s.forEach(r=>{r.complete?Kr(t,r):r.addEventListener("load",o=>{Kr(t,o.target)})}),Oa(t),t.initialized=!0,Oa(t),t.emit("init"),t.emit("afterInit"),t}destroy(e,t){e===void 0&&(e=!0),t===void 0&&(t=!0);const i=this,{params:s,el:r,wrapperEl:o,slides:a}=i;return typeof i.params>"u"||i.destroyed||(i.emit("beforeDestroy"),i.initialized=!1,i.detachEvents(),s.loop&&i.loopDestroy(),t&&(i.removeClasses(),r&&typeof r!="string"&&r.removeAttribute("style"),o&&o.removeAttribute("style"),a&&a.length&&a.forEach(l=>{l.classList.remove(s.slideVisibleClass,s.slideFullyVisibleClass,s.slideActiveClass,s.slideNextClass,s.slidePrevClass),l.removeAttribute("style"),l.removeAttribute("data-swiper-slide-index")})),i.emit("destroy"),Object.keys(i.eventsListeners).forEach(l=>{i.off(l)}),e!==!1&&(i.el&&typeof i.el!="string"&&(i.el.swiper=null),zh(i)),i.destroyed=!0),null}static extendDefaults(e){ln(Bo,e)}static get extendedDefaults(){return Bo}static get defaults(){return mc}static installModule(e){Cn.prototype.__modules__||(Cn.prototype.__modules__=[]);const t=Cn.prototype.__modules__;typeof e=="function"&&t.indexOf(e)<0&&t.push(e)}static use(e){return Array.isArray(e)?(e.forEach(t=>Cn.installModule(t)),Cn):(Cn.installModule(e),Cn)}}Object.keys(Fo).forEach(n=>{Object.keys(Fo[n]).forEach(e=>{Cn.prototype[e]=Fo[n][e]})});Cn.use([Kh,Jh]);/**
  2. * @license
  3. * Copyright 2010-2024 Three.js Authors
  4. * SPDX-License-Identifier: MIT
  5. */const Ul="171",Xt={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},us={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},sp=0,gc=1,rp=2,iu=1,op=2,qn=3,Mi=0,en=1,jn=2,Si=0,gs=1,_c=2,vc=3,xc=4,ap=5,Ni=100,lp=101,cp=102,dp=103,up=104,hp=200,fp=201,pp=202,mp=203,Fa=204,Ba=205,gp=206,_p=207,vp=208,xp=209,Sp=210,yp=211,Mp=212,Ep=213,bp=214,za=0,ka=1,Ha=2,ys=3,Ga=4,Va=5,Wa=6,Xa=7,su=0,wp=1,Tp=2,yi=0,Ap=1,Cp=2,Rp=3,Pp=4,Dp=5,Lp=6,Ip=7,ru=300,Ms=301,Es=302,Ya=303,qa=304,Eo=306,ja=1e3,Fi=1001,$a=1002,In=1003,Up=1004,dr=1005,Bn=1006,zo=1007,Bi=1008,ti=1009,ou=1010,au=1011,Ks=1012,Nl=1013,ki=1014,Zn=1015,er=1016,Ol=1017,Fl=1018,bs=1020,lu=35902,cu=1021,du=1022,Ln=1023,uu=1024,hu=1025,_s=1026,ws=1027,fu=1028,Bl=1029,pu=1030,zl=1031,kl=1033,Jr=33776,Qr=33777,eo=33778,to=33779,Za=35840,Ka=35841,Ja=35842,Qa=35843,el=36196,tl=37492,nl=37496,il=37808,sl=37809,rl=37810,ol=37811,al=37812,ll=37813,cl=37814,dl=37815,ul=37816,hl=37817,fl=37818,pl=37819,ml=37820,gl=37821,no=36492,_l=36494,vl=36495,mu=36283,xl=36284,Sl=36285,yl=36286,Np=3200,Op=3201,Fp=0,Bp=1,pi="",Pt="srgb",Ts="srgb-linear",fo="linear",nt="srgb",Yi=7680,Sc=519,zp=512,kp=513,Hp=514,gu=515,Gp=516,Vp=517,Wp=518,Xp=519,Ml=35044,yc="300 es",Kn=2e3,po=2001;class Wi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}}const Ft=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Mc=1234567;const vs=Math.PI/180,Js=180/Math.PI;function Jn(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Ft[n&255]+Ft[n>>8&255]+Ft[n>>16&255]+Ft[n>>24&255]+"-"+Ft[e&255]+Ft[e>>8&255]+"-"+Ft[e>>16&15|64]+Ft[e>>24&255]+"-"+Ft[t&63|128]+Ft[t>>8&255]+"-"+Ft[t>>16&255]+Ft[t>>24&255]+Ft[i&255]+Ft[i>>8&255]+Ft[i>>16&255]+Ft[i>>24&255]).toLowerCase()}function Be(n,e,t){return Math.max(e,Math.min(t,n))}function Hl(n,e){return(n%e+e)%e}function Yp(n,e,t,i,s){return i+(n-e)*(s-i)/(t-e)}function qp(n,e,t){return n!==e?(t-n)/(e-n):0}function Vs(n,e,t){return(1-t)*n+t*e}function jp(n,e,t,i){return Vs(n,e,1-Math.exp(-t*i))}function $p(n,e=1){return e-Math.abs(Hl(n,e*2)-e)}function Zp(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function Kp(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Jp(n,e){return n+Math.floor(Math.random()*(e-n+1))}function Qp(n,e){return n+Math.random()*(e-n)}function em(n){return n*(.5-Math.random())}function tm(n){n!==void 0&&(Mc=n);let e=Mc+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function nm(n){return n*vs}function im(n){return n*Js}function sm(n){return(n&n-1)===0&&n!==0}function rm(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function om(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function am(n,e,t,i,s){const r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+i)/2),d=o((e+i)/2),u=r((e-i)/2),h=o((e-i)/2),f=r((i-e)/2),g=o((i-e)/2);switch(s){case"XYX":n.set(a*d,l*u,l*h,a*c);break;case"YZY":n.set(l*h,a*d,l*u,a*c);break;case"ZXZ":n.set(l*u,l*h,a*d,a*c);break;case"XZX":n.set(a*d,l*g,l*f,a*c);break;case"YXY":n.set(l*f,a*d,l*g,a*c);break;case"ZYZ":n.set(l*g,l*f,a*d,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Dn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function tt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const _u={DEG2RAD:vs,RAD2DEG:Js,generateUUID:Jn,clamp:Be,euclideanModulo:Hl,mapLinear:Yp,inverseLerp:qp,lerp:Vs,damp:jp,pingpong:$p,smoothstep:Zp,smootherstep:Kp,randInt:Jp,randFloat:Qp,randFloatSpread:em,seededRandom:tm,degToRad:nm,radToDeg:im,isPowerOfTwo:sm,ceilPowerOfTwo:rm,floorPowerOfTwo:om,setQuaternionFromProperEuler:am,normalize:tt,denormalize:Dn};class Te{constructor(e=0,t=0){Te.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[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=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Be(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Be(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*s+e.x,this.y=r*s+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ne{constructor(e,t,i,s,r,o,a,l,c){Ne.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,o,a,l,c)}set(e,t,i,s,r,o,a,l,c){const d=this.elements;return d[0]=e,d[1]=s,d[2]=a,d[3]=t,d[4]=r,d[5]=l,d[6]=i,d[7]=o,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,o=i[0],a=i[3],l=i[6],c=i[1],d=i[4],u=i[7],h=i[2],f=i[5],g=i[8],_=s[0],m=s[3],p=s[6],b=s[1],y=s[4],S=s[7],C=s[2],T=s[5],D=s[8];return r[0]=o*_+a*b+l*C,r[3]=o*m+a*y+l*T,r[6]=o*p+a*S+l*D,r[1]=c*_+d*b+u*C,r[4]=c*m+d*y+u*T,r[7]=c*p+d*S+u*D,r[2]=h*_+f*b+g*C,r[5]=h*m+f*y+g*T,r[8]=h*p+f*S+g*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],d=e[8];return t*o*d-t*a*c-i*r*d+i*a*l+s*r*c-s*o*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],d=e[8],u=d*o-a*c,h=a*l-d*r,f=c*r-o*l,g=t*u+i*h+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=u*_,e[1]=(s*c-d*i)*_,e[2]=(a*i-s*o)*_,e[3]=h*_,e[4]=(d*t-s*l)*_,e[5]=(s*r-a*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(o*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,o,a){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(ko.makeScale(e,t)),this}rotate(e){return this.premultiply(ko.makeRotation(-e)),this}translate(e,t){return this.premultiply(ko.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const ko=new Ne;function vu(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Qs(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function lm(){const n=Qs("canvas");return n.style.display="block",n}const Ec={};function cs(n){n in Ec||(Ec[n]=!0,console.warn(n))}function cm(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}function dm(n){const e=n.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function um(n){const e=n.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const bc=new Ne().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),wc=new Ne().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function hm(){const n={enabled:!0,workingColorSpace:Ts,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===nt&&(s.r=Qn(s.r),s.g=Qn(s.g),s.b=Qn(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===nt&&(s.r=xs(s.r),s.g=xs(s.g),s.b=xs(s.b))),s},fromWorkingColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},toWorkingColorSpace:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===pi?fo:this.spaces[s].transfer},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Ts]:{primaries:e,whitePoint:i,transfer:fo,toXYZ:bc,fromXYZ:wc,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Pt},outputColorSpaceConfig:{drawingBufferColorSpace:Pt}},[Pt]:{primaries:e,whitePoint:i,transfer:nt,toXYZ:bc,fromXYZ:wc,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Pt}}}),n}const je=hm();function Qn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function xs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let qi;class fm{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{qi===void 0&&(qi=Qs("canvas")),qi.width=e.width,qi.height=e.height;const i=qi.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=qi}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){const t=Qs("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=Qn(r[o]/255)*255;return i.putImageData(s,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Qn(t[i]/255)*255):t[i]=Qn(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let pm=0;class xu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:pm++}),this.uuid=Jn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(Ho(s[o].image)):r.push(Ho(s[o]))}else r=Ho(s);i.url=r}return t||(e.images[this.uuid]=i),i}}function Ho(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?fm.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let mm=0;class Tt extends Wi{constructor(e=Tt.DEFAULT_IMAGE,t=Tt.DEFAULT_MAPPING,i=Fi,s=Fi,r=Bn,o=Bi,a=Ln,l=ti,c=Tt.DEFAULT_ANISOTROPY,d=pi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mm++}),this.uuid=Jn(),this.name="",this.source=new xu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Te(0,0),this.repeat=new Te(1,1),this.center=new Te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ne,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ru)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ja:e.x=e.x-Math.floor(e.x);break;case Fi:e.x=e.x<0?0:1;break;case $a: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 ja:e.y=e.y-Math.floor(e.y);break;case Fi:e.y=e.y<0?0:1;break;case $a:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Tt.DEFAULT_IMAGE=null;Tt.DEFAULT_MAPPING=ru;Tt.DEFAULT_ANISOTROPY=1;class rt{constructor(e=0,t=0,i=0,s=1){rt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=s}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,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*i+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*i+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*i+o[11]*s+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],d=l[4],u=l[8],h=l[1],f=l[5],g=l[9],_=l[2],m=l[6],p=l[10];if(Math.abs(d-h)<.01&&Math.abs(u-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(d+h)<.1&&Math.abs(u+_)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const y=(c+1)/2,S=(f+1)/2,C=(p+1)/2,T=(d+h)/4,D=(u+_)/4,R=(g+m)/4;return y>S&&y>C?y<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(y),s=T/i,r=D/i):S>C?S<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),i=T/s,r=R/s):C<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(C),i=D/r,s=R/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-g)*(m-g)+(u-_)*(u-_)+(h-d)*(h-d));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(u-_)/b,this.z=(h-d)/b,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this.w=Be(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this.w=Be(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Be(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class gm extends Wi{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new rt(0,0,e,t),this.scissorTest=!1,this.viewport=new rt(0,0,e,t);const s={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const r=new Tt(s,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);r.flipY=!1,r.generateMipmaps=i.generateMipmaps,r.internalFormat=i.internalFormat,this.textures=[];const o=i.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].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.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,s=e.textures.length;i<s;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new xu(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Hi extends gm{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class Su extends Tt{constructor(e=null,t=1,i=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:s},this.magFilter=In,this.minFilter=In,this.wrapR=Fi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class _m extends Tt{constructor(e=null,t=1,i=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:s},this.magFilter=In,this.minFilter=In,this.wrapR=Fi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Gi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,o,a){let l=i[s+0],c=i[s+1],d=i[s+2],u=i[s+3];const h=r[o+0],f=r[o+1],g=r[o+2],_=r[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=d,e[t+3]=u;return}if(a===1){e[t+0]=h,e[t+1]=f,e[t+2]=g,e[t+3]=_;return}if(u!==_||l!==h||c!==f||d!==g){let m=1-a;const p=l*h+c*f+d*g+u*_,b=p>=0?1:-1,y=1-p*p;if(y>Number.EPSILON){const C=Math.sqrt(y),T=Math.atan2(C,p*b);m=Math.sin(m*T)/C,a=Math.sin(a*T)/C}const S=a*b;if(l=l*m+h*S,c=c*m+f*S,d=d*m+g*S,u=u*m+_*S,m===1-a){const C=1/Math.sqrt(l*l+c*c+d*d+u*u);l*=C,c*=C,d*=C,u*=C}}e[t]=l,e[t+1]=c,e[t+2]=d,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,s,r,o){const a=i[s],l=i[s+1],c=i[s+2],d=i[s+3],u=r[o],h=r[o+1],f=r[o+2],g=r[o+3];return e[t]=a*g+d*u+l*f-c*h,e[t+1]=l*g+d*h+c*u-a*f,e[t+2]=c*g+d*f+a*h-l*u,e[t+3]=d*g-a*u-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(i/2),d=a(s/2),u=a(r/2),h=l(i/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=h*d*u+c*f*g,this._y=c*f*u-h*d*g,this._z=c*d*g+h*f*u,this._w=c*d*u-h*f*g;break;case"YXZ":this._x=h*d*u+c*f*g,this._y=c*f*u-h*d*g,this._z=c*d*g-h*f*u,this._w=c*d*u+h*f*g;break;case"ZXY":this._x=h*d*u-c*f*g,this._y=c*f*u+h*d*g,this._z=c*d*g+h*f*u,this._w=c*d*u-h*f*g;break;case"ZYX":this._x=h*d*u-c*f*g,this._y=c*f*u+h*d*g,this._z=c*d*g-h*f*u,this._w=c*d*u+h*f*g;break;case"YZX":this._x=h*d*u+c*f*g,this._y=c*f*u+h*d*g,this._z=c*d*g-h*f*u,this._w=c*d*u-h*f*g;break;case"XZY":this._x=h*d*u-c*f*g,this._y=c*f*u-h*d*g,this._z=c*d*g+h*f*u,this._w=c*d*u+h*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],d=t[6],u=t[10],h=i+a+u;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(d-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(i>a&&i>u){const f=2*Math.sqrt(1+i-a-u);this._w=(d-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>u){const f=2*Math.sqrt(1+a-i-u);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+d)/f}else{const f=2*Math.sqrt(1+u-i-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+d)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Be(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,d=t._w;return this._x=i*d+o*a+s*c-r*l,this._y=s*d+o*l+r*a-i*c,this._z=r*d+o*c+i*l-s*a,this._w=o*d-i*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,s=this._y,r=this._z,o=this._w;let a=o*e._w+i*e._x+s*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=s,this._z=r,this;const l=1-a*a;if(l<=Number.EPSILON){const f=1-t;return this._w=f*o+t*this._w,this._x=f*i+t*this._x,this._y=f*s+t*this._y,this._z=f*r+t*this._z,this.normalize(),this}const c=Math.sqrt(l),d=Math.atan2(c,a),u=Math.sin((1-t)*d)/c,h=Math.sin(t*d)/c;return this._w=o*u+this._w*h,this._x=i*u+this._x*h,this._y=s*u+this._y*h,this._z=r*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{constructor(e=0,t=0,i=0){P.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(Tc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Tc.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*i),d=2*(a*t-r*s),u=2*(r*i-o*t);return this.x=t+l*c+o*u-a*d,this.y=i+l*d+a*c-r*u,this.z=s+l*u+r*d-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,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=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Be(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-i*l,this.z=i*a-s*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Go.copy(this).projectOnVector(e),this.sub(Go)}reflect(e){return this.sub(Go.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Be(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Go=new P,Tc=new Gi;class Sn{constructor(e=new P(1/0,1/0,1/0),t=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(bn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(bn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=bn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,bn):bn.fromBufferAttribute(r,o),bn.applyMatrix4(e.matrixWorld),this.expandByPoint(bn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ur.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),ur.copy(i.boundingBox)),ur.applyMatrix4(e.matrixWorld),this.union(ur)}const s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,bn),bn.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(Is),hr.subVectors(this.max,Is),ji.subVectors(e.a,Is),$i.subVectors(e.b,Is),Zi.subVectors(e.c,Is),oi.subVectors($i,ji),ai.subVectors(Zi,$i),wi.subVectors(ji,Zi);let t=[0,-oi.z,oi.y,0,-ai.z,ai.y,0,-wi.z,wi.y,oi.z,0,-oi.x,ai.z,0,-ai.x,wi.z,0,-wi.x,-oi.y,oi.x,0,-ai.y,ai.x,0,-wi.y,wi.x,0];return!Vo(t,ji,$i,Zi,hr)||(t=[1,0,0,0,1,0,0,0,1],!Vo(t,ji,$i,Zi,hr))?!1:(fr.crossVectors(oi,ai),t=[fr.x,fr.y,fr.z],Vo(t,ji,$i,Zi,hr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,bn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(bn).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:(Gn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Gn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Gn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Gn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Gn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Gn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Gn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Gn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Gn),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)}}const Gn=[new P,new P,new P,new P,new P,new P,new P,new P],bn=new P,ur=new Sn,ji=new P,$i=new P,Zi=new P,oi=new P,ai=new P,wi=new P,Is=new P,hr=new P,fr=new P,Ti=new P;function Vo(n,e,t,i,s){for(let r=0,o=n.length-3;r<=o;r+=3){Ti.fromArray(n,r);const a=s.x*Math.abs(Ti.x)+s.y*Math.abs(Ti.y)+s.z*Math.abs(Ti.z),l=e.dot(Ti),c=t.dot(Ti),d=i.dot(Ti);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>a)return!1}return!0}const vm=new Sn,Us=new P,Wo=new P;class Ps{constructor(e=new P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):vm.setFromPoints(e).getCenter(i);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Us.subVectors(e,this.center);const t=Us.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(Us,s/i),this.radius+=s}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):(Wo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Us.copy(e.center).add(Wo)),this.expandByPoint(Us.copy(e.center).sub(Wo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Vn=new P,Xo=new P,pr=new P,li=new P,Yo=new P,mr=new P,qo=new P;class bo{constructor(e=new P,t=new P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Vn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Vn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Vn.copy(this.origin).addScaledVector(this.direction,t),Vn.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){Xo.copy(e).add(t).multiplyScalar(.5),pr.copy(t).sub(e).normalize(),li.copy(this.origin).sub(Xo);const r=e.distanceTo(t)*.5,o=-this.direction.dot(pr),a=li.dot(this.direction),l=-li.dot(pr),c=li.lengthSq(),d=Math.abs(1-o*o);let u,h,f,g;if(d>0)if(u=o*l-a,h=o*a-l,g=r*d,u>=0)if(h>=-g)if(h<=g){const _=1/d;u*=_,h*=_,f=u*(u+o*h+2*a)+h*(o*u+h+2*l)+c}else h=r,u=Math.max(0,-(o*h+a)),f=-u*u+h*(h+2*l)+c;else h=-r,u=Math.max(0,-(o*h+a)),f=-u*u+h*(h+2*l)+c;else h<=-g?(u=Math.max(0,-(-o*r+a)),h=u>0?-r:Math.min(Math.max(-r,-l),r),f=-u*u+h*(h+2*l)+c):h<=g?(u=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(u=Math.max(0,-(o*r+a)),h=u>0?r:Math.min(Math.max(-r,-l),r),f=-u*u+h*(h+2*l)+c);else h=o>0?-r:r,u=Math.max(0,-(o*h+a)),f=-u*u+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Xo).addScaledVector(pr,h),f}intersectSphere(e,t){Vn.subVectors(e.center,this.origin);const i=Vn.dot(this.direction),s=Vn.dot(Vn)-i*i,r=e.radius*e.radius;if(s>r)return null;const o=Math.sqrt(r-s),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,o,a,l;const c=1/this.direction.x,d=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),d>=0?(r=(e.min.y-h.y)*d,o=(e.max.y-h.y)*d):(r=(e.max.y-h.y)*d,o=(e.min.y-h.y)*d),i>o||r>s||((r>i||isNaN(i))&&(i=r),(o<s||isNaN(s))&&(s=o),u>=0?(a=(e.min.z-h.z)*u,l=(e.max.z-h.z)*u):(a=(e.max.z-h.z)*u,l=(e.min.z-h.z)*u),i>l||a>s)||((a>i||i!==i)&&(i=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(i>=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,Vn)!==null}intersectTriangle(e,t,i,s,r){Yo.subVectors(t,e),mr.subVectors(i,e),qo.crossVectors(Yo,mr);let o=this.direction.dot(qo),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;li.subVectors(this.origin,e);const l=a*this.direction.dot(mr.crossVectors(li,mr));if(l<0)return null;const c=a*this.direction.dot(Yo.cross(li));if(c<0||l+c>o)return null;const d=-a*li.dot(qo);return d<0?null:this.at(d/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class pt{constructor(e,t,i,s,r,o,a,l,c,d,u,h,f,g,_,m){pt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,o,a,l,c,d,u,h,f,g,_,m)}set(e,t,i,s,r,o,a,l,c,d,u,h,f,g,_,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=i,p[12]=s,p[1]=r,p[5]=o,p[9]=a,p[13]=l,p[2]=c,p[6]=d,p[10]=u,p[14]=h,p[3]=f,p[7]=g,p[11]=_,p[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new pt().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,s=1/Ki.setFromMatrixColumn(e,0).length(),r=1/Ki.setFromMatrixColumn(e,1).length(),o=1/Ki.setFromMatrixColumn(e,2).length();return t[0]=i[0]*s,t[1]=i[1]*s,t[2]=i[2]*s,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,s=e.y,r=e.z,o=Math.cos(i),a=Math.sin(i),l=Math.cos(s),c=Math.sin(s),d=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const h=o*d,f=o*u,g=a*d,_=a*u;t[0]=l*d,t[4]=-l*u,t[8]=c,t[1]=f+g*c,t[5]=h-_*c,t[9]=-a*l,t[2]=_-h*c,t[6]=g+f*c,t[10]=o*l}else if(e.order==="YXZ"){const h=l*d,f=l*u,g=c*d,_=c*u;t[0]=h+_*a,t[4]=g*a-f,t[8]=o*c,t[1]=o*u,t[5]=o*d,t[9]=-a,t[2]=f*a-g,t[6]=_+h*a,t[10]=o*l}else if(e.order==="ZXY"){const h=l*d,f=l*u,g=c*d,_=c*u;t[0]=h-_*a,t[4]=-o*u,t[8]=g+f*a,t[1]=f+g*a,t[5]=o*d,t[9]=_-h*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const h=o*d,f=o*u,g=a*d,_=a*u;t[0]=l*d,t[4]=g*c-f,t[8]=h*c+_,t[1]=l*u,t[5]=_*c+h,t[9]=f*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const h=o*l,f=o*c,g=a*l,_=a*c;t[0]=l*d,t[4]=_-h*u,t[8]=g*u+f,t[1]=u,t[5]=o*d,t[9]=-a*d,t[2]=-c*d,t[6]=f*u+g,t[10]=h-_*u}else if(e.order==="XZY"){const h=o*l,f=o*c,g=a*l,_=a*c;t[0]=l*d,t[4]=-u,t[8]=c*d,t[1]=h*u+_,t[5]=o*d,t[9]=f*u-g,t[2]=g*u-f,t[6]=a*d,t[10]=_*u+h}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(xm,e,Sm)}lookAt(e,t,i){const s=this.elements;return sn.subVectors(e,t),sn.lengthSq()===0&&(sn.z=1),sn.normalize(),ci.crossVectors(i,sn),ci.lengthSq()===0&&(Math.abs(i.z)===1?sn.x+=1e-4:sn.z+=1e-4,sn.normalize(),ci.crossVectors(i,sn)),ci.normalize(),gr.crossVectors(sn,ci),s[0]=ci.x,s[4]=gr.x,s[8]=sn.x,s[1]=ci.y,s[5]=gr.y,s[9]=sn.y,s[2]=ci.z,s[6]=gr.z,s[10]=sn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,o=i[0],a=i[4],l=i[8],c=i[12],d=i[1],u=i[5],h=i[9],f=i[13],g=i[2],_=i[6],m=i[10],p=i[14],b=i[3],y=i[7],S=i[11],C=i[15],T=s[0],D=s[4],R=s[8],E=s[12],v=s[1],A=s[5],O=s[9],L=s[13],k=s[2],X=s[6],B=s[10],G=s[14],z=s[3],J=s[7],se=s[11],ae=s[15];return r[0]=o*T+a*v+l*k+c*z,r[4]=o*D+a*A+l*X+c*J,r[8]=o*R+a*O+l*B+c*se,r[12]=o*E+a*L+l*G+c*ae,r[1]=d*T+u*v+h*k+f*z,r[5]=d*D+u*A+h*X+f*J,r[9]=d*R+u*O+h*B+f*se,r[13]=d*E+u*L+h*G+f*ae,r[2]=g*T+_*v+m*k+p*z,r[6]=g*D+_*A+m*X+p*J,r[10]=g*R+_*O+m*B+p*se,r[14]=g*E+_*L+m*G+p*ae,r[3]=b*T+y*v+S*k+C*z,r[7]=b*D+y*A+S*X+C*J,r[11]=b*R+y*O+S*B+C*se,r[15]=b*E+y*L+S*G+C*ae,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],s=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],d=e[2],u=e[6],h=e[10],f=e[14],g=e[3],_=e[7],m=e[11],p=e[15];return g*(+r*l*u-s*c*u-r*a*h+i*c*h+s*a*f-i*l*f)+_*(+t*l*f-t*c*h+r*o*h-s*o*f+s*c*d-r*l*d)+m*(+t*c*u-t*a*f-r*o*u+i*o*f+r*a*d-i*c*d)+p*(-s*a*d-t*l*u+t*a*h+s*o*u-i*o*h+i*l*d)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],d=e[8],u=e[9],h=e[10],f=e[11],g=e[12],_=e[13],m=e[14],p=e[15],b=u*m*c-_*h*c+_*l*f-a*m*f-u*l*p+a*h*p,y=g*h*c-d*m*c-g*l*f+o*m*f+d*l*p-o*h*p,S=d*_*c-g*u*c+g*a*f-o*_*f-d*a*p+o*u*p,C=g*u*l-d*_*l-g*a*h+o*_*h+d*a*m-o*u*m,T=t*b+i*y+s*S+r*C;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const D=1/T;return e[0]=b*D,e[1]=(_*h*r-u*m*r-_*s*f+i*m*f+u*s*p-i*h*p)*D,e[2]=(a*m*r-_*l*r+_*s*c-i*m*c-a*s*p+i*l*p)*D,e[3]=(u*l*r-a*h*r-u*s*c+i*h*c+a*s*f-i*l*f)*D,e[4]=y*D,e[5]=(d*m*r-g*h*r+g*s*f-t*m*f-d*s*p+t*h*p)*D,e[6]=(g*l*r-o*m*r-g*s*c+t*m*c+o*s*p-t*l*p)*D,e[7]=(o*h*r-d*l*r+d*s*c-t*h*c-o*s*f+t*l*f)*D,e[8]=S*D,e[9]=(g*u*r-d*_*r-g*i*f+t*_*f+d*i*p-t*u*p)*D,e[10]=(o*_*r-g*a*r+g*i*c-t*_*c-o*i*p+t*a*p)*D,e[11]=(d*a*r-o*u*r-d*i*c+t*u*c+o*i*f-t*a*f)*D,e[12]=C*D,e[13]=(d*_*s-g*u*s+g*i*h-t*_*h-d*i*m+t*u*m)*D,e[14]=(g*a*s-o*_*s-g*i*l+t*_*l+o*i*m-t*a*m)*D,e[15]=(o*u*s-d*a*s+d*i*l-t*u*l-o*i*h+t*a*h)*D,this}scale(e){const t=this.elements,i=e.x,s=e.y,r=e.z;return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,s))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),s=Math.sin(t),r=1-i,o=e.x,a=e.y,l=e.z,c=r*o,d=r*a;return this.set(c*o+i,c*a-s*l,c*l+s*a,0,c*a+s*l,d*a+i,d*l-s*o,0,c*l-s*a,d*l+s*o,r*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,s,r,o){return this.set(1,i,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,i){const s=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,d=o+o,u=a+a,h=r*c,f=r*d,g=r*u,_=o*d,m=o*u,p=a*u,b=l*c,y=l*d,S=l*u,C=i.x,T=i.y,D=i.z;return s[0]=(1-(_+p))*C,s[1]=(f+S)*C,s[2]=(g-y)*C,s[3]=0,s[4]=(f-S)*T,s[5]=(1-(h+p))*T,s[6]=(m+b)*T,s[7]=0,s[8]=(g+y)*D,s[9]=(m-b)*D,s[10]=(1-(h+_))*D,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,i){const s=this.elements;let r=Ki.set(s[0],s[1],s[2]).length();const o=Ki.set(s[4],s[5],s[6]).length(),a=Ki.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],wn.copy(this);const c=1/r,d=1/o,u=1/a;return wn.elements[0]*=c,wn.elements[1]*=c,wn.elements[2]*=c,wn.elements[4]*=d,wn.elements[5]*=d,wn.elements[6]*=d,wn.elements[8]*=u,wn.elements[9]*=u,wn.elements[10]*=u,t.setFromRotationMatrix(wn),i.x=r,i.y=o,i.z=a,this}makePerspective(e,t,i,s,r,o,a=Kn){const l=this.elements,c=2*r/(t-e),d=2*r/(i-s),u=(t+e)/(t-e),h=(i+s)/(i-s);let f,g;if(a===Kn)f=-(o+r)/(o-r),g=-2*o*r/(o-r);else if(a===po)f=-o/(o-r),g=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=d,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,s,r,o,a=Kn){const l=this.elements,c=1/(t-e),d=1/(i-s),u=1/(o-r),h=(t+e)*c,f=(i+s)*d;let g,_;if(a===Kn)g=(o+r)*u,_=-2*u;else if(a===po)g=r*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-h,l[1]=0,l[5]=2*d,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<16;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Ki=new P,wn=new pt,xm=new P(0,0,0),Sm=new P(1,1,1),ci=new P,gr=new P,sn=new P,Ac=new pt,Cc=new Gi;class ni{constructor(e=0,t=0,i=0,s=ni.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=s}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,s=this._order){return this._x=e,this._y=t,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const s=e.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],d=s[9],u=s[2],h=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Be(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-d,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Be(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Be(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Be(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Be(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Be(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-d,f),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 Ac.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ac,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Cc.setFromEuler(this),this.setFromQuaternion(Cc,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}}ni.DEFAULT_ORDER="XYZ";class Gl{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let ym=0;const Rc=new P,Ji=new Gi,Wn=new pt,_r=new P,Ns=new P,Mm=new P,Em=new Gi,Pc=new P(1,0,0),Dc=new P(0,1,0),Lc=new P(0,0,1),Ic={type:"added"},bm={type:"removed"},Qi={type:"childadded",child:null},jo={type:"childremoved",child:null};class Yt extends Wi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ym++}),this.uuid=Jn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Yt.DEFAULT_UP.clone();const e=new P,t=new ni,i=new Gi,s=new P(1,1,1);function r(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new pt},normalMatrix:{value:new Ne}}),this.matrix=new pt,this.matrixWorld=new pt,this.matrixAutoUpdate=Yt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Yt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Gl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ji.setFromAxisAngle(e,t),this.quaternion.multiply(Ji),this}rotateOnWorldAxis(e,t){return Ji.setFromAxisAngle(e,t),this.quaternion.premultiply(Ji),this}rotateX(e){return this.rotateOnAxis(Pc,e)}rotateY(e){return this.rotateOnAxis(Dc,e)}rotateZ(e){return this.rotateOnAxis(Lc,e)}translateOnAxis(e,t){return Rc.copy(e).applyQuaternion(this.quaternion),this.position.add(Rc.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Pc,e)}translateY(e){return this.translateOnAxis(Dc,e)}translateZ(e){return this.translateOnAxis(Lc,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Wn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?_r.copy(e):_r.set(e,t,i);const s=this.parent;this.updateWorldMatrix(!0,!1),Ns.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Wn.lookAt(Ns,_r,this.up):Wn.lookAt(_r,Ns,this.up),this.quaternion.setFromRotationMatrix(Wn),s&&(Wn.extractRotation(s.matrixWorld),Ji.setFromRotationMatrix(Wn),this.quaternion.premultiply(Ji.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ic),Qi.child=e,this.dispatchEvent(Qi),Qi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(bm),jo.child=e,this.dispatchEvent(jo),jo.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Wn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Wn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Wn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ic),Qi.child=e,this.dispatchEvent(Qi),Qi.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,s=this.children.length;i<s;i++){const o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ns,e,Mm),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ns,Em,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,s=t.length;i<s;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const u=l[c];r(e.shapes,u)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];s.animations.push(r(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),d=o(e.images),u=o(e.shapes),h=o(e.skeletons),f=o(e.animations),g=o(e.nodes);a.length>0&&(i.geometries=a),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),d.length>0&&(i.images=d),u.length>0&&(i.shapes=u),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),g.length>0&&(i.nodes=g)}return i.object=s,i;function o(a){const l=[];for(const c in a){const d=a[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const s=e.children[i];this.add(s.clone())}return this}}Yt.DEFAULT_UP=new P(0,1,0);Yt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Yt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Tn=new P,Xn=new P,$o=new P,Yn=new P,es=new P,ts=new P,Uc=new P,Zo=new P,Ko=new P,Jo=new P,Qo=new rt,ea=new rt,ta=new rt;class xn{constructor(e=new P,t=new P,i=new P){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Tn.subVectors(e,t),s.cross(Tn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Tn.subVectors(s,t),Xn.subVectors(i,t),$o.subVectors(e,t);const o=Tn.dot(Tn),a=Tn.dot(Xn),l=Tn.dot($o),c=Xn.dot(Xn),d=Xn.dot($o),u=o*c-a*a;if(u===0)return r.set(0,0,0),null;const h=1/u,f=(c*l-a*d)*h,g=(o*d-a*l)*h;return r.set(1-f-g,g,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,Yn)===null?!1:Yn.x>=0&&Yn.y>=0&&Yn.x+Yn.y<=1}static getInterpolation(e,t,i,s,r,o,a,l){return this.getBarycoord(e,t,i,s,Yn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Yn.x),l.addScaledVector(o,Yn.y),l.addScaledVector(a,Yn.z),l)}static getInterpolatedAttribute(e,t,i,s,r,o){return Qo.setScalar(0),ea.setScalar(0),ta.setScalar(0),Qo.fromBufferAttribute(e,t),ea.fromBufferAttribute(e,i),ta.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(Qo,r.x),o.addScaledVector(ea,r.y),o.addScaledVector(ta,r.z),o}static isFrontFacing(e,t,i,s){return Tn.subVectors(i,t),Xn.subVectors(e,t),Tn.cross(Xn).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Tn.subVectors(this.c,this.b),Xn.subVectors(this.a,this.b),Tn.cross(Xn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return xn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return xn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return xn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let o,a;es.subVectors(s,i),ts.subVectors(r,i),Zo.subVectors(e,i);const l=es.dot(Zo),c=ts.dot(Zo);if(l<=0&&c<=0)return t.copy(i);Ko.subVectors(e,s);const d=es.dot(Ko),u=ts.dot(Ko);if(d>=0&&u<=d)return t.copy(s);const h=l*u-d*c;if(h<=0&&l>=0&&d<=0)return o=l/(l-d),t.copy(i).addScaledVector(es,o);Jo.subVectors(e,r);const f=es.dot(Jo),g=ts.dot(Jo);if(g>=0&&f<=g)return t.copy(r);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(i).addScaledVector(ts,a);const m=d*g-f*u;if(m<=0&&u-d>=0&&f-g>=0)return Uc.subVectors(r,s),a=(u-d)/(u-d+(f-g)),t.copy(s).addScaledVector(Uc,a);const p=1/(m+_+h);return o=_*p,a=h*p,t.copy(i).addScaledVector(es,o).addScaledVector(ts,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const yu={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},di={h:0,s:0,l:0},vr={h:0,s:0,l:0};function na(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Ze{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Pt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.toWorkingColorSpace(this,t),this}setRGB(e,t,i,s=je.workingColorSpace){return this.r=e,this.g=t,this.b=i,je.toWorkingColorSpace(this,s),this}setHSL(e,t,i,s=je.workingColorSpace){if(e=Hl(e,1),t=Be(t,0,1),i=Be(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,o=2*i-r;this.r=na(o,r,e+1/3),this.g=na(o,r,e),this.b=na(o,r,e-1/3)}return je.toWorkingColorSpace(this,s),this}setStyle(e,t=Pt){function i(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Pt){const i=yu[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=Qn(e.r),this.g=Qn(e.g),this.b=Qn(e.b),this}copyLinearToSRGB(e){return this.r=xs(e.r),this.g=xs(e.g),this.b=xs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Pt){return je.fromWorkingColorSpace(Bt.copy(this),e),Math.round(Be(Bt.r*255,0,255))*65536+Math.round(Be(Bt.g*255,0,255))*256+Math.round(Be(Bt.b*255,0,255))}getHexString(e=Pt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.fromWorkingColorSpace(Bt.copy(this),t);const i=Bt.r,s=Bt.g,r=Bt.b,o=Math.max(i,s,r),a=Math.min(i,s,r);let l,c;const d=(a+o)/2;if(a===o)l=0,c=0;else{const u=o-a;switch(c=d<=.5?u/(o+a):u/(2-o-a),o){case i:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-i)/u+2;break;case r:l=(i-s)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,t=je.workingColorSpace){return je.fromWorkingColorSpace(Bt.copy(this),t),e.r=Bt.r,e.g=Bt.g,e.b=Bt.b,e}getStyle(e=Pt){je.fromWorkingColorSpace(Bt.copy(this),e);const t=Bt.r,i=Bt.g,s=Bt.b;return e!==Pt?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(e,t,i){return this.getHSL(di),this.setHSL(di.h+e,di.s+t,di.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(di),e.getHSL(vr);const i=Vs(di.h,vr.h,t),s=Vs(di.s,vr.s,t),r=Vs(di.l,vr.l,t);return this.setHSL(i,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*s,this.g=r[1]*t+r[4]*i+r[7]*s,this.b=r[2]*t+r[5]*i+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Bt=new Ze;Ze.NAMES=yu;let wm=0;class tr extends Wi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wm++}),this.uuid=Jn(),this.name="",this.type="Material",this.blending=gs,this.side=Mi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Fa,this.blendDst=Ba,this.blendEquation=Ni,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ze(0,0,0),this.blendAlpha=0,this.depthFunc=ys,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Sc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yi,this.stencilZFail=Yi,this.stencilZPass=Yi,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}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==gs&&(i.blending=this.blending),this.side!==Mi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Fa&&(i.blendSrc=this.blendSrc),this.blendDst!==Ba&&(i.blendDst=this.blendDst),this.blendEquation!==Ni&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ys&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Sc&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yi&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Yi&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Yi&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const o=[];for(const a in r){const l=r[a];delete l.metadata,o.push(l)}return o}if(t){const r=s(e.textures),o=s(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class tn extends tr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=su,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const yt=new P,xr=new Te;class Un{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=Ml,this.updateRanges=[],this.gpuType=Zn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[i+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)xr.fromBufferAttribute(this,t),xr.applyMatrix3(e),this.setXY(t,xr.x,xr.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)yt.fromBufferAttribute(this,t),yt.applyMatrix3(e),this.setXYZ(t,yt.x,yt.y,yt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)yt.fromBufferAttribute(this,t),yt.applyMatrix4(e),this.setXYZ(t,yt.x,yt.y,yt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)yt.fromBufferAttribute(this,t),yt.applyNormalMatrix(e),this.setXYZ(t,yt.x,yt.y,yt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)yt.fromBufferAttribute(this,t),yt.transformDirection(e),this.setXYZ(t,yt.x,yt.y,yt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Dn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=tt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Dn(t,this.array)),t}setX(e,t){return this.normalized&&(t=tt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Dn(t,this.array)),t}setY(e,t){return this.normalized&&(t=tt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Dn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=tt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Dn(t,this.array)),t}setW(e,t){return this.normalized&&(t=tt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,s){return e*=this.itemSize,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array),s=tt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=s,this}setXYZW(e,t,i,s,r){return e*=this.itemSize,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array),s=tt(s,this.array),r=tt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ml&&(e.usage=this.usage),e}}class Mu extends Un{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Eu extends Un{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class kt extends Un{constructor(e,t,i){super(new Float32Array(e),t,i)}}let Tm=0;const pn=new pt,ia=new Yt,ns=new P,rn=new Sn,Os=new Sn,Rt=new P;class yn extends Wi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Tm++}),this.uuid=Jn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(vu(e)?Eu:Mu)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new Ne().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return pn.makeRotationFromQuaternion(e),this.applyMatrix4(pn),this}rotateX(e){return pn.makeRotationX(e),this.applyMatrix4(pn),this}rotateY(e){return pn.makeRotationY(e),this.applyMatrix4(pn),this}rotateZ(e){return pn.makeRotationZ(e),this.applyMatrix4(pn),this}translate(e,t,i){return pn.makeTranslation(e,t,i),this.applyMatrix4(pn),this}scale(e,t,i){return pn.makeScale(e,t,i),this.applyMatrix4(pn),this}lookAt(e){return ia.lookAt(e),ia.updateMatrix(),this.applyMatrix4(ia.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ns).negate(),this.translate(ns.x,ns.y,ns.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;s<r;s++){const o=e[s];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new kt(i,3))}else{const i=Math.min(e.length,t.count);for(let s=0;s<i;s++){const r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Sn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i<s;i++){const r=t[i];rn.setFromBufferAttribute(r),this.morphTargetsRelative?(Rt.addVectors(this.boundingBox.min,rn.min),this.boundingBox.expandByPoint(Rt),Rt.addVectors(this.boundingBox.max,rn.max),this.boundingBox.expandByPoint(Rt)):(this.boundingBox.expandByPoint(rn.min),this.boundingBox.expandByPoint(rn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ps);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(e){const i=this.boundingSphere.center;if(rn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];Os.setFromBufferAttribute(a),this.morphTargetsRelative?(Rt.addVectors(rn.min,Os.min),rn.expandByPoint(Rt),Rt.addVectors(rn.max,Os.max),rn.expandByPoint(Rt)):(rn.expandByPoint(Os.min),rn.expandByPoint(Os.max))}rn.getCenter(i);let s=0;for(let r=0,o=e.count;r<o;r++)Rt.fromBufferAttribute(e,r),s=Math.max(s,i.distanceToSquared(Rt));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],l=this.morphTargetsRelative;for(let c=0,d=a.count;c<d;c++)Rt.fromBufferAttribute(a,c),l&&(ns.fromBufferAttribute(e,c),Rt.add(ns)),s=Math.max(s,i.distanceToSquared(Rt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Un(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let R=0;R<i.count;R++)a[R]=new P,l[R]=new P;const c=new P,d=new P,u=new P,h=new Te,f=new Te,g=new Te,_=new P,m=new P;function p(R,E,v){c.fromBufferAttribute(i,R),d.fromBufferAttribute(i,E),u.fromBufferAttribute(i,v),h.fromBufferAttribute(r,R),f.fromBufferAttribute(r,E),g.fromBufferAttribute(r,v),d.sub(c),u.sub(c),f.sub(h),g.sub(h);const A=1/(f.x*g.y-g.x*f.y);isFinite(A)&&(_.copy(d).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(A),m.copy(u).multiplyScalar(f.x).addScaledVector(d,-g.x).multiplyScalar(A),a[R].add(_),a[E].add(_),a[v].add(_),l[R].add(m),l[E].add(m),l[v].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let R=0,E=b.length;R<E;++R){const v=b[R],A=v.start,O=v.count;for(let L=A,k=A+O;L<k;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}const y=new P,S=new P,C=new P,T=new P;function D(R){C.fromBufferAttribute(s,R),T.copy(C);const E=a[R];y.copy(E),y.sub(C.multiplyScalar(C.dot(E))).normalize(),S.crossVectors(T,E);const A=S.dot(l[R])<0?-1:1;o.setXYZW(R,y.x,y.y,y.z,A)}for(let R=0,E=b.length;R<E;++R){const v=b[R],A=v.start,O=v.count;for(let L=A,k=A+O;L<k;L+=3)D(e.getX(L+0)),D(e.getX(L+1)),D(e.getX(L+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Un(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,f=i.count;h<f;h++)i.setXYZ(h,0,0,0);const s=new P,r=new P,o=new P,a=new P,l=new P,c=new P,d=new P,u=new P;if(e)for(let h=0,f=e.count;h<f;h+=3){const g=e.getX(h+0),_=e.getX(h+1),m=e.getX(h+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,_),o.fromBufferAttribute(t,m),d.subVectors(o,r),u.subVectors(s,r),d.cross(u),a.fromBufferAttribute(i,g),l.fromBufferAttribute(i,_),c.fromBufferAttribute(i,m),a.add(d),l.add(d),c.add(d),i.setXYZ(g,a.x,a.y,a.z),i.setXYZ(_,l.x,l.y,l.z),i.setXYZ(m,c.x,c.y,c.z)}else for(let h=0,f=t.count;h<f;h+=3)s.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),o.fromBufferAttribute(t,h+2),d.subVectors(o,r),u.subVectors(s,r),d.cross(u),i.setXYZ(h+0,d.x,d.y,d.z),i.setXYZ(h+1,d.x,d.y,d.z),i.setXYZ(h+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Rt.fromBufferAttribute(e,t),Rt.normalize(),e.setXYZ(t,Rt.x,Rt.y,Rt.z)}toNonIndexed(){function e(a,l){const c=a.array,d=a.itemSize,u=a.normalized,h=new c.constructor(l.length*d);let f=0,g=0;for(let _=0,m=l.length;_<m;_++){a.isInterleavedBufferAttribute?f=l[_]*a.data.stride+a.offset:f=l[_]*d;for(let p=0;p<d;p++)h[g++]=c[f++]}return new Un(h,d,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new yn,i=this.index.array,s=this.attributes;for(const a in s){const l=s[a],c=e(l,i);t.setAttribute(a,c)}const r=this.morphAttributes;for(const a in r){const l=[],c=r[a];for(let d=0,u=c.length;d<u;d++){const h=c[d],f=e(h,i);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let u=0,h=c.length;u<h;u++){const f=c[u];d.push(f.toJSON(e.data))}d.length>0&&(s[l]=d,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.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;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const s=e.attributes;for(const c in s){const d=s[c];this.setAttribute(c,d.clone(t))}const r=e.morphAttributes;for(const c in r){const d=[],u=r[c];for(let h=0,f=u.length;h<f;h++)d.push(u[h].clone(t));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,d=o.length;c<d;c++){const u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Nc=new pt,Ai=new bo,Sr=new Ps,Oc=new P,yr=new P,Mr=new P,Er=new P,sa=new P,br=new P,Fc=new P,wr=new P;class vt extends Yt{constructor(e=new yn,t=new tn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){const a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,s=i.attributes.position,r=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(s,e);const a=this.morphTargetInfluences;if(r&&a){br.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const d=a[l],u=r[l];d!==0&&(sa.fromBufferAttribute(u,e),o?br.addScaledVector(sa,d):br.addScaledVector(sa.sub(t),d))}t.add(br)}return t}raycast(e,t){const i=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Sr.copy(i.boundingSphere),Sr.applyMatrix4(r),Ai.copy(e.ray).recast(e.near),!(Sr.containsPoint(Ai.origin)===!1&&(Ai.intersectSphere(Sr,Oc)===null||Ai.origin.distanceToSquared(Oc)>(e.far-e.near)**2))&&(Nc.copy(r).invert(),Ai.copy(e.ray).applyMatrix4(Nc),!(i.boundingBox!==null&&Ai.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Ai)))}_computeIntersections(e,t,i){let s;const r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,d=r.attributes.uv1,u=r.attributes.normal,h=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,_=h.length;g<_;g++){const m=h[g],p=o[m.materialIndex],b=Math.max(m.start,f.start),y=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let S=b,C=y;S<C;S+=3){const T=a.getX(S),D=a.getX(S+1),R=a.getX(S+2);s=Tr(this,p,e,i,c,d,u,T,D,R),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(a.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const b=a.getX(m),y=a.getX(m+1),S=a.getX(m+2);s=Tr(this,o,e,i,c,d,u,b,y,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,_=h.length;g<_;g++){const m=h[g],p=o[m.materialIndex],b=Math.max(m.start,f.start),y=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let S=b,C=y;S<C;S+=3){const T=S,D=S+1,R=S+2;s=Tr(this,p,e,i,c,d,u,T,D,R),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let m=g,p=_;m<p;m+=3){const b=m,y=m+1,S=m+2;s=Tr(this,o,e,i,c,d,u,b,y,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function Am(n,e,t,i,s,r,o,a){let l;if(e.side===en?l=i.intersectTriangle(o,r,s,!0,a):l=i.intersectTriangle(s,r,o,e.side===Mi,a),l===null)return null;wr.copy(a),wr.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(wr);return c<t.near||c>t.far?null:{distance:c,point:wr.clone(),object:n}}function Tr(n,e,t,i,s,r,o,a,l,c){n.getVertexPosition(a,yr),n.getVertexPosition(l,Mr),n.getVertexPosition(c,Er);const d=Am(n,e,t,i,yr,Mr,Er,Fc);if(d){const u=new P;xn.getBarycoord(Fc,yr,Mr,Er,u),s&&(d.uv=xn.getInterpolatedAttribute(s,a,l,c,u,new Te)),r&&(d.uv1=xn.getInterpolatedAttribute(r,a,l,c,u,new Te)),o&&(d.normal=xn.getInterpolatedAttribute(o,a,l,c,u,new P),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));const h={a,b:l,c,normal:new P,materialIndex:0};xn.getNormal(yr,Mr,Er,h.normal),d.face=h,d.barycoord=u}return d}class nr extends yn{constructor(e=1,t=1,i=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:s,heightSegments:r,depthSegments:o};const a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);const l=[],c=[],d=[],u=[];let h=0,f=0;g("z","y","x",-1,-1,i,t,e,o,r,0),g("z","y","x",1,-1,i,t,-e,o,r,1),g("x","z","y",1,1,e,i,t,s,o,2),g("x","z","y",1,-1,e,i,-t,s,o,3),g("x","y","z",1,-1,e,t,i,s,r,4),g("x","y","z",-1,-1,e,t,-i,s,r,5),this.setIndex(l),this.setAttribute("position",new kt(c,3)),this.setAttribute("normal",new kt(d,3)),this.setAttribute("uv",new kt(u,2));function g(_,m,p,b,y,S,C,T,D,R,E){const v=S/D,A=C/R,O=S/2,L=C/2,k=T/2,X=D+1,B=R+1;let G=0,z=0;const J=new P;for(let se=0;se<B;se++){const ae=se*A-L;for(let Ce=0;Ce<X;Ce++){const Qe=Ce*v-O;J[_]=Qe*b,J[m]=ae*y,J[p]=k,c.push(J.x,J.y,J.z),J[_]=0,J[m]=0,J[p]=T>0?1:-1,d.push(J.x,J.y,J.z),u.push(Ce/D),u.push(1-se/R),G+=1}}for(let se=0;se<R;se++)for(let ae=0;ae<D;ae++){const Ce=h+ae+X*se,Qe=h+ae+X*(se+1),j=h+(ae+1)+X*(se+1),te=h+(ae+1)+X*se;l.push(Ce,Qe,te),l.push(Qe,j,te),z+=6}a.addGroup(f,z,E),f+=z,h+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function As(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const s=n[t][i];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=s.clone():Array.isArray(s)?e[t][i]=s.slice():e[t][i]=s}}return e}function Wt(n){const e={};for(let t=0;t<n.length;t++){const i=As(n[t]);for(const s in i)e[s]=i[s]}return e}function Cm(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function bu(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:je.workingColorSpace}const Vl={clone:As,merge:Wt};var Rm=`void main() {
  6. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  7. }`,Pm=`void main() {
  8. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  9. }`;class ii extends tr{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Rm,this.fragmentShader=Pm,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=As(e.uniforms),this.uniformsGroups=Cm(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class wu extends Yt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new pt,this.projectionMatrix=new pt,this.projectionMatrixInverse=new pt,this.coordinateSystem=Kn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const ui=new P,Bc=new Te,zc=new Te;class vn extends wu{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Js*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(vs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Js*2*Math.atan(Math.tan(vs*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){ui.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ui.x,ui.y).multiplyScalar(-e/ui.z),ui.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ui.x,ui.y).multiplyScalar(-e/ui.z)}getViewSize(e,t){return this.getViewBounds(e,Bc,zc),t.subVectors(zc,Bc)}setViewOffset(e,t,i,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(vs*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,t-=o.offsetY*i/c,s*=o.width/l,i*=o.height/c}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const is=-90,ss=1;class Dm extends Yt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new vn(is,ss,e,t);s.layers=this.layers,this.add(s);const r=new vn(is,ss,e,t);r.layers=this.layers,this.add(r);const o=new vn(is,ss,e,t);o.layers=this.layers,this.add(o);const a=new vn(is,ss,e,t);a.layers=this.layers,this.add(a);const l=new vn(is,ss,e,t);l.layers=this.layers,this.add(l);const c=new vn(is,ss,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,o,a,l]=t;for(const c of t)this.remove(c);if(e===Kn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===po)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,l,c,d]=this.children,u=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,s),e.render(t,r),e.setRenderTarget(i,1,s),e.render(t,o),e.setRenderTarget(i,2,s),e.render(t,a),e.setRenderTarget(i,3,s),e.render(t,l),e.setRenderTarget(i,4,s),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),e.render(t,d),e.setRenderTarget(u,h,f),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class Tu extends Tt{constructor(e,t,i,s,r,o,a,l,c,d){e=e!==void 0?e:[],t=t!==void 0?t:Ms,super(e,t,i,s,r,o,a,l,c,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Lm extends Hi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new Tu(s,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Bn}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
  10. varying vec3 vWorldDirection;
  11. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  12. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  13. }
  14. void main() {
  15. vWorldDirection = transformDirection( position, modelMatrix );
  16. #include <begin_vertex>
  17. #include <project_vertex>
  18. }
  19. `,fragmentShader:`
  20. uniform sampler2D tEquirect;
  21. varying vec3 vWorldDirection;
  22. #include <common>
  23. void main() {
  24. vec3 direction = normalize( vWorldDirection );
  25. vec2 sampleUV = equirectUv( direction );
  26. gl_FragColor = texture2D( tEquirect, sampleUV );
  27. }
  28. `},s=new nr(5,5,5),r=new ii({name:"CubemapFromEquirect",uniforms:As(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:en,blending:Si});r.uniforms.tEquirect.value=t;const o=new vt(s,r),a=t.minFilter;return t.minFilter===Bi&&(t.minFilter=Bn),new Dm(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,s){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,s);e.setRenderTarget(r)}}let Im=class extends Yt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ni,this.environmentIntensity=1,this.environmentRotation=new ni,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}};class Um{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ml,this.updateRanges=[],this.version=0,this.uuid=Jn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[i+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Jn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Jn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Gt=new P;class _i{constructor(e,t,i,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.applyMatrix4(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.applyNormalMatrix(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Gt.fromBufferAttribute(this,t),Gt.transformDirection(e),this.setXYZ(t,Gt.x,Gt.y,Gt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Dn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=tt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=tt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=tt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Dn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Dn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Dn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Dn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array),s=tt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=s,this}setXYZW(e,t,i,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=tt(t,this.array),i=tt(i,this.array),s=tt(s,this.array),r=tt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new Un(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new _i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const ra=new P,Nm=new P,Om=new Ne;class hi{constructor(e=new P(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,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=ra.subVectors(i,t).cross(Nm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(ra),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Om.getNormalMatrix(e),s=this.coplanarPoint(ra).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ci=new Ps,Ar=new P;class Au{constructor(e=new hi,t=new hi,i=new hi,s=new hi,r=new hi,o=new hi){this.planes=[e,t,i,s,r,o]}set(e,t,i,s,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Kn){const i=this.planes,s=e.elements,r=s[0],o=s[1],a=s[2],l=s[3],c=s[4],d=s[5],u=s[6],h=s[7],f=s[8],g=s[9],_=s[10],m=s[11],p=s[12],b=s[13],y=s[14],S=s[15];if(i[0].setComponents(l-r,h-c,m-f,S-p).normalize(),i[1].setComponents(l+r,h+c,m+f,S+p).normalize(),i[2].setComponents(l+o,h+d,m+g,S+b).normalize(),i[3].setComponents(l-o,h-d,m-g,S-b).normalize(),i[4].setComponents(l-a,h-u,m-_,S-y).normalize(),t===Kn)i[5].setComponents(l+a,h+u,m+_,S+y).normalize();else if(t===po)i[5].setComponents(a,u,_,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ci.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ci.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ci)}intersectsSprite(e){return Ci.center.set(0,0,0),Ci.radius=.7071067811865476,Ci.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ci)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const s=t[i];if(Ar.x=s.normal.x>0?e.max.x:e.min.x,Ar.y=s.normal.y>0?e.max.y:e.min.y,Ar.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Ar)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Cu extends tr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ze(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const mo=new P,go=new P,kc=new pt,Fs=new bo,Cr=new Ps,oa=new P,Hc=new P;let Fm=class extends Yt{constructor(e=new yn,t=new Cu){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s<r;s++)mo.fromBufferAttribute(t,s-1),go.fromBufferAttribute(t,s),i[s]=i[s-1],i[s]+=mo.distanceTo(go);e.setAttribute("lineDistance",new kt(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Cr.copy(i.boundingSphere),Cr.applyMatrix4(s),Cr.radius+=r,e.ray.intersectsSphere(Cr)===!1)return;kc.copy(s).invert(),Fs.copy(e.ray).applyMatrix4(kc);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,d=i.index,h=i.attributes.position;if(d!==null){const f=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let _=f,m=g-1;_<m;_+=c){const p=d.getX(_),b=d.getX(_+1),y=Rr(this,e,Fs,l,p,b);y&&t.push(y)}if(this.isLineLoop){const _=d.getX(g-1),m=d.getX(f),p=Rr(this,e,Fs,l,_,m);p&&t.push(p)}}else{const f=Math.max(0,o.start),g=Math.min(h.count,o.start+o.count);for(let _=f,m=g-1;_<m;_+=c){const p=Rr(this,e,Fs,l,_,_+1);p&&t.push(p)}if(this.isLineLoop){const _=Rr(this,e,Fs,l,g-1,f);_&&t.push(_)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){const a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Rr(n,e,t,i,s,r){const o=n.geometry.attributes.position;if(mo.fromBufferAttribute(o,s),go.fromBufferAttribute(o,r),t.distanceSqToSegment(mo,go,oa,Hc)>i)return;oa.applyMatrix4(n.matrixWorld);const l=e.ray.origin.distanceTo(oa);if(!(l<e.near||l>e.far))return{distance:l,point:Hc.clone().applyMatrix4(n.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:n}}const Gc=new P,Vc=new P;class Bm extends Fm{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s<r;s+=2)Gc.fromBufferAttribute(t,s),Vc.fromBufferAttribute(t,s+1),i[s]=s===0?0:i[s-1],i[s+1]=i[s]+Gc.distanceTo(Vc);e.setAttribute("lineDistance",new kt(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class vi extends Yt{constructor(){super(),this.isGroup=!0,this.type="Group"}}class zm extends Tt{constructor(e,t,i,s,r,o,a,l,c){super(e,t,i,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ru extends Tt{constructor(e,t,i,s,r,o,a,l,c,d=_s){if(d!==_s&&d!==ws)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&d===_s&&(i=ki),i===void 0&&d===ws&&(i=bs),super(null,s,r,o,a,l,d,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:In,this.minFilter=l!==void 0?l:In,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Wl extends yn{constructor(e=1,t=32,i=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:s},t=Math.max(3,t);const r=[],o=[],a=[],l=[],c=new P,d=new Te;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let u=0,h=3;u<=t;u++,h+=3){const f=i+u/t*s;c.x=e*Math.cos(f),c.y=e*Math.sin(f),o.push(c.x,c.y,c.z),a.push(0,0,1),d.x=(o[h]/e+1)/2,d.y=(o[h+1]/e+1)/2,l.push(d.x,d.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new kt(o,3)),this.setAttribute("normal",new kt(a,3)),this.setAttribute("uv",new kt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wl(e.radius,e.segments,e.thetaStart,e.thetaLength)}}const Pr=new P,Dr=new P,aa=new P,Lr=new xn;class Pu extends yn{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const s=Math.pow(10,4),r=Math.cos(vs*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],d=["a","b","c"],u=new Array(3),h={},f=[];for(let g=0;g<l;g+=3){o?(c[0]=o.getX(g),c[1]=o.getX(g+1),c[2]=o.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);const{a:_,b:m,c:p}=Lr;if(_.fromBufferAttribute(a,c[0]),m.fromBufferAttribute(a,c[1]),p.fromBufferAttribute(a,c[2]),Lr.getNormal(aa),u[0]=`${Math.round(_.x*s)},${Math.round(_.y*s)},${Math.round(_.z*s)}`,u[1]=`${Math.round(m.x*s)},${Math.round(m.y*s)},${Math.round(m.z*s)}`,u[2]=`${Math.round(p.x*s)},${Math.round(p.y*s)},${Math.round(p.z*s)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let b=0;b<3;b++){const y=(b+1)%3,S=u[b],C=u[y],T=Lr[d[b]],D=Lr[d[y]],R=`${S}_${C}`,E=`${C}_${S}`;E in h&&h[E]?(aa.dot(h[E].normal)<=r&&(f.push(T.x,T.y,T.z),f.push(D.x,D.y,D.z)),h[E]=null):R in h||(h[R]={index0:c[b],index1:c[y],normal:aa.clone()})}}for(const g in h)if(h[g]){const{index0:_,index1:m}=h[g];Pr.fromBufferAttribute(a,_),Dr.fromBufferAttribute(a,m),f.push(Pr.x,Pr.y,Pr.z),f.push(Dr.x,Dr.y,Dr.z)}this.setAttribute("position",new kt(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class qt extends yn{constructor(e=1,t=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:s};const r=e/2,o=t/2,a=Math.floor(i),l=Math.floor(s),c=a+1,d=l+1,u=e/a,h=t/l,f=[],g=[],_=[],m=[];for(let p=0;p<d;p++){const b=p*h-o;for(let y=0;y<c;y++){const S=y*u-r;g.push(S,-b,0),_.push(0,0,1),m.push(y/a),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let b=0;b<a;b++){const y=b+c*p,S=b+c*(p+1),C=b+1+c*(p+1),T=b+1+c*p;f.push(y,S,T),f.push(S,C,T)}this.setIndex(f),this.setAttribute("position",new kt(g,3)),this.setAttribute("normal",new kt(_,3)),this.setAttribute("uv",new kt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qt(e.width,e.height,e.widthSegments,e.heightSegments)}}class km extends yn{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,s=new P,r=new P;if(e.index!==null){const o=e.attributes.position,a=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,d=l.length;c<d;++c){const u=l[c],h=u.start,f=u.count;for(let g=h,_=h+f;g<_;g+=3)for(let m=0;m<3;m++){const p=a.getX(g+m),b=a.getX(g+(m+1)%3);s.fromBufferAttribute(o,p),r.fromBufferAttribute(o,b),Wc(s,r,i)===!0&&(t.push(s.x,s.y,s.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const d=3*a+c,u=3*a+(c+1)%3;s.fromBufferAttribute(o,d),r.fromBufferAttribute(o,u),Wc(s,r,i)===!0&&(t.push(s.x,s.y,s.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new kt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Wc(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,s=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(s)===!0?!1:(t.add(i),t.add(s),!0)}class Hm extends tr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Np,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Gm extends tr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const Xc={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class Du{constructor(e,t,i){const s=this;let r=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(d){a++,r===!1&&s.onStart!==void 0&&s.onStart(d,o,a),r=!0},this.itemEnd=function(d){o++,s.onProgress!==void 0&&s.onProgress(d,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(d){s.onError!==void 0&&s.onError(d)},this.resolveURL=function(d){return l?l(d):d},this.setURLModifier=function(d){return l=d,this},this.addHandler=function(d,u){return c.push(d,u),this},this.removeHandler=function(d){const u=c.indexOf(d);return u!==-1&&c.splice(u,2),this},this.getHandler=function(d){for(let u=0,h=c.length;u<h;u+=2){const f=c[u],g=c[u+1];if(f.global&&(f.lastIndex=0),f.test(d))return g}return null}}}const Vm=new Du;class Xl{constructor(e){this.manager=e!==void 0?e:Vm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(s,r){i.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Xl.DEFAULT_MATERIAL_NAME="__DEFAULT";class Wm extends Xl{constructor(e){super(e)}load(e,t,i,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Xc.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=Qs("img");function l(){d(),Xc.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(u){d(),s&&s(u),r.manager.itemError(e),r.manager.itemEnd(e)}function d(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class wo extends Xl{constructor(e){super(e)}load(e,t,i,s){const r=new Tt,o=new Wm(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},i,s),r}}class Xm extends Yt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ze(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Lu extends wu{constructor(e=-1,t=1,i=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,o=i+e,a=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=d*this.view.offsetY,l=a-d*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Ym extends Xm{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class qm extends yn{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class jm extends vn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class El extends Um{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}const Yc=new pt;class $m{constructor(e,t,i=0,s=1/0){this.ray=new bo(e,t),this.near=i,this.far=s,this.camera=null,this.layers=new Gl,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Yc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Yc),this}intersectObject(e,t=!0,i=[]){return bl(e,this,i,t),i.sort(qc),i}intersectObjects(e,t=!0,i=[]){for(let s=0,r=e.length;s<r;s++)bl(e[s],this,i,t);return i.sort(qc),i}}function qc(n,e){return n.distance-e.distance}function bl(n,e,t,i){let s=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(s=!1),s===!0&&i===!0){const r=n.children;for(let o=0,a=r.length;o<a;o++)bl(r[o],e,t,!0)}}class jc{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Be(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Be(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const $c=new P,Ir=new P;class Zm{constructor(e=new P,t=new P){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){$c.subVectors(e,this.start),Ir.subVectors(this.end,this.start);const i=Ir.dot(Ir);let r=Ir.dot($c)/i;return t&&(r=Be(r,0,1)),r}closestPointToPoint(e,t,i){const s=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(s).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)}}class Km extends Wi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}function Zc(n,e,t,i){const s=Jm(i);switch(t){case cu:return n*e;case uu:return n*e;case hu:return n*e*2;case fu:return n*e/s.components*s.byteLength;case Bl:return n*e/s.components*s.byteLength;case pu:return n*e*2/s.components*s.byteLength;case zl:return n*e*2/s.components*s.byteLength;case du:return n*e*3/s.components*s.byteLength;case Ln:return n*e*4/s.components*s.byteLength;case kl:return n*e*4/s.components*s.byteLength;case Jr:case Qr:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case eo:case to:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ka:case Qa:return Math.max(n,16)*Math.max(e,8)/4;case Za:case Ja:return Math.max(n,8)*Math.max(e,8)/2;case el:case tl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case nl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case il:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case sl:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case rl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case ol:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case al:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case ll:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case cl:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case dl:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case ul:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case hl:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case fl:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case pl:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case ml:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case gl:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case no:case _l:case vl:return Math.ceil(n/4)*Math.ceil(e/4)*16;case mu:case xl:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Sl:case yl:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jm(n){switch(n){case ti:case ou:return{byteLength:1,components:1};case Ks:case au:case er:return{byteLength:2,components:1};case Ol:case Fl:return{byteLength:2,components:4};case ki:case Nl:case Zn:return{byteLength:4,components:1};case lu:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ul}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ul);/**
  29. * @license
  30. * Copyright 2010-2024 Three.js Authors
  31. * SPDX-License-Identifier: MIT
  32. */function Iu(){let n=null,e=!1,t=null,i=null;function s(r,o){t(r,o),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function Qm(n){const e=new WeakMap;function t(a,l){const c=a.array,d=a.usage,u=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,d),a.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:u}}function i(a,l,c){const d=l.array,u=l.updateRanges;if(n.bindBuffer(c,a),u.length===0)n.bufferSubData(c,0,d);else{u.sort((f,g)=>f.start-g.start);let h=0;for(let f=1;f<u.length;f++){const g=u[h],_=u[f];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++h,u[h]=_)}u.length=h+1;for(let f=0,g=u.length;f<g;f++){const _=u[f];n.bufferSubData(c,_.start*d.BYTES_PER_ELEMENT,d,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=e.get(a);l&&(n.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const d=e.get(a);(!d||d.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,a,l),c.version=a.version}}return{get:s,remove:r,update:o}}var eg=`#ifdef USE_ALPHAHASH
  33. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  34. #endif`,tg=`#ifdef USE_ALPHAHASH
  35. const float ALPHA_HASH_SCALE = 0.05;
  36. float hash2D( vec2 value ) {
  37. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  38. }
  39. float hash3D( vec3 value ) {
  40. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  41. }
  42. float getAlphaHashThreshold( vec3 position ) {
  43. float maxDeriv = max(
  44. length( dFdx( position.xyz ) ),
  45. length( dFdy( position.xyz ) )
  46. );
  47. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  48. vec2 pixScales = vec2(
  49. exp2( floor( log2( pixScale ) ) ),
  50. exp2( ceil( log2( pixScale ) ) )
  51. );
  52. vec2 alpha = vec2(
  53. hash3D( floor( pixScales.x * position.xyz ) ),
  54. hash3D( floor( pixScales.y * position.xyz ) )
  55. );
  56. float lerpFactor = fract( log2( pixScale ) );
  57. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  58. float a = min( lerpFactor, 1.0 - lerpFactor );
  59. vec3 cases = vec3(
  60. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  61. ( x - 0.5 * a ) / ( 1.0 - a ),
  62. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  63. );
  64. float threshold = ( x < ( 1.0 - a ) )
  65. ? ( ( x < a ) ? cases.x : cases.y )
  66. : cases.z;
  67. return clamp( threshold , 1.0e-6, 1.0 );
  68. }
  69. #endif`,ng=`#ifdef USE_ALPHAMAP
  70. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  71. #endif`,ig=`#ifdef USE_ALPHAMAP
  72. uniform sampler2D alphaMap;
  73. #endif`,sg=`#ifdef USE_ALPHATEST
  74. #ifdef ALPHA_TO_COVERAGE
  75. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  76. if ( diffuseColor.a == 0.0 ) discard;
  77. #else
  78. if ( diffuseColor.a < alphaTest ) discard;
  79. #endif
  80. #endif`,rg=`#ifdef USE_ALPHATEST
  81. uniform float alphaTest;
  82. #endif`,og=`#ifdef USE_AOMAP
  83. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  84. reflectedLight.indirectDiffuse *= ambientOcclusion;
  85. #if defined( USE_CLEARCOAT )
  86. clearcoatSpecularIndirect *= ambientOcclusion;
  87. #endif
  88. #if defined( USE_SHEEN )
  89. sheenSpecularIndirect *= ambientOcclusion;
  90. #endif
  91. #if defined( USE_ENVMAP ) && defined( STANDARD )
  92. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  93. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  94. #endif
  95. #endif`,ag=`#ifdef USE_AOMAP
  96. uniform sampler2D aoMap;
  97. uniform float aoMapIntensity;
  98. #endif`,lg=`#ifdef USE_BATCHING
  99. #if ! defined( GL_ANGLE_multi_draw )
  100. #define gl_DrawID _gl_DrawID
  101. uniform int _gl_DrawID;
  102. #endif
  103. uniform highp sampler2D batchingTexture;
  104. uniform highp usampler2D batchingIdTexture;
  105. mat4 getBatchingMatrix( const in float i ) {
  106. int size = textureSize( batchingTexture, 0 ).x;
  107. int j = int( i ) * 4;
  108. int x = j % size;
  109. int y = j / size;
  110. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  111. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  112. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  113. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  114. return mat4( v1, v2, v3, v4 );
  115. }
  116. float getIndirectIndex( const in int i ) {
  117. int size = textureSize( batchingIdTexture, 0 ).x;
  118. int x = i % size;
  119. int y = i / size;
  120. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  121. }
  122. #endif
  123. #ifdef USE_BATCHING_COLOR
  124. uniform sampler2D batchingColorTexture;
  125. vec3 getBatchingColor( const in float i ) {
  126. int size = textureSize( batchingColorTexture, 0 ).x;
  127. int j = int( i );
  128. int x = j % size;
  129. int y = j / size;
  130. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  131. }
  132. #endif`,cg=`#ifdef USE_BATCHING
  133. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  134. #endif`,dg=`vec3 transformed = vec3( position );
  135. #ifdef USE_ALPHAHASH
  136. vPosition = vec3( position );
  137. #endif`,ug=`vec3 objectNormal = vec3( normal );
  138. #ifdef USE_TANGENT
  139. vec3 objectTangent = vec3( tangent.xyz );
  140. #endif`,hg=`float G_BlinnPhong_Implicit( ) {
  141. return 0.25;
  142. }
  143. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  144. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  145. }
  146. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  147. vec3 halfDir = normalize( lightDir + viewDir );
  148. float dotNH = saturate( dot( normal, halfDir ) );
  149. float dotVH = saturate( dot( viewDir, halfDir ) );
  150. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  151. float G = G_BlinnPhong_Implicit( );
  152. float D = D_BlinnPhong( shininess, dotNH );
  153. return F * ( G * D );
  154. } // validated`,fg=`#ifdef USE_IRIDESCENCE
  155. const mat3 XYZ_TO_REC709 = mat3(
  156. 3.2404542, -0.9692660, 0.0556434,
  157. -1.5371385, 1.8760108, -0.2040259,
  158. -0.4985314, 0.0415560, 1.0572252
  159. );
  160. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  161. vec3 sqrtF0 = sqrt( fresnel0 );
  162. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  163. }
  164. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  165. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  166. }
  167. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  168. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  169. }
  170. vec3 evalSensitivity( float OPD, vec3 shift ) {
  171. float phase = 2.0 * PI * OPD * 1.0e-9;
  172. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  173. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  174. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  175. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  176. 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 ) );
  177. xyz /= 1.0685e-7;
  178. vec3 rgb = XYZ_TO_REC709 * xyz;
  179. return rgb;
  180. }
  181. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  182. vec3 I;
  183. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  184. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  185. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  186. if ( cosTheta2Sq < 0.0 ) {
  187. return vec3( 1.0 );
  188. }
  189. float cosTheta2 = sqrt( cosTheta2Sq );
  190. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  191. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  192. float T121 = 1.0 - R12;
  193. float phi12 = 0.0;
  194. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  195. float phi21 = PI - phi12;
  196. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  197. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  198. vec3 phi23 = vec3( 0.0 );
  199. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  200. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  201. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  202. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  203. vec3 phi = vec3( phi21 ) + phi23;
  204. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  205. vec3 r123 = sqrt( R123 );
  206. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  207. vec3 C0 = R12 + Rs;
  208. I = C0;
  209. vec3 Cm = Rs - T121;
  210. for ( int m = 1; m <= 2; ++ m ) {
  211. Cm *= r123;
  212. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  213. I += Cm * Sm;
  214. }
  215. return max( I, vec3( 0.0 ) );
  216. }
  217. #endif`,pg=`#ifdef USE_BUMPMAP
  218. uniform sampler2D bumpMap;
  219. uniform float bumpScale;
  220. vec2 dHdxy_fwd() {
  221. vec2 dSTdx = dFdx( vBumpMapUv );
  222. vec2 dSTdy = dFdy( vBumpMapUv );
  223. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  224. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  225. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  226. return vec2( dBx, dBy );
  227. }
  228. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  229. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  230. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  231. vec3 vN = surf_norm;
  232. vec3 R1 = cross( vSigmaY, vN );
  233. vec3 R2 = cross( vN, vSigmaX );
  234. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  235. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  236. return normalize( abs( fDet ) * surf_norm - vGrad );
  237. }
  238. #endif`,mg=`#if NUM_CLIPPING_PLANES > 0
  239. vec4 plane;
  240. #ifdef ALPHA_TO_COVERAGE
  241. float distanceToPlane, distanceGradient;
  242. float clipOpacity = 1.0;
  243. #pragma unroll_loop_start
  244. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  245. plane = clippingPlanes[ i ];
  246. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  247. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  248. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  249. if ( clipOpacity == 0.0 ) discard;
  250. }
  251. #pragma unroll_loop_end
  252. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  253. float unionClipOpacity = 1.0;
  254. #pragma unroll_loop_start
  255. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  256. plane = clippingPlanes[ i ];
  257. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  258. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  259. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  260. }
  261. #pragma unroll_loop_end
  262. clipOpacity *= 1.0 - unionClipOpacity;
  263. #endif
  264. diffuseColor.a *= clipOpacity;
  265. if ( diffuseColor.a == 0.0 ) discard;
  266. #else
  267. #pragma unroll_loop_start
  268. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  269. plane = clippingPlanes[ i ];
  270. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  271. }
  272. #pragma unroll_loop_end
  273. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  274. bool clipped = true;
  275. #pragma unroll_loop_start
  276. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  277. plane = clippingPlanes[ i ];
  278. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  279. }
  280. #pragma unroll_loop_end
  281. if ( clipped ) discard;
  282. #endif
  283. #endif
  284. #endif`,gg=`#if NUM_CLIPPING_PLANES > 0
  285. varying vec3 vClipPosition;
  286. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  287. #endif`,_g=`#if NUM_CLIPPING_PLANES > 0
  288. varying vec3 vClipPosition;
  289. #endif`,vg=`#if NUM_CLIPPING_PLANES > 0
  290. vClipPosition = - mvPosition.xyz;
  291. #endif`,xg=`#if defined( USE_COLOR_ALPHA )
  292. diffuseColor *= vColor;
  293. #elif defined( USE_COLOR )
  294. diffuseColor.rgb *= vColor;
  295. #endif`,Sg=`#if defined( USE_COLOR_ALPHA )
  296. varying vec4 vColor;
  297. #elif defined( USE_COLOR )
  298. varying vec3 vColor;
  299. #endif`,yg=`#if defined( USE_COLOR_ALPHA )
  300. varying vec4 vColor;
  301. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  302. varying vec3 vColor;
  303. #endif`,Mg=`#if defined( USE_COLOR_ALPHA )
  304. vColor = vec4( 1.0 );
  305. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  306. vColor = vec3( 1.0 );
  307. #endif
  308. #ifdef USE_COLOR
  309. vColor *= color;
  310. #endif
  311. #ifdef USE_INSTANCING_COLOR
  312. vColor.xyz *= instanceColor.xyz;
  313. #endif
  314. #ifdef USE_BATCHING_COLOR
  315. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  316. vColor.xyz *= batchingColor.xyz;
  317. #endif`,Eg=`#define PI 3.141592653589793
  318. #define PI2 6.283185307179586
  319. #define PI_HALF 1.5707963267948966
  320. #define RECIPROCAL_PI 0.3183098861837907
  321. #define RECIPROCAL_PI2 0.15915494309189535
  322. #define EPSILON 1e-6
  323. #ifndef saturate
  324. #define saturate( a ) clamp( a, 0.0, 1.0 )
  325. #endif
  326. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  327. float pow2( const in float x ) { return x*x; }
  328. vec3 pow2( const in vec3 x ) { return x*x; }
  329. float pow3( const in float x ) { return x*x*x; }
  330. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  331. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  332. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  333. highp float rand( const in vec2 uv ) {
  334. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  335. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  336. return fract( sin( sn ) * c );
  337. }
  338. #ifdef HIGH_PRECISION
  339. float precisionSafeLength( vec3 v ) { return length( v ); }
  340. #else
  341. float precisionSafeLength( vec3 v ) {
  342. float maxComponent = max3( abs( v ) );
  343. return length( v / maxComponent ) * maxComponent;
  344. }
  345. #endif
  346. struct IncidentLight {
  347. vec3 color;
  348. vec3 direction;
  349. bool visible;
  350. };
  351. struct ReflectedLight {
  352. vec3 directDiffuse;
  353. vec3 directSpecular;
  354. vec3 indirectDiffuse;
  355. vec3 indirectSpecular;
  356. };
  357. #ifdef USE_ALPHAHASH
  358. varying vec3 vPosition;
  359. #endif
  360. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  361. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  362. }
  363. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  364. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  365. }
  366. mat3 transposeMat3( const in mat3 m ) {
  367. mat3 tmp;
  368. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  369. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  370. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  371. return tmp;
  372. }
  373. bool isPerspectiveMatrix( mat4 m ) {
  374. return m[ 2 ][ 3 ] == - 1.0;
  375. }
  376. vec2 equirectUv( in vec3 dir ) {
  377. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  378. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  379. return vec2( u, v );
  380. }
  381. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  382. return RECIPROCAL_PI * diffuseColor;
  383. }
  384. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  385. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  386. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  387. }
  388. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  389. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  390. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  391. } // validated`,bg=`#ifdef ENVMAP_TYPE_CUBE_UV
  392. #define cubeUV_minMipLevel 4.0
  393. #define cubeUV_minTileSize 16.0
  394. float getFace( vec3 direction ) {
  395. vec3 absDirection = abs( direction );
  396. float face = - 1.0;
  397. if ( absDirection.x > absDirection.z ) {
  398. if ( absDirection.x > absDirection.y )
  399. face = direction.x > 0.0 ? 0.0 : 3.0;
  400. else
  401. face = direction.y > 0.0 ? 1.0 : 4.0;
  402. } else {
  403. if ( absDirection.z > absDirection.y )
  404. face = direction.z > 0.0 ? 2.0 : 5.0;
  405. else
  406. face = direction.y > 0.0 ? 1.0 : 4.0;
  407. }
  408. return face;
  409. }
  410. vec2 getUV( vec3 direction, float face ) {
  411. vec2 uv;
  412. if ( face == 0.0 ) {
  413. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  414. } else if ( face == 1.0 ) {
  415. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  416. } else if ( face == 2.0 ) {
  417. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  418. } else if ( face == 3.0 ) {
  419. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  420. } else if ( face == 4.0 ) {
  421. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  422. } else {
  423. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  424. }
  425. return 0.5 * ( uv + 1.0 );
  426. }
  427. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  428. float face = getFace( direction );
  429. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  430. mipInt = max( mipInt, cubeUV_minMipLevel );
  431. float faceSize = exp2( mipInt );
  432. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  433. if ( face > 2.0 ) {
  434. uv.y += faceSize;
  435. face -= 3.0;
  436. }
  437. uv.x += face * faceSize;
  438. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  439. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  440. uv.x *= CUBEUV_TEXEL_WIDTH;
  441. uv.y *= CUBEUV_TEXEL_HEIGHT;
  442. #ifdef texture2DGradEXT
  443. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  444. #else
  445. return texture2D( envMap, uv ).rgb;
  446. #endif
  447. }
  448. #define cubeUV_r0 1.0
  449. #define cubeUV_m0 - 2.0
  450. #define cubeUV_r1 0.8
  451. #define cubeUV_m1 - 1.0
  452. #define cubeUV_r4 0.4
  453. #define cubeUV_m4 2.0
  454. #define cubeUV_r5 0.305
  455. #define cubeUV_m5 3.0
  456. #define cubeUV_r6 0.21
  457. #define cubeUV_m6 4.0
  458. float roughnessToMip( float roughness ) {
  459. float mip = 0.0;
  460. if ( roughness >= cubeUV_r1 ) {
  461. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  462. } else if ( roughness >= cubeUV_r4 ) {
  463. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  464. } else if ( roughness >= cubeUV_r5 ) {
  465. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  466. } else if ( roughness >= cubeUV_r6 ) {
  467. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  468. } else {
  469. mip = - 2.0 * log2( 1.16 * roughness ); }
  470. return mip;
  471. }
  472. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  473. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  474. float mipF = fract( mip );
  475. float mipInt = floor( mip );
  476. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  477. if ( mipF == 0.0 ) {
  478. return vec4( color0, 1.0 );
  479. } else {
  480. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  481. return vec4( mix( color0, color1, mipF ), 1.0 );
  482. }
  483. }
  484. #endif`,wg=`vec3 transformedNormal = objectNormal;
  485. #ifdef USE_TANGENT
  486. vec3 transformedTangent = objectTangent;
  487. #endif
  488. #ifdef USE_BATCHING
  489. mat3 bm = mat3( batchingMatrix );
  490. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  491. transformedNormal = bm * transformedNormal;
  492. #ifdef USE_TANGENT
  493. transformedTangent = bm * transformedTangent;
  494. #endif
  495. #endif
  496. #ifdef USE_INSTANCING
  497. mat3 im = mat3( instanceMatrix );
  498. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  499. transformedNormal = im * transformedNormal;
  500. #ifdef USE_TANGENT
  501. transformedTangent = im * transformedTangent;
  502. #endif
  503. #endif
  504. transformedNormal = normalMatrix * transformedNormal;
  505. #ifdef FLIP_SIDED
  506. transformedNormal = - transformedNormal;
  507. #endif
  508. #ifdef USE_TANGENT
  509. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  510. #ifdef FLIP_SIDED
  511. transformedTangent = - transformedTangent;
  512. #endif
  513. #endif`,Tg=`#ifdef USE_DISPLACEMENTMAP
  514. uniform sampler2D displacementMap;
  515. uniform float displacementScale;
  516. uniform float displacementBias;
  517. #endif`,Ag=`#ifdef USE_DISPLACEMENTMAP
  518. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  519. #endif`,Cg=`#ifdef USE_EMISSIVEMAP
  520. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  521. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  522. emissiveColor = sRGBTransferEOTF( emissiveColor );
  523. #endif
  524. totalEmissiveRadiance *= emissiveColor.rgb;
  525. #endif`,Rg=`#ifdef USE_EMISSIVEMAP
  526. uniform sampler2D emissiveMap;
  527. #endif`,Pg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) {
  528. return value;
  529. }
  530. vec4 sRGBTransferEOTF( in vec4 value ) {
  531. 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 );
  532. }
  533. vec4 sRGBTransferOETF( in vec4 value ) {
  534. 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 );
  535. }`,Lg=`#ifdef USE_ENVMAP
  536. #ifdef ENV_WORLDPOS
  537. vec3 cameraToFrag;
  538. if ( isOrthographic ) {
  539. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  540. } else {
  541. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  542. }
  543. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  544. #ifdef ENVMAP_MODE_REFLECTION
  545. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  546. #else
  547. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  548. #endif
  549. #else
  550. vec3 reflectVec = vReflect;
  551. #endif
  552. #ifdef ENVMAP_TYPE_CUBE
  553. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  554. #else
  555. vec4 envColor = vec4( 0.0 );
  556. #endif
  557. #ifdef ENVMAP_BLENDING_MULTIPLY
  558. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  559. #elif defined( ENVMAP_BLENDING_MIX )
  560. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  561. #elif defined( ENVMAP_BLENDING_ADD )
  562. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  563. #endif
  564. #endif`,Ig=`#ifdef USE_ENVMAP
  565. uniform float envMapIntensity;
  566. uniform float flipEnvMap;
  567. uniform mat3 envMapRotation;
  568. #ifdef ENVMAP_TYPE_CUBE
  569. uniform samplerCube envMap;
  570. #else
  571. uniform sampler2D envMap;
  572. #endif
  573. #endif`,Ug=`#ifdef USE_ENVMAP
  574. uniform float reflectivity;
  575. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  576. #define ENV_WORLDPOS
  577. #endif
  578. #ifdef ENV_WORLDPOS
  579. varying vec3 vWorldPosition;
  580. uniform float refractionRatio;
  581. #else
  582. varying vec3 vReflect;
  583. #endif
  584. #endif`,Ng=`#ifdef USE_ENVMAP
  585. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  586. #define ENV_WORLDPOS
  587. #endif
  588. #ifdef ENV_WORLDPOS
  589. varying vec3 vWorldPosition;
  590. #else
  591. varying vec3 vReflect;
  592. uniform float refractionRatio;
  593. #endif
  594. #endif`,Og=`#ifdef USE_ENVMAP
  595. #ifdef ENV_WORLDPOS
  596. vWorldPosition = worldPosition.xyz;
  597. #else
  598. vec3 cameraToVertex;
  599. if ( isOrthographic ) {
  600. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  601. } else {
  602. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  603. }
  604. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  605. #ifdef ENVMAP_MODE_REFLECTION
  606. vReflect = reflect( cameraToVertex, worldNormal );
  607. #else
  608. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  609. #endif
  610. #endif
  611. #endif`,Fg=`#ifdef USE_FOG
  612. vFogDepth = - mvPosition.z;
  613. #endif`,Bg=`#ifdef USE_FOG
  614. varying float vFogDepth;
  615. #endif`,zg=`#ifdef USE_FOG
  616. #ifdef FOG_EXP2
  617. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  618. #else
  619. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  620. #endif
  621. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  622. #endif`,kg=`#ifdef USE_FOG
  623. uniform vec3 fogColor;
  624. varying float vFogDepth;
  625. #ifdef FOG_EXP2
  626. uniform float fogDensity;
  627. #else
  628. uniform float fogNear;
  629. uniform float fogFar;
  630. #endif
  631. #endif`,Hg=`#ifdef USE_GRADIENTMAP
  632. uniform sampler2D gradientMap;
  633. #endif
  634. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  635. float dotNL = dot( normal, lightDirection );
  636. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  637. #ifdef USE_GRADIENTMAP
  638. return vec3( texture2D( gradientMap, coord ).r );
  639. #else
  640. vec2 fw = fwidth( coord ) * 0.5;
  641. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  642. #endif
  643. }`,Gg=`#ifdef USE_LIGHTMAP
  644. uniform sampler2D lightMap;
  645. uniform float lightMapIntensity;
  646. #endif`,Vg=`LambertMaterial material;
  647. material.diffuseColor = diffuseColor.rgb;
  648. material.specularStrength = specularStrength;`,Wg=`varying vec3 vViewPosition;
  649. struct LambertMaterial {
  650. vec3 diffuseColor;
  651. float specularStrength;
  652. };
  653. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  654. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  655. vec3 irradiance = dotNL * directLight.color;
  656. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  657. }
  658. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  659. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  660. }
  661. #define RE_Direct RE_Direct_Lambert
  662. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Xg=`uniform bool receiveShadow;
  663. uniform vec3 ambientLightColor;
  664. #if defined( USE_LIGHT_PROBES )
  665. uniform vec3 lightProbe[ 9 ];
  666. #endif
  667. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  668. float x = normal.x, y = normal.y, z = normal.z;
  669. vec3 result = shCoefficients[ 0 ] * 0.886227;
  670. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  671. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  672. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  673. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  674. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  675. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  676. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  677. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  678. return result;
  679. }
  680. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  681. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  682. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  683. return irradiance;
  684. }
  685. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  686. vec3 irradiance = ambientLightColor;
  687. return irradiance;
  688. }
  689. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  690. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  691. if ( cutoffDistance > 0.0 ) {
  692. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  693. }
  694. return distanceFalloff;
  695. }
  696. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  697. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  698. }
  699. #if NUM_DIR_LIGHTS > 0
  700. struct DirectionalLight {
  701. vec3 direction;
  702. vec3 color;
  703. };
  704. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  705. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  706. light.color = directionalLight.color;
  707. light.direction = directionalLight.direction;
  708. light.visible = true;
  709. }
  710. #endif
  711. #if NUM_POINT_LIGHTS > 0
  712. struct PointLight {
  713. vec3 position;
  714. vec3 color;
  715. float distance;
  716. float decay;
  717. };
  718. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  719. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  720. vec3 lVector = pointLight.position - geometryPosition;
  721. light.direction = normalize( lVector );
  722. float lightDistance = length( lVector );
  723. light.color = pointLight.color;
  724. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  725. light.visible = ( light.color != vec3( 0.0 ) );
  726. }
  727. #endif
  728. #if NUM_SPOT_LIGHTS > 0
  729. struct SpotLight {
  730. vec3 position;
  731. vec3 direction;
  732. vec3 color;
  733. float distance;
  734. float decay;
  735. float coneCos;
  736. float penumbraCos;
  737. };
  738. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  739. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  740. vec3 lVector = spotLight.position - geometryPosition;
  741. light.direction = normalize( lVector );
  742. float angleCos = dot( light.direction, spotLight.direction );
  743. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  744. if ( spotAttenuation > 0.0 ) {
  745. float lightDistance = length( lVector );
  746. light.color = spotLight.color * spotAttenuation;
  747. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  748. light.visible = ( light.color != vec3( 0.0 ) );
  749. } else {
  750. light.color = vec3( 0.0 );
  751. light.visible = false;
  752. }
  753. }
  754. #endif
  755. #if NUM_RECT_AREA_LIGHTS > 0
  756. struct RectAreaLight {
  757. vec3 color;
  758. vec3 position;
  759. vec3 halfWidth;
  760. vec3 halfHeight;
  761. };
  762. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  763. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  764. #endif
  765. #if NUM_HEMI_LIGHTS > 0
  766. struct HemisphereLight {
  767. vec3 direction;
  768. vec3 skyColor;
  769. vec3 groundColor;
  770. };
  771. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  772. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  773. float dotNL = dot( normal, hemiLight.direction );
  774. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  775. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  776. return irradiance;
  777. }
  778. #endif`,Yg=`#ifdef USE_ENVMAP
  779. vec3 getIBLIrradiance( const in vec3 normal ) {
  780. #ifdef ENVMAP_TYPE_CUBE_UV
  781. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  782. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  783. return PI * envMapColor.rgb * envMapIntensity;
  784. #else
  785. return vec3( 0.0 );
  786. #endif
  787. }
  788. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  789. #ifdef ENVMAP_TYPE_CUBE_UV
  790. vec3 reflectVec = reflect( - viewDir, normal );
  791. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  792. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  793. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  794. return envMapColor.rgb * envMapIntensity;
  795. #else
  796. return vec3( 0.0 );
  797. #endif
  798. }
  799. #ifdef USE_ANISOTROPY
  800. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  801. #ifdef ENVMAP_TYPE_CUBE_UV
  802. vec3 bentNormal = cross( bitangent, viewDir );
  803. bentNormal = normalize( cross( bentNormal, bitangent ) );
  804. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  805. return getIBLRadiance( viewDir, bentNormal, roughness );
  806. #else
  807. return vec3( 0.0 );
  808. #endif
  809. }
  810. #endif
  811. #endif`,qg=`ToonMaterial material;
  812. material.diffuseColor = diffuseColor.rgb;`,jg=`varying vec3 vViewPosition;
  813. struct ToonMaterial {
  814. vec3 diffuseColor;
  815. };
  816. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  817. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  818. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  819. }
  820. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  821. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  822. }
  823. #define RE_Direct RE_Direct_Toon
  824. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,$g=`BlinnPhongMaterial material;
  825. material.diffuseColor = diffuseColor.rgb;
  826. material.specularColor = specular;
  827. material.specularShininess = shininess;
  828. material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition;
  829. struct BlinnPhongMaterial {
  830. vec3 diffuseColor;
  831. vec3 specularColor;
  832. float specularShininess;
  833. float specularStrength;
  834. };
  835. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  836. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  837. vec3 irradiance = dotNL * directLight.color;
  838. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  839. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  840. }
  841. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  842. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  843. }
  844. #define RE_Direct RE_Direct_BlinnPhong
  845. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Kg=`PhysicalMaterial material;
  846. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  847. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  848. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  849. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  850. material.roughness = min( material.roughness, 1.0 );
  851. #ifdef IOR
  852. material.ior = ior;
  853. #ifdef USE_SPECULAR
  854. float specularIntensityFactor = specularIntensity;
  855. vec3 specularColorFactor = specularColor;
  856. #ifdef USE_SPECULAR_COLORMAP
  857. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  858. #endif
  859. #ifdef USE_SPECULAR_INTENSITYMAP
  860. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  861. #endif
  862. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  863. #else
  864. float specularIntensityFactor = 1.0;
  865. vec3 specularColorFactor = vec3( 1.0 );
  866. material.specularF90 = 1.0;
  867. #endif
  868. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  869. #else
  870. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  871. material.specularF90 = 1.0;
  872. #endif
  873. #ifdef USE_CLEARCOAT
  874. material.clearcoat = clearcoat;
  875. material.clearcoatRoughness = clearcoatRoughness;
  876. material.clearcoatF0 = vec3( 0.04 );
  877. material.clearcoatF90 = 1.0;
  878. #ifdef USE_CLEARCOATMAP
  879. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  880. #endif
  881. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  882. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  883. #endif
  884. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  885. material.clearcoatRoughness += geometryRoughness;
  886. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  887. #endif
  888. #ifdef USE_DISPERSION
  889. material.dispersion = dispersion;
  890. #endif
  891. #ifdef USE_IRIDESCENCE
  892. material.iridescence = iridescence;
  893. material.iridescenceIOR = iridescenceIOR;
  894. #ifdef USE_IRIDESCENCEMAP
  895. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  896. #endif
  897. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  898. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  899. #else
  900. material.iridescenceThickness = iridescenceThicknessMaximum;
  901. #endif
  902. #endif
  903. #ifdef USE_SHEEN
  904. material.sheenColor = sheenColor;
  905. #ifdef USE_SHEEN_COLORMAP
  906. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  907. #endif
  908. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  909. #ifdef USE_SHEEN_ROUGHNESSMAP
  910. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  911. #endif
  912. #endif
  913. #ifdef USE_ANISOTROPY
  914. #ifdef USE_ANISOTROPYMAP
  915. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  916. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  917. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  918. #else
  919. vec2 anisotropyV = anisotropyVector;
  920. #endif
  921. material.anisotropy = length( anisotropyV );
  922. if( material.anisotropy == 0.0 ) {
  923. anisotropyV = vec2( 1.0, 0.0 );
  924. } else {
  925. anisotropyV /= material.anisotropy;
  926. material.anisotropy = saturate( material.anisotropy );
  927. }
  928. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  929. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  930. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  931. #endif`,Jg=`struct PhysicalMaterial {
  932. vec3 diffuseColor;
  933. float roughness;
  934. vec3 specularColor;
  935. float specularF90;
  936. float dispersion;
  937. #ifdef USE_CLEARCOAT
  938. float clearcoat;
  939. float clearcoatRoughness;
  940. vec3 clearcoatF0;
  941. float clearcoatF90;
  942. #endif
  943. #ifdef USE_IRIDESCENCE
  944. float iridescence;
  945. float iridescenceIOR;
  946. float iridescenceThickness;
  947. vec3 iridescenceFresnel;
  948. vec3 iridescenceF0;
  949. #endif
  950. #ifdef USE_SHEEN
  951. vec3 sheenColor;
  952. float sheenRoughness;
  953. #endif
  954. #ifdef IOR
  955. float ior;
  956. #endif
  957. #ifdef USE_TRANSMISSION
  958. float transmission;
  959. float transmissionAlpha;
  960. float thickness;
  961. float attenuationDistance;
  962. vec3 attenuationColor;
  963. #endif
  964. #ifdef USE_ANISOTROPY
  965. float anisotropy;
  966. float alphaT;
  967. vec3 anisotropyT;
  968. vec3 anisotropyB;
  969. #endif
  970. };
  971. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  972. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  973. vec3 sheenSpecularDirect = vec3( 0.0 );
  974. vec3 sheenSpecularIndirect = vec3(0.0 );
  975. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  976. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  977. float x2 = x * x;
  978. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  979. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  980. }
  981. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  982. float a2 = pow2( alpha );
  983. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  984. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  985. return 0.5 / max( gv + gl, EPSILON );
  986. }
  987. float D_GGX( const in float alpha, const in float dotNH ) {
  988. float a2 = pow2( alpha );
  989. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  990. return RECIPROCAL_PI * a2 / pow2( denom );
  991. }
  992. #ifdef USE_ANISOTROPY
  993. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  994. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  995. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  996. float v = 0.5 / ( gv + gl );
  997. return saturate(v);
  998. }
  999. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1000. float a2 = alphaT * alphaB;
  1001. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1002. highp float v2 = dot( v, v );
  1003. float w2 = a2 / v2;
  1004. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1005. }
  1006. #endif
  1007. #ifdef USE_CLEARCOAT
  1008. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1009. vec3 f0 = material.clearcoatF0;
  1010. float f90 = material.clearcoatF90;
  1011. float roughness = material.clearcoatRoughness;
  1012. float alpha = pow2( roughness );
  1013. vec3 halfDir = normalize( lightDir + viewDir );
  1014. float dotNL = saturate( dot( normal, lightDir ) );
  1015. float dotNV = saturate( dot( normal, viewDir ) );
  1016. float dotNH = saturate( dot( normal, halfDir ) );
  1017. float dotVH = saturate( dot( viewDir, halfDir ) );
  1018. vec3 F = F_Schlick( f0, f90, dotVH );
  1019. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1020. float D = D_GGX( alpha, dotNH );
  1021. return F * ( V * D );
  1022. }
  1023. #endif
  1024. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1025. vec3 f0 = material.specularColor;
  1026. float f90 = material.specularF90;
  1027. float roughness = material.roughness;
  1028. float alpha = pow2( roughness );
  1029. vec3 halfDir = normalize( lightDir + viewDir );
  1030. float dotNL = saturate( dot( normal, lightDir ) );
  1031. float dotNV = saturate( dot( normal, viewDir ) );
  1032. float dotNH = saturate( dot( normal, halfDir ) );
  1033. float dotVH = saturate( dot( viewDir, halfDir ) );
  1034. vec3 F = F_Schlick( f0, f90, dotVH );
  1035. #ifdef USE_IRIDESCENCE
  1036. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1037. #endif
  1038. #ifdef USE_ANISOTROPY
  1039. float dotTL = dot( material.anisotropyT, lightDir );
  1040. float dotTV = dot( material.anisotropyT, viewDir );
  1041. float dotTH = dot( material.anisotropyT, halfDir );
  1042. float dotBL = dot( material.anisotropyB, lightDir );
  1043. float dotBV = dot( material.anisotropyB, viewDir );
  1044. float dotBH = dot( material.anisotropyB, halfDir );
  1045. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1046. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1047. #else
  1048. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1049. float D = D_GGX( alpha, dotNH );
  1050. #endif
  1051. return F * ( V * D );
  1052. }
  1053. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1054. const float LUT_SIZE = 64.0;
  1055. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1056. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1057. float dotNV = saturate( dot( N, V ) );
  1058. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1059. uv = uv * LUT_SCALE + LUT_BIAS;
  1060. return uv;
  1061. }
  1062. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1063. float l = length( f );
  1064. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1065. }
  1066. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1067. float x = dot( v1, v2 );
  1068. float y = abs( x );
  1069. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1070. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1071. float v = a / b;
  1072. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1073. return cross( v1, v2 ) * theta_sintheta;
  1074. }
  1075. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1076. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1077. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1078. vec3 lightNormal = cross( v1, v2 );
  1079. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1080. vec3 T1, T2;
  1081. T1 = normalize( V - N * dot( V, N ) );
  1082. T2 = - cross( N, T1 );
  1083. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  1084. vec3 coords[ 4 ];
  1085. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1086. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1087. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1088. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1089. coords[ 0 ] = normalize( coords[ 0 ] );
  1090. coords[ 1 ] = normalize( coords[ 1 ] );
  1091. coords[ 2 ] = normalize( coords[ 2 ] );
  1092. coords[ 3 ] = normalize( coords[ 3 ] );
  1093. vec3 vectorFormFactor = vec3( 0.0 );
  1094. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1095. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1096. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1097. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1098. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1099. return vec3( result );
  1100. }
  1101. #if defined( USE_SHEEN )
  1102. float D_Charlie( float roughness, float dotNH ) {
  1103. float alpha = pow2( roughness );
  1104. float invAlpha = 1.0 / alpha;
  1105. float cos2h = dotNH * dotNH;
  1106. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1107. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1108. }
  1109. float V_Neubelt( float dotNV, float dotNL ) {
  1110. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1111. }
  1112. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1113. vec3 halfDir = normalize( lightDir + viewDir );
  1114. float dotNL = saturate( dot( normal, lightDir ) );
  1115. float dotNV = saturate( dot( normal, viewDir ) );
  1116. float dotNH = saturate( dot( normal, halfDir ) );
  1117. float D = D_Charlie( sheenRoughness, dotNH );
  1118. float V = V_Neubelt( dotNV, dotNL );
  1119. return sheenColor * ( D * V );
  1120. }
  1121. #endif
  1122. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1123. float dotNV = saturate( dot( normal, viewDir ) );
  1124. float r2 = roughness * roughness;
  1125. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1126. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1127. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1128. return saturate( DG * RECIPROCAL_PI );
  1129. }
  1130. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1131. float dotNV = saturate( dot( normal, viewDir ) );
  1132. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  1133. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  1134. vec4 r = roughness * c0 + c1;
  1135. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  1136. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  1137. return fab;
  1138. }
  1139. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1140. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1141. return specularColor * fab.x + specularF90 * fab.y;
  1142. }
  1143. #ifdef USE_IRIDESCENCE
  1144. 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 ) {
  1145. #else
  1146. 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 ) {
  1147. #endif
  1148. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1149. #ifdef USE_IRIDESCENCE
  1150. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1151. #else
  1152. vec3 Fr = specularColor;
  1153. #endif
  1154. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1155. float Ess = fab.x + fab.y;
  1156. float Ems = 1.0 - Ess;
  1157. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1158. singleScatter += FssEss;
  1159. multiScatter += Fms * Ems;
  1160. }
  1161. #if NUM_RECT_AREA_LIGHTS > 0
  1162. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1163. vec3 normal = geometryNormal;
  1164. vec3 viewDir = geometryViewDir;
  1165. vec3 position = geometryPosition;
  1166. vec3 lightPos = rectAreaLight.position;
  1167. vec3 halfWidth = rectAreaLight.halfWidth;
  1168. vec3 halfHeight = rectAreaLight.halfHeight;
  1169. vec3 lightColor = rectAreaLight.color;
  1170. float roughness = material.roughness;
  1171. vec3 rectCoords[ 4 ];
  1172. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1173. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1174. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1175. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1176. vec4 t1 = texture2D( ltc_1, uv );
  1177. vec4 t2 = texture2D( ltc_2, uv );
  1178. mat3 mInv = mat3(
  1179. vec3( t1.x, 0, t1.y ),
  1180. vec3( 0, 1, 0 ),
  1181. vec3( t1.z, 0, t1.w )
  1182. );
  1183. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1184. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1185. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1186. }
  1187. #endif
  1188. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1189. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1190. vec3 irradiance = dotNL * directLight.color;
  1191. #ifdef USE_CLEARCOAT
  1192. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1193. vec3 ccIrradiance = dotNLcc * directLight.color;
  1194. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1195. #endif
  1196. #ifdef USE_SHEEN
  1197. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1198. #endif
  1199. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  1200. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1201. }
  1202. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1203. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1204. }
  1205. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1206. #ifdef USE_CLEARCOAT
  1207. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1208. #endif
  1209. #ifdef USE_SHEEN
  1210. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1211. #endif
  1212. vec3 singleScattering = vec3( 0.0 );
  1213. vec3 multiScattering = vec3( 0.0 );
  1214. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1215. #ifdef USE_IRIDESCENCE
  1216. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1217. #else
  1218. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1219. #endif
  1220. vec3 totalScattering = singleScattering + multiScattering;
  1221. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1222. reflectedLight.indirectSpecular += radiance * singleScattering;
  1223. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1224. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1225. }
  1226. #define RE_Direct RE_Direct_Physical
  1227. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1228. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1229. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1230. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1231. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1232. }`,Qg=`
  1233. vec3 geometryPosition = - vViewPosition;
  1234. vec3 geometryNormal = normal;
  1235. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1236. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1237. #ifdef USE_CLEARCOAT
  1238. geometryClearcoatNormal = clearcoatNormal;
  1239. #endif
  1240. #ifdef USE_IRIDESCENCE
  1241. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1242. if ( material.iridescenceThickness == 0.0 ) {
  1243. material.iridescence = 0.0;
  1244. } else {
  1245. material.iridescence = saturate( material.iridescence );
  1246. }
  1247. if ( material.iridescence > 0.0 ) {
  1248. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1249. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1250. }
  1251. #endif
  1252. IncidentLight directLight;
  1253. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1254. PointLight pointLight;
  1255. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1256. PointLightShadow pointLightShadow;
  1257. #endif
  1258. #pragma unroll_loop_start
  1259. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1260. pointLight = pointLights[ i ];
  1261. getPointLightInfo( pointLight, geometryPosition, directLight );
  1262. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1263. pointLightShadow = pointLightShadows[ i ];
  1264. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1265. #endif
  1266. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1267. }
  1268. #pragma unroll_loop_end
  1269. #endif
  1270. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1271. SpotLight spotLight;
  1272. vec4 spotColor;
  1273. vec3 spotLightCoord;
  1274. bool inSpotLightMap;
  1275. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1276. SpotLightShadow spotLightShadow;
  1277. #endif
  1278. #pragma unroll_loop_start
  1279. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1280. spotLight = spotLights[ i ];
  1281. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1282. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1283. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1284. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1285. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1286. #else
  1287. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1288. #endif
  1289. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1290. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1291. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1292. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1293. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1294. #endif
  1295. #undef SPOT_LIGHT_MAP_INDEX
  1296. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1297. spotLightShadow = spotLightShadows[ i ];
  1298. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1299. #endif
  1300. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1301. }
  1302. #pragma unroll_loop_end
  1303. #endif
  1304. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1305. DirectionalLight directionalLight;
  1306. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1307. DirectionalLightShadow directionalLightShadow;
  1308. #endif
  1309. #pragma unroll_loop_start
  1310. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1311. directionalLight = directionalLights[ i ];
  1312. getDirectionalLightInfo( directionalLight, directLight );
  1313. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1314. directionalLightShadow = directionalLightShadows[ i ];
  1315. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1316. #endif
  1317. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1318. }
  1319. #pragma unroll_loop_end
  1320. #endif
  1321. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1322. RectAreaLight rectAreaLight;
  1323. #pragma unroll_loop_start
  1324. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1325. rectAreaLight = rectAreaLights[ i ];
  1326. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1327. }
  1328. #pragma unroll_loop_end
  1329. #endif
  1330. #if defined( RE_IndirectDiffuse )
  1331. vec3 iblIrradiance = vec3( 0.0 );
  1332. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1333. #if defined( USE_LIGHT_PROBES )
  1334. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1335. #endif
  1336. #if ( NUM_HEMI_LIGHTS > 0 )
  1337. #pragma unroll_loop_start
  1338. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1339. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1340. }
  1341. #pragma unroll_loop_end
  1342. #endif
  1343. #endif
  1344. #if defined( RE_IndirectSpecular )
  1345. vec3 radiance = vec3( 0.0 );
  1346. vec3 clearcoatRadiance = vec3( 0.0 );
  1347. #endif`,e_=`#if defined( RE_IndirectDiffuse )
  1348. #ifdef USE_LIGHTMAP
  1349. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1350. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1351. irradiance += lightMapIrradiance;
  1352. #endif
  1353. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1354. iblIrradiance += getIBLIrradiance( geometryNormal );
  1355. #endif
  1356. #endif
  1357. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1358. #ifdef USE_ANISOTROPY
  1359. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1360. #else
  1361. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1362. #endif
  1363. #ifdef USE_CLEARCOAT
  1364. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1365. #endif
  1366. #endif`,t_=`#if defined( RE_IndirectDiffuse )
  1367. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1368. #endif
  1369. #if defined( RE_IndirectSpecular )
  1370. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1371. #endif`,n_=`#if defined( USE_LOGDEPTHBUF )
  1372. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1373. #endif`,i_=`#if defined( USE_LOGDEPTHBUF )
  1374. uniform float logDepthBufFC;
  1375. varying float vFragDepth;
  1376. varying float vIsPerspective;
  1377. #endif`,s_=`#ifdef USE_LOGDEPTHBUF
  1378. varying float vFragDepth;
  1379. varying float vIsPerspective;
  1380. #endif`,r_=`#ifdef USE_LOGDEPTHBUF
  1381. vFragDepth = 1.0 + gl_Position.w;
  1382. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1383. #endif`,o_=`#ifdef USE_MAP
  1384. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1385. #ifdef DECODE_VIDEO_TEXTURE
  1386. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1387. #endif
  1388. diffuseColor *= sampledDiffuseColor;
  1389. #endif`,a_=`#ifdef USE_MAP
  1390. uniform sampler2D map;
  1391. #endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1392. #if defined( USE_POINTS_UV )
  1393. vec2 uv = vUv;
  1394. #else
  1395. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1396. #endif
  1397. #endif
  1398. #ifdef USE_MAP
  1399. diffuseColor *= texture2D( map, uv );
  1400. #endif
  1401. #ifdef USE_ALPHAMAP
  1402. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1403. #endif`,c_=`#if defined( USE_POINTS_UV )
  1404. varying vec2 vUv;
  1405. #else
  1406. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1407. uniform mat3 uvTransform;
  1408. #endif
  1409. #endif
  1410. #ifdef USE_MAP
  1411. uniform sampler2D map;
  1412. #endif
  1413. #ifdef USE_ALPHAMAP
  1414. uniform sampler2D alphaMap;
  1415. #endif`,d_=`float metalnessFactor = metalness;
  1416. #ifdef USE_METALNESSMAP
  1417. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1418. metalnessFactor *= texelMetalness.b;
  1419. #endif`,u_=`#ifdef USE_METALNESSMAP
  1420. uniform sampler2D metalnessMap;
  1421. #endif`,h_=`#ifdef USE_INSTANCING_MORPH
  1422. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1423. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1424. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1425. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1426. }
  1427. #endif`,f_=`#if defined( USE_MORPHCOLORS )
  1428. vColor *= morphTargetBaseInfluence;
  1429. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1430. #if defined( USE_COLOR_ALPHA )
  1431. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1432. #elif defined( USE_COLOR )
  1433. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1434. #endif
  1435. }
  1436. #endif`,p_=`#ifdef USE_MORPHNORMALS
  1437. objectNormal *= morphTargetBaseInfluence;
  1438. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1439. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1440. }
  1441. #endif`,m_=`#ifdef USE_MORPHTARGETS
  1442. #ifndef USE_INSTANCING_MORPH
  1443. uniform float morphTargetBaseInfluence;
  1444. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1445. #endif
  1446. uniform sampler2DArray morphTargetsTexture;
  1447. uniform ivec2 morphTargetsTextureSize;
  1448. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1449. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1450. int y = texelIndex / morphTargetsTextureSize.x;
  1451. int x = texelIndex - y * morphTargetsTextureSize.x;
  1452. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1453. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1454. }
  1455. #endif`,g_=`#ifdef USE_MORPHTARGETS
  1456. transformed *= morphTargetBaseInfluence;
  1457. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1458. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1459. }
  1460. #endif`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1461. #ifdef FLAT_SHADED
  1462. vec3 fdx = dFdx( vViewPosition );
  1463. vec3 fdy = dFdy( vViewPosition );
  1464. vec3 normal = normalize( cross( fdx, fdy ) );
  1465. #else
  1466. vec3 normal = normalize( vNormal );
  1467. #ifdef DOUBLE_SIDED
  1468. normal *= faceDirection;
  1469. #endif
  1470. #endif
  1471. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1472. #ifdef USE_TANGENT
  1473. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1474. #else
  1475. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1476. #if defined( USE_NORMALMAP )
  1477. vNormalMapUv
  1478. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1479. vClearcoatNormalMapUv
  1480. #else
  1481. vUv
  1482. #endif
  1483. );
  1484. #endif
  1485. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1486. tbn[0] *= faceDirection;
  1487. tbn[1] *= faceDirection;
  1488. #endif
  1489. #endif
  1490. #ifdef USE_CLEARCOAT_NORMALMAP
  1491. #ifdef USE_TANGENT
  1492. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1493. #else
  1494. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1495. #endif
  1496. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1497. tbn2[0] *= faceDirection;
  1498. tbn2[1] *= faceDirection;
  1499. #endif
  1500. #endif
  1501. vec3 nonPerturbedNormal = normal;`,v_=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1502. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1503. #ifdef FLIP_SIDED
  1504. normal = - normal;
  1505. #endif
  1506. #ifdef DOUBLE_SIDED
  1507. normal = normal * faceDirection;
  1508. #endif
  1509. normal = normalize( normalMatrix * normal );
  1510. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1511. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1512. mapN.xy *= normalScale;
  1513. normal = normalize( tbn * mapN );
  1514. #elif defined( USE_BUMPMAP )
  1515. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1516. #endif`,x_=`#ifndef FLAT_SHADED
  1517. varying vec3 vNormal;
  1518. #ifdef USE_TANGENT
  1519. varying vec3 vTangent;
  1520. varying vec3 vBitangent;
  1521. #endif
  1522. #endif`,S_=`#ifndef FLAT_SHADED
  1523. varying vec3 vNormal;
  1524. #ifdef USE_TANGENT
  1525. varying vec3 vTangent;
  1526. varying vec3 vBitangent;
  1527. #endif
  1528. #endif`,y_=`#ifndef FLAT_SHADED
  1529. vNormal = normalize( transformedNormal );
  1530. #ifdef USE_TANGENT
  1531. vTangent = normalize( transformedTangent );
  1532. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1533. #endif
  1534. #endif`,M_=`#ifdef USE_NORMALMAP
  1535. uniform sampler2D normalMap;
  1536. uniform vec2 normalScale;
  1537. #endif
  1538. #ifdef USE_NORMALMAP_OBJECTSPACE
  1539. uniform mat3 normalMatrix;
  1540. #endif
  1541. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1542. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1543. vec3 q0 = dFdx( eye_pos.xyz );
  1544. vec3 q1 = dFdy( eye_pos.xyz );
  1545. vec2 st0 = dFdx( uv.st );
  1546. vec2 st1 = dFdy( uv.st );
  1547. vec3 N = surf_norm;
  1548. vec3 q1perp = cross( q1, N );
  1549. vec3 q0perp = cross( N, q0 );
  1550. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1551. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1552. float det = max( dot( T, T ), dot( B, B ) );
  1553. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1554. return mat3( T * scale, B * scale, N );
  1555. }
  1556. #endif`,E_=`#ifdef USE_CLEARCOAT
  1557. vec3 clearcoatNormal = nonPerturbedNormal;
  1558. #endif`,b_=`#ifdef USE_CLEARCOAT_NORMALMAP
  1559. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1560. clearcoatMapN.xy *= clearcoatNormalScale;
  1561. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1562. #endif`,w_=`#ifdef USE_CLEARCOATMAP
  1563. uniform sampler2D clearcoatMap;
  1564. #endif
  1565. #ifdef USE_CLEARCOAT_NORMALMAP
  1566. uniform sampler2D clearcoatNormalMap;
  1567. uniform vec2 clearcoatNormalScale;
  1568. #endif
  1569. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1570. uniform sampler2D clearcoatRoughnessMap;
  1571. #endif`,T_=`#ifdef USE_IRIDESCENCEMAP
  1572. uniform sampler2D iridescenceMap;
  1573. #endif
  1574. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1575. uniform sampler2D iridescenceThicknessMap;
  1576. #endif`,A_=`#ifdef OPAQUE
  1577. diffuseColor.a = 1.0;
  1578. #endif
  1579. #ifdef USE_TRANSMISSION
  1580. diffuseColor.a *= material.transmissionAlpha;
  1581. #endif
  1582. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,C_=`vec3 packNormalToRGB( const in vec3 normal ) {
  1583. return normalize( normal ) * 0.5 + 0.5;
  1584. }
  1585. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1586. return 2.0 * rgb.xyz - 1.0;
  1587. }
  1588. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1589. const float Inv255 = 1. / 255.;
  1590. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1591. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1592. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1593. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1594. vec4 packDepthToRGBA( const in float v ) {
  1595. if( v <= 0.0 )
  1596. return vec4( 0., 0., 0., 0. );
  1597. if( v >= 1.0 )
  1598. return vec4( 1., 1., 1., 1. );
  1599. float vuf;
  1600. float af = modf( v * PackFactors.a, vuf );
  1601. float bf = modf( vuf * ShiftRight8, vuf );
  1602. float gf = modf( vuf * ShiftRight8, vuf );
  1603. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1604. }
  1605. vec3 packDepthToRGB( const in float v ) {
  1606. if( v <= 0.0 )
  1607. return vec3( 0., 0., 0. );
  1608. if( v >= 1.0 )
  1609. return vec3( 1., 1., 1. );
  1610. float vuf;
  1611. float bf = modf( v * PackFactors.b, vuf );
  1612. float gf = modf( vuf * ShiftRight8, vuf );
  1613. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1614. }
  1615. vec2 packDepthToRG( const in float v ) {
  1616. if( v <= 0.0 )
  1617. return vec2( 0., 0. );
  1618. if( v >= 1.0 )
  1619. return vec2( 1., 1. );
  1620. float vuf;
  1621. float gf = modf( v * 256., vuf );
  1622. return vec2( vuf * Inv255, gf );
  1623. }
  1624. float unpackRGBAToDepth( const in vec4 v ) {
  1625. return dot( v, UnpackFactors4 );
  1626. }
  1627. float unpackRGBToDepth( const in vec3 v ) {
  1628. return dot( v, UnpackFactors3 );
  1629. }
  1630. float unpackRGToDepth( const in vec2 v ) {
  1631. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1632. }
  1633. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1634. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1635. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1636. }
  1637. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1638. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1639. }
  1640. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1641. return ( viewZ + near ) / ( near - far );
  1642. }
  1643. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1644. return depth * ( near - far ) - near;
  1645. }
  1646. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1647. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1648. }
  1649. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1650. return ( near * far ) / ( ( far - near ) * depth - far );
  1651. }`,R_=`#ifdef PREMULTIPLIED_ALPHA
  1652. gl_FragColor.rgb *= gl_FragColor.a;
  1653. #endif`,P_=`vec4 mvPosition = vec4( transformed, 1.0 );
  1654. #ifdef USE_BATCHING
  1655. mvPosition = batchingMatrix * mvPosition;
  1656. #endif
  1657. #ifdef USE_INSTANCING
  1658. mvPosition = instanceMatrix * mvPosition;
  1659. #endif
  1660. mvPosition = modelViewMatrix * mvPosition;
  1661. gl_Position = projectionMatrix * mvPosition;`,D_=`#ifdef DITHERING
  1662. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1663. #endif`,L_=`#ifdef DITHERING
  1664. vec3 dithering( vec3 color ) {
  1665. float grid_position = rand( gl_FragCoord.xy );
  1666. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1667. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1668. return color + dither_shift_RGB;
  1669. }
  1670. #endif`,I_=`float roughnessFactor = roughness;
  1671. #ifdef USE_ROUGHNESSMAP
  1672. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1673. roughnessFactor *= texelRoughness.g;
  1674. #endif`,U_=`#ifdef USE_ROUGHNESSMAP
  1675. uniform sampler2D roughnessMap;
  1676. #endif`,N_=`#if NUM_SPOT_LIGHT_COORDS > 0
  1677. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1678. #endif
  1679. #if NUM_SPOT_LIGHT_MAPS > 0
  1680. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1681. #endif
  1682. #ifdef USE_SHADOWMAP
  1683. #if NUM_DIR_LIGHT_SHADOWS > 0
  1684. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1685. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1686. struct DirectionalLightShadow {
  1687. float shadowIntensity;
  1688. float shadowBias;
  1689. float shadowNormalBias;
  1690. float shadowRadius;
  1691. vec2 shadowMapSize;
  1692. };
  1693. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1694. #endif
  1695. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1696. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1697. struct SpotLightShadow {
  1698. float shadowIntensity;
  1699. float shadowBias;
  1700. float shadowNormalBias;
  1701. float shadowRadius;
  1702. vec2 shadowMapSize;
  1703. };
  1704. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1705. #endif
  1706. #if NUM_POINT_LIGHT_SHADOWS > 0
  1707. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1708. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1709. struct PointLightShadow {
  1710. float shadowIntensity;
  1711. float shadowBias;
  1712. float shadowNormalBias;
  1713. float shadowRadius;
  1714. vec2 shadowMapSize;
  1715. float shadowCameraNear;
  1716. float shadowCameraFar;
  1717. };
  1718. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1719. #endif
  1720. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1721. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  1722. }
  1723. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1724. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1725. }
  1726. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  1727. float occlusion = 1.0;
  1728. vec2 distribution = texture2DDistribution( shadow, uv );
  1729. float hard_shadow = step( compare , distribution.x );
  1730. if (hard_shadow != 1.0 ) {
  1731. float distance = compare - distribution.x ;
  1732. float variance = max( 0.00000, distribution.y * distribution.y );
  1733. 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 );
  1734. }
  1735. return occlusion;
  1736. }
  1737. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1738. float shadow = 1.0;
  1739. shadowCoord.xyz /= shadowCoord.w;
  1740. shadowCoord.z += shadowBias;
  1741. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1742. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1743. if ( frustumTest ) {
  1744. #if defined( SHADOWMAP_TYPE_PCF )
  1745. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1746. float dx0 = - texelSize.x * shadowRadius;
  1747. float dy0 = - texelSize.y * shadowRadius;
  1748. float dx1 = + texelSize.x * shadowRadius;
  1749. float dy1 = + texelSize.y * shadowRadius;
  1750. float dx2 = dx0 / 2.0;
  1751. float dy2 = dy0 / 2.0;
  1752. float dx3 = dx1 / 2.0;
  1753. float dy3 = dy1 / 2.0;
  1754. shadow = (
  1755. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1756. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1757. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1758. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1759. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1760. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1761. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1762. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1763. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1764. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1765. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1766. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1767. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1768. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1769. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1770. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1771. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1772. ) * ( 1.0 / 17.0 );
  1773. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1774. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1775. float dx = texelSize.x;
  1776. float dy = texelSize.y;
  1777. vec2 uv = shadowCoord.xy;
  1778. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1779. uv -= f * texelSize;
  1780. shadow = (
  1781. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1782. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1783. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1784. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1785. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1786. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1787. f.x ) +
  1788. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1789. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1790. f.x ) +
  1791. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1792. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1793. f.y ) +
  1794. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1795. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1796. f.y ) +
  1797. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1798. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1799. f.x ),
  1800. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1801. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1802. f.x ),
  1803. f.y )
  1804. ) * ( 1.0 / 9.0 );
  1805. #elif defined( SHADOWMAP_TYPE_VSM )
  1806. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1807. #else
  1808. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1809. #endif
  1810. }
  1811. return mix( 1.0, shadow, shadowIntensity );
  1812. }
  1813. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1814. vec3 absV = abs( v );
  1815. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1816. absV *= scaleToCube;
  1817. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1818. vec2 planar = v.xy;
  1819. float almostATexel = 1.5 * texelSizeY;
  1820. float almostOne = 1.0 - almostATexel;
  1821. if ( absV.z >= almostOne ) {
  1822. if ( v.z > 0.0 )
  1823. planar.x = 4.0 - v.x;
  1824. } else if ( absV.x >= almostOne ) {
  1825. float signX = sign( v.x );
  1826. planar.x = v.z * signX + 2.0 * signX;
  1827. } else if ( absV.y >= almostOne ) {
  1828. float signY = sign( v.y );
  1829. planar.x = v.x + 2.0 * signY + 2.0;
  1830. planar.y = v.z * signY - 2.0;
  1831. }
  1832. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1833. }
  1834. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1835. float shadow = 1.0;
  1836. vec3 lightToPosition = shadowCoord.xyz;
  1837. float lightToPositionLength = length( lightToPosition );
  1838. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1839. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1840. vec3 bd3D = normalize( lightToPosition );
  1841. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1842. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1843. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1844. shadow = (
  1845. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1846. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1847. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1848. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1849. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1850. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1851. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1852. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1853. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1854. ) * ( 1.0 / 9.0 );
  1855. #else
  1856. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1857. #endif
  1858. }
  1859. return mix( 1.0, shadow, shadowIntensity );
  1860. }
  1861. #endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0
  1862. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1863. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1864. #endif
  1865. #ifdef USE_SHADOWMAP
  1866. #if NUM_DIR_LIGHT_SHADOWS > 0
  1867. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1868. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1869. struct DirectionalLightShadow {
  1870. float shadowIntensity;
  1871. float shadowBias;
  1872. float shadowNormalBias;
  1873. float shadowRadius;
  1874. vec2 shadowMapSize;
  1875. };
  1876. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1877. #endif
  1878. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1879. struct SpotLightShadow {
  1880. float shadowIntensity;
  1881. float shadowBias;
  1882. float shadowNormalBias;
  1883. float shadowRadius;
  1884. vec2 shadowMapSize;
  1885. };
  1886. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1887. #endif
  1888. #if NUM_POINT_LIGHT_SHADOWS > 0
  1889. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1890. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1891. struct PointLightShadow {
  1892. float shadowIntensity;
  1893. float shadowBias;
  1894. float shadowNormalBias;
  1895. float shadowRadius;
  1896. vec2 shadowMapSize;
  1897. float shadowCameraNear;
  1898. float shadowCameraFar;
  1899. };
  1900. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1901. #endif
  1902. #endif`,F_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1903. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1904. vec4 shadowWorldPosition;
  1905. #endif
  1906. #if defined( USE_SHADOWMAP )
  1907. #if NUM_DIR_LIGHT_SHADOWS > 0
  1908. #pragma unroll_loop_start
  1909. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1910. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1911. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1912. }
  1913. #pragma unroll_loop_end
  1914. #endif
  1915. #if NUM_POINT_LIGHT_SHADOWS > 0
  1916. #pragma unroll_loop_start
  1917. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1918. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1919. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1920. }
  1921. #pragma unroll_loop_end
  1922. #endif
  1923. #endif
  1924. #if NUM_SPOT_LIGHT_COORDS > 0
  1925. #pragma unroll_loop_start
  1926. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1927. shadowWorldPosition = worldPosition;
  1928. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1929. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1930. #endif
  1931. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1932. }
  1933. #pragma unroll_loop_end
  1934. #endif`,B_=`float getShadowMask() {
  1935. float shadow = 1.0;
  1936. #ifdef USE_SHADOWMAP
  1937. #if NUM_DIR_LIGHT_SHADOWS > 0
  1938. DirectionalLightShadow directionalLight;
  1939. #pragma unroll_loop_start
  1940. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1941. directionalLight = directionalLightShadows[ i ];
  1942. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1943. }
  1944. #pragma unroll_loop_end
  1945. #endif
  1946. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1947. SpotLightShadow spotLight;
  1948. #pragma unroll_loop_start
  1949. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1950. spotLight = spotLightShadows[ i ];
  1951. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1952. }
  1953. #pragma unroll_loop_end
  1954. #endif
  1955. #if NUM_POINT_LIGHT_SHADOWS > 0
  1956. PointLightShadow pointLight;
  1957. #pragma unroll_loop_start
  1958. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1959. pointLight = pointLightShadows[ i ];
  1960. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1961. }
  1962. #pragma unroll_loop_end
  1963. #endif
  1964. #endif
  1965. return shadow;
  1966. }`,z_=`#ifdef USE_SKINNING
  1967. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1968. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1969. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1970. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1971. #endif`,k_=`#ifdef USE_SKINNING
  1972. uniform mat4 bindMatrix;
  1973. uniform mat4 bindMatrixInverse;
  1974. uniform highp sampler2D boneTexture;
  1975. mat4 getBoneMatrix( const in float i ) {
  1976. int size = textureSize( boneTexture, 0 ).x;
  1977. int j = int( i ) * 4;
  1978. int x = j % size;
  1979. int y = j / size;
  1980. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1981. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  1982. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  1983. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  1984. return mat4( v1, v2, v3, v4 );
  1985. }
  1986. #endif`,H_=`#ifdef USE_SKINNING
  1987. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  1988. vec4 skinned = vec4( 0.0 );
  1989. skinned += boneMatX * skinVertex * skinWeight.x;
  1990. skinned += boneMatY * skinVertex * skinWeight.y;
  1991. skinned += boneMatZ * skinVertex * skinWeight.z;
  1992. skinned += boneMatW * skinVertex * skinWeight.w;
  1993. transformed = ( bindMatrixInverse * skinned ).xyz;
  1994. #endif`,G_=`#ifdef USE_SKINNING
  1995. mat4 skinMatrix = mat4( 0.0 );
  1996. skinMatrix += skinWeight.x * boneMatX;
  1997. skinMatrix += skinWeight.y * boneMatY;
  1998. skinMatrix += skinWeight.z * boneMatZ;
  1999. skinMatrix += skinWeight.w * boneMatW;
  2000. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2001. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2002. #ifdef USE_TANGENT
  2003. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2004. #endif
  2005. #endif`,V_=`float specularStrength;
  2006. #ifdef USE_SPECULARMAP
  2007. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2008. specularStrength = texelSpecular.r;
  2009. #else
  2010. specularStrength = 1.0;
  2011. #endif`,W_=`#ifdef USE_SPECULARMAP
  2012. uniform sampler2D specularMap;
  2013. #endif`,X_=`#if defined( TONE_MAPPING )
  2014. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2015. #endif`,Y_=`#ifndef saturate
  2016. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2017. #endif
  2018. uniform float toneMappingExposure;
  2019. vec3 LinearToneMapping( vec3 color ) {
  2020. return saturate( toneMappingExposure * color );
  2021. }
  2022. vec3 ReinhardToneMapping( vec3 color ) {
  2023. color *= toneMappingExposure;
  2024. return saturate( color / ( vec3( 1.0 ) + color ) );
  2025. }
  2026. vec3 CineonToneMapping( vec3 color ) {
  2027. color *= toneMappingExposure;
  2028. color = max( vec3( 0.0 ), color - 0.004 );
  2029. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2030. }
  2031. vec3 RRTAndODTFit( vec3 v ) {
  2032. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2033. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2034. return a / b;
  2035. }
  2036. vec3 ACESFilmicToneMapping( vec3 color ) {
  2037. const mat3 ACESInputMat = mat3(
  2038. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2039. vec3( 0.04823, 0.01566, 0.83777 )
  2040. );
  2041. const mat3 ACESOutputMat = mat3(
  2042. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2043. vec3( -0.07367, -0.00605, 1.07602 )
  2044. );
  2045. color *= toneMappingExposure / 0.6;
  2046. color = ACESInputMat * color;
  2047. color = RRTAndODTFit( color );
  2048. color = ACESOutputMat * color;
  2049. return saturate( color );
  2050. }
  2051. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2052. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2053. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2054. vec3( - 0.0728, - 0.0083, 1.1187 )
  2055. );
  2056. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2057. vec3( 0.6274, 0.0691, 0.0164 ),
  2058. vec3( 0.3293, 0.9195, 0.0880 ),
  2059. vec3( 0.0433, 0.0113, 0.8956 )
  2060. );
  2061. vec3 agxDefaultContrastApprox( vec3 x ) {
  2062. vec3 x2 = x * x;
  2063. vec3 x4 = x2 * x2;
  2064. return + 15.5 * x4 * x2
  2065. - 40.14 * x4 * x
  2066. + 31.96 * x4
  2067. - 6.868 * x2 * x
  2068. + 0.4298 * x2
  2069. + 0.1191 * x
  2070. - 0.00232;
  2071. }
  2072. vec3 AgXToneMapping( vec3 color ) {
  2073. const mat3 AgXInsetMatrix = mat3(
  2074. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2075. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2076. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2077. );
  2078. const mat3 AgXOutsetMatrix = mat3(
  2079. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2080. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2081. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2082. );
  2083. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2084. color *= toneMappingExposure;
  2085. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2086. color = AgXInsetMatrix * color;
  2087. color = max( color, 1e-10 ); color = log2( color );
  2088. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2089. color = clamp( color, 0.0, 1.0 );
  2090. color = agxDefaultContrastApprox( color );
  2091. color = AgXOutsetMatrix * color;
  2092. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2093. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2094. color = clamp( color, 0.0, 1.0 );
  2095. return color;
  2096. }
  2097. vec3 NeutralToneMapping( vec3 color ) {
  2098. const float StartCompression = 0.8 - 0.04;
  2099. const float Desaturation = 0.15;
  2100. color *= toneMappingExposure;
  2101. float x = min( color.r, min( color.g, color.b ) );
  2102. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2103. color -= offset;
  2104. float peak = max( color.r, max( color.g, color.b ) );
  2105. if ( peak < StartCompression ) return color;
  2106. float d = 1. - StartCompression;
  2107. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2108. color *= newPeak / peak;
  2109. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2110. return mix( color, vec3( newPeak ), g );
  2111. }
  2112. vec3 CustomToneMapping( vec3 color ) { return color; }`,q_=`#ifdef USE_TRANSMISSION
  2113. material.transmission = transmission;
  2114. material.transmissionAlpha = 1.0;
  2115. material.thickness = thickness;
  2116. material.attenuationDistance = attenuationDistance;
  2117. material.attenuationColor = attenuationColor;
  2118. #ifdef USE_TRANSMISSIONMAP
  2119. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2120. #endif
  2121. #ifdef USE_THICKNESSMAP
  2122. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2123. #endif
  2124. vec3 pos = vWorldPosition;
  2125. vec3 v = normalize( cameraPosition - pos );
  2126. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2127. vec4 transmitted = getIBLVolumeRefraction(
  2128. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2129. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2130. material.attenuationColor, material.attenuationDistance );
  2131. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2132. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2133. #endif`,j_=`#ifdef USE_TRANSMISSION
  2134. uniform float transmission;
  2135. uniform float thickness;
  2136. uniform float attenuationDistance;
  2137. uniform vec3 attenuationColor;
  2138. #ifdef USE_TRANSMISSIONMAP
  2139. uniform sampler2D transmissionMap;
  2140. #endif
  2141. #ifdef USE_THICKNESSMAP
  2142. uniform sampler2D thicknessMap;
  2143. #endif
  2144. uniform vec2 transmissionSamplerSize;
  2145. uniform sampler2D transmissionSamplerMap;
  2146. uniform mat4 modelMatrix;
  2147. uniform mat4 projectionMatrix;
  2148. varying vec3 vWorldPosition;
  2149. float w0( float a ) {
  2150. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2151. }
  2152. float w1( float a ) {
  2153. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2154. }
  2155. float w2( float a ){
  2156. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2157. }
  2158. float w3( float a ) {
  2159. return ( 1.0 / 6.0 ) * ( a * a * a );
  2160. }
  2161. float g0( float a ) {
  2162. return w0( a ) + w1( a );
  2163. }
  2164. float g1( float a ) {
  2165. return w2( a ) + w3( a );
  2166. }
  2167. float h0( float a ) {
  2168. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2169. }
  2170. float h1( float a ) {
  2171. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2172. }
  2173. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2174. uv = uv * texelSize.zw + 0.5;
  2175. vec2 iuv = floor( uv );
  2176. vec2 fuv = fract( uv );
  2177. float g0x = g0( fuv.x );
  2178. float g1x = g1( fuv.x );
  2179. float h0x = h0( fuv.x );
  2180. float h1x = h1( fuv.x );
  2181. float h0y = h0( fuv.y );
  2182. float h1y = h1( fuv.y );
  2183. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2184. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2185. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2186. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2187. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2188. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2189. }
  2190. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2191. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2192. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2193. vec2 fLodSizeInv = 1.0 / fLodSize;
  2194. vec2 cLodSizeInv = 1.0 / cLodSize;
  2195. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2196. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2197. return mix( fSample, cSample, fract( lod ) );
  2198. }
  2199. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2200. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2201. vec3 modelScale;
  2202. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2203. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2204. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2205. return normalize( refractionVector ) * thickness * modelScale;
  2206. }
  2207. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2208. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2209. }
  2210. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2211. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2212. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2213. }
  2214. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2215. if ( isinf( attenuationDistance ) ) {
  2216. return vec3( 1.0 );
  2217. } else {
  2218. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2219. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2220. }
  2221. }
  2222. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2223. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2224. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2225. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2226. vec4 transmittedLight;
  2227. vec3 transmittance;
  2228. #ifdef USE_DISPERSION
  2229. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2230. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2231. for ( int i = 0; i < 3; i ++ ) {
  2232. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2233. vec3 refractedRayExit = position + transmissionRay;
  2234. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2235. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2236. refractionCoords += 1.0;
  2237. refractionCoords /= 2.0;
  2238. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2239. transmittedLight[ i ] = transmissionSample[ i ];
  2240. transmittedLight.a += transmissionSample.a;
  2241. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2242. }
  2243. transmittedLight.a /= 3.0;
  2244. #else
  2245. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2246. vec3 refractedRayExit = position + transmissionRay;
  2247. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2248. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2249. refractionCoords += 1.0;
  2250. refractionCoords /= 2.0;
  2251. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2252. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2253. #endif
  2254. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2255. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2256. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2257. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2258. }
  2259. #endif`,$_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2260. varying vec2 vUv;
  2261. #endif
  2262. #ifdef USE_MAP
  2263. varying vec2 vMapUv;
  2264. #endif
  2265. #ifdef USE_ALPHAMAP
  2266. varying vec2 vAlphaMapUv;
  2267. #endif
  2268. #ifdef USE_LIGHTMAP
  2269. varying vec2 vLightMapUv;
  2270. #endif
  2271. #ifdef USE_AOMAP
  2272. varying vec2 vAoMapUv;
  2273. #endif
  2274. #ifdef USE_BUMPMAP
  2275. varying vec2 vBumpMapUv;
  2276. #endif
  2277. #ifdef USE_NORMALMAP
  2278. varying vec2 vNormalMapUv;
  2279. #endif
  2280. #ifdef USE_EMISSIVEMAP
  2281. varying vec2 vEmissiveMapUv;
  2282. #endif
  2283. #ifdef USE_METALNESSMAP
  2284. varying vec2 vMetalnessMapUv;
  2285. #endif
  2286. #ifdef USE_ROUGHNESSMAP
  2287. varying vec2 vRoughnessMapUv;
  2288. #endif
  2289. #ifdef USE_ANISOTROPYMAP
  2290. varying vec2 vAnisotropyMapUv;
  2291. #endif
  2292. #ifdef USE_CLEARCOATMAP
  2293. varying vec2 vClearcoatMapUv;
  2294. #endif
  2295. #ifdef USE_CLEARCOAT_NORMALMAP
  2296. varying vec2 vClearcoatNormalMapUv;
  2297. #endif
  2298. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2299. varying vec2 vClearcoatRoughnessMapUv;
  2300. #endif
  2301. #ifdef USE_IRIDESCENCEMAP
  2302. varying vec2 vIridescenceMapUv;
  2303. #endif
  2304. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2305. varying vec2 vIridescenceThicknessMapUv;
  2306. #endif
  2307. #ifdef USE_SHEEN_COLORMAP
  2308. varying vec2 vSheenColorMapUv;
  2309. #endif
  2310. #ifdef USE_SHEEN_ROUGHNESSMAP
  2311. varying vec2 vSheenRoughnessMapUv;
  2312. #endif
  2313. #ifdef USE_SPECULARMAP
  2314. varying vec2 vSpecularMapUv;
  2315. #endif
  2316. #ifdef USE_SPECULAR_COLORMAP
  2317. varying vec2 vSpecularColorMapUv;
  2318. #endif
  2319. #ifdef USE_SPECULAR_INTENSITYMAP
  2320. varying vec2 vSpecularIntensityMapUv;
  2321. #endif
  2322. #ifdef USE_TRANSMISSIONMAP
  2323. uniform mat3 transmissionMapTransform;
  2324. varying vec2 vTransmissionMapUv;
  2325. #endif
  2326. #ifdef USE_THICKNESSMAP
  2327. uniform mat3 thicknessMapTransform;
  2328. varying vec2 vThicknessMapUv;
  2329. #endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2330. varying vec2 vUv;
  2331. #endif
  2332. #ifdef USE_MAP
  2333. uniform mat3 mapTransform;
  2334. varying vec2 vMapUv;
  2335. #endif
  2336. #ifdef USE_ALPHAMAP
  2337. uniform mat3 alphaMapTransform;
  2338. varying vec2 vAlphaMapUv;
  2339. #endif
  2340. #ifdef USE_LIGHTMAP
  2341. uniform mat3 lightMapTransform;
  2342. varying vec2 vLightMapUv;
  2343. #endif
  2344. #ifdef USE_AOMAP
  2345. uniform mat3 aoMapTransform;
  2346. varying vec2 vAoMapUv;
  2347. #endif
  2348. #ifdef USE_BUMPMAP
  2349. uniform mat3 bumpMapTransform;
  2350. varying vec2 vBumpMapUv;
  2351. #endif
  2352. #ifdef USE_NORMALMAP
  2353. uniform mat3 normalMapTransform;
  2354. varying vec2 vNormalMapUv;
  2355. #endif
  2356. #ifdef USE_DISPLACEMENTMAP
  2357. uniform mat3 displacementMapTransform;
  2358. varying vec2 vDisplacementMapUv;
  2359. #endif
  2360. #ifdef USE_EMISSIVEMAP
  2361. uniform mat3 emissiveMapTransform;
  2362. varying vec2 vEmissiveMapUv;
  2363. #endif
  2364. #ifdef USE_METALNESSMAP
  2365. uniform mat3 metalnessMapTransform;
  2366. varying vec2 vMetalnessMapUv;
  2367. #endif
  2368. #ifdef USE_ROUGHNESSMAP
  2369. uniform mat3 roughnessMapTransform;
  2370. varying vec2 vRoughnessMapUv;
  2371. #endif
  2372. #ifdef USE_ANISOTROPYMAP
  2373. uniform mat3 anisotropyMapTransform;
  2374. varying vec2 vAnisotropyMapUv;
  2375. #endif
  2376. #ifdef USE_CLEARCOATMAP
  2377. uniform mat3 clearcoatMapTransform;
  2378. varying vec2 vClearcoatMapUv;
  2379. #endif
  2380. #ifdef USE_CLEARCOAT_NORMALMAP
  2381. uniform mat3 clearcoatNormalMapTransform;
  2382. varying vec2 vClearcoatNormalMapUv;
  2383. #endif
  2384. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2385. uniform mat3 clearcoatRoughnessMapTransform;
  2386. varying vec2 vClearcoatRoughnessMapUv;
  2387. #endif
  2388. #ifdef USE_SHEEN_COLORMAP
  2389. uniform mat3 sheenColorMapTransform;
  2390. varying vec2 vSheenColorMapUv;
  2391. #endif
  2392. #ifdef USE_SHEEN_ROUGHNESSMAP
  2393. uniform mat3 sheenRoughnessMapTransform;
  2394. varying vec2 vSheenRoughnessMapUv;
  2395. #endif
  2396. #ifdef USE_IRIDESCENCEMAP
  2397. uniform mat3 iridescenceMapTransform;
  2398. varying vec2 vIridescenceMapUv;
  2399. #endif
  2400. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2401. uniform mat3 iridescenceThicknessMapTransform;
  2402. varying vec2 vIridescenceThicknessMapUv;
  2403. #endif
  2404. #ifdef USE_SPECULARMAP
  2405. uniform mat3 specularMapTransform;
  2406. varying vec2 vSpecularMapUv;
  2407. #endif
  2408. #ifdef USE_SPECULAR_COLORMAP
  2409. uniform mat3 specularColorMapTransform;
  2410. varying vec2 vSpecularColorMapUv;
  2411. #endif
  2412. #ifdef USE_SPECULAR_INTENSITYMAP
  2413. uniform mat3 specularIntensityMapTransform;
  2414. varying vec2 vSpecularIntensityMapUv;
  2415. #endif
  2416. #ifdef USE_TRANSMISSIONMAP
  2417. uniform mat3 transmissionMapTransform;
  2418. varying vec2 vTransmissionMapUv;
  2419. #endif
  2420. #ifdef USE_THICKNESSMAP
  2421. uniform mat3 thicknessMapTransform;
  2422. varying vec2 vThicknessMapUv;
  2423. #endif`,K_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2424. vUv = vec3( uv, 1 ).xy;
  2425. #endif
  2426. #ifdef USE_MAP
  2427. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2428. #endif
  2429. #ifdef USE_ALPHAMAP
  2430. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2431. #endif
  2432. #ifdef USE_LIGHTMAP
  2433. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2434. #endif
  2435. #ifdef USE_AOMAP
  2436. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2437. #endif
  2438. #ifdef USE_BUMPMAP
  2439. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2440. #endif
  2441. #ifdef USE_NORMALMAP
  2442. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2443. #endif
  2444. #ifdef USE_DISPLACEMENTMAP
  2445. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_EMISSIVEMAP
  2448. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_METALNESSMAP
  2451. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_ROUGHNESSMAP
  2454. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_ANISOTROPYMAP
  2457. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_CLEARCOATMAP
  2460. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_CLEARCOAT_NORMALMAP
  2463. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2466. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2467. #endif
  2468. #ifdef USE_IRIDESCENCEMAP
  2469. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2470. #endif
  2471. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2472. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2473. #endif
  2474. #ifdef USE_SHEEN_COLORMAP
  2475. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2476. #endif
  2477. #ifdef USE_SHEEN_ROUGHNESSMAP
  2478. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2479. #endif
  2480. #ifdef USE_SPECULARMAP
  2481. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2482. #endif
  2483. #ifdef USE_SPECULAR_COLORMAP
  2484. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2485. #endif
  2486. #ifdef USE_SPECULAR_INTENSITYMAP
  2487. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2488. #endif
  2489. #ifdef USE_TRANSMISSIONMAP
  2490. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2491. #endif
  2492. #ifdef USE_THICKNESSMAP
  2493. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2494. #endif`,J_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2495. vec4 worldPosition = vec4( transformed, 1.0 );
  2496. #ifdef USE_BATCHING
  2497. worldPosition = batchingMatrix * worldPosition;
  2498. #endif
  2499. #ifdef USE_INSTANCING
  2500. worldPosition = instanceMatrix * worldPosition;
  2501. #endif
  2502. worldPosition = modelMatrix * worldPosition;
  2503. #endif`;const Q_=`varying vec2 vUv;
  2504. uniform mat3 uvTransform;
  2505. void main() {
  2506. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2507. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2508. }`,ev=`uniform sampler2D t2D;
  2509. uniform float backgroundIntensity;
  2510. varying vec2 vUv;
  2511. void main() {
  2512. vec4 texColor = texture2D( t2D, vUv );
  2513. #ifdef DECODE_VIDEO_TEXTURE
  2514. 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 );
  2515. #endif
  2516. texColor.rgb *= backgroundIntensity;
  2517. gl_FragColor = texColor;
  2518. #include <tonemapping_fragment>
  2519. #include <colorspace_fragment>
  2520. }`,tv=`varying vec3 vWorldDirection;
  2521. #include <common>
  2522. void main() {
  2523. vWorldDirection = transformDirection( position, modelMatrix );
  2524. #include <begin_vertex>
  2525. #include <project_vertex>
  2526. gl_Position.z = gl_Position.w;
  2527. }`,nv=`#ifdef ENVMAP_TYPE_CUBE
  2528. uniform samplerCube envMap;
  2529. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2530. uniform sampler2D envMap;
  2531. #endif
  2532. uniform float flipEnvMap;
  2533. uniform float backgroundBlurriness;
  2534. uniform float backgroundIntensity;
  2535. uniform mat3 backgroundRotation;
  2536. varying vec3 vWorldDirection;
  2537. #include <cube_uv_reflection_fragment>
  2538. void main() {
  2539. #ifdef ENVMAP_TYPE_CUBE
  2540. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2541. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2542. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2543. #else
  2544. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2545. #endif
  2546. texColor.rgb *= backgroundIntensity;
  2547. gl_FragColor = texColor;
  2548. #include <tonemapping_fragment>
  2549. #include <colorspace_fragment>
  2550. }`,iv=`varying vec3 vWorldDirection;
  2551. #include <common>
  2552. void main() {
  2553. vWorldDirection = transformDirection( position, modelMatrix );
  2554. #include <begin_vertex>
  2555. #include <project_vertex>
  2556. gl_Position.z = gl_Position.w;
  2557. }`,sv=`uniform samplerCube tCube;
  2558. uniform float tFlip;
  2559. uniform float opacity;
  2560. varying vec3 vWorldDirection;
  2561. void main() {
  2562. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2563. gl_FragColor = texColor;
  2564. gl_FragColor.a *= opacity;
  2565. #include <tonemapping_fragment>
  2566. #include <colorspace_fragment>
  2567. }`,rv=`#include <common>
  2568. #include <batching_pars_vertex>
  2569. #include <uv_pars_vertex>
  2570. #include <displacementmap_pars_vertex>
  2571. #include <morphtarget_pars_vertex>
  2572. #include <skinning_pars_vertex>
  2573. #include <logdepthbuf_pars_vertex>
  2574. #include <clipping_planes_pars_vertex>
  2575. varying vec2 vHighPrecisionZW;
  2576. void main() {
  2577. #include <uv_vertex>
  2578. #include <batching_vertex>
  2579. #include <skinbase_vertex>
  2580. #include <morphinstance_vertex>
  2581. #ifdef USE_DISPLACEMENTMAP
  2582. #include <beginnormal_vertex>
  2583. #include <morphnormal_vertex>
  2584. #include <skinnormal_vertex>
  2585. #endif
  2586. #include <begin_vertex>
  2587. #include <morphtarget_vertex>
  2588. #include <skinning_vertex>
  2589. #include <displacementmap_vertex>
  2590. #include <project_vertex>
  2591. #include <logdepthbuf_vertex>
  2592. #include <clipping_planes_vertex>
  2593. vHighPrecisionZW = gl_Position.zw;
  2594. }`,ov=`#if DEPTH_PACKING == 3200
  2595. uniform float opacity;
  2596. #endif
  2597. #include <common>
  2598. #include <packing>
  2599. #include <uv_pars_fragment>
  2600. #include <map_pars_fragment>
  2601. #include <alphamap_pars_fragment>
  2602. #include <alphatest_pars_fragment>
  2603. #include <alphahash_pars_fragment>
  2604. #include <logdepthbuf_pars_fragment>
  2605. #include <clipping_planes_pars_fragment>
  2606. varying vec2 vHighPrecisionZW;
  2607. void main() {
  2608. vec4 diffuseColor = vec4( 1.0 );
  2609. #include <clipping_planes_fragment>
  2610. #if DEPTH_PACKING == 3200
  2611. diffuseColor.a = opacity;
  2612. #endif
  2613. #include <map_fragment>
  2614. #include <alphamap_fragment>
  2615. #include <alphatest_fragment>
  2616. #include <alphahash_fragment>
  2617. #include <logdepthbuf_fragment>
  2618. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  2619. #if DEPTH_PACKING == 3200
  2620. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2621. #elif DEPTH_PACKING == 3201
  2622. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2623. #elif DEPTH_PACKING == 3202
  2624. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2625. #elif DEPTH_PACKING == 3203
  2626. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2627. #endif
  2628. }`,av=`#define DISTANCE
  2629. varying vec3 vWorldPosition;
  2630. #include <common>
  2631. #include <batching_pars_vertex>
  2632. #include <uv_pars_vertex>
  2633. #include <displacementmap_pars_vertex>
  2634. #include <morphtarget_pars_vertex>
  2635. #include <skinning_pars_vertex>
  2636. #include <clipping_planes_pars_vertex>
  2637. void main() {
  2638. #include <uv_vertex>
  2639. #include <batching_vertex>
  2640. #include <skinbase_vertex>
  2641. #include <morphinstance_vertex>
  2642. #ifdef USE_DISPLACEMENTMAP
  2643. #include <beginnormal_vertex>
  2644. #include <morphnormal_vertex>
  2645. #include <skinnormal_vertex>
  2646. #endif
  2647. #include <begin_vertex>
  2648. #include <morphtarget_vertex>
  2649. #include <skinning_vertex>
  2650. #include <displacementmap_vertex>
  2651. #include <project_vertex>
  2652. #include <worldpos_vertex>
  2653. #include <clipping_planes_vertex>
  2654. vWorldPosition = worldPosition.xyz;
  2655. }`,lv=`#define DISTANCE
  2656. uniform vec3 referencePosition;
  2657. uniform float nearDistance;
  2658. uniform float farDistance;
  2659. varying vec3 vWorldPosition;
  2660. #include <common>
  2661. #include <packing>
  2662. #include <uv_pars_fragment>
  2663. #include <map_pars_fragment>
  2664. #include <alphamap_pars_fragment>
  2665. #include <alphatest_pars_fragment>
  2666. #include <alphahash_pars_fragment>
  2667. #include <clipping_planes_pars_fragment>
  2668. void main () {
  2669. vec4 diffuseColor = vec4( 1.0 );
  2670. #include <clipping_planes_fragment>
  2671. #include <map_fragment>
  2672. #include <alphamap_fragment>
  2673. #include <alphatest_fragment>
  2674. #include <alphahash_fragment>
  2675. float dist = length( vWorldPosition - referencePosition );
  2676. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2677. dist = saturate( dist );
  2678. gl_FragColor = packDepthToRGBA( dist );
  2679. }`,cv=`varying vec3 vWorldDirection;
  2680. #include <common>
  2681. void main() {
  2682. vWorldDirection = transformDirection( position, modelMatrix );
  2683. #include <begin_vertex>
  2684. #include <project_vertex>
  2685. }`,dv=`uniform sampler2D tEquirect;
  2686. varying vec3 vWorldDirection;
  2687. #include <common>
  2688. void main() {
  2689. vec3 direction = normalize( vWorldDirection );
  2690. vec2 sampleUV = equirectUv( direction );
  2691. gl_FragColor = texture2D( tEquirect, sampleUV );
  2692. #include <tonemapping_fragment>
  2693. #include <colorspace_fragment>
  2694. }`,uv=`uniform float scale;
  2695. attribute float lineDistance;
  2696. varying float vLineDistance;
  2697. #include <common>
  2698. #include <uv_pars_vertex>
  2699. #include <color_pars_vertex>
  2700. #include <fog_pars_vertex>
  2701. #include <morphtarget_pars_vertex>
  2702. #include <logdepthbuf_pars_vertex>
  2703. #include <clipping_planes_pars_vertex>
  2704. void main() {
  2705. vLineDistance = scale * lineDistance;
  2706. #include <uv_vertex>
  2707. #include <color_vertex>
  2708. #include <morphinstance_vertex>
  2709. #include <morphcolor_vertex>
  2710. #include <begin_vertex>
  2711. #include <morphtarget_vertex>
  2712. #include <project_vertex>
  2713. #include <logdepthbuf_vertex>
  2714. #include <clipping_planes_vertex>
  2715. #include <fog_vertex>
  2716. }`,hv=`uniform vec3 diffuse;
  2717. uniform float opacity;
  2718. uniform float dashSize;
  2719. uniform float totalSize;
  2720. varying float vLineDistance;
  2721. #include <common>
  2722. #include <color_pars_fragment>
  2723. #include <uv_pars_fragment>
  2724. #include <map_pars_fragment>
  2725. #include <fog_pars_fragment>
  2726. #include <logdepthbuf_pars_fragment>
  2727. #include <clipping_planes_pars_fragment>
  2728. void main() {
  2729. vec4 diffuseColor = vec4( diffuse, opacity );
  2730. #include <clipping_planes_fragment>
  2731. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2732. discard;
  2733. }
  2734. vec3 outgoingLight = vec3( 0.0 );
  2735. #include <logdepthbuf_fragment>
  2736. #include <map_fragment>
  2737. #include <color_fragment>
  2738. outgoingLight = diffuseColor.rgb;
  2739. #include <opaque_fragment>
  2740. #include <tonemapping_fragment>
  2741. #include <colorspace_fragment>
  2742. #include <fog_fragment>
  2743. #include <premultiplied_alpha_fragment>
  2744. }`,fv=`#include <common>
  2745. #include <batching_pars_vertex>
  2746. #include <uv_pars_vertex>
  2747. #include <envmap_pars_vertex>
  2748. #include <color_pars_vertex>
  2749. #include <fog_pars_vertex>
  2750. #include <morphtarget_pars_vertex>
  2751. #include <skinning_pars_vertex>
  2752. #include <logdepthbuf_pars_vertex>
  2753. #include <clipping_planes_pars_vertex>
  2754. void main() {
  2755. #include <uv_vertex>
  2756. #include <color_vertex>
  2757. #include <morphinstance_vertex>
  2758. #include <morphcolor_vertex>
  2759. #include <batching_vertex>
  2760. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2761. #include <beginnormal_vertex>
  2762. #include <morphnormal_vertex>
  2763. #include <skinbase_vertex>
  2764. #include <skinnormal_vertex>
  2765. #include <defaultnormal_vertex>
  2766. #endif
  2767. #include <begin_vertex>
  2768. #include <morphtarget_vertex>
  2769. #include <skinning_vertex>
  2770. #include <project_vertex>
  2771. #include <logdepthbuf_vertex>
  2772. #include <clipping_planes_vertex>
  2773. #include <worldpos_vertex>
  2774. #include <envmap_vertex>
  2775. #include <fog_vertex>
  2776. }`,pv=`uniform vec3 diffuse;
  2777. uniform float opacity;
  2778. #ifndef FLAT_SHADED
  2779. varying vec3 vNormal;
  2780. #endif
  2781. #include <common>
  2782. #include <dithering_pars_fragment>
  2783. #include <color_pars_fragment>
  2784. #include <uv_pars_fragment>
  2785. #include <map_pars_fragment>
  2786. #include <alphamap_pars_fragment>
  2787. #include <alphatest_pars_fragment>
  2788. #include <alphahash_pars_fragment>
  2789. #include <aomap_pars_fragment>
  2790. #include <lightmap_pars_fragment>
  2791. #include <envmap_common_pars_fragment>
  2792. #include <envmap_pars_fragment>
  2793. #include <fog_pars_fragment>
  2794. #include <specularmap_pars_fragment>
  2795. #include <logdepthbuf_pars_fragment>
  2796. #include <clipping_planes_pars_fragment>
  2797. void main() {
  2798. vec4 diffuseColor = vec4( diffuse, opacity );
  2799. #include <clipping_planes_fragment>
  2800. #include <logdepthbuf_fragment>
  2801. #include <map_fragment>
  2802. #include <color_fragment>
  2803. #include <alphamap_fragment>
  2804. #include <alphatest_fragment>
  2805. #include <alphahash_fragment>
  2806. #include <specularmap_fragment>
  2807. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2808. #ifdef USE_LIGHTMAP
  2809. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2810. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2811. #else
  2812. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2813. #endif
  2814. #include <aomap_fragment>
  2815. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2816. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2817. #include <envmap_fragment>
  2818. #include <opaque_fragment>
  2819. #include <tonemapping_fragment>
  2820. #include <colorspace_fragment>
  2821. #include <fog_fragment>
  2822. #include <premultiplied_alpha_fragment>
  2823. #include <dithering_fragment>
  2824. }`,mv=`#define LAMBERT
  2825. varying vec3 vViewPosition;
  2826. #include <common>
  2827. #include <batching_pars_vertex>
  2828. #include <uv_pars_vertex>
  2829. #include <displacementmap_pars_vertex>
  2830. #include <envmap_pars_vertex>
  2831. #include <color_pars_vertex>
  2832. #include <fog_pars_vertex>
  2833. #include <normal_pars_vertex>
  2834. #include <morphtarget_pars_vertex>
  2835. #include <skinning_pars_vertex>
  2836. #include <shadowmap_pars_vertex>
  2837. #include <logdepthbuf_pars_vertex>
  2838. #include <clipping_planes_pars_vertex>
  2839. void main() {
  2840. #include <uv_vertex>
  2841. #include <color_vertex>
  2842. #include <morphinstance_vertex>
  2843. #include <morphcolor_vertex>
  2844. #include <batching_vertex>
  2845. #include <beginnormal_vertex>
  2846. #include <morphnormal_vertex>
  2847. #include <skinbase_vertex>
  2848. #include <skinnormal_vertex>
  2849. #include <defaultnormal_vertex>
  2850. #include <normal_vertex>
  2851. #include <begin_vertex>
  2852. #include <morphtarget_vertex>
  2853. #include <skinning_vertex>
  2854. #include <displacementmap_vertex>
  2855. #include <project_vertex>
  2856. #include <logdepthbuf_vertex>
  2857. #include <clipping_planes_vertex>
  2858. vViewPosition = - mvPosition.xyz;
  2859. #include <worldpos_vertex>
  2860. #include <envmap_vertex>
  2861. #include <shadowmap_vertex>
  2862. #include <fog_vertex>
  2863. }`,gv=`#define LAMBERT
  2864. uniform vec3 diffuse;
  2865. uniform vec3 emissive;
  2866. uniform float opacity;
  2867. #include <common>
  2868. #include <packing>
  2869. #include <dithering_pars_fragment>
  2870. #include <color_pars_fragment>
  2871. #include <uv_pars_fragment>
  2872. #include <map_pars_fragment>
  2873. #include <alphamap_pars_fragment>
  2874. #include <alphatest_pars_fragment>
  2875. #include <alphahash_pars_fragment>
  2876. #include <aomap_pars_fragment>
  2877. #include <lightmap_pars_fragment>
  2878. #include <emissivemap_pars_fragment>
  2879. #include <envmap_common_pars_fragment>
  2880. #include <envmap_pars_fragment>
  2881. #include <fog_pars_fragment>
  2882. #include <bsdfs>
  2883. #include <lights_pars_begin>
  2884. #include <normal_pars_fragment>
  2885. #include <lights_lambert_pars_fragment>
  2886. #include <shadowmap_pars_fragment>
  2887. #include <bumpmap_pars_fragment>
  2888. #include <normalmap_pars_fragment>
  2889. #include <specularmap_pars_fragment>
  2890. #include <logdepthbuf_pars_fragment>
  2891. #include <clipping_planes_pars_fragment>
  2892. void main() {
  2893. vec4 diffuseColor = vec4( diffuse, opacity );
  2894. #include <clipping_planes_fragment>
  2895. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2896. vec3 totalEmissiveRadiance = emissive;
  2897. #include <logdepthbuf_fragment>
  2898. #include <map_fragment>
  2899. #include <color_fragment>
  2900. #include <alphamap_fragment>
  2901. #include <alphatest_fragment>
  2902. #include <alphahash_fragment>
  2903. #include <specularmap_fragment>
  2904. #include <normal_fragment_begin>
  2905. #include <normal_fragment_maps>
  2906. #include <emissivemap_fragment>
  2907. #include <lights_lambert_fragment>
  2908. #include <lights_fragment_begin>
  2909. #include <lights_fragment_maps>
  2910. #include <lights_fragment_end>
  2911. #include <aomap_fragment>
  2912. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2913. #include <envmap_fragment>
  2914. #include <opaque_fragment>
  2915. #include <tonemapping_fragment>
  2916. #include <colorspace_fragment>
  2917. #include <fog_fragment>
  2918. #include <premultiplied_alpha_fragment>
  2919. #include <dithering_fragment>
  2920. }`,_v=`#define MATCAP
  2921. varying vec3 vViewPosition;
  2922. #include <common>
  2923. #include <batching_pars_vertex>
  2924. #include <uv_pars_vertex>
  2925. #include <color_pars_vertex>
  2926. #include <displacementmap_pars_vertex>
  2927. #include <fog_pars_vertex>
  2928. #include <normal_pars_vertex>
  2929. #include <morphtarget_pars_vertex>
  2930. #include <skinning_pars_vertex>
  2931. #include <logdepthbuf_pars_vertex>
  2932. #include <clipping_planes_pars_vertex>
  2933. void main() {
  2934. #include <uv_vertex>
  2935. #include <color_vertex>
  2936. #include <morphinstance_vertex>
  2937. #include <morphcolor_vertex>
  2938. #include <batching_vertex>
  2939. #include <beginnormal_vertex>
  2940. #include <morphnormal_vertex>
  2941. #include <skinbase_vertex>
  2942. #include <skinnormal_vertex>
  2943. #include <defaultnormal_vertex>
  2944. #include <normal_vertex>
  2945. #include <begin_vertex>
  2946. #include <morphtarget_vertex>
  2947. #include <skinning_vertex>
  2948. #include <displacementmap_vertex>
  2949. #include <project_vertex>
  2950. #include <logdepthbuf_vertex>
  2951. #include <clipping_planes_vertex>
  2952. #include <fog_vertex>
  2953. vViewPosition = - mvPosition.xyz;
  2954. }`,vv=`#define MATCAP
  2955. uniform vec3 diffuse;
  2956. uniform float opacity;
  2957. uniform sampler2D matcap;
  2958. varying vec3 vViewPosition;
  2959. #include <common>
  2960. #include <dithering_pars_fragment>
  2961. #include <color_pars_fragment>
  2962. #include <uv_pars_fragment>
  2963. #include <map_pars_fragment>
  2964. #include <alphamap_pars_fragment>
  2965. #include <alphatest_pars_fragment>
  2966. #include <alphahash_pars_fragment>
  2967. #include <fog_pars_fragment>
  2968. #include <normal_pars_fragment>
  2969. #include <bumpmap_pars_fragment>
  2970. #include <normalmap_pars_fragment>
  2971. #include <logdepthbuf_pars_fragment>
  2972. #include <clipping_planes_pars_fragment>
  2973. void main() {
  2974. vec4 diffuseColor = vec4( diffuse, opacity );
  2975. #include <clipping_planes_fragment>
  2976. #include <logdepthbuf_fragment>
  2977. #include <map_fragment>
  2978. #include <color_fragment>
  2979. #include <alphamap_fragment>
  2980. #include <alphatest_fragment>
  2981. #include <alphahash_fragment>
  2982. #include <normal_fragment_begin>
  2983. #include <normal_fragment_maps>
  2984. vec3 viewDir = normalize( vViewPosition );
  2985. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  2986. vec3 y = cross( viewDir, x );
  2987. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  2988. #ifdef USE_MATCAP
  2989. vec4 matcapColor = texture2D( matcap, uv );
  2990. #else
  2991. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  2992. #endif
  2993. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  2994. #include <opaque_fragment>
  2995. #include <tonemapping_fragment>
  2996. #include <colorspace_fragment>
  2997. #include <fog_fragment>
  2998. #include <premultiplied_alpha_fragment>
  2999. #include <dithering_fragment>
  3000. }`,xv=`#define NORMAL
  3001. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3002. varying vec3 vViewPosition;
  3003. #endif
  3004. #include <common>
  3005. #include <batching_pars_vertex>
  3006. #include <uv_pars_vertex>
  3007. #include <displacementmap_pars_vertex>
  3008. #include <normal_pars_vertex>
  3009. #include <morphtarget_pars_vertex>
  3010. #include <skinning_pars_vertex>
  3011. #include <logdepthbuf_pars_vertex>
  3012. #include <clipping_planes_pars_vertex>
  3013. void main() {
  3014. #include <uv_vertex>
  3015. #include <batching_vertex>
  3016. #include <beginnormal_vertex>
  3017. #include <morphinstance_vertex>
  3018. #include <morphnormal_vertex>
  3019. #include <skinbase_vertex>
  3020. #include <skinnormal_vertex>
  3021. #include <defaultnormal_vertex>
  3022. #include <normal_vertex>
  3023. #include <begin_vertex>
  3024. #include <morphtarget_vertex>
  3025. #include <skinning_vertex>
  3026. #include <displacementmap_vertex>
  3027. #include <project_vertex>
  3028. #include <logdepthbuf_vertex>
  3029. #include <clipping_planes_vertex>
  3030. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3031. vViewPosition = - mvPosition.xyz;
  3032. #endif
  3033. }`,Sv=`#define NORMAL
  3034. uniform float opacity;
  3035. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3036. varying vec3 vViewPosition;
  3037. #endif
  3038. #include <packing>
  3039. #include <uv_pars_fragment>
  3040. #include <normal_pars_fragment>
  3041. #include <bumpmap_pars_fragment>
  3042. #include <normalmap_pars_fragment>
  3043. #include <logdepthbuf_pars_fragment>
  3044. #include <clipping_planes_pars_fragment>
  3045. void main() {
  3046. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3047. #include <clipping_planes_fragment>
  3048. #include <logdepthbuf_fragment>
  3049. #include <normal_fragment_begin>
  3050. #include <normal_fragment_maps>
  3051. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3052. #ifdef OPAQUE
  3053. gl_FragColor.a = 1.0;
  3054. #endif
  3055. }`,yv=`#define PHONG
  3056. varying vec3 vViewPosition;
  3057. #include <common>
  3058. #include <batching_pars_vertex>
  3059. #include <uv_pars_vertex>
  3060. #include <displacementmap_pars_vertex>
  3061. #include <envmap_pars_vertex>
  3062. #include <color_pars_vertex>
  3063. #include <fog_pars_vertex>
  3064. #include <normal_pars_vertex>
  3065. #include <morphtarget_pars_vertex>
  3066. #include <skinning_pars_vertex>
  3067. #include <shadowmap_pars_vertex>
  3068. #include <logdepthbuf_pars_vertex>
  3069. #include <clipping_planes_pars_vertex>
  3070. void main() {
  3071. #include <uv_vertex>
  3072. #include <color_vertex>
  3073. #include <morphcolor_vertex>
  3074. #include <batching_vertex>
  3075. #include <beginnormal_vertex>
  3076. #include <morphinstance_vertex>
  3077. #include <morphnormal_vertex>
  3078. #include <skinbase_vertex>
  3079. #include <skinnormal_vertex>
  3080. #include <defaultnormal_vertex>
  3081. #include <normal_vertex>
  3082. #include <begin_vertex>
  3083. #include <morphtarget_vertex>
  3084. #include <skinning_vertex>
  3085. #include <displacementmap_vertex>
  3086. #include <project_vertex>
  3087. #include <logdepthbuf_vertex>
  3088. #include <clipping_planes_vertex>
  3089. vViewPosition = - mvPosition.xyz;
  3090. #include <worldpos_vertex>
  3091. #include <envmap_vertex>
  3092. #include <shadowmap_vertex>
  3093. #include <fog_vertex>
  3094. }`,Mv=`#define PHONG
  3095. uniform vec3 diffuse;
  3096. uniform vec3 emissive;
  3097. uniform vec3 specular;
  3098. uniform float shininess;
  3099. uniform float opacity;
  3100. #include <common>
  3101. #include <packing>
  3102. #include <dithering_pars_fragment>
  3103. #include <color_pars_fragment>
  3104. #include <uv_pars_fragment>
  3105. #include <map_pars_fragment>
  3106. #include <alphamap_pars_fragment>
  3107. #include <alphatest_pars_fragment>
  3108. #include <alphahash_pars_fragment>
  3109. #include <aomap_pars_fragment>
  3110. #include <lightmap_pars_fragment>
  3111. #include <emissivemap_pars_fragment>
  3112. #include <envmap_common_pars_fragment>
  3113. #include <envmap_pars_fragment>
  3114. #include <fog_pars_fragment>
  3115. #include <bsdfs>
  3116. #include <lights_pars_begin>
  3117. #include <normal_pars_fragment>
  3118. #include <lights_phong_pars_fragment>
  3119. #include <shadowmap_pars_fragment>
  3120. #include <bumpmap_pars_fragment>
  3121. #include <normalmap_pars_fragment>
  3122. #include <specularmap_pars_fragment>
  3123. #include <logdepthbuf_pars_fragment>
  3124. #include <clipping_planes_pars_fragment>
  3125. void main() {
  3126. vec4 diffuseColor = vec4( diffuse, opacity );
  3127. #include <clipping_planes_fragment>
  3128. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3129. vec3 totalEmissiveRadiance = emissive;
  3130. #include <logdepthbuf_fragment>
  3131. #include <map_fragment>
  3132. #include <color_fragment>
  3133. #include <alphamap_fragment>
  3134. #include <alphatest_fragment>
  3135. #include <alphahash_fragment>
  3136. #include <specularmap_fragment>
  3137. #include <normal_fragment_begin>
  3138. #include <normal_fragment_maps>
  3139. #include <emissivemap_fragment>
  3140. #include <lights_phong_fragment>
  3141. #include <lights_fragment_begin>
  3142. #include <lights_fragment_maps>
  3143. #include <lights_fragment_end>
  3144. #include <aomap_fragment>
  3145. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3146. #include <envmap_fragment>
  3147. #include <opaque_fragment>
  3148. #include <tonemapping_fragment>
  3149. #include <colorspace_fragment>
  3150. #include <fog_fragment>
  3151. #include <premultiplied_alpha_fragment>
  3152. #include <dithering_fragment>
  3153. }`,Ev=`#define STANDARD
  3154. varying vec3 vViewPosition;
  3155. #ifdef USE_TRANSMISSION
  3156. varying vec3 vWorldPosition;
  3157. #endif
  3158. #include <common>
  3159. #include <batching_pars_vertex>
  3160. #include <uv_pars_vertex>
  3161. #include <displacementmap_pars_vertex>
  3162. #include <color_pars_vertex>
  3163. #include <fog_pars_vertex>
  3164. #include <normal_pars_vertex>
  3165. #include <morphtarget_pars_vertex>
  3166. #include <skinning_pars_vertex>
  3167. #include <shadowmap_pars_vertex>
  3168. #include <logdepthbuf_pars_vertex>
  3169. #include <clipping_planes_pars_vertex>
  3170. void main() {
  3171. #include <uv_vertex>
  3172. #include <color_vertex>
  3173. #include <morphinstance_vertex>
  3174. #include <morphcolor_vertex>
  3175. #include <batching_vertex>
  3176. #include <beginnormal_vertex>
  3177. #include <morphnormal_vertex>
  3178. #include <skinbase_vertex>
  3179. #include <skinnormal_vertex>
  3180. #include <defaultnormal_vertex>
  3181. #include <normal_vertex>
  3182. #include <begin_vertex>
  3183. #include <morphtarget_vertex>
  3184. #include <skinning_vertex>
  3185. #include <displacementmap_vertex>
  3186. #include <project_vertex>
  3187. #include <logdepthbuf_vertex>
  3188. #include <clipping_planes_vertex>
  3189. vViewPosition = - mvPosition.xyz;
  3190. #include <worldpos_vertex>
  3191. #include <shadowmap_vertex>
  3192. #include <fog_vertex>
  3193. #ifdef USE_TRANSMISSION
  3194. vWorldPosition = worldPosition.xyz;
  3195. #endif
  3196. }`,bv=`#define STANDARD
  3197. #ifdef PHYSICAL
  3198. #define IOR
  3199. #define USE_SPECULAR
  3200. #endif
  3201. uniform vec3 diffuse;
  3202. uniform vec3 emissive;
  3203. uniform float roughness;
  3204. uniform float metalness;
  3205. uniform float opacity;
  3206. #ifdef IOR
  3207. uniform float ior;
  3208. #endif
  3209. #ifdef USE_SPECULAR
  3210. uniform float specularIntensity;
  3211. uniform vec3 specularColor;
  3212. #ifdef USE_SPECULAR_COLORMAP
  3213. uniform sampler2D specularColorMap;
  3214. #endif
  3215. #ifdef USE_SPECULAR_INTENSITYMAP
  3216. uniform sampler2D specularIntensityMap;
  3217. #endif
  3218. #endif
  3219. #ifdef USE_CLEARCOAT
  3220. uniform float clearcoat;
  3221. uniform float clearcoatRoughness;
  3222. #endif
  3223. #ifdef USE_DISPERSION
  3224. uniform float dispersion;
  3225. #endif
  3226. #ifdef USE_IRIDESCENCE
  3227. uniform float iridescence;
  3228. uniform float iridescenceIOR;
  3229. uniform float iridescenceThicknessMinimum;
  3230. uniform float iridescenceThicknessMaximum;
  3231. #endif
  3232. #ifdef USE_SHEEN
  3233. uniform vec3 sheenColor;
  3234. uniform float sheenRoughness;
  3235. #ifdef USE_SHEEN_COLORMAP
  3236. uniform sampler2D sheenColorMap;
  3237. #endif
  3238. #ifdef USE_SHEEN_ROUGHNESSMAP
  3239. uniform sampler2D sheenRoughnessMap;
  3240. #endif
  3241. #endif
  3242. #ifdef USE_ANISOTROPY
  3243. uniform vec2 anisotropyVector;
  3244. #ifdef USE_ANISOTROPYMAP
  3245. uniform sampler2D anisotropyMap;
  3246. #endif
  3247. #endif
  3248. varying vec3 vViewPosition;
  3249. #include <common>
  3250. #include <packing>
  3251. #include <dithering_pars_fragment>
  3252. #include <color_pars_fragment>
  3253. #include <uv_pars_fragment>
  3254. #include <map_pars_fragment>
  3255. #include <alphamap_pars_fragment>
  3256. #include <alphatest_pars_fragment>
  3257. #include <alphahash_pars_fragment>
  3258. #include <aomap_pars_fragment>
  3259. #include <lightmap_pars_fragment>
  3260. #include <emissivemap_pars_fragment>
  3261. #include <iridescence_fragment>
  3262. #include <cube_uv_reflection_fragment>
  3263. #include <envmap_common_pars_fragment>
  3264. #include <envmap_physical_pars_fragment>
  3265. #include <fog_pars_fragment>
  3266. #include <lights_pars_begin>
  3267. #include <normal_pars_fragment>
  3268. #include <lights_physical_pars_fragment>
  3269. #include <transmission_pars_fragment>
  3270. #include <shadowmap_pars_fragment>
  3271. #include <bumpmap_pars_fragment>
  3272. #include <normalmap_pars_fragment>
  3273. #include <clearcoat_pars_fragment>
  3274. #include <iridescence_pars_fragment>
  3275. #include <roughnessmap_pars_fragment>
  3276. #include <metalnessmap_pars_fragment>
  3277. #include <logdepthbuf_pars_fragment>
  3278. #include <clipping_planes_pars_fragment>
  3279. void main() {
  3280. vec4 diffuseColor = vec4( diffuse, opacity );
  3281. #include <clipping_planes_fragment>
  3282. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3283. vec3 totalEmissiveRadiance = emissive;
  3284. #include <logdepthbuf_fragment>
  3285. #include <map_fragment>
  3286. #include <color_fragment>
  3287. #include <alphamap_fragment>
  3288. #include <alphatest_fragment>
  3289. #include <alphahash_fragment>
  3290. #include <roughnessmap_fragment>
  3291. #include <metalnessmap_fragment>
  3292. #include <normal_fragment_begin>
  3293. #include <normal_fragment_maps>
  3294. #include <clearcoat_normal_fragment_begin>
  3295. #include <clearcoat_normal_fragment_maps>
  3296. #include <emissivemap_fragment>
  3297. #include <lights_physical_fragment>
  3298. #include <lights_fragment_begin>
  3299. #include <lights_fragment_maps>
  3300. #include <lights_fragment_end>
  3301. #include <aomap_fragment>
  3302. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3303. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3304. #include <transmission_fragment>
  3305. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3306. #ifdef USE_SHEEN
  3307. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3308. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3309. #endif
  3310. #ifdef USE_CLEARCOAT
  3311. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3312. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3313. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3314. #endif
  3315. #include <opaque_fragment>
  3316. #include <tonemapping_fragment>
  3317. #include <colorspace_fragment>
  3318. #include <fog_fragment>
  3319. #include <premultiplied_alpha_fragment>
  3320. #include <dithering_fragment>
  3321. }`,wv=`#define TOON
  3322. varying vec3 vViewPosition;
  3323. #include <common>
  3324. #include <batching_pars_vertex>
  3325. #include <uv_pars_vertex>
  3326. #include <displacementmap_pars_vertex>
  3327. #include <color_pars_vertex>
  3328. #include <fog_pars_vertex>
  3329. #include <normal_pars_vertex>
  3330. #include <morphtarget_pars_vertex>
  3331. #include <skinning_pars_vertex>
  3332. #include <shadowmap_pars_vertex>
  3333. #include <logdepthbuf_pars_vertex>
  3334. #include <clipping_planes_pars_vertex>
  3335. void main() {
  3336. #include <uv_vertex>
  3337. #include <color_vertex>
  3338. #include <morphinstance_vertex>
  3339. #include <morphcolor_vertex>
  3340. #include <batching_vertex>
  3341. #include <beginnormal_vertex>
  3342. #include <morphnormal_vertex>
  3343. #include <skinbase_vertex>
  3344. #include <skinnormal_vertex>
  3345. #include <defaultnormal_vertex>
  3346. #include <normal_vertex>
  3347. #include <begin_vertex>
  3348. #include <morphtarget_vertex>
  3349. #include <skinning_vertex>
  3350. #include <displacementmap_vertex>
  3351. #include <project_vertex>
  3352. #include <logdepthbuf_vertex>
  3353. #include <clipping_planes_vertex>
  3354. vViewPosition = - mvPosition.xyz;
  3355. #include <worldpos_vertex>
  3356. #include <shadowmap_vertex>
  3357. #include <fog_vertex>
  3358. }`,Tv=`#define TOON
  3359. uniform vec3 diffuse;
  3360. uniform vec3 emissive;
  3361. uniform float opacity;
  3362. #include <common>
  3363. #include <packing>
  3364. #include <dithering_pars_fragment>
  3365. #include <color_pars_fragment>
  3366. #include <uv_pars_fragment>
  3367. #include <map_pars_fragment>
  3368. #include <alphamap_pars_fragment>
  3369. #include <alphatest_pars_fragment>
  3370. #include <alphahash_pars_fragment>
  3371. #include <aomap_pars_fragment>
  3372. #include <lightmap_pars_fragment>
  3373. #include <emissivemap_pars_fragment>
  3374. #include <gradientmap_pars_fragment>
  3375. #include <fog_pars_fragment>
  3376. #include <bsdfs>
  3377. #include <lights_pars_begin>
  3378. #include <normal_pars_fragment>
  3379. #include <lights_toon_pars_fragment>
  3380. #include <shadowmap_pars_fragment>
  3381. #include <bumpmap_pars_fragment>
  3382. #include <normalmap_pars_fragment>
  3383. #include <logdepthbuf_pars_fragment>
  3384. #include <clipping_planes_pars_fragment>
  3385. void main() {
  3386. vec4 diffuseColor = vec4( diffuse, opacity );
  3387. #include <clipping_planes_fragment>
  3388. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3389. vec3 totalEmissiveRadiance = emissive;
  3390. #include <logdepthbuf_fragment>
  3391. #include <map_fragment>
  3392. #include <color_fragment>
  3393. #include <alphamap_fragment>
  3394. #include <alphatest_fragment>
  3395. #include <alphahash_fragment>
  3396. #include <normal_fragment_begin>
  3397. #include <normal_fragment_maps>
  3398. #include <emissivemap_fragment>
  3399. #include <lights_toon_fragment>
  3400. #include <lights_fragment_begin>
  3401. #include <lights_fragment_maps>
  3402. #include <lights_fragment_end>
  3403. #include <aomap_fragment>
  3404. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3405. #include <opaque_fragment>
  3406. #include <tonemapping_fragment>
  3407. #include <colorspace_fragment>
  3408. #include <fog_fragment>
  3409. #include <premultiplied_alpha_fragment>
  3410. #include <dithering_fragment>
  3411. }`,Av=`uniform float size;
  3412. uniform float scale;
  3413. #include <common>
  3414. #include <color_pars_vertex>
  3415. #include <fog_pars_vertex>
  3416. #include <morphtarget_pars_vertex>
  3417. #include <logdepthbuf_pars_vertex>
  3418. #include <clipping_planes_pars_vertex>
  3419. #ifdef USE_POINTS_UV
  3420. varying vec2 vUv;
  3421. uniform mat3 uvTransform;
  3422. #endif
  3423. void main() {
  3424. #ifdef USE_POINTS_UV
  3425. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3426. #endif
  3427. #include <color_vertex>
  3428. #include <morphinstance_vertex>
  3429. #include <morphcolor_vertex>
  3430. #include <begin_vertex>
  3431. #include <morphtarget_vertex>
  3432. #include <project_vertex>
  3433. gl_PointSize = size;
  3434. #ifdef USE_SIZEATTENUATION
  3435. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3436. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3437. #endif
  3438. #include <logdepthbuf_vertex>
  3439. #include <clipping_planes_vertex>
  3440. #include <worldpos_vertex>
  3441. #include <fog_vertex>
  3442. }`,Cv=`uniform vec3 diffuse;
  3443. uniform float opacity;
  3444. #include <common>
  3445. #include <color_pars_fragment>
  3446. #include <map_particle_pars_fragment>
  3447. #include <alphatest_pars_fragment>
  3448. #include <alphahash_pars_fragment>
  3449. #include <fog_pars_fragment>
  3450. #include <logdepthbuf_pars_fragment>
  3451. #include <clipping_planes_pars_fragment>
  3452. void main() {
  3453. vec4 diffuseColor = vec4( diffuse, opacity );
  3454. #include <clipping_planes_fragment>
  3455. vec3 outgoingLight = vec3( 0.0 );
  3456. #include <logdepthbuf_fragment>
  3457. #include <map_particle_fragment>
  3458. #include <color_fragment>
  3459. #include <alphatest_fragment>
  3460. #include <alphahash_fragment>
  3461. outgoingLight = diffuseColor.rgb;
  3462. #include <opaque_fragment>
  3463. #include <tonemapping_fragment>
  3464. #include <colorspace_fragment>
  3465. #include <fog_fragment>
  3466. #include <premultiplied_alpha_fragment>
  3467. }`,Rv=`#include <common>
  3468. #include <batching_pars_vertex>
  3469. #include <fog_pars_vertex>
  3470. #include <morphtarget_pars_vertex>
  3471. #include <skinning_pars_vertex>
  3472. #include <logdepthbuf_pars_vertex>
  3473. #include <shadowmap_pars_vertex>
  3474. void main() {
  3475. #include <batching_vertex>
  3476. #include <beginnormal_vertex>
  3477. #include <morphinstance_vertex>
  3478. #include <morphnormal_vertex>
  3479. #include <skinbase_vertex>
  3480. #include <skinnormal_vertex>
  3481. #include <defaultnormal_vertex>
  3482. #include <begin_vertex>
  3483. #include <morphtarget_vertex>
  3484. #include <skinning_vertex>
  3485. #include <project_vertex>
  3486. #include <logdepthbuf_vertex>
  3487. #include <worldpos_vertex>
  3488. #include <shadowmap_vertex>
  3489. #include <fog_vertex>
  3490. }`,Pv=`uniform vec3 color;
  3491. uniform float opacity;
  3492. #include <common>
  3493. #include <packing>
  3494. #include <fog_pars_fragment>
  3495. #include <bsdfs>
  3496. #include <lights_pars_begin>
  3497. #include <logdepthbuf_pars_fragment>
  3498. #include <shadowmap_pars_fragment>
  3499. #include <shadowmask_pars_fragment>
  3500. void main() {
  3501. #include <logdepthbuf_fragment>
  3502. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3503. #include <tonemapping_fragment>
  3504. #include <colorspace_fragment>
  3505. #include <fog_fragment>
  3506. }`,Dv=`uniform float rotation;
  3507. uniform vec2 center;
  3508. #include <common>
  3509. #include <uv_pars_vertex>
  3510. #include <fog_pars_vertex>
  3511. #include <logdepthbuf_pars_vertex>
  3512. #include <clipping_planes_pars_vertex>
  3513. void main() {
  3514. #include <uv_vertex>
  3515. vec4 mvPosition = modelViewMatrix[ 3 ];
  3516. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3517. #ifndef USE_SIZEATTENUATION
  3518. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3519. if ( isPerspective ) scale *= - mvPosition.z;
  3520. #endif
  3521. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3522. vec2 rotatedPosition;
  3523. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3524. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3525. mvPosition.xy += rotatedPosition;
  3526. gl_Position = projectionMatrix * mvPosition;
  3527. #include <logdepthbuf_vertex>
  3528. #include <clipping_planes_vertex>
  3529. #include <fog_vertex>
  3530. }`,Lv=`uniform vec3 diffuse;
  3531. uniform float opacity;
  3532. #include <common>
  3533. #include <uv_pars_fragment>
  3534. #include <map_pars_fragment>
  3535. #include <alphamap_pars_fragment>
  3536. #include <alphatest_pars_fragment>
  3537. #include <alphahash_pars_fragment>
  3538. #include <fog_pars_fragment>
  3539. #include <logdepthbuf_pars_fragment>
  3540. #include <clipping_planes_pars_fragment>
  3541. void main() {
  3542. vec4 diffuseColor = vec4( diffuse, opacity );
  3543. #include <clipping_planes_fragment>
  3544. vec3 outgoingLight = vec3( 0.0 );
  3545. #include <logdepthbuf_fragment>
  3546. #include <map_fragment>
  3547. #include <alphamap_fragment>
  3548. #include <alphatest_fragment>
  3549. #include <alphahash_fragment>
  3550. outgoingLight = diffuseColor.rgb;
  3551. #include <opaque_fragment>
  3552. #include <tonemapping_fragment>
  3553. #include <colorspace_fragment>
  3554. #include <fog_fragment>
  3555. }`,Fe={alphahash_fragment:eg,alphahash_pars_fragment:tg,alphamap_fragment:ng,alphamap_pars_fragment:ig,alphatest_fragment:sg,alphatest_pars_fragment:rg,aomap_fragment:og,aomap_pars_fragment:ag,batching_pars_vertex:lg,batching_vertex:cg,begin_vertex:dg,beginnormal_vertex:ug,bsdfs:hg,iridescence_fragment:fg,bumpmap_pars_fragment:pg,clipping_planes_fragment:mg,clipping_planes_pars_fragment:gg,clipping_planes_pars_vertex:_g,clipping_planes_vertex:vg,color_fragment:xg,color_pars_fragment:Sg,color_pars_vertex:yg,color_vertex:Mg,common:Eg,cube_uv_reflection_fragment:bg,defaultnormal_vertex:wg,displacementmap_pars_vertex:Tg,displacementmap_vertex:Ag,emissivemap_fragment:Cg,emissivemap_pars_fragment:Rg,colorspace_fragment:Pg,colorspace_pars_fragment:Dg,envmap_fragment:Lg,envmap_common_pars_fragment:Ig,envmap_pars_fragment:Ug,envmap_pars_vertex:Ng,envmap_physical_pars_fragment:Yg,envmap_vertex:Og,fog_vertex:Fg,fog_pars_vertex:Bg,fog_fragment:zg,fog_pars_fragment:kg,gradientmap_pars_fragment:Hg,lightmap_pars_fragment:Gg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Wg,lights_pars_begin:Xg,lights_toon_fragment:qg,lights_toon_pars_fragment:jg,lights_phong_fragment:$g,lights_phong_pars_fragment:Zg,lights_physical_fragment:Kg,lights_physical_pars_fragment:Jg,lights_fragment_begin:Qg,lights_fragment_maps:e_,lights_fragment_end:t_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:o_,map_pars_fragment:a_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:d_,metalnessmap_pars_fragment:u_,morphinstance_vertex:h_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:v_,normal_pars_fragment:x_,normal_pars_vertex:S_,normal_vertex:y_,normalmap_pars_fragment:M_,clearcoat_normal_fragment_begin:E_,clearcoat_normal_fragment_maps:b_,clearcoat_pars_fragment:w_,iridescence_pars_fragment:T_,opaque_fragment:A_,packing:C_,premultiplied_alpha_fragment:R_,project_vertex:P_,dithering_fragment:D_,dithering_pars_fragment:L_,roughnessmap_fragment:I_,roughnessmap_pars_fragment:U_,shadowmap_pars_fragment:N_,shadowmap_pars_vertex:O_,shadowmap_vertex:F_,shadowmask_pars_fragment:B_,skinbase_vertex:z_,skinning_pars_vertex:k_,skinning_vertex:H_,skinnormal_vertex:G_,specularmap_fragment:V_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:Y_,transmission_fragment:q_,transmission_pars_fragment:j_,uv_pars_fragment:$_,uv_pars_vertex:Z_,uv_vertex:K_,worldpos_vertex:J_,background_vert:Q_,background_frag:ev,backgroundCube_vert:tv,backgroundCube_frag:nv,cube_vert:iv,cube_frag:sv,depth_vert:rv,depth_frag:ov,distanceRGBA_vert:av,distanceRGBA_frag:lv,equirect_vert:cv,equirect_frag:dv,linedashed_vert:uv,linedashed_frag:hv,meshbasic_vert:fv,meshbasic_frag:pv,meshlambert_vert:mv,meshlambert_frag:gv,meshmatcap_vert:_v,meshmatcap_frag:vv,meshnormal_vert:xv,meshnormal_frag:Sv,meshphong_vert:yv,meshphong_frag:Mv,meshphysical_vert:Ev,meshphysical_frag:bv,meshtoon_vert:wv,meshtoon_frag:Tv,points_vert:Av,points_frag:Cv,shadow_vert:Rv,shadow_frag:Pv,sprite_vert:Dv,sprite_frag:Lv},ie={common:{diffuse:{value:new Ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ne},alphaMap:{value:null},alphaMapTransform:{value:new Ne},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ne}},envmap:{envMap:{value:null},envMapRotation:{value:new Ne},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ne}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ne}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ne},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ne},normalScale:{value:new Te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ne},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ne}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ne}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ne}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ne},alphaTest:{value:0},uvTransform:{value:new Ne}},sprite:{diffuse:{value:new Ze(16777215)},opacity:{value:1},center:{value:new Te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ne},alphaMap:{value:null},alphaMapTransform:{value:new Ne},alphaTest:{value:0}}},Qt={basic:{uniforms:Wt([ie.common,ie.specularmap,ie.envmap,ie.aomap,ie.lightmap,ie.fog]),vertexShader:Fe.meshbasic_vert,fragmentShader:Fe.meshbasic_frag},lambert:{uniforms:Wt([ie.common,ie.specularmap,ie.envmap,ie.aomap,ie.lightmap,ie.emissivemap,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.fog,ie.lights,{emissive:{value:new Ze(0)}}]),vertexShader:Fe.meshlambert_vert,fragmentShader:Fe.meshlambert_frag},phong:{uniforms:Wt([ie.common,ie.specularmap,ie.envmap,ie.aomap,ie.lightmap,ie.emissivemap,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.fog,ie.lights,{emissive:{value:new Ze(0)},specular:{value:new Ze(1118481)},shininess:{value:30}}]),vertexShader:Fe.meshphong_vert,fragmentShader:Fe.meshphong_frag},standard:{uniforms:Wt([ie.common,ie.envmap,ie.aomap,ie.lightmap,ie.emissivemap,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.roughnessmap,ie.metalnessmap,ie.fog,ie.lights,{emissive:{value:new Ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Fe.meshphysical_vert,fragmentShader:Fe.meshphysical_frag},toon:{uniforms:Wt([ie.common,ie.aomap,ie.lightmap,ie.emissivemap,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.gradientmap,ie.fog,ie.lights,{emissive:{value:new Ze(0)}}]),vertexShader:Fe.meshtoon_vert,fragmentShader:Fe.meshtoon_frag},matcap:{uniforms:Wt([ie.common,ie.bumpmap,ie.normalmap,ie.displacementmap,ie.fog,{matcap:{value:null}}]),vertexShader:Fe.meshmatcap_vert,fragmentShader:Fe.meshmatcap_frag},points:{uniforms:Wt([ie.points,ie.fog]),vertexShader:Fe.points_vert,fragmentShader:Fe.points_frag},dashed:{uniforms:Wt([ie.common,ie.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Fe.linedashed_vert,fragmentShader:Fe.linedashed_frag},depth:{uniforms:Wt([ie.common,ie.displacementmap]),vertexShader:Fe.depth_vert,fragmentShader:Fe.depth_frag},normal:{uniforms:Wt([ie.common,ie.bumpmap,ie.normalmap,ie.displacementmap,{opacity:{value:1}}]),vertexShader:Fe.meshnormal_vert,fragmentShader:Fe.meshnormal_frag},sprite:{uniforms:Wt([ie.sprite,ie.fog]),vertexShader:Fe.sprite_vert,fragmentShader:Fe.sprite_frag},background:{uniforms:{uvTransform:{value:new Ne},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Fe.background_vert,fragmentShader:Fe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ne}},vertexShader:Fe.backgroundCube_vert,fragmentShader:Fe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Fe.cube_vert,fragmentShader:Fe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Fe.equirect_vert,fragmentShader:Fe.equirect_frag},distanceRGBA:{uniforms:Wt([ie.common,ie.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Fe.distanceRGBA_vert,fragmentShader:Fe.distanceRGBA_frag},shadow:{uniforms:Wt([ie.lights,ie.fog,{color:{value:new Ze(0)},opacity:{value:1}}]),vertexShader:Fe.shadow_vert,fragmentShader:Fe.shadow_frag}};Qt.physical={uniforms:Wt([Qt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ne},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ne},clearcoatNormalScale:{value:new Te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ne},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ne},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ne},sheen:{value:0},sheenColor:{value:new Ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ne},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ne},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ne},transmissionSamplerSize:{value:new Te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ne},attenuationDistance:{value:0},attenuationColor:{value:new Ze(0)},specularColor:{value:new Ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ne},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ne},anisotropyVector:{value:new Te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ne}}]),vertexShader:Fe.meshphysical_vert,fragmentShader:Fe.meshphysical_frag};const Ur={r:0,b:0,g:0},Ri=new ni,Iv=new pt;function Uv(n,e,t,i,s,r,o){const a=new Ze(0);let l=r===!0?0:1,c,d,u=null,h=0,f=null;function g(y){let S=y.isScene===!0?y.background:null;return S&&S.isTexture&&(S=(y.backgroundBlurriness>0?t:e).get(S)),S}function _(y){let S=!1;const C=g(y);C===null?p(a,l):C&&C.isColor&&(p(C,1),S=!0);const T=n.xr.getEnvironmentBlendMode();T==="additive"?i.buffers.color.setClear(0,0,0,1,o):T==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||S)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function m(y,S){const C=g(S);C&&(C.isCubeTexture||C.mapping===Eo)?(d===void 0&&(d=new vt(new nr(1,1,1),new ii({name:"BackgroundCubeMaterial",uniforms:As(Qt.backgroundCube.uniforms),vertexShader:Qt.backgroundCube.vertexShader,fragmentShader:Qt.backgroundCube.fragmentShader,side:en,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,D,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(d)),Ri.copy(S.backgroundRotation),Ri.x*=-1,Ri.y*=-1,Ri.z*=-1,C.isCubeTexture&&C.isRenderTargetTexture===!1&&(Ri.y*=-1,Ri.z*=-1),d.material.uniforms.envMap.value=C,d.material.uniforms.flipEnvMap.value=C.isCubeTexture&&C.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(Iv.makeRotationFromEuler(Ri)),d.material.toneMapped=je.getTransfer(C.colorSpace)!==nt,(u!==C||h!==C.version||f!==n.toneMapping)&&(d.material.needsUpdate=!0,u=C,h=C.version,f=n.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):C&&C.isTexture&&(c===void 0&&(c=new vt(new qt(2,2),new ii({name:"BackgroundMaterial",uniforms:As(Qt.background.uniforms),vertexShader:Qt.background.vertexShader,fragmentShader:Qt.background.fragmentShader,side:Mi,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=C,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=je.getTransfer(C.colorSpace)!==nt,C.matrixAutoUpdate===!0&&C.updateMatrix(),c.material.uniforms.uvTransform.value.copy(C.matrix),(u!==C||h!==C.version||f!==n.toneMapping)&&(c.material.needsUpdate=!0,u=C,h=C.version,f=n.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function p(y,S){y.getRGB(Ur,bu(n)),i.buffers.color.setClear(Ur.r,Ur.g,Ur.b,S,o)}function b(){d!==void 0&&(d.geometry.dispose(),d.material.dispose()),c!==void 0&&(c.geometry.dispose(),c.material.dispose())}return{getClearColor:function(){return a},setClearColor:function(y,S=1){a.set(y),l=S,p(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,p(a,l)},render:_,addToRenderList:m,dispose:b}}function Nv(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,o=!1;function a(v,A,O,L,k){let X=!1;const B=u(L,O,A);r!==B&&(r=B,c(r.object)),X=f(v,L,O,k),X&&g(v,L,O,k),k!==null&&e.update(k,n.ELEMENT_ARRAY_BUFFER),(X||o)&&(o=!1,S(v,A,O,L),k!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(k).buffer))}function l(){return n.createVertexArray()}function c(v){return n.bindVertexArray(v)}function d(v){return n.deleteVertexArray(v)}function u(v,A,O){const L=O.wireframe===!0;let k=i[v.id];k===void 0&&(k={},i[v.id]=k);let X=k[A.id];X===void 0&&(X={},k[A.id]=X);let B=X[L];return B===void 0&&(B=h(l()),X[L]=B),B}function h(v){const A=[],O=[],L=[];for(let k=0;k<t;k++)A[k]=0,O[k]=0,L[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:A,enabledAttributes:O,attributeDivisors:L,object:v,attributes:{},index:null}}function f(v,A,O,L){const k=r.attributes,X=A.attributes;let B=0;const G=O.getAttributes();for(const z in G)if(G[z].location>=0){const se=k[z];let ae=X[z];if(ae===void 0&&(z==="instanceMatrix"&&v.instanceMatrix&&(ae=v.instanceMatrix),z==="instanceColor"&&v.instanceColor&&(ae=v.instanceColor)),se===void 0||se.attribute!==ae||ae&&se.data!==ae.data)return!0;B++}return r.attributesNum!==B||r.index!==L}function g(v,A,O,L){const k={},X=A.attributes;let B=0;const G=O.getAttributes();for(const z in G)if(G[z].location>=0){let se=X[z];se===void 0&&(z==="instanceMatrix"&&v.instanceMatrix&&(se=v.instanceMatrix),z==="instanceColor"&&v.instanceColor&&(se=v.instanceColor));const ae={};ae.attribute=se,se&&se.data&&(ae.data=se.data),k[z]=ae,B++}r.attributes=k,r.attributesNum=B,r.index=L}function _(){const v=r.newAttributes;for(let A=0,O=v.length;A<O;A++)v[A]=0}function m(v){p(v,0)}function p(v,A){const O=r.newAttributes,L=r.enabledAttributes,k=r.attributeDivisors;O[v]=1,L[v]===0&&(n.enableVertexAttribArray(v),L[v]=1),k[v]!==A&&(n.vertexAttribDivisor(v,A),k[v]=A)}function b(){const v=r.newAttributes,A=r.enabledAttributes;for(let O=0,L=A.length;O<L;O++)A[O]!==v[O]&&(n.disableVertexAttribArray(O),A[O]=0)}function y(v,A,O,L,k,X,B){B===!0?n.vertexAttribIPointer(v,A,O,k,X):n.vertexAttribPointer(v,A,O,L,k,X)}function S(v,A,O,L){_();const k=L.attributes,X=O.getAttributes(),B=A.defaultAttributeValues;for(const G in X){const z=X[G];if(z.location>=0){let J=k[G];if(J===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(J=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(J=v.instanceColor)),J!==void 0){const se=J.normalized,ae=J.itemSize,Ce=e.get(J);if(Ce===void 0)continue;const Qe=Ce.buffer,j=Ce.type,te=Ce.bytesPerElement,_e=j===n.INT||j===n.UNSIGNED_INT||J.gpuType===Nl;if(J.isInterleavedBufferAttribute){const le=J.data,Ae=le.stride,Ie=J.offset;if(le.isInstancedInterleavedBuffer){for(let ze=0;ze<z.locationSize;ze++)p(z.location+ze,le.meshPerAttribute);v.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let ze=0;ze<z.locationSize;ze++)m(z.location+ze);n.bindBuffer(n.ARRAY_BUFFER,Qe);for(let ze=0;ze<z.locationSize;ze++)y(z.location+ze,ae/z.locationSize,j,se,Ae*te,(Ie+ae/z.locationSize*ze)*te,_e)}else{if(J.isInstancedBufferAttribute){for(let le=0;le<z.locationSize;le++)p(z.location+le,J.meshPerAttribute);v.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let le=0;le<z.locationSize;le++)m(z.location+le);n.bindBuffer(n.ARRAY_BUFFER,Qe);for(let le=0;le<z.locationSize;le++)y(z.location+le,ae/z.locationSize,j,se,ae*te,ae/z.locationSize*le*te,_e)}}else if(B!==void 0){const se=B[G];if(se!==void 0)switch(se.length){case 2:n.vertexAttrib2fv(z.location,se);break;case 3:n.vertexAttrib3fv(z.location,se);break;case 4:n.vertexAttrib4fv(z.location,se);break;default:n.vertexAttrib1fv(z.location,se)}}}}b()}function C(){R();for(const v in i){const A=i[v];for(const O in A){const L=A[O];for(const k in L)d(L[k].object),delete L[k];delete A[O]}delete i[v]}}function T(v){if(i[v.id]===void 0)return;const A=i[v.id];for(const O in A){const L=A[O];for(const k in L)d(L[k].object),delete L[k];delete A[O]}delete i[v.id]}function D(v){for(const A in i){const O=i[A];if(O[v.id]===void 0)continue;const L=O[v.id];for(const k in L)d(L[k].object),delete L[k];delete O[v.id]}}function R(){E(),o=!0,r!==s&&(r=s,c(r.object))}function E(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:R,resetDefaultState:E,dispose:C,releaseStatesOfGeometry:T,releaseStatesOfProgram:D,initAttributes:_,enableAttribute:m,disableUnusedAttributes:b}}function Ov(n,e,t){let i;function s(c){i=c}function r(c,d){n.drawArrays(i,c,d),t.update(d,i,1)}function o(c,d,u){u!==0&&(n.drawArraysInstanced(i,c,d,u),t.update(d,i,u))}function a(c,d,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,d,0,u);let f=0;for(let g=0;g<u;g++)f+=d[g];t.update(f,i,1)}function l(c,d,u,h){if(u===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)o(c[g],d[g],h[g]);else{f.multiDrawArraysInstancedWEBGL(i,c,0,d,0,h,0,u);let g=0;for(let _=0;_<u;_++)g+=d[_]*h[_];t.update(g,i,1)}}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function Fv(n,e,t,i){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const D=e.get("EXT_texture_filter_anisotropic");s=n.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(D){return!(D!==Ln&&i.convert(D)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(D){const R=D===er&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(D!==ti&&i.convert(D)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&D!==Zn&&!R)}function l(D){if(D==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";D="mediump"}return D==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const d=l(c);d!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const u=t.logarithmicDepthBuffer===!0,h=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),p=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),y=n.getParameter(n.MAX_VARYING_VECTORS),S=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),C=g>0,T=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:h,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:y,maxFragmentUniforms:S,vertexTextures:C,maxSamples:T}}function Bv(n){const e=this;let t=null,i=0,s=!1,r=!1;const o=new hi,a=new Ne,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,h){const f=u.length!==0||h||i!==0||s;return s=h,i=u.length,f},this.beginShadows=function(){r=!0,d(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,h){t=d(u,h,0)},this.setState=function(u,h,f){const g=u.clippingPlanes,_=u.clipIntersection,m=u.clipShadows,p=n.get(u);if(!s||g===null||g.length===0||r&&!m)r?d(null):c();else{const b=r?0:i,y=b*4;let S=p.clippingState||null;l.value=S,S=d(g,h,y,f);for(let C=0;C!==y;++C)S[C]=t[C];p.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(u,h,f,g){const _=u!==null?u.length:0;let m=null;if(_!==0){if(m=l.value,g!==!0||m===null){const p=f+_*4,b=h.matrixWorldInverse;a.getNormalMatrix(b),(m===null||m.length<p)&&(m=new Float32Array(p));for(let y=0,S=f;y!==_;++y,S+=4)o.copy(u[y]).applyMatrix4(b,a),o.normal.toArray(m,S),m[S+3]=o.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}function zv(n){let e=new WeakMap;function t(o,a){return a===Ya?o.mapping=Ms:a===qa&&(o.mapping=Es),o}function i(o){if(o&&o.isTexture){const a=o.mapping;if(a===Ya||a===qa)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new Lm(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",s),t(c.texture,o.mapping)}else return null}}return o}function s(o){const a=o.target;a.removeEventListener("dispose",s);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}const hs=4,Kc=[.125,.215,.35,.446,.526,.582],Oi=20,la=new Lu,Jc=new Ze;let ca=null,da=0,ua=0,ha=!1;const Ii=(1+Math.sqrt(5))/2,rs=1/Ii,Qc=[new P(-Ii,rs,0),new P(Ii,rs,0),new P(-rs,0,Ii),new P(rs,0,Ii),new P(0,Ii,-rs),new P(0,Ii,rs),new P(-1,1,-1),new P(1,1,-1),new P(-1,1,1),new P(1,1,1)];class ed{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,s=100){ca=this._renderer.getRenderTarget(),da=this._renderer.getActiveCubeFace(),ua=this._renderer.getActiveMipmapLevel(),ha=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,i,s,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=id(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=nd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ca,da,ua),this._renderer.xr.enabled=ha,e.scissorTest=!1,Nr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ms||e.mapping===Es?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ca=this._renderer.getRenderTarget(),da=this._renderer.getActiveCubeFace(),ua=this._renderer.getActiveMipmapLevel(),ha=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Bn,minFilter:Bn,generateMipmaps:!1,type:er,format:Ln,colorSpace:Ts,depthBuffer:!1},s=td(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=td(e,t,i);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=kv(r)),this._blurMaterial=Hv(r,e,t)}return s}_compileMaterial(e){const t=new vt(this._lodPlanes[0],e);this._renderer.compile(t,la)}_sceneToCubeUV(e,t,i,s){const a=new vn(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,h=d.toneMapping;d.getClearColor(Jc),d.toneMapping=yi,d.autoClear=!1;const f=new tn({name:"PMREM.Background",side:en,depthWrite:!1,depthTest:!1}),g=new vt(new nr,f);let _=!1;const m=e.background;m?m.isColor&&(f.color.copy(m),e.background=null,_=!0):(f.color.copy(Jc),_=!0);for(let p=0;p<6;p++){const b=p%3;b===0?(a.up.set(0,l[p],0),a.lookAt(c[p],0,0)):b===1?(a.up.set(0,0,l[p]),a.lookAt(0,c[p],0)):(a.up.set(0,l[p],0),a.lookAt(0,0,c[p]));const y=this._cubeSize;Nr(s,b*y,p>2?y:0,y,y),d.setRenderTarget(s),_&&d.render(g,a),d.render(e,a)}g.geometry.dispose(),g.material.dispose(),d.toneMapping=h,d.autoClear=u,e.background=m}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===Ms||e.mapping===Es;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=id()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=nd());const r=s?this._cubemapMaterial:this._equirectMaterial,o=new vt(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;Nr(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,la)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let r=1;r<s;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Qc[(s-r-1)%Qc.length];this._blur(e,r-1,r,o,a)}t.autoClear=i}_blur(e,t,i,s,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,s,"latitudinal",r),this._halfBlur(o,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,u=new vt(this._lodPlanes[s],c),h=c.uniforms,f=this._sizeLods[i]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Oi-1),_=r/g,m=isFinite(r)?1+Math.floor(d*_):Oi;m>Oi&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Oi}`);const p=[];let b=0;for(let D=0;D<Oi;++D){const R=D/_,E=Math.exp(-R*R/2);p.push(E),D===0?b+=E:D<m&&(b+=2*E)}for(let D=0;D<p.length;D++)p[D]=p[D]/b;h.envMap.value=e.texture,h.samples.value=m,h.weights.value=p,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);const{_lodMax:y}=this;h.dTheta.value=g,h.mipInt.value=y-i;const S=this._sizeLods[s],C=3*S*(s>y-hs?s-y+hs:0),T=4*(this._cubeSize-S);Nr(t,C,T,3*S,2*S),l.setRenderTarget(t),l.render(u,la)}}function kv(n){const e=[],t=[],i=[];let s=n;const r=n-hs+1+Kc.length;for(let o=0;o<r;o++){const a=Math.pow(2,s);t.push(a);let l=1/a;o>n-hs?l=Kc[o-n+hs-1]:o===0&&(l=0),i.push(l);const c=1/(a-2),d=-c,u=1+c,h=[d,d,u,d,u,u,d,d,u,u,d,u],f=6,g=6,_=3,m=2,p=1,b=new Float32Array(_*g*f),y=new Float32Array(m*g*f),S=new Float32Array(p*g*f);for(let T=0;T<f;T++){const D=T%3*2/3-1,R=T>2?0:-1,E=[D,R,0,D+2/3,R,0,D+2/3,R+1,0,D,R,0,D+2/3,R+1,0,D,R+1,0];b.set(E,_*g*T),y.set(h,m*g*T);const v=[T,T,T,T,T,T];S.set(v,p*g*T)}const C=new yn;C.setAttribute("position",new Un(b,_)),C.setAttribute("uv",new Un(y,m)),C.setAttribute("faceIndex",new Un(S,p)),e.push(C),s>hs&&s--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function td(n,e,t){const i=new Hi(n,e,t);return i.texture.mapping=Eo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Nr(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Hv(n,e,t){const i=new Float32Array(Oi),s=new P(0,1,0);return new ii({name:"SphericalGaussianBlur",defines:{n:Oi,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Yl(),fragmentShader:`
  3556. precision mediump float;
  3557. precision mediump int;
  3558. varying vec3 vOutputDirection;
  3559. uniform sampler2D envMap;
  3560. uniform int samples;
  3561. uniform float weights[ n ];
  3562. uniform bool latitudinal;
  3563. uniform float dTheta;
  3564. uniform float mipInt;
  3565. uniform vec3 poleAxis;
  3566. #define ENVMAP_TYPE_CUBE_UV
  3567. #include <cube_uv_reflection_fragment>
  3568. vec3 getSample( float theta, vec3 axis ) {
  3569. float cosTheta = cos( theta );
  3570. // Rodrigues' axis-angle rotation
  3571. vec3 sampleDirection = vOutputDirection * cosTheta
  3572. + cross( axis, vOutputDirection ) * sin( theta )
  3573. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3574. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3575. }
  3576. void main() {
  3577. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3578. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3579. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3580. }
  3581. axis = normalize( axis );
  3582. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3583. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3584. for ( int i = 1; i < n; i++ ) {
  3585. if ( i >= samples ) {
  3586. break;
  3587. }
  3588. float theta = dTheta * float( i );
  3589. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3590. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3591. }
  3592. }
  3593. `,blending:Si,depthTest:!1,depthWrite:!1})}function nd(){return new ii({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Yl(),fragmentShader:`
  3594. precision mediump float;
  3595. precision mediump int;
  3596. varying vec3 vOutputDirection;
  3597. uniform sampler2D envMap;
  3598. #include <common>
  3599. void main() {
  3600. vec3 outputDirection = normalize( vOutputDirection );
  3601. vec2 uv = equirectUv( outputDirection );
  3602. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3603. }
  3604. `,blending:Si,depthTest:!1,depthWrite:!1})}function id(){return new ii({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Yl(),fragmentShader:`
  3605. precision mediump float;
  3606. precision mediump int;
  3607. uniform float flipEnvMap;
  3608. varying vec3 vOutputDirection;
  3609. uniform samplerCube envMap;
  3610. void main() {
  3611. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3612. }
  3613. `,blending:Si,depthTest:!1,depthWrite:!1})}function Yl(){return`
  3614. precision mediump float;
  3615. precision mediump int;
  3616. attribute float faceIndex;
  3617. varying vec3 vOutputDirection;
  3618. // RH coordinate system; PMREM face-indexing convention
  3619. vec3 getDirection( vec2 uv, float face ) {
  3620. uv = 2.0 * uv - 1.0;
  3621. vec3 direction = vec3( uv, 1.0 );
  3622. if ( face == 0.0 ) {
  3623. direction = direction.zyx; // ( 1, v, u ) pos x
  3624. } else if ( face == 1.0 ) {
  3625. direction = direction.xzy;
  3626. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3627. } else if ( face == 2.0 ) {
  3628. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3629. } else if ( face == 3.0 ) {
  3630. direction = direction.zyx;
  3631. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3632. } else if ( face == 4.0 ) {
  3633. direction = direction.xzy;
  3634. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3635. } else if ( face == 5.0 ) {
  3636. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3637. }
  3638. return direction;
  3639. }
  3640. void main() {
  3641. vOutputDirection = getDirection( uv, faceIndex );
  3642. gl_Position = vec4( position, 1.0 );
  3643. }
  3644. `}function Gv(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,c=l===Ya||l===qa,d=l===Ms||l===Es;if(c||d){let u=e.get(a);const h=u!==void 0?u.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==h)return t===null&&(t=new ed(n)),u=c?t.fromEquirectangular(a,u):t.fromCubemap(a,u),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),u.texture;if(u!==void 0)return u.texture;{const f=a.image;return c&&f&&f.height>0||d&&f&&s(f)?(t===null&&(t=new ed(n)),u=c?t.fromEquirectangular(a):t.fromCubemap(a),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),a.addEventListener("dispose",r),u.texture):null}}}return a}function s(a){let l=0;const c=6;for(let d=0;d<c;d++)a[d]!==void 0&&l++;return l===c}function r(a){const l=a.target;l.removeEventListener("dispose",r);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function Vv(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let s;switch(i){case"WEBGL_depth_texture":s=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=n.getExtension(i)}return e[i]=s,s}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const s=t(i);return s===null&&cs("THREE.WebGLRenderer: "+i+" extension not supported."),s}}}function Wv(n,e,t,i){const s={},r=new WeakMap;function o(u){const h=u.target;h.index!==null&&e.remove(h.index);for(const g in h.attributes)e.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete s[h.id];const f=r.get(h);f&&(e.remove(f),r.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(u,h){return s[h.id]===!0||(h.addEventListener("dispose",o),s[h.id]=!0,t.memory.geometries++),h}function l(u){const h=u.attributes;for(const f in h)e.update(h[f],n.ARRAY_BUFFER)}function c(u){const h=[],f=u.index,g=u.attributes.position;let _=0;if(f!==null){const b=f.array;_=f.version;for(let y=0,S=b.length;y<S;y+=3){const C=b[y+0],T=b[y+1],D=b[y+2];h.push(C,T,T,D,D,C)}}else if(g!==void 0){const b=g.array;_=g.version;for(let y=0,S=b.length/3-1;y<S;y+=3){const C=y+0,T=y+1,D=y+2;h.push(C,T,T,D,D,C)}}else return;const m=new(vu(h)?Eu:Mu)(h,1);m.version=_;const p=r.get(u);p&&e.remove(p),r.set(u,m)}function d(u){const h=r.get(u);if(h){const f=u.index;f!==null&&h.version<f.version&&c(u)}else c(u);return r.get(u)}return{get:a,update:l,getWireframeAttribute:d}}function Xv(n,e,t){let i;function s(h){i=h}let r,o;function a(h){r=h.type,o=h.bytesPerElement}function l(h,f){n.drawElements(i,f,r,h*o),t.update(f,i,1)}function c(h,f,g){g!==0&&(n.drawElementsInstanced(i,f,r,h*o,g),t.update(f,i,g))}function d(h,f,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,f,0,r,h,0,g);let m=0;for(let p=0;p<g;p++)m+=f[p];t.update(m,i,1)}function u(h,f,g,_){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<h.length;p++)c(h[p]/o,f[p],_[p]);else{m.multiDrawElementsInstancedWEBGL(i,f,0,r,h,0,_,0,g);let p=0;for(let b=0;b<g;b++)p+=f[b]*_[b];t.update(p,i,1)}}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=d,this.renderMultiDrawInstances=u}function Yv(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(r/3);break;case n.LINES:t.lines+=a*(r/2);break;case n.LINE_STRIP:t.lines+=a*(r-1);break;case n.LINE_LOOP:t.lines+=a*r;break;case n.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:i}}function qv(n,e,t){const i=new WeakMap,s=new rt;function r(o,a,l){const c=o.morphTargetInfluences,d=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=d!==void 0?d.length:0;let h=i.get(a);if(h===void 0||h.count!==u){let E=function(){D.dispose(),i.delete(a),a.removeEventListener("dispose",E)};h!==void 0&&h.texture.dispose();const f=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],b=a.morphAttributes.color||[];let y=0;f===!0&&(y=1),g===!0&&(y=2),_===!0&&(y=3);let S=a.attributes.position.count*y,C=1;S>e.maxTextureSize&&(C=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const T=new Float32Array(S*C*4*u),D=new Su(T,S,C,u);D.type=Zn,D.needsUpdate=!0;const R=y*4;for(let v=0;v<u;v++){const A=m[v],O=p[v],L=b[v],k=S*C*4*v;for(let X=0;X<A.count;X++){const B=X*R;f===!0&&(s.fromBufferAttribute(A,X),T[k+B+0]=s.x,T[k+B+1]=s.y,T[k+B+2]=s.z,T[k+B+3]=0),g===!0&&(s.fromBufferAttribute(O,X),T[k+B+4]=s.x,T[k+B+5]=s.y,T[k+B+6]=s.z,T[k+B+7]=0),_===!0&&(s.fromBufferAttribute(L,X),T[k+B+8]=s.x,T[k+B+9]=s.y,T[k+B+10]=s.z,T[k+B+11]=L.itemSize===4?s.w:1)}}h={count:u,texture:D,size:new Te(S,C)},i.set(a,h),a.addEventListener("dispose",E)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let f=0;for(let _=0;_<c.length;_++)f+=c[_];const g=a.morphTargetsRelative?1:1-f;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:r}}function jv(n,e,t,i){let s=new WeakMap;function r(l){const c=i.render.frame,d=l.geometry,u=e.get(l,d);if(s.get(u)!==c&&(e.update(u),s.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),s.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){const h=l.skeleton;s.get(h)!==c&&(h.update(),s.set(h,c))}return u}function o(){s=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}const Uu=new Tt,sd=new Ru(1,1),Nu=new Su,Ou=new _m,Fu=new Tu,rd=[],od=[],ad=new Float32Array(16),ld=new Float32Array(9),cd=new Float32Array(4);function Ds(n,e,t){const i=n[0];if(i<=0||i>0)return n;const s=e*t;let r=rd[s];if(r===void 0&&(r=new Float32Array(s),rd[s]=r),e!==0){i.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(r,a)}return r}function At(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Ct(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function To(n,e){let t=od[e];t===void 0&&(t=new Int32Array(e),od[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function $v(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function Zv(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(At(t,e))return;n.uniform2fv(this.addr,e),Ct(t,e)}}function Kv(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(At(t,e))return;n.uniform3fv(this.addr,e),Ct(t,e)}}function Jv(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(At(t,e))return;n.uniform4fv(this.addr,e),Ct(t,e)}}function Qv(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(At(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Ct(t,e)}else{if(At(t,i))return;cd.set(i),n.uniformMatrix2fv(this.addr,!1,cd),Ct(t,i)}}function e0(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(At(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Ct(t,e)}else{if(At(t,i))return;ld.set(i),n.uniformMatrix3fv(this.addr,!1,ld),Ct(t,i)}}function t0(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(At(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Ct(t,e)}else{if(At(t,i))return;ad.set(i),n.uniformMatrix4fv(this.addr,!1,ad),Ct(t,i)}}function n0(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function i0(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(At(t,e))return;n.uniform2iv(this.addr,e),Ct(t,e)}}function s0(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(At(t,e))return;n.uniform3iv(this.addr,e),Ct(t,e)}}function r0(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(At(t,e))return;n.uniform4iv(this.addr,e),Ct(t,e)}}function o0(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function a0(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(At(t,e))return;n.uniform2uiv(this.addr,e),Ct(t,e)}}function l0(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(At(t,e))return;n.uniform3uiv(this.addr,e),Ct(t,e)}}function c0(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(At(t,e))return;n.uniform4uiv(this.addr,e),Ct(t,e)}}function d0(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s);let r;this.type===n.SAMPLER_2D_SHADOW?(sd.compareFunction=gu,r=sd):r=Uu,t.setTexture2D(e||r,s)}function u0(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTexture3D(e||Ou,s)}function h0(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTextureCube(e||Fu,s)}function f0(n,e,t){const i=this.cache,s=t.allocateTextureUnit();i[0]!==s&&(n.uniform1i(this.addr,s),i[0]=s),t.setTexture2DArray(e||Nu,s)}function p0(n){switch(n){case 5126:return $v;case 35664:return Zv;case 35665:return Kv;case 35666:return Jv;case 35674:return Qv;case 35675:return e0;case 35676:return t0;case 5124:case 35670:return n0;case 35667:case 35671:return i0;case 35668:case 35672:return s0;case 35669:case 35673:return r0;case 5125:return o0;case 36294:return a0;case 36295:return l0;case 36296:return c0;case 35678:case 36198:case 36298:case 36306:case 35682:return d0;case 35679:case 36299:case 36307:return u0;case 35680:case 36300:case 36308:case 36293:return h0;case 36289:case 36303:case 36311:case 36292:return f0}}function m0(n,e){n.uniform1fv(this.addr,e)}function g0(n,e){const t=Ds(e,this.size,2);n.uniform2fv(this.addr,t)}function _0(n,e){const t=Ds(e,this.size,3);n.uniform3fv(this.addr,t)}function v0(n,e){const t=Ds(e,this.size,4);n.uniform4fv(this.addr,t)}function x0(n,e){const t=Ds(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function S0(n,e){const t=Ds(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function y0(n,e){const t=Ds(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function M0(n,e){n.uniform1iv(this.addr,e)}function E0(n,e){n.uniform2iv(this.addr,e)}function b0(n,e){n.uniform3iv(this.addr,e)}function w0(n,e){n.uniform4iv(this.addr,e)}function T0(n,e){n.uniform1uiv(this.addr,e)}function A0(n,e){n.uniform2uiv(this.addr,e)}function C0(n,e){n.uniform3uiv(this.addr,e)}function R0(n,e){n.uniform4uiv(this.addr,e)}function P0(n,e,t){const i=this.cache,s=e.length,r=To(t,s);At(i,r)||(n.uniform1iv(this.addr,r),Ct(i,r));for(let o=0;o!==s;++o)t.setTexture2D(e[o]||Uu,r[o])}function D0(n,e,t){const i=this.cache,s=e.length,r=To(t,s);At(i,r)||(n.uniform1iv(this.addr,r),Ct(i,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||Ou,r[o])}function L0(n,e,t){const i=this.cache,s=e.length,r=To(t,s);At(i,r)||(n.uniform1iv(this.addr,r),Ct(i,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||Fu,r[o])}function I0(n,e,t){const i=this.cache,s=e.length,r=To(t,s);At(i,r)||(n.uniform1iv(this.addr,r),Ct(i,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||Nu,r[o])}function U0(n){switch(n){case 5126:return m0;case 35664:return g0;case 35665:return _0;case 35666:return v0;case 35674:return x0;case 35675:return S0;case 35676:return y0;case 5124:case 35670:return M0;case 35667:case 35671:return E0;case 35668:case 35672:return b0;case 35669:case 35673:return w0;case 5125:return T0;case 36294:return A0;case 36295:return C0;case 36296:return R0;case 35678:case 36198:case 36298:case 36306:case 35682:return P0;case 35679:case 36299:case 36307:return D0;case 35680:case 36300:case 36308:case 36293:return L0;case 36289:case 36303:case 36311:case 36292:return I0}}class N0{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=p0(t.type)}}class O0{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=U0(t.type)}}class F0{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const s=this.seq;for(let r=0,o=s.length;r!==o;++r){const a=s[r];a.setValue(e,t[a.id],i)}}}const fa=/(\w+)(\])?(\[|\.)?/g;function dd(n,e){n.seq.push(e),n.map[e.id]=e}function B0(n,e,t){const i=n.name,s=i.length;for(fa.lastIndex=0;;){const r=fa.exec(i),o=fa.lastIndex;let a=r[1];const l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){dd(t,c===void 0?new N0(a,n,e):new O0(a,n,e));break}else{let u=t.map[a];u===void 0&&(u=new F0(a),dd(t,u)),t=u}}}class io{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<i;++s){const r=e.getActiveUniform(t,s),o=e.getUniformLocation(t,r.name);B0(r,o,this)}}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,o=t.length;r!==o;++r){const a=t[r],l=i[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const o=e[s];o.id in t&&i.push(o)}return i}}function ud(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const z0=37297;let k0=0;function H0(n,e){const t=n.split(`
  3645. `),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){const a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(`
  3646. `)}const hd=new Ne;function G0(n){je._getMatrix(hd,je.workingColorSpace,n);const e=`mat3( ${hd.elements.map(t=>t.toFixed(4))} )`;switch(je.getTransfer(n)){case fo:return[e,"LinearTransferOETF"];case nt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function fd(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=n.getShaderInfoLog(e).trim();if(i&&s==="")return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const o=parseInt(r[1]);return t.toUpperCase()+`
  3647. `+s+`
  3648. `+H0(n.getShaderSource(e),o)}else return s}function V0(n,e){const t=G0(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
  3649. `)}function W0(n,e){let t;switch(e){case Ap:t="Linear";break;case Cp:t="Reinhard";break;case Rp:t="Cineon";break;case Pp:t="ACESFilmic";break;case Lp:t="AgX";break;case Ip:t="Neutral";break;case Dp:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Or=new P;function X0(){je.getLuminanceCoefficients(Or);const n=Or.x.toFixed(4),e=Or.y.toFixed(4),t=Or.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
  3650. `)}function Y0(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Bs).join(`
  3651. `)}function q0(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
  3652. `)}function j0(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const r=n.getActiveAttrib(e,s),o=r.name;let a=1;r.type===n.FLOAT_MAT2&&(a=2),r.type===n.FLOAT_MAT3&&(a=3),r.type===n.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:n.getAttribLocation(e,o),locationSize:a}}return t}function Bs(n){return n!==""}function pd(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function md(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const $0=/^[ \t]*#include +<([\w\d./]+)>/gm;function wl(n){return n.replace($0,K0)}const Z0=new Map;function K0(n,e){let t=Fe[e];if(t===void 0){const i=Z0.get(e);if(i!==void 0)t=Fe[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return wl(t)}const J0=/#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 gd(n){return n.replace(J0,Q0)}function Q0(n,e,t,i){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function _d(n){let e=`precision ${n.precision} float;
  3653. precision ${n.precision} int;
  3654. precision ${n.precision} sampler2D;
  3655. precision ${n.precision} samplerCube;
  3656. precision ${n.precision} sampler3D;
  3657. precision ${n.precision} sampler2DArray;
  3658. precision ${n.precision} sampler2DShadow;
  3659. precision ${n.precision} samplerCubeShadow;
  3660. precision ${n.precision} sampler2DArrayShadow;
  3661. precision ${n.precision} isampler2D;
  3662. precision ${n.precision} isampler3D;
  3663. precision ${n.precision} isamplerCube;
  3664. precision ${n.precision} isampler2DArray;
  3665. precision ${n.precision} usampler2D;
  3666. precision ${n.precision} usampler3D;
  3667. precision ${n.precision} usamplerCube;
  3668. precision ${n.precision} usampler2DArray;
  3669. `;return n.precision==="highp"?e+=`
  3670. #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
  3671. #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
  3672. #define LOW_PRECISION`),e}function ex(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===iu?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===op?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===qn&&(e="SHADOWMAP_TYPE_VSM"),e}function tx(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case Ms:case Es:e="ENVMAP_TYPE_CUBE";break;case Eo:e="ENVMAP_TYPE_CUBE_UV";break}return e}function nx(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Es:e="ENVMAP_MODE_REFRACTION";break}return e}function ix(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case su:e="ENVMAP_BLENDING_MULTIPLY";break;case wp:e="ENVMAP_BLENDING_MIX";break;case Tp:e="ENVMAP_BLENDING_ADD";break}return e}function sx(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:i,maxMip:t}}function rx(n,e,t,i){const s=n.getContext(),r=t.defines;let o=t.vertexShader,a=t.fragmentShader;const l=ex(t),c=tx(t),d=nx(t),u=ix(t),h=sx(t),f=Y0(t),g=q0(r),_=s.createProgram();let m,p,b=t.glslVersion?"#version "+t.glslVersion+`
  3673. `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Bs).join(`
  3674. `),m.length>0&&(m+=`
  3675. `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Bs).join(`
  3676. `),p.length>0&&(p+=`
  3677. `)):(m=[_d(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3678. `].filter(Bs).join(`
  3679. `),p=[_d(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+d:"",t.envMap?"#define "+u:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==yi?"#define TONE_MAPPING":"",t.toneMapping!==yi?Fe.tonemapping_pars_fragment:"",t.toneMapping!==yi?W0("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Fe.colorspace_pars_fragment,V0("linearToOutputTexel",t.outputColorSpace),X0(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
  3680. `].filter(Bs).join(`
  3681. `)),o=wl(o),o=pd(o,t),o=md(o,t),a=wl(a),a=pd(a,t),a=md(a,t),o=gd(o),a=gd(a),t.isRawShaderMaterial!==!0&&(b=`#version 300 es
  3682. `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3683. `)+`
  3684. `+m,p=["#define varying in",t.glslVersion===yc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===yc?"":"#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(`
  3685. `)+`
  3686. `+p);const y=b+m+o,S=b+p+a,C=ud(s,s.VERTEX_SHADER,y),T=ud(s,s.FRAGMENT_SHADER,S);s.attachShader(_,C),s.attachShader(_,T),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function D(A){if(n.debug.checkShaderErrors){const O=s.getProgramInfoLog(_).trim(),L=s.getShaderInfoLog(C).trim(),k=s.getShaderInfoLog(T).trim();let X=!0,B=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,C,T);else{const G=fd(s,C,"vertex"),z=fd(s,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
  3687. Material Name: `+A.name+`
  3688. Material Type: `+A.type+`
  3689. Program Info Log: `+O+`
  3690. `+G+`
  3691. `+z)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(L===""||k==="")&&(B=!1);B&&(A.diagnostics={runnable:X,programLog:O,vertexShader:{log:L,prefix:m},fragmentShader:{log:k,prefix:p}})}s.deleteShader(C),s.deleteShader(T),R=new io(s,_),E=j0(s,_)}let R;this.getUniforms=function(){return R===void 0&&D(this),R};let E;this.getAttributes=function(){return E===void 0&&D(this),E};let v=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return v===!1&&(v=s.getProgramParameter(_,z0)),v},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=k0++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=C,this.fragmentShader=T,this}let ox=0;class ax{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(s)===!1&&(o.add(s),s.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new lx(e),t.set(e,i)),i}}class lx{constructor(e){this.id=ox++,this.code=e,this.usedTimes=0}}function cx(n,e,t,i,s,r,o){const a=new Gl,l=new ax,c=new Set,d=[],u=s.logarithmicDepthBuffer,h=s.vertexTextures;let f=s.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(E){return c.add(E),E===0?"uv":`uv${E}`}function m(E,v,A,O,L){const k=O.fog,X=L.geometry,B=E.isMeshStandardMaterial?O.environment:null,G=(E.isMeshStandardMaterial?t:e).get(E.envMap||B),z=G&&G.mapping===Eo?G.image.height:null,J=g[E.type];E.precision!==null&&(f=s.getMaxPrecision(E.precision),f!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",f,"instead."));const se=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,ae=se!==void 0?se.length:0;let Ce=0;X.morphAttributes.position!==void 0&&(Ce=1),X.morphAttributes.normal!==void 0&&(Ce=2),X.morphAttributes.color!==void 0&&(Ce=3);let Qe,j,te,_e;if(J){const et=Qt[J];Qe=et.vertexShader,j=et.fragmentShader}else Qe=E.vertexShader,j=E.fragmentShader,l.update(E),te=l.getVertexShaderID(E),_e=l.getFragmentShaderID(E);const le=n.getRenderTarget(),Ae=n.state.buffers.depth.getReversed(),Ie=L.isInstancedMesh===!0,ze=L.isBatchedMesh===!0,ht=!!E.map,Ve=!!E.matcap,xt=!!G,I=!!E.aoMap,un=!!E.lightMap,ke=!!E.bumpMap,He=!!E.normalMap,xe=!!E.displacementMap,ot=!!E.emissiveMap,Se=!!E.metalnessMap,w=!!E.roughnessMap,x=E.anisotropy>0,H=E.clearcoat>0,$=E.dispersion>0,K=E.iridescence>0,q=E.sheen>0,ve=E.transmission>0,ce=x&&!!E.anisotropyMap,fe=H&&!!E.clearcoatMap,We=H&&!!E.clearcoatNormalMap,ee=H&&!!E.clearcoatRoughnessMap,pe=K&&!!E.iridescenceMap,Ee=K&&!!E.iridescenceThicknessMap,Re=q&&!!E.sheenColorMap,me=q&&!!E.sheenRoughnessMap,Ge=!!E.specularMap,Oe=!!E.specularColorMap,st=!!E.specularIntensityMap,U=ve&&!!E.transmissionMap,re=ve&&!!E.thicknessMap,Y=!!E.gradientMap,Z=!!E.alphaMap,ue=E.alphaTest>0,de=!!E.alphaHash,Ue=!!E.extensions;let mt=yi;E.toneMapped&&(le===null||le.isXRRenderTarget===!0)&&(mt=n.toneMapping);const Ot={shaderID:J,shaderType:E.type,shaderName:E.name,vertexShader:Qe,fragmentShader:j,defines:E.defines,customVertexShaderID:te,customFragmentShaderID:_e,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:f,batching:ze,batchingColor:ze&&L._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&L.instanceColor!==null,instancingMorph:Ie&&L.morphTexture!==null,supportsVertexTextures:h,outputColorSpace:le===null?n.outputColorSpace:le.isXRRenderTarget===!0?le.texture.colorSpace:Ts,alphaToCoverage:!!E.alphaToCoverage,map:ht,matcap:Ve,envMap:xt,envMapMode:xt&&G.mapping,envMapCubeUVHeight:z,aoMap:I,lightMap:un,bumpMap:ke,normalMap:He,displacementMap:h&&xe,emissiveMap:ot,normalMapObjectSpace:He&&E.normalMapType===Bp,normalMapTangentSpace:He&&E.normalMapType===Fp,metalnessMap:Se,roughnessMap:w,anisotropy:x,anisotropyMap:ce,clearcoat:H,clearcoatMap:fe,clearcoatNormalMap:We,clearcoatRoughnessMap:ee,dispersion:$,iridescence:K,iridescenceMap:pe,iridescenceThicknessMap:Ee,sheen:q,sheenColorMap:Re,sheenRoughnessMap:me,specularMap:Ge,specularColorMap:Oe,specularIntensityMap:st,transmission:ve,transmissionMap:U,thicknessMap:re,gradientMap:Y,opaque:E.transparent===!1&&E.blending===gs&&E.alphaToCoverage===!1,alphaMap:Z,alphaTest:ue,alphaHash:de,combine:E.combine,mapUv:ht&&_(E.map.channel),aoMapUv:I&&_(E.aoMap.channel),lightMapUv:un&&_(E.lightMap.channel),bumpMapUv:ke&&_(E.bumpMap.channel),normalMapUv:He&&_(E.normalMap.channel),displacementMapUv:xe&&_(E.displacementMap.channel),emissiveMapUv:ot&&_(E.emissiveMap.channel),metalnessMapUv:Se&&_(E.metalnessMap.channel),roughnessMapUv:w&&_(E.roughnessMap.channel),anisotropyMapUv:ce&&_(E.anisotropyMap.channel),clearcoatMapUv:fe&&_(E.clearcoatMap.channel),clearcoatNormalMapUv:We&&_(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ee&&_(E.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&_(E.iridescenceMap.channel),iridescenceThicknessMapUv:Ee&&_(E.iridescenceThicknessMap.channel),sheenColorMapUv:Re&&_(E.sheenColorMap.channel),sheenRoughnessMapUv:me&&_(E.sheenRoughnessMap.channel),specularMapUv:Ge&&_(E.specularMap.channel),specularColorMapUv:Oe&&_(E.specularColorMap.channel),specularIntensityMapUv:st&&_(E.specularIntensityMap.channel),transmissionMapUv:U&&_(E.transmissionMap.channel),thicknessMapUv:re&&_(E.thicknessMap.channel),alphaMapUv:Z&&_(E.alphaMap.channel),vertexTangents:!!X.attributes.tangent&&(He||x),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!X.attributes.uv&&(ht||Z),fog:!!k,useFog:E.fog===!0,fogExp2:!!k&&k.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:Ae,skinning:L.isSkinnedMesh===!0,morphTargets:X.morphAttributes.position!==void 0,morphNormals:X.morphAttributes.normal!==void 0,morphColors:X.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:Ce,numDirLights:v.directional.length,numPointLights:v.point.length,numSpotLights:v.spot.length,numSpotLightMaps:v.spotLightMap.length,numRectAreaLights:v.rectArea.length,numHemiLights:v.hemi.length,numDirLightShadows:v.directionalShadowMap.length,numPointLightShadows:v.pointShadowMap.length,numSpotLightShadows:v.spotShadowMap.length,numSpotLightShadowsWithMaps:v.numSpotLightShadowsWithMaps,numLightProbes:v.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:n.shadowMap.enabled&&A.length>0,shadowMapType:n.shadowMap.type,toneMapping:mt,decodeVideoTexture:ht&&E.map.isVideoTexture===!0&&je.getTransfer(E.map.colorSpace)===nt,decodeVideoTextureEmissive:ot&&E.emissiveMap.isVideoTexture===!0&&je.getTransfer(E.emissiveMap.colorSpace)===nt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===jn,flipSided:E.side===en,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:Ue&&E.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ue&&E.extensions.multiDraw===!0||ze)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return Ot.vertexUv1s=c.has(1),Ot.vertexUv2s=c.has(2),Ot.vertexUv3s=c.has(3),c.clear(),Ot}function p(E){const v=[];if(E.shaderID?v.push(E.shaderID):(v.push(E.customVertexShaderID),v.push(E.customFragmentShaderID)),E.defines!==void 0)for(const A in E.defines)v.push(A),v.push(E.defines[A]);return E.isRawShaderMaterial===!1&&(b(v,E),y(v,E),v.push(n.outputColorSpace)),v.push(E.customProgramCacheKey),v.join()}function b(E,v){E.push(v.precision),E.push(v.outputColorSpace),E.push(v.envMapMode),E.push(v.envMapCubeUVHeight),E.push(v.mapUv),E.push(v.alphaMapUv),E.push(v.lightMapUv),E.push(v.aoMapUv),E.push(v.bumpMapUv),E.push(v.normalMapUv),E.push(v.displacementMapUv),E.push(v.emissiveMapUv),E.push(v.metalnessMapUv),E.push(v.roughnessMapUv),E.push(v.anisotropyMapUv),E.push(v.clearcoatMapUv),E.push(v.clearcoatNormalMapUv),E.push(v.clearcoatRoughnessMapUv),E.push(v.iridescenceMapUv),E.push(v.iridescenceThicknessMapUv),E.push(v.sheenColorMapUv),E.push(v.sheenRoughnessMapUv),E.push(v.specularMapUv),E.push(v.specularColorMapUv),E.push(v.specularIntensityMapUv),E.push(v.transmissionMapUv),E.push(v.thicknessMapUv),E.push(v.combine),E.push(v.fogExp2),E.push(v.sizeAttenuation),E.push(v.morphTargetsCount),E.push(v.morphAttributeCount),E.push(v.numDirLights),E.push(v.numPointLights),E.push(v.numSpotLights),E.push(v.numSpotLightMaps),E.push(v.numHemiLights),E.push(v.numRectAreaLights),E.push(v.numDirLightShadows),E.push(v.numPointLightShadows),E.push(v.numSpotLightShadows),E.push(v.numSpotLightShadowsWithMaps),E.push(v.numLightProbes),E.push(v.shadowMapType),E.push(v.toneMapping),E.push(v.numClippingPlanes),E.push(v.numClipIntersection),E.push(v.depthPacking)}function y(E,v){a.disableAll(),v.supportsVertexTextures&&a.enable(0),v.instancing&&a.enable(1),v.instancingColor&&a.enable(2),v.instancingMorph&&a.enable(3),v.matcap&&a.enable(4),v.envMap&&a.enable(5),v.normalMapObjectSpace&&a.enable(6),v.normalMapTangentSpace&&a.enable(7),v.clearcoat&&a.enable(8),v.iridescence&&a.enable(9),v.alphaTest&&a.enable(10),v.vertexColors&&a.enable(11),v.vertexAlphas&&a.enable(12),v.vertexUv1s&&a.enable(13),v.vertexUv2s&&a.enable(14),v.vertexUv3s&&a.enable(15),v.vertexTangents&&a.enable(16),v.anisotropy&&a.enable(17),v.alphaHash&&a.enable(18),v.batching&&a.enable(19),v.dispersion&&a.enable(20),v.batchingColor&&a.enable(21),E.push(a.mask),a.disableAll(),v.fog&&a.enable(0),v.useFog&&a.enable(1),v.flatShading&&a.enable(2),v.logarithmicDepthBuffer&&a.enable(3),v.reverseDepthBuffer&&a.enable(4),v.skinning&&a.enable(5),v.morphTargets&&a.enable(6),v.morphNormals&&a.enable(7),v.morphColors&&a.enable(8),v.premultipliedAlpha&&a.enable(9),v.shadowMapEnabled&&a.enable(10),v.doubleSided&&a.enable(11),v.flipSided&&a.enable(12),v.useDepthPacking&&a.enable(13),v.dithering&&a.enable(14),v.transmission&&a.enable(15),v.sheen&&a.enable(16),v.opaque&&a.enable(17),v.pointsUvs&&a.enable(18),v.decodeVideoTexture&&a.enable(19),v.decodeVideoTextureEmissive&&a.enable(20),v.alphaToCoverage&&a.enable(21),E.push(a.mask)}function S(E){const v=g[E.type];let A;if(v){const O=Qt[v];A=Vl.clone(O.uniforms)}else A=E.uniforms;return A}function C(E,v){let A;for(let O=0,L=d.length;O<L;O++){const k=d[O];if(k.cacheKey===v){A=k,++A.usedTimes;break}}return A===void 0&&(A=new rx(n,v,E,r),d.push(A)),A}function T(E){if(--E.usedTimes===0){const v=d.indexOf(E);d[v]=d[d.length-1],d.pop(),E.destroy()}}function D(E){l.remove(E)}function R(){l.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:S,acquireProgram:C,releaseProgram:T,releaseShaderCache:D,programs:d,dispose:R}}function dx(){let n=new WeakMap;function e(o){return n.has(o)}function t(o){let a=n.get(o);return a===void 0&&(a={},n.set(o,a)),a}function i(o){n.delete(o)}function s(o,a,l){n.get(o)[a]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function ux(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function vd(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function xd(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function o(u,h,f,g,_,m){let p=n[e];return p===void 0?(p={id:u.id,object:u,geometry:h,material:f,groupOrder:g,renderOrder:u.renderOrder,z:_,group:m},n[e]=p):(p.id=u.id,p.object=u,p.geometry=h,p.material=f,p.groupOrder=g,p.renderOrder=u.renderOrder,p.z=_,p.group=m),e++,p}function a(u,h,f,g,_,m){const p=o(u,h,f,g,_,m);f.transmission>0?i.push(p):f.transparent===!0?s.push(p):t.push(p)}function l(u,h,f,g,_,m){const p=o(u,h,f,g,_,m);f.transmission>0?i.unshift(p):f.transparent===!0?s.unshift(p):t.unshift(p)}function c(u,h){t.length>1&&t.sort(u||ux),i.length>1&&i.sort(h||vd),s.length>1&&s.sort(h||vd)}function d(){for(let u=e,h=n.length;u<h;u++){const f=n[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:i,transparent:s,init:r,push:a,unshift:l,finish:d,sort:c}}function hx(){let n=new WeakMap;function e(i,s){const r=n.get(i);let o;return r===void 0?(o=new xd,n.set(i,[o])):s>=r.length?(o=new xd,r.push(o)):o=r[s],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function fx(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new P,color:new Ze};break;case"SpotLight":t={position:new P,direction:new P,color:new Ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new P,color:new Ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new P,skyColor:new Ze,groundColor:new Ze};break;case"RectAreaLight":t={color:new Ze,position:new P,halfWidth:new P,halfHeight:new P};break}return n[e.id]=t,t}}}function px(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Te,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let mx=0;function gx(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function _x(n){const e=new fx,t=px(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new P);const s=new P,r=new pt,o=new pt;function a(c){let d=0,u=0,h=0;for(let E=0;E<9;E++)i.probe[E].set(0,0,0);let f=0,g=0,_=0,m=0,p=0,b=0,y=0,S=0,C=0,T=0,D=0;c.sort(gx);for(let E=0,v=c.length;E<v;E++){const A=c[E],O=A.color,L=A.intensity,k=A.distance,X=A.shadow&&A.shadow.map?A.shadow.map.texture:null;if(A.isAmbientLight)d+=O.r*L,u+=O.g*L,h+=O.b*L;else if(A.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(A.sh.coefficients[B],L);D++}else if(A.isDirectionalLight){const B=e.get(A);if(B.color.copy(A.color).multiplyScalar(A.intensity),A.castShadow){const G=A.shadow,z=t.get(A);z.shadowIntensity=G.intensity,z.shadowBias=G.bias,z.shadowNormalBias=G.normalBias,z.shadowRadius=G.radius,z.shadowMapSize=G.mapSize,i.directionalShadow[f]=z,i.directionalShadowMap[f]=X,i.directionalShadowMatrix[f]=A.shadow.matrix,b++}i.directional[f]=B,f++}else if(A.isSpotLight){const B=e.get(A);B.position.setFromMatrixPosition(A.matrixWorld),B.color.copy(O).multiplyScalar(L),B.distance=k,B.coneCos=Math.cos(A.angle),B.penumbraCos=Math.cos(A.angle*(1-A.penumbra)),B.decay=A.decay,i.spot[_]=B;const G=A.shadow;if(A.map&&(i.spotLightMap[C]=A.map,C++,G.updateMatrices(A),A.castShadow&&T++),i.spotLightMatrix[_]=G.matrix,A.castShadow){const z=t.get(A);z.shadowIntensity=G.intensity,z.shadowBias=G.bias,z.shadowNormalBias=G.normalBias,z.shadowRadius=G.radius,z.shadowMapSize=G.mapSize,i.spotShadow[_]=z,i.spotShadowMap[_]=X,S++}_++}else if(A.isRectAreaLight){const B=e.get(A);B.color.copy(O).multiplyScalar(L),B.halfWidth.set(A.width*.5,0,0),B.halfHeight.set(0,A.height*.5,0),i.rectArea[m]=B,m++}else if(A.isPointLight){const B=e.get(A);if(B.color.copy(A.color).multiplyScalar(A.intensity),B.distance=A.distance,B.decay=A.decay,A.castShadow){const G=A.shadow,z=t.get(A);z.shadowIntensity=G.intensity,z.shadowBias=G.bias,z.shadowNormalBias=G.normalBias,z.shadowRadius=G.radius,z.shadowMapSize=G.mapSize,z.shadowCameraNear=G.camera.near,z.shadowCameraFar=G.camera.far,i.pointShadow[g]=z,i.pointShadowMap[g]=X,i.pointShadowMatrix[g]=A.shadow.matrix,y++}i.point[g]=B,g++}else if(A.isHemisphereLight){const B=e.get(A);B.skyColor.copy(A.color).multiplyScalar(L),B.groundColor.copy(A.groundColor).multiplyScalar(L),i.hemi[p]=B,p++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ie.LTC_FLOAT_1,i.rectAreaLTC2=ie.LTC_FLOAT_2):(i.rectAreaLTC1=ie.LTC_HALF_1,i.rectAreaLTC2=ie.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=u,i.ambient[2]=h;const R=i.hash;(R.directionalLength!==f||R.pointLength!==g||R.spotLength!==_||R.rectAreaLength!==m||R.hemiLength!==p||R.numDirectionalShadows!==b||R.numPointShadows!==y||R.numSpotShadows!==S||R.numSpotMaps!==C||R.numLightProbes!==D)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=g,i.hemi.length=p,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=y,i.pointShadowMap.length=y,i.spotShadow.length=S,i.spotShadowMap.length=S,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=y,i.spotLightMatrix.length=S+C-T,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=D,R.directionalLength=f,R.pointLength=g,R.spotLength=_,R.rectAreaLength=m,R.hemiLength=p,R.numDirectionalShadows=b,R.numPointShadows=y,R.numSpotShadows=S,R.numSpotMaps=C,R.numLightProbes=D,i.version=mx++)}function l(c,d){let u=0,h=0,f=0,g=0,_=0;const m=d.matrixWorldInverse;for(let p=0,b=c.length;p<b;p++){const y=c[p];if(y.isDirectionalLight){const S=i.directional[u];S.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),u++}else if(y.isSpotLight){const S=i.spot[f];S.position.setFromMatrixPosition(y.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),f++}else if(y.isRectAreaLight){const S=i.rectArea[g];S.position.setFromMatrixPosition(y.matrixWorld),S.position.applyMatrix4(m),o.identity(),r.copy(y.matrixWorld),r.premultiply(m),o.extractRotation(r),S.halfWidth.set(y.width*.5,0,0),S.halfHeight.set(0,y.height*.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),g++}else if(y.isPointLight){const S=i.point[h];S.position.setFromMatrixPosition(y.matrixWorld),S.position.applyMatrix4(m),h++}else if(y.isHemisphereLight){const S=i.hemi[_];S.direction.setFromMatrixPosition(y.matrixWorld),S.direction.transformDirection(m),_++}}}return{setup:a,setupView:l,state:i}}function Sd(n){const e=new _x(n),t=[],i=[];function s(d){c.camera=d,t.length=0,i.length=0}function r(d){t.push(d)}function o(d){i.push(d)}function a(){e.setup(t)}function l(d){e.setupView(t,d)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:a,setupLightsView:l,pushLight:r,pushShadow:o}}function vx(n){let e=new WeakMap;function t(s,r=0){const o=e.get(s);let a;return o===void 0?(a=new Sd(n),e.set(s,[a])):r>=o.length?(a=new Sd(n),o.push(a)):a=o[r],a}function i(){e=new WeakMap}return{get:t,dispose:i}}const xx=`void main() {
  3692. gl_Position = vec4( position, 1.0 );
  3693. }`,Sx=`uniform sampler2D shadow_pass;
  3694. uniform vec2 resolution;
  3695. uniform float radius;
  3696. #include <packing>
  3697. void main() {
  3698. const float samples = float( VSM_SAMPLES );
  3699. float mean = 0.0;
  3700. float squared_mean = 0.0;
  3701. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3702. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3703. for ( float i = 0.0; i < samples; i ++ ) {
  3704. float uvOffset = uvStart + i * uvStride;
  3705. #ifdef HORIZONTAL_PASS
  3706. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3707. mean += distribution.x;
  3708. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3709. #else
  3710. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3711. mean += depth;
  3712. squared_mean += depth * depth;
  3713. #endif
  3714. }
  3715. mean = mean / samples;
  3716. squared_mean = squared_mean / samples;
  3717. float std_dev = sqrt( squared_mean - mean * mean );
  3718. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3719. }`;function yx(n,e,t){let i=new Au;const s=new Te,r=new Te,o=new rt,a=new Hm({depthPacking:Op}),l=new Gm,c={},d=t.maxTextureSize,u={[Mi]:en,[en]:Mi,[jn]:jn},h=new ii({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Te},radius:{value:4}},vertexShader:xx,fragmentShader:Sx}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const g=new yn;g.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new vt(g,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=iu;let p=this.type;this.render=function(T,D,R){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;const E=n.getRenderTarget(),v=n.getActiveCubeFace(),A=n.getActiveMipmapLevel(),O=n.state;O.setBlending(Si),O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const L=p!==qn&&this.type===qn,k=p===qn&&this.type!==qn;for(let X=0,B=T.length;X<B;X++){const G=T[X],z=G.shadow;if(z===void 0){console.warn("THREE.WebGLShadowMap:",G,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;s.copy(z.mapSize);const J=z.getFrameExtents();if(s.multiply(J),r.copy(z.mapSize),(s.x>d||s.y>d)&&(s.x>d&&(r.x=Math.floor(d/J.x),s.x=r.x*J.x,z.mapSize.x=r.x),s.y>d&&(r.y=Math.floor(d/J.y),s.y=r.y*J.y,z.mapSize.y=r.y)),z.map===null||L===!0||k===!0){const ae=this.type!==qn?{minFilter:In,magFilter:In}:{};z.map!==null&&z.map.dispose(),z.map=new Hi(s.x,s.y,ae),z.map.texture.name=G.name+".shadowMap",z.camera.updateProjectionMatrix()}n.setRenderTarget(z.map),n.clear();const se=z.getViewportCount();for(let ae=0;ae<se;ae++){const Ce=z.getViewport(ae);o.set(r.x*Ce.x,r.y*Ce.y,r.x*Ce.z,r.y*Ce.w),O.viewport(o),z.updateMatrices(G,ae),i=z.getFrustum(),S(D,R,z.camera,G,this.type)}z.isPointLightShadow!==!0&&this.type===qn&&b(z,R),z.needsUpdate=!1}p=this.type,m.needsUpdate=!1,n.setRenderTarget(E,v,A)};function b(T,D){const R=e.update(_);h.defines.VSM_SAMPLES!==T.blurSamples&&(h.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Hi(s.x,s.y)),h.uniforms.shadow_pass.value=T.map.texture,h.uniforms.resolution.value=T.mapSize,h.uniforms.radius.value=T.radius,n.setRenderTarget(T.mapPass),n.clear(),n.renderBufferDirect(D,null,R,h,_,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,n.setRenderTarget(T.map),n.clear(),n.renderBufferDirect(D,null,R,f,_,null)}function y(T,D,R,E){let v=null;const A=R.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(A!==void 0)v=A;else if(v=R.isPointLight===!0?l:a,n.localClippingEnabled&&D.clipShadows===!0&&Array.isArray(D.clippingPlanes)&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0||D.map&&D.alphaTest>0){const O=v.uuid,L=D.uuid;let k=c[O];k===void 0&&(k={},c[O]=k);let X=k[L];X===void 0&&(X=v.clone(),k[L]=X,D.addEventListener("dispose",C)),v=X}if(v.visible=D.visible,v.wireframe=D.wireframe,E===qn?v.side=D.shadowSide!==null?D.shadowSide:D.side:v.side=D.shadowSide!==null?D.shadowSide:u[D.side],v.alphaMap=D.alphaMap,v.alphaTest=D.alphaTest,v.map=D.map,v.clipShadows=D.clipShadows,v.clippingPlanes=D.clippingPlanes,v.clipIntersection=D.clipIntersection,v.displacementMap=D.displacementMap,v.displacementScale=D.displacementScale,v.displacementBias=D.displacementBias,v.wireframeLinewidth=D.wireframeLinewidth,v.linewidth=D.linewidth,R.isPointLight===!0&&v.isMeshDistanceMaterial===!0){const O=n.properties.get(v);O.light=R}return v}function S(T,D,R,E,v){if(T.visible===!1)return;if(T.layers.test(D.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&v===qn)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,T.matrixWorld);const L=e.update(T),k=T.material;if(Array.isArray(k)){const X=L.groups;for(let B=0,G=X.length;B<G;B++){const z=X[B],J=k[z.materialIndex];if(J&&J.visible){const se=y(T,J,E,v);T.onBeforeShadow(n,T,D,R,L,se,z),n.renderBufferDirect(R,null,L,se,T,z),T.onAfterShadow(n,T,D,R,L,se,z)}}}else if(k.visible){const X=y(T,k,E,v);T.onBeforeShadow(n,T,D,R,L,X,null),n.renderBufferDirect(R,null,L,X,T,null),T.onAfterShadow(n,T,D,R,L,X,null)}}const O=T.children;for(let L=0,k=O.length;L<k;L++)S(O[L],D,R,E,v)}function C(T){T.target.removeEventListener("dispose",C);for(const R in c){const E=c[R],v=T.target.uuid;v in E&&(E[v].dispose(),delete E[v])}}}const Mx={[za]:ka,[Ha]:Wa,[Ga]:Xa,[ys]:Va,[ka]:za,[Wa]:Ha,[Xa]:Ga,[Va]:ys};function Ex(n,e){function t(){let U=!1;const re=new rt;let Y=null;const Z=new rt(0,0,0,0);return{setMask:function(ue){Y!==ue&&!U&&(n.colorMask(ue,ue,ue,ue),Y=ue)},setLocked:function(ue){U=ue},setClear:function(ue,de,Ue,mt,Ot){Ot===!0&&(ue*=mt,de*=mt,Ue*=mt),re.set(ue,de,Ue,mt),Z.equals(re)===!1&&(n.clearColor(ue,de,Ue,mt),Z.copy(re))},reset:function(){U=!1,Y=null,Z.set(-1,0,0,0)}}}function i(){let U=!1,re=!1,Y=null,Z=null,ue=null;return{setReversed:function(de){if(re!==de){const Ue=e.get("EXT_clip_control");re?Ue.clipControlEXT(Ue.LOWER_LEFT_EXT,Ue.ZERO_TO_ONE_EXT):Ue.clipControlEXT(Ue.LOWER_LEFT_EXT,Ue.NEGATIVE_ONE_TO_ONE_EXT);const mt=ue;ue=null,this.setClear(mt)}re=de},getReversed:function(){return re},setTest:function(de){de?le(n.DEPTH_TEST):Ae(n.DEPTH_TEST)},setMask:function(de){Y!==de&&!U&&(n.depthMask(de),Y=de)},setFunc:function(de){if(re&&(de=Mx[de]),Z!==de){switch(de){case za:n.depthFunc(n.NEVER);break;case ka:n.depthFunc(n.ALWAYS);break;case Ha:n.depthFunc(n.LESS);break;case ys:n.depthFunc(n.LEQUAL);break;case Ga:n.depthFunc(n.EQUAL);break;case Va:n.depthFunc(n.GEQUAL);break;case Wa:n.depthFunc(n.GREATER);break;case Xa:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Z=de}},setLocked:function(de){U=de},setClear:function(de){ue!==de&&(re&&(de=1-de),n.clearDepth(de),ue=de)},reset:function(){U=!1,Y=null,Z=null,ue=null,re=!1}}}function s(){let U=!1,re=null,Y=null,Z=null,ue=null,de=null,Ue=null,mt=null,Ot=null;return{setTest:function(et){U||(et?le(n.STENCIL_TEST):Ae(n.STENCIL_TEST))},setMask:function(et){re!==et&&!U&&(n.stencilMask(et),re=et)},setFunc:function(et,Mn,Hn){(Y!==et||Z!==Mn||ue!==Hn)&&(n.stencilFunc(et,Mn,Hn),Y=et,Z=Mn,ue=Hn)},setOp:function(et,Mn,Hn){(de!==et||Ue!==Mn||mt!==Hn)&&(n.stencilOp(et,Mn,Hn),de=et,Ue=Mn,mt=Hn)},setLocked:function(et){U=et},setClear:function(et){Ot!==et&&(n.clearStencil(et),Ot=et)},reset:function(){U=!1,re=null,Y=null,Z=null,ue=null,de=null,Ue=null,mt=null,Ot=null}}}const r=new t,o=new i,a=new s,l=new WeakMap,c=new WeakMap;let d={},u={},h=new WeakMap,f=[],g=null,_=!1,m=null,p=null,b=null,y=null,S=null,C=null,T=null,D=new Ze(0,0,0),R=0,E=!1,v=null,A=null,O=null,L=null,k=null;const X=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let B=!1,G=0;const z=n.getParameter(n.VERSION);z.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(z)[1]),B=G>=1):z.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),B=G>=2);let J=null,se={};const ae=n.getParameter(n.SCISSOR_BOX),Ce=n.getParameter(n.VIEWPORT),Qe=new rt().fromArray(ae),j=new rt().fromArray(Ce);function te(U,re,Y,Z){const ue=new Uint8Array(4),de=n.createTexture();n.bindTexture(U,de),n.texParameteri(U,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(U,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ue=0;Ue<Y;Ue++)U===n.TEXTURE_3D||U===n.TEXTURE_2D_ARRAY?n.texImage3D(re,0,n.RGBA,1,1,Z,0,n.RGBA,n.UNSIGNED_BYTE,ue):n.texImage2D(re+Ue,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,ue);return de}const _e={};_e[n.TEXTURE_2D]=te(n.TEXTURE_2D,n.TEXTURE_2D,1),_e[n.TEXTURE_CUBE_MAP]=te(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),_e[n.TEXTURE_2D_ARRAY]=te(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),_e[n.TEXTURE_3D]=te(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),le(n.DEPTH_TEST),o.setFunc(ys),ke(!1),He(gc),le(n.CULL_FACE),I(Si);function le(U){d[U]!==!0&&(n.enable(U),d[U]=!0)}function Ae(U){d[U]!==!1&&(n.disable(U),d[U]=!1)}function Ie(U,re){return u[U]!==re?(n.bindFramebuffer(U,re),u[U]=re,U===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=re),U===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=re),!0):!1}function ze(U,re){let Y=f,Z=!1;if(U){Y=h.get(re),Y===void 0&&(Y=[],h.set(re,Y));const ue=U.textures;if(Y.length!==ue.length||Y[0]!==n.COLOR_ATTACHMENT0){for(let de=0,Ue=ue.length;de<Ue;de++)Y[de]=n.COLOR_ATTACHMENT0+de;Y.length=ue.length,Z=!0}}else Y[0]!==n.BACK&&(Y[0]=n.BACK,Z=!0);Z&&n.drawBuffers(Y)}function ht(U){return g!==U?(n.useProgram(U),g=U,!0):!1}const Ve={[Ni]:n.FUNC_ADD,[lp]:n.FUNC_SUBTRACT,[cp]:n.FUNC_REVERSE_SUBTRACT};Ve[dp]=n.MIN,Ve[up]=n.MAX;const xt={[hp]:n.ZERO,[fp]:n.ONE,[pp]:n.SRC_COLOR,[Fa]:n.SRC_ALPHA,[Sp]:n.SRC_ALPHA_SATURATE,[vp]:n.DST_COLOR,[gp]:n.DST_ALPHA,[mp]:n.ONE_MINUS_SRC_COLOR,[Ba]:n.ONE_MINUS_SRC_ALPHA,[xp]:n.ONE_MINUS_DST_COLOR,[_p]:n.ONE_MINUS_DST_ALPHA,[yp]:n.CONSTANT_COLOR,[Mp]:n.ONE_MINUS_CONSTANT_COLOR,[Ep]:n.CONSTANT_ALPHA,[bp]:n.ONE_MINUS_CONSTANT_ALPHA};function I(U,re,Y,Z,ue,de,Ue,mt,Ot,et){if(U===Si){_===!0&&(Ae(n.BLEND),_=!1);return}if(_===!1&&(le(n.BLEND),_=!0),U!==ap){if(U!==m||et!==E){if((p!==Ni||S!==Ni)&&(n.blendEquation(n.FUNC_ADD),p=Ni,S=Ni),et)switch(U){case gs:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case _c:n.blendFunc(n.ONE,n.ONE);break;case vc:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case xc:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case gs:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case _c:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case vc:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case xc:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}b=null,y=null,C=null,T=null,D.set(0,0,0),R=0,m=U,E=et}return}ue=ue||re,de=de||Y,Ue=Ue||Z,(re!==p||ue!==S)&&(n.blendEquationSeparate(Ve[re],Ve[ue]),p=re,S=ue),(Y!==b||Z!==y||de!==C||Ue!==T)&&(n.blendFuncSeparate(xt[Y],xt[Z],xt[de],xt[Ue]),b=Y,y=Z,C=de,T=Ue),(mt.equals(D)===!1||Ot!==R)&&(n.blendColor(mt.r,mt.g,mt.b,Ot),D.copy(mt),R=Ot),m=U,E=!1}function un(U,re){U.side===jn?Ae(n.CULL_FACE):le(n.CULL_FACE);let Y=U.side===en;re&&(Y=!Y),ke(Y),U.blending===gs&&U.transparent===!1?I(Si):I(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),o.setFunc(U.depthFunc),o.setTest(U.depthTest),o.setMask(U.depthWrite),r.setMask(U.colorWrite);const Z=U.stencilWrite;a.setTest(Z),Z&&(a.setMask(U.stencilWriteMask),a.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),a.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),ot(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?le(n.SAMPLE_ALPHA_TO_COVERAGE):Ae(n.SAMPLE_ALPHA_TO_COVERAGE)}function ke(U){v!==U&&(U?n.frontFace(n.CW):n.frontFace(n.CCW),v=U)}function He(U){U!==sp?(le(n.CULL_FACE),U!==A&&(U===gc?n.cullFace(n.BACK):U===rp?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Ae(n.CULL_FACE),A=U}function xe(U){U!==O&&(B&&n.lineWidth(U),O=U)}function ot(U,re,Y){U?(le(n.POLYGON_OFFSET_FILL),(L!==re||k!==Y)&&(n.polygonOffset(re,Y),L=re,k=Y)):Ae(n.POLYGON_OFFSET_FILL)}function Se(U){U?le(n.SCISSOR_TEST):Ae(n.SCISSOR_TEST)}function w(U){U===void 0&&(U=n.TEXTURE0+X-1),J!==U&&(n.activeTexture(U),J=U)}function x(U,re,Y){Y===void 0&&(J===null?Y=n.TEXTURE0+X-1:Y=J);let Z=se[Y];Z===void 0&&(Z={type:void 0,texture:void 0},se[Y]=Z),(Z.type!==U||Z.texture!==re)&&(J!==Y&&(n.activeTexture(Y),J=Y),n.bindTexture(U,re||_e[U]),Z.type=U,Z.texture=re)}function H(){const U=se[J];U!==void 0&&U.type!==void 0&&(n.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function $(){try{n.compressedTexImage2D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function K(){try{n.compressedTexImage3D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function q(){try{n.texSubImage2D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ve(){try{n.texSubImage3D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ce(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function fe(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function We(){try{n.texStorage2D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ee(){try{n.texStorage3D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function pe(){try{n.texImage2D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ee(){try{n.texImage3D.apply(n,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Re(U){Qe.equals(U)===!1&&(n.scissor(U.x,U.y,U.z,U.w),Qe.copy(U))}function me(U){j.equals(U)===!1&&(n.viewport(U.x,U.y,U.z,U.w),j.copy(U))}function Ge(U,re){let Y=c.get(re);Y===void 0&&(Y=new WeakMap,c.set(re,Y));let Z=Y.get(U);Z===void 0&&(Z=n.getUniformBlockIndex(re,U.name),Y.set(U,Z))}function Oe(U,re){const Z=c.get(re).get(U);l.get(re)!==Z&&(n.uniformBlockBinding(re,Z,U.__bindingPointIndex),l.set(re,Z))}function st(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),o.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),d={},J=null,se={},u={},h=new WeakMap,f=[],g=null,_=!1,m=null,p=null,b=null,y=null,S=null,C=null,T=null,D=new Ze(0,0,0),R=0,E=!1,v=null,A=null,O=null,L=null,k=null,Qe.set(0,0,n.canvas.width,n.canvas.height),j.set(0,0,n.canvas.width,n.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:le,disable:Ae,bindFramebuffer:Ie,drawBuffers:ze,useProgram:ht,setBlending:I,setMaterial:un,setFlipSided:ke,setCullFace:He,setLineWidth:xe,setPolygonOffset:ot,setScissorTest:Se,activeTexture:w,bindTexture:x,unbindTexture:H,compressedTexImage2D:$,compressedTexImage3D:K,texImage2D:pe,texImage3D:Ee,updateUBOMapping:Ge,uniformBlockBinding:Oe,texStorage2D:We,texStorage3D:ee,texSubImage2D:q,texSubImage3D:ve,compressedTexSubImage2D:ce,compressedTexSubImage3D:fe,scissor:Re,viewport:me,reset:st}}function bx(n,e,t,i,s,r,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Te,d=new WeakMap;let u;const h=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(w,x){return f?new OffscreenCanvas(w,x):Qs("canvas")}function _(w,x,H){let $=1;const K=Se(w);if((K.width>H||K.height>H)&&($=H/Math.max(K.width,K.height)),$<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){const q=Math.floor($*K.width),ve=Math.floor($*K.height);u===void 0&&(u=g(q,ve));const ce=x?g(q,ve):u;return ce.width=q,ce.height=ve,ce.getContext("2d").drawImage(w,0,0,q,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+q+"x"+ve+")."),ce}else return"data"in w&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),w;return w}function m(w){return w.generateMipmaps}function p(w){n.generateMipmap(w)}function b(w){return w.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:w.isWebGL3DRenderTarget?n.TEXTURE_3D:w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(w,x,H,$,K=!1){if(w!==null){if(n[w]!==void 0)return n[w];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let q=x;if(x===n.RED&&(H===n.FLOAT&&(q=n.R32F),H===n.HALF_FLOAT&&(q=n.R16F),H===n.UNSIGNED_BYTE&&(q=n.R8)),x===n.RED_INTEGER&&(H===n.UNSIGNED_BYTE&&(q=n.R8UI),H===n.UNSIGNED_SHORT&&(q=n.R16UI),H===n.UNSIGNED_INT&&(q=n.R32UI),H===n.BYTE&&(q=n.R8I),H===n.SHORT&&(q=n.R16I),H===n.INT&&(q=n.R32I)),x===n.RG&&(H===n.FLOAT&&(q=n.RG32F),H===n.HALF_FLOAT&&(q=n.RG16F),H===n.UNSIGNED_BYTE&&(q=n.RG8)),x===n.RG_INTEGER&&(H===n.UNSIGNED_BYTE&&(q=n.RG8UI),H===n.UNSIGNED_SHORT&&(q=n.RG16UI),H===n.UNSIGNED_INT&&(q=n.RG32UI),H===n.BYTE&&(q=n.RG8I),H===n.SHORT&&(q=n.RG16I),H===n.INT&&(q=n.RG32I)),x===n.RGB_INTEGER&&(H===n.UNSIGNED_BYTE&&(q=n.RGB8UI),H===n.UNSIGNED_SHORT&&(q=n.RGB16UI),H===n.UNSIGNED_INT&&(q=n.RGB32UI),H===n.BYTE&&(q=n.RGB8I),H===n.SHORT&&(q=n.RGB16I),H===n.INT&&(q=n.RGB32I)),x===n.RGBA_INTEGER&&(H===n.UNSIGNED_BYTE&&(q=n.RGBA8UI),H===n.UNSIGNED_SHORT&&(q=n.RGBA16UI),H===n.UNSIGNED_INT&&(q=n.RGBA32UI),H===n.BYTE&&(q=n.RGBA8I),H===n.SHORT&&(q=n.RGBA16I),H===n.INT&&(q=n.RGBA32I)),x===n.RGB&&H===n.UNSIGNED_INT_5_9_9_9_REV&&(q=n.RGB9_E5),x===n.RGBA){const ve=K?fo:je.getTransfer($);H===n.FLOAT&&(q=n.RGBA32F),H===n.HALF_FLOAT&&(q=n.RGBA16F),H===n.UNSIGNED_BYTE&&(q=ve===nt?n.SRGB8_ALPHA8:n.RGBA8),H===n.UNSIGNED_SHORT_4_4_4_4&&(q=n.RGBA4),H===n.UNSIGNED_SHORT_5_5_5_1&&(q=n.RGB5_A1)}return(q===n.R16F||q===n.R32F||q===n.RG16F||q===n.RG32F||q===n.RGBA16F||q===n.RGBA32F)&&e.get("EXT_color_buffer_float"),q}function S(w,x){let H;return w?x===null||x===ki||x===bs?H=n.DEPTH24_STENCIL8:x===Zn?H=n.DEPTH32F_STENCIL8:x===Ks&&(H=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ki||x===bs?H=n.DEPTH_COMPONENT24:x===Zn?H=n.DEPTH_COMPONENT32F:x===Ks&&(H=n.DEPTH_COMPONENT16),H}function C(w,x){return m(w)===!0||w.isFramebufferTexture&&w.minFilter!==In&&w.minFilter!==Bn?Math.log2(Math.max(x.width,x.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?x.mipmaps.length:1}function T(w){const x=w.target;x.removeEventListener("dispose",T),R(x),x.isVideoTexture&&d.delete(x)}function D(w){const x=w.target;x.removeEventListener("dispose",D),v(x)}function R(w){const x=i.get(w);if(x.__webglInit===void 0)return;const H=w.source,$=h.get(H);if($){const K=$[x.__cacheKey];K.usedTimes--,K.usedTimes===0&&E(w),Object.keys($).length===0&&h.delete(H)}i.remove(w)}function E(w){const x=i.get(w);n.deleteTexture(x.__webglTexture);const H=w.source,$=h.get(H);delete $[x.__cacheKey],o.memory.textures--}function v(w){const x=i.get(w);if(w.depthTexture&&(w.depthTexture.dispose(),i.remove(w.depthTexture)),w.isWebGLCubeRenderTarget)for(let $=0;$<6;$++){if(Array.isArray(x.__webglFramebuffer[$]))for(let K=0;K<x.__webglFramebuffer[$].length;K++)n.deleteFramebuffer(x.__webglFramebuffer[$][K]);else n.deleteFramebuffer(x.__webglFramebuffer[$]);x.__webglDepthbuffer&&n.deleteRenderbuffer(x.__webglDepthbuffer[$])}else{if(Array.isArray(x.__webglFramebuffer))for(let $=0;$<x.__webglFramebuffer.length;$++)n.deleteFramebuffer(x.__webglFramebuffer[$]);else n.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&n.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&n.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let $=0;$<x.__webglColorRenderbuffer.length;$++)x.__webglColorRenderbuffer[$]&&n.deleteRenderbuffer(x.__webglColorRenderbuffer[$]);x.__webglDepthRenderbuffer&&n.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const H=w.textures;for(let $=0,K=H.length;$<K;$++){const q=i.get(H[$]);q.__webglTexture&&(n.deleteTexture(q.__webglTexture),o.memory.textures--),i.remove(H[$])}i.remove(w)}let A=0;function O(){A=0}function L(){const w=A;return w>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+s.maxTextures),A+=1,w}function k(w){const x=[];return x.push(w.wrapS),x.push(w.wrapT),x.push(w.wrapR||0),x.push(w.magFilter),x.push(w.minFilter),x.push(w.anisotropy),x.push(w.internalFormat),x.push(w.format),x.push(w.type),x.push(w.generateMipmaps),x.push(w.premultiplyAlpha),x.push(w.flipY),x.push(w.unpackAlignment),x.push(w.colorSpace),x.join()}function X(w,x){const H=i.get(w);if(w.isVideoTexture&&xe(w),w.isRenderTargetTexture===!1&&w.version>0&&H.__version!==w.version){const $=w.image;if($===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if($.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{j(H,w,x);return}}t.bindTexture(n.TEXTURE_2D,H.__webglTexture,n.TEXTURE0+x)}function B(w,x){const H=i.get(w);if(w.version>0&&H.__version!==w.version){j(H,w,x);return}t.bindTexture(n.TEXTURE_2D_ARRAY,H.__webglTexture,n.TEXTURE0+x)}function G(w,x){const H=i.get(w);if(w.version>0&&H.__version!==w.version){j(H,w,x);return}t.bindTexture(n.TEXTURE_3D,H.__webglTexture,n.TEXTURE0+x)}function z(w,x){const H=i.get(w);if(w.version>0&&H.__version!==w.version){te(H,w,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture,n.TEXTURE0+x)}const J={[ja]:n.REPEAT,[Fi]:n.CLAMP_TO_EDGE,[$a]:n.MIRRORED_REPEAT},se={[In]:n.NEAREST,[Up]:n.NEAREST_MIPMAP_NEAREST,[dr]:n.NEAREST_MIPMAP_LINEAR,[Bn]:n.LINEAR,[zo]:n.LINEAR_MIPMAP_NEAREST,[Bi]:n.LINEAR_MIPMAP_LINEAR},ae={[zp]:n.NEVER,[Xp]:n.ALWAYS,[kp]:n.LESS,[gu]:n.LEQUAL,[Hp]:n.EQUAL,[Wp]:n.GEQUAL,[Gp]:n.GREATER,[Vp]:n.NOTEQUAL};function Ce(w,x){if(x.type===Zn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Bn||x.magFilter===zo||x.magFilter===dr||x.magFilter===Bi||x.minFilter===Bn||x.minFilter===zo||x.minFilter===dr||x.minFilter===Bi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(w,n.TEXTURE_WRAP_S,J[x.wrapS]),n.texParameteri(w,n.TEXTURE_WRAP_T,J[x.wrapT]),(w===n.TEXTURE_3D||w===n.TEXTURE_2D_ARRAY)&&n.texParameteri(w,n.TEXTURE_WRAP_R,J[x.wrapR]),n.texParameteri(w,n.TEXTURE_MAG_FILTER,se[x.magFilter]),n.texParameteri(w,n.TEXTURE_MIN_FILTER,se[x.minFilter]),x.compareFunction&&(n.texParameteri(w,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(w,n.TEXTURE_COMPARE_FUNC,ae[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===In||x.minFilter!==dr&&x.minFilter!==Bi||x.type===Zn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const H=e.get("EXT_texture_filter_anisotropic");n.texParameterf(w,H.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function Qe(w,x){let H=!1;w.__webglInit===void 0&&(w.__webglInit=!0,x.addEventListener("dispose",T));const $=x.source;let K=h.get($);K===void 0&&(K={},h.set($,K));const q=k(x);if(q!==w.__cacheKey){K[q]===void 0&&(K[q]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,H=!0),K[q].usedTimes++;const ve=K[w.__cacheKey];ve!==void 0&&(K[w.__cacheKey].usedTimes--,ve.usedTimes===0&&E(x)),w.__cacheKey=q,w.__webglTexture=K[q].texture}return H}function j(w,x,H){let $=n.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&($=n.TEXTURE_2D_ARRAY),x.isData3DTexture&&($=n.TEXTURE_3D);const K=Qe(w,x),q=x.source;t.bindTexture($,w.__webglTexture,n.TEXTURE0+H);const ve=i.get(q);if(q.version!==ve.__version||K===!0){t.activeTexture(n.TEXTURE0+H);const ce=je.getPrimaries(je.workingColorSpace),fe=x.colorSpace===pi?null:je.getPrimaries(x.colorSpace),We=x.colorSpace===pi||ce===fe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,x.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,x.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,We);let ee=_(x.image,!1,s.maxTextureSize);ee=ot(x,ee);const pe=r.convert(x.format,x.colorSpace),Ee=r.convert(x.type);let Re=y(x.internalFormat,pe,Ee,x.colorSpace,x.isVideoTexture);Ce($,x);let me;const Ge=x.mipmaps,Oe=x.isVideoTexture!==!0,st=ve.__version===void 0||K===!0,U=q.dataReady,re=C(x,ee);if(x.isDepthTexture)Re=S(x.format===ws,x.type),st&&(Oe?t.texStorage2D(n.TEXTURE_2D,1,Re,ee.width,ee.height):t.texImage2D(n.TEXTURE_2D,0,Re,ee.width,ee.height,0,pe,Ee,null));else if(x.isDataTexture)if(Ge.length>0){Oe&&st&&t.texStorage2D(n.TEXTURE_2D,re,Re,Ge[0].width,Ge[0].height);for(let Y=0,Z=Ge.length;Y<Z;Y++)me=Ge[Y],Oe?U&&t.texSubImage2D(n.TEXTURE_2D,Y,0,0,me.width,me.height,pe,Ee,me.data):t.texImage2D(n.TEXTURE_2D,Y,Re,me.width,me.height,0,pe,Ee,me.data);x.generateMipmaps=!1}else Oe?(st&&t.texStorage2D(n.TEXTURE_2D,re,Re,ee.width,ee.height),U&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,ee.width,ee.height,pe,Ee,ee.data)):t.texImage2D(n.TEXTURE_2D,0,Re,ee.width,ee.height,0,pe,Ee,ee.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Oe&&st&&t.texStorage3D(n.TEXTURE_2D_ARRAY,re,Re,Ge[0].width,Ge[0].height,ee.depth);for(let Y=0,Z=Ge.length;Y<Z;Y++)if(me=Ge[Y],x.format!==Ln)if(pe!==null)if(Oe){if(U)if(x.layerUpdates.size>0){const ue=Zc(me.width,me.height,x.format,x.type);for(const de of x.layerUpdates){const Ue=me.data.subarray(de*ue/me.data.BYTES_PER_ELEMENT,(de+1)*ue/me.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Y,0,0,de,me.width,me.height,1,pe,Ue)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Y,0,0,0,me.width,me.height,ee.depth,pe,me.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Y,Re,me.width,me.height,ee.depth,0,me.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Oe?U&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Y,0,0,0,me.width,me.height,ee.depth,pe,Ee,me.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Y,Re,me.width,me.height,ee.depth,0,pe,Ee,me.data)}else{Oe&&st&&t.texStorage2D(n.TEXTURE_2D,re,Re,Ge[0].width,Ge[0].height);for(let Y=0,Z=Ge.length;Y<Z;Y++)me=Ge[Y],x.format!==Ln?pe!==null?Oe?U&&t.compressedTexSubImage2D(n.TEXTURE_2D,Y,0,0,me.width,me.height,pe,me.data):t.compressedTexImage2D(n.TEXTURE_2D,Y,Re,me.width,me.height,0,me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Oe?U&&t.texSubImage2D(n.TEXTURE_2D,Y,0,0,me.width,me.height,pe,Ee,me.data):t.texImage2D(n.TEXTURE_2D,Y,Re,me.width,me.height,0,pe,Ee,me.data)}else if(x.isDataArrayTexture)if(Oe){if(st&&t.texStorage3D(n.TEXTURE_2D_ARRAY,re,Re,ee.width,ee.height,ee.depth),U)if(x.layerUpdates.size>0){const Y=Zc(ee.width,ee.height,x.format,x.type);for(const Z of x.layerUpdates){const ue=ee.data.subarray(Z*Y/ee.data.BYTES_PER_ELEMENT,(Z+1)*Y/ee.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,Z,ee.width,ee.height,1,pe,Ee,ue)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ee.width,ee.height,ee.depth,pe,Ee,ee.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Re,ee.width,ee.height,ee.depth,0,pe,Ee,ee.data);else if(x.isData3DTexture)Oe?(st&&t.texStorage3D(n.TEXTURE_3D,re,Re,ee.width,ee.height,ee.depth),U&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ee.width,ee.height,ee.depth,pe,Ee,ee.data)):t.texImage3D(n.TEXTURE_3D,0,Re,ee.width,ee.height,ee.depth,0,pe,Ee,ee.data);else if(x.isFramebufferTexture){if(st)if(Oe)t.texStorage2D(n.TEXTURE_2D,re,Re,ee.width,ee.height);else{let Y=ee.width,Z=ee.height;for(let ue=0;ue<re;ue++)t.texImage2D(n.TEXTURE_2D,ue,Re,Y,Z,0,pe,Ee,null),Y>>=1,Z>>=1}}else if(Ge.length>0){if(Oe&&st){const Y=Se(Ge[0]);t.texStorage2D(n.TEXTURE_2D,re,Re,Y.width,Y.height)}for(let Y=0,Z=Ge.length;Y<Z;Y++)me=Ge[Y],Oe?U&&t.texSubImage2D(n.TEXTURE_2D,Y,0,0,pe,Ee,me):t.texImage2D(n.TEXTURE_2D,Y,Re,pe,Ee,me);x.generateMipmaps=!1}else if(Oe){if(st){const Y=Se(ee);t.texStorage2D(n.TEXTURE_2D,re,Re,Y.width,Y.height)}U&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,pe,Ee,ee)}else t.texImage2D(n.TEXTURE_2D,0,Re,pe,Ee,ee);m(x)&&p($),ve.__version=q.version,x.onUpdate&&x.onUpdate(x)}w.__version=x.version}function te(w,x,H){if(x.image.length!==6)return;const $=Qe(w,x),K=x.source;t.bindTexture(n.TEXTURE_CUBE_MAP,w.__webglTexture,n.TEXTURE0+H);const q=i.get(K);if(K.version!==q.__version||$===!0){t.activeTexture(n.TEXTURE0+H);const ve=je.getPrimaries(je.workingColorSpace),ce=x.colorSpace===pi?null:je.getPrimaries(x.colorSpace),fe=x.colorSpace===pi||ve===ce?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,x.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,x.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,fe);const We=x.isCompressedTexture||x.image[0].isCompressedTexture,ee=x.image[0]&&x.image[0].isDataTexture,pe=[];for(let Z=0;Z<6;Z++)!We&&!ee?pe[Z]=_(x.image[Z],!0,s.maxCubemapSize):pe[Z]=ee?x.image[Z].image:x.image[Z],pe[Z]=ot(x,pe[Z]);const Ee=pe[0],Re=r.convert(x.format,x.colorSpace),me=r.convert(x.type),Ge=y(x.internalFormat,Re,me,x.colorSpace),Oe=x.isVideoTexture!==!0,st=q.__version===void 0||$===!0,U=K.dataReady;let re=C(x,Ee);Ce(n.TEXTURE_CUBE_MAP,x);let Y;if(We){Oe&&st&&t.texStorage2D(n.TEXTURE_CUBE_MAP,re,Ge,Ee.width,Ee.height);for(let Z=0;Z<6;Z++){Y=pe[Z].mipmaps;for(let ue=0;ue<Y.length;ue++){const de=Y[ue];x.format!==Ln?Re!==null?Oe?U&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ue,0,0,de.width,de.height,Re,de.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ue,Ge,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Oe?U&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ue,0,0,de.width,de.height,Re,me,de.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ue,Ge,de.width,de.height,0,Re,me,de.data)}}}else{if(Y=x.mipmaps,Oe&&st){Y.length>0&&re++;const Z=Se(pe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,re,Ge,Z.width,Z.height)}for(let Z=0;Z<6;Z++)if(ee){Oe?U&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,pe[Z].width,pe[Z].height,Re,me,pe[Z].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,Ge,pe[Z].width,pe[Z].height,0,Re,me,pe[Z].data);for(let ue=0;ue<Y.length;ue++){const Ue=Y[ue].image[Z].image;Oe?U&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ue+1,0,0,Ue.width,Ue.height,Re,me,Ue.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ue+1,Ge,Ue.width,Ue.height,0,Re,me,Ue.data)}}else{Oe?U&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,Re,me,pe[Z]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,Ge,Re,me,pe[Z]);for(let ue=0;ue<Y.length;ue++){const de=Y[ue];Oe?U&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ue+1,0,0,Re,me,de.image[Z]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ue+1,Ge,Re,me,de.image[Z])}}}m(x)&&p(n.TEXTURE_CUBE_MAP),q.__version=K.version,x.onUpdate&&x.onUpdate(x)}w.__version=x.version}function _e(w,x,H,$,K,q){const ve=r.convert(H.format,H.colorSpace),ce=r.convert(H.type),fe=y(H.internalFormat,ve,ce,H.colorSpace),We=i.get(x),ee=i.get(H);if(ee.__renderTarget=x,!We.__hasExternalTextures){const pe=Math.max(1,x.width>>q),Ee=Math.max(1,x.height>>q);K===n.TEXTURE_3D||K===n.TEXTURE_2D_ARRAY?t.texImage3D(K,q,fe,pe,Ee,x.depth,0,ve,ce,null):t.texImage2D(K,q,fe,pe,Ee,0,ve,ce,null)}t.bindFramebuffer(n.FRAMEBUFFER,w),He(x)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,$,K,ee.__webglTexture,0,ke(x)):(K===n.TEXTURE_2D||K>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,$,K,ee.__webglTexture,q),t.bindFramebuffer(n.FRAMEBUFFER,null)}function le(w,x,H){if(n.bindRenderbuffer(n.RENDERBUFFER,w),x.depthBuffer){const $=x.depthTexture,K=$&&$.isDepthTexture?$.type:null,q=S(x.stencilBuffer,K),ve=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ce=ke(x);He(x)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ce,q,x.width,x.height):H?n.renderbufferStorageMultisample(n.RENDERBUFFER,ce,q,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,q,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,ve,n.RENDERBUFFER,w)}else{const $=x.textures;for(let K=0;K<$.length;K++){const q=$[K],ve=r.convert(q.format,q.colorSpace),ce=r.convert(q.type),fe=y(q.internalFormat,ve,ce,q.colorSpace),We=ke(x);H&&He(x)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,We,fe,x.width,x.height):He(x)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,We,fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function Ae(w,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,w),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const $=i.get(x.depthTexture);$.__renderTarget=x,(!$.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),X(x.depthTexture,0);const K=$.__webglTexture,q=ke(x);if(x.depthTexture.format===_s)He(x)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,K,0,q):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,K,0);else if(x.depthTexture.format===ws)He(x)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,K,0,q):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,K,0);else throw new Error("Unknown depthTexture format")}function Ie(w){const x=i.get(w),H=w.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==w.depthTexture){const $=w.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),$){const K=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,$.removeEventListener("dispose",K)};$.addEventListener("dispose",K),x.__depthDisposeCallback=K}x.__boundDepthTexture=$}if(w.depthTexture&&!x.__autoAllocateDepthBuffer){if(H)throw new Error("target.depthTexture not supported in Cube render targets");Ae(x.__webglFramebuffer,w)}else if(H){x.__webglDepthbuffer=[];for(let $=0;$<6;$++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[$]),x.__webglDepthbuffer[$]===void 0)x.__webglDepthbuffer[$]=n.createRenderbuffer(),le(x.__webglDepthbuffer[$],w,!1);else{const K=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,q=x.__webglDepthbuffer[$];n.bindRenderbuffer(n.RENDERBUFFER,q),n.framebufferRenderbuffer(n.FRAMEBUFFER,K,n.RENDERBUFFER,q)}}else if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),le(x.__webglDepthbuffer,w,!1);else{const $=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,K=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,K),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,K)}t.bindFramebuffer(n.FRAMEBUFFER,null)}function ze(w,x,H){const $=i.get(w);x!==void 0&&_e($.__webglFramebuffer,w,w.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),H!==void 0&&Ie(w)}function ht(w){const x=w.texture,H=i.get(w),$=i.get(x);w.addEventListener("dispose",D);const K=w.textures,q=w.isWebGLCubeRenderTarget===!0,ve=K.length>1;if(ve||($.__webglTexture===void 0&&($.__webglTexture=n.createTexture()),$.__version=x.version,o.memory.textures++),q){H.__webglFramebuffer=[];for(let ce=0;ce<6;ce++)if(x.mipmaps&&x.mipmaps.length>0){H.__webglFramebuffer[ce]=[];for(let fe=0;fe<x.mipmaps.length;fe++)H.__webglFramebuffer[ce][fe]=n.createFramebuffer()}else H.__webglFramebuffer[ce]=n.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){H.__webglFramebuffer=[];for(let ce=0;ce<x.mipmaps.length;ce++)H.__webglFramebuffer[ce]=n.createFramebuffer()}else H.__webglFramebuffer=n.createFramebuffer();if(ve)for(let ce=0,fe=K.length;ce<fe;ce++){const We=i.get(K[ce]);We.__webglTexture===void 0&&(We.__webglTexture=n.createTexture(),o.memory.textures++)}if(w.samples>0&&He(w)===!1){H.__webglMultisampledFramebuffer=n.createFramebuffer(),H.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,H.__webglMultisampledFramebuffer);for(let ce=0;ce<K.length;ce++){const fe=K[ce];H.__webglColorRenderbuffer[ce]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,H.__webglColorRenderbuffer[ce]);const We=r.convert(fe.format,fe.colorSpace),ee=r.convert(fe.type),pe=y(fe.internalFormat,We,ee,fe.colorSpace,w.isXRRenderTarget===!0),Ee=ke(w);n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,pe,w.width,w.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ce,n.RENDERBUFFER,H.__webglColorRenderbuffer[ce])}n.bindRenderbuffer(n.RENDERBUFFER,null),w.depthBuffer&&(H.__webglDepthRenderbuffer=n.createRenderbuffer(),le(H.__webglDepthRenderbuffer,w,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(q){t.bindTexture(n.TEXTURE_CUBE_MAP,$.__webglTexture),Ce(n.TEXTURE_CUBE_MAP,x);for(let ce=0;ce<6;ce++)if(x.mipmaps&&x.mipmaps.length>0)for(let fe=0;fe<x.mipmaps.length;fe++)_e(H.__webglFramebuffer[ce][fe],w,x,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,fe);else _e(H.__webglFramebuffer[ce],w,x,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0);m(x)&&p(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ve){for(let ce=0,fe=K.length;ce<fe;ce++){const We=K[ce],ee=i.get(We);t.bindTexture(n.TEXTURE_2D,ee.__webglTexture),Ce(n.TEXTURE_2D,We),_e(H.__webglFramebuffer,w,We,n.COLOR_ATTACHMENT0+ce,n.TEXTURE_2D,0),m(We)&&p(n.TEXTURE_2D)}t.unbindTexture()}else{let ce=n.TEXTURE_2D;if((w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(ce=w.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ce,$.__webglTexture),Ce(ce,x),x.mipmaps&&x.mipmaps.length>0)for(let fe=0;fe<x.mipmaps.length;fe++)_e(H.__webglFramebuffer[fe],w,x,n.COLOR_ATTACHMENT0,ce,fe);else _e(H.__webglFramebuffer,w,x,n.COLOR_ATTACHMENT0,ce,0);m(x)&&p(ce),t.unbindTexture()}w.depthBuffer&&Ie(w)}function Ve(w){const x=w.textures;for(let H=0,$=x.length;H<$;H++){const K=x[H];if(m(K)){const q=b(w),ve=i.get(K).__webglTexture;t.bindTexture(q,ve),p(q),t.unbindTexture()}}}const xt=[],I=[];function un(w){if(w.samples>0){if(He(w)===!1){const x=w.textures,H=w.width,$=w.height;let K=n.COLOR_BUFFER_BIT;const q=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ve=i.get(w),ce=x.length>1;if(ce)for(let fe=0;fe<x.length;fe++)t.bindFramebuffer(n.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,ve.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let fe=0;fe<x.length;fe++){if(w.resolveDepthBuffer&&(w.depthBuffer&&(K|=n.DEPTH_BUFFER_BIT),w.stencilBuffer&&w.resolveStencilBuffer&&(K|=n.STENCIL_BUFFER_BIT)),ce){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,ve.__webglColorRenderbuffer[fe]);const We=i.get(x[fe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,We,0)}n.blitFramebuffer(0,0,H,$,0,0,H,$,K,n.NEAREST),l===!0&&(xt.length=0,I.length=0,xt.push(n.COLOR_ATTACHMENT0+fe),w.depthBuffer&&w.resolveDepthBuffer===!1&&(xt.push(q),I.push(q),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,I)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,xt))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ce)for(let fe=0;fe<x.length;fe++){t.bindFramebuffer(n.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.RENDERBUFFER,ve.__webglColorRenderbuffer[fe]);const We=i.get(x[fe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,ve.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+fe,n.TEXTURE_2D,We,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.resolveDepthBuffer===!1&&l){const x=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[x])}}}function ke(w){return Math.min(s.maxSamples,w.samples)}function He(w){const x=i.get(w);return w.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function xe(w){const x=o.render.frame;d.get(w)!==x&&(d.set(w,x),w.update())}function ot(w,x){const H=w.colorSpace,$=w.format,K=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||H!==Ts&&H!==pi&&(je.getTransfer(H)===nt?($!==Ln||K!==ti)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",H)),x}function Se(w){return typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement?(c.width=w.naturalWidth||w.width,c.height=w.naturalHeight||w.height):typeof VideoFrame<"u"&&w instanceof VideoFrame?(c.width=w.displayWidth,c.height=w.displayHeight):(c.width=w.width,c.height=w.height),c}this.allocateTextureUnit=L,this.resetTextureUnits=O,this.setTexture2D=X,this.setTexture2DArray=B,this.setTexture3D=G,this.setTextureCube=z,this.rebindTextures=ze,this.setupRenderTarget=ht,this.updateRenderTargetMipmap=Ve,this.updateMultisampleRenderTarget=un,this.setupDepthRenderbuffer=Ie,this.setupFrameBufferTexture=_e,this.useMultisampledRTT=He}function wx(n,e){function t(i,s=pi){let r;const o=je.getTransfer(s);if(i===ti)return n.UNSIGNED_BYTE;if(i===Ol)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Fl)return n.UNSIGNED_SHORT_5_5_5_1;if(i===lu)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===ou)return n.BYTE;if(i===au)return n.SHORT;if(i===Ks)return n.UNSIGNED_SHORT;if(i===Nl)return n.INT;if(i===ki)return n.UNSIGNED_INT;if(i===Zn)return n.FLOAT;if(i===er)return n.HALF_FLOAT;if(i===cu)return n.ALPHA;if(i===du)return n.RGB;if(i===Ln)return n.RGBA;if(i===uu)return n.LUMINANCE;if(i===hu)return n.LUMINANCE_ALPHA;if(i===_s)return n.DEPTH_COMPONENT;if(i===ws)return n.DEPTH_STENCIL;if(i===fu)return n.RED;if(i===Bl)return n.RED_INTEGER;if(i===pu)return n.RG;if(i===zl)return n.RG_INTEGER;if(i===kl)return n.RGBA_INTEGER;if(i===Jr||i===Qr||i===eo||i===to)if(o===nt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Jr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Qr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===eo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===to)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Jr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Qr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===eo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===to)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Za||i===Ka||i===Ja||i===Qa)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Za)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ka)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ja)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Qa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===el||i===tl||i===nl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===el||i===tl)return o===nt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===nl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===il||i===sl||i===rl||i===ol||i===al||i===ll||i===cl||i===dl||i===ul||i===hl||i===fl||i===pl||i===ml||i===gl)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===il)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===sl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===rl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===ol)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===al)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ll)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===cl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===dl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ul)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===hl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===fl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===pl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ml)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===gl)return o===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===no||i===_l||i===vl)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===no)return o===nt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===_l)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===vl)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===mu||i===xl||i===Sl||i===yl)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===no)return r.COMPRESSED_RED_RGTC1_EXT;if(i===xl)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Sl)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===yl)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===bs?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Tx={type:"move"};class pa{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new vi,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 vi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new vi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let s=null,r=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,i),p=this._getHandJoint(c,_);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const d=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],h=d.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&h>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Tx)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new vi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const Ax=`
  3720. void main() {
  3721. gl_Position = vec4( position, 1.0 );
  3722. }`,Cx=`
  3723. uniform sampler2DArray depthColor;
  3724. uniform float depthWidth;
  3725. uniform float depthHeight;
  3726. void main() {
  3727. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3728. if ( coord.x >= 1.0 ) {
  3729. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3730. } else {
  3731. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3732. }
  3733. }`;class Rx{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const s=new Tt,r=e.properties.get(s);r.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new ii({vertexShader:Ax,fragmentShader:Cx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new vt(new qt(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Px extends Wi{constructor(e,t){super();const i=this;let s=null,r=1,o=null,a="local-floor",l=1,c=null,d=null,u=null,h=null,f=null,g=null;const _=new Rx,m=t.getContextAttributes();let p=null,b=null;const y=[],S=[],C=new Te;let T=null;const D=new vn;D.viewport=new rt;const R=new vn;R.viewport=new rt;const E=[D,R],v=new jm;let A=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let te=y[j];return te===void 0&&(te=new pa,y[j]=te),te.getTargetRaySpace()},this.getControllerGrip=function(j){let te=y[j];return te===void 0&&(te=new pa,y[j]=te),te.getGripSpace()},this.getHand=function(j){let te=y[j];return te===void 0&&(te=new pa,y[j]=te),te.getHandSpace()};function L(j){const te=S.indexOf(j.inputSource);if(te===-1)return;const _e=y[te];_e!==void 0&&(_e.update(j.inputSource,j.frame,c||o),_e.dispatchEvent({type:j.type,data:j.inputSource}))}function k(){s.removeEventListener("select",L),s.removeEventListener("selectstart",L),s.removeEventListener("selectend",L),s.removeEventListener("squeeze",L),s.removeEventListener("squeezestart",L),s.removeEventListener("squeezeend",L),s.removeEventListener("end",k),s.removeEventListener("inputsourceschange",X);for(let j=0;j<y.length;j++){const te=S[j];te!==null&&(S[j]=null,y[j].disconnect(te))}A=null,O=null,_.reset(),e.setRenderTarget(p),f=null,h=null,u=null,s=null,b=null,Qe.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(C.width,C.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){r=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){a=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(j){if(s=j,s!==null){if(p=e.getRenderTarget(),s.addEventListener("select",L),s.addEventListener("selectstart",L),s.addEventListener("selectend",L),s.addEventListener("squeeze",L),s.addEventListener("squeezestart",L),s.addEventListener("squeezeend",L),s.addEventListener("end",k),s.addEventListener("inputsourceschange",X),m.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(C),s.renderState.layers===void 0){const te={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,te),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),b=new Hi(f.framebufferWidth,f.framebufferHeight,{format:Ln,type:ti,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let te=null,_e=null,le=null;m.depth&&(le=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,te=m.stencil?ws:_s,_e=m.stencil?bs:ki);const Ae={colorFormat:t.RGBA8,depthFormat:le,scaleFactor:r};u=new XRWebGLBinding(s,t),h=u.createProjectionLayer(Ae),s.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),b=new Hi(h.textureWidth,h.textureHeight,{format:Ln,type:ti,depthTexture:new Ru(h.textureWidth,h.textureHeight,_e,void 0,void 0,void 0,void 0,void 0,void 0,te),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),Qe.setContext(s),Qe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function X(j){for(let te=0;te<j.removed.length;te++){const _e=j.removed[te],le=S.indexOf(_e);le>=0&&(S[le]=null,y[le].disconnect(_e))}for(let te=0;te<j.added.length;te++){const _e=j.added[te];let le=S.indexOf(_e);if(le===-1){for(let Ie=0;Ie<y.length;Ie++)if(Ie>=S.length){S.push(_e),le=Ie;break}else if(S[Ie]===null){S[Ie]=_e,le=Ie;break}if(le===-1)break}const Ae=y[le];Ae&&Ae.connect(_e)}}const B=new P,G=new P;function z(j,te,_e){B.setFromMatrixPosition(te.matrixWorld),G.setFromMatrixPosition(_e.matrixWorld);const le=B.distanceTo(G),Ae=te.projectionMatrix.elements,Ie=_e.projectionMatrix.elements,ze=Ae[14]/(Ae[10]-1),ht=Ae[14]/(Ae[10]+1),Ve=(Ae[9]+1)/Ae[5],xt=(Ae[9]-1)/Ae[5],I=(Ae[8]-1)/Ae[0],un=(Ie[8]+1)/Ie[0],ke=ze*I,He=ze*un,xe=le/(-I+un),ot=xe*-I;if(te.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(ot),j.translateZ(xe),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),Ae[10]===-1)j.projectionMatrix.copy(te.projectionMatrix),j.projectionMatrixInverse.copy(te.projectionMatrixInverse);else{const Se=ze+xe,w=ht+xe,x=ke-ot,H=He+(le-ot),$=Ve*ht/w*Se,K=xt*ht/w*Se;j.projectionMatrix.makePerspective(x,H,$,K,Se,w),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function J(j,te){te===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(te.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(s===null)return;let te=j.near,_e=j.far;_.texture!==null&&(_.depthNear>0&&(te=_.depthNear),_.depthFar>0&&(_e=_.depthFar)),v.near=R.near=D.near=te,v.far=R.far=D.far=_e,(A!==v.near||O!==v.far)&&(s.updateRenderState({depthNear:v.near,depthFar:v.far}),A=v.near,O=v.far),D.layers.mask=j.layers.mask|2,R.layers.mask=j.layers.mask|4,v.layers.mask=D.layers.mask|R.layers.mask;const le=j.parent,Ae=v.cameras;J(v,le);for(let Ie=0;Ie<Ae.length;Ie++)J(Ae[Ie],le);Ae.length===2?z(v,D,R):v.projectionMatrix.copy(D.projectionMatrix),se(j,v,le)};function se(j,te,_e){_e===null?j.matrix.copy(te.matrixWorld):(j.matrix.copy(_e.matrixWorld),j.matrix.invert(),j.matrix.multiply(te.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(te.projectionMatrix),j.projectionMatrixInverse.copy(te.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=Js*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return v},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function(j){l=j,h!==null&&(h.fixedFoveation=j),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=j)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(v)};let ae=null;function Ce(j,te){if(d=te.getViewerPose(c||o),g=te,d!==null){const _e=d.views;f!==null&&(e.setRenderTargetFramebuffer(b,f.framebuffer),e.setRenderTarget(b));let le=!1;_e.length!==v.cameras.length&&(v.cameras.length=0,le=!0);for(let Ie=0;Ie<_e.length;Ie++){const ze=_e[Ie];let ht=null;if(f!==null)ht=f.getViewport(ze);else{const xt=u.getViewSubImage(h,ze);ht=xt.viewport,Ie===0&&(e.setRenderTargetTextures(b,xt.colorTexture,h.ignoreDepthValues?void 0:xt.depthStencilTexture),e.setRenderTarget(b))}let Ve=E[Ie];Ve===void 0&&(Ve=new vn,Ve.layers.enable(Ie),Ve.viewport=new rt,E[Ie]=Ve),Ve.matrix.fromArray(ze.transform.matrix),Ve.matrix.decompose(Ve.position,Ve.quaternion,Ve.scale),Ve.projectionMatrix.fromArray(ze.projectionMatrix),Ve.projectionMatrixInverse.copy(Ve.projectionMatrix).invert(),Ve.viewport.set(ht.x,ht.y,ht.width,ht.height),Ie===0&&(v.matrix.copy(Ve.matrix),v.matrix.decompose(v.position,v.quaternion,v.scale)),le===!0&&v.cameras.push(Ve)}const Ae=s.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")){const Ie=u.getDepthInformation(_e[0]);Ie&&Ie.isValid&&Ie.texture&&_.init(e,Ie,s.renderState)}}for(let _e=0;_e<y.length;_e++){const le=S[_e],Ae=y[_e];le!==null&&Ae!==void 0&&Ae.update(le,te,c||o)}ae&&ae(j,te),te.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:te}),g=null}const Qe=new Iu;Qe.setAnimationLoop(Ce),this.setAnimationLoop=function(j){ae=j},this.dispose=function(){}}}const Pi=new ni,Dx=new pt;function Lx(n,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function i(m,p){p.color.getRGB(m.fogColor.value,bu(n)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,b,y,S){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(m,p):p.isMeshToonMaterial?(r(m,p),u(m,p)):p.isMeshPhongMaterial?(r(m,p),d(m,p)):p.isMeshStandardMaterial?(r(m,p),h(m,p),p.isMeshPhysicalMaterial&&f(m,p,S)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),_(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?l(m,p,b,y):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===en&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===en&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const b=e.get(p),y=b.envMap,S=b.envMapRotation;y&&(m.envMap.value=y,Pi.copy(S),Pi.x*=-1,Pi.y*=-1,Pi.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Pi.y*=-1,Pi.z*=-1),m.envMapRotation.value.setFromMatrix4(Dx.makeRotationFromEuler(Pi)),m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,b,y){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=y*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function d(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function h(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,b){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===en&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function _(m,p){const b=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Ix(n,e,t,i){let s={},r={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(b,y){const S=y.program;i.uniformBlockBinding(b,S)}function c(b,y){let S=s[b.id];S===void 0&&(g(b),S=d(b),s[b.id]=S,b.addEventListener("dispose",m));const C=y.program;i.updateUBOMapping(b,C);const T=e.render.frame;r[b.id]!==T&&(h(b),r[b.id]=T)}function d(b){const y=u();b.__bindingPointIndex=y;const S=n.createBuffer(),C=b.__size,T=b.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,C,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,y,S),S}function u(){for(let b=0;b<a;b++)if(o.indexOf(b)===-1)return o.push(b),b;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(b){const y=s[b.id],S=b.uniforms,C=b.__cache;n.bindBuffer(n.UNIFORM_BUFFER,y);for(let T=0,D=S.length;T<D;T++){const R=Array.isArray(S[T])?S[T]:[S[T]];for(let E=0,v=R.length;E<v;E++){const A=R[E];if(f(A,T,E,C)===!0){const O=A.__offset,L=Array.isArray(A.value)?A.value:[A.value];let k=0;for(let X=0;X<L.length;X++){const B=L[X],G=_(B);typeof B=="number"||typeof B=="boolean"?(A.__data[0]=B,n.bufferSubData(n.UNIFORM_BUFFER,O+k,A.__data)):B.isMatrix3?(A.__data[0]=B.elements[0],A.__data[1]=B.elements[1],A.__data[2]=B.elements[2],A.__data[3]=0,A.__data[4]=B.elements[3],A.__data[5]=B.elements[4],A.__data[6]=B.elements[5],A.__data[7]=0,A.__data[8]=B.elements[6],A.__data[9]=B.elements[7],A.__data[10]=B.elements[8],A.__data[11]=0):(B.toArray(A.__data,k),k+=G.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,O,A.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(b,y,S,C){const T=b.value,D=y+"_"+S;if(C[D]===void 0)return typeof T=="number"||typeof T=="boolean"?C[D]=T:C[D]=T.clone(),!0;{const R=C[D];if(typeof T=="number"||typeof T=="boolean"){if(R!==T)return C[D]=T,!0}else if(R.equals(T)===!1)return R.copy(T),!0}return!1}function g(b){const y=b.uniforms;let S=0;const C=16;for(let D=0,R=y.length;D<R;D++){const E=Array.isArray(y[D])?y[D]:[y[D]];for(let v=0,A=E.length;v<A;v++){const O=E[v],L=Array.isArray(O.value)?O.value:[O.value];for(let k=0,X=L.length;k<X;k++){const B=L[k],G=_(B),z=S%C,J=z%G.boundary,se=z+J;S+=J,se!==0&&C-se<G.storage&&(S+=C-se),O.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=S,S+=G.storage}}}const T=S%C;return T>0&&(S+=C-T),b.__size=S,b.__cache={},this}function _(b){const y={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(y.boundary=4,y.storage=4):b.isVector2?(y.boundary=8,y.storage=8):b.isVector3||b.isColor?(y.boundary=16,y.storage=12):b.isVector4?(y.boundary=16,y.storage=16):b.isMatrix3?(y.boundary=48,y.storage=48):b.isMatrix4?(y.boundary=64,y.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),y}function m(b){const y=b.target;y.removeEventListener("dispose",m);const S=o.indexOf(y.__bindingPointIndex);o.splice(S,1),n.deleteBuffer(s[y.id]),delete s[y.id],delete r[y.id]}function p(){for(const b in s)n.deleteBuffer(s[b]);o=[],s={},r={}}return{bind:l,update:c,dispose:p}}class Ux{constructor(e={}){const{canvas:t=lm(),context:i=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:h=!1}=e;this.isWebGLRenderer=!0;let f;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=i.getContextAttributes().alpha}else f=o;const g=new Uint32Array(4),_=new Int32Array(4);let m=null,p=null;const b=[],y=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Pt,this.toneMapping=yi,this.toneMappingExposure=1;const S=this;let C=!1,T=0,D=0,R=null,E=-1,v=null;const A=new rt,O=new rt;let L=null;const k=new Ze(0);let X=0,B=t.width,G=t.height,z=1,J=null,se=null;const ae=new rt(0,0,B,G),Ce=new rt(0,0,B,G);let Qe=!1;const j=new Au;let te=!1,_e=!1;const le=new pt,Ae=new pt,Ie=new P,ze=new rt,ht={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ve=!1;function xt(){return R===null?z:1}let I=i;function un(M,N){return t.getContext(M,N)}try{const M={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ul}`),t.addEventListener("webglcontextlost",Z,!1),t.addEventListener("webglcontextrestored",ue,!1),t.addEventListener("webglcontextcreationerror",de,!1),I===null){const N="webgl2";if(I=un(N,M),I===null)throw un(N)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(M){throw console.error("THREE.WebGLRenderer: "+M.message),M}let ke,He,xe,ot,Se,w,x,H,$,K,q,ve,ce,fe,We,ee,pe,Ee,Re,me,Ge,Oe,st,U;function re(){ke=new Vv(I),ke.init(),Oe=new wx(I,ke),He=new Fv(I,ke,e,Oe),xe=new Ex(I,ke),He.reverseDepthBuffer&&h&&xe.buffers.depth.setReversed(!0),ot=new Yv(I),Se=new dx,w=new bx(I,ke,xe,Se,He,Oe,ot),x=new zv(S),H=new Gv(S),$=new Qm(I),st=new Nv(I,$),K=new Wv(I,$,ot,st),q=new jv(I,K,$,ot),Re=new qv(I,He,w),ee=new Bv(Se),ve=new cx(S,x,H,ke,He,st,ee),ce=new Lx(S,Se),fe=new hx,We=new vx(ke),Ee=new Uv(S,x,H,xe,q,f,l),pe=new yx(S,q,He),U=new Ix(I,ot,He,xe),me=new Ov(I,ke,ot),Ge=new Xv(I,ke,ot),ot.programs=ve.programs,S.capabilities=He,S.extensions=ke,S.properties=Se,S.renderLists=fe,S.shadowMap=pe,S.state=xe,S.info=ot}re();const Y=new Px(S,I);this.xr=Y,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const M=ke.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=ke.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return z},this.setPixelRatio=function(M){M!==void 0&&(z=M,this.setSize(B,G,!1))},this.getSize=function(M){return M.set(B,G)},this.setSize=function(M,N,V=!0){if(Y.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=M,G=N,t.width=Math.floor(M*z),t.height=Math.floor(N*z),V===!0&&(t.style.width=M+"px",t.style.height=N+"px"),this.setViewport(0,0,M,N)},this.getDrawingBufferSize=function(M){return M.set(B*z,G*z).floor()},this.setDrawingBufferSize=function(M,N,V){B=M,G=N,z=V,t.width=Math.floor(M*V),t.height=Math.floor(N*V),this.setViewport(0,0,M,N)},this.getCurrentViewport=function(M){return M.copy(A)},this.getViewport=function(M){return M.copy(ae)},this.setViewport=function(M,N,V,W){M.isVector4?ae.set(M.x,M.y,M.z,M.w):ae.set(M,N,V,W),xe.viewport(A.copy(ae).multiplyScalar(z).round())},this.getScissor=function(M){return M.copy(Ce)},this.setScissor=function(M,N,V,W){M.isVector4?Ce.set(M.x,M.y,M.z,M.w):Ce.set(M,N,V,W),xe.scissor(O.copy(Ce).multiplyScalar(z).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(M){xe.setScissorTest(Qe=M)},this.setOpaqueSort=function(M){J=M},this.setTransparentSort=function(M){se=M},this.getClearColor=function(M){return M.copy(Ee.getClearColor())},this.setClearColor=function(){Ee.setClearColor.apply(Ee,arguments)},this.getClearAlpha=function(){return Ee.getClearAlpha()},this.setClearAlpha=function(){Ee.setClearAlpha.apply(Ee,arguments)},this.clear=function(M=!0,N=!0,V=!0){let W=0;if(M){let F=!1;if(R!==null){const Q=R.texture.format;F=Q===kl||Q===zl||Q===Bl}if(F){const Q=R.texture.type,oe=Q===ti||Q===ki||Q===Ks||Q===bs||Q===Ol||Q===Fl,he=Ee.getClearColor(),ge=Ee.getClearAlpha(),Pe=he.r,De=he.g,ye=he.b;oe?(g[0]=Pe,g[1]=De,g[2]=ye,g[3]=ge,I.clearBufferuiv(I.COLOR,0,g)):(_[0]=Pe,_[1]=De,_[2]=ye,_[3]=ge,I.clearBufferiv(I.COLOR,0,_))}else W|=I.COLOR_BUFFER_BIT}N&&(W|=I.DEPTH_BUFFER_BIT),V&&(W|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(W)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Z,!1),t.removeEventListener("webglcontextrestored",ue,!1),t.removeEventListener("webglcontextcreationerror",de,!1),Ee.dispose(),fe.dispose(),We.dispose(),Se.dispose(),x.dispose(),H.dispose(),q.dispose(),st.dispose(),U.dispose(),ve.dispose(),Y.dispose(),Y.removeEventListener("sessionstart",Jl),Y.removeEventListener("sessionend",Ql),Ei.stop()};function Z(M){M.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),C=!0}function ue(){console.log("THREE.WebGLRenderer: Context Restored."),C=!1;const M=ot.autoReset,N=pe.enabled,V=pe.autoUpdate,W=pe.needsUpdate,F=pe.type;re(),ot.autoReset=M,pe.enabled=N,pe.autoUpdate=V,pe.needsUpdate=W,pe.type=F}function de(M){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function Ue(M){const N=M.target;N.removeEventListener("dispose",Ue),mt(N)}function mt(M){Ot(M),Se.remove(M)}function Ot(M){const N=Se.get(M).programs;N!==void 0&&(N.forEach(function(V){ve.releaseProgram(V)}),M.isShaderMaterial&&ve.releaseShaderCache(M))}this.renderBufferDirect=function(M,N,V,W,F,Q){N===null&&(N=ht);const oe=F.isMesh&&F.matrixWorld.determinant()<0,he=uh(M,N,V,W,F);xe.setMaterial(W,oe);let ge=V.index,Pe=1;if(W.wireframe===!0){if(ge=K.getWireframeAttribute(V),ge===void 0)return;Pe=2}const De=V.drawRange,ye=V.attributes.position;let Xe=De.start*Pe,Ke=(De.start+De.count)*Pe;Q!==null&&(Xe=Math.max(Xe,Q.start*Pe),Ke=Math.min(Ke,(Q.start+Q.count)*Pe)),ge!==null?(Xe=Math.max(Xe,0),Ke=Math.min(Ke,ge.count)):ye!=null&&(Xe=Math.max(Xe,0),Ke=Math.min(Ke,ye.count));const St=Ke-Xe;if(St<0||St===1/0)return;st.setup(F,W,he,V,ge);let gt,qe=me;if(ge!==null&&(gt=$.get(ge),qe=Ge,qe.setIndex(gt)),F.isMesh)W.wireframe===!0?(xe.setLineWidth(W.wireframeLinewidth*xt()),qe.setMode(I.LINES)):qe.setMode(I.TRIANGLES);else if(F.isLine){let Me=W.linewidth;Me===void 0&&(Me=1),xe.setLineWidth(Me*xt()),F.isLineSegments?qe.setMode(I.LINES):F.isLineLoop?qe.setMode(I.LINE_LOOP):qe.setMode(I.LINE_STRIP)}else F.isPoints?qe.setMode(I.POINTS):F.isSprite&&qe.setMode(I.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)qe.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(ke.get("WEBGL_multi_draw"))qe.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Me=F._multiDrawStarts,Dt=F._multiDrawCounts,Je=F._multiDrawCount,En=ge?$.get(ge).bytesPerElement:1,Xi=Se.get(W).currentProgram.getUniforms();for(let nn=0;nn<Je;nn++)Xi.setValue(I,"_gl_DrawID",nn),qe.render(Me[nn]/En,Dt[nn])}else if(F.isInstancedMesh)qe.renderInstances(Xe,St,F.count);else if(V.isInstancedBufferGeometry){const Me=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,Dt=Math.min(V.instanceCount,Me);qe.renderInstances(Xe,St,Dt)}else qe.render(Xe,St)};function et(M,N,V){M.transparent===!0&&M.side===jn&&M.forceSinglePass===!1?(M.side=en,M.needsUpdate=!0,ar(M,N,V),M.side=Mi,M.needsUpdate=!0,ar(M,N,V),M.side=jn):ar(M,N,V)}this.compile=function(M,N,V=null){V===null&&(V=M),p=We.get(V),p.init(N),y.push(p),V.traverseVisible(function(F){F.isLight&&F.layers.test(N.layers)&&(p.pushLight(F),F.castShadow&&p.pushShadow(F))}),M!==V&&M.traverseVisible(function(F){F.isLight&&F.layers.test(N.layers)&&(p.pushLight(F),F.castShadow&&p.pushShadow(F))}),p.setupLights();const W=new Set;return M.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const Q=F.material;if(Q)if(Array.isArray(Q))for(let oe=0;oe<Q.length;oe++){const he=Q[oe];et(he,V,F),W.add(he)}else et(Q,V,F),W.add(Q)}),y.pop(),p=null,W},this.compileAsync=function(M,N,V=null){const W=this.compile(M,N,V);return new Promise(F=>{function Q(){if(W.forEach(function(oe){Se.get(oe).currentProgram.isReady()&&W.delete(oe)}),W.size===0){F(M);return}setTimeout(Q,10)}ke.get("KHR_parallel_shader_compile")!==null?Q():setTimeout(Q,10)})};let Mn=null;function Hn(M){Mn&&Mn(M)}function Jl(){Ei.stop()}function Ql(){Ei.start()}const Ei=new Iu;Ei.setAnimationLoop(Hn),typeof self<"u"&&Ei.setContext(self),this.setAnimationLoop=function(M){Mn=M,Y.setAnimationLoop(M),M===null?Ei.stop():Ei.start()},Y.addEventListener("sessionstart",Jl),Y.addEventListener("sessionend",Ql),this.render=function(M,N){if(N!==void 0&&N.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),Y.enabled===!0&&Y.isPresenting===!0&&(Y.cameraAutoUpdate===!0&&Y.updateCamera(N),N=Y.getCamera()),M.isScene===!0&&M.onBeforeRender(S,M,N,R),p=We.get(M,y.length),p.init(N),y.push(p),Ae.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),j.setFromProjectionMatrix(Ae),_e=this.localClippingEnabled,te=ee.init(this.clippingPlanes,_e),m=fe.get(M,b.length),m.init(),b.push(m),Y.enabled===!0&&Y.isPresenting===!0){const Q=S.xr.getDepthSensingMesh();Q!==null&&Co(Q,N,-1/0,S.sortObjects)}Co(M,N,0,S.sortObjects),m.finish(),S.sortObjects===!0&&m.sort(J,se),Ve=Y.enabled===!1||Y.isPresenting===!1||Y.hasDepthSensing()===!1,Ve&&Ee.addToRenderList(m,M),this.info.render.frame++,te===!0&&ee.beginShadows();const V=p.state.shadowsArray;pe.render(V,M,N),te===!0&&ee.endShadows(),this.info.autoReset===!0&&this.info.reset();const W=m.opaque,F=m.transmissive;if(p.setupLights(),N.isArrayCamera){const Q=N.cameras;if(F.length>0)for(let oe=0,he=Q.length;oe<he;oe++){const ge=Q[oe];tc(W,F,M,ge)}Ve&&Ee.render(M);for(let oe=0,he=Q.length;oe<he;oe++){const ge=Q[oe];ec(m,M,ge,ge.viewport)}}else F.length>0&&tc(W,F,M,N),Ve&&Ee.render(M),ec(m,M,N);R!==null&&(w.updateMultisampleRenderTarget(R),w.updateRenderTargetMipmap(R)),M.isScene===!0&&M.onAfterRender(S,M,N),st.resetDefaultState(),E=-1,v=null,y.pop(),y.length>0?(p=y[y.length-1],te===!0&&ee.setGlobalState(S.clippingPlanes,p.state.camera)):p=null,b.pop(),b.length>0?m=b[b.length-1]:m=null};function Co(M,N,V,W){if(M.visible===!1)return;if(M.layers.test(N.layers)){if(M.isGroup)V=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(N);else if(M.isLight)p.pushLight(M),M.castShadow&&p.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||j.intersectsSprite(M)){W&&ze.setFromMatrixPosition(M.matrixWorld).applyMatrix4(Ae);const oe=q.update(M),he=M.material;he.visible&&m.push(M,oe,he,V,ze.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||j.intersectsObject(M))){const oe=q.update(M),he=M.material;if(W&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),ze.copy(M.boundingSphere.center)):(oe.boundingSphere===null&&oe.computeBoundingSphere(),ze.copy(oe.boundingSphere.center)),ze.applyMatrix4(M.matrixWorld).applyMatrix4(Ae)),Array.isArray(he)){const ge=oe.groups;for(let Pe=0,De=ge.length;Pe<De;Pe++){const ye=ge[Pe],Xe=he[ye.materialIndex];Xe&&Xe.visible&&m.push(M,oe,Xe,V,ze.z,ye)}}else he.visible&&m.push(M,oe,he,V,ze.z,null)}}const Q=M.children;for(let oe=0,he=Q.length;oe<he;oe++)Co(Q[oe],N,V,W)}function ec(M,N,V,W){const F=M.opaque,Q=M.transmissive,oe=M.transparent;p.setupLightsView(V),te===!0&&ee.setGlobalState(S.clippingPlanes,V),W&&xe.viewport(A.copy(W)),F.length>0&&or(F,N,V),Q.length>0&&or(Q,N,V),oe.length>0&&or(oe,N,V),xe.buffers.depth.setTest(!0),xe.buffers.depth.setMask(!0),xe.buffers.color.setMask(!0),xe.setPolygonOffset(!1)}function tc(M,N,V,W){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[W.id]===void 0&&(p.state.transmissionRenderTarget[W.id]=new Hi(1,1,{generateMipmaps:!0,type:ke.has("EXT_color_buffer_half_float")||ke.has("EXT_color_buffer_float")?er:ti,minFilter:Bi,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:je.workingColorSpace}));const Q=p.state.transmissionRenderTarget[W.id],oe=W.viewport||A;Q.setSize(oe.z,oe.w);const he=S.getRenderTarget();S.setRenderTarget(Q),S.getClearColor(k),X=S.getClearAlpha(),X<1&&S.setClearColor(16777215,.5),S.clear(),Ve&&Ee.render(V);const ge=S.toneMapping;S.toneMapping=yi;const Pe=W.viewport;if(W.viewport!==void 0&&(W.viewport=void 0),p.setupLightsView(W),te===!0&&ee.setGlobalState(S.clippingPlanes,W),or(M,V,W),w.updateMultisampleRenderTarget(Q),w.updateRenderTargetMipmap(Q),ke.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let ye=0,Xe=N.length;ye<Xe;ye++){const Ke=N[ye],St=Ke.object,gt=Ke.geometry,qe=Ke.material,Me=Ke.group;if(qe.side===jn&&St.layers.test(W.layers)){const Dt=qe.side;qe.side=en,qe.needsUpdate=!0,nc(St,V,W,gt,qe,Me),qe.side=Dt,qe.needsUpdate=!0,De=!0}}De===!0&&(w.updateMultisampleRenderTarget(Q),w.updateRenderTargetMipmap(Q))}S.setRenderTarget(he),S.setClearColor(k,X),Pe!==void 0&&(W.viewport=Pe),S.toneMapping=ge}function or(M,N,V){const W=N.isScene===!0?N.overrideMaterial:null;for(let F=0,Q=M.length;F<Q;F++){const oe=M[F],he=oe.object,ge=oe.geometry,Pe=W===null?oe.material:W,De=oe.group;he.layers.test(V.layers)&&nc(he,N,V,ge,Pe,De)}}function nc(M,N,V,W,F,Q){M.onBeforeRender(S,N,V,W,F,Q),M.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),F.onBeforeRender(S,N,V,W,M,Q),F.transparent===!0&&F.side===jn&&F.forceSinglePass===!1?(F.side=en,F.needsUpdate=!0,S.renderBufferDirect(V,N,W,F,M,Q),F.side=Mi,F.needsUpdate=!0,S.renderBufferDirect(V,N,W,F,M,Q),F.side=jn):S.renderBufferDirect(V,N,W,F,M,Q),M.onAfterRender(S,N,V,W,F,Q)}function ar(M,N,V){N.isScene!==!0&&(N=ht);const W=Se.get(M),F=p.state.lights,Q=p.state.shadowsArray,oe=F.state.version,he=ve.getParameters(M,F.state,Q,N,V),ge=ve.getProgramCacheKey(he);let Pe=W.programs;W.environment=M.isMeshStandardMaterial?N.environment:null,W.fog=N.fog,W.envMap=(M.isMeshStandardMaterial?H:x).get(M.envMap||W.environment),W.envMapRotation=W.environment!==null&&M.envMap===null?N.environmentRotation:M.envMapRotation,Pe===void 0&&(M.addEventListener("dispose",Ue),Pe=new Map,W.programs=Pe);let De=Pe.get(ge);if(De!==void 0){if(W.currentProgram===De&&W.lightsStateVersion===oe)return sc(M,he),De}else he.uniforms=ve.getUniforms(M),M.onBeforeCompile(he,S),De=ve.acquireProgram(he,ge),Pe.set(ge,De),W.uniforms=he.uniforms;const ye=W.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(ye.clippingPlanes=ee.uniform),sc(M,he),W.needsLights=fh(M),W.lightsStateVersion=oe,W.needsLights&&(ye.ambientLightColor.value=F.state.ambient,ye.lightProbe.value=F.state.probe,ye.directionalLights.value=F.state.directional,ye.directionalLightShadows.value=F.state.directionalShadow,ye.spotLights.value=F.state.spot,ye.spotLightShadows.value=F.state.spotShadow,ye.rectAreaLights.value=F.state.rectArea,ye.ltc_1.value=F.state.rectAreaLTC1,ye.ltc_2.value=F.state.rectAreaLTC2,ye.pointLights.value=F.state.point,ye.pointLightShadows.value=F.state.pointShadow,ye.hemisphereLights.value=F.state.hemi,ye.directionalShadowMap.value=F.state.directionalShadowMap,ye.directionalShadowMatrix.value=F.state.directionalShadowMatrix,ye.spotShadowMap.value=F.state.spotShadowMap,ye.spotLightMatrix.value=F.state.spotLightMatrix,ye.spotLightMap.value=F.state.spotLightMap,ye.pointShadowMap.value=F.state.pointShadowMap,ye.pointShadowMatrix.value=F.state.pointShadowMatrix),W.currentProgram=De,W.uniformsList=null,De}function ic(M){if(M.uniformsList===null){const N=M.currentProgram.getUniforms();M.uniformsList=io.seqWithValue(N.seq,M.uniforms)}return M.uniformsList}function sc(M,N){const V=Se.get(M);V.outputColorSpace=N.outputColorSpace,V.batching=N.batching,V.batchingColor=N.batchingColor,V.instancing=N.instancing,V.instancingColor=N.instancingColor,V.instancingMorph=N.instancingMorph,V.skinning=N.skinning,V.morphTargets=N.morphTargets,V.morphNormals=N.morphNormals,V.morphColors=N.morphColors,V.morphTargetsCount=N.morphTargetsCount,V.numClippingPlanes=N.numClippingPlanes,V.numIntersection=N.numClipIntersection,V.vertexAlphas=N.vertexAlphas,V.vertexTangents=N.vertexTangents,V.toneMapping=N.toneMapping}function uh(M,N,V,W,F){N.isScene!==!0&&(N=ht),w.resetTextureUnits();const Q=N.fog,oe=W.isMeshStandardMaterial?N.environment:null,he=R===null?S.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Ts,ge=(W.isMeshStandardMaterial?H:x).get(W.envMap||oe),Pe=W.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,De=!!V.attributes.tangent&&(!!W.normalMap||W.anisotropy>0),ye=!!V.morphAttributes.position,Xe=!!V.morphAttributes.normal,Ke=!!V.morphAttributes.color;let St=yi;W.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(St=S.toneMapping);const gt=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,qe=gt!==void 0?gt.length:0,Me=Se.get(W),Dt=p.state.lights;if(te===!0&&(_e===!0||M!==v)){const Ht=M===v&&W.id===E;ee.setState(W,M,Ht)}let Je=!1;W.version===Me.__version?(Me.needsLights&&Me.lightsStateVersion!==Dt.state.version||Me.outputColorSpace!==he||F.isBatchedMesh&&Me.batching===!1||!F.isBatchedMesh&&Me.batching===!0||F.isBatchedMesh&&Me.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Me.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Me.instancing===!1||!F.isInstancedMesh&&Me.instancing===!0||F.isSkinnedMesh&&Me.skinning===!1||!F.isSkinnedMesh&&Me.skinning===!0||F.isInstancedMesh&&Me.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Me.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Me.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Me.instancingMorph===!1&&F.morphTexture!==null||Me.envMap!==ge||W.fog===!0&&Me.fog!==Q||Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==ee.numPlanes||Me.numIntersection!==ee.numIntersection)||Me.vertexAlphas!==Pe||Me.vertexTangents!==De||Me.morphTargets!==ye||Me.morphNormals!==Xe||Me.morphColors!==Ke||Me.toneMapping!==St||Me.morphTargetsCount!==qe)&&(Je=!0):(Je=!0,Me.__version=W.version);let En=Me.currentProgram;Je===!0&&(En=ar(W,N,F));let Xi=!1,nn=!1,Ls=!1;const lt=En.getUniforms(),hn=Me.uniforms;if(xe.useProgram(En.program)&&(Xi=!0,nn=!0,Ls=!0),W.id!==E&&(E=W.id,nn=!0),Xi||v!==M){xe.buffers.depth.getReversed()?(le.copy(M.projectionMatrix),dm(le),um(le),lt.setValue(I,"projectionMatrix",le)):lt.setValue(I,"projectionMatrix",M.projectionMatrix),lt.setValue(I,"viewMatrix",M.matrixWorldInverse);const jt=lt.map.cameraPosition;jt!==void 0&&jt.setValue(I,Ie.setFromMatrixPosition(M.matrixWorld)),He.logarithmicDepthBuffer&&lt.setValue(I,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(W.isMeshPhongMaterial||W.isMeshToonMaterial||W.isMeshLambertMaterial||W.isMeshBasicMaterial||W.isMeshStandardMaterial||W.isShaderMaterial)&&lt.setValue(I,"isOrthographic",M.isOrthographicCamera===!0),v!==M&&(v=M,nn=!0,Ls=!0)}if(F.isSkinnedMesh){lt.setOptional(I,F,"bindMatrix"),lt.setOptional(I,F,"bindMatrixInverse");const Ht=F.skeleton;Ht&&(Ht.boneTexture===null&&Ht.computeBoneTexture(),lt.setValue(I,"boneTexture",Ht.boneTexture,w))}F.isBatchedMesh&&(lt.setOptional(I,F,"batchingTexture"),lt.setValue(I,"batchingTexture",F._matricesTexture,w),lt.setOptional(I,F,"batchingIdTexture"),lt.setValue(I,"batchingIdTexture",F._indirectTexture,w),lt.setOptional(I,F,"batchingColorTexture"),F._colorsTexture!==null&&lt.setValue(I,"batchingColorTexture",F._colorsTexture,w));const fn=V.morphAttributes;if((fn.position!==void 0||fn.normal!==void 0||fn.color!==void 0)&&Re.update(F,V,En),(nn||Me.receiveShadow!==F.receiveShadow)&&(Me.receiveShadow=F.receiveShadow,lt.setValue(I,"receiveShadow",F.receiveShadow)),W.isMeshGouraudMaterial&&W.envMap!==null&&(hn.envMap.value=ge,hn.flipEnvMap.value=ge.isCubeTexture&&ge.isRenderTargetTexture===!1?-1:1),W.isMeshStandardMaterial&&W.envMap===null&&N.environment!==null&&(hn.envMapIntensity.value=N.environmentIntensity),nn&&(lt.setValue(I,"toneMappingExposure",S.toneMappingExposure),Me.needsLights&&hh(hn,Ls),Q&&W.fog===!0&&ce.refreshFogUniforms(hn,Q),ce.refreshMaterialUniforms(hn,W,z,G,p.state.transmissionRenderTarget[M.id]),io.upload(I,ic(Me),hn,w)),W.isShaderMaterial&&W.uniformsNeedUpdate===!0&&(io.upload(I,ic(Me),hn,w),W.uniformsNeedUpdate=!1),W.isSpriteMaterial&&lt.setValue(I,"center",F.center),lt.setValue(I,"modelViewMatrix",F.modelViewMatrix),lt.setValue(I,"normalMatrix",F.normalMatrix),lt.setValue(I,"modelMatrix",F.matrixWorld),W.isShaderMaterial||W.isRawShaderMaterial){const Ht=W.uniformsGroups;for(let jt=0,Ro=Ht.length;jt<Ro;jt++){const bi=Ht[jt];U.update(bi,En),U.bind(bi,En)}}return En}function hh(M,N){M.ambientLightColor.needsUpdate=N,M.lightProbe.needsUpdate=N,M.directionalLights.needsUpdate=N,M.directionalLightShadows.needsUpdate=N,M.pointLights.needsUpdate=N,M.pointLightShadows.needsUpdate=N,M.spotLights.needsUpdate=N,M.spotLightShadows.needsUpdate=N,M.rectAreaLights.needsUpdate=N,M.hemisphereLights.needsUpdate=N}function fh(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(M,N,V){Se.get(M.texture).__webglTexture=N,Se.get(M.depthTexture).__webglTexture=V;const W=Se.get(M);W.__hasExternalTextures=!0,W.__autoAllocateDepthBuffer=V===void 0,W.__autoAllocateDepthBuffer||ke.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),W.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(M,N){const V=Se.get(M);V.__webglFramebuffer=N,V.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(M,N=0,V=0){R=M,T=N,D=V;let W=!0,F=null,Q=!1,oe=!1;if(M){const ge=Se.get(M);if(ge.__useDefaultFramebuffer!==void 0)xe.bindFramebuffer(I.FRAMEBUFFER,null),W=!1;else if(ge.__webglFramebuffer===void 0)w.setupRenderTarget(M);else if(ge.__hasExternalTextures)w.rebindTextures(M,Se.get(M.texture).__webglTexture,Se.get(M.depthTexture).__webglTexture);else if(M.depthBuffer){const ye=M.depthTexture;if(ge.__boundDepthTexture!==ye){if(ye!==null&&Se.has(ye)&&(M.width!==ye.image.width||M.height!==ye.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");w.setupDepthRenderbuffer(M)}}const Pe=M.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(oe=!0);const De=Se.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(De[N])?F=De[N][V]:F=De[N],Q=!0):M.samples>0&&w.useMultisampledRTT(M)===!1?F=Se.get(M).__webglMultisampledFramebuffer:Array.isArray(De)?F=De[V]:F=De,A.copy(M.viewport),O.copy(M.scissor),L=M.scissorTest}else A.copy(ae).multiplyScalar(z).floor(),O.copy(Ce).multiplyScalar(z).floor(),L=Qe;if(xe.bindFramebuffer(I.FRAMEBUFFER,F)&&W&&xe.drawBuffers(M,F),xe.viewport(A),xe.scissor(O),xe.setScissorTest(L),Q){const ge=Se.get(M.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+N,ge.__webglTexture,V)}else if(oe){const ge=Se.get(M.texture),Pe=N||0;I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,ge.__webglTexture,V||0,Pe)}E=-1},this.readRenderTargetPixels=function(M,N,V,W,F,Q,oe){if(!(M&&M.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let he=Se.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&oe!==void 0&&(he=he[oe]),he){xe.bindFramebuffer(I.FRAMEBUFFER,he);try{const ge=M.texture,Pe=ge.format,De=ge.type;if(!He.textureFormatReadable(Pe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!He.textureTypeReadable(De)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=M.width-W&&V>=0&&V<=M.height-F&&I.readPixels(N,V,W,F,Oe.convert(Pe),Oe.convert(De),Q)}finally{const ge=R!==null?Se.get(R).__webglFramebuffer:null;xe.bindFramebuffer(I.FRAMEBUFFER,ge)}}},this.readRenderTargetPixelsAsync=async function(M,N,V,W,F,Q,oe){if(!(M&&M.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let he=Se.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&oe!==void 0&&(he=he[oe]),he){const ge=M.texture,Pe=ge.format,De=ge.type;if(!He.textureFormatReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!He.textureTypeReadable(De))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(N>=0&&N<=M.width-W&&V>=0&&V<=M.height-F){xe.bindFramebuffer(I.FRAMEBUFFER,he);const ye=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,ye),I.bufferData(I.PIXEL_PACK_BUFFER,Q.byteLength,I.STREAM_READ),I.readPixels(N,V,W,F,Oe.convert(Pe),Oe.convert(De),0);const Xe=R!==null?Se.get(R).__webglFramebuffer:null;xe.bindFramebuffer(I.FRAMEBUFFER,Xe);const Ke=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await cm(I,Ke,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,ye),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,Q),I.deleteBuffer(ye),I.deleteSync(Ke),Q}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(M,N=null,V=0){M.isTexture!==!0&&(cs("WebGLRenderer: copyFramebufferToTexture function signature has changed."),N=arguments[0]||null,M=arguments[1]);const W=Math.pow(2,-V),F=Math.floor(M.image.width*W),Q=Math.floor(M.image.height*W),oe=N!==null?N.x:0,he=N!==null?N.y:0;w.setTexture2D(M,0),I.copyTexSubImage2D(I.TEXTURE_2D,V,0,0,oe,he,F,Q),xe.unbindTexture()};const ph=I.createFramebuffer(),mh=I.createFramebuffer();this.copyTextureToTexture=function(M,N,V=null,W=null,F=0,Q=null){M.isTexture!==!0&&(cs("WebGLRenderer: copyTextureToTexture function signature has changed."),W=arguments[0]||null,M=arguments[1],N=arguments[2],Q=arguments[3]||0,V=null),Q===null&&(F!==0?(cs("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Q=F,F=0):Q=0);let oe,he,ge,Pe,De,ye,Xe,Ke,St;const gt=M.isCompressedTexture?M.mipmaps[Q]:M.image;if(V!==null)oe=V.max.x-V.min.x,he=V.max.y-V.min.y,ge=V.isBox3?V.max.z-V.min.z:1,Pe=V.min.x,De=V.min.y,ye=V.isBox3?V.min.z:0;else{const fn=Math.pow(2,-F);oe=Math.floor(gt.width*fn),he=Math.floor(gt.height*fn),M.isDataArrayTexture?ge=gt.depth:M.isData3DTexture?ge=Math.floor(gt.depth*fn):ge=1,Pe=0,De=0,ye=0}W!==null?(Xe=W.x,Ke=W.y,St=W.z):(Xe=0,Ke=0,St=0);const qe=Oe.convert(N.format),Me=Oe.convert(N.type);let Dt;N.isData3DTexture?(w.setTexture3D(N,0),Dt=I.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(w.setTexture2DArray(N,0),Dt=I.TEXTURE_2D_ARRAY):(w.setTexture2D(N,0),Dt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,N.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,N.unpackAlignment);const Je=I.getParameter(I.UNPACK_ROW_LENGTH),En=I.getParameter(I.UNPACK_IMAGE_HEIGHT),Xi=I.getParameter(I.UNPACK_SKIP_PIXELS),nn=I.getParameter(I.UNPACK_SKIP_ROWS),Ls=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,gt.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,gt.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Pe),I.pixelStorei(I.UNPACK_SKIP_ROWS,De),I.pixelStorei(I.UNPACK_SKIP_IMAGES,ye);const lt=M.isDataArrayTexture||M.isData3DTexture,hn=N.isDataArrayTexture||N.isData3DTexture;if(M.isDepthTexture){const fn=Se.get(M),Ht=Se.get(N),jt=Se.get(fn.__renderTarget),Ro=Se.get(Ht.__renderTarget);xe.bindFramebuffer(I.READ_FRAMEBUFFER,jt.__webglFramebuffer),xe.bindFramebuffer(I.DRAW_FRAMEBUFFER,Ro.__webglFramebuffer);for(let bi=0;bi<ge;bi++)lt&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Se.get(M).__webglTexture,F,ye+bi),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Se.get(N).__webglTexture,Q,St+bi)),I.blitFramebuffer(Pe,De,oe,he,Xe,Ke,oe,he,I.DEPTH_BUFFER_BIT,I.NEAREST);xe.bindFramebuffer(I.READ_FRAMEBUFFER,null),xe.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(F!==0||M.isRenderTargetTexture||Se.has(M)){const fn=Se.get(M),Ht=Se.get(N);xe.bindFramebuffer(I.READ_FRAMEBUFFER,ph),xe.bindFramebuffer(I.DRAW_FRAMEBUFFER,mh);for(let jt=0;jt<ge;jt++)lt?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,fn.__webglTexture,F,ye+jt):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,fn.__webglTexture,F),hn?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Ht.__webglTexture,Q,St+jt):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Ht.__webglTexture,Q),F!==0?I.blitFramebuffer(Pe,De,oe,he,Xe,Ke,oe,he,I.COLOR_BUFFER_BIT,I.NEAREST):hn?I.copyTexSubImage3D(Dt,Q,Xe,Ke,St+jt,Pe,De,oe,he):I.copyTexSubImage2D(Dt,Q,Xe,Ke,Pe,De,oe,he);xe.bindFramebuffer(I.READ_FRAMEBUFFER,null),xe.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else hn?M.isDataTexture||M.isData3DTexture?I.texSubImage3D(Dt,Q,Xe,Ke,St,oe,he,ge,qe,Me,gt.data):N.isCompressedArrayTexture?I.compressedTexSubImage3D(Dt,Q,Xe,Ke,St,oe,he,ge,qe,gt.data):I.texSubImage3D(Dt,Q,Xe,Ke,St,oe,he,ge,qe,Me,gt):M.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,Q,Xe,Ke,oe,he,qe,Me,gt.data):M.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,Q,Xe,Ke,gt.width,gt.height,qe,gt.data):I.texSubImage2D(I.TEXTURE_2D,Q,Xe,Ke,oe,he,qe,Me,gt);I.pixelStorei(I.UNPACK_ROW_LENGTH,Je),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,En),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Xi),I.pixelStorei(I.UNPACK_SKIP_ROWS,nn),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Ls),Q===0&&N.generateMipmaps&&I.generateMipmap(Dt),xe.unbindTexture()},this.copyTextureToTexture3D=function(M,N,V=null,W=null,F=0){return M.isTexture!==!0&&(cs("WebGLRenderer: copyTextureToTexture3D function signature has changed."),V=arguments[0]||null,W=arguments[1]||null,M=arguments[2],N=arguments[3],F=arguments[4]||0),cs('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(M,N,V,W,F)},this.initRenderTarget=function(M){Se.get(M).__webglFramebuffer===void 0&&w.setupRenderTarget(M)},this.initTexture=function(M){M.isCubeTexture?w.setTextureCube(M,0):M.isData3DTexture?w.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?w.setTexture2DArray(M,0):w.setTexture2D(M,0),xe.unbindTexture()},this.resetState=function(){T=0,D=0,R=null,xe.reset(),st.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Kn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorspace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}var Ws=function(){var n=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(d){d.preventDefault(),i(++n%e.children.length)},!1);function t(d){return e.appendChild(d.dom),d}function i(d){for(var u=0;u<e.children.length;u++)e.children[u].style.display=u===d?"block":"none";n=d}var s=(performance||Date).now(),r=s,o=0,a=t(new Ws.Panel("FPS","#0ff","#002")),l=t(new Ws.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=t(new Ws.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:e,addPanel:t,showPanel:i,begin:function(){s=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(l.update(d-s,200),d>=r+1e3&&(a.update(o*1e3/(d-r),100),r=d,o=0,c)){var u=performance.memory;c.update(u.usedJSHeapSize/1048576,u.jsHeapSizeLimit/1048576)}return d},update:function(){s=this.end()},domElement:e,setMode:i}};Ws.Panel=function(n,e,t){var i=1/0,s=0,r=Math.round,o=r(window.devicePixelRatio||1),a=80*o,l=48*o,c=3*o,d=2*o,u=3*o,h=15*o,f=74*o,g=30*o,_=document.createElement("canvas");_.width=a,_.height=l,_.style.cssText="width:80px;height:48px";var m=_.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=t,m.fillRect(0,0,a,l),m.fillStyle=e,m.fillText(n,c,d),m.fillRect(u,h,f,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(u,h,f,g),{dom:_,update:function(p,b){i=Math.min(i,p),s=Math.max(s,p),m.fillStyle=t,m.globalAlpha=1,m.fillRect(0,0,a,h),m.fillStyle=e,m.fillText(r(p)+" "+n+" ("+r(i)+"-"+r(s)+")",c,d),m.drawImage(_,u+o,h,f-o,g,u,h,f-o,g),m.fillRect(u+f-o,h,o,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(u+f-o,h,o,r((1-p/b)*g))}}};const Nx=Ws,yd={type:"change"},ql={type:"start"},Bu={type:"end"},Fr=new bo,Md=new hi,Ox=Math.cos(70*_u.DEG2RAD),wt=new P,$t=2*Math.PI,it={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ma=1e-6;class Fx extends Km{constructor(e,t=null){super(e,t),this.state=it.NONE,this.enabled=!0,this.target=new P,this.cursor=new P,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Xt.ROTATE,MIDDLE:Xt.DOLLY,RIGHT:Xt.PAN},this.touches={ONE:us.ROTATE,TWO:us.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new P,this._lastQuaternion=new Gi,this._lastTargetPosition=new P,this._quat=new Gi().setFromUnitVectors(e.up,new P(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new jc,this._sphericalDelta=new jc,this._scale=1,this._panOffset=new P,this._rotateStart=new Te,this._rotateEnd=new Te,this._rotateDelta=new Te,this._panStart=new Te,this._panEnd=new Te,this._panDelta=new Te,this._dollyStart=new Te,this._dollyEnd=new Te,this._dollyDelta=new Te,this._dollyDirection=new P,this._mouse=new Te,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=zx.bind(this),this._onPointerDown=Bx.bind(this),this._onPointerUp=kx.bind(this),this._onContextMenu=qx.bind(this),this._onMouseWheel=Vx.bind(this),this._onKeyDown=Wx.bind(this),this._onTouchStart=Xx.bind(this),this._onTouchMove=Yx.bind(this),this._onMouseDown=Hx.bind(this),this._onMouseMove=Gx.bind(this),this._interceptControlDown=jx.bind(this),this._interceptControlUp=$x.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(yd),this.update(),this.state=it.NONE}update(e=null){const t=this.object.position;wt.copy(t).sub(this.target),wt.applyQuaternion(this._quat),this._spherical.setFromVector3(wt),this.autoRotate&&this.state===it.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=$t:i>Math.PI&&(i-=$t),s<-Math.PI?s+=$t:s>Math.PI&&(s-=$t),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(wt.setFromSpherical(this._spherical),wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(wt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=wt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new P(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new P(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=wt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Fr.origin.copy(this.object.position),Fr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Fr.direction))<Ox?this.object.lookAt(this.target):(Md.setFromNormalAndCoplanarPoint(this.object.up,this.target),Fr.intersectPlane(Md,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>ma||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ma||this._lastTargetPosition.distanceToSquared(this.target)>ma?(this.dispatchEvent(yd),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?$t/60*this.autoRotateSpeed*e:$t/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){wt.setFromMatrixColumn(t,0),wt.multiplyScalar(-e),this._panOffset.add(wt)}_panUp(e,t){this.screenSpacePanning===!0?wt.setFromMatrixColumn(t,1):(wt.setFromMatrixColumn(t,0),wt.crossVectors(this.object.up,wt)),wt.multiplyScalar(e),this._panOffset.add(wt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;wt.copy(s).sub(this.target);let r=wt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,o=i.width,a=i.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft($t*this._rotateDelta.x/t.clientHeight),this._rotateUp($t*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp($t*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-$t*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft($t*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-$t*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft($t*this._rotateDelta.x/t.clientHeight),this._rotateUp($t*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Te,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function Bx(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function zx(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function kx(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Bu),this.state=it.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Hx(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Xt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=it.DOLLY;break;case Xt.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=it.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=it.ROTATE}break;case Xt.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=it.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=it.PAN}break;default:this.state=it.NONE}this.state!==it.NONE&&this.dispatchEvent(ql)}function Gx(n){switch(this.state){case it.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case it.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case it.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function Vx(n){this.enabled===!1||this.enableZoom===!1||this.state!==it.NONE||(n.preventDefault(),this.dispatchEvent(ql),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(Bu))}function Wx(n){this.enabled!==!1&&this._handleKeyDown(n)}function Xx(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case us.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=it.TOUCH_ROTATE;break;case us.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=it.TOUCH_PAN;break;default:this.state=it.NONE}break;case 2:switch(this.touches.TWO){case us.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=it.TOUCH_DOLLY_PAN;break;case us.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=it.TOUCH_DOLLY_ROTATE;break;default:this.state=it.NONE}break;default:this.state=it.NONE}this.state!==it.NONE&&this.dispatchEvent(ql)}function Yx(n){switch(this._trackPointer(n),this.state){case it.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case it.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case it.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case it.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=it.NONE}}function qx(n){this.enabled!==!1&&n.preventDefault()}function jx(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function $x(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ed=new Sn,Br=new P;class zu extends qm{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],i=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(i),this.setAttribute("position",new kt(e,3)),this.setAttribute("uv",new kt(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),i.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new El(t,6,1);return this.setAttribute("instanceStart",new _i(i,3,0)),this.setAttribute("instanceEnd",new _i(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const i=new El(t,6,1);return this.setAttribute("instanceColorStart",new _i(i,3,0)),this.setAttribute("instanceColorEnd",new _i(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new km(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Sn);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Ed.setFromBufferAttribute(t),this.boundingBox.union(Ed))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ps),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let s=0;for(let r=0,o=e.count;r<o;r++)Br.fromBufferAttribute(e,r),s=Math.max(s,i.distanceToSquared(Br)),Br.fromBufferAttribute(t,r),s=Math.max(s,i.distanceToSquared(Br));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}ie.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Te(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};Qt.line={uniforms:Vl.merge([ie.common,ie.fog,ie.line]),vertexShader:`
  3734. #include <common>
  3735. #include <color_pars_vertex>
  3736. #include <fog_pars_vertex>
  3737. #include <logdepthbuf_pars_vertex>
  3738. #include <clipping_planes_pars_vertex>
  3739. uniform float linewidth;
  3740. uniform vec2 resolution;
  3741. attribute vec3 instanceStart;
  3742. attribute vec3 instanceEnd;
  3743. attribute vec3 instanceColorStart;
  3744. attribute vec3 instanceColorEnd;
  3745. #ifdef WORLD_UNITS
  3746. varying vec4 worldPos;
  3747. varying vec3 worldStart;
  3748. varying vec3 worldEnd;
  3749. #ifdef USE_DASH
  3750. varying vec2 vUv;
  3751. #endif
  3752. #else
  3753. varying vec2 vUv;
  3754. #endif
  3755. #ifdef USE_DASH
  3756. uniform float dashScale;
  3757. attribute float instanceDistanceStart;
  3758. attribute float instanceDistanceEnd;
  3759. varying float vLineDistance;
  3760. #endif
  3761. void trimSegment( const in vec4 start, inout vec4 end ) {
  3762. // trim end segment so it terminates between the camera plane and the near plane
  3763. // conservative estimate of the near plane
  3764. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  3765. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  3766. float nearEstimate = - 0.5 * b / a;
  3767. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  3768. end.xyz = mix( start.xyz, end.xyz, alpha );
  3769. }
  3770. void main() {
  3771. #ifdef USE_COLOR
  3772. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  3773. #endif
  3774. #ifdef USE_DASH
  3775. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  3776. vUv = uv;
  3777. #endif
  3778. float aspect = resolution.x / resolution.y;
  3779. // camera space
  3780. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  3781. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  3782. #ifdef WORLD_UNITS
  3783. worldStart = start.xyz;
  3784. worldEnd = end.xyz;
  3785. #else
  3786. vUv = uv;
  3787. #endif
  3788. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  3789. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  3790. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  3791. // perhaps there is a more elegant solution -- WestLangley
  3792. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  3793. if ( perspective ) {
  3794. if ( start.z < 0.0 && end.z >= 0.0 ) {
  3795. trimSegment( start, end );
  3796. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  3797. trimSegment( end, start );
  3798. }
  3799. }
  3800. // clip space
  3801. vec4 clipStart = projectionMatrix * start;
  3802. vec4 clipEnd = projectionMatrix * end;
  3803. // ndc space
  3804. vec3 ndcStart = clipStart.xyz / clipStart.w;
  3805. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  3806. // direction
  3807. vec2 dir = ndcEnd.xy - ndcStart.xy;
  3808. // account for clip-space aspect ratio
  3809. dir.x *= aspect;
  3810. dir = normalize( dir );
  3811. #ifdef WORLD_UNITS
  3812. vec3 worldDir = normalize( end.xyz - start.xyz );
  3813. vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
  3814. vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
  3815. vec3 worldFwd = cross( worldDir, worldUp );
  3816. worldPos = position.y < 0.5 ? start: end;
  3817. // height offset
  3818. float hw = linewidth * 0.5;
  3819. worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
  3820. // don't extend the line if we're rendering dashes because we
  3821. // won't be rendering the endcaps
  3822. #ifndef USE_DASH
  3823. // cap extension
  3824. worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
  3825. // add width to the box
  3826. worldPos.xyz += worldFwd * hw;
  3827. // endcaps
  3828. if ( position.y > 1.0 || position.y < 0.0 ) {
  3829. worldPos.xyz -= worldFwd * 2.0 * hw;
  3830. }
  3831. #endif
  3832. // project the worldpos
  3833. vec4 clip = projectionMatrix * worldPos;
  3834. // shift the depth of the projected points so the line
  3835. // segments overlap neatly
  3836. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  3837. clip.z = clipPose.z * clip.w;
  3838. #else
  3839. vec2 offset = vec2( dir.y, - dir.x );
  3840. // undo aspect ratio adjustment
  3841. dir.x /= aspect;
  3842. offset.x /= aspect;
  3843. // sign flip
  3844. if ( position.x < 0.0 ) offset *= - 1.0;
  3845. // endcaps
  3846. if ( position.y < 0.0 ) {
  3847. offset += - dir;
  3848. } else if ( position.y > 1.0 ) {
  3849. offset += dir;
  3850. }
  3851. // adjust for linewidth
  3852. offset *= linewidth;
  3853. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  3854. offset /= resolution.y;
  3855. // select end
  3856. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  3857. // back to clip space
  3858. offset *= clip.w;
  3859. clip.xy += offset;
  3860. #endif
  3861. gl_Position = clip;
  3862. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  3863. #include <logdepthbuf_vertex>
  3864. #include <clipping_planes_vertex>
  3865. #include <fog_vertex>
  3866. }
  3867. `,fragmentShader:`
  3868. uniform vec3 diffuse;
  3869. uniform float opacity;
  3870. uniform float linewidth;
  3871. #ifdef USE_DASH
  3872. uniform float dashOffset;
  3873. uniform float dashSize;
  3874. uniform float gapSize;
  3875. #endif
  3876. varying float vLineDistance;
  3877. #ifdef WORLD_UNITS
  3878. varying vec4 worldPos;
  3879. varying vec3 worldStart;
  3880. varying vec3 worldEnd;
  3881. #ifdef USE_DASH
  3882. varying vec2 vUv;
  3883. #endif
  3884. #else
  3885. varying vec2 vUv;
  3886. #endif
  3887. #include <common>
  3888. #include <color_pars_fragment>
  3889. #include <fog_pars_fragment>
  3890. #include <logdepthbuf_pars_fragment>
  3891. #include <clipping_planes_pars_fragment>
  3892. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  3893. float mua;
  3894. float mub;
  3895. vec3 p13 = p1 - p3;
  3896. vec3 p43 = p4 - p3;
  3897. vec3 p21 = p2 - p1;
  3898. float d1343 = dot( p13, p43 );
  3899. float d4321 = dot( p43, p21 );
  3900. float d1321 = dot( p13, p21 );
  3901. float d4343 = dot( p43, p43 );
  3902. float d2121 = dot( p21, p21 );
  3903. float denom = d2121 * d4343 - d4321 * d4321;
  3904. float numer = d1343 * d4321 - d1321 * d4343;
  3905. mua = numer / denom;
  3906. mua = clamp( mua, 0.0, 1.0 );
  3907. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  3908. mub = clamp( mub, 0.0, 1.0 );
  3909. return vec2( mua, mub );
  3910. }
  3911. void main() {
  3912. #include <clipping_planes_fragment>
  3913. #ifdef USE_DASH
  3914. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  3915. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  3916. #endif
  3917. float alpha = opacity;
  3918. #ifdef WORLD_UNITS
  3919. // Find the closest points on the view ray and the line segment
  3920. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  3921. vec3 lineDir = worldEnd - worldStart;
  3922. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  3923. vec3 p1 = worldStart + lineDir * params.x;
  3924. vec3 p2 = rayEnd * params.y;
  3925. vec3 delta = p1 - p2;
  3926. float len = length( delta );
  3927. float norm = len / linewidth;
  3928. #ifndef USE_DASH
  3929. #ifdef USE_ALPHA_TO_COVERAGE
  3930. float dnorm = fwidth( norm );
  3931. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  3932. #else
  3933. if ( norm > 0.5 ) {
  3934. discard;
  3935. }
  3936. #endif
  3937. #endif
  3938. #else
  3939. #ifdef USE_ALPHA_TO_COVERAGE
  3940. // artifacts appear on some hardware if a derivative is taken within a conditional
  3941. float a = vUv.x;
  3942. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  3943. float len2 = a * a + b * b;
  3944. float dlen = fwidth( len2 );
  3945. if ( abs( vUv.y ) > 1.0 ) {
  3946. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  3947. }
  3948. #else
  3949. if ( abs( vUv.y ) > 1.0 ) {
  3950. float a = vUv.x;
  3951. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  3952. float len2 = a * a + b * b;
  3953. if ( len2 > 1.0 ) discard;
  3954. }
  3955. #endif
  3956. #endif
  3957. vec4 diffuseColor = vec4( diffuse, alpha );
  3958. #include <logdepthbuf_fragment>
  3959. #include <color_fragment>
  3960. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  3961. #include <tonemapping_fragment>
  3962. #include <colorspace_fragment>
  3963. #include <fog_fragment>
  3964. #include <premultiplied_alpha_fragment>
  3965. }
  3966. `};class Vi extends ii{constructor(e){super({type:"LineMaterial",uniforms:Vl.clone(Qt.line.uniforms),vertexShader:Qt.line.vertexShader,fragmentShader:Qt.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const ga=new rt,bd=new P,wd=new P,Lt=new rt,It=new rt,Nn=new rt,_a=new P,va=new pt,Nt=new Zm,Td=new P,zr=new Sn,kr=new Ps,On=new rt;let Fn,zi;function Ad(n,e,t){return On.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),On.multiplyScalar(1/On.w),On.x=zi/t.width,On.y=zi/t.height,On.applyMatrix4(n.projectionMatrixInverse),On.multiplyScalar(1/On.w),Math.abs(Math.max(On.x,On.y))}function Zx(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,r=i.attributes.instanceEnd,o=Math.min(i.instanceCount,s.count);for(let a=0,l=o;a<l;a++){Nt.start.fromBufferAttribute(s,a),Nt.end.fromBufferAttribute(r,a),Nt.applyMatrix4(t);const c=new P,d=new P;Fn.distanceSqToSegment(Nt.start,Nt.end,d,c),d.distanceTo(c)<zi*.5&&e.push({point:d,pointOnLine:c,distance:Fn.origin.distanceTo(d),object:n,face:null,faceIndex:a,uv:null,uv1:null})}}function Kx(n,e,t){const i=e.projectionMatrix,r=n.material.resolution,o=n.matrixWorld,a=n.geometry,l=a.attributes.instanceStart,c=a.attributes.instanceEnd,d=Math.min(a.instanceCount,l.count),u=-e.near;Fn.at(1,Nn),Nn.w=1,Nn.applyMatrix4(e.matrixWorldInverse),Nn.applyMatrix4(i),Nn.multiplyScalar(1/Nn.w),Nn.x*=r.x/2,Nn.y*=r.y/2,Nn.z=0,_a.copy(Nn),va.multiplyMatrices(e.matrixWorldInverse,o);for(let h=0,f=d;h<f;h++){if(Lt.fromBufferAttribute(l,h),It.fromBufferAttribute(c,h),Lt.w=1,It.w=1,Lt.applyMatrix4(va),It.applyMatrix4(va),Lt.z>u&&It.z>u)continue;if(Lt.z>u){const y=Lt.z-It.z,S=(Lt.z-u)/y;Lt.lerp(It,S)}else if(It.z>u){const y=It.z-Lt.z,S=(It.z-u)/y;It.lerp(Lt,S)}Lt.applyMatrix4(i),It.applyMatrix4(i),Lt.multiplyScalar(1/Lt.w),It.multiplyScalar(1/It.w),Lt.x*=r.x/2,Lt.y*=r.y/2,It.x*=r.x/2,It.y*=r.y/2,Nt.start.copy(Lt),Nt.start.z=0,Nt.end.copy(It),Nt.end.z=0;const _=Nt.closestPointToPointParameter(_a,!0);Nt.at(_,Td);const m=_u.lerp(Lt.z,It.z,_),p=m>=-1&&m<=1,b=_a.distanceTo(Td)<zi*.5;if(p&&b){Nt.start.fromBufferAttribute(l,h),Nt.end.fromBufferAttribute(c,h),Nt.start.applyMatrix4(o),Nt.end.applyMatrix4(o);const y=new P,S=new P;Fn.distanceSqToSegment(Nt.start,Nt.end,S,y),t.push({point:S,pointOnLine:y,distance:Fn.origin.distanceTo(S),object:n,face:null,faceIndex:h,uv:null,uv1:null})}}}class ku extends vt{constructor(e=new zu,t=new Vi({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let o=0,a=0,l=t.count;o<l;o++,a+=2)bd.fromBufferAttribute(t,o),wd.fromBufferAttribute(i,o),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+bd.distanceTo(wd);const r=new El(s,2,1);return e.setAttribute("instanceDistanceStart",new _i(r,1,0)),e.setAttribute("instanceDistanceEnd",new _i(r,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Fn=e.ray;const o=this.matrixWorld,a=this.geometry,l=this.material;zi=l.linewidth+r,a.boundingSphere===null&&a.computeBoundingSphere(),kr.copy(a.boundingSphere).applyMatrix4(o);let c;if(i)c=zi*.5;else{const u=Math.max(s.near,kr.distanceToPoint(Fn.origin));c=Ad(s,u,l.resolution)}if(kr.radius+=c,Fn.intersectsSphere(kr)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),zr.copy(a.boundingBox).applyMatrix4(o);let d;if(i)d=zi*.5;else{const u=Math.max(s.near,zr.distanceToPoint(Fn.origin));d=Ad(s,u,l.resolution)}zr.expandByScalar(d),Fn.intersectsBox(zr)!==!1&&(i?Zx(this,t):Kx(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(ga),this.material.uniforms.resolution.value.set(ga.z,ga.w))}}class ir extends zu{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,i=new Float32Array(2*t);for(let s=0;s<t;s+=3)i[2*s]=e[s],i[2*s+1]=e[s+1],i[2*s+2]=e[s+2],i[2*s+3]=e[s+3],i[2*s+4]=e[s+4],i[2*s+5]=e[s+5];return super.setPositions(i),this}setColors(e){const t=e.length-3,i=new Float32Array(2*t);for(let s=0;s<t;s+=3)i[2*s]=e[s],i[2*s+1]=e[s+1],i[2*s+2]=e[s+2],i[2*s+3]=e[s+3],i[2*s+4]=e[s+4],i[2*s+5]=e[s+5];return super.setColors(i),this}setFromPoints(e){const t=e.length-1,i=new Float32Array(6*t);for(let s=0;s<t;s++)i[6*s]=e[s].x,i[6*s+1]=e[s].y,i[6*s+2]=e[s].z||0,i[6*s+3]=e[s+1].x,i[6*s+4]=e[s+1].y,i[6*s+5]=e[s+1].z||0;return super.setPositions(i),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class jl extends ku{constructor(e=new ir,t=new Vi({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const Hu="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABwElEQVRoQ+3ZPUoDQRjG8edf6RmsPIQX8BCCIMSIEiOKIIogiI0IoiiC+BHFbxC0FOy9gL2NeAgbu5EFBQkrM8l8ZBaykC5Mnt+872RnZ1HFLyqeX31AryvYr0ClK2CMqUmakvQpqQU8pwZ13ULGmGFJH22Bx4GHlAgfQF3SVUnYCeA+FcIHMCDpTVJRifarBtylQHQNKMIZY8YkPf4TdAq4jo3wAjggZoCLmAhvgAOiAZzHQgQBOCDmgNMYiGAAB8QCcBQaERTggFgEDkMiggMcEEvAQShEFIADYgXYC4GIBnBArAK7voioAAfEGrDtg4gOcECsA1vdIpIAHBAbwGY3iGQAB8QscNYpIinAgngFRqoMeAFGswZYtt+TwG22AEv4vBexJXzef6OW8HnfyCzh895KWMIvA/udLtiy70e5D1jC572dtoTP+4HGEn4eOA7RNn/HCNZClvBNoBU6fDFeEIAlfN7HKpbw08BljJn/HdOrApbwdeAmZnivFjLGDEp6lzRUEjL/w11jTFPSSUn4yhyvV/sFx8/TVUNS8fmStAM8xe759vG9FnHqsMn2Qilh/QqknO1+C/V6tst+/xsUtbYxjEhssgAAAABJRU5ErkJggg==",Hr=.25;function Gr(n){let e=[];return n.forEach(t=>{e=e.concat(t.toArray())}),e}let Jx=new tn({map:new wo().load(Hu),color:2512283,transparent:!0});class Qx extends jl{constructor(e,t,i,s){let r,o=new qt(.1,.1);o.rotateX(-Math.PI/2);let a=new vt(o,Jx);if(i.name===0){let c=e.clone(),d=new P(e.x,e.y,i.y+i.parent.parent.position.z-Hr),u=new P(t.x,t.y,i.y+i.parent.parent.position.z-Hr),h=new P(t.x,t.y,i.y+i.parent.parent.position.z);a.position.copy(h),a.rotation.y=-Math.PI/2,a.position.z-=.02,r=Gr([c,d,u,h])}else if(i.name===1){let c=e.clone(),d=new P((e.x+t.x)/2,e.y,e.z),u=new P((e.x+t.x)/2,e.y,t.z),h=new P(i.x+i.parent.parent.parent.position.x,e.y,t.z);a.position.copy(h);const f=u.x<h.x;a.rotation.y=f?0:-Math.PI,f?a.position.x-=.02:a.position.x+=.02,r=Gr([c,d,u,h])}else if(i.name===2){let c=e.clone(),d=new P(e.x,e.y,i.y+i.parent.parent.position.z+Hr),u=new P(t.x,t.y,i.y+i.parent.parent.position.z+Hr),h=new P(t.x,t.y,i.y+i.parent.parent.position.z);a.rotation.y=Math.PI/2,a.position.copy(h),a.position.z+=.02,r=Gr([c,d,u,h])}else{let c=e.clone(),d=new P((e.x+t.x)/2,e.y,e.z),u=new P((e.x+t.x)/2,e.y,t.z),h=new P(i.x+i.parent.parent.parent.position.x,e.y,t.z);const f=u.x<h.x;a.position.copy(h),a.rotation.y=f?0:Math.PI,f?a.position.x-=.02:a.position.x+=.02,r=Gr([c,d,u,h])}const l=new ir;a.visible=!1,l.setPositions(r),super(l,s),this.name="line_"+this.uuid,this.userData={dir:i.name,points:r},this.scale.set(1,1,1),this.position.y+=.5,this.add(a)}}let eS=new tn({map:new wo().load(Hu),color:2512283,transparent:!0});class xa extends jl{constructor(e,t,i,s,r){let o=new qt(.1,.1);o.rotateX(-Math.PI/2);let a=new vt(o,eS);new P(e[0],e[1],e[2]),new P(e[3],e[4],e[5]);let l=new P(e[6],e[7],e[8]),c=new P(e[9],e[10],e[11]),d;switch(i){case 0:a.rotation.y=-Math.PI/2,a.position.copy(c);break;case 1:d=l.x<c.x,a.rotation.y=d?0:-Math.PI,d?a.position.x-=.02:a.position.x+=.02;break;case 2:a.position.copy(c),a.rotation.y=Math.PI/2,a.position.z+=.02;break;case 3:d=l.x<c.x,a.position.copy(c),a.rotation.y=d?0:Math.PI,d?a.position.x-=.02:a.position.x+=.02;break}const u=new ir;a.visible=!1,u.setPositions(e),super(u,t),this.name="line_point_"+this.uuid,this.scale.set(1,1,1),this.position.y+=.5,r&&(this.uuid=r),this.userData={id:r||this.uuid,dir:i,points:e,imgId:s||null},this.add(a)}}const tS=""+new URL("arrow-b9bc92aa.svg",import.meta.url).href,nS=new tn({map:new wo().load(tS),color:14962004,transparent:!0});class Vr extends vt{constructor(e,t){const i=new qt(.15,.15);i.rotateX(-Math.PI/2),super(i,nS);const s=e.clone();this.position.copy(s),this.rotation.y=0,this.position.y=5,this.position.z-=.02,this.userData={imageId:t||null,point:s.toArray()},this.visible=!0,this.scale.set(1,1,1),this.position.y+=.5,this.name="marker_"+this.uuid,this.renderOrder=1e3}}class Sa extends vt{constructor(e,t){let i=5,s=new P().copy(t);const r=document.createElement("canvas");r.width=128*i,r.height=128*i;let o=68*i;const a=r.getContext("2d");a.font=`800 ${o}px Arial`,a.textAlign="center",a.textBaseline="middle",a.fillStyle="#e44d54",a.fillText(e,r.width/2,r.height/2);const l=new zm(r),c=new tn({map:l,transparent:!0});l.colorSpace=Pt,l.needsUpdate=!0,l.anisotropy=4;const d=new Wl(.08,128);d.rotateX(-Math.PI/2),super(d,c),this.userData=e;const u=new Pu(d),h=new ir;h.fromEdgesGeometry(u);const f=new Vi({color:14962004,linewidth:5,dashed:!1,dashScale:.1,alphaToCoverage:!1});f.resolution.set(window.innerWidth,window.innerHeight);const g=new ku(h,f);g.position.y+=.5,this.add(g),this.userData=s.toArray(),this.position.copy(s),this.name="circle_"+e}}const iS=(n,e="",t=200)=>{let i=[],s="";for(let r=0,o=e.length;r<o;r++)s+=e.charAt(r),n.measureText(s).width>t&&(i.push(s.substring(0,s.length-1)),s="",r--);return i.push(s),i};class Wr extends vt{constructor(e,t,i=12,s="#000000",r){const o=i/12;let a=1.5*o,l=.12*o;const c=a/l;let d=2;const u=168*d*o,h=u/c;var f=document.createElement("canvas");f.width=u,f.height=h;let g="Arial",_=12*d*o;var m=f.getContext("2d");const p=iS(m,e,140);console.log("lines",p),l=l*p.length,f.height=h*p.length,m.fillStyle="transparent",m.rect(0,0,u,h*p.length),m.fill();let b="normal "+_+"px "+g;m.font=b,m.fillStyle=s,m.textAlign="center",m.textBaseline="middle",p.forEach((D,R)=>{m.fillText(D,u/2,h/2+h*R)});const y=new Tt(f);y.colorSpace=Pt,y.needsUpdate=!0,y.anisotropy=4;const S=new qt(a,l);S.rotateX(-Math.PI/2);const C=new tn({map:y,transparent:!0});super(S,C),r&&(this.uuid=r);const T=new P().copy(t);this.userData={id:this.uuid,text:e,color:s,pos:T.toArray(),fontsize:i},this.position.copy(T),this.name="pureText_"+e}}const ya=function(n,e){let t=n.offsetX/e.clientWidth*2-1,i=-(n.offsetY/e.clientHeight)*2+1;return new Te(t,i)};class sS{constructor(e){ct(this,"init",()=>{this.floorplanControls=new Fx(this.orthCamera,this.scene.domElement),this.floorplanControls.enablePan=!0,this.floorplanControls.maxDistance=100,this.floorplanControls.minDistance=3.5,this.floorplanControls.maxZoom=500,this.floorplanControls.minZoom=100,this.setMode(0),this.floorplanControls.enableRotate=!1,this.raycaster=new $m,this.onBindEvent(),this.inited=!0,this.matLine=new Vi({color:this.lineColor,linewidth:4,dashed:!1,alphaToCoverage:!0}),this.matLine.resolution=new Te(this.scene.width,this.scene.height)});ct(this,"onPointerMove",e=>{if(this.pointermove=ya(e,this.scene.domElement),this.raycaster.setFromCamera(this.pointermove,this.orthCamera),!!this.drawing){if(this.mode===1){let t=this.scene.boxManager.imgList;const i=this.raycaster.intersectObjects(t,!1);i[0]&&i[0].object!==this.startObj&&(this.touchImg=i[0],this.setActiveLine(this.touchImg))}if(this.mode===2&&this.marker){this.marker.visible=!0;let t=new P(this.pointermove.x,this.pointermove.y,-1);t.unproject(this.orthCamera),t.y=5,this.marker.position.copy(t)}if(this.mode===3&&this.symbol){this.symbol.visible=!0;let t=new P(this.pointermove.x,this.pointermove.y,-1);t.unproject(this.orthCamera),t.y=5;const i=new P;this.scene.boxManager.obb.clampPoint(t,i),i.y=5,this.symbol.position.copy(i)}if(this.mode===4&&this.text){this.text.visible=!0;let t=new P(this.pointermove.x,this.pointermove.y,-1);t.unproject(this.orthCamera),t.y=5;const i=new P;this.scene.boxManager.obb.clampPoint(t,i),i.y=5,this.text.position.copy(i),this.text.userData.pos=i.toArray()}}});ct(this,"onPointerDown",e=>{if(console.log("start draw"),this.pointerdown=ya(e,this.scene.domElement),this.mode===0&&this.raycaster.intersectObjects(this.scene.scene.children,!0).forEach(i=>{if(String(i.object.name).includes("marker")||String(i.object.name).includes("line")||String(i.object.name).includes("circle")||String(i.object.name).includes("pureText")){let s;switch(!0){case String(i.object.name).includes("marker"):s=1;break;case String(i.object.name).includes("line"):s=2;break;case String(i.object.name).includes("circle"):s=3;break;case String(i.object.name).includes("pureText"):s=4;break}this.selectItem=i.object,this.scene.emit("confirmDelete",{id:i.object.uuid,type:s})}}),this.mode===1){this.raycaster.setFromCamera(this.pointerdown,this.orthCamera);let t=this.scene.boxManager.imgList;const i=this.raycaster.intersectObjects(t,!1);console.log("intersects",i),i[0]?(this.startObj=i[0].object,this.drawing=!0):(this.startObj=null,this.drawing=!1)}if(this.mode===2&&this.marker){this.raycaster.setFromCamera(this.pointerdown,this.orthCamera);let t=this.scene.boxManager.imgList;const i=this.raycaster.intersectObjects(t,!1);if(i[0]){const s=i[0].object.userData;let r=new P(this.pointerdown.x,this.pointerdown.y,-1);r.unproject(this.orthCamera),r.y=5;const o=new Vr(r,s),a={id:s,point:r.toArray()};this.renderMarkers.find(c=>c.id===s)?this.scene.emit("markerExist"):(this.scene.scene.add(o),this.renderMarkers.push(a),this.scene.scene.remove(this.marker),this.marker=null),console.log("activeMarkeritem",a),this.setMode(0)}}if(this.mode===3&&this.symbol){let t=new P(this.pointerdown.x,this.pointerdown.y,-1);t.unproject(this.orthCamera),t.y=5;const i={index:this.symbolIndex,point:t.toArray()};this.renderSymbols.push(i),console.log("activeSymbolItem",i),this.setMode(0)}this.mode===4&&this.text&&(new P(this.pointerdown.x,this.pointerdown.y,-1),this.scene.emit("edit",{type:4,text:this.showText,id:this.text.uuid,...this.text.userData}),this.drawing=!0)});ct(this,"onPointerUp",e=>{if(this.pointerup=ya(e,this.scene.domElement),this.mode===1&&(this.drawing=!1,this.floorplanControls.enabled=!0,this.drawLine)){const t=this.drawLine.userData.points,i=this.drawLine.userData.dir,s=this.touchImg.object.userData,r=new xa(t,this.matLine,i,s);this.scene.scene.add(r);const o={id:r.uuid,imgId:s,startId:this.startObj.userData,dir:i,points:t},a={id:s,startId:this.startObj.userData,dir:[i]};this.renderLines.push(o),this.insertActiveEdge(a),this.scene.scene.remove(this.drawLine),this.drawLine=null,this.startObj=null}if(this.mode,this.mode===4&&this.text){let t=new P(this.pointerup.x,this.pointerup.y,-1);t.unproject(this.orthCamera),t.y=5;const i=new P;this.scene.boxManager.obb.clampPoint(t,i),i.y=5,console.log("pos",t),console.log("clamp",i),this.text.position.copy(i),this.text.userData.pos=i.toArray();const s=this.text.userData;this.drawing=!1,console.log("activeTextItem",s),this.insertrenderTexts(s)}this.syncDrawData()});ct(this,"Listener",{onPointerDown:this.onPointerDown.bind(this),onPointerMove:this.onPointerMove.bind(this),onPointerUp:this.onPointerUp.bind(this)});ct(this,"onBindEvent",()=>{this.scene.domElement.addEventListener("pointerdown",this.Listener.onPointerDown),this.scene.domElement.addEventListener("pointermove",this.Listener.onPointerMove,!1),this.scene.domElement.addEventListener("pointerup",this.Listener.onPointerUp)});ct(this,"unbindEvent",()=>{this.scene.domElement.removeEventListener("pointerdown",this.Listener.onPointerDown),this.scene.domElement.removeEventListener("pointermove",this.Listener.onPointerMove),this.scene.domElement.removeEventListener("pointerup",this.Listener.onPointerUp)});ct(this,"buildLine",()=>{this.drawLine&&this.drawLine.removeFromParent();let e=new P(this.pointerdown.x,this.pointerdown.y,-1),t=new P(this.pointermove.x,this.pointermove.y,-1);e.unproject(this.orthCamera),t.unproject(this.orthCamera),e.y=5,t.y=5;const i=new Vi({color:this.lineColor,linewidth:4,dashed:!1,alphaToCoverage:!0});i.resolution=new Te(this.scene.width,this.scene.height),this.drawLine=new Qx(e,t,this.activeEdge,i),this.scene.scene.add(this.drawLine)});ct(this,"setActiveLine",e=>{function t(s,r){if(s-=.5,r-=.5,s>=0&&r>=0)return s>r?3:0;if(s>=0&&r<=0)return s>Math.abs(r)?3:2;if(s<=0&&r>=0)return Math.abs(s)>r?1:0;if(s<=0&&r<=0)return-s>-r?1:2}this.activeEdge&&(this.activeEdge.visible=!1,this.activeEdge=null);let i=t(e.uv.x,e.uv.y);this.activeEdge=e.object.touchLines.getObjectByName(i),this.activeEdge.visible=!0,this.buildLine()});ct(this,"update",()=>{this.floorplanControls.enabled&&(this.floorplanControls&&this.floorplanControls.update(),this.scene.boxManager&&this.showAllActiveEdges())});this.scene=e,this.orthCamera=e.orthCamera,this.floorplanControls=null,this.raycaster=null,this.position=new P,this.pointerdown=new Te,this.pointerup=new Te,this.pointer=new Te,this.markPosition=new P,this.touchImg=null,this.activeEdge=null,this.drawLine=null,this.startObj=null,this.marker=null,this.symbol=null,this.symbolIndex=0,this.text=null,this.showText="文本",this.selectItem=null,this.drawing=!1,this.inited=!1,this.renderLines=[],this.renderMarkers=[],this.activeEdges=[],this.renderSymbols=[],this.renderTexts=[],this.matLine=null,this.lineColor=14962004,this.mode=0,this.init()}setMode(e){if(this.mode=e,e!==0&&(this.reset(),this.setEditMode()),e===2){let t=new P(0,0,-1);t.unproject(this.orthCamera),t.y=5,this.marker=new Vr(t),this.marker.visible=!1,this.scene.scene.add(this.marker),this.drawing=!0}if(e===3){let t=new P(0,0,-1);t.unproject(this.orthCamera),t.y=5;const i=this.getLaSybIndex();this.symbolIndex=i+1,this.symbol=new Sa(this.symbolIndex,t),this.symbol.visible=!1,this.scene.scene.add(this.symbol),console.log("this.symbol",this.symbol),this.drawing=!0}if(e===4){let t=new P(0,0,-1);t.unproject(this.orthCamera),t.y=5,this.text=new Wr(this.showText,t),this.text.visible=!1,this.showText="文本",this.scene.scene.add(this.text),this.drawing=!0}e===0&&this.setFreeMode(),this.scene.emit("mode",this.mode)}getLaSybIndex(){return this.renderSymbols.reduce((t,i)=>i.index>t.index?i:t,{index:0,point:[]}).index}setFreeMode(){this.floorplanControls.enablePan=!0,this.floorplanControls.mouseButtons={LEFT:Xt.PAN,MIDDLE:Xt.DOLLY,RIGHT:Xt.PAN},this.reset()}setEditMode(){this.floorplanControls.enablePan=!0,this.floorplanControls.mouseButtons={LEFT:Xt.ROTATE,MIDDLE:Xt.DOLLY,RIGHT:Xt.PAN}}setRotateMode(){this.floorplanControls.enableRotate=!0,this.floorplanControls.mouseButtons={LEFT:Xt.ROTATE,MIDDLE:Xt.DOLLY,RIGHT:Xt.PAN}}insertActiveEdge(e){const t=this.activeEdges.find(i=>e.id===i.id);t?t.dir=[...new Set([...t.dir,...e.dir])]:this.activeEdges.push(e)}insertrenderTexts(e){const t=this.renderTexts.findIndex(i=>e.id===i.id);t>-1?this.renderTexts[t]=e:this.renderTexts.push(e)}showAllActiveEdges(){if(this.inited){let e=this.scene.boxManager.imgList;this.activeEdges.length>0?this.activeEdges.forEach(t=>{const i=e.find(s=>s.userData===t.id);if(i){let s=[0,1,2,3].filter(r=>!t.dir.includes(r));t.dir.forEach(r=>{i.touchLines.children[r].visible=!0}),s.forEach(r=>{i.touchLines.children[r].visible=!1})}}):e.forEach(t=>{t.touchLines.children.forEach(i=>{i.visible&&(i.visible=!1)})})}}deleteItemByType(e,t){if(e===1){const i=this.renderMarkers.findIndex(s=>{const r=new P().fromArray(s.point),o=new P().fromArray(t.point);return r.equals(o)});this.renderMarkers.splice(i,1)}if(e===2){const{imgId:i,id:s,dir:r,points:o}=t,a=this.renderLines.findIndex(c=>c.id===s);a>-1&&this.renderLines.splice(a,1);const l=this.activeEdges.findIndex(c=>c.id===i);if(l>-1){const c=this.renderLines.filter(u=>u.imgId===this.activeEdges[l].id).reduce((u,h)=>u.concat(h.dir),[]),d=[...new Set(c)];console.log("uni_dir",d),d.length>0?this.activeEdges[l].dir=d:(console.log("全空",this.activeEdges[l].id),this.scene.boxManager.imgList.find(f=>f.userData===this.activeEdges[l].id).touchLines.children.forEach(f=>{f.visible=!1}),this.activeEdges.splice(l,1),this.update())}}if(e===3){const i=this.renderSymbols.findIndex(s=>{const r=new P().fromArray(s.point),o=new P().fromArray(t);return r.equals(o)});this.renderSymbols.splice(i,1)}if(e===4){const{id:i}=t,s=this.renderTexts.findIndex(r=>r.id===i);s>-1&&this.renderTexts.splice(s,1)}}editing(e){if(e.type===4&&this.text){const{pos:t}=this.text.userData,i=new P().fromArray(t);this.scene.scene.remove(this.text),this.text=null,this.showText=e.text,console.log("editing",e,i),this.text=new Wr(e.text,i,e.fontsize,e.color,e.id),this.scene.scene.add(this.text);const s=this.text.userData;console.log("activeTextItem",s),this.insertrenderTexts(s)}}getDrawData(){let e;return this.scene.sceneType===1?e={hor_lines:this.renderLines,hor_activeEdges:this.activeEdges,hor_markers:this.renderMarkers,hor_symbols:this.renderSymbols,hor_texts:this.renderTexts,vir_lines:[],vir_activeEdges:[],vir_markers:[],vir_symbols:[],vir_texts:[]}:e={hor_lines:[],hor_activeEdges:[],hor_markers:[],hor_symbols:[],hor_texts:[],vir_lines:this.renderLines,vir_activeEdges:this.activeEdges,vir_markers:this.renderMarkers,vir_symbols:this.renderSymbols,vir_texts:this.renderTexts},e}syncDrawData(){const e=this.getDrawData();this.scene.emit("data",e)}load(e,t){if(e===1){console.log("data1",t);const{hor_activeEdges:i,hor_lines:s,hor_markers:r,hor_symbols:o,hor_texts:a}=t;i&&(this.activeEdges=i),s&&Array.isArray(s)&&(this.renderLines=s,s.forEach(l=>{const c=new xa(l.points,this.matLine,l.dir,l.imgId,l.id);this.scene.scene.add(c)})),r&&Array.isArray(r)&&(this.renderMarkers=r,r.forEach(l=>{console.log("pos");const c=new P().fromArray(l.point),d=new Vr(c,l.id);this.scene.scene.add(d)})),o&&Array.isArray(o)&&(this.renderSymbols=o,o.forEach(l=>{console.log("pos");const c=new P().fromArray(l.point),d=new Sa(l.index,c);this.scene.scene.add(d)})),a&&Array.isArray(a)&&(this.renderTexts=a,a.forEach(l=>{console.log("pos");const c=new P().fromArray(l.pos),d=new Wr(l.text,c,l.fontsize,l.color,l.id);this.scene.scene.add(d)}))}if(e===2){const{vir_activeEdges:i,vir_lines:s,vir_markers:r,vir_symbols:o,vir_texts:a}=t;i&&(this.activeEdges=i),s&&Array.isArray(s)&&(this.renderLines=s,s.forEach(l=>{const c=new xa(l.points,this.matLine,l.dir,l.imgId,l.id);this.scene.scene.add(c)})),r&&Array.isArray(r)&&(this.renderMarkers=r,r.forEach(l=>{const c=new P().fromArray(l.point),d=new Vr(c);this.scene.scene.add(d)})),o&&Array.isArray(o)&&(this.renderSymbols=o,o.forEach(l=>{const c=new P().fromArray(l.point),d=new Sa(l.index,c);this.scene.scene.add(d)})),a&&Array.isArray(a)&&(this.renderTexts=a,a.forEach(l=>{console.log("pos");const c=new P().fromArray(l.pos),d=new Wr(l.text,c,l.fontsize,l.color,l.id);this.scene.scene.add(d)}))}this.syncDrawData()}reset(){this.marker&&(this.scene.scene.remove(this.marker),this.marker=null),this.drawLine&&(this.scene.scene.remove(this.drawLine),this.drawLine=null),this.touchImg&&(this.touchImg=null),this.activeEdge&&(this.activeEdge=null),this.text&&(this.text=null,this.scene.scene.remove(this.text)),this.showText="文本",this.drawing=!1}clear(){this.activeEdges=[],this.renderLines=[],this.renderMarkers=[],this.renderSymbols=[],this.renderTexts=[],this.reset(),this.scene.clearDrawScene(),this.syncDrawData()}deleteImageDataByIds(e){setTimeout(()=>{console.warn("单多张图片删除时要删除相关数据",e),this.clear(),this.scene.emit("autoSave")},500)}t_deleteImageDataByIds(e){e.forEach(t=>{const i=this.renderMarkers.findIndex(r=>r.id===t);i>-1&&this.renderMarkers.splice(i,1);const s=this.renderLines.filter(r=>r.imgId===t||r.startId===t);s.forEach(r=>{const o=this.activeEdges.find(l=>l.id===r.imgId||l.startId===r.imgId);if(o)if(o.dir.length>0){const l=Array.from(o.dir).findIndex(c=>c===r.dir);o.dir.splice(l,1)}else{const l=this.activeEdges.findIndex(c=>c.id===o.id);console.warn("edge没dir",l),l>-1&&this.activeEdges.splice(l,1)}const a=this.renderLines.findIndex(l=>l.imageId===r.imageId);console.log("lineIndex",a),a>-1&&this.renderLines.splice(a,1)}),console.log("lines",s)}),setTimeout(()=>{this.syncDrawData(),this.scene.emit("autoSave")},2500)}checkDeleteing(){const e=this.scene.scene.children.filter(t=>String(t.name).includes("marker_"));Array.from(e).forEach(t=>{const{imageId:i,point:s}=t.userData,r=this.scene.boxManager.imgList.find(o=>o.userData===i);if(r){const o=new P().fromArray(s);o.project(this.orthCamera),console.log("nPoint",o,s),this.raycaster.setFromCamera(o,this.orthCamera);const a=this.raycaster.intersectObjects(this.scene.boxManager.imgList,!1);r.userData!==a[0].object.userData&&(console.log("相交不正确"),this.scene.scene.remove(t))}})}}class Gu extends vt{constructor(e,t){let i=5;const s=150*i,r=15*i;var o=document.createElement("canvas");o.width=s,o.height=r;let a="Arial",l=7*i,c=75*i,d=10*i;var u=o.getContext("2d");u.fillStyle="#ffffff",u.rect(0,0,s,r),u.fill(),u.font="normal "+l+"px "+a,u.fillStyle="#000000",u.textAlign="center",u.fillText(e,c,d);const h=new Tt(o);h.colorSpace=Pt,h.needsUpdate=!0,h.anisotropy=4;const f=new qt(1.5,.15);f.rotateX(-Math.PI/2);const g=new tn({map:h});super(f,g);const _=new Pu(f),m=new Bm(_,new Cu({color:13421772}));m.position.y+=.5,this.add(m),this.name="textlabel_"+e}}class Vu extends vt{constructor(e,t){let i=5;const s=150*i,r=15*i;var o=document.createElement("canvas");o.width=s,o.height=r;let a="Arial",l=5.2*i,c=75*i,d=10*i;var u=o.getContext("2d");u.fillStyle="#ffffff",u.rect(0,0,s,r),u.fill(),u.font="normal "+l+"px "+a,u.fillStyle="#000000",u.textAlign="center",u.fillText(e,c,d);const h=new Tt(o);h.colorSpace=Pt,h.needsUpdate=!0,h.anisotropy=4;const f=new qt(1.5,.15);f.rotateX(-Math.PI/2);const g=new tn({map:h});super(f,g),this.name="SimpleLabel_"+e}}class Wu extends vi{constructor(e,t){super(),e.forEach((i,s)=>{const r=new ir;r.setPositions(i);const o=new jl(r,t);o.scale.set(1,1,1),o.position.y+=.5,o.name=s,o.visible=!1,o.x=i[0],o.y=i[2],this.add(o)})}}let rS=class extends vt{constructor(e,t,i=!0){let s,r,o;i?(s=1.5,r=.85,o=[[-.75,0,-.425,.75,0,-.425],[-.75,0,-.425,-.75,0,.425],[-.75,0,.425,.75,0,.425],[.75,0,.425,.75,0,-.425]]):(s=1.5,r=2,o=[[-.75,0,-1,.75,0,-1],[-.75,0,-1,-.75,0,1],[-.75,0,1,.75,0,1],[.75,0,1,.75,0,-1]]);const a=new qt(s,r);a.rotateX(-Math.PI/2);const l=new tn({map:e,transparent:!0});super(a,l),this.width=s,this.height=r,this.touchLines=new Wu(o,t),this.touchLines.position.y+=.5,this.add(this.touchLines),this.name="imglabel"}};class oS extends vi{constructor(e,t,i,s){super(),this.manager=e,this.name="horizontal_box",this.total=s,this.getStyle(),this.load(t,i)}getStyle(){this.width=2,this.height=2*710/500,this.color=16777215}cover(e,t){var i=e.image.width/e.image.height;t<i?e.matrix.setUvTransform(0,0,t/i,1,0,.5,.5):e.matrix.setUvTransform(0,0,1,i/t,0,.5,.5)}load(e,t){const i=new qt(1,1);i.rotateX(-Math.PI/2);const s=new tn({color:this.color}),r=new vt(i,s);r.scale.set(this.width,1,this.height),this.add(r),this.position.x=(this.width+.125)*t-1.8;const o=new Vi({color:14962004,linewidth:4,dashed:!1,alphaToCoverage:!0});o.resolution=new Te(this.manager.scene.width,this.manager.scene.height),e.forEach((c,d)=>{let u;this.manager.loader.load(c.imgUrl,h=>{let f=h.image.width/h.image.height;h.matrixAutoUpdate=!1;let g=1.5/.85;h.matrixAutoUpdate=!1,g<f?h.matrix.setUvTransform(0,0,g/f,1,0,.5,.5):h.matrix.setUvTransform(0,0,1,f/g,0,.5,.5),h.colorSpace=Pt,u=new rS(h,o),u.userData=c.id,u.position.y+=1,d===0?u.position.z-=.8:u.position.z+=.43,this.add(u),this.manager.imgList.push(u);const _=new Gu(c.imgInfo,!0);this.add(_),_.position.copy(u.position),_.position.z+=_.scale.z*.5+.1})});const a=` 第 ${t+1} 页 共 ${this.total} 页`,l=new Vu(a,!0);l.renderOrder=100,l.position.z+=1.26,this.add(l)}}class aS extends vt{constructor(e,t,i=!0){let s,r,o;i?(s=1.5,r=.85,o=[[-.75,0,-.425,.75,0,-.425],[-.75,0,-.425,-.75,0,.425],[-.75,0,.425,.75,0,.425],[.75,0,.425,.75,0,-.425]]):(s=1.5,r=2,o=[[-.75,0,-1,.75,0,-1],[-.75,0,-1,-.75,0,1],[-.75,0,1,.75,0,1],[.75,0,1,.75,0,-1]]);const a=new qt(s,r);a.rotateX(-Math.PI/2);const l=new tn({color:15921906,transparent:!1});super(a,l);let c=e.image.width/e.image.height;const d=s/c>=2?2:s/c,u=new qt(s,d);u.rotateX(-Math.PI/2);const h=new tn({map:e,transparent:!0}),f=new vt(u,h);f.renderOrder=10,this.add(f),this.width=s,this.height=r,this.touchLines=new Wu(o,t),this.touchLines.position.y+=.5,this.add(this.touchLines),this.name="imglabel"}}class lS extends vi{constructor(e,t,i,s){super(),this.manager=e,this.total=s,this.name="vertical_box",this.getStyle(),this.load(t,i)}getStyle(){this.width=2,this.height=2*710/500,this.color=16777215}load(e,t){const i=new qt(1,1);i.rotateX(-Math.PI/2);const s=new tn({color:this.color}),r=new vt(i,s);r.scale.set(this.width,1,this.height),this.add(r),this.position.x=(this.width+.125)*t-1.8;const o=new Vi({color:14962004,linewidth:4,dashed:!1,alphaToCoverage:!0});o.resolution=new Te(this.manager.scene.width,this.manager.scene.height),e.forEach((c,d)=>{let u;this.manager.loader.load(c.imgUrl,h=>{h.image.width/h.image.height,h.matrixAutoUpdate=!1,h.colorSpace=Pt,u=new aS(h,o,!1),u.userData=c.id,u.position.y+=1,u.position.z-=.2,this.add(u),this.manager.imgList.push(u);const f=new Gu(c.imgInfo,!0);this.add(f),f.position.copy(u.position),f.position.z+=f.scale.z*.5+.7})});const a=` 第 ${t+1} 页 共 ${this.total} 页`,l=new Vu(a,!0);l.renderOrder=100,l.position.z+=1.26,this.add(l)}}class cS{constructor(e){ct(this,"load",(e,t)=>{console.log("this.model.name",this.model.name);const i=e.length;e.forEach((s,r)=>{if(t===1){console.log("横排");const o=new oS(this,s,r,i);this.model.add(o)}if(t===2){const o=new lS(this,s,r,i);this.model.add(o)}}),this.scene.scene.add(this.model),this.setArea()});ct(this,"onBindEvent",()=>{this.loadingManager.onStart=(e,t,i)=>{console.log("loading_manager: loading...")},this.loadingManager.onLoad=()=>{console.log("loading_manager: loading complete!"),this.scene.emit("loaded")},this.loadingManager.onProgress=function(e,t,i){},this.loadingManager.onError=function(e){console.error("loading_manager: error loading "+e)}});ct(this,"setVisible",e=>{this.model&&(this.model.visible=e)});ct(this,"setOpacity",e=>{this.material.opacity=e});this.scene=e,this.loadingManager=new Du,this.loader=new wo(this.loadingManager),this.model=new vi,this.model.name="boxManager",this.maps={},this.obb=new Sn,this.imgList=[],this.opacity=1,this.onBindEvent()}setArea(){const e=this.model,t=new Sn().setFromObject(e),i=t.getSize(new P);this.obb=t,console.log("boundingBox-size",i)}}class dS{constructor(){const e=Nh();Object.keys(e).forEach(t=>{this[t]=e[t]})}}function uS(n){for(var e=atob(n.split(",")[1]),t=n.split(",")[0].split(":")[1].split(";")[0],i=new ArrayBuffer(e.length),s=new Uint8Array(i),r=0;r<e.length;r++)s[r]=e.charCodeAt(r);var o=new Blob([i],{type:t});return o}const hS=function(n,e){var t=document.createElement("a");typeof t.download=="string"?(document.body.appendChild(t),t.download=e,t.href=n,t.click(),document.body.removeChild(t)):location.replace(uri)},os=new Nx;class fS extends dS{constructor(t){super();ct(this,"load",(t,i,s)=>{t&&(this.clearScene(),this.sceneType=i,this.boxManager=new cS(this),this.boxManager.load(t,i),this.loadLight(),this.player.load(i,s||[]),this.initCamPView.copy(this.orthCamera.position),this.initCamRView.copy(this.orthCamera.rotation))});ct(this,"loadLight",()=>{const t=new Ym(16777215,1.5);this.scene.add(t)});ct(this,"setCamera",()=>{});ct(this,"toHorizontal",()=>{});ct(this,"toVertical",()=>{});ct(this,"onResize",(t,i)=>{this.width=typeof t=="number"?t:this.domElement.clientWidth,this.height=typeof i=="height"?i:this.domElement.clientHeight;const s=document.querySelector("#canvas"),{width:r,height:o}=s.getBoundingClientRect();r!==this.domElement.clientWidth&&(this.width=r),o!==this.domElement.clientHeight&&(this.height=o),console.warn("onResize",this.width,this.height),this.orthCamera.left=-this.width/2,this.orthCamera.right=this.width/2,this.orthCamera.bottom=-this.height/2,this.orthCamera.top=this.height/2,this.orthCamera.updateProjectionMatrix(),this.renderer.setSize(this.width,this.height),this.renderRes=window.devicePixelRatio,this.defaultUseZoom=this.defaultZoom/this.renderRes,this.renderer.setPixelRatio(this.renderRes)});ct(this,"render",()=>{this.player&&(this.player.update(),this.renderer.render(this.scene,this.orthCamera))});ct(this,"animate",()=>{os.begin(),this.render(),os.end(),requestAnimationFrame(this.animate)});ct(this,"onBindEvent",()=>{window.addEventListener("resize",this.onResize,!1)});this.domElement=t,this.scene=null,this.renderer=null,this.orthCamera=null,this.camera=null,this.player=null,this.sceneType=1,this.width=0,this.height=0,this.defaultZoom=250,this.defaultUseZoom=250/window.devicePixelRatio,this.initCamPView=new P,this.initCamRView=new P,this.blobScreens=[],this.inited=!1,this.init=()=>{this.scene=new Im,this.scene.background=new Ze(15790837),this.renderer=new Ux({canvas:this.domElement,antialias:!0,autoClear:!0,preserveDrawingBuffer:!0}),this.width=this.domElement.clientWidth,this.height=this.domElement.clientHeight,this.renderRes=window.devicePixelRatio,this.defaultUseZoom=this.defaultZoom/window.devicePixelRatio,this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(this.renderRes),console.log("init",this.width,this.height,this.renderRes,this.defaultZoom),this.camera=new vn(70,this.domElement.clientWidth/this.domElement.clientHeight,.1,1e3),this.orthCamera=new Lu(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e3),this.orthCamera.zoom=this.defaultUseZoom,this.orthCamera.position.set(0,10,0),this.orthCamera.lookAt(0,0,0),this.orthCamera.updateProjectionMatrix(),this.player=new sS(this),t.parentNode.appendChild(os.dom),os.dom.style.pointerEvents="none",os.dom.style.left="15%",os.dom.style.display="none",this.onBindEvent(),this.inited=!0,this.load(),this.animate()}}clearScene(){for(var t=this.scene.children.length-1;t>=0;t--){let i=this.scene.children[t];this.scene.remove(i)}}clearDrawScene(){for(var t=this.scene.children.length-1;t>=0;t--){let i=this.scene.children[t];(String(i.name).includes("marker_")||String(i.name).includes("line_")||String(i.name).includes("line_point_")||String(i.name).includes("circle_")||String(i.name).includes("pureText_"))&&this.scene.remove(i)}}deleteItemById(t,i){for(var s=this.scene.children.length-1;s>=0;s--){let r=this.scene.children[s];r.uuid===t&&(console.log("deleteItemById-userData",r.userData),this.player.deleteItemByType(i,r.userData),this.scene.remove(r))}}deleteImageDataByIds(t){this.player.deleteImageDataByIds(t)}lockView(t){t?(this.player.floorplanControls.enablePan=!1,this.player.floorplanControls.enableZoom=!1):(this.player.floorplanControls.enablePan=!0,this.player.floorplanControls.enableZoom=!0)}setMode(t){this.player.setMode(t)}resetCameraView(){this.orthCamera.zoom=this.defaultUseZoom,this.orthCamera.updateMatrixWorld()}editing(t){this.player.editing(t)}endScreenshot(){this.lockView(!1),this.blobScreens=[],this.scene.position.x=0,this.player.floorplanControls.reset(),this.onResize(this.width,this.height)}screenshot(t,i,s){this.orthCamera.zoom=i||this.defaultUseZoom,this.scene.position.x=t||0,this.renderer.setSize(this.width*4,this.height*4),this.renderer.setPixelRatio(this.renderRes),this.orthCamera.aspect=this.width/this.height,this.orthCamera.updateProjectionMatrix(),this.renderer.render(this.scene,this.orthCamera,null,!1);const o=this.renderer.domElement.toDataURL("image/jpeg");console.log("dataURL",o),this.blobScreens.push(uS(o)),console.log(this.width,this.height),typeof s=="number"&&hS(o,`${s}.jpg`),this.renderer.setSize(this.width,this.height)}exportScreenshot(t=!0){if(window.devicePixelRatio!==1){this.emit("devicePixelRatio");return}window.isExportScreenshot=!0,this.player.floorplanControls.reset(),this.onResize(),this.lockView(!0),this.setMode(0);const i=this.boxManager.model,s=i.children.length;if(s===0)return;i.updateMatrixWorld(),this.orthCamera.updateProjectionMatrix();const r=new Sn().setFromObject(i),a=(r.max.x-r.min.x)/s;let l=Math.floor(s/3);if(console.log("slides",l),l>=1&&s>3)for(var c=0;c<=l;c++)(function(d,u){setTimeout(function(){const h=-(a*3*d);console.log("Iteration:",a,d,h,u.defaultUseZoom),u.screenshot(h,u.defaultUseZoom),console.log(`Width: ${h}`),d===l&&(console.log("last"),u.emit("submitScreenshot",t),window.isExportScreenshot=!1)},d*500)})(c,this);else s>=1&&(console.log("total",s),this.player.floorplanControls.reset(),this.screenshot(-.3,227),this.emit("submitScreenshot",t),window.isExportScreenshot=!1)}test(){const t=this.boxManager.model,i=new Sn().setFromObject(t);this.lockView(!0),i.max.x-i.min.x,i.max.y-i.min.y,i.max.z-i.min.z}}var pS=Object.defineProperty,_o=Object.getOwnPropertySymbols,Xu=Object.prototype.hasOwnProperty,Yu=Object.prototype.propertyIsEnumerable,Cd=(n,e,t)=>e in n?pS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,fs=(n,e)=>{for(var t in e||(e={}))Xu.call(e,t)&&Cd(n,t,e[t]);if(_o)for(var t of _o(e))Yu.call(e,t)&&Cd(n,t,e[t]);return n},qu=(n,e)=>{var t={};for(var i in n)Xu.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&_o)for(var i of _o(n))e.indexOf(i)<0&&Yu.call(n,i)&&(t[i]=n[i]);return t};const ju="[vue-draggable-plus]: ";function mS(n){console.warn(ju+n)}function gS(n){console.error(ju+n)}function Rd(n,e,t){return t>=0&&t<n.length&&n.splice(t,0,n.splice(e,1)[0]),n}function _S(n){return n.replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():"")}function vS(n){return Object.keys(n).reduce((e,t)=>(typeof n[t]<"u"&&(e[_S(t)]=n[t]),e),{})}function Pd(n,e){return Array.isArray(n)&&n.splice(e,1),n}function Dd(n,e,t){return Array.isArray(n)&&n.splice(e,0,t),n}function xS(n){return typeof n>"u"}function SS(n){return typeof n=="string"}function Ld(n,e,t){const i=n.children[t];n.insertBefore(e,i)}function Ma(n){n.parentNode&&n.parentNode.removeChild(n)}function yS(n,e=document){var t;let i=null;return typeof(e==null?void 0:e.querySelector)=="function"?i=(t=e==null?void 0:e.querySelector)==null?void 0:t.call(e,n):i=document.querySelector(n),i||mS(`Element not found: ${n}`),i}function MS(n,e,t=null){return function(...i){return n.apply(t,i),e.apply(t,i)}}function ES(n,e){const t=fs({},n);return Object.keys(e).forEach(i=>{t[i]?t[i]=MS(n[i],e[i]):t[i]=e[i]}),t}function bS(n){return n instanceof HTMLElement}function Id(n,e){Object.keys(n).forEach(t=>{e(t,n[t])})}function wS(n){return n.charCodeAt(0)===111&&n.charCodeAt(1)===110&&(n.charCodeAt(2)>122||n.charCodeAt(2)<97)}const TS=Object.assign;/**!
  3967. * Sortable 1.15.2
  3968. * @author RubaXa <trash@rubaxa.org>
  3969. * @author owenm <owen23355@gmail.com>
  3970. * @license MIT
  3971. */function Ud(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,i)}return t}function kn(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ud(Object(t),!0).forEach(function(i){AS(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ud(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function so(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?so=function(e){return typeof e}:so=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},so(n)}function AS(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function si(){return si=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},si.apply(this,arguments)}function CS(n,e){if(n==null)return{};var t={},i=Object.keys(n),s,r;for(r=0;r<i.length;r++)s=i[r],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}function RS(n,e){if(n==null)return{};var t=CS(n,e),i,s;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}var PS="1.15.2";function ei(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var ri=ei(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),sr=ei(/Edge/i),Nd=ei(/firefox/i),Xs=ei(/safari/i)&&!ei(/chrome/i)&&!ei(/android/i),$u=ei(/iP(ad|od|hone)/i),Zu=ei(/chrome/i)&&ei(/android/i),Ku={capture:!1,passive:!1};function $e(n,e,t){n.addEventListener(e,t,!ri&&Ku)}function Ye(n,e,t){n.removeEventListener(e,t,!ri&&Ku)}function vo(n,e){if(e){if(e[0]===">"&&(e=e.substring(1)),n)try{if(n.matches)return n.matches(e);if(n.msMatchesSelector)return n.msMatchesSelector(e);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(e)}catch{return!1}return!1}}function DS(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function Rn(n,e,t,i){if(n){t=t||document;do{if(e!=null&&(e[0]===">"?n.parentNode===t&&vo(n,e):vo(n,e))||i&&n===t)return n;if(n===t)break}while(n=DS(n))}return null}var Od=/\s+/g;function on(n,e,t){if(n&&e)if(n.classList)n.classList[t?"add":"remove"](e);else{var i=(" "+n.className+" ").replace(Od," ").replace(" "+e+" "," ");n.className=(i+(t?" "+e:"")).replace(Od," ")}}function be(n,e,t){var i=n&&n.style;if(i){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(t=n.currentStyle),e===void 0?t:t[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=t+(typeof t=="string"?"":"px")}}function Ss(n,e){var t="";if(typeof n=="string")t=n;else do{var i=be(n,"transform");i&&i!=="none"&&(t=i+" "+t)}while(!e&&(n=n.parentNode));var s=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return s&&new s(t)}function Ju(n,e,t){if(n){var i=n.getElementsByTagName(e),s=0,r=i.length;if(t)for(;s<r;s++)t(i[s],s);return i}return[]}function zn(){var n=document.scrollingElement;return n||document.documentElement}function bt(n,e,t,i,s){if(!(!n.getBoundingClientRect&&n!==window)){var r,o,a,l,c,d,u;if(n!==window&&n.parentNode&&n!==zn()?(r=n.getBoundingClientRect(),o=r.top,a=r.left,l=r.bottom,c=r.right,d=r.height,u=r.width):(o=0,a=0,l=window.innerHeight,c=window.innerWidth,d=window.innerHeight,u=window.innerWidth),(e||t)&&n!==window&&(s=s||n.parentNode,!ri))do if(s&&s.getBoundingClientRect&&(be(s,"transform")!=="none"||t&&be(s,"position")!=="static")){var h=s.getBoundingClientRect();o-=h.top+parseInt(be(s,"border-top-width")),a-=h.left+parseInt(be(s,"border-left-width")),l=o+r.height,c=a+r.width;break}while(s=s.parentNode);if(i&&n!==window){var f=Ss(s||n),g=f&&f.a,_=f&&f.d;f&&(o/=_,a/=g,u/=g,d/=_,l=o+d,c=a+u)}return{top:o,left:a,bottom:l,right:c,width:u,height:d}}}function Fd(n,e,t){for(var i=xi(n,!0),s=bt(n)[e];i;){var r=bt(i)[t],o=void 0;if(o=s>=r,!o)return i;if(i===zn())break;i=xi(i,!1)}return!1}function Cs(n,e,t,i){for(var s=0,r=0,o=n.children;r<o.length;){if(o[r].style.display!=="none"&&o[r]!==we.ghost&&(i||o[r]!==we.dragged)&&Rn(o[r],t.draggable,n,!1)){if(s===e)return o[r];s++}r++}return null}function $l(n,e){for(var t=n.lastElementChild;t&&(t===we.ghost||be(t,"display")==="none"||e&&!vo(t,e));)t=t.previousElementSibling;return t||null}function _n(n,e){var t=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==we.clone&&(!e||vo(n,e))&&t++;return t}function Bd(n){var e=0,t=0,i=zn();if(n)do{var s=Ss(n),r=s.a,o=s.d;e+=n.scrollLeft*r,t+=n.scrollTop*o}while(n!==i&&(n=n.parentNode));return[e,t]}function LS(n,e){for(var t in n)if(n.hasOwnProperty(t)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===n[t][i])return Number(t)}return-1}function xi(n,e){if(!n||!n.getBoundingClientRect)return zn();var t=n,i=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var s=be(t);if(t.clientWidth<t.scrollWidth&&(s.overflowX=="auto"||s.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(s.overflowY=="auto"||s.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return zn();if(i||e)return t;i=!0}}while(t=t.parentNode);return zn()}function IS(n,e){if(n&&e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function Ea(n,e){return Math.round(n.top)===Math.round(e.top)&&Math.round(n.left)===Math.round(e.left)&&Math.round(n.height)===Math.round(e.height)&&Math.round(n.width)===Math.round(e.width)}var Ys;function Qu(n,e){return function(){if(!Ys){var t=arguments,i=this;t.length===1?n.call(i,t[0]):n.apply(i,t),Ys=setTimeout(function(){Ys=void 0},e)}}}function US(){clearTimeout(Ys),Ys=void 0}function eh(n,e,t){n.scrollLeft+=e,n.scrollTop+=t}function th(n){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(n).cloneNode(!0):t?t(n).clone(!0)[0]:n.cloneNode(!0)}function nh(n,e,t){var i={};return Array.from(n.children).forEach(function(s){var r,o,a,l;if(!(!Rn(s,e.draggable,n,!1)||s.animated||s===t)){var c=bt(s);i.left=Math.min((r=i.left)!==null&&r!==void 0?r:1/0,c.left),i.top=Math.min((o=i.top)!==null&&o!==void 0?o:1/0,c.top),i.right=Math.max((a=i.right)!==null&&a!==void 0?a:-1/0,c.right),i.bottom=Math.max((l=i.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var cn="Sortable"+new Date().getTime();function NS(){var n=[],e;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var t=[].slice.call(this.el.children);t.forEach(function(i){if(!(be(i,"display")==="none"||i===we.ghost)){n.push({target:i,rect:bt(i)});var s=kn({},n[n.length-1].rect);if(i.thisAnimationDuration){var r=Ss(i,!0);r&&(s.top-=r.f,s.left-=r.e)}i.fromRect=s}})}},addAnimationState:function(t){n.push(t)},removeAnimationState:function(t){n.splice(LS(n,{target:t}),1)},animateAll:function(t){var i=this;if(!this.options.animation){clearTimeout(e),typeof t=="function"&&t();return}var s=!1,r=0;n.forEach(function(o){var a=0,l=o.target,c=l.fromRect,d=bt(l),u=l.prevFromRect,h=l.prevToRect,f=o.rect,g=Ss(l,!0);g&&(d.top-=g.f,d.left-=g.e),l.toRect=d,l.thisAnimationDuration&&Ea(u,d)&&!Ea(c,d)&&(f.top-d.top)/(f.left-d.left)===(c.top-d.top)/(c.left-d.left)&&(a=FS(f,u,h,i.options)),Ea(d,c)||(l.prevFromRect=c,l.prevToRect=d,a||(a=i.options.animation),i.animate(l,f,d,a)),a&&(s=!0,r=Math.max(r,a),clearTimeout(l.animationResetTimer),l.animationResetTimer=setTimeout(function(){l.animationTime=0,l.prevFromRect=null,l.fromRect=null,l.prevToRect=null,l.thisAnimationDuration=null},a),l.thisAnimationDuration=a)}),clearTimeout(e),s?e=setTimeout(function(){typeof t=="function"&&t()},r):typeof t=="function"&&t(),n=[]},animate:function(t,i,s,r){if(r){be(t,"transition",""),be(t,"transform","");var o=Ss(this.el),a=o&&o.a,l=o&&o.d,c=(i.left-s.left)/(a||1),d=(i.top-s.top)/(l||1);t.animatingX=!!c,t.animatingY=!!d,be(t,"transform","translate3d("+c+"px,"+d+"px,0)"),this.forRepaintDummy=OS(t),be(t,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),be(t,"transform","translate3d(0,0,0)"),typeof t.animated=="number"&&clearTimeout(t.animated),t.animated=setTimeout(function(){be(t,"transition",""),be(t,"transform",""),t.animated=!1,t.animatingX=!1,t.animatingY=!1},r)}}}}function OS(n){return n.offsetWidth}function FS(n,e,t,i){return Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*i.animation}var as=[],ba={initializeByDefault:!0},rr={mount:function(n){for(var e in ba)ba.hasOwnProperty(e)&&!(e in n)&&(n[e]=ba[e]);as.forEach(function(t){if(t.pluginName===n.pluginName)throw"Sortable: Cannot mount plugin ".concat(n.pluginName," more than once")}),as.push(n)},pluginEvent:function(n,e,t){var i=this;this.eventCanceled=!1,t.cancel=function(){i.eventCanceled=!0};var s=n+"Global";as.forEach(function(r){e[r.pluginName]&&(e[r.pluginName][s]&&e[r.pluginName][s](kn({sortable:e},t)),e.options[r.pluginName]&&e[r.pluginName][n]&&e[r.pluginName][n](kn({sortable:e},t)))})},initializePlugins:function(n,e,t,i){as.forEach(function(o){var a=o.pluginName;if(!(!n.options[a]&&!o.initializeByDefault)){var l=new o(n,e,n.options);l.sortable=n,l.options=n.options,n[a]=l,si(t,l.defaults)}});for(var s in n.options)if(n.options.hasOwnProperty(s)){var r=this.modifyOption(n,s,n.options[s]);typeof r<"u"&&(n.options[s]=r)}},getEventProperties:function(n,e){var t={};return as.forEach(function(i){typeof i.eventProperties=="function"&&si(t,i.eventProperties.call(e[i.pluginName],n))}),t},modifyOption:function(n,e,t){var i;return as.forEach(function(s){n[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[e]=="function"&&(i=s.optionListeners[e].call(n[s.pluginName],t))}),i}};function BS(n){var e=n.sortable,t=n.rootEl,i=n.name,s=n.targetEl,r=n.cloneEl,o=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,d=n.oldDraggableIndex,u=n.newDraggableIndex,h=n.originalEvent,f=n.putSortable,g=n.extraEventProperties;if(e=e||t&&t[cn],!!e){var _,m=e.options,p="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!ri&&!sr?_=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(_=document.createEvent("Event"),_.initEvent(i,!0,!0)),_.to=o||t,_.from=a||t,_.item=s||t,_.clone=r,_.oldIndex=l,_.newIndex=c,_.oldDraggableIndex=d,_.newDraggableIndex=u,_.originalEvent=h,_.pullMode=f?f.lastPutMode:void 0;var b=kn(kn({},g),rr.getEventProperties(i,e));for(var y in b)_[y]=b[y];t&&t.dispatchEvent(_),m[p]&&m[p].call(e,_)}}var zS=["evt"],Zt=function(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=t.evt,s=RS(t,zS);rr.pluginEvent.bind(we)(n,e,kn({dragEl:ne,parentEl:_t,ghostEl:Le,rootEl:dt,nextEl:Ui,lastDownEl:ro,cloneEl:ft,cloneHidden:mi,dragStarted:zs,putSortable:Ut,activeSortable:we.active,originalEvent:i,oldIndex:ps,oldDraggableIndex:qs,newIndex:an,newDraggableIndex:fi,hideGhostForTarget:oh,unhideGhostForTarget:ah,cloneNowHidden:function(){mi=!0},cloneNowShown:function(){mi=!1},dispatchSortableEvent:function(r){Vt({sortable:e,name:r,originalEvent:i})}},s))};function Vt(n){BS(kn({putSortable:Ut,cloneEl:ft,targetEl:ne,rootEl:dt,oldIndex:ps,oldDraggableIndex:qs,newIndex:an,newDraggableIndex:fi},n))}var ne,_t,Le,dt,Ui,ro,ft,mi,ps,an,qs,fi,Xr,Ut,ds=!1,xo=!1,So=[],Di,An,wa,Ta,zd,kd,zs,ls,js,$s=!1,Yr=!1,oo,zt,Aa=[],Tl=!1,yo=[],Ao=typeof document<"u",qr=$u,Hd=sr||ri?"cssFloat":"float",kS=Ao&&!Zu&&!$u&&"draggable"in document.createElement("div"),ih=function(){if(Ao){if(ri)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}}(),sh=function(n,e){var t=be(n),i=parseInt(t.width)-parseInt(t.paddingLeft)-parseInt(t.paddingRight)-parseInt(t.borderLeftWidth)-parseInt(t.borderRightWidth),s=Cs(n,0,e),r=Cs(n,1,e),o=s&&be(s),a=r&&be(r),l=o&&parseInt(o.marginLeft)+parseInt(o.marginRight)+bt(s).width,c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+bt(r).width;if(t.display==="flex")return t.flexDirection==="column"||t.flexDirection==="column-reverse"?"vertical":"horizontal";if(t.display==="grid")return t.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&o.float&&o.float!=="none"){var d=o.float==="left"?"left":"right";return r&&(a.clear==="both"||a.clear===d)?"vertical":"horizontal"}return s&&(o.display==="block"||o.display==="flex"||o.display==="table"||o.display==="grid"||l>=i&&t[Hd]==="none"||r&&t[Hd]==="none"&&l+c>i)?"vertical":"horizontal"},HS=function(n,e,t){var i=t?n.left:n.top,s=t?n.right:n.bottom,r=t?n.width:n.height,o=t?e.left:e.top,a=t?e.right:e.bottom,l=t?e.width:e.height;return i===o||s===a||i+r/2===o+l/2},GS=function(n,e){var t;return So.some(function(i){var s=i[cn].options.emptyInsertThreshold;if(!(!s||$l(i))){var r=bt(i),o=n>=r.left-s&&n<=r.right+s,a=e>=r.top-s&&e<=r.bottom+s;if(o&&a)return t=i}}),t},rh=function(n){function e(s,r){return function(o,a,l,c){var d=o.options.group.name&&a.options.group.name&&o.options.group.name===a.options.group.name;if(s==null&&(r||d))return!0;if(s==null||s===!1)return!1;if(r&&s==="clone")return s;if(typeof s=="function")return e(s(o,a,l,c),r)(o,a,l,c);var u=(r?o:a).options.group.name;return s===!0||typeof s=="string"&&s===u||s.join&&s.indexOf(u)>-1}}var t={},i=n.group;(!i||so(i)!="object")&&(i={name:i}),t.name=i.name,t.checkPull=e(i.pull,!0),t.checkPut=e(i.put),t.revertClone=i.revertClone,n.group=t},oh=function(){!ih&&Le&&be(Le,"display","none")},ah=function(){!ih&&Le&&be(Le,"display","")};Ao&&!Zu&&document.addEventListener("click",function(n){if(xo)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),xo=!1,!1},!0);var Li=function(n){if(ne){n=n.touches?n.touches[0]:n;var e=GS(n.clientX,n.clientY);if(e){var t={};for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i]);t.target=t.rootEl=e,t.preventDefault=void 0,t.stopPropagation=void 0,e[cn]._onDragOver(t)}}},VS=function(n){ne&&ne.parentNode[cn]._isOutsideThisEl(n.target)};function we(n,e){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=e=si({},e),n[cn]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return sh(n,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,o){r.setData("Text",o.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:we.supportPointer!==!1&&"PointerEvent"in window&&!Xs,emptyInsertThreshold:5};rr.initializePlugins(this,n,t);for(var i in t)!(i in e)&&(e[i]=t[i]);rh(e);for(var s in this)s.charAt(0)==="_"&&typeof this[s]=="function"&&(this[s]=this[s].bind(this));this.nativeDraggable=e.forceFallback?!1:kS,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?$e(n,"pointerdown",this._onTapStart):($e(n,"mousedown",this._onTapStart),$e(n,"touchstart",this._onTapStart)),this.nativeDraggable&&($e(n,"dragover",this),$e(n,"dragenter",this)),So.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),si(this,NS())}we.prototype={constructor:we,_isOutsideThisEl:function(n){!this.el.contains(n)&&n!==this.el&&(ls=null)},_getDirection:function(n,e){return typeof this.options.direction=="function"?this.options.direction.call(this,n,e,ne):this.options.direction},_onTapStart:function(n){if(n.cancelable){var e=this,t=this.el,i=this.options,s=i.preventOnFilter,r=n.type,o=n.touches&&n.touches[0]||n.pointerType&&n.pointerType==="touch"&&n,a=(o||n).target,l=n.target.shadowRoot&&(n.path&&n.path[0]||n.composedPath&&n.composedPath()[0])||a,c=i.filter;if(KS(t),!ne&&!(/mousedown|pointerdown/.test(r)&&n.button!==0||i.disabled)&&!l.isContentEditable&&!(!this.nativeDraggable&&Xs&&a&&a.tagName.toUpperCase()==="SELECT")&&(a=Rn(a,i.draggable,t,!1),!(a&&a.animated)&&ro!==a)){if(ps=_n(a),qs=_n(a,i.draggable),typeof c=="function"){if(c.call(this,n,a,this)){Vt({sortable:e,rootEl:l,name:"filter",targetEl:a,toEl:t,fromEl:t}),Zt("filter",e,{evt:n}),s&&n.cancelable&&n.preventDefault();return}}else if(c&&(c=c.split(",").some(function(d){if(d=Rn(l,d.trim(),t,!1),d)return Vt({sortable:e,rootEl:d,name:"filter",targetEl:a,fromEl:t,toEl:t}),Zt("filter",e,{evt:n}),!0}),c)){s&&n.cancelable&&n.preventDefault();return}i.handle&&!Rn(l,i.handle,t,!1)||this._prepareDragStart(n,o,a)}}},_prepareDragStart:function(n,e,t){var i=this,s=i.el,r=i.options,o=s.ownerDocument,a;if(t&&!ne&&t.parentNode===s){var l=bt(t);if(dt=s,ne=t,_t=ne.parentNode,Ui=ne.nextSibling,ro=t,Xr=r.group,we.dragged=ne,Di={target:ne,clientX:(e||n).clientX,clientY:(e||n).clientY},zd=Di.clientX-l.left,kd=Di.clientY-l.top,this._lastX=(e||n).clientX,this._lastY=(e||n).clientY,ne.style["will-change"]="all",a=function(){if(Zt("delayEnded",i,{evt:n}),we.eventCanceled){i._onDrop();return}i._disableDelayedDragEvents(),!Nd&&i.nativeDraggable&&(ne.draggable=!0),i._triggerDragStart(n,e),Vt({sortable:i,name:"choose",originalEvent:n}),on(ne,r.chosenClass,!0)},r.ignore.split(",").forEach(function(c){Ju(ne,c.trim(),Ca)}),$e(o,"dragover",Li),$e(o,"mousemove",Li),$e(o,"touchmove",Li),$e(o,"mouseup",i._onDrop),$e(o,"touchend",i._onDrop),$e(o,"touchcancel",i._onDrop),Nd&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ne.draggable=!0),Zt("delayStart",this,{evt:n}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(sr||ri))){if(we.eventCanceled){this._onDrop();return}$e(o,"mouseup",i._disableDelayedDrag),$e(o,"touchend",i._disableDelayedDrag),$e(o,"touchcancel",i._disableDelayedDrag),$e(o,"mousemove",i._delayedDragTouchMoveHandler),$e(o,"touchmove",i._delayedDragTouchMoveHandler),r.supportPointer&&$e(o,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(a,r.delay)}else a()}},_delayedDragTouchMoveHandler:function(n){var e=n.touches?n.touches[0]:n;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){ne&&Ca(ne),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var n=this.el.ownerDocument;Ye(n,"mouseup",this._disableDelayedDrag),Ye(n,"touchend",this._disableDelayedDrag),Ye(n,"touchcancel",this._disableDelayedDrag),Ye(n,"mousemove",this._delayedDragTouchMoveHandler),Ye(n,"touchmove",this._delayedDragTouchMoveHandler),Ye(n,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(n,e){e=e||n.pointerType=="touch"&&n,!this.nativeDraggable||e?this.options.supportPointer?$e(document,"pointermove",this._onTouchMove):e?$e(document,"touchmove",this._onTouchMove):$e(document,"mousemove",this._onTouchMove):($e(ne,"dragend",this),$e(dt,"dragstart",this._onDragStart));try{document.selection?ao(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(n,e){if(ds=!1,dt&&ne){Zt("dragStarted",this,{evt:e}),this.nativeDraggable&&$e(document,"dragover",VS);var t=this.options;!n&&on(ne,t.dragClass,!1),on(ne,t.ghostClass,!0),we.active=this,n&&this._appendGhost(),Vt({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(An){this._lastX=An.clientX,this._lastY=An.clientY,oh();for(var n=document.elementFromPoint(An.clientX,An.clientY),e=n;n&&n.shadowRoot&&(n=n.shadowRoot.elementFromPoint(An.clientX,An.clientY),n!==e);)e=n;if(ne.parentNode[cn]._isOutsideThisEl(n),e)do{if(e[cn]){var t=void 0;if(t=e[cn]._onDragOver({clientX:An.clientX,clientY:An.clientY,target:n,rootEl:e}),t&&!this.options.dragoverBubble)break}n=e}while(e=e.parentNode);ah()}},_onTouchMove:function(n){if(Di){var e=this.options,t=e.fallbackTolerance,i=e.fallbackOffset,s=n.touches?n.touches[0]:n,r=Le&&Ss(Le,!0),o=Le&&r&&r.a,a=Le&&r&&r.d,l=qr&&zt&&Bd(zt),c=(s.clientX-Di.clientX+i.x)/(o||1)+(l?l[0]-Aa[0]:0)/(o||1),d=(s.clientY-Di.clientY+i.y)/(a||1)+(l?l[1]-Aa[1]:0)/(a||1);if(!we.active&&!ds){if(t&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<t)return;this._onDragStart(n,!0)}if(Le){r?(r.e+=c-(wa||0),r.f+=d-(Ta||0)):r={a:1,b:0,c:0,d:1,e:c,f:d};var u="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");be(Le,"webkitTransform",u),be(Le,"mozTransform",u),be(Le,"msTransform",u),be(Le,"transform",u),wa=c,Ta=d,An=s}n.cancelable&&n.preventDefault()}},_appendGhost:function(){if(!Le){var n=this.options.fallbackOnBody?document.body:dt,e=bt(ne,!0,qr,!0,n),t=this.options;if(qr){for(zt=n;be(zt,"position")==="static"&&be(zt,"transform")==="none"&&zt!==document;)zt=zt.parentNode;zt!==document.body&&zt!==document.documentElement?(zt===document&&(zt=zn()),e.top+=zt.scrollTop,e.left+=zt.scrollLeft):zt=zn(),Aa=Bd(zt)}Le=ne.cloneNode(!0),on(Le,t.ghostClass,!1),on(Le,t.fallbackClass,!0),on(Le,t.dragClass,!0),be(Le,"transition",""),be(Le,"transform",""),be(Le,"box-sizing","border-box"),be(Le,"margin",0),be(Le,"top",e.top),be(Le,"left",e.left),be(Le,"width",e.width),be(Le,"height",e.height),be(Le,"opacity","0.8"),be(Le,"position",qr?"absolute":"fixed"),be(Le,"zIndex","100000"),be(Le,"pointerEvents","none"),we.ghost=Le,n.appendChild(Le),be(Le,"transform-origin",zd/parseInt(Le.style.width)*100+"% "+kd/parseInt(Le.style.height)*100+"%")}},_onDragStart:function(n,e){var t=this,i=n.dataTransfer,s=t.options;if(Zt("dragStart",this,{evt:n}),we.eventCanceled){this._onDrop();return}Zt("setupClone",this),we.eventCanceled||(ft=th(ne),ft.removeAttribute("id"),ft.draggable=!1,ft.style["will-change"]="",this._hideClone(),on(ft,this.options.chosenClass,!1),we.clone=ft),t.cloneId=ao(function(){Zt("clone",t),!we.eventCanceled&&(t.options.removeCloneOnHide||dt.insertBefore(ft,ne),t._hideClone(),Vt({sortable:t,name:"clone"}))}),!e&&on(ne,s.dragClass,!0),e?(xo=!0,t._loopId=setInterval(t._emulateDragOver,50)):(Ye(document,"mouseup",t._onDrop),Ye(document,"touchend",t._onDrop),Ye(document,"touchcancel",t._onDrop),i&&(i.effectAllowed="move",s.setData&&s.setData.call(t,i,ne)),$e(document,"drop",t),be(ne,"transform","translateZ(0)")),ds=!0,t._dragStartId=ao(t._dragStarted.bind(t,e,n)),$e(document,"selectstart",t),zs=!0,Xs&&be(document.body,"user-select","none")},_onDragOver:function(n){var e=this.el,t=n.target,i,s,r,o=this.options,a=o.group,l=we.active,c=Xr===a,d=o.sort,u=Ut||l,h,f=this,g=!1;if(Tl)return;function _(G,z){Zt(G,f,kn({evt:n,isOwner:c,axis:h?"vertical":"horizontal",revert:r,dragRect:i,targetRect:s,canSort:d,fromSortable:u,target:t,completed:p,onMove:function(J,se){return jr(dt,e,ne,i,J,bt(J),n,se)},changed:b},z))}function m(){_("dragOverAnimationCapture"),f.captureAnimationState(),f!==u&&u.captureAnimationState()}function p(G){return _("dragOverCompleted",{insertion:G}),G&&(c?l._hideClone():l._showClone(f),f!==u&&(on(ne,Ut?Ut.options.ghostClass:l.options.ghostClass,!1),on(ne,o.ghostClass,!0)),Ut!==f&&f!==we.active?Ut=f:f===we.active&&Ut&&(Ut=null),u===f&&(f._ignoreWhileAnimating=t),f.animateAll(function(){_("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==u&&(u.animateAll(),u._ignoreWhileAnimating=null)),(t===ne&&!ne.animated||t===e&&!t.animated)&&(ls=null),!o.dragoverBubble&&!n.rootEl&&t!==document&&(ne.parentNode[cn]._isOutsideThisEl(n.target),!G&&Li(n)),!o.dragoverBubble&&n.stopPropagation&&n.stopPropagation(),g=!0}function b(){an=_n(ne),fi=_n(ne,o.draggable),Vt({sortable:f,name:"change",toEl:e,newIndex:an,newDraggableIndex:fi,originalEvent:n})}if(n.preventDefault!==void 0&&n.cancelable&&n.preventDefault(),t=Rn(t,o.draggable,e,!0),_("dragOver"),we.eventCanceled)return g;if(ne.contains(n.target)||t.animated&&t.animatingX&&t.animatingY||f._ignoreWhileAnimating===t)return p(!1);if(xo=!1,l&&!o.disabled&&(c?d||(r=_t!==dt):Ut===this||(this.lastPutMode=Xr.checkPull(this,l,ne,n))&&a.checkPut(this,l,ne,n))){if(h=this._getDirection(n,t)==="vertical",i=bt(ne),_("dragOverValid"),we.eventCanceled)return g;if(r)return _t=dt,m(),this._hideClone(),_("revert"),we.eventCanceled||(Ui?dt.insertBefore(ne,Ui):dt.appendChild(ne)),p(!0);var y=$l(e,o.draggable);if(!y||qS(n,h,this)&&!y.animated){if(y===ne)return p(!1);if(y&&e===n.target&&(t=y),t&&(s=bt(t)),jr(dt,e,ne,i,t,s,n,!!t)!==!1)return m(),y&&y.nextSibling?e.insertBefore(ne,y.nextSibling):e.appendChild(ne),_t=e,b(),p(!0)}else if(y&&YS(n,h,this)){var S=Cs(e,0,o,!0);if(S===ne)return p(!1);if(t=S,s=bt(t),jr(dt,e,ne,i,t,s,n,!1)!==!1)return m(),e.insertBefore(ne,S),_t=e,b(),p(!0)}else if(t.parentNode===e){s=bt(t);var C=0,T,D=ne.parentNode!==e,R=!HS(ne.animated&&ne.toRect||i,t.animated&&t.toRect||s,h),E=h?"top":"left",v=Fd(t,"top","top")||Fd(ne,"top","top"),A=v?v.scrollTop:void 0;ls!==t&&(T=s[E],$s=!1,Yr=!R&&o.invertSwap||D),C=jS(n,t,s,h,R?1:o.swapThreshold,o.invertedSwapThreshold==null?o.swapThreshold:o.invertedSwapThreshold,Yr,ls===t);var O;if(C!==0){var L=_n(ne);do L-=C,O=_t.children[L];while(O&&(be(O,"display")==="none"||O===Le))}if(C===0||O===t)return p(!1);ls=t,js=C;var k=t.nextElementSibling,X=!1;X=C===1;var B=jr(dt,e,ne,i,t,s,n,X);if(B!==!1)return(B===1||B===-1)&&(X=B===1),Tl=!0,setTimeout(XS,30),m(),X&&!k?e.appendChild(ne):t.parentNode.insertBefore(ne,X?k:t),v&&eh(v,0,A-v.scrollTop),_t=ne.parentNode,T!==void 0&&!Yr&&(oo=Math.abs(T-bt(t)[E])),b(),p(!0)}if(e.contains(ne))return p(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Ye(document,"mousemove",this._onTouchMove),Ye(document,"touchmove",this._onTouchMove),Ye(document,"pointermove",this._onTouchMove),Ye(document,"dragover",Li),Ye(document,"mousemove",Li),Ye(document,"touchmove",Li)},_offUpEvents:function(){var n=this.el.ownerDocument;Ye(n,"mouseup",this._onDrop),Ye(n,"touchend",this._onDrop),Ye(n,"pointerup",this._onDrop),Ye(n,"touchcancel",this._onDrop),Ye(document,"selectstart",this)},_onDrop:function(n){var e=this.el,t=this.options;if(an=_n(ne),fi=_n(ne,t.draggable),Zt("drop",this,{evt:n}),_t=ne&&ne.parentNode,an=_n(ne),fi=_n(ne,t.draggable),we.eventCanceled){this._nulling();return}ds=!1,Yr=!1,$s=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Al(this.cloneId),Al(this._dragStartId),this.nativeDraggable&&(Ye(document,"drop",this),Ye(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Xs&&be(document.body,"user-select",""),be(ne,"transform",""),n&&(zs&&(n.cancelable&&n.preventDefault(),!t.dropBubble&&n.stopPropagation()),Le&&Le.parentNode&&Le.parentNode.removeChild(Le),(dt===_t||Ut&&Ut.lastPutMode!=="clone")&&ft&&ft.parentNode&&ft.parentNode.removeChild(ft),ne&&(this.nativeDraggable&&Ye(ne,"dragend",this),Ca(ne),ne.style["will-change"]="",zs&&!ds&&on(ne,Ut?Ut.options.ghostClass:this.options.ghostClass,!1),on(ne,this.options.chosenClass,!1),Vt({sortable:this,name:"unchoose",toEl:_t,newIndex:null,newDraggableIndex:null,originalEvent:n}),dt!==_t?(an>=0&&(Vt({rootEl:_t,name:"add",toEl:_t,fromEl:dt,originalEvent:n}),Vt({sortable:this,name:"remove",toEl:_t,originalEvent:n}),Vt({rootEl:_t,name:"sort",toEl:_t,fromEl:dt,originalEvent:n}),Vt({sortable:this,name:"sort",toEl:_t,originalEvent:n})),Ut&&Ut.save()):an!==ps&&an>=0&&(Vt({sortable:this,name:"update",toEl:_t,originalEvent:n}),Vt({sortable:this,name:"sort",toEl:_t,originalEvent:n})),we.active&&((an==null||an===-1)&&(an=ps,fi=qs),Vt({sortable:this,name:"end",toEl:_t,originalEvent:n}),this.save()))),this._nulling()},_nulling:function(){Zt("nulling",this),dt=ne=_t=Le=Ui=ft=ro=mi=Di=An=zs=an=fi=ps=qs=ls=js=Ut=Xr=we.dragged=we.ghost=we.clone=we.active=null,yo.forEach(function(n){n.checked=!0}),yo.length=wa=Ta=0},handleEvent:function(n){switch(n.type){case"drop":case"dragend":this._onDrop(n);break;case"dragenter":case"dragover":ne&&(this._onDragOver(n),WS(n));break;case"selectstart":n.preventDefault();break}},toArray:function(){for(var n=[],e,t=this.el.children,i=0,s=t.length,r=this.options;i<s;i++)e=t[i],Rn(e,r.draggable,this.el,!1)&&n.push(e.getAttribute(r.dataIdAttr)||ZS(e));return n},sort:function(n,e){var t={},i=this.el;this.toArray().forEach(function(s,r){var o=i.children[r];Rn(o,this.options.draggable,i,!1)&&(t[s]=o)},this),e&&this.captureAnimationState(),n.forEach(function(s){t[s]&&(i.removeChild(t[s]),i.appendChild(t[s]))}),e&&this.animateAll()},save:function(){var n=this.options.store;n&&n.set&&n.set(this)},closest:function(n,e){return Rn(n,e||this.options.draggable,this.el,!1)},option:function(n,e){var t=this.options;if(e===void 0)return t[n];var i=rr.modifyOption(this,n,e);typeof i<"u"?t[n]=i:t[n]=e,n==="group"&&rh(t)},destroy:function(){Zt("destroy",this);var n=this.el;n[cn]=null,Ye(n,"mousedown",this._onTapStart),Ye(n,"touchstart",this._onTapStart),Ye(n,"pointerdown",this._onTapStart),this.nativeDraggable&&(Ye(n,"dragover",this),Ye(n,"dragenter",this)),Array.prototype.forEach.call(n.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),So.splice(So.indexOf(this.el),1),this.el=n=null},_hideClone:function(){if(!mi){if(Zt("hideClone",this),we.eventCanceled)return;be(ft,"display","none"),this.options.removeCloneOnHide&&ft.parentNode&&ft.parentNode.removeChild(ft),mi=!0}},_showClone:function(n){if(n.lastPutMode!=="clone"){this._hideClone();return}if(mi){if(Zt("showClone",this),we.eventCanceled)return;ne.parentNode==dt&&!this.options.group.revertClone?dt.insertBefore(ft,ne):Ui?dt.insertBefore(ft,Ui):dt.appendChild(ft),this.options.group.revertClone&&this.animate(ne,ft),be(ft,"display",""),mi=!1}}};function WS(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function jr(n,e,t,i,s,r,o,a){var l,c=n[cn],d=c.options.onMove,u;return window.CustomEvent&&!ri&&!sr?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=n,l.dragged=t,l.draggedRect=i,l.related=s||e,l.relatedRect=r||bt(e),l.willInsertAfter=a,l.originalEvent=o,n.dispatchEvent(l),d&&(u=d.call(c,l,o)),u}function Ca(n){n.draggable=!1}function XS(){Tl=!1}function YS(n,e,t){var i=bt(Cs(t.el,0,t.options,!0)),s=nh(t.el,t.options,Le),r=10;return e?n.clientX<s.left-r||n.clientY<i.top&&n.clientX<i.right:n.clientY<s.top-r||n.clientY<i.bottom&&n.clientX<i.left}function qS(n,e,t){var i=bt($l(t.el,t.options.draggable)),s=nh(t.el,t.options,Le),r=10;return e?n.clientX>s.right+r||n.clientY>i.bottom&&n.clientX>i.left:n.clientY>s.bottom+r||n.clientX>i.right&&n.clientY>i.top}function jS(n,e,t,i,s,r,o,a){var l=i?n.clientY:n.clientX,c=i?t.height:t.width,d=i?t.top:t.left,u=i?t.bottom:t.right,h=!1;if(!o){if(a&&oo<c*s){if(!$s&&(js===1?l>d+c*r/2:l<u-c*r/2)&&($s=!0),$s)h=!0;else if(js===1?l<d+oo:l>u-oo)return-js}else if(l>d+c*(1-s)/2&&l<u-c*(1-s)/2)return $S(e)}return h=h||o,h&&(l<d+c*r/2||l>u-c*r/2)?l>d+c/2?1:-1:0}function $S(n){return _n(ne)<_n(n)?1:-1}function ZS(n){for(var e=n.tagName+n.className+n.src+n.href+n.textContent,t=e.length,i=0;t--;)i+=e.charCodeAt(t);return i.toString(36)}function KS(n){yo.length=0;for(var e=n.getElementsByTagName("input"),t=e.length;t--;){var i=e[t];i.checked&&yo.push(i)}}function ao(n){return setTimeout(n,0)}function Al(n){return clearTimeout(n)}Ao&&$e(document,"touchmove",function(n){(we.active||ds)&&n.cancelable&&n.preventDefault()});we.utils={on:$e,off:Ye,css:be,find:Ju,is:function(n,e){return!!Rn(n,e,n,!1)},extend:IS,throttle:Qu,closest:Rn,toggleClass:on,clone:th,index:_n,nextTick:ao,cancelNextTick:Al,detectDirection:sh,getChild:Cs};we.get=function(n){return n[cn]};we.mount=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(we.utils=kn(kn({},we.utils),i.utils)),rr.mount(i)})};we.create=function(n,e){return new we(n,e)};we.version=PS;var Mt=[],ks,Cl,Rl=!1,Ra,Pa,Mo,Hs;function JS(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return n.prototype={dragStarted:function(e){var t=e.originalEvent;this.sortable.nativeDraggable?$e(document,"dragover",this._handleAutoScroll):this.options.supportPointer?$e(document,"pointermove",this._handleFallbackAutoScroll):t.touches?$e(document,"touchmove",this._handleFallbackAutoScroll):$e(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var t=e.originalEvent;!this.options.dragOverBubble&&!t.rootEl&&this._handleAutoScroll(t)},drop:function(){this.sortable.nativeDraggable?Ye(document,"dragover",this._handleAutoScroll):(Ye(document,"pointermove",this._handleFallbackAutoScroll),Ye(document,"touchmove",this._handleFallbackAutoScroll),Ye(document,"mousemove",this._handleFallbackAutoScroll)),Gd(),lo(),US()},nulling:function(){Mo=Cl=ks=Rl=Hs=Ra=Pa=null,Mt.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,t){var i=this,s=(e.touches?e.touches[0]:e).clientX,r=(e.touches?e.touches[0]:e).clientY,o=document.elementFromPoint(s,r);if(Mo=e,t||this.options.forceAutoScrollFallback||sr||ri||Xs){Da(e,this.options,o,t);var a=xi(o,!0);Rl&&(!Hs||s!==Ra||r!==Pa)&&(Hs&&Gd(),Hs=setInterval(function(){var l=xi(document.elementFromPoint(s,r),!0);l!==a&&(a=l,lo()),Da(e,i.options,l,t)},10),Ra=s,Pa=r)}else{if(!this.options.bubbleScroll||xi(o,!0)===zn()){lo();return}Da(e,this.options,xi(o,!1),!1)}}},si(n,{pluginName:"scroll",initializeByDefault:!0})}function lo(){Mt.forEach(function(n){clearInterval(n.pid)}),Mt=[]}function Gd(){clearInterval(Hs)}var Da=Qu(function(n,e,t,i){if(e.scroll){var s=(n.touches?n.touches[0]:n).clientX,r=(n.touches?n.touches[0]:n).clientY,o=e.scrollSensitivity,a=e.scrollSpeed,l=zn(),c=!1,d;Cl!==t&&(Cl=t,lo(),ks=e.scroll,d=e.scrollFn,ks===!0&&(ks=xi(t,!0)));var u=0,h=ks;do{var f=h,g=bt(f),_=g.top,m=g.bottom,p=g.left,b=g.right,y=g.width,S=g.height,C=void 0,T=void 0,D=f.scrollWidth,R=f.scrollHeight,E=be(f),v=f.scrollLeft,A=f.scrollTop;f===l?(C=y<D&&(E.overflowX==="auto"||E.overflowX==="scroll"||E.overflowX==="visible"),T=S<R&&(E.overflowY==="auto"||E.overflowY==="scroll"||E.overflowY==="visible")):(C=y<D&&(E.overflowX==="auto"||E.overflowX==="scroll"),T=S<R&&(E.overflowY==="auto"||E.overflowY==="scroll"));var O=C&&(Math.abs(b-s)<=o&&v+y<D)-(Math.abs(p-s)<=o&&!!v),L=T&&(Math.abs(m-r)<=o&&A+S<R)-(Math.abs(_-r)<=o&&!!A);if(!Mt[u])for(var k=0;k<=u;k++)Mt[k]||(Mt[k]={});(Mt[u].vx!=O||Mt[u].vy!=L||Mt[u].el!==f)&&(Mt[u].el=f,Mt[u].vx=O,Mt[u].vy=L,clearInterval(Mt[u].pid),(O!=0||L!=0)&&(c=!0,Mt[u].pid=setInterval((function(){i&&this.layer===0&&we.active._onTouchMove(Mo);var X=Mt[this.layer].vy?Mt[this.layer].vy*a:0,B=Mt[this.layer].vx?Mt[this.layer].vx*a:0;typeof d=="function"&&d.call(we.dragged.parentNode[cn],B,X,n,Mo,Mt[this.layer].el)!=="continue"||eh(Mt[this.layer].el,B,X)}).bind({layer:u}),24))),u++}while(e.bubbleScroll&&h!==l&&(h=xi(h,!1)));Rl=c}},30),lh=function(n){var e=n.originalEvent,t=n.putSortable,i=n.dragEl,s=n.activeSortable,r=n.dispatchSortableEvent,o=n.hideGhostForTarget,a=n.unhideGhostForTarget;if(e){var l=t||s;o();var c=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,d=document.elementFromPoint(c.clientX,c.clientY);a(),l&&!l.el.contains(d)&&(r("spill"),this.onSpill({dragEl:i,putSortable:t}))}};function Zl(){}Zl.prototype={startIndex:null,dragStart:function(n){var e=n.oldDraggableIndex;this.startIndex=e},onSpill:function(n){var e=n.dragEl,t=n.putSortable;this.sortable.captureAnimationState(),t&&t.captureAnimationState();var i=Cs(this.sortable.el,this.startIndex,this.options);i?this.sortable.el.insertBefore(e,i):this.sortable.el.appendChild(e),this.sortable.animateAll(),t&&t.animateAll()},drop:lh};si(Zl,{pluginName:"revertOnSpill"});function Kl(){}Kl.prototype={onSpill:function(n){var e=n.dragEl,t=n.putSortable,i=t||this.sortable;i.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),i.animateAll()},drop:lh};si(Kl,{pluginName:"removeOnSpill"});we.mount(new JS);we.mount(Kl,Zl);function QS(n){return n==null?n:JSON.parse(JSON.stringify(n))}function ey(n){Dl()&&Sh(n)}function ty(n){Dl()?Ll(n):Yd(n)}let ch=null,dh=null;function Vd(n=null,e=null){ch=n,dh=e}function ny(){return{data:ch,clonedData:dh}}const Wd=Symbol("cloneElement");function iy(...n){var e,t;const i=(e=Dl())==null?void 0:e.proxy;let s=null;const r=n[0];let[,o,a]=n;Array.isArray(ut(o))||(a=o,o=null);let l=null;const{immediate:c=!0,clone:d=QS,customUpdate:u}=(t=ut(a))!=null?t:{};function h(R){var E;const{from:v,oldIndex:A,item:O}=R;s=Array.from(v.childNodes);const L=ut((E=ut(o))==null?void 0:E[A]),k=d(L);Vd(L,k),O[Wd]=k}function f(R){const E=R.item[Wd];if(!xS(E)){if(Ma(R.item),Po(o)){const v=[...ut(o)];o.value=Dd(v,R.newDraggableIndex,E);return}Dd(ut(o),R.newDraggableIndex,E)}}function g(R){const{from:E,item:v,oldIndex:A,oldDraggableIndex:O,pullMode:L,clone:k}=R;if(Ld(E,v,A),L==="clone"){Ma(k);return}if(Po(o)){const X=[...ut(o)];o.value=Pd(X,O);return}Pd(ut(o),O)}function _(R){if(u){u(R);return}const{from:E,item:v,oldIndex:A,oldDraggableIndex:O,newDraggableIndex:L}=R;if(Ma(v),Ld(E,v,A),Po(o)){const k=[...ut(o)];o.value=Rd(k,O,L);return}Rd(ut(o),O,L)}function m(R){const{newIndex:E,oldIndex:v,from:A,to:O}=R;let L=null;const k=E===v&&A===O;try{if(k){let X=null;s==null||s.some((B,G)=>{if(X&&(s==null?void 0:s.length)!==O.childNodes.length)return A.insertBefore(X,B.nextSibling),!0;const z=O.childNodes[G];X=O==null?void 0:O.replaceChild(B,z)})}}catch(X){L=X}finally{s=null}Yd(()=>{if(Vd(),L)throw L})}const p={onUpdate:_,onStart:h,onAdd:f,onRemove:g,onEnd:m};function b(R){const E=ut(r);return R||(R=SS(E)?yS(E,i==null?void 0:i.$el):E),R&&!bS(R)&&(R=R.$el),R||gS("Root element not found"),R}function y(){var R;const E=(R=ut(a))!=null?R:{},v=qu(E,["immediate","clone"]);return Id(v,(A,O)=>{wS(A)&&(v[A]=(L,...k)=>{const X=ny();return TS(L,X),O(L,...k)})}),ES(o===null?{}:p,v)}const S=R=>{R=b(R),l&&C.destroy(),l=new we(R,y())};co(()=>a,()=>{l&&Id(y(),(R,E)=>{l==null||l.option(R,E)})},{deep:!0});const C={option:(R,E)=>l==null?void 0:l.option(R,E),destroy:()=>{l==null||l.destroy(),l=null},save:()=>l==null?void 0:l.save(),toArray:()=>l==null?void 0:l.toArray(),closest:(...R)=>l==null?void 0:l.closest(...R)},T=()=>C==null?void 0:C.option("disabled",!0),D=()=>C==null?void 0:C.option("disabled",!1);return ty(()=>{c&&S()}),ey(C.destroy),fs({start:S,pause:T,resume:D},C)}const Pl=["update","start","add","remove","choose","unchoose","end","sort","filter","clone","move","change"],sy=["clone","animation","ghostClass","group","sort","disabled","store","handle","draggable","swapThreshold","invertSwap","invertedSwapThreshold","removeCloneOnHide","direction","chosenClass","dragClass","ignore","filter","preventOnFilter","easing","setData","dropBubble","dragoverBubble","dataIdAttr","delay","delayOnTouchOnly","touchStartThreshold","forceFallback","fallbackClass","fallbackOnBody","fallbackTolerance","fallbackOffset","supportPointer","emptyInsertThreshold","scroll","forceAutoScrollFallback","scrollSensitivity","scrollSpeed","bubbleScroll","modelValue","tag","target","customUpdate",...Pl.map(n=>`on${n.replace(/^\S/,e=>e.toUpperCase())}`)],ry=Xd({name:"VueDraggable",model:{prop:"modelValue",event:"update:modelValue"},props:sy,emits:["update:modelValue",...Pl],setup(n,{slots:e,emit:t,expose:i,attrs:s}){const r=Pl.reduce((d,u)=>{const h=`on${u.replace(/^\S/,f=>f.toUpperCase())}`;return d[h]=(...f)=>t(u,...f),d},{}),o=Zs(()=>{const d=vh(n),u=qu(d,["modelValue"]),h=Object.entries(u).reduce((f,[g,_])=>{const m=ut(_);return m!==void 0&&(f[g]=m),f},{});return fs(fs({},r),vS(fs(fs({},s),h)))}),a=Zs({get:()=>n.modelValue,set:d=>t("update:modelValue",d)}),l=Kt(),c=$r(iy(n.target||l,a,o));return i(c),()=>{var d;return xh(n.tag||"div",{ref:l},(d=e==null?void 0:e.default)==null?void 0:d.call(e,c))}}}),oy={class:"VueDraggable"},ay=["onClick"],ly=["src"],cy={class:"text"},dy=["title"],uy=Xd({__name:"draggable",props:{sortType:Boolean,caseId:Number},emits:["changeList","handleItem"],setup(n,{expose:e,emit:t}){const i=n,s=t,r=Kt([]),o=Kt(""),a=Zs(()=>{let g=o.value.toLowerCase();return r.value.filter(_=>{var m;return(m=_.imgInfo)==null?void 0:m.toLowerCase().includes(g)})});co(()=>i.sortType,(g,_)=>{s("changeList",r.value)},{deep:!0,immediate:!0});async function l({newIndex:g,oldIndex:_}){if(o.value){yh("搜索状态禁止拖动");return}const m=Array.from(r.value).filter((p,b)=>b===g||b===_).reduce((p,b)=>p.concat(b.id),[]);console.log("draggable-imageIDs",m),s("delImage",m),setTimeout(async()=>{let p=a.value.map((b,y)=>({...b,sort:y+1}));console.log(p,"apiList"),await Ch(p),s("changeList",p)},500)}function c(g){setTimeout(()=>{let _=r.value.findIndex(m=>m.id===g);console.log(_,r.value),s("handleItem",_)},500)}function d(g){console.log("handleSearch",g,o.value)}async function u(){let g=await Rh(i.caseId,"desc");r.value=g.data,s("changeList",r.value)}async function h(g,_){await La.confirm("删除图像后会重新排版并清空标记数据,是否继续?","温馨提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"default"})&&Ph(_).then(p=>{s("delImage",[_]),r.value.splice(g,1),s("changeList",r.value)})}async function f(g){await Ih({caseId:i.caseId,data:{...g}}),u()}return Ll(()=>{u()}),e({getList:u}),(g,_)=>{const m=Jt("el-input"),p=Jt("EditPen"),b=Jt("CircleCloseFilled"),y=Jt("el-empty");return Pn(),ms("div",oy,[at(m,{onChange:d,clearable:"",size:"medium",placeholder:"请输入内容","suffix-icon":"search",modelValue:o.value,"onUpdate:modelValue":_[0]||(_[0]=S=>o.value=S),class:"input-with-select"},null,8,["modelValue"]),r.value.length?(Pn(),Gs(ut(ry),{key:0,move:o.value?!1:null,class:"draggable",ref:"el",modelValue:r.value,"onUpdate:modelValue":_[1]||(_[1]=S=>r.value=S),onSort:l},{default:Et(()=>[(Pn(!0),ms(qd,null,jd(o.value?a.value:r.value,(S,C)=>(Pn(),ms("div",{class:"item",key:S.id,onClick:T=>c(S.id)},[gn("img",{class:"itemImg",src:ut(Ia)({type:102})+"/"+S.imgUrl,alt:""},null,8,ly),gn("div",cy,[gn("div",{title:S.imgInfo},$d(S.imgInfo),9,dy),at(p,{onClick:rc(T=>f(S),["stop"]),class:"EditPen"},null,8,["onClick"])]),at(b,{onClick:rc(T=>h(C,S.id),["stop"]),class:"itemIcon"},null,8,["onClick"])],8,ay))),128))]),_:1},8,["move","modelValue"])):(Pn(),Gs(y,{key:1,class:"empty",description:"请上传现场照片"}))])}}});const hy=Zd(uy,[["__scopeId","data-v-9f7dcba5"]]);const fy={key:0,class:"layout"},py={__name:"edit",props:{show:Boolean,data:Object},emits:["update","del","close"],setup(n,{emit:e}){const t=Kt(!1),i=n,s=e,r=["#ff0f00","#ffbe00","#1a9bff","#1aad19","#000000","#ffffff","#666666"];co(i,({show:f,data:g})=>{t.value=f,a.text=g.text,a.id=g.id,a.type=g.type,a.pos=g.pos,a.fontsize=g.fontsize||12,console.log("data",g)},{deep:!0});const o={id:"",text:"",fontsize:12,type:null,pos:null,color:"#000000"};let a=$r(o);co(a,()=>{u()},{deep:!0});const l=[8,30],c=[];for(let f=l[0];f<=l[1];f++)c.push({value:f,label:f.toString()});const d=()=>{t.value=!1,s("close",a),a=$r(o)},u=()=>{s("update",a)},h=()=>{t.value=!1,s("del",a),a=$r(o)};return(f,g)=>{const _=Jt("Close"),m=Jt("el-icon"),p=Jt("el-input"),b=Jt("el-form-item"),y=Jt("el-option"),S=Jt("el-select"),C=Jt("el-color-picker"),T=Jt("el-button"),D=Jt("el-form");return t.value?(Pn(),ms("div",fy,[at(m,{class:"close",onClick:d},{default:Et(()=>[at(_)]),_:1}),at(D,{inline:!0,model:ut(a),"label-width":"auto"},{default:Et(()=>[at(b,{label:"内容"},{default:Et(()=>[at(p,{type:"input",maxlength:40,modelValue:ut(a).text,"onUpdate:modelValue":g[0]||(g[0]=R=>ut(a).text=R)},null,8,["modelValue"])]),_:1}),at(b,{label:"字号:"},{default:Et(()=>[at(S,{modelValue:ut(a).fontsize,"onUpdate:modelValue":g[1]||(g[1]=R=>ut(a).fontsize=R),placeholder:"选择字号",style:{width:"200px"}},{default:Et(()=>[(Pn(),ms(qd,null,jd(c,R=>at(y,Mh({ref_for:!0},R,{key:R.value}),null,16)),64))]),_:1},8,["modelValue"])]),_:1}),at(b,{label:"颜色:"},{default:Et(()=>[at(C,{modelValue:ut(a).color,"onUpdate:modelValue":g[2]||(g[2]=R=>ut(a).color=R),"color-format":"rgba","show-alpha":"",predefine:r},null,8,["modelValue"])]),_:1}),at(b,{label:"删除:"},{default:Et(()=>[at(T,{type:"primary",onClick:h},{default:Et(()=>g[3]||(g[3]=[mn("删除")])),_:1})]),_:1})]),_:1},8,["model"])])):Zr("",!0)}}};const my={class:"photo"},gy={class:"left"},_y={class:"upload my-photo-upload"},vy={class:"right"},xy={class:"tools"},Sy={id:"canvas"},yy={__name:"index",props:{caseId:Number,title:String},setup(n){const e=Zs(()=>{var B,G;return(G=(B=oc.currentRoute.value)==null?void 0:B.params)==null?void 0:G.caseId}),t=Kt({show:!1,data:{}}),i=Kt([]);Kt([]),Kt(null);const s=Kt(null),r=Kt(!1),o=Kt(!1),a=Kt(0),l=Zs(()=>a.value>0),c=Kt(),d=Kt(!1);let u=null;const h=async()=>{await Uh({caseId:e.value,data:{imgUrl:"",imgInfo:"",id:"",sort:""}}),f()};function f(){console.log("changeList",s.value),s.value&&s.value.getList()}const g=async B=>{const G=B.map(ae=>({...ae,imgUrl:Ia({type:102})+"/"+ae.imgUrl}));if(!c.value){const ae=await Dh(e.value);ae.data?(ae.data.data&&(c.value=ae.data.data),"isHorizontal"in ae.data&&(o.value=!ae.data.isHorizontal)):c.value=[]}let z=[];G.map((ae,Ce)=>{if(o.value)z.push([ae]);else if(Ce%2==0){let Qe=G[Ce+1]?[ae,G[Ce+1]]:[ae];z.push(Qe)}}),i.value=z,console.log("changeListnewList",i.value);const J=[];z.map(ae=>J.push(JSON.parse(JSON.stringify(ae))));const se=o.value?2:1;u&&(u.load(J,se,c.value||[]),console.log("changeList",J,se,c.value))},_=()=>{const B=document.getElementById("canvas");B&&(u=new fS(B),u.init(),window.scene=u,u.on("mode",G=>{console.warn("mode",G),a.value=G}),u.on("markerExist",()=>{Do.error("该案件已有方向标注!")}),u.on("confirmDelete",async({id:G,type:z})=>{await La.confirm("是否删除该部件?","温馨提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"default"})&&window.scene.deleteItemById(G,z)}),u.on("data",G=>{let z=!1;Object.keys(G).forEach(J=>{Array.isArray(G[J])&&G[J].length>0&&(z=!0)}),d.value=z,console.log("sync",G,z),c.value=G}),u.on("edit",G=>{console.log("editData",G),t.value.show=!0,t.value.data=G}),u.on("devicePixelRatio",()=>{Do.error(`当前浏览器缩放${Math.floor(window.devicePixelRatio*100)}%比例,请设置缩放比例为100%,方可正常导出`)}),u.on("loaded",()=>{r.value=!0}),u.on("autoSave",()=>{console.log("autoSave"),R()}),u.on("submitScreenshot",G=>{if(window.scene){const z={files:window.scene.blobScreens.map((J,se)=>new File([J],`${Date.now()}-${se}.jpg`)),caseId:e.value};console.log("params",z,window.scene),setTimeout(async()=>{try{const J=await Lh(z);console.log("res",J);const{data:se,code:ae}=J,Ce="照片卷.jpg";se&&se.imgUrl&&G&&Oh(Ia({type:102})+"/"+se.imgUrl,Ce),window.scene.endScreenshot(),r.value=!0}catch{window.scene.endScreenshot(),r.value=!0}},500)}}))},m=B=>{let G=o.value?B:Math.floor(B/2);console.log("handleItem",B,G)},p=async()=>{await La.confirm("切换模版不包括标注内容,确定要切换吗?","温馨提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"default"})&&(o.value=!o.value,window.scene.setMode(0),window.scene.clearScene(),v())},b=()=>{window.scene&&window.scene.setMode(1)},y=()=>{window.scene&&window.scene.setMode(2)},S=()=>{oc.replace({name:bh.material,params:{caseId:e.value}})},C=()=>{window.scene&&window.scene.setMode(3)},T=()=>{window.scene&&window.scene.setMode(4)},D=async()=>{if(window.scene){const B=u.player.getDrawData();u.player.syncDrawData(),console.log("data",B);const G=await ac({caseId:e.value,data:B,isHorizontal:!o.value});console.log("res",G),i.value.length>0&&!window.isExportScreenshot&&window.scene.exportScreenshot(!1),Do.success("保存成功!")}},R=async()=>{if(window.scene){const B=u.player.getDrawData();u.player.syncDrawData(),await ac({caseId:e.value,data:B,isHorizontal:!o.value})}},E=()=>{window.scene&&window.scene.setMode(0)},v=()=>{window.scene&&window.scene.player.clear()},A=B=>{window.scene&&window.scene.editing(B)},O=B=>{if(window.scene){const{id:G,type:z}=B;console.log("handleEditingDel",B),window.scene.deleteItemById(G,z),window.scene.setMode(0)}},L=()=>{window.scene.setMode(0)},k=B=>{console.log("handleImageDel",B),window.scene&&window.scene.deleteImageDataByIds(B)},X=()=>{window.scene&&(window.isExportScreenshot||(r.value=!1,window.scene.exportScreenshot()))};return Ll(()=>{_(),console.warn("renderCanvas")}),(B,G)=>{const z=Jt("el-button");return Pn(),ms("div",my,[gn("div",gy,[gn("div",_y,[at(z,{type:"primary",onClick:h},{default:Et(()=>G[0]||(G[0]=[mn(" 上传照片 ")])),_:1}),at(z,{type:"primary",onClick:p,icon:o.value?ut(wh):ut(Th)},{default:Et(()=>[mn($d(o.value?"横排":"竖排"),1)]),_:1},8,["icon"])]),at(hy,{ref_key:"childRef",ref:s,caseId:e.value,sortType:o.value,onChangeList:g,onHandleItem:m,onDelImage:k},null,8,["caseId","sortType"])]),gn("div",vy,[gn("div",xy,[at(z,{onClick:y},{default:Et(()=>G[1]||(G[1]=[gn("i",{class:"iconfont icon-arrows1"},null,-1),mn(" 箭头 ")])),_:1}),at(z,{onClick:b},{default:Et(()=>G[2]||(G[2]=[gn("i",{class:"iconfont icon-index"},null,-1),mn(" 标引 ")])),_:1}),at(z,{onClick:C},{default:Et(()=>G[3]||(G[3]=[gn("i",{class:"iconfont icon-symbol"},null,-1),mn(" 符号 ")])),_:1}),at(z,{onClick:T},{default:Et(()=>G[4]||(G[4]=[gn("i",{class:"iconfont icon-text1"},null,-1),mn(" 文本")])),_:1}),at(z,{onClick:D},{default:Et(()=>G[5]||(G[5]=[mn("保存")])),_:1}),i.value.length?(Pn(),Gs(z,{key:0,onClick:X,loading:!r.value,disabled:!r.value},{default:Et(()=>G[6]||(G[6]=[mn("导出")])),_:1},8,["loading","disabled"])):Zr("",!0),at(z,{onClick:S},{default:Et(()=>G[7]||(G[7]=[mn("返回")])),_:1}),d.value?(Pn(),Gs(z,{key:1,onClick:v},{default:Et(()=>G[8]||(G[8]=[mn("清空")])),_:1})):Zr("",!0),l.value?(Pn(),Gs(z,{key:2,onClick:E},{default:Et(()=>G[9]||(G[9]=[mn("退出编辑")])),_:1})):Zr("",!0)]),Eh(gn("canvas",Sy,null,512),[[Ah,!0]]),at(py,{show:t.value.show,data:t.value.data,onUpdate:A,onDel:O,onClose:L},null,8,["show","data"])])])}}},zy=Zd(yy,[["__scopeId","data-v-4176868e"]]);export{zy as default};