three.min.js 659 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802
  1. /**
  2. * @license
  3. * Copyright 2010-2024 Three.js Authors
  4. * SPDX-License-Identifier: MIT
  5. */const hr="165",pf={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},mf={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},fc=0,Za=1,pc=2,gf=3,_f=0,Ja=1,mc=2,ln=3,mn=0,Pe=1,cn=2,gn=0,Qn=1,$a=2,Ka=3,Qa=4,gc=5,Dn=100,_c=101,xc=102,vc=103,yc=104,Mc=200,Sc=201,bc=202,Ac=203,ur=204,dr=205,wc=206,Ec=207,Tc=208,Cc=209,Rc=210,Pc=211,Ic=212,Lc=213,Uc=214,Dc=0,Nc=1,Fc=2,us=3,Oc=4,Bc=5,zc=6,kc=7,ds=0,Vc=1,Hc=2,_n=0,Gc=1,Wc=2,Xc=3,qc=4,Yc=5,Zc=6,Jc=7,ja="attached",$c="detached",fr=300,xn=301,Nn=302,fs=303,ps=304,Ri=306,ms=1e3,Ze=1001,gs=1002,Me=1003,to=1004,xf=1004,Pi=1005,vf=1005,pe=1006,_s=1007,yf=1007,hn=1008,Mf=1008,vn=1009,Kc=1010,Qc=1011,xs=1012,eo=1013,jn=1014,Ve=1015,vs=1016,no=1017,io=1018,ti=1020,jc=35902,th=1021,eh=1022,Fe=1023,nh=1024,ih=1025,ei=1026,ni=1027,so=1028,ro=1029,sh=1030,ao=1031,oo=1033,pr=33776,mr=33777,gr=33778,_r=33779,lo=35840,co=35841,ho=35842,uo=35843,fo=36196,po=37492,mo=37496,go=37808,_o=37809,xo=37810,vo=37811,yo=37812,Mo=37813,So=37814,bo=37815,Ao=37816,wo=37817,Eo=37818,To=37819,Co=37820,Ro=37821,xr=36492,Po=36494,Io=36495,rh=36283,Lo=36284,Uo=36285,Do=36286,ah=2200,oh=2201,lh=2202,ys=2300,vr=2301,yr=2302,ii=2400,si=2401,Ms=2402,Mr=2500,No=2501,Sf=0,bf=1,Af=2,ch=3200,hh=3201,Fn=0,uh=1,yn="",Je="srgb",Mn="srgb-linear",Sr="display-p3",Ss="display-p3-linear",bs="linear",se="srgb",As="rec709",ws="p3",wf=0,ri=7680,Ef=7681,Tf=7682,Cf=7683,Rf=34055,Pf=34056,If=5386,Lf=512,Uf=513,Df=514,Nf=515,Ff=516,Of=517,Bf=518,Fo=519,dh=512,fh=513,ph=514,Oo=515,mh=516,gh=517,_h=518,xh=519,Es=35044,zf=35048,kf=35040,Vf=35045,Hf=35049,Gf=35041,Wf=35046,Xf=35050,qf=35042,Yf="100",Bo="300 es",un=2e3,Ts=2001;class Sn{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,t);t.target=null}}}const Ae=["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 vh=1234567;const ai=Math.PI/180,Ii=180/Math.PI;function He(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ae[r&255]+Ae[r>>8&255]+Ae[r>>16&255]+Ae[r>>24&255]+"-"+Ae[t&255]+Ae[t>>8&255]+"-"+Ae[t>>16&15|64]+Ae[t>>24&255]+"-"+Ae[e&63|128]+Ae[e>>8&255]+"-"+Ae[e>>16&255]+Ae[e>>24&255]+Ae[n&255]+Ae[n>>8&255]+Ae[n>>16&255]+Ae[n>>24&255]).toLowerCase()}function le(r,t,e){return Math.max(t,Math.min(e,r))}function zo(r,t){return(r%t+t)%t}function Zf(r,t,e,n,i){return n+(r-t)*(i-n)/(e-t)}function Jf(r,t,e){return r!==t?(e-r)/(t-r):0}function Cs(r,t,e){return(1-e)*r+e*t}function $f(r,t,e,n){return Cs(r,t,1-Math.exp(-e*n))}function Kf(r,t=1){return t-Math.abs(zo(r,t*2)-t)}function Qf(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function jf(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function tp(r,t){return r+Math.floor(Math.random()*(t-r+1))}function ep(r,t){return r+Math.random()*(t-r)}function np(r){return r*(.5-Math.random())}function ip(r){r!==void 0&&(vh=r);let t=vh+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function sp(r){return r*ai}function rp(r){return r*Ii}function ap(r){return(r&r-1)===0&&r!==0}function op(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function lp(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function cp(r,t,e,n,i){const s=Math.cos,a=Math.sin,o=s(e/2),l=a(e/2),c=s((t+n)/2),h=a((t+n)/2),u=s((t-n)/2),d=a((t-n)/2),f=s((n-t)/2),m=a((n-t)/2);switch(i){case"XYX":r.set(o*h,l*u,l*d,o*c);break;case"YZY":r.set(l*d,o*h,l*u,o*c);break;case"ZXZ":r.set(l*u,l*d,o*h,o*c);break;case"XZX":r.set(o*h,l*m,l*f,o*c);break;case"YXY":r.set(l*f,o*h,l*m,o*c);break;case"ZYZ":r.set(l*m,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ie(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Ot(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const hp={DEG2RAD:ai,RAD2DEG:Ii,generateUUID:He,clamp:le,euclideanModulo:zo,mapLinear:Zf,inverseLerp:Jf,lerp:Cs,damp:$f,pingpong:Kf,smoothstep:Qf,smootherstep:jf,randInt:tp,randFloat:ep,randFloatSpread:np,seededRandom:ip,degToRad:sp,radToDeg:rp,isPowerOfTwo:ap,ceilPowerOfTwo:op,floorPowerOfTwo:lp,setQuaternionFromProperEuler:cp,normalize:Ot,denormalize:Ie};class Y{constructor(t=0,e=0){Y.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(le(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*n-a*i+t.x,this.y=s*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Bt{constructor(t,e,n,i,s,a,o,l,c){Bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,a,o,l,c)}set(t,e,n,i,s,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],_=i[0],g=i[3],p=i[6],v=i[1],x=i[4],y=i[7],P=i[2],w=i[5],T=i[8];return s[0]=a*_+o*v+l*P,s[3]=a*g+o*x+l*w,s[6]=a*p+o*y+l*T,s[1]=c*_+h*v+u*P,s[4]=c*g+h*x+u*w,s[7]=c*p+h*y+u*T,s[2]=d*_+f*v+m*P,s[5]=d*g+f*x+m*w,s[8]=d*p+f*y+m*T,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*s*h+n*o*l+i*s*c-i*a*l}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*s,f=c*s-a*l,m=e*u+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/m;return t[0]=u*_,t[1]=(i*c-h*n)*_,t[2]=(o*n-i*a)*_,t[3]=d*_,t[4]=(h*e-i*l)*_,t[5]=(i*s-o*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(a*e-n*s)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-i*c,i*l,-i*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(ko.makeScale(t,e)),this}rotate(t){return this.premultiply(ko.makeRotation(-t)),this}translate(t,e){return this.premultiply(ko.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const ko=new Bt;function yh(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}const up={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Li(r,t){return new up[r](t)}function Rs(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function Mh(){const r=Rs("canvas");return r.style.display="block",r}const Sh={};function Vo(r){r in Sh||(Sh[r]=!0,console.warn(r))}function dp(r,t,e){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}const bh=new Bt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ah=new Bt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),br={[Mn]:{transfer:bs,primaries:As,toReference:r=>r,fromReference:r=>r},[Je]:{transfer:se,primaries:As,toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[Ss]:{transfer:bs,primaries:ws,toReference:r=>r.applyMatrix3(Ah),fromReference:r=>r.applyMatrix3(bh)},[Sr]:{transfer:se,primaries:ws,toReference:r=>r.convertSRGBToLinear().applyMatrix3(Ah),fromReference:r=>r.applyMatrix3(bh).convertLinearToSRGB()}},fp=new Set([Mn,Ss]),Kt={enabled:!0,_workingColorSpace:Mn,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!fp.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,t,e){if(this.enabled===!1||t===e||!t||!e)return r;const n=br[t].toReference,i=br[e].fromReference;return i(n(r))},fromWorkingColorSpace:function(r,t){return this.convert(r,this._workingColorSpace,t)},toWorkingColorSpace:function(r,t){return this.convert(r,t,this._workingColorSpace)},getPrimaries:function(r){return br[r].primaries},getTransfer:function(r){return r===yn?bs:br[r].transfer}};function Ui(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Ho(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Di;class wh{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Di===void 0&&(Di=Rs("canvas")),Di.width=t.width,Di.height=t.height;const n=Di.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Di}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Rs("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=Ui(s[a]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Ui(e[n]/255)*255):e[n]=Ui(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let pp=0;class oi{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:pp++}),this.uuid=He(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(Go(i[a].image)):s.push(Go(i[a]))}else s=Go(i);n.url=s}return e||(t.images[this.uuid]=n),n}}function Go(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?wh.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let mp=0;class he extends Sn{constructor(t=he.DEFAULT_IMAGE,e=he.DEFAULT_MAPPING,n=Ze,i=Ze,s=pe,a=hn,o=Fe,l=vn,c=he.DEFAULT_ANISOTROPY,h=yn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mp++}),this.uuid=He(),this.name="",this.source=new oi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Y(0,0),this.repeat=new Y(1,1),this.center=new Y(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Bt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}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(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==fr)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ms:t.x=t.x-Math.floor(t.x);break;case Ze:t.x=t.x<0?0:1;break;case gs:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ms:t.y=t.y-Math.floor(t.y);break;case Ze:t.y=t.y<0?0:1;break;case gs:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}he.DEFAULT_IMAGE=null,he.DEFAULT_MAPPING=fr,he.DEFAULT_ANISOTROPY=1;class ee{constructor(t=0,e=0,n=0,i=1){ee.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,s;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],m=l[9],_=l[2],g=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const x=(c+1)/2,y=(f+1)/2,P=(p+1)/2,w=(h+d)/4,T=(u+_)/4,R=(m+g)/4;return x>y&&x>P?x<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(x),i=w/n,s=T/n):y>P?y<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(y),n=w/i,s=R/i):P<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(P),n=T/s,i=R/s),this.set(n,i,s,e),this}let v=Math.sqrt((g-m)*(g-m)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(u-_)/v,this.z=(d-h)/v,this.w=Math.acos((c+f+p-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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 Eh extends Sn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new ee(0,0,t,e),this.scissorTest=!1,this.viewport=new ee(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:pe,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new he(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,i=t.textures.length;n<i;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new oi(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ke extends Eh{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Ar extends he{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Me,this.minFilter=Me,this.wrapR=Ze,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class gp extends Ke{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Ar(null,t,e,n),this.texture.isRenderTargetTexture=!0}}class Wo extends he{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=Me,this.minFilter=Me,this.wrapR=Ze,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class _p extends Ke{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Wo(null,t,e,n),this.texture.isRenderTargetTexture=!0}}class Oe{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,a,o){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3];const d=s[a+0],f=s[a+1],m=s[a+2],_=s[a+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=f,t[e+2]=m,t[e+3]=_;return}if(u!==_||l!==d||c!==f||h!==m){let g=1-o;const p=l*d+c*f+h*m+u*_,v=p>=0?1:-1,x=1-p*p;if(x>Number.EPSILON){const P=Math.sqrt(x),w=Math.atan2(P,p*v);g=Math.sin(g*w)/P,o=Math.sin(o*w)/P}const y=o*v;if(l=l*g+d*y,c=c*g+f*y,h=h*g+m*y,u=u*g+_*y,g===1-o){const P=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=P,c*=P,h*=P,u*=P}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[a],d=s[a+1],f=s[a+2],m=s[a+3];return t[e]=o*m+h*u+l*f-c*d,t[e+1]=l*m+h*d+c*u-o*f,t[e+2]=c*m+h*f+o*d-l*u,t[e+3]=h*m-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,s=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),u=o(s/2),d=l(n/2),f=l(i/2),m=l(s/2);switch(a){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],s=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(s+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(s-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(le(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,s=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+i*c-s*l,this._y=i*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*t._w+n*t._x+i*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-e;return this._w=f*a+e*this._w,this._x=f*n+e*this._x,this._y=f*i+e*this._y,this._z=f*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class E{constructor(t=0,e=0,n=0){E.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Th.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Th.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=t.elements,a=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,s=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*i-o*n),h=2*(o*e-s*i),u=2*(s*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-s*u,this.z=i+l*u+s*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,s=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-s*o,this.y=s*a-n*l,this.z=n*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Xo.copy(this).projectOnVector(t),this.sub(Xo)}reflect(t){return this.sub(Xo.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(le(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Xo=new E,Th=new Oe;class Le{constructor(t=new E(1/0,1/0,1/0),e=new E(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Qe.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Qe.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Qe.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Qe):Qe.fromBufferAttribute(s,a),Qe.applyMatrix4(t.matrixWorld),this.expandByPoint(Qe);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),wr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),wr.copy(n.boundingBox)),wr.applyMatrix4(t.matrixWorld),this.union(wr)}const i=t.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Qe),Qe.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ps),Er.subVectors(this.max,Ps),Ni.subVectors(t.a,Ps),Fi.subVectors(t.b,Ps),Oi.subVectors(t.c,Ps),On.subVectors(Fi,Ni),Bn.subVectors(Oi,Fi),li.subVectors(Ni,Oi);let e=[0,-On.z,On.y,0,-Bn.z,Bn.y,0,-li.z,li.y,On.z,0,-On.x,Bn.z,0,-Bn.x,li.z,0,-li.x,-On.y,On.x,0,-Bn.y,Bn.x,0,-li.y,li.x,0];return!qo(e,Ni,Fi,Oi,Er)||(e=[1,0,0,0,1,0,0,0,1],!qo(e,Ni,Fi,Oi,Er))?!1:(Tr.crossVectors(On,Bn),e=[Tr.x,Tr.y,Tr.z],qo(e,Ni,Fi,Oi,Er))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Qe).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Qe).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(bn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),bn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),bn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),bn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),bn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),bn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),bn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),bn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(bn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const bn=[new E,new E,new E,new E,new E,new E,new E,new E],Qe=new E,wr=new Le,Ni=new E,Fi=new E,Oi=new E,On=new E,Bn=new E,li=new E,Ps=new E,Er=new E,Tr=new E,ci=new E;function qo(r,t,e,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){ci.fromArray(r,s);const o=i.x*Math.abs(ci.x)+i.y*Math.abs(ci.y)+i.z*Math.abs(ci.z),l=t.dot(ci),c=e.dot(ci),h=n.dot(ci);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const xp=new Le,Is=new E,Yo=new E;class we{constructor(t=new E,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):xp.setFromPoints(t).getCenter(n);let i=0;for(let s=0,a=t.length;s<a;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Is.subVectors(t,this.center);const e=Is.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Is,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Yo.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Is.copy(t.center).add(Yo)),this.expandByPoint(Is.copy(t.center).sub(Yo))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const An=new E,Zo=new E,Cr=new E,zn=new E,Jo=new E,Rr=new E,$o=new E;class Bi{constructor(t=new E,e=new E(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,An)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=An.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(An.copy(this.origin).addScaledVector(this.direction,e),An.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Zo.copy(t).add(e).multiplyScalar(.5),Cr.copy(e).sub(t).normalize(),zn.copy(this.origin).sub(Zo);const s=t.distanceTo(e)*.5,a=-this.direction.dot(Cr),o=zn.dot(this.direction),l=-zn.dot(Cr),c=zn.lengthSq(),h=Math.abs(1-a*a);let u,d,f,m;if(h>0)if(u=a*l-o,d=a*o-l,m=s*h,u>=0)if(d>=-m)if(d<=m){const _=1/h;u*=_,d*=_,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Zo).addScaledVector(Cr,d),f}intersectSphere(t,e){An.subVectors(t.center,this.origin);const n=An.dot(this.direction),i=An.dot(An)-n*n,s=t.radius*t.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(s=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a<i||isNaN(i))&&(i=a),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,An)!==null}intersectTriangle(t,e,n,i,s){Jo.subVectors(e,t),Rr.subVectors(n,t),$o.crossVectors(Jo,Rr);let a=this.direction.dot($o),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;zn.subVectors(this.origin,t);const l=o*this.direction.dot(Rr.crossVectors(zn,Rr));if(l<0)return null;const c=o*this.direction.dot(Jo.cross(zn));if(c<0||l+c>a)return null;const h=-o*zn.dot($o);return h<0?null:this.at(h/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Rt{constructor(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g){Rt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g)}set(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=i,p[1]=s,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=_,p[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Rt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/zi.setFromMatrixColumn(t,0).length(),s=1/zi.setFromMatrixColumn(t,1).length(),a=1/zi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,s=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=a*h,f=a*u,m=o*h,_=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+m*c,e[5]=d-_*c,e[9]=-o*l,e[2]=_-d*c,e[6]=m+f*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,m=c*h,_=c*u;e[0]=d+_*o,e[4]=m*o-f,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-m,e[6]=_+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,m=c*h,_=c*u;e[0]=d-_*o,e[4]=-a*u,e[8]=m+f*o,e[1]=f+m*o,e[5]=a*h,e[9]=_-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,f=a*u,m=o*h,_=o*u;e[0]=l*h,e[4]=m*c-f,e[8]=d*c+_,e[1]=l*u,e[5]=_*c+d,e[9]=f*c-m,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,f=a*c,m=o*l,_=o*c;e[0]=l*h,e[4]=_-d*u,e[8]=m*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+m,e[10]=d-_*u}else if(t.order==="XZY"){const d=a*l,f=a*c,m=o*l,_=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+_,e[5]=a*h,e[9]=f*u-m,e[2]=m*u-f,e[6]=o*h,e[10]=_*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(vp,t,yp)}lookAt(t,e,n){const i=this.elements;return Ge.subVectors(t,e),Ge.lengthSq()===0&&(Ge.z=1),Ge.normalize(),kn.crossVectors(n,Ge),kn.lengthSq()===0&&(Math.abs(n.z)===1?Ge.x+=1e-4:Ge.z+=1e-4,Ge.normalize(),kn.crossVectors(n,Ge)),kn.normalize(),Pr.crossVectors(Ge,kn),i[0]=kn.x,i[4]=Pr.x,i[8]=Ge.x,i[1]=kn.y,i[5]=Pr.y,i[9]=Ge.y,i[2]=kn.z,i[6]=Pr.z,i[10]=Ge.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],_=n[6],g=n[10],p=n[14],v=n[3],x=n[7],y=n[11],P=n[15],w=i[0],T=i[4],R=i[8],b=i[12],M=i[1],I=i[5],k=i[9],O=i[13],V=i[2],q=i[6],H=i[10],nt=i[14],G=i[3],mt=i[7],Mt=i[11],vt=i[15];return s[0]=a*w+o*M+l*V+c*G,s[4]=a*T+o*I+l*q+c*mt,s[8]=a*R+o*k+l*H+c*Mt,s[12]=a*b+o*O+l*nt+c*vt,s[1]=h*w+u*M+d*V+f*G,s[5]=h*T+u*I+d*q+f*mt,s[9]=h*R+u*k+d*H+f*Mt,s[13]=h*b+u*O+d*nt+f*vt,s[2]=m*w+_*M+g*V+p*G,s[6]=m*T+_*I+g*q+p*mt,s[10]=m*R+_*k+g*H+p*Mt,s[14]=m*b+_*O+g*nt+p*vt,s[3]=v*w+x*M+y*V+P*G,s[7]=v*T+x*I+y*q+P*mt,s[11]=v*R+x*k+y*H+P*Mt,s[15]=v*b+x*O+y*nt+P*vt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],s=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],_=t[7],g=t[11],p=t[15];return m*(+s*l*u-i*c*u-s*o*d+n*c*d+i*o*f-n*l*f)+_*(+e*l*f-e*c*d+s*a*d-i*a*f+i*c*h-s*l*h)+g*(+e*c*u-e*o*f-s*a*u+n*a*f+s*o*h-n*c*h)+p*(-i*o*h-e*l*u+e*o*d+i*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],p=t[15],v=u*g*c-_*d*c+_*l*f-o*g*f-u*l*p+o*d*p,x=m*d*c-h*g*c-m*l*f+a*g*f+h*l*p-a*d*p,y=h*_*c-m*u*c+m*o*f-a*_*f-h*o*p+a*u*p,P=m*u*l-h*_*l-m*o*d+a*_*d+h*o*g-a*u*g,w=e*v+n*x+i*y+s*P;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/w;return t[0]=v*T,t[1]=(_*d*s-u*g*s-_*i*f+n*g*f+u*i*p-n*d*p)*T,t[2]=(o*g*s-_*l*s+_*i*c-n*g*c-o*i*p+n*l*p)*T,t[3]=(u*l*s-o*d*s-u*i*c+n*d*c+o*i*f-n*l*f)*T,t[4]=x*T,t[5]=(h*g*s-m*d*s+m*i*f-e*g*f-h*i*p+e*d*p)*T,t[6]=(m*l*s-a*g*s-m*i*c+e*g*c+a*i*p-e*l*p)*T,t[7]=(a*d*s-h*l*s+h*i*c-e*d*c-a*i*f+e*l*f)*T,t[8]=y*T,t[9]=(m*u*s-h*_*s-m*n*f+e*_*f+h*n*p-e*u*p)*T,t[10]=(a*_*s-m*o*s+m*n*c-e*_*c-a*n*p+e*o*p)*T,t[11]=(h*o*s-a*u*s-h*n*c+e*u*c+a*n*f-e*o*f)*T,t[12]=P*T,t[13]=(h*_*i-m*u*i+m*n*d-e*_*d-h*n*g+e*u*g)*T,t[14]=(m*o*i-a*_*i-m*n*l+e*_*l+a*n*g-e*o*g)*T,t[15]=(a*u*i-h*o*i+h*n*l-e*u*l-a*n*d+e*o*d)*T,this}scale(t){const e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),s=1-n,a=t.x,o=t.y,l=t.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,a){return this.set(1,n,s,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,s=e._x,a=e._y,o=e._z,l=e._w,c=s+s,h=a+a,u=o+o,d=s*c,f=s*h,m=s*u,_=a*h,g=a*u,p=o*u,v=l*c,x=l*h,y=l*u,P=n.x,w=n.y,T=n.z;return i[0]=(1-(_+p))*P,i[1]=(f+y)*P,i[2]=(m-x)*P,i[3]=0,i[4]=(f-y)*w,i[5]=(1-(d+p))*w,i[6]=(g+v)*w,i[7]=0,i[8]=(m+x)*T,i[9]=(g-v)*T,i[10]=(1-(d+_))*T,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let s=zi.set(i[0],i[1],i[2]).length();const a=zi.set(i[4],i[5],i[6]).length(),o=zi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],je.copy(this);const c=1/s,h=1/a,u=1/o;return je.elements[0]*=c,je.elements[1]*=c,je.elements[2]*=c,je.elements[4]*=h,je.elements[5]*=h,je.elements[6]*=h,je.elements[8]*=u,je.elements[9]*=u,je.elements[10]*=u,e.setFromRotationMatrix(je),n.x=s,n.y=a,n.z=o,this}makePerspective(t,e,n,i,s,a,o=un){const l=this.elements,c=2*s/(e-t),h=2*s/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i);let f,m;if(o===un)f=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Ts)f=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,s,a,o=un){const l=this.elements,c=1/(e-t),h=1/(n-i),u=1/(a-s),d=(e+t)*c,f=(n+i)*h;let m,_;if(o===un)m=(a+s)*u,_=-2*u;else if(o===Ts)m=s*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const zi=new E,je=new Rt,vp=new E(0,0,0),yp=new E(1,1,1),kn=new E,Pr=new E,Ge=new E,Ch=new Rt,Rh=new Oe;class Xe{constructor(t=0,e=0,n=0,i=Xe.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(le(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-le(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(le(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-le(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(le(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-le(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ch.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ch,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Rh.setFromEuler(this),this.setFromQuaternion(Rh,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Xe.DEFAULT_ORDER="XYZ";class Ir{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Mp=0;const Ph=new E,ki=new Oe,wn=new Rt,Lr=new E,Ls=new E,Sp=new E,bp=new Oe,Ih=new E(1,0,0),Lh=new E(0,1,0),Uh=new E(0,0,1),Dh={type:"added"},Ap={type:"removed"},Vi={type:"childadded",child:null},Ko={type:"childremoved",child:null};class Zt extends Sn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Mp++}),this.uuid=He(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Zt.DEFAULT_UP.clone();const t=new E,e=new Xe,n=new Oe,i=new E(1,1,1);function s(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Rt},normalMatrix:{value:new Bt}}),this.matrix=new Rt,this.matrixWorld=new Rt,this.matrixAutoUpdate=Zt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ir,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return ki.setFromAxisAngle(t,e),this.quaternion.multiply(ki),this}rotateOnWorldAxis(t,e){return ki.setFromAxisAngle(t,e),this.quaternion.premultiply(ki),this}rotateX(t){return this.rotateOnAxis(Ih,t)}rotateY(t){return this.rotateOnAxis(Lh,t)}rotateZ(t){return this.rotateOnAxis(Uh,t)}translateOnAxis(t,e){return Ph.copy(t).applyQuaternion(this.quaternion),this.position.add(Ph.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ih,t)}translateY(t){return this.translateOnAxis(Lh,t)}translateZ(t){return this.translateOnAxis(Uh,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(wn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Lr.copy(t):Lr.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Ls.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?wn.lookAt(Ls,Lr,this.up):wn.lookAt(Lr,Ls,this.up),this.quaternion.setFromRotationMatrix(wn),i&&(wn.extractRotation(i.matrixWorld),ki.setFromRotationMatrix(wn),this.quaternion.premultiply(ki.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Dh),Vi.child=t,this.dispatchEvent(Vi),Vi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Ap),Ko.child=t,this.dispatchEvent(Ko),Ko.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),wn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),wn.multiply(t.parent.matrixWorld)),t.applyMatrix4(wn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Dh),Vi.child=t,this.dispatchEvent(Vi),Vi.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,t,Sp),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,bp,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){const s=e[n];(s.matrixWorldAutoUpdate===!0||t===!0)&&s.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++){const o=i[s];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(t.shapes,u)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(t.materials,this.material[l]));i.material=o}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(t.animations,l))}}if(e){const o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),m=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}}Zt.DEFAULT_UP=new E(0,1,0),Zt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const tn=new E,En=new E,Qo=new E,Tn=new E,Hi=new E,Gi=new E,Nh=new E,jo=new E,tl=new E,el=new E;class qe{constructor(t=new E,e=new E,n=new E){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),tn.subVectors(t,e),i.cross(tn);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){tn.subVectors(i,e),En.subVectors(n,e),Qo.subVectors(t,e);const a=tn.dot(tn),o=tn.dot(En),l=tn.dot(Qo),c=En.dot(En),h=En.dot(Qo),u=a*c-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,m=(a*h-o*l)*d;return s.set(1-f-m,m,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Tn)===null?!1:Tn.x>=0&&Tn.y>=0&&Tn.x+Tn.y<=1}static getInterpolation(t,e,n,i,s,a,o,l){return this.getBarycoord(t,e,n,i,Tn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Tn.x),l.addScaledVector(a,Tn.y),l.addScaledVector(o,Tn.z),l)}static isFrontFacing(t,e,n,i){return tn.subVectors(n,e),En.subVectors(t,e),tn.cross(En).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return tn.subVectors(this.c,this.b),En.subVectors(this.a,this.b),tn.cross(En).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return qe.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return qe.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return qe.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return qe.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return qe.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,s=this.c;let a,o;Hi.subVectors(i,n),Gi.subVectors(s,n),jo.subVectors(t,n);const l=Hi.dot(jo),c=Gi.dot(jo);if(l<=0&&c<=0)return e.copy(n);tl.subVectors(t,i);const h=Hi.dot(tl),u=Gi.dot(tl);if(h>=0&&u<=h)return e.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(Hi,a);el.subVectors(t,s);const f=Hi.dot(el),m=Gi.dot(el);if(m>=0&&f<=m)return e.copy(s);const _=f*c-l*m;if(_<=0&&c>=0&&m<=0)return o=c/(c-m),e.copy(n).addScaledVector(Gi,o);const g=h*m-f*u;if(g<=0&&u-h>=0&&f-m>=0)return Nh.subVectors(s,i),o=(u-h)/(u-h+(f-m)),e.copy(i).addScaledVector(Nh,o);const p=1/(g+_+d);return a=_*p,o=d*p,e.copy(n).addScaledVector(Hi,a).addScaledVector(Gi,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Fh={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},Vn={h:0,s:0,l:0},Ur={h:0,s:0,l:0};function nl(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class pt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Je){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Kt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Kt.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Kt.workingColorSpace){if(t=zo(t,1),e=le(e,0,1),n=le(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,a=2*n-s;this.r=nl(a,s,t+1/3),this.g=nl(a,s,t),this.b=nl(a,s,t-1/3)}return Kt.toWorkingColorSpace(this,i),this}setStyle(t,e=Je){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Je){const n=Fh[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ui(t.r),this.g=Ui(t.g),this.b=Ui(t.b),this}copyLinearToSRGB(t){return this.r=Ho(t.r),this.g=Ho(t.g),this.b=Ho(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Je){return Kt.fromWorkingColorSpace(Ee.copy(this),t),Math.round(le(Ee.r*255,0,255))*65536+Math.round(le(Ee.g*255,0,255))*256+Math.round(le(Ee.b*255,0,255))}getHexString(t=Je){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kt.workingColorSpace){Kt.fromWorkingColorSpace(Ee.copy(this),e);const n=Ee.r,i=Ee.g,s=Ee.b,a=Math.max(n,i,s),o=Math.min(n,i,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Kt.workingColorSpace){return Kt.fromWorkingColorSpace(Ee.copy(this),e),t.r=Ee.r,t.g=Ee.g,t.b=Ee.b,t}getStyle(t=Je){Kt.fromWorkingColorSpace(Ee.copy(this),t);const e=Ee.r,n=Ee.g,i=Ee.b;return t!==Je?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(Vn),this.setHSL(Vn.h+t,Vn.s+e,Vn.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Vn),t.getHSL(Ur);const n=Cs(Vn.h,Ur.h,e),i=Cs(Vn.s,Ur.s,e),s=Cs(Vn.l,Ur.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ee=new pt;pt.NAMES=Fh;let wp=0;class Te extends Sn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wp++}),this.uuid=He(),this.name="",this.type="Material",this.blending=Qn,this.side=mn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ur,this.blendDst=dr,this.blendEquation=Dn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new pt(0,0,0),this.blendAlpha=0,this.depthFunc=us,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Fo,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ri,this.stencilZFail=ri,this.stencilZPass=ri,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Qn&&(n.blending=this.blending),this.side!==mn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==ur&&(n.blendSrc=this.blendSrc),this.blendDst!==dr&&(n.blendDst=this.blendDst),this.blendEquation!==Dn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==us&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Fo&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ri&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ri&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ri&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(e){const s=i(t.textures),a=i(t.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class Hn extends Te{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new pt(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 Xe,this.combine=ds,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Cn=Ep();function Ep(){const r=new ArrayBuffer(4),t=new Float32Array(r),e=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;!(c&8388608);)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function Be(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=le(r,-65504,65504),Cn.floatView[0]=r;const t=Cn.uint32View[0],e=t>>23&511;return Cn.baseTable[e]+((t&8388607)>>Cn.shiftTable[e])}function Us(r){const t=r>>10;return Cn.uint32View[0]=Cn.mantissaTable[Cn.offsetTable[t]+(r&1023)]+Cn.exponentTable[t],Cn.floatView[0]}const Tp={toHalfFloat:Be,fromHalfFloat:Us},me=new E,Dr=new Y;class te{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Es,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ve,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Vo("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Dr.fromBufferAttribute(this,e),Dr.applyMatrix3(t),this.setXY(e,Dr.x,Dr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyMatrix3(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyMatrix4(t),this.setXYZ(e,me.x,me.y,me.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.applyNormalMatrix(t),this.setXYZ(e,me.x,me.y,me.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)me.fromBufferAttribute(this,e),me.transformDirection(t),this.setXYZ(e,me.x,me.y,me.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ie(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Ot(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ie(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ot(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ie(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ot(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ie(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ot(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ie(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ot(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array),i=Ot(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array),i=Ot(i,this.array),s=Ot(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Es&&(t.usage=this.usage),t}}class Cp extends te{constructor(t,e,n){super(new Int8Array(t),e,n)}}class Rp extends te{constructor(t,e,n){super(new Uint8Array(t),e,n)}}class Pp extends te{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}}class Ip extends te{constructor(t,e,n){super(new Int16Array(t),e,n)}}class il extends te{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Lp extends te{constructor(t,e,n){super(new Int32Array(t),e,n)}}class sl extends te{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Up extends te{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=Us(this.array[t*this.itemSize]);return this.normalized&&(e=Ie(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ot(e,this.array)),this.array[t*this.itemSize]=Be(e),this}getY(t){let e=Us(this.array[t*this.itemSize+1]);return this.normalized&&(e=Ie(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ot(e,this.array)),this.array[t*this.itemSize+1]=Be(e),this}getZ(t){let e=Us(this.array[t*this.itemSize+2]);return this.normalized&&(e=Ie(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ot(e,this.array)),this.array[t*this.itemSize+2]=Be(e),this}getW(t){let e=Us(this.array[t*this.itemSize+3]);return this.normalized&&(e=Ie(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ot(e,this.array)),this.array[t*this.itemSize+3]=Be(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array)),this.array[t+0]=Be(e),this.array[t+1]=Be(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array),i=Ot(i,this.array)),this.array[t+0]=Be(e),this.array[t+1]=Be(n),this.array[t+2]=Be(i),this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array),i=Ot(i,this.array),s=Ot(s,this.array)),this.array[t+0]=Be(e),this.array[t+1]=Be(n),this.array[t+2]=Be(i),this.array[t+3]=Be(s),this}}class bt extends te{constructor(t,e,n){super(new Float32Array(t),e,n)}}let Dp=0;const $e=new Rt,rl=new Zt,Wi=new E,We=new Le,Ds=new Le,Se=new E;class Ht extends Sn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Dp++}),this.uuid=He(),this.name="",this.type="BufferGeometry",this.index=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(t){return Array.isArray(t)?this.index=new(yh(t)?sl:il)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Bt().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return $e.makeRotationFromQuaternion(t),this.applyMatrix4($e),this}rotateX(t){return $e.makeRotationX(t),this.applyMatrix4($e),this}rotateY(t){return $e.makeRotationY(t),this.applyMatrix4($e),this}rotateZ(t){return $e.makeRotationZ(t),this.applyMatrix4($e),this}translate(t,e,n){return $e.makeTranslation(t,e,n),this.applyMatrix4($e),this}scale(t,e,n){return $e.makeScale(t,e,n),this.applyMatrix4($e),this}lookAt(t){return rl.lookAt(t),rl.updateMatrix(),this.applyMatrix4(rl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Wi).negate(),this.translate(Wi.x,Wi.y,Wi.z),this}setFromPoints(t){const e=[];for(let n=0,i=t.length;n<i;n++){const s=t[n];e.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new bt(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Le);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new E(-1/0,-1/0,-1/0),new E(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const s=e[n];We.setFromBufferAttribute(s),this.morphTargetsRelative?(Se.addVectors(this.boundingBox.min,We.min),this.boundingBox.expandByPoint(Se),Se.addVectors(this.boundingBox.max,We.max),this.boundingBox.expandByPoint(Se)):(this.boundingBox.expandByPoint(We.min),this.boundingBox.expandByPoint(We.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 we);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new E,1/0);return}if(t){const n=this.boundingSphere.center;if(We.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];Ds.setFromBufferAttribute(o),this.morphTargetsRelative?(Se.addVectors(We.min,Ds.min),We.expandByPoint(Se),Se.addVectors(We.max,Ds.max),We.expandByPoint(Se)):(We.expandByPoint(Ds.min),We.expandByPoint(Ds.max))}We.getCenter(n);let i=0;for(let s=0,a=t.count;s<a;s++)Se.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(Se));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Se.fromBufferAttribute(o,c),l&&(Wi.fromBufferAttribute(t,c),Se.add(Wi)),i=Math.max(i,n.distanceToSquared(Se))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new te(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let R=0;R<n.count;R++)o[R]=new E,l[R]=new E;const c=new E,h=new E,u=new E,d=new Y,f=new Y,m=new Y,_=new E,g=new E;function p(R,b,M){c.fromBufferAttribute(n,R),h.fromBufferAttribute(n,b),u.fromBufferAttribute(n,M),d.fromBufferAttribute(s,R),f.fromBufferAttribute(s,b),m.fromBufferAttribute(s,M),h.sub(c),u.sub(c),f.sub(d),m.sub(d);const I=1/(f.x*m.y-m.x*f.y);isFinite(I)&&(_.copy(h).multiplyScalar(m.y).addScaledVector(u,-f.y).multiplyScalar(I),g.copy(u).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(I),o[R].add(_),o[b].add(_),o[M].add(_),l[R].add(g),l[b].add(g),l[M].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:t.count}]);for(let R=0,b=v.length;R<b;++R){const M=v[R],I=M.start,k=M.count;for(let O=I,V=I+k;O<V;O+=3)p(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const x=new E,y=new E,P=new E,w=new E;function T(R){P.fromBufferAttribute(i,R),w.copy(P);const b=o[R];x.copy(b),x.sub(P.multiplyScalar(P.dot(b))).normalize(),y.crossVectors(w,b);const I=y.dot(l[R])<0?-1:1;a.setXYZW(R,x.x,x.y,x.z,I)}for(let R=0,b=v.length;R<b;++R){const M=v[R],I=M.start,k=M.count;for(let O=I,V=I+k;O<V;O+=3)T(t.getX(O+0)),T(t.getX(O+1)),T(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new te(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new E,s=new E,a=new E,o=new E,l=new E,c=new E,h=new E,u=new E;if(t)for(let d=0,f=t.count;d<f;d+=3){const m=t.getX(d+0),_=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,m),s.fromBufferAttribute(e,_),a.fromBufferAttribute(e,g),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),o.fromBufferAttribute(n,m),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,g),o.add(h),l.add(h),c.add(h),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Se.fromBufferAttribute(t,e),Se.normalize(),t.setXYZ(e,Se.x,Se.y,Se.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,m=0;for(let _=0,g=l.length;_<g;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*h;for(let p=0;p<h;p++)d[m++]=c[f++]}return new te(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ht,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=t(l,n);e.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Oh=new Rt,hi=new Bi,Nr=new we,Bh=new E,Xi=new E,qi=new E,Yi=new E,al=new E,Fr=new E,Or=new Y,Br=new Y,zr=new Y,zh=new E,kh=new E,Vh=new E,kr=new E,Vr=new E;class ge extends Zt{constructor(t=new Ht,e=new Hn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(s&&o){Fr.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],u=s[l];h!==0&&(al.fromBufferAttribute(u,t),a?Fr.addScaledVector(al,h):Fr.addScaledVector(al.sub(e),h))}e.add(Fr)}return e}raycast(t,e){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Nr.copy(n.boundingSphere),Nr.applyMatrix4(s),hi.copy(t.ray).recast(t.near),!(Nr.containsPoint(hi.origin)===!1&&(hi.intersectSphere(Nr,Bh)===null||hi.origin.distanceToSquared(Bh)>(t.far-t.near)**2))&&(Oh.copy(s).invert(),hi.copy(t.ray).applyMatrix4(Oh),!(n.boundingBox!==null&&hi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,hi)))}_computeIntersections(t,e,n){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,_=d.length;m<_;m++){const g=d[m],p=a[g.materialIndex],v=Math.max(g.start,f.start),x=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let y=v,P=x;y<P;y+=3){const w=o.getX(y),T=o.getX(y+1),R=o.getX(y+2);i=Hr(this,p,t,n,c,h,u,w,T,R),i&&(i.faceIndex=Math.floor(y/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const m=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let g=m,p=_;g<p;g+=3){const v=o.getX(g),x=o.getX(g+1),y=o.getX(g+2);i=Hr(this,a,t,n,c,h,u,v,x,y),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let m=0,_=d.length;m<_;m++){const g=d[m],p=a[g.materialIndex],v=Math.max(g.start,f.start),x=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let y=v,P=x;y<P;y+=3){const w=y,T=y+1,R=y+2;i=Hr(this,p,t,n,c,h,u,w,T,R),i&&(i.faceIndex=Math.floor(y/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const m=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let g=m,p=_;g<p;g+=3){const v=g,x=g+1,y=g+2;i=Hr(this,a,t,n,c,h,u,v,x,y),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}}}function Np(r,t,e,n,i,s,a,o){let l;if(t.side===Pe?l=n.intersectTriangle(a,s,i,!0,o):l=n.intersectTriangle(i,s,a,t.side===mn,o),l===null)return null;Vr.copy(o),Vr.applyMatrix4(r.matrixWorld);const c=e.ray.origin.distanceTo(Vr);return c<e.near||c>e.far?null:{distance:c,point:Vr.clone(),object:r}}function Hr(r,t,e,n,i,s,a,o,l,c){r.getVertexPosition(o,Xi),r.getVertexPosition(l,qi),r.getVertexPosition(c,Yi);const h=Np(r,t,e,n,Xi,qi,Yi,kr);if(h){i&&(Or.fromBufferAttribute(i,o),Br.fromBufferAttribute(i,l),zr.fromBufferAttribute(i,c),h.uv=qe.getInterpolation(kr,Xi,qi,Yi,Or,Br,zr,new Y)),s&&(Or.fromBufferAttribute(s,o),Br.fromBufferAttribute(s,l),zr.fromBufferAttribute(s,c),h.uv1=qe.getInterpolation(kr,Xi,qi,Yi,Or,Br,zr,new Y)),a&&(zh.fromBufferAttribute(a,o),kh.fromBufferAttribute(a,l),Vh.fromBufferAttribute(a,c),h.normal=qe.getInterpolation(kr,Xi,qi,Yi,zh,kh,Vh,new E),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new E,materialIndex:0};qe.getNormal(Xi,qi,Yi,u.normal),h.face=u}return h}class Ti extends Ht{constructor(t=1,e=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,f=0;m("z","y","x",-1,-1,n,e,t,a,s,0),m("z","y","x",1,-1,n,e,-t,a,s,1),m("x","z","y",1,1,t,n,e,i,a,2),m("x","z","y",1,-1,t,n,-e,i,a,3),m("x","y","z",1,-1,t,e,n,i,s,4),m("x","y","z",-1,-1,t,e,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new bt(c,3)),this.setAttribute("normal",new bt(h,3)),this.setAttribute("uv",new bt(u,2));function m(_,g,p,v,x,y,P,w,T,R,b){const M=y/T,I=P/R,k=y/2,O=P/2,V=w/2,q=T+1,H=R+1;let nt=0,G=0;const mt=new E;for(let Mt=0;Mt<H;Mt++){const vt=Mt*I-O;for(let Gt=0;Gt<q;Gt++){const Jt=Gt*M-k;mt[_]=Jt*v,mt[g]=vt*x,mt[p]=V,c.push(mt.x,mt.y,mt.z),mt[_]=0,mt[g]=0,mt[p]=w>0?1:-1,h.push(mt.x,mt.y,mt.z),u.push(Gt/T),u.push(1-Mt/R),nt+=1}}for(let Mt=0;Mt<R;Mt++)for(let vt=0;vt<T;vt++){const Gt=d+vt+q*Mt,Jt=d+vt+q*(Mt+1),W=d+(vt+1)+q*(Mt+1),it=d+(vt+1)+q*Mt;l.push(Gt,Jt,it),l.push(Jt,W,it),G+=6}o.addGroup(f,G,b),f+=G,d+=nt}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ti(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Zi(r){const t={};for(const e in r){t[e]={};for(const n in r[e]){const i=r[e][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}function Ue(r){const t={};for(let e=0;e<r.length;e++){const n=Zi(r[e]);for(const i in n)t[i]=n[i]}return t}function Fp(r){const t=[];for(let e=0;e<r.length;e++)t.push(r[e].clone());return t}function Hh(r){const t=r.getRenderTarget();return t===null?r.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Kt.workingColorSpace}const Gh={clone:Zi,merge:Ue};var Op=`void main() {
  6. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  7. }`,Bp=`void main() {
  8. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  9. }`;class en extends Te{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Op,this.fragmentShader=Bp,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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Zi(t.uniforms),this.uniformsGroups=Fp(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?e.uniforms[i]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[i]={type:"m4",value:a.toArray()}:e.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class Gr extends Zt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=un}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Gn=new E,Wh=new Y,Xh=new Y;class be extends Gr{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Ii*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ai*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Ii*2*Math.atan(Math.tan(ai*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Gn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Gn.x,Gn.y).multiplyScalar(-t/Gn.z),Gn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Gn.x,Gn.y).multiplyScalar(-t/Gn.z)}getViewSize(t,e){return this.getViewBounds(t,Wh,Xh),e.subVectors(Xh,Wh)}setViewOffset(t,e,n,i,s,a){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(ai*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,e-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Ji=-90,$i=1;class qh extends Zt{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new be(Ji,$i,t,e);i.layers=this.layers,this.add(i);const s=new be(Ji,$i,t,e);s.layers=this.layers,this.add(s);const a=new be(Ji,$i,t,e);a.layers=this.layers,this.add(a);const o=new be(Ji,$i,t,e);o.layers=this.layers,this.add(o);const l=new be(Ji,$i,t,e);l.layers=this.layers,this.add(l);const c=new be(Ji,$i,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,s,a,o,l]=e;for(const c of e)this.remove(c);if(t===un)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Ts)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),m=t.xr.enabled;t.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,s),t.setRenderTarget(n,1,i),t.render(e,a),t.setRenderTarget(n,2,i),t.render(e,o),t.setRenderTarget(n,3,i),t.render(e,l),t.setRenderTarget(n,4,i),t.render(e,c),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}class Ns extends he{constructor(t,e,n,i,s,a,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:xn,super(t,e,n,i,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Yh extends Ke{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new Ns(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:pe}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={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. `},i=new Ti(5,5,5),s=new en({name:"CubemapFromEquirect",uniforms:Zi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Pe,blending:gn});s.uniforms.tEquirect.value=e;const a=new ge(i,s),o=e.minFilter;return e.minFilter===hn&&(e.minFilter=pe),new qh(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,i){const s=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(s)}}const ol=new E,zp=new E,kp=new Bt;class Wn{constructor(t=new E(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=ol.subVectors(n,e).cross(zp.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(ol),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||kp.getNormalMatrix(t),i=this.coplanarPoint(ol).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ui=new we,Wr=new E;class Fs{constructor(t=new Wn,e=new Wn,n=new Wn,i=new Wn,s=new Wn,a=new Wn){this.planes=[t,e,n,i,s,a]}set(t,e,n,i,s,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=un){const n=this.planes,i=t.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],h=i[5],u=i[6],d=i[7],f=i[8],m=i[9],_=i[10],g=i[11],p=i[12],v=i[13],x=i[14],y=i[15];if(n[0].setComponents(l-s,d-c,g-f,y-p).normalize(),n[1].setComponents(l+s,d+c,g+f,y+p).normalize(),n[2].setComponents(l+a,d+h,g+m,y+v).normalize(),n[3].setComponents(l-a,d-h,g-m,y-v).normalize(),n[4].setComponents(l-o,d-u,g-_,y-x).normalize(),e===un)n[5].setComponents(l+o,d+u,g+_,y+x).normalize();else if(e===Ts)n[5].setComponents(o,u,_,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),ui.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ui.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ui)}intersectsSprite(t){return ui.center.set(0,0,0),ui.radius=.7071067811865476,ui.applyMatrix4(t.matrixWorld),this.intersectsSphere(ui)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(Wr.x=i.normal.x>0?t.max.x:t.min.x,Wr.y=i.normal.y>0?t.max.y:t.min.y,Wr.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Wr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Zh(){let r=null,t=!1,e=null,n=null;function i(s,a){e(s,a),n=r.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=r.requestAnimationFrame(i),t=!0)},stop:function(){r.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){r=s}}}function Vp(r){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=r.createBuffer();r.bindBuffer(l,d),r.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=r.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=r.HALF_FLOAT:f=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=r.SHORT;else if(c instanceof Uint32Array)f=r.UNSIGNED_INT;else if(c instanceof Int32Array)f=r.INT;else if(c instanceof Int8Array)f=r.BYTE;else if(c instanceof Uint8Array)f=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l._updateRange,d=l.updateRanges;if(r.bindBuffer(c,o),u.count===-1&&d.length===0&&r.bufferSubData(c,0,h),d.length!==0){for(let f=0,m=d.length;f<m;f++){const _=d[f];r.bufferSubData(c,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}l.clearUpdateRanges()}u.count!==-1&&(r.bufferSubData(c,u.offset*h.BYTES_PER_ELEMENT,h,u.offset,u.count),u.count=-1),l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=t.get(o);l&&(r.deleteBuffer(l.buffer),t.delete(o))}function a(o,l){if(o.isGLBufferAttribute){const h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}o.isInterleavedBufferAttribute&&(o=o.data);const c=t.get(o);if(c===void 0)t.set(o,e(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:i,remove:s,update:a}}class cs extends Ht{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const s=t/2,a=e/2,o=Math.floor(n),l=Math.floor(i),c=o+1,h=l+1,u=t/o,d=e/l,f=[],m=[],_=[],g=[];for(let p=0;p<h;p++){const v=p*d-a;for(let x=0;x<c;x++){const y=x*u-s;m.push(y,-v,0),_.push(0,0,1),g.push(x/o),g.push(1-p/l)}}for(let p=0;p<l;p++)for(let v=0;v<o;v++){const x=v+c*p,y=v+c*(p+1),P=v+1+c*(p+1),w=v+1+c*p;f.push(x,y,w),f.push(y,P,w)}this.setIndex(f),this.setAttribute("position",new bt(m,3)),this.setAttribute("normal",new bt(_,3)),this.setAttribute("uv",new bt(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new cs(t.width,t.height,t.widthSegments,t.heightSegments)}}var Hp=`#ifdef USE_ALPHAHASH
  29. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  30. #endif`,Gp=`#ifdef USE_ALPHAHASH
  31. const float ALPHA_HASH_SCALE = 0.05;
  32. float hash2D( vec2 value ) {
  33. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  34. }
  35. float hash3D( vec3 value ) {
  36. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  37. }
  38. float getAlphaHashThreshold( vec3 position ) {
  39. float maxDeriv = max(
  40. length( dFdx( position.xyz ) ),
  41. length( dFdy( position.xyz ) )
  42. );
  43. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  44. vec2 pixScales = vec2(
  45. exp2( floor( log2( pixScale ) ) ),
  46. exp2( ceil( log2( pixScale ) ) )
  47. );
  48. vec2 alpha = vec2(
  49. hash3D( floor( pixScales.x * position.xyz ) ),
  50. hash3D( floor( pixScales.y * position.xyz ) )
  51. );
  52. float lerpFactor = fract( log2( pixScale ) );
  53. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  54. float a = min( lerpFactor, 1.0 - lerpFactor );
  55. vec3 cases = vec3(
  56. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  57. ( x - 0.5 * a ) / ( 1.0 - a ),
  58. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  59. );
  60. float threshold = ( x < ( 1.0 - a ) )
  61. ? ( ( x < a ) ? cases.x : cases.y )
  62. : cases.z;
  63. return clamp( threshold , 1.0e-6, 1.0 );
  64. }
  65. #endif`,Wp=`#ifdef USE_ALPHAMAP
  66. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  67. #endif`,Xp=`#ifdef USE_ALPHAMAP
  68. uniform sampler2D alphaMap;
  69. #endif`,qp=`#ifdef USE_ALPHATEST
  70. #ifdef ALPHA_TO_COVERAGE
  71. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  72. if ( diffuseColor.a == 0.0 ) discard;
  73. #else
  74. if ( diffuseColor.a < alphaTest ) discard;
  75. #endif
  76. #endif`,Yp=`#ifdef USE_ALPHATEST
  77. uniform float alphaTest;
  78. #endif`,Zp=`#ifdef USE_AOMAP
  79. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  80. reflectedLight.indirectDiffuse *= ambientOcclusion;
  81. #if defined( USE_CLEARCOAT )
  82. clearcoatSpecularIndirect *= ambientOcclusion;
  83. #endif
  84. #if defined( USE_SHEEN )
  85. sheenSpecularIndirect *= ambientOcclusion;
  86. #endif
  87. #if defined( USE_ENVMAP ) && defined( STANDARD )
  88. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  89. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  90. #endif
  91. #endif`,Jp=`#ifdef USE_AOMAP
  92. uniform sampler2D aoMap;
  93. uniform float aoMapIntensity;
  94. #endif`,$p=`#ifdef USE_BATCHING
  95. attribute float batchId;
  96. uniform highp sampler2D batchingTexture;
  97. mat4 getBatchingMatrix( const in float i ) {
  98. int size = textureSize( batchingTexture, 0 ).x;
  99. int j = int( i ) * 4;
  100. int x = j % size;
  101. int y = j / size;
  102. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  103. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  104. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  105. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  106. return mat4( v1, v2, v3, v4 );
  107. }
  108. #endif
  109. #ifdef USE_BATCHING_COLOR
  110. uniform sampler2D batchingColorTexture;
  111. vec3 getBatchingColor( const in float i ) {
  112. int size = textureSize( batchingColorTexture, 0 ).x;
  113. int j = int( i );
  114. int x = j % size;
  115. int y = j / size;
  116. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  117. }
  118. #endif`,Kp=`#ifdef USE_BATCHING
  119. mat4 batchingMatrix = getBatchingMatrix( batchId );
  120. #endif`,Qp=`vec3 transformed = vec3( position );
  121. #ifdef USE_ALPHAHASH
  122. vPosition = vec3( position );
  123. #endif`,jp=`vec3 objectNormal = vec3( normal );
  124. #ifdef USE_TANGENT
  125. vec3 objectTangent = vec3( tangent.xyz );
  126. #endif`,tm=`float G_BlinnPhong_Implicit( ) {
  127. return 0.25;
  128. }
  129. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  130. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  131. }
  132. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  133. vec3 halfDir = normalize( lightDir + viewDir );
  134. float dotNH = saturate( dot( normal, halfDir ) );
  135. float dotVH = saturate( dot( viewDir, halfDir ) );
  136. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  137. float G = G_BlinnPhong_Implicit( );
  138. float D = D_BlinnPhong( shininess, dotNH );
  139. return F * ( G * D );
  140. } // validated`,em=`#ifdef USE_IRIDESCENCE
  141. const mat3 XYZ_TO_REC709 = mat3(
  142. 3.2404542, -0.9692660, 0.0556434,
  143. -1.5371385, 1.8760108, -0.2040259,
  144. -0.4985314, 0.0415560, 1.0572252
  145. );
  146. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  147. vec3 sqrtF0 = sqrt( fresnel0 );
  148. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  149. }
  150. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  151. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  152. }
  153. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  154. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  155. }
  156. vec3 evalSensitivity( float OPD, vec3 shift ) {
  157. float phase = 2.0 * PI * OPD * 1.0e-9;
  158. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  159. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  160. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  161. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  162. 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 ) );
  163. xyz /= 1.0685e-7;
  164. vec3 rgb = XYZ_TO_REC709 * xyz;
  165. return rgb;
  166. }
  167. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  168. vec3 I;
  169. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  170. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  171. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  172. if ( cosTheta2Sq < 0.0 ) {
  173. return vec3( 1.0 );
  174. }
  175. float cosTheta2 = sqrt( cosTheta2Sq );
  176. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  177. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  178. float T121 = 1.0 - R12;
  179. float phi12 = 0.0;
  180. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  181. float phi21 = PI - phi12;
  182. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  183. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  184. vec3 phi23 = vec3( 0.0 );
  185. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  186. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  187. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  188. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  189. vec3 phi = vec3( phi21 ) + phi23;
  190. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  191. vec3 r123 = sqrt( R123 );
  192. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  193. vec3 C0 = R12 + Rs;
  194. I = C0;
  195. vec3 Cm = Rs - T121;
  196. for ( int m = 1; m <= 2; ++ m ) {
  197. Cm *= r123;
  198. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  199. I += Cm * Sm;
  200. }
  201. return max( I, vec3( 0.0 ) );
  202. }
  203. #endif`,nm=`#ifdef USE_BUMPMAP
  204. uniform sampler2D bumpMap;
  205. uniform float bumpScale;
  206. vec2 dHdxy_fwd() {
  207. vec2 dSTdx = dFdx( vBumpMapUv );
  208. vec2 dSTdy = dFdy( vBumpMapUv );
  209. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  210. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  211. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  212. return vec2( dBx, dBy );
  213. }
  214. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  215. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  216. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  217. vec3 vN = surf_norm;
  218. vec3 R1 = cross( vSigmaY, vN );
  219. vec3 R2 = cross( vN, vSigmaX );
  220. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  221. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  222. return normalize( abs( fDet ) * surf_norm - vGrad );
  223. }
  224. #endif`,im=`#if NUM_CLIPPING_PLANES > 0
  225. vec4 plane;
  226. #ifdef ALPHA_TO_COVERAGE
  227. float distanceToPlane, distanceGradient;
  228. float clipOpacity = 1.0;
  229. #pragma unroll_loop_start
  230. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  231. plane = clippingPlanes[ i ];
  232. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  233. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  234. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  235. if ( clipOpacity == 0.0 ) discard;
  236. }
  237. #pragma unroll_loop_end
  238. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  239. float unionClipOpacity = 1.0;
  240. #pragma unroll_loop_start
  241. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  242. plane = clippingPlanes[ i ];
  243. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  244. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  245. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  246. }
  247. #pragma unroll_loop_end
  248. clipOpacity *= 1.0 - unionClipOpacity;
  249. #endif
  250. diffuseColor.a *= clipOpacity;
  251. if ( diffuseColor.a == 0.0 ) discard;
  252. #else
  253. #pragma unroll_loop_start
  254. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  255. plane = clippingPlanes[ i ];
  256. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  257. }
  258. #pragma unroll_loop_end
  259. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  260. bool clipped = true;
  261. #pragma unroll_loop_start
  262. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  263. plane = clippingPlanes[ i ];
  264. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  265. }
  266. #pragma unroll_loop_end
  267. if ( clipped ) discard;
  268. #endif
  269. #endif
  270. #endif`,sm=`#if NUM_CLIPPING_PLANES > 0
  271. varying vec3 vClipPosition;
  272. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  273. #endif`,rm=`#if NUM_CLIPPING_PLANES > 0
  274. varying vec3 vClipPosition;
  275. #endif`,am=`#if NUM_CLIPPING_PLANES > 0
  276. vClipPosition = - mvPosition.xyz;
  277. #endif`,om=`#if defined( USE_COLOR_ALPHA )
  278. diffuseColor *= vColor;
  279. #elif defined( USE_COLOR )
  280. diffuseColor.rgb *= vColor;
  281. #endif`,lm=`#if defined( USE_COLOR_ALPHA )
  282. varying vec4 vColor;
  283. #elif defined( USE_COLOR )
  284. varying vec3 vColor;
  285. #endif`,cm=`#if defined( USE_COLOR_ALPHA )
  286. varying vec4 vColor;
  287. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  288. varying vec3 vColor;
  289. #endif`,hm=`#if defined( USE_COLOR_ALPHA )
  290. vColor = vec4( 1.0 );
  291. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  292. vColor = vec3( 1.0 );
  293. #endif
  294. #ifdef USE_COLOR
  295. vColor *= color;
  296. #endif
  297. #ifdef USE_INSTANCING_COLOR
  298. vColor.xyz *= instanceColor.xyz;
  299. #endif
  300. #ifdef USE_BATCHING_COLOR
  301. vec3 batchingColor = getBatchingColor( batchId );
  302. vColor.xyz *= batchingColor.xyz;
  303. #endif`,um=`#define PI 3.141592653589793
  304. #define PI2 6.283185307179586
  305. #define PI_HALF 1.5707963267948966
  306. #define RECIPROCAL_PI 0.3183098861837907
  307. #define RECIPROCAL_PI2 0.15915494309189535
  308. #define EPSILON 1e-6
  309. #ifndef saturate
  310. #define saturate( a ) clamp( a, 0.0, 1.0 )
  311. #endif
  312. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  313. float pow2( const in float x ) { return x*x; }
  314. vec3 pow2( const in vec3 x ) { return x*x; }
  315. float pow3( const in float x ) { return x*x*x; }
  316. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  317. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  318. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  319. highp float rand( const in vec2 uv ) {
  320. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  321. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  322. return fract( sin( sn ) * c );
  323. }
  324. #ifdef HIGH_PRECISION
  325. float precisionSafeLength( vec3 v ) { return length( v ); }
  326. #else
  327. float precisionSafeLength( vec3 v ) {
  328. float maxComponent = max3( abs( v ) );
  329. return length( v / maxComponent ) * maxComponent;
  330. }
  331. #endif
  332. struct IncidentLight {
  333. vec3 color;
  334. vec3 direction;
  335. bool visible;
  336. };
  337. struct ReflectedLight {
  338. vec3 directDiffuse;
  339. vec3 directSpecular;
  340. vec3 indirectDiffuse;
  341. vec3 indirectSpecular;
  342. };
  343. #ifdef USE_ALPHAHASH
  344. varying vec3 vPosition;
  345. #endif
  346. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  347. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  348. }
  349. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  350. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  351. }
  352. mat3 transposeMat3( const in mat3 m ) {
  353. mat3 tmp;
  354. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  355. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  356. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  357. return tmp;
  358. }
  359. float luminance( const in vec3 rgb ) {
  360. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  361. return dot( weights, rgb );
  362. }
  363. bool isPerspectiveMatrix( mat4 m ) {
  364. return m[ 2 ][ 3 ] == - 1.0;
  365. }
  366. vec2 equirectUv( in vec3 dir ) {
  367. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  368. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  369. return vec2( u, v );
  370. }
  371. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  372. return RECIPROCAL_PI * diffuseColor;
  373. }
  374. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  375. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  376. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  377. }
  378. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  379. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  380. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  381. } // validated`,dm=`#ifdef ENVMAP_TYPE_CUBE_UV
  382. #define cubeUV_minMipLevel 4.0
  383. #define cubeUV_minTileSize 16.0
  384. float getFace( vec3 direction ) {
  385. vec3 absDirection = abs( direction );
  386. float face = - 1.0;
  387. if ( absDirection.x > absDirection.z ) {
  388. if ( absDirection.x > absDirection.y )
  389. face = direction.x > 0.0 ? 0.0 : 3.0;
  390. else
  391. face = direction.y > 0.0 ? 1.0 : 4.0;
  392. } else {
  393. if ( absDirection.z > absDirection.y )
  394. face = direction.z > 0.0 ? 2.0 : 5.0;
  395. else
  396. face = direction.y > 0.0 ? 1.0 : 4.0;
  397. }
  398. return face;
  399. }
  400. vec2 getUV( vec3 direction, float face ) {
  401. vec2 uv;
  402. if ( face == 0.0 ) {
  403. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  404. } else if ( face == 1.0 ) {
  405. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  406. } else if ( face == 2.0 ) {
  407. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  408. } else if ( face == 3.0 ) {
  409. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  410. } else if ( face == 4.0 ) {
  411. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  412. } else {
  413. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  414. }
  415. return 0.5 * ( uv + 1.0 );
  416. }
  417. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  418. float face = getFace( direction );
  419. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  420. mipInt = max( mipInt, cubeUV_minMipLevel );
  421. float faceSize = exp2( mipInt );
  422. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  423. if ( face > 2.0 ) {
  424. uv.y += faceSize;
  425. face -= 3.0;
  426. }
  427. uv.x += face * faceSize;
  428. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  429. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  430. uv.x *= CUBEUV_TEXEL_WIDTH;
  431. uv.y *= CUBEUV_TEXEL_HEIGHT;
  432. #ifdef texture2DGradEXT
  433. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  434. #else
  435. return texture2D( envMap, uv ).rgb;
  436. #endif
  437. }
  438. #define cubeUV_r0 1.0
  439. #define cubeUV_m0 - 2.0
  440. #define cubeUV_r1 0.8
  441. #define cubeUV_m1 - 1.0
  442. #define cubeUV_r4 0.4
  443. #define cubeUV_m4 2.0
  444. #define cubeUV_r5 0.305
  445. #define cubeUV_m5 3.0
  446. #define cubeUV_r6 0.21
  447. #define cubeUV_m6 4.0
  448. float roughnessToMip( float roughness ) {
  449. float mip = 0.0;
  450. if ( roughness >= cubeUV_r1 ) {
  451. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  452. } else if ( roughness >= cubeUV_r4 ) {
  453. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  454. } else if ( roughness >= cubeUV_r5 ) {
  455. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  456. } else if ( roughness >= cubeUV_r6 ) {
  457. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  458. } else {
  459. mip = - 2.0 * log2( 1.16 * roughness ); }
  460. return mip;
  461. }
  462. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  463. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  464. float mipF = fract( mip );
  465. float mipInt = floor( mip );
  466. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  467. if ( mipF == 0.0 ) {
  468. return vec4( color0, 1.0 );
  469. } else {
  470. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  471. return vec4( mix( color0, color1, mipF ), 1.0 );
  472. }
  473. }
  474. #endif`,fm=`vec3 transformedNormal = objectNormal;
  475. #ifdef USE_TANGENT
  476. vec3 transformedTangent = objectTangent;
  477. #endif
  478. #ifdef USE_BATCHING
  479. mat3 bm = mat3( batchingMatrix );
  480. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  481. transformedNormal = bm * transformedNormal;
  482. #ifdef USE_TANGENT
  483. transformedTangent = bm * transformedTangent;
  484. #endif
  485. #endif
  486. #ifdef USE_INSTANCING
  487. mat3 im = mat3( instanceMatrix );
  488. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  489. transformedNormal = im * transformedNormal;
  490. #ifdef USE_TANGENT
  491. transformedTangent = im * transformedTangent;
  492. #endif
  493. #endif
  494. transformedNormal = normalMatrix * transformedNormal;
  495. #ifdef FLIP_SIDED
  496. transformedNormal = - transformedNormal;
  497. #endif
  498. #ifdef USE_TANGENT
  499. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  500. #ifdef FLIP_SIDED
  501. transformedTangent = - transformedTangent;
  502. #endif
  503. #endif`,pm=`#ifdef USE_DISPLACEMENTMAP
  504. uniform sampler2D displacementMap;
  505. uniform float displacementScale;
  506. uniform float displacementBias;
  507. #endif`,mm=`#ifdef USE_DISPLACEMENTMAP
  508. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  509. #endif`,gm=`#ifdef USE_EMISSIVEMAP
  510. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  511. totalEmissiveRadiance *= emissiveColor.rgb;
  512. #endif`,_m=`#ifdef USE_EMISSIVEMAP
  513. uniform sampler2D emissiveMap;
  514. #endif`,xm="gl_FragColor = linearToOutputTexel( gl_FragColor );",vm=`
  515. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  516. vec3( 0.8224621, 0.177538, 0.0 ),
  517. vec3( 0.0331941, 0.9668058, 0.0 ),
  518. vec3( 0.0170827, 0.0723974, 0.9105199 )
  519. );
  520. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  521. vec3( 1.2249401, - 0.2249404, 0.0 ),
  522. vec3( - 0.0420569, 1.0420571, 0.0 ),
  523. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  524. );
  525. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  526. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  527. }
  528. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  529. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  530. }
  531. vec4 LinearTransferOETF( in vec4 value ) {
  532. return value;
  533. }
  534. vec4 sRGBTransferOETF( in vec4 value ) {
  535. 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 );
  536. }
  537. vec4 LinearToLinear( in vec4 value ) {
  538. return value;
  539. }
  540. vec4 LinearTosRGB( in vec4 value ) {
  541. return sRGBTransferOETF( value );
  542. }`,ym=`#ifdef USE_ENVMAP
  543. #ifdef ENV_WORLDPOS
  544. vec3 cameraToFrag;
  545. if ( isOrthographic ) {
  546. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  547. } else {
  548. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  549. }
  550. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  551. #ifdef ENVMAP_MODE_REFLECTION
  552. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  553. #else
  554. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  555. #endif
  556. #else
  557. vec3 reflectVec = vReflect;
  558. #endif
  559. #ifdef ENVMAP_TYPE_CUBE
  560. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  561. #else
  562. vec4 envColor = vec4( 0.0 );
  563. #endif
  564. #ifdef ENVMAP_BLENDING_MULTIPLY
  565. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  566. #elif defined( ENVMAP_BLENDING_MIX )
  567. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  568. #elif defined( ENVMAP_BLENDING_ADD )
  569. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  570. #endif
  571. #endif`,Mm=`#ifdef USE_ENVMAP
  572. uniform float envMapIntensity;
  573. uniform float flipEnvMap;
  574. uniform mat3 envMapRotation;
  575. #ifdef ENVMAP_TYPE_CUBE
  576. uniform samplerCube envMap;
  577. #else
  578. uniform sampler2D envMap;
  579. #endif
  580. #endif`,Sm=`#ifdef USE_ENVMAP
  581. uniform float reflectivity;
  582. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  583. #define ENV_WORLDPOS
  584. #endif
  585. #ifdef ENV_WORLDPOS
  586. varying vec3 vWorldPosition;
  587. uniform float refractionRatio;
  588. #else
  589. varying vec3 vReflect;
  590. #endif
  591. #endif`,bm=`#ifdef USE_ENVMAP
  592. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  593. #define ENV_WORLDPOS
  594. #endif
  595. #ifdef ENV_WORLDPOS
  596. varying vec3 vWorldPosition;
  597. #else
  598. varying vec3 vReflect;
  599. uniform float refractionRatio;
  600. #endif
  601. #endif`,Am=`#ifdef USE_ENVMAP
  602. #ifdef ENV_WORLDPOS
  603. vWorldPosition = worldPosition.xyz;
  604. #else
  605. vec3 cameraToVertex;
  606. if ( isOrthographic ) {
  607. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  608. } else {
  609. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  610. }
  611. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  612. #ifdef ENVMAP_MODE_REFLECTION
  613. vReflect = reflect( cameraToVertex, worldNormal );
  614. #else
  615. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  616. #endif
  617. #endif
  618. #endif`,wm=`#ifdef USE_FOG
  619. vFogDepth = - mvPosition.z;
  620. #endif`,Em=`#ifdef USE_FOG
  621. varying float vFogDepth;
  622. #endif`,Tm=`#ifdef USE_FOG
  623. #ifdef FOG_EXP2
  624. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  625. #else
  626. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  627. #endif
  628. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  629. #endif`,Cm=`#ifdef USE_FOG
  630. uniform vec3 fogColor;
  631. varying float vFogDepth;
  632. #ifdef FOG_EXP2
  633. uniform float fogDensity;
  634. #else
  635. uniform float fogNear;
  636. uniform float fogFar;
  637. #endif
  638. #endif`,Rm=`#ifdef USE_GRADIENTMAP
  639. uniform sampler2D gradientMap;
  640. #endif
  641. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  642. float dotNL = dot( normal, lightDirection );
  643. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  644. #ifdef USE_GRADIENTMAP
  645. return vec3( texture2D( gradientMap, coord ).r );
  646. #else
  647. vec2 fw = fwidth( coord ) * 0.5;
  648. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  649. #endif
  650. }`,Pm=`#ifdef USE_LIGHTMAP
  651. uniform sampler2D lightMap;
  652. uniform float lightMapIntensity;
  653. #endif`,Im=`LambertMaterial material;
  654. material.diffuseColor = diffuseColor.rgb;
  655. material.specularStrength = specularStrength;`,Lm=`varying vec3 vViewPosition;
  656. struct LambertMaterial {
  657. vec3 diffuseColor;
  658. float specularStrength;
  659. };
  660. 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 ) {
  661. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  662. vec3 irradiance = dotNL * directLight.color;
  663. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  664. }
  665. 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 ) {
  666. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  667. }
  668. #define RE_Direct RE_Direct_Lambert
  669. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Um=`uniform bool receiveShadow;
  670. uniform vec3 ambientLightColor;
  671. #if defined( USE_LIGHT_PROBES )
  672. uniform vec3 lightProbe[ 9 ];
  673. #endif
  674. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  675. float x = normal.x, y = normal.y, z = normal.z;
  676. vec3 result = shCoefficients[ 0 ] * 0.886227;
  677. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  678. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  679. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  680. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  681. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  682. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  683. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  684. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  685. return result;
  686. }
  687. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  688. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  689. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  690. return irradiance;
  691. }
  692. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  693. vec3 irradiance = ambientLightColor;
  694. return irradiance;
  695. }
  696. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  697. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  698. if ( cutoffDistance > 0.0 ) {
  699. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  700. }
  701. return distanceFalloff;
  702. }
  703. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  704. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  705. }
  706. #if NUM_DIR_LIGHTS > 0
  707. struct DirectionalLight {
  708. vec3 direction;
  709. vec3 color;
  710. };
  711. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  712. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  713. light.color = directionalLight.color;
  714. light.direction = directionalLight.direction;
  715. light.visible = true;
  716. }
  717. #endif
  718. #if NUM_POINT_LIGHTS > 0
  719. struct PointLight {
  720. vec3 position;
  721. vec3 color;
  722. float distance;
  723. float decay;
  724. };
  725. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  726. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  727. vec3 lVector = pointLight.position - geometryPosition;
  728. light.direction = normalize( lVector );
  729. float lightDistance = length( lVector );
  730. light.color = pointLight.color;
  731. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  732. light.visible = ( light.color != vec3( 0.0 ) );
  733. }
  734. #endif
  735. #if NUM_SPOT_LIGHTS > 0
  736. struct SpotLight {
  737. vec3 position;
  738. vec3 direction;
  739. vec3 color;
  740. float distance;
  741. float decay;
  742. float coneCos;
  743. float penumbraCos;
  744. };
  745. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  746. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  747. vec3 lVector = spotLight.position - geometryPosition;
  748. light.direction = normalize( lVector );
  749. float angleCos = dot( light.direction, spotLight.direction );
  750. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  751. if ( spotAttenuation > 0.0 ) {
  752. float lightDistance = length( lVector );
  753. light.color = spotLight.color * spotAttenuation;
  754. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  755. light.visible = ( light.color != vec3( 0.0 ) );
  756. } else {
  757. light.color = vec3( 0.0 );
  758. light.visible = false;
  759. }
  760. }
  761. #endif
  762. #if NUM_RECT_AREA_LIGHTS > 0
  763. struct RectAreaLight {
  764. vec3 color;
  765. vec3 position;
  766. vec3 halfWidth;
  767. vec3 halfHeight;
  768. };
  769. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  770. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  771. #endif
  772. #if NUM_HEMI_LIGHTS > 0
  773. struct HemisphereLight {
  774. vec3 direction;
  775. vec3 skyColor;
  776. vec3 groundColor;
  777. };
  778. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  779. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  780. float dotNL = dot( normal, hemiLight.direction );
  781. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  782. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  783. return irradiance;
  784. }
  785. #endif`,Dm=`#ifdef USE_ENVMAP
  786. vec3 getIBLIrradiance( const in vec3 normal ) {
  787. #ifdef ENVMAP_TYPE_CUBE_UV
  788. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  789. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  790. return PI * envMapColor.rgb * envMapIntensity;
  791. #else
  792. return vec3( 0.0 );
  793. #endif
  794. }
  795. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  796. #ifdef ENVMAP_TYPE_CUBE_UV
  797. vec3 reflectVec = reflect( - viewDir, normal );
  798. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  799. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  800. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  801. return envMapColor.rgb * envMapIntensity;
  802. #else
  803. return vec3( 0.0 );
  804. #endif
  805. }
  806. #ifdef USE_ANISOTROPY
  807. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  808. #ifdef ENVMAP_TYPE_CUBE_UV
  809. vec3 bentNormal = cross( bitangent, viewDir );
  810. bentNormal = normalize( cross( bentNormal, bitangent ) );
  811. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  812. return getIBLRadiance( viewDir, bentNormal, roughness );
  813. #else
  814. return vec3( 0.0 );
  815. #endif
  816. }
  817. #endif
  818. #endif`,Nm=`ToonMaterial material;
  819. material.diffuseColor = diffuseColor.rgb;`,Fm=`varying vec3 vViewPosition;
  820. struct ToonMaterial {
  821. vec3 diffuseColor;
  822. };
  823. 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 ) {
  824. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  825. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  826. }
  827. 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 ) {
  828. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  829. }
  830. #define RE_Direct RE_Direct_Toon
  831. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Om=`BlinnPhongMaterial material;
  832. material.diffuseColor = diffuseColor.rgb;
  833. material.specularColor = specular;
  834. material.specularShininess = shininess;
  835. material.specularStrength = specularStrength;`,Bm=`varying vec3 vViewPosition;
  836. struct BlinnPhongMaterial {
  837. vec3 diffuseColor;
  838. vec3 specularColor;
  839. float specularShininess;
  840. float specularStrength;
  841. };
  842. 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 ) {
  843. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  844. vec3 irradiance = dotNL * directLight.color;
  845. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  846. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  847. }
  848. 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 ) {
  849. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  850. }
  851. #define RE_Direct RE_Direct_BlinnPhong
  852. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,zm=`PhysicalMaterial material;
  853. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  854. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  855. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  856. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  857. material.roughness = min( material.roughness, 1.0 );
  858. #ifdef IOR
  859. material.ior = ior;
  860. #ifdef USE_SPECULAR
  861. float specularIntensityFactor = specularIntensity;
  862. vec3 specularColorFactor = specularColor;
  863. #ifdef USE_SPECULAR_COLORMAP
  864. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  865. #endif
  866. #ifdef USE_SPECULAR_INTENSITYMAP
  867. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  868. #endif
  869. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  870. #else
  871. float specularIntensityFactor = 1.0;
  872. vec3 specularColorFactor = vec3( 1.0 );
  873. material.specularF90 = 1.0;
  874. #endif
  875. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  876. #else
  877. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  878. material.specularF90 = 1.0;
  879. #endif
  880. #ifdef USE_CLEARCOAT
  881. material.clearcoat = clearcoat;
  882. material.clearcoatRoughness = clearcoatRoughness;
  883. material.clearcoatF0 = vec3( 0.04 );
  884. material.clearcoatF90 = 1.0;
  885. #ifdef USE_CLEARCOATMAP
  886. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  887. #endif
  888. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  889. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  890. #endif
  891. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  892. material.clearcoatRoughness += geometryRoughness;
  893. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  894. #endif
  895. #ifdef USE_DISPERSION
  896. material.dispersion = dispersion;
  897. #endif
  898. #ifdef USE_IRIDESCENCE
  899. material.iridescence = iridescence;
  900. material.iridescenceIOR = iridescenceIOR;
  901. #ifdef USE_IRIDESCENCEMAP
  902. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  903. #endif
  904. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  905. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  906. #else
  907. material.iridescenceThickness = iridescenceThicknessMaximum;
  908. #endif
  909. #endif
  910. #ifdef USE_SHEEN
  911. material.sheenColor = sheenColor;
  912. #ifdef USE_SHEEN_COLORMAP
  913. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  914. #endif
  915. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  916. #ifdef USE_SHEEN_ROUGHNESSMAP
  917. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  918. #endif
  919. #endif
  920. #ifdef USE_ANISOTROPY
  921. #ifdef USE_ANISOTROPYMAP
  922. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  923. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  924. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  925. #else
  926. vec2 anisotropyV = anisotropyVector;
  927. #endif
  928. material.anisotropy = length( anisotropyV );
  929. if( material.anisotropy == 0.0 ) {
  930. anisotropyV = vec2( 1.0, 0.0 );
  931. } else {
  932. anisotropyV /= material.anisotropy;
  933. material.anisotropy = saturate( material.anisotropy );
  934. }
  935. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  936. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  937. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  938. #endif`,km=`struct PhysicalMaterial {
  939. vec3 diffuseColor;
  940. float roughness;
  941. vec3 specularColor;
  942. float specularF90;
  943. float dispersion;
  944. #ifdef USE_CLEARCOAT
  945. float clearcoat;
  946. float clearcoatRoughness;
  947. vec3 clearcoatF0;
  948. float clearcoatF90;
  949. #endif
  950. #ifdef USE_IRIDESCENCE
  951. float iridescence;
  952. float iridescenceIOR;
  953. float iridescenceThickness;
  954. vec3 iridescenceFresnel;
  955. vec3 iridescenceF0;
  956. #endif
  957. #ifdef USE_SHEEN
  958. vec3 sheenColor;
  959. float sheenRoughness;
  960. #endif
  961. #ifdef IOR
  962. float ior;
  963. #endif
  964. #ifdef USE_TRANSMISSION
  965. float transmission;
  966. float transmissionAlpha;
  967. float thickness;
  968. float attenuationDistance;
  969. vec3 attenuationColor;
  970. #endif
  971. #ifdef USE_ANISOTROPY
  972. float anisotropy;
  973. float alphaT;
  974. vec3 anisotropyT;
  975. vec3 anisotropyB;
  976. #endif
  977. };
  978. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  979. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  980. vec3 sheenSpecularDirect = vec3( 0.0 );
  981. vec3 sheenSpecularIndirect = vec3(0.0 );
  982. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  983. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  984. float x2 = x * x;
  985. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  986. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  987. }
  988. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  989. float a2 = pow2( alpha );
  990. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  991. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  992. return 0.5 / max( gv + gl, EPSILON );
  993. }
  994. float D_GGX( const in float alpha, const in float dotNH ) {
  995. float a2 = pow2( alpha );
  996. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  997. return RECIPROCAL_PI * a2 / pow2( denom );
  998. }
  999. #ifdef USE_ANISOTROPY
  1000. 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 ) {
  1001. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1002. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1003. float v = 0.5 / ( gv + gl );
  1004. return saturate(v);
  1005. }
  1006. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1007. float a2 = alphaT * alphaB;
  1008. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1009. highp float v2 = dot( v, v );
  1010. float w2 = a2 / v2;
  1011. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1012. }
  1013. #endif
  1014. #ifdef USE_CLEARCOAT
  1015. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1016. vec3 f0 = material.clearcoatF0;
  1017. float f90 = material.clearcoatF90;
  1018. float roughness = material.clearcoatRoughness;
  1019. float alpha = pow2( roughness );
  1020. vec3 halfDir = normalize( lightDir + viewDir );
  1021. float dotNL = saturate( dot( normal, lightDir ) );
  1022. float dotNV = saturate( dot( normal, viewDir ) );
  1023. float dotNH = saturate( dot( normal, halfDir ) );
  1024. float dotVH = saturate( dot( viewDir, halfDir ) );
  1025. vec3 F = F_Schlick( f0, f90, dotVH );
  1026. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1027. float D = D_GGX( alpha, dotNH );
  1028. return F * ( V * D );
  1029. }
  1030. #endif
  1031. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1032. vec3 f0 = material.specularColor;
  1033. float f90 = material.specularF90;
  1034. float roughness = material.roughness;
  1035. float alpha = pow2( roughness );
  1036. vec3 halfDir = normalize( lightDir + viewDir );
  1037. float dotNL = saturate( dot( normal, lightDir ) );
  1038. float dotNV = saturate( dot( normal, viewDir ) );
  1039. float dotNH = saturate( dot( normal, halfDir ) );
  1040. float dotVH = saturate( dot( viewDir, halfDir ) );
  1041. vec3 F = F_Schlick( f0, f90, dotVH );
  1042. #ifdef USE_IRIDESCENCE
  1043. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1044. #endif
  1045. #ifdef USE_ANISOTROPY
  1046. float dotTL = dot( material.anisotropyT, lightDir );
  1047. float dotTV = dot( material.anisotropyT, viewDir );
  1048. float dotTH = dot( material.anisotropyT, halfDir );
  1049. float dotBL = dot( material.anisotropyB, lightDir );
  1050. float dotBV = dot( material.anisotropyB, viewDir );
  1051. float dotBH = dot( material.anisotropyB, halfDir );
  1052. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1053. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1054. #else
  1055. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1056. float D = D_GGX( alpha, dotNH );
  1057. #endif
  1058. return F * ( V * D );
  1059. }
  1060. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1061. const float LUT_SIZE = 64.0;
  1062. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1063. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1064. float dotNV = saturate( dot( N, V ) );
  1065. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1066. uv = uv * LUT_SCALE + LUT_BIAS;
  1067. return uv;
  1068. }
  1069. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1070. float l = length( f );
  1071. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1072. }
  1073. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1074. float x = dot( v1, v2 );
  1075. float y = abs( x );
  1076. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1077. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1078. float v = a / b;
  1079. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1080. return cross( v1, v2 ) * theta_sintheta;
  1081. }
  1082. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1083. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1084. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1085. vec3 lightNormal = cross( v1, v2 );
  1086. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1087. vec3 T1, T2;
  1088. T1 = normalize( V - N * dot( V, N ) );
  1089. T2 = - cross( N, T1 );
  1090. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  1091. vec3 coords[ 4 ];
  1092. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1093. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1094. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1095. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1096. coords[ 0 ] = normalize( coords[ 0 ] );
  1097. coords[ 1 ] = normalize( coords[ 1 ] );
  1098. coords[ 2 ] = normalize( coords[ 2 ] );
  1099. coords[ 3 ] = normalize( coords[ 3 ] );
  1100. vec3 vectorFormFactor = vec3( 0.0 );
  1101. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1102. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1103. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1104. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1105. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1106. return vec3( result );
  1107. }
  1108. #if defined( USE_SHEEN )
  1109. float D_Charlie( float roughness, float dotNH ) {
  1110. float alpha = pow2( roughness );
  1111. float invAlpha = 1.0 / alpha;
  1112. float cos2h = dotNH * dotNH;
  1113. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1114. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1115. }
  1116. float V_Neubelt( float dotNV, float dotNL ) {
  1117. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1118. }
  1119. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1120. vec3 halfDir = normalize( lightDir + viewDir );
  1121. float dotNL = saturate( dot( normal, lightDir ) );
  1122. float dotNV = saturate( dot( normal, viewDir ) );
  1123. float dotNH = saturate( dot( normal, halfDir ) );
  1124. float D = D_Charlie( sheenRoughness, dotNH );
  1125. float V = V_Neubelt( dotNV, dotNL );
  1126. return sheenColor * ( D * V );
  1127. }
  1128. #endif
  1129. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1130. float dotNV = saturate( dot( normal, viewDir ) );
  1131. float r2 = roughness * roughness;
  1132. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1133. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1134. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1135. return saturate( DG * RECIPROCAL_PI );
  1136. }
  1137. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1138. float dotNV = saturate( dot( normal, viewDir ) );
  1139. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  1140. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  1141. vec4 r = roughness * c0 + c1;
  1142. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  1143. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  1144. return fab;
  1145. }
  1146. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1147. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1148. return specularColor * fab.x + specularF90 * fab.y;
  1149. }
  1150. #ifdef USE_IRIDESCENCE
  1151. 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 ) {
  1152. #else
  1153. 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 ) {
  1154. #endif
  1155. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1156. #ifdef USE_IRIDESCENCE
  1157. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1158. #else
  1159. vec3 Fr = specularColor;
  1160. #endif
  1161. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1162. float Ess = fab.x + fab.y;
  1163. float Ems = 1.0 - Ess;
  1164. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1165. singleScatter += FssEss;
  1166. multiScatter += Fms * Ems;
  1167. }
  1168. #if NUM_RECT_AREA_LIGHTS > 0
  1169. 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 ) {
  1170. vec3 normal = geometryNormal;
  1171. vec3 viewDir = geometryViewDir;
  1172. vec3 position = geometryPosition;
  1173. vec3 lightPos = rectAreaLight.position;
  1174. vec3 halfWidth = rectAreaLight.halfWidth;
  1175. vec3 halfHeight = rectAreaLight.halfHeight;
  1176. vec3 lightColor = rectAreaLight.color;
  1177. float roughness = material.roughness;
  1178. vec3 rectCoords[ 4 ];
  1179. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1180. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1181. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1182. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1183. vec4 t1 = texture2D( ltc_1, uv );
  1184. vec4 t2 = texture2D( ltc_2, uv );
  1185. mat3 mInv = mat3(
  1186. vec3( t1.x, 0, t1.y ),
  1187. vec3( 0, 1, 0 ),
  1188. vec3( t1.z, 0, t1.w )
  1189. );
  1190. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1191. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1192. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1193. }
  1194. #endif
  1195. 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 ) {
  1196. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1197. vec3 irradiance = dotNL * directLight.color;
  1198. #ifdef USE_CLEARCOAT
  1199. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1200. vec3 ccIrradiance = dotNLcc * directLight.color;
  1201. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1202. #endif
  1203. #ifdef USE_SHEEN
  1204. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1205. #endif
  1206. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  1207. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1208. }
  1209. 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 ) {
  1210. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1211. }
  1212. 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) {
  1213. #ifdef USE_CLEARCOAT
  1214. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1215. #endif
  1216. #ifdef USE_SHEEN
  1217. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1218. #endif
  1219. vec3 singleScattering = vec3( 0.0 );
  1220. vec3 multiScattering = vec3( 0.0 );
  1221. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1222. #ifdef USE_IRIDESCENCE
  1223. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1224. #else
  1225. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1226. #endif
  1227. vec3 totalScattering = singleScattering + multiScattering;
  1228. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1229. reflectedLight.indirectSpecular += radiance * singleScattering;
  1230. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1231. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1232. }
  1233. #define RE_Direct RE_Direct_Physical
  1234. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1235. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1236. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1237. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1238. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1239. }`,Vm=`
  1240. vec3 geometryPosition = - vViewPosition;
  1241. vec3 geometryNormal = normal;
  1242. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1243. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1244. #ifdef USE_CLEARCOAT
  1245. geometryClearcoatNormal = clearcoatNormal;
  1246. #endif
  1247. #ifdef USE_IRIDESCENCE
  1248. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1249. if ( material.iridescenceThickness == 0.0 ) {
  1250. material.iridescence = 0.0;
  1251. } else {
  1252. material.iridescence = saturate( material.iridescence );
  1253. }
  1254. if ( material.iridescence > 0.0 ) {
  1255. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1256. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1257. }
  1258. #endif
  1259. IncidentLight directLight;
  1260. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1261. PointLight pointLight;
  1262. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1263. PointLightShadow pointLightShadow;
  1264. #endif
  1265. #pragma unroll_loop_start
  1266. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1267. pointLight = pointLights[ i ];
  1268. getPointLightInfo( pointLight, geometryPosition, directLight );
  1269. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1270. pointLightShadow = pointLightShadows[ i ];
  1271. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1272. #endif
  1273. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1274. }
  1275. #pragma unroll_loop_end
  1276. #endif
  1277. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1278. SpotLight spotLight;
  1279. vec4 spotColor;
  1280. vec3 spotLightCoord;
  1281. bool inSpotLightMap;
  1282. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1283. SpotLightShadow spotLightShadow;
  1284. #endif
  1285. #pragma unroll_loop_start
  1286. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1287. spotLight = spotLights[ i ];
  1288. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1289. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1290. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1291. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1292. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1293. #else
  1294. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1295. #endif
  1296. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1297. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1298. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1299. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1300. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1301. #endif
  1302. #undef SPOT_LIGHT_MAP_INDEX
  1303. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1304. spotLightShadow = spotLightShadows[ i ];
  1305. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1306. #endif
  1307. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1308. }
  1309. #pragma unroll_loop_end
  1310. #endif
  1311. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1312. DirectionalLight directionalLight;
  1313. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1314. DirectionalLightShadow directionalLightShadow;
  1315. #endif
  1316. #pragma unroll_loop_start
  1317. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1318. directionalLight = directionalLights[ i ];
  1319. getDirectionalLightInfo( directionalLight, directLight );
  1320. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1321. directionalLightShadow = directionalLightShadows[ i ];
  1322. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1323. #endif
  1324. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1325. }
  1326. #pragma unroll_loop_end
  1327. #endif
  1328. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1329. RectAreaLight rectAreaLight;
  1330. #pragma unroll_loop_start
  1331. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1332. rectAreaLight = rectAreaLights[ i ];
  1333. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1334. }
  1335. #pragma unroll_loop_end
  1336. #endif
  1337. #if defined( RE_IndirectDiffuse )
  1338. vec3 iblIrradiance = vec3( 0.0 );
  1339. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1340. #if defined( USE_LIGHT_PROBES )
  1341. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1342. #endif
  1343. #if ( NUM_HEMI_LIGHTS > 0 )
  1344. #pragma unroll_loop_start
  1345. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1346. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1347. }
  1348. #pragma unroll_loop_end
  1349. #endif
  1350. #endif
  1351. #if defined( RE_IndirectSpecular )
  1352. vec3 radiance = vec3( 0.0 );
  1353. vec3 clearcoatRadiance = vec3( 0.0 );
  1354. #endif`,Hm=`#if defined( RE_IndirectDiffuse )
  1355. #ifdef USE_LIGHTMAP
  1356. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1357. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1358. irradiance += lightMapIrradiance;
  1359. #endif
  1360. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1361. iblIrradiance += getIBLIrradiance( geometryNormal );
  1362. #endif
  1363. #endif
  1364. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1365. #ifdef USE_ANISOTROPY
  1366. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1367. #else
  1368. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1369. #endif
  1370. #ifdef USE_CLEARCOAT
  1371. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1372. #endif
  1373. #endif`,Gm=`#if defined( RE_IndirectDiffuse )
  1374. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1375. #endif
  1376. #if defined( RE_IndirectSpecular )
  1377. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1378. #endif`,Wm=`#if defined( USE_LOGDEPTHBUF )
  1379. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1380. #endif`,Xm=`#if defined( USE_LOGDEPTHBUF )
  1381. uniform float logDepthBufFC;
  1382. varying float vFragDepth;
  1383. varying float vIsPerspective;
  1384. #endif`,qm=`#ifdef USE_LOGDEPTHBUF
  1385. varying float vFragDepth;
  1386. varying float vIsPerspective;
  1387. #endif`,Ym=`#ifdef USE_LOGDEPTHBUF
  1388. vFragDepth = 1.0 + gl_Position.w;
  1389. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1390. #endif`,Zm=`#ifdef USE_MAP
  1391. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1392. #ifdef DECODE_VIDEO_TEXTURE
  1393. sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
  1394. #endif
  1395. diffuseColor *= sampledDiffuseColor;
  1396. #endif`,Jm=`#ifdef USE_MAP
  1397. uniform sampler2D map;
  1398. #endif`,$m=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1399. #if defined( USE_POINTS_UV )
  1400. vec2 uv = vUv;
  1401. #else
  1402. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1403. #endif
  1404. #endif
  1405. #ifdef USE_MAP
  1406. diffuseColor *= texture2D( map, uv );
  1407. #endif
  1408. #ifdef USE_ALPHAMAP
  1409. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1410. #endif`,Km=`#if defined( USE_POINTS_UV )
  1411. varying vec2 vUv;
  1412. #else
  1413. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1414. uniform mat3 uvTransform;
  1415. #endif
  1416. #endif
  1417. #ifdef USE_MAP
  1418. uniform sampler2D map;
  1419. #endif
  1420. #ifdef USE_ALPHAMAP
  1421. uniform sampler2D alphaMap;
  1422. #endif`,Qm=`float metalnessFactor = metalness;
  1423. #ifdef USE_METALNESSMAP
  1424. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1425. metalnessFactor *= texelMetalness.b;
  1426. #endif`,jm=`#ifdef USE_METALNESSMAP
  1427. uniform sampler2D metalnessMap;
  1428. #endif`,tg=`#ifdef USE_INSTANCING_MORPH
  1429. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1430. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1431. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1432. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1433. }
  1434. #endif`,eg=`#if defined( USE_MORPHCOLORS )
  1435. vColor *= morphTargetBaseInfluence;
  1436. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1437. #if defined( USE_COLOR_ALPHA )
  1438. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1439. #elif defined( USE_COLOR )
  1440. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1441. #endif
  1442. }
  1443. #endif`,ng=`#ifdef USE_MORPHNORMALS
  1444. objectNormal *= morphTargetBaseInfluence;
  1445. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1446. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1447. }
  1448. #endif`,ig=`#ifdef USE_MORPHTARGETS
  1449. #ifndef USE_INSTANCING_MORPH
  1450. uniform float morphTargetBaseInfluence;
  1451. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1452. #endif
  1453. uniform sampler2DArray morphTargetsTexture;
  1454. uniform ivec2 morphTargetsTextureSize;
  1455. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1456. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1457. int y = texelIndex / morphTargetsTextureSize.x;
  1458. int x = texelIndex - y * morphTargetsTextureSize.x;
  1459. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1460. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1461. }
  1462. #endif`,sg=`#ifdef USE_MORPHTARGETS
  1463. transformed *= morphTargetBaseInfluence;
  1464. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1465. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1466. }
  1467. #endif`,rg=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1468. #ifdef FLAT_SHADED
  1469. vec3 fdx = dFdx( vViewPosition );
  1470. vec3 fdy = dFdy( vViewPosition );
  1471. vec3 normal = normalize( cross( fdx, fdy ) );
  1472. #else
  1473. vec3 normal = normalize( vNormal );
  1474. #ifdef DOUBLE_SIDED
  1475. normal *= faceDirection;
  1476. #endif
  1477. #endif
  1478. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1479. #ifdef USE_TANGENT
  1480. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1481. #else
  1482. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1483. #if defined( USE_NORMALMAP )
  1484. vNormalMapUv
  1485. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1486. vClearcoatNormalMapUv
  1487. #else
  1488. vUv
  1489. #endif
  1490. );
  1491. #endif
  1492. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1493. tbn[0] *= faceDirection;
  1494. tbn[1] *= faceDirection;
  1495. #endif
  1496. #endif
  1497. #ifdef USE_CLEARCOAT_NORMALMAP
  1498. #ifdef USE_TANGENT
  1499. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1500. #else
  1501. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1502. #endif
  1503. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1504. tbn2[0] *= faceDirection;
  1505. tbn2[1] *= faceDirection;
  1506. #endif
  1507. #endif
  1508. vec3 nonPerturbedNormal = normal;`,ag=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1509. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1510. #ifdef FLIP_SIDED
  1511. normal = - normal;
  1512. #endif
  1513. #ifdef DOUBLE_SIDED
  1514. normal = normal * faceDirection;
  1515. #endif
  1516. normal = normalize( normalMatrix * normal );
  1517. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1518. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1519. mapN.xy *= normalScale;
  1520. normal = normalize( tbn * mapN );
  1521. #elif defined( USE_BUMPMAP )
  1522. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1523. #endif`,og=`#ifndef FLAT_SHADED
  1524. varying vec3 vNormal;
  1525. #ifdef USE_TANGENT
  1526. varying vec3 vTangent;
  1527. varying vec3 vBitangent;
  1528. #endif
  1529. #endif`,lg=`#ifndef FLAT_SHADED
  1530. varying vec3 vNormal;
  1531. #ifdef USE_TANGENT
  1532. varying vec3 vTangent;
  1533. varying vec3 vBitangent;
  1534. #endif
  1535. #endif`,cg=`#ifndef FLAT_SHADED
  1536. vNormal = normalize( transformedNormal );
  1537. #ifdef USE_TANGENT
  1538. vTangent = normalize( transformedTangent );
  1539. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1540. #endif
  1541. #endif`,hg=`#ifdef USE_NORMALMAP
  1542. uniform sampler2D normalMap;
  1543. uniform vec2 normalScale;
  1544. #endif
  1545. #ifdef USE_NORMALMAP_OBJECTSPACE
  1546. uniform mat3 normalMatrix;
  1547. #endif
  1548. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1549. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1550. vec3 q0 = dFdx( eye_pos.xyz );
  1551. vec3 q1 = dFdy( eye_pos.xyz );
  1552. vec2 st0 = dFdx( uv.st );
  1553. vec2 st1 = dFdy( uv.st );
  1554. vec3 N = surf_norm;
  1555. vec3 q1perp = cross( q1, N );
  1556. vec3 q0perp = cross( N, q0 );
  1557. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1558. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1559. float det = max( dot( T, T ), dot( B, B ) );
  1560. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1561. return mat3( T * scale, B * scale, N );
  1562. }
  1563. #endif`,ug=`#ifdef USE_CLEARCOAT
  1564. vec3 clearcoatNormal = nonPerturbedNormal;
  1565. #endif`,dg=`#ifdef USE_CLEARCOAT_NORMALMAP
  1566. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1567. clearcoatMapN.xy *= clearcoatNormalScale;
  1568. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1569. #endif`,fg=`#ifdef USE_CLEARCOATMAP
  1570. uniform sampler2D clearcoatMap;
  1571. #endif
  1572. #ifdef USE_CLEARCOAT_NORMALMAP
  1573. uniform sampler2D clearcoatNormalMap;
  1574. uniform vec2 clearcoatNormalScale;
  1575. #endif
  1576. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1577. uniform sampler2D clearcoatRoughnessMap;
  1578. #endif`,pg=`#ifdef USE_IRIDESCENCEMAP
  1579. uniform sampler2D iridescenceMap;
  1580. #endif
  1581. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1582. uniform sampler2D iridescenceThicknessMap;
  1583. #endif`,mg=`#ifdef OPAQUE
  1584. diffuseColor.a = 1.0;
  1585. #endif
  1586. #ifdef USE_TRANSMISSION
  1587. diffuseColor.a *= material.transmissionAlpha;
  1588. #endif
  1589. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,gg=`vec3 packNormalToRGB( const in vec3 normal ) {
  1590. return normalize( normal ) * 0.5 + 0.5;
  1591. }
  1592. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1593. return 2.0 * rgb.xyz - 1.0;
  1594. }
  1595. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  1596. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  1597. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  1598. const float ShiftRight8 = 1. / 256.;
  1599. vec4 packDepthToRGBA( const in float v ) {
  1600. vec4 r = vec4( fract( v * PackFactors ), v );
  1601. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  1602. }
  1603. float unpackRGBAToDepth( const in vec4 v ) {
  1604. return dot( v, UnpackFactors );
  1605. }
  1606. vec2 packDepthToRG( in highp float v ) {
  1607. return packDepthToRGBA( v ).yx;
  1608. }
  1609. float unpackRGToDepth( const in highp vec2 v ) {
  1610. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  1611. }
  1612. vec4 pack2HalfToRGBA( vec2 v ) {
  1613. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1614. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1615. }
  1616. vec2 unpackRGBATo2Half( vec4 v ) {
  1617. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1618. }
  1619. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1620. return ( viewZ + near ) / ( near - far );
  1621. }
  1622. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1623. return depth * ( near - far ) - near;
  1624. }
  1625. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1626. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1627. }
  1628. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1629. return ( near * far ) / ( ( far - near ) * depth - far );
  1630. }`,_g=`#ifdef PREMULTIPLIED_ALPHA
  1631. gl_FragColor.rgb *= gl_FragColor.a;
  1632. #endif`,xg=`vec4 mvPosition = vec4( transformed, 1.0 );
  1633. #ifdef USE_BATCHING
  1634. mvPosition = batchingMatrix * mvPosition;
  1635. #endif
  1636. #ifdef USE_INSTANCING
  1637. mvPosition = instanceMatrix * mvPosition;
  1638. #endif
  1639. mvPosition = modelViewMatrix * mvPosition;
  1640. gl_Position = projectionMatrix * mvPosition;`,vg=`#ifdef DITHERING
  1641. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1642. #endif`,yg=`#ifdef DITHERING
  1643. vec3 dithering( vec3 color ) {
  1644. float grid_position = rand( gl_FragCoord.xy );
  1645. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1646. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1647. return color + dither_shift_RGB;
  1648. }
  1649. #endif`,Mg=`float roughnessFactor = roughness;
  1650. #ifdef USE_ROUGHNESSMAP
  1651. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1652. roughnessFactor *= texelRoughness.g;
  1653. #endif`,Sg=`#ifdef USE_ROUGHNESSMAP
  1654. uniform sampler2D roughnessMap;
  1655. #endif`,bg=`#if NUM_SPOT_LIGHT_COORDS > 0
  1656. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1657. #endif
  1658. #if NUM_SPOT_LIGHT_MAPS > 0
  1659. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1660. #endif
  1661. #ifdef USE_SHADOWMAP
  1662. #if NUM_DIR_LIGHT_SHADOWS > 0
  1663. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1664. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1665. struct DirectionalLightShadow {
  1666. float shadowBias;
  1667. float shadowNormalBias;
  1668. float shadowRadius;
  1669. vec2 shadowMapSize;
  1670. };
  1671. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1672. #endif
  1673. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1674. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1675. struct SpotLightShadow {
  1676. float shadowBias;
  1677. float shadowNormalBias;
  1678. float shadowRadius;
  1679. vec2 shadowMapSize;
  1680. };
  1681. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1682. #endif
  1683. #if NUM_POINT_LIGHT_SHADOWS > 0
  1684. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1685. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1686. struct PointLightShadow {
  1687. float shadowBias;
  1688. float shadowNormalBias;
  1689. float shadowRadius;
  1690. vec2 shadowMapSize;
  1691. float shadowCameraNear;
  1692. float shadowCameraFar;
  1693. };
  1694. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1695. #endif
  1696. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1697. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  1698. }
  1699. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1700. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1701. }
  1702. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  1703. float occlusion = 1.0;
  1704. vec2 distribution = texture2DDistribution( shadow, uv );
  1705. float hard_shadow = step( compare , distribution.x );
  1706. if (hard_shadow != 1.0 ) {
  1707. float distance = compare - distribution.x ;
  1708. float variance = max( 0.00000, distribution.y * distribution.y );
  1709. 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 );
  1710. }
  1711. return occlusion;
  1712. }
  1713. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1714. float shadow = 1.0;
  1715. shadowCoord.xyz /= shadowCoord.w;
  1716. shadowCoord.z += shadowBias;
  1717. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1718. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1719. if ( frustumTest ) {
  1720. #if defined( SHADOWMAP_TYPE_PCF )
  1721. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1722. float dx0 = - texelSize.x * shadowRadius;
  1723. float dy0 = - texelSize.y * shadowRadius;
  1724. float dx1 = + texelSize.x * shadowRadius;
  1725. float dy1 = + texelSize.y * shadowRadius;
  1726. float dx2 = dx0 / 2.0;
  1727. float dy2 = dy0 / 2.0;
  1728. float dx3 = dx1 / 2.0;
  1729. float dy3 = dy1 / 2.0;
  1730. shadow = (
  1731. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1732. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1733. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1734. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1735. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1736. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1737. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1738. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1739. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1740. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1741. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1742. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1743. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1744. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1745. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1746. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1747. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1748. ) * ( 1.0 / 17.0 );
  1749. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1750. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1751. float dx = texelSize.x;
  1752. float dy = texelSize.y;
  1753. vec2 uv = shadowCoord.xy;
  1754. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1755. uv -= f * texelSize;
  1756. shadow = (
  1757. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1758. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1759. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1760. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1761. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1762. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1763. f.x ) +
  1764. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1765. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1766. f.x ) +
  1767. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1768. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1769. f.y ) +
  1770. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1771. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1772. f.y ) +
  1773. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1774. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1775. f.x ),
  1776. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1777. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1778. f.x ),
  1779. f.y )
  1780. ) * ( 1.0 / 9.0 );
  1781. #elif defined( SHADOWMAP_TYPE_VSM )
  1782. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1783. #else
  1784. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1785. #endif
  1786. }
  1787. return shadow;
  1788. }
  1789. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1790. vec3 absV = abs( v );
  1791. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1792. absV *= scaleToCube;
  1793. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1794. vec2 planar = v.xy;
  1795. float almostATexel = 1.5 * texelSizeY;
  1796. float almostOne = 1.0 - almostATexel;
  1797. if ( absV.z >= almostOne ) {
  1798. if ( v.z > 0.0 )
  1799. planar.x = 4.0 - v.x;
  1800. } else if ( absV.x >= almostOne ) {
  1801. float signX = sign( v.x );
  1802. planar.x = v.z * signX + 2.0 * signX;
  1803. } else if ( absV.y >= almostOne ) {
  1804. float signY = sign( v.y );
  1805. planar.x = v.x + 2.0 * signY + 2.0;
  1806. planar.y = v.z * signY - 2.0;
  1807. }
  1808. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1809. }
  1810. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1811. float shadow = 1.0;
  1812. vec3 lightToPosition = shadowCoord.xyz;
  1813. float lightToPositionLength = length( lightToPosition );
  1814. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1815. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1816. vec3 bd3D = normalize( lightToPosition );
  1817. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1818. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1819. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1820. shadow = (
  1821. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1822. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1823. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1824. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1825. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1826. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1827. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1828. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1829. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1830. ) * ( 1.0 / 9.0 );
  1831. #else
  1832. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1833. #endif
  1834. }
  1835. return shadow;
  1836. }
  1837. #endif`,Ag=`#if NUM_SPOT_LIGHT_COORDS > 0
  1838. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1839. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1840. #endif
  1841. #ifdef USE_SHADOWMAP
  1842. #if NUM_DIR_LIGHT_SHADOWS > 0
  1843. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1844. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1845. struct DirectionalLightShadow {
  1846. float shadowBias;
  1847. float shadowNormalBias;
  1848. float shadowRadius;
  1849. vec2 shadowMapSize;
  1850. };
  1851. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1852. #endif
  1853. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1854. struct SpotLightShadow {
  1855. float shadowBias;
  1856. float shadowNormalBias;
  1857. float shadowRadius;
  1858. vec2 shadowMapSize;
  1859. };
  1860. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1861. #endif
  1862. #if NUM_POINT_LIGHT_SHADOWS > 0
  1863. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1864. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1865. struct PointLightShadow {
  1866. float shadowBias;
  1867. float shadowNormalBias;
  1868. float shadowRadius;
  1869. vec2 shadowMapSize;
  1870. float shadowCameraNear;
  1871. float shadowCameraFar;
  1872. };
  1873. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1874. #endif
  1875. #endif`,wg=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1876. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1877. vec4 shadowWorldPosition;
  1878. #endif
  1879. #if defined( USE_SHADOWMAP )
  1880. #if NUM_DIR_LIGHT_SHADOWS > 0
  1881. #pragma unroll_loop_start
  1882. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1883. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1884. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1885. }
  1886. #pragma unroll_loop_end
  1887. #endif
  1888. #if NUM_POINT_LIGHT_SHADOWS > 0
  1889. #pragma unroll_loop_start
  1890. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1891. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1892. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1893. }
  1894. #pragma unroll_loop_end
  1895. #endif
  1896. #endif
  1897. #if NUM_SPOT_LIGHT_COORDS > 0
  1898. #pragma unroll_loop_start
  1899. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1900. shadowWorldPosition = worldPosition;
  1901. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1902. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1903. #endif
  1904. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1905. }
  1906. #pragma unroll_loop_end
  1907. #endif`,Eg=`float getShadowMask() {
  1908. float shadow = 1.0;
  1909. #ifdef USE_SHADOWMAP
  1910. #if NUM_DIR_LIGHT_SHADOWS > 0
  1911. DirectionalLightShadow directionalLight;
  1912. #pragma unroll_loop_start
  1913. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1914. directionalLight = directionalLightShadows[ i ];
  1915. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1916. }
  1917. #pragma unroll_loop_end
  1918. #endif
  1919. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1920. SpotLightShadow spotLight;
  1921. #pragma unroll_loop_start
  1922. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1923. spotLight = spotLightShadows[ i ];
  1924. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1925. }
  1926. #pragma unroll_loop_end
  1927. #endif
  1928. #if NUM_POINT_LIGHT_SHADOWS > 0
  1929. PointLightShadow pointLight;
  1930. #pragma unroll_loop_start
  1931. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1932. pointLight = pointLightShadows[ i ];
  1933. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1934. }
  1935. #pragma unroll_loop_end
  1936. #endif
  1937. #endif
  1938. return shadow;
  1939. }`,Tg=`#ifdef USE_SKINNING
  1940. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1941. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1942. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1943. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1944. #endif`,Cg=`#ifdef USE_SKINNING
  1945. uniform mat4 bindMatrix;
  1946. uniform mat4 bindMatrixInverse;
  1947. uniform highp sampler2D boneTexture;
  1948. mat4 getBoneMatrix( const in float i ) {
  1949. int size = textureSize( boneTexture, 0 ).x;
  1950. int j = int( i ) * 4;
  1951. int x = j % size;
  1952. int y = j / size;
  1953. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1954. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  1955. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  1956. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  1957. return mat4( v1, v2, v3, v4 );
  1958. }
  1959. #endif`,Rg=`#ifdef USE_SKINNING
  1960. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  1961. vec4 skinned = vec4( 0.0 );
  1962. skinned += boneMatX * skinVertex * skinWeight.x;
  1963. skinned += boneMatY * skinVertex * skinWeight.y;
  1964. skinned += boneMatZ * skinVertex * skinWeight.z;
  1965. skinned += boneMatW * skinVertex * skinWeight.w;
  1966. transformed = ( bindMatrixInverse * skinned ).xyz;
  1967. #endif`,Pg=`#ifdef USE_SKINNING
  1968. mat4 skinMatrix = mat4( 0.0 );
  1969. skinMatrix += skinWeight.x * boneMatX;
  1970. skinMatrix += skinWeight.y * boneMatY;
  1971. skinMatrix += skinWeight.z * boneMatZ;
  1972. skinMatrix += skinWeight.w * boneMatW;
  1973. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  1974. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  1975. #ifdef USE_TANGENT
  1976. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  1977. #endif
  1978. #endif`,Ig=`float specularStrength;
  1979. #ifdef USE_SPECULARMAP
  1980. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  1981. specularStrength = texelSpecular.r;
  1982. #else
  1983. specularStrength = 1.0;
  1984. #endif`,Lg=`#ifdef USE_SPECULARMAP
  1985. uniform sampler2D specularMap;
  1986. #endif`,Ug=`#if defined( TONE_MAPPING )
  1987. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  1988. #endif`,Dg=`#ifndef saturate
  1989. #define saturate( a ) clamp( a, 0.0, 1.0 )
  1990. #endif
  1991. uniform float toneMappingExposure;
  1992. vec3 LinearToneMapping( vec3 color ) {
  1993. return saturate( toneMappingExposure * color );
  1994. }
  1995. vec3 ReinhardToneMapping( vec3 color ) {
  1996. color *= toneMappingExposure;
  1997. return saturate( color / ( vec3( 1.0 ) + color ) );
  1998. }
  1999. vec3 OptimizedCineonToneMapping( vec3 color ) {
  2000. color *= toneMappingExposure;
  2001. color = max( vec3( 0.0 ), color - 0.004 );
  2002. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2003. }
  2004. vec3 RRTAndODTFit( vec3 v ) {
  2005. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2006. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2007. return a / b;
  2008. }
  2009. vec3 ACESFilmicToneMapping( vec3 color ) {
  2010. const mat3 ACESInputMat = mat3(
  2011. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2012. vec3( 0.04823, 0.01566, 0.83777 )
  2013. );
  2014. const mat3 ACESOutputMat = mat3(
  2015. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2016. vec3( -0.07367, -0.00605, 1.07602 )
  2017. );
  2018. color *= toneMappingExposure / 0.6;
  2019. color = ACESInputMat * color;
  2020. color = RRTAndODTFit( color );
  2021. color = ACESOutputMat * color;
  2022. return saturate( color );
  2023. }
  2024. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2025. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2026. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2027. vec3( - 0.0728, - 0.0083, 1.1187 )
  2028. );
  2029. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2030. vec3( 0.6274, 0.0691, 0.0164 ),
  2031. vec3( 0.3293, 0.9195, 0.0880 ),
  2032. vec3( 0.0433, 0.0113, 0.8956 )
  2033. );
  2034. vec3 agxDefaultContrastApprox( vec3 x ) {
  2035. vec3 x2 = x * x;
  2036. vec3 x4 = x2 * x2;
  2037. return + 15.5 * x4 * x2
  2038. - 40.14 * x4 * x
  2039. + 31.96 * x4
  2040. - 6.868 * x2 * x
  2041. + 0.4298 * x2
  2042. + 0.1191 * x
  2043. - 0.00232;
  2044. }
  2045. vec3 AgXToneMapping( vec3 color ) {
  2046. const mat3 AgXInsetMatrix = mat3(
  2047. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2048. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2049. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2050. );
  2051. const mat3 AgXOutsetMatrix = mat3(
  2052. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2053. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2054. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2055. );
  2056. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2057. color *= toneMappingExposure;
  2058. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2059. color = AgXInsetMatrix * color;
  2060. color = max( color, 1e-10 ); color = log2( color );
  2061. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2062. color = clamp( color, 0.0, 1.0 );
  2063. color = agxDefaultContrastApprox( color );
  2064. color = AgXOutsetMatrix * color;
  2065. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2066. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2067. color = clamp( color, 0.0, 1.0 );
  2068. return color;
  2069. }
  2070. vec3 NeutralToneMapping( vec3 color ) {
  2071. const float StartCompression = 0.8 - 0.04;
  2072. const float Desaturation = 0.15;
  2073. color *= toneMappingExposure;
  2074. float x = min( color.r, min( color.g, color.b ) );
  2075. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2076. color -= offset;
  2077. float peak = max( color.r, max( color.g, color.b ) );
  2078. if ( peak < StartCompression ) return color;
  2079. float d = 1. - StartCompression;
  2080. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2081. color *= newPeak / peak;
  2082. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2083. return mix( color, vec3( newPeak ), g );
  2084. }
  2085. vec3 CustomToneMapping( vec3 color ) { return color; }`,Ng=`#ifdef USE_TRANSMISSION
  2086. material.transmission = transmission;
  2087. material.transmissionAlpha = 1.0;
  2088. material.thickness = thickness;
  2089. material.attenuationDistance = attenuationDistance;
  2090. material.attenuationColor = attenuationColor;
  2091. #ifdef USE_TRANSMISSIONMAP
  2092. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2093. #endif
  2094. #ifdef USE_THICKNESSMAP
  2095. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2096. #endif
  2097. vec3 pos = vWorldPosition;
  2098. vec3 v = normalize( cameraPosition - pos );
  2099. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2100. vec4 transmitted = getIBLVolumeRefraction(
  2101. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2102. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2103. material.attenuationColor, material.attenuationDistance );
  2104. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2105. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2106. #endif`,Fg=`#ifdef USE_TRANSMISSION
  2107. uniform float transmission;
  2108. uniform float thickness;
  2109. uniform float attenuationDistance;
  2110. uniform vec3 attenuationColor;
  2111. #ifdef USE_TRANSMISSIONMAP
  2112. uniform sampler2D transmissionMap;
  2113. #endif
  2114. #ifdef USE_THICKNESSMAP
  2115. uniform sampler2D thicknessMap;
  2116. #endif
  2117. uniform vec2 transmissionSamplerSize;
  2118. uniform sampler2D transmissionSamplerMap;
  2119. uniform mat4 modelMatrix;
  2120. uniform mat4 projectionMatrix;
  2121. varying vec3 vWorldPosition;
  2122. float w0( float a ) {
  2123. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2124. }
  2125. float w1( float a ) {
  2126. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2127. }
  2128. float w2( float a ){
  2129. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2130. }
  2131. float w3( float a ) {
  2132. return ( 1.0 / 6.0 ) * ( a * a * a );
  2133. }
  2134. float g0( float a ) {
  2135. return w0( a ) + w1( a );
  2136. }
  2137. float g1( float a ) {
  2138. return w2( a ) + w3( a );
  2139. }
  2140. float h0( float a ) {
  2141. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2142. }
  2143. float h1( float a ) {
  2144. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2145. }
  2146. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2147. uv = uv * texelSize.zw + 0.5;
  2148. vec2 iuv = floor( uv );
  2149. vec2 fuv = fract( uv );
  2150. float g0x = g0( fuv.x );
  2151. float g1x = g1( fuv.x );
  2152. float h0x = h0( fuv.x );
  2153. float h1x = h1( fuv.x );
  2154. float h0y = h0( fuv.y );
  2155. float h1y = h1( fuv.y );
  2156. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2157. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2158. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2159. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2160. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2161. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2162. }
  2163. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2164. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2165. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2166. vec2 fLodSizeInv = 1.0 / fLodSize;
  2167. vec2 cLodSizeInv = 1.0 / cLodSize;
  2168. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2169. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2170. return mix( fSample, cSample, fract( lod ) );
  2171. }
  2172. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2173. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2174. vec3 modelScale;
  2175. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2176. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2177. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2178. return normalize( refractionVector ) * thickness * modelScale;
  2179. }
  2180. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2181. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2182. }
  2183. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2184. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2185. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2186. }
  2187. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2188. if ( isinf( attenuationDistance ) ) {
  2189. return vec3( 1.0 );
  2190. } else {
  2191. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2192. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2193. }
  2194. }
  2195. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2196. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2197. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2198. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2199. vec4 transmittedLight;
  2200. vec3 transmittance;
  2201. #ifdef USE_DISPERSION
  2202. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2203. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2204. for ( int i = 0; i < 3; i ++ ) {
  2205. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2206. vec3 refractedRayExit = position + transmissionRay;
  2207. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2208. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2209. refractionCoords += 1.0;
  2210. refractionCoords /= 2.0;
  2211. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2212. transmittedLight[ i ] = transmissionSample[ i ];
  2213. transmittedLight.a += transmissionSample.a;
  2214. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2215. }
  2216. transmittedLight.a /= 3.0;
  2217. #else
  2218. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2219. vec3 refractedRayExit = position + transmissionRay;
  2220. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2221. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2222. refractionCoords += 1.0;
  2223. refractionCoords /= 2.0;
  2224. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2225. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2226. #endif
  2227. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2228. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2229. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2230. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2231. }
  2232. #endif`,Og=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2233. varying vec2 vUv;
  2234. #endif
  2235. #ifdef USE_MAP
  2236. varying vec2 vMapUv;
  2237. #endif
  2238. #ifdef USE_ALPHAMAP
  2239. varying vec2 vAlphaMapUv;
  2240. #endif
  2241. #ifdef USE_LIGHTMAP
  2242. varying vec2 vLightMapUv;
  2243. #endif
  2244. #ifdef USE_AOMAP
  2245. varying vec2 vAoMapUv;
  2246. #endif
  2247. #ifdef USE_BUMPMAP
  2248. varying vec2 vBumpMapUv;
  2249. #endif
  2250. #ifdef USE_NORMALMAP
  2251. varying vec2 vNormalMapUv;
  2252. #endif
  2253. #ifdef USE_EMISSIVEMAP
  2254. varying vec2 vEmissiveMapUv;
  2255. #endif
  2256. #ifdef USE_METALNESSMAP
  2257. varying vec2 vMetalnessMapUv;
  2258. #endif
  2259. #ifdef USE_ROUGHNESSMAP
  2260. varying vec2 vRoughnessMapUv;
  2261. #endif
  2262. #ifdef USE_ANISOTROPYMAP
  2263. varying vec2 vAnisotropyMapUv;
  2264. #endif
  2265. #ifdef USE_CLEARCOATMAP
  2266. varying vec2 vClearcoatMapUv;
  2267. #endif
  2268. #ifdef USE_CLEARCOAT_NORMALMAP
  2269. varying vec2 vClearcoatNormalMapUv;
  2270. #endif
  2271. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2272. varying vec2 vClearcoatRoughnessMapUv;
  2273. #endif
  2274. #ifdef USE_IRIDESCENCEMAP
  2275. varying vec2 vIridescenceMapUv;
  2276. #endif
  2277. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2278. varying vec2 vIridescenceThicknessMapUv;
  2279. #endif
  2280. #ifdef USE_SHEEN_COLORMAP
  2281. varying vec2 vSheenColorMapUv;
  2282. #endif
  2283. #ifdef USE_SHEEN_ROUGHNESSMAP
  2284. varying vec2 vSheenRoughnessMapUv;
  2285. #endif
  2286. #ifdef USE_SPECULARMAP
  2287. varying vec2 vSpecularMapUv;
  2288. #endif
  2289. #ifdef USE_SPECULAR_COLORMAP
  2290. varying vec2 vSpecularColorMapUv;
  2291. #endif
  2292. #ifdef USE_SPECULAR_INTENSITYMAP
  2293. varying vec2 vSpecularIntensityMapUv;
  2294. #endif
  2295. #ifdef USE_TRANSMISSIONMAP
  2296. uniform mat3 transmissionMapTransform;
  2297. varying vec2 vTransmissionMapUv;
  2298. #endif
  2299. #ifdef USE_THICKNESSMAP
  2300. uniform mat3 thicknessMapTransform;
  2301. varying vec2 vThicknessMapUv;
  2302. #endif`,Bg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2303. varying vec2 vUv;
  2304. #endif
  2305. #ifdef USE_MAP
  2306. uniform mat3 mapTransform;
  2307. varying vec2 vMapUv;
  2308. #endif
  2309. #ifdef USE_ALPHAMAP
  2310. uniform mat3 alphaMapTransform;
  2311. varying vec2 vAlphaMapUv;
  2312. #endif
  2313. #ifdef USE_LIGHTMAP
  2314. uniform mat3 lightMapTransform;
  2315. varying vec2 vLightMapUv;
  2316. #endif
  2317. #ifdef USE_AOMAP
  2318. uniform mat3 aoMapTransform;
  2319. varying vec2 vAoMapUv;
  2320. #endif
  2321. #ifdef USE_BUMPMAP
  2322. uniform mat3 bumpMapTransform;
  2323. varying vec2 vBumpMapUv;
  2324. #endif
  2325. #ifdef USE_NORMALMAP
  2326. uniform mat3 normalMapTransform;
  2327. varying vec2 vNormalMapUv;
  2328. #endif
  2329. #ifdef USE_DISPLACEMENTMAP
  2330. uniform mat3 displacementMapTransform;
  2331. varying vec2 vDisplacementMapUv;
  2332. #endif
  2333. #ifdef USE_EMISSIVEMAP
  2334. uniform mat3 emissiveMapTransform;
  2335. varying vec2 vEmissiveMapUv;
  2336. #endif
  2337. #ifdef USE_METALNESSMAP
  2338. uniform mat3 metalnessMapTransform;
  2339. varying vec2 vMetalnessMapUv;
  2340. #endif
  2341. #ifdef USE_ROUGHNESSMAP
  2342. uniform mat3 roughnessMapTransform;
  2343. varying vec2 vRoughnessMapUv;
  2344. #endif
  2345. #ifdef USE_ANISOTROPYMAP
  2346. uniform mat3 anisotropyMapTransform;
  2347. varying vec2 vAnisotropyMapUv;
  2348. #endif
  2349. #ifdef USE_CLEARCOATMAP
  2350. uniform mat3 clearcoatMapTransform;
  2351. varying vec2 vClearcoatMapUv;
  2352. #endif
  2353. #ifdef USE_CLEARCOAT_NORMALMAP
  2354. uniform mat3 clearcoatNormalMapTransform;
  2355. varying vec2 vClearcoatNormalMapUv;
  2356. #endif
  2357. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2358. uniform mat3 clearcoatRoughnessMapTransform;
  2359. varying vec2 vClearcoatRoughnessMapUv;
  2360. #endif
  2361. #ifdef USE_SHEEN_COLORMAP
  2362. uniform mat3 sheenColorMapTransform;
  2363. varying vec2 vSheenColorMapUv;
  2364. #endif
  2365. #ifdef USE_SHEEN_ROUGHNESSMAP
  2366. uniform mat3 sheenRoughnessMapTransform;
  2367. varying vec2 vSheenRoughnessMapUv;
  2368. #endif
  2369. #ifdef USE_IRIDESCENCEMAP
  2370. uniform mat3 iridescenceMapTransform;
  2371. varying vec2 vIridescenceMapUv;
  2372. #endif
  2373. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2374. uniform mat3 iridescenceThicknessMapTransform;
  2375. varying vec2 vIridescenceThicknessMapUv;
  2376. #endif
  2377. #ifdef USE_SPECULARMAP
  2378. uniform mat3 specularMapTransform;
  2379. varying vec2 vSpecularMapUv;
  2380. #endif
  2381. #ifdef USE_SPECULAR_COLORMAP
  2382. uniform mat3 specularColorMapTransform;
  2383. varying vec2 vSpecularColorMapUv;
  2384. #endif
  2385. #ifdef USE_SPECULAR_INTENSITYMAP
  2386. uniform mat3 specularIntensityMapTransform;
  2387. varying vec2 vSpecularIntensityMapUv;
  2388. #endif
  2389. #ifdef USE_TRANSMISSIONMAP
  2390. uniform mat3 transmissionMapTransform;
  2391. varying vec2 vTransmissionMapUv;
  2392. #endif
  2393. #ifdef USE_THICKNESSMAP
  2394. uniform mat3 thicknessMapTransform;
  2395. varying vec2 vThicknessMapUv;
  2396. #endif`,zg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2397. vUv = vec3( uv, 1 ).xy;
  2398. #endif
  2399. #ifdef USE_MAP
  2400. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2401. #endif
  2402. #ifdef USE_ALPHAMAP
  2403. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2404. #endif
  2405. #ifdef USE_LIGHTMAP
  2406. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2407. #endif
  2408. #ifdef USE_AOMAP
  2409. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2410. #endif
  2411. #ifdef USE_BUMPMAP
  2412. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2413. #endif
  2414. #ifdef USE_NORMALMAP
  2415. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2416. #endif
  2417. #ifdef USE_DISPLACEMENTMAP
  2418. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2419. #endif
  2420. #ifdef USE_EMISSIVEMAP
  2421. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2422. #endif
  2423. #ifdef USE_METALNESSMAP
  2424. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2425. #endif
  2426. #ifdef USE_ROUGHNESSMAP
  2427. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2428. #endif
  2429. #ifdef USE_ANISOTROPYMAP
  2430. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2431. #endif
  2432. #ifdef USE_CLEARCOATMAP
  2433. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2434. #endif
  2435. #ifdef USE_CLEARCOAT_NORMALMAP
  2436. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2437. #endif
  2438. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2439. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2440. #endif
  2441. #ifdef USE_IRIDESCENCEMAP
  2442. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2443. #endif
  2444. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2445. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_SHEEN_COLORMAP
  2448. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_SHEEN_ROUGHNESSMAP
  2451. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_SPECULARMAP
  2454. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_SPECULAR_COLORMAP
  2457. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_SPECULAR_INTENSITYMAP
  2460. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_TRANSMISSIONMAP
  2463. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_THICKNESSMAP
  2466. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2467. #endif`,kg=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2468. vec4 worldPosition = vec4( transformed, 1.0 );
  2469. #ifdef USE_BATCHING
  2470. worldPosition = batchingMatrix * worldPosition;
  2471. #endif
  2472. #ifdef USE_INSTANCING
  2473. worldPosition = instanceMatrix * worldPosition;
  2474. #endif
  2475. worldPosition = modelMatrix * worldPosition;
  2476. #endif`;const Vg=`varying vec2 vUv;
  2477. uniform mat3 uvTransform;
  2478. void main() {
  2479. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2480. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2481. }`,Hg=`uniform sampler2D t2D;
  2482. uniform float backgroundIntensity;
  2483. varying vec2 vUv;
  2484. void main() {
  2485. vec4 texColor = texture2D( t2D, vUv );
  2486. #ifdef DECODE_VIDEO_TEXTURE
  2487. 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 );
  2488. #endif
  2489. texColor.rgb *= backgroundIntensity;
  2490. gl_FragColor = texColor;
  2491. #include <tonemapping_fragment>
  2492. #include <colorspace_fragment>
  2493. }`,Gg=`varying vec3 vWorldDirection;
  2494. #include <common>
  2495. void main() {
  2496. vWorldDirection = transformDirection( position, modelMatrix );
  2497. #include <begin_vertex>
  2498. #include <project_vertex>
  2499. gl_Position.z = gl_Position.w;
  2500. }`,Wg=`#ifdef ENVMAP_TYPE_CUBE
  2501. uniform samplerCube envMap;
  2502. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2503. uniform sampler2D envMap;
  2504. #endif
  2505. uniform float flipEnvMap;
  2506. uniform float backgroundBlurriness;
  2507. uniform float backgroundIntensity;
  2508. uniform mat3 backgroundRotation;
  2509. varying vec3 vWorldDirection;
  2510. #include <cube_uv_reflection_fragment>
  2511. void main() {
  2512. #ifdef ENVMAP_TYPE_CUBE
  2513. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2514. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2515. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2516. #else
  2517. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2518. #endif
  2519. texColor.rgb *= backgroundIntensity;
  2520. gl_FragColor = texColor;
  2521. #include <tonemapping_fragment>
  2522. #include <colorspace_fragment>
  2523. }`,Xg=`varying vec3 vWorldDirection;
  2524. #include <common>
  2525. void main() {
  2526. vWorldDirection = transformDirection( position, modelMatrix );
  2527. #include <begin_vertex>
  2528. #include <project_vertex>
  2529. gl_Position.z = gl_Position.w;
  2530. }`,qg=`uniform samplerCube tCube;
  2531. uniform float tFlip;
  2532. uniform float opacity;
  2533. varying vec3 vWorldDirection;
  2534. void main() {
  2535. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2536. gl_FragColor = texColor;
  2537. gl_FragColor.a *= opacity;
  2538. #include <tonemapping_fragment>
  2539. #include <colorspace_fragment>
  2540. }`,Yg=`#include <common>
  2541. #include <batching_pars_vertex>
  2542. #include <uv_pars_vertex>
  2543. #include <displacementmap_pars_vertex>
  2544. #include <morphtarget_pars_vertex>
  2545. #include <skinning_pars_vertex>
  2546. #include <logdepthbuf_pars_vertex>
  2547. #include <clipping_planes_pars_vertex>
  2548. varying vec2 vHighPrecisionZW;
  2549. void main() {
  2550. #include <uv_vertex>
  2551. #include <batching_vertex>
  2552. #include <skinbase_vertex>
  2553. #include <morphinstance_vertex>
  2554. #ifdef USE_DISPLACEMENTMAP
  2555. #include <beginnormal_vertex>
  2556. #include <morphnormal_vertex>
  2557. #include <skinnormal_vertex>
  2558. #endif
  2559. #include <begin_vertex>
  2560. #include <morphtarget_vertex>
  2561. #include <skinning_vertex>
  2562. #include <displacementmap_vertex>
  2563. #include <project_vertex>
  2564. #include <logdepthbuf_vertex>
  2565. #include <clipping_planes_vertex>
  2566. vHighPrecisionZW = gl_Position.zw;
  2567. }`,Zg=`#if DEPTH_PACKING == 3200
  2568. uniform float opacity;
  2569. #endif
  2570. #include <common>
  2571. #include <packing>
  2572. #include <uv_pars_fragment>
  2573. #include <map_pars_fragment>
  2574. #include <alphamap_pars_fragment>
  2575. #include <alphatest_pars_fragment>
  2576. #include <alphahash_pars_fragment>
  2577. #include <logdepthbuf_pars_fragment>
  2578. #include <clipping_planes_pars_fragment>
  2579. varying vec2 vHighPrecisionZW;
  2580. void main() {
  2581. vec4 diffuseColor = vec4( 1.0 );
  2582. #include <clipping_planes_fragment>
  2583. #if DEPTH_PACKING == 3200
  2584. diffuseColor.a = opacity;
  2585. #endif
  2586. #include <map_fragment>
  2587. #include <alphamap_fragment>
  2588. #include <alphatest_fragment>
  2589. #include <alphahash_fragment>
  2590. #include <logdepthbuf_fragment>
  2591. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  2592. #if DEPTH_PACKING == 3200
  2593. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2594. #elif DEPTH_PACKING == 3201
  2595. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2596. #endif
  2597. }`,Jg=`#define DISTANCE
  2598. varying vec3 vWorldPosition;
  2599. #include <common>
  2600. #include <batching_pars_vertex>
  2601. #include <uv_pars_vertex>
  2602. #include <displacementmap_pars_vertex>
  2603. #include <morphtarget_pars_vertex>
  2604. #include <skinning_pars_vertex>
  2605. #include <clipping_planes_pars_vertex>
  2606. void main() {
  2607. #include <uv_vertex>
  2608. #include <batching_vertex>
  2609. #include <skinbase_vertex>
  2610. #include <morphinstance_vertex>
  2611. #ifdef USE_DISPLACEMENTMAP
  2612. #include <beginnormal_vertex>
  2613. #include <morphnormal_vertex>
  2614. #include <skinnormal_vertex>
  2615. #endif
  2616. #include <begin_vertex>
  2617. #include <morphtarget_vertex>
  2618. #include <skinning_vertex>
  2619. #include <displacementmap_vertex>
  2620. #include <project_vertex>
  2621. #include <worldpos_vertex>
  2622. #include <clipping_planes_vertex>
  2623. vWorldPosition = worldPosition.xyz;
  2624. }`,$g=`#define DISTANCE
  2625. uniform vec3 referencePosition;
  2626. uniform float nearDistance;
  2627. uniform float farDistance;
  2628. varying vec3 vWorldPosition;
  2629. #include <common>
  2630. #include <packing>
  2631. #include <uv_pars_fragment>
  2632. #include <map_pars_fragment>
  2633. #include <alphamap_pars_fragment>
  2634. #include <alphatest_pars_fragment>
  2635. #include <alphahash_pars_fragment>
  2636. #include <clipping_planes_pars_fragment>
  2637. void main () {
  2638. vec4 diffuseColor = vec4( 1.0 );
  2639. #include <clipping_planes_fragment>
  2640. #include <map_fragment>
  2641. #include <alphamap_fragment>
  2642. #include <alphatest_fragment>
  2643. #include <alphahash_fragment>
  2644. float dist = length( vWorldPosition - referencePosition );
  2645. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2646. dist = saturate( dist );
  2647. gl_FragColor = packDepthToRGBA( dist );
  2648. }`,Kg=`varying vec3 vWorldDirection;
  2649. #include <common>
  2650. void main() {
  2651. vWorldDirection = transformDirection( position, modelMatrix );
  2652. #include <begin_vertex>
  2653. #include <project_vertex>
  2654. }`,Qg=`uniform sampler2D tEquirect;
  2655. varying vec3 vWorldDirection;
  2656. #include <common>
  2657. void main() {
  2658. vec3 direction = normalize( vWorldDirection );
  2659. vec2 sampleUV = equirectUv( direction );
  2660. gl_FragColor = texture2D( tEquirect, sampleUV );
  2661. #include <tonemapping_fragment>
  2662. #include <colorspace_fragment>
  2663. }`,jg=`uniform float scale;
  2664. attribute float lineDistance;
  2665. varying float vLineDistance;
  2666. #include <common>
  2667. #include <uv_pars_vertex>
  2668. #include <color_pars_vertex>
  2669. #include <fog_pars_vertex>
  2670. #include <morphtarget_pars_vertex>
  2671. #include <logdepthbuf_pars_vertex>
  2672. #include <clipping_planes_pars_vertex>
  2673. void main() {
  2674. vLineDistance = scale * lineDistance;
  2675. #include <uv_vertex>
  2676. #include <color_vertex>
  2677. #include <morphinstance_vertex>
  2678. #include <morphcolor_vertex>
  2679. #include <begin_vertex>
  2680. #include <morphtarget_vertex>
  2681. #include <project_vertex>
  2682. #include <logdepthbuf_vertex>
  2683. #include <clipping_planes_vertex>
  2684. #include <fog_vertex>
  2685. }`,t_=`uniform vec3 diffuse;
  2686. uniform float opacity;
  2687. uniform float dashSize;
  2688. uniform float totalSize;
  2689. varying float vLineDistance;
  2690. #include <common>
  2691. #include <color_pars_fragment>
  2692. #include <uv_pars_fragment>
  2693. #include <map_pars_fragment>
  2694. #include <fog_pars_fragment>
  2695. #include <logdepthbuf_pars_fragment>
  2696. #include <clipping_planes_pars_fragment>
  2697. void main() {
  2698. vec4 diffuseColor = vec4( diffuse, opacity );
  2699. #include <clipping_planes_fragment>
  2700. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2701. discard;
  2702. }
  2703. vec3 outgoingLight = vec3( 0.0 );
  2704. #include <logdepthbuf_fragment>
  2705. #include <map_fragment>
  2706. #include <color_fragment>
  2707. outgoingLight = diffuseColor.rgb;
  2708. #include <opaque_fragment>
  2709. #include <tonemapping_fragment>
  2710. #include <colorspace_fragment>
  2711. #include <fog_fragment>
  2712. #include <premultiplied_alpha_fragment>
  2713. }`,e_=`#include <common>
  2714. #include <batching_pars_vertex>
  2715. #include <uv_pars_vertex>
  2716. #include <envmap_pars_vertex>
  2717. #include <color_pars_vertex>
  2718. #include <fog_pars_vertex>
  2719. #include <morphtarget_pars_vertex>
  2720. #include <skinning_pars_vertex>
  2721. #include <logdepthbuf_pars_vertex>
  2722. #include <clipping_planes_pars_vertex>
  2723. void main() {
  2724. #include <uv_vertex>
  2725. #include <color_vertex>
  2726. #include <morphinstance_vertex>
  2727. #include <morphcolor_vertex>
  2728. #include <batching_vertex>
  2729. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2730. #include <beginnormal_vertex>
  2731. #include <morphnormal_vertex>
  2732. #include <skinbase_vertex>
  2733. #include <skinnormal_vertex>
  2734. #include <defaultnormal_vertex>
  2735. #endif
  2736. #include <begin_vertex>
  2737. #include <morphtarget_vertex>
  2738. #include <skinning_vertex>
  2739. #include <project_vertex>
  2740. #include <logdepthbuf_vertex>
  2741. #include <clipping_planes_vertex>
  2742. #include <worldpos_vertex>
  2743. #include <envmap_vertex>
  2744. #include <fog_vertex>
  2745. }`,n_=`uniform vec3 diffuse;
  2746. uniform float opacity;
  2747. #ifndef FLAT_SHADED
  2748. varying vec3 vNormal;
  2749. #endif
  2750. #include <common>
  2751. #include <dithering_pars_fragment>
  2752. #include <color_pars_fragment>
  2753. #include <uv_pars_fragment>
  2754. #include <map_pars_fragment>
  2755. #include <alphamap_pars_fragment>
  2756. #include <alphatest_pars_fragment>
  2757. #include <alphahash_pars_fragment>
  2758. #include <aomap_pars_fragment>
  2759. #include <lightmap_pars_fragment>
  2760. #include <envmap_common_pars_fragment>
  2761. #include <envmap_pars_fragment>
  2762. #include <fog_pars_fragment>
  2763. #include <specularmap_pars_fragment>
  2764. #include <logdepthbuf_pars_fragment>
  2765. #include <clipping_planes_pars_fragment>
  2766. void main() {
  2767. vec4 diffuseColor = vec4( diffuse, opacity );
  2768. #include <clipping_planes_fragment>
  2769. #include <logdepthbuf_fragment>
  2770. #include <map_fragment>
  2771. #include <color_fragment>
  2772. #include <alphamap_fragment>
  2773. #include <alphatest_fragment>
  2774. #include <alphahash_fragment>
  2775. #include <specularmap_fragment>
  2776. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2777. #ifdef USE_LIGHTMAP
  2778. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2779. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2780. #else
  2781. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2782. #endif
  2783. #include <aomap_fragment>
  2784. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2785. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2786. #include <envmap_fragment>
  2787. #include <opaque_fragment>
  2788. #include <tonemapping_fragment>
  2789. #include <colorspace_fragment>
  2790. #include <fog_fragment>
  2791. #include <premultiplied_alpha_fragment>
  2792. #include <dithering_fragment>
  2793. }`,i_=`#define LAMBERT
  2794. varying vec3 vViewPosition;
  2795. #include <common>
  2796. #include <batching_pars_vertex>
  2797. #include <uv_pars_vertex>
  2798. #include <displacementmap_pars_vertex>
  2799. #include <envmap_pars_vertex>
  2800. #include <color_pars_vertex>
  2801. #include <fog_pars_vertex>
  2802. #include <normal_pars_vertex>
  2803. #include <morphtarget_pars_vertex>
  2804. #include <skinning_pars_vertex>
  2805. #include <shadowmap_pars_vertex>
  2806. #include <logdepthbuf_pars_vertex>
  2807. #include <clipping_planes_pars_vertex>
  2808. void main() {
  2809. #include <uv_vertex>
  2810. #include <color_vertex>
  2811. #include <morphinstance_vertex>
  2812. #include <morphcolor_vertex>
  2813. #include <batching_vertex>
  2814. #include <beginnormal_vertex>
  2815. #include <morphnormal_vertex>
  2816. #include <skinbase_vertex>
  2817. #include <skinnormal_vertex>
  2818. #include <defaultnormal_vertex>
  2819. #include <normal_vertex>
  2820. #include <begin_vertex>
  2821. #include <morphtarget_vertex>
  2822. #include <skinning_vertex>
  2823. #include <displacementmap_vertex>
  2824. #include <project_vertex>
  2825. #include <logdepthbuf_vertex>
  2826. #include <clipping_planes_vertex>
  2827. vViewPosition = - mvPosition.xyz;
  2828. #include <worldpos_vertex>
  2829. #include <envmap_vertex>
  2830. #include <shadowmap_vertex>
  2831. #include <fog_vertex>
  2832. }`,s_=`#define LAMBERT
  2833. uniform vec3 diffuse;
  2834. uniform vec3 emissive;
  2835. uniform float opacity;
  2836. #include <common>
  2837. #include <packing>
  2838. #include <dithering_pars_fragment>
  2839. #include <color_pars_fragment>
  2840. #include <uv_pars_fragment>
  2841. #include <map_pars_fragment>
  2842. #include <alphamap_pars_fragment>
  2843. #include <alphatest_pars_fragment>
  2844. #include <alphahash_pars_fragment>
  2845. #include <aomap_pars_fragment>
  2846. #include <lightmap_pars_fragment>
  2847. #include <emissivemap_pars_fragment>
  2848. #include <envmap_common_pars_fragment>
  2849. #include <envmap_pars_fragment>
  2850. #include <fog_pars_fragment>
  2851. #include <bsdfs>
  2852. #include <lights_pars_begin>
  2853. #include <normal_pars_fragment>
  2854. #include <lights_lambert_pars_fragment>
  2855. #include <shadowmap_pars_fragment>
  2856. #include <bumpmap_pars_fragment>
  2857. #include <normalmap_pars_fragment>
  2858. #include <specularmap_pars_fragment>
  2859. #include <logdepthbuf_pars_fragment>
  2860. #include <clipping_planes_pars_fragment>
  2861. void main() {
  2862. vec4 diffuseColor = vec4( diffuse, opacity );
  2863. #include <clipping_planes_fragment>
  2864. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2865. vec3 totalEmissiveRadiance = emissive;
  2866. #include <logdepthbuf_fragment>
  2867. #include <map_fragment>
  2868. #include <color_fragment>
  2869. #include <alphamap_fragment>
  2870. #include <alphatest_fragment>
  2871. #include <alphahash_fragment>
  2872. #include <specularmap_fragment>
  2873. #include <normal_fragment_begin>
  2874. #include <normal_fragment_maps>
  2875. #include <emissivemap_fragment>
  2876. #include <lights_lambert_fragment>
  2877. #include <lights_fragment_begin>
  2878. #include <lights_fragment_maps>
  2879. #include <lights_fragment_end>
  2880. #include <aomap_fragment>
  2881. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2882. #include <envmap_fragment>
  2883. #include <opaque_fragment>
  2884. #include <tonemapping_fragment>
  2885. #include <colorspace_fragment>
  2886. #include <fog_fragment>
  2887. #include <premultiplied_alpha_fragment>
  2888. #include <dithering_fragment>
  2889. }`,r_=`#define MATCAP
  2890. varying vec3 vViewPosition;
  2891. #include <common>
  2892. #include <batching_pars_vertex>
  2893. #include <uv_pars_vertex>
  2894. #include <color_pars_vertex>
  2895. #include <displacementmap_pars_vertex>
  2896. #include <fog_pars_vertex>
  2897. #include <normal_pars_vertex>
  2898. #include <morphtarget_pars_vertex>
  2899. #include <skinning_pars_vertex>
  2900. #include <logdepthbuf_pars_vertex>
  2901. #include <clipping_planes_pars_vertex>
  2902. void main() {
  2903. #include <uv_vertex>
  2904. #include <color_vertex>
  2905. #include <morphinstance_vertex>
  2906. #include <morphcolor_vertex>
  2907. #include <batching_vertex>
  2908. #include <beginnormal_vertex>
  2909. #include <morphnormal_vertex>
  2910. #include <skinbase_vertex>
  2911. #include <skinnormal_vertex>
  2912. #include <defaultnormal_vertex>
  2913. #include <normal_vertex>
  2914. #include <begin_vertex>
  2915. #include <morphtarget_vertex>
  2916. #include <skinning_vertex>
  2917. #include <displacementmap_vertex>
  2918. #include <project_vertex>
  2919. #include <logdepthbuf_vertex>
  2920. #include <clipping_planes_vertex>
  2921. #include <fog_vertex>
  2922. vViewPosition = - mvPosition.xyz;
  2923. }`,a_=`#define MATCAP
  2924. uniform vec3 diffuse;
  2925. uniform float opacity;
  2926. uniform sampler2D matcap;
  2927. varying vec3 vViewPosition;
  2928. #include <common>
  2929. #include <dithering_pars_fragment>
  2930. #include <color_pars_fragment>
  2931. #include <uv_pars_fragment>
  2932. #include <map_pars_fragment>
  2933. #include <alphamap_pars_fragment>
  2934. #include <alphatest_pars_fragment>
  2935. #include <alphahash_pars_fragment>
  2936. #include <fog_pars_fragment>
  2937. #include <normal_pars_fragment>
  2938. #include <bumpmap_pars_fragment>
  2939. #include <normalmap_pars_fragment>
  2940. #include <logdepthbuf_pars_fragment>
  2941. #include <clipping_planes_pars_fragment>
  2942. void main() {
  2943. vec4 diffuseColor = vec4( diffuse, opacity );
  2944. #include <clipping_planes_fragment>
  2945. #include <logdepthbuf_fragment>
  2946. #include <map_fragment>
  2947. #include <color_fragment>
  2948. #include <alphamap_fragment>
  2949. #include <alphatest_fragment>
  2950. #include <alphahash_fragment>
  2951. #include <normal_fragment_begin>
  2952. #include <normal_fragment_maps>
  2953. vec3 viewDir = normalize( vViewPosition );
  2954. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  2955. vec3 y = cross( viewDir, x );
  2956. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  2957. #ifdef USE_MATCAP
  2958. vec4 matcapColor = texture2D( matcap, uv );
  2959. #else
  2960. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  2961. #endif
  2962. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  2963. #include <opaque_fragment>
  2964. #include <tonemapping_fragment>
  2965. #include <colorspace_fragment>
  2966. #include <fog_fragment>
  2967. #include <premultiplied_alpha_fragment>
  2968. #include <dithering_fragment>
  2969. }`,o_=`#define NORMAL
  2970. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  2971. varying vec3 vViewPosition;
  2972. #endif
  2973. #include <common>
  2974. #include <batching_pars_vertex>
  2975. #include <uv_pars_vertex>
  2976. #include <displacementmap_pars_vertex>
  2977. #include <normal_pars_vertex>
  2978. #include <morphtarget_pars_vertex>
  2979. #include <skinning_pars_vertex>
  2980. #include <logdepthbuf_pars_vertex>
  2981. #include <clipping_planes_pars_vertex>
  2982. void main() {
  2983. #include <uv_vertex>
  2984. #include <batching_vertex>
  2985. #include <beginnormal_vertex>
  2986. #include <morphinstance_vertex>
  2987. #include <morphnormal_vertex>
  2988. #include <skinbase_vertex>
  2989. #include <skinnormal_vertex>
  2990. #include <defaultnormal_vertex>
  2991. #include <normal_vertex>
  2992. #include <begin_vertex>
  2993. #include <morphtarget_vertex>
  2994. #include <skinning_vertex>
  2995. #include <displacementmap_vertex>
  2996. #include <project_vertex>
  2997. #include <logdepthbuf_vertex>
  2998. #include <clipping_planes_vertex>
  2999. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3000. vViewPosition = - mvPosition.xyz;
  3001. #endif
  3002. }`,l_=`#define NORMAL
  3003. uniform float opacity;
  3004. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3005. varying vec3 vViewPosition;
  3006. #endif
  3007. #include <packing>
  3008. #include <uv_pars_fragment>
  3009. #include <normal_pars_fragment>
  3010. #include <bumpmap_pars_fragment>
  3011. #include <normalmap_pars_fragment>
  3012. #include <logdepthbuf_pars_fragment>
  3013. #include <clipping_planes_pars_fragment>
  3014. void main() {
  3015. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3016. #include <clipping_planes_fragment>
  3017. #include <logdepthbuf_fragment>
  3018. #include <normal_fragment_begin>
  3019. #include <normal_fragment_maps>
  3020. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3021. #ifdef OPAQUE
  3022. gl_FragColor.a = 1.0;
  3023. #endif
  3024. }`,c_=`#define PHONG
  3025. varying vec3 vViewPosition;
  3026. #include <common>
  3027. #include <batching_pars_vertex>
  3028. #include <uv_pars_vertex>
  3029. #include <displacementmap_pars_vertex>
  3030. #include <envmap_pars_vertex>
  3031. #include <color_pars_vertex>
  3032. #include <fog_pars_vertex>
  3033. #include <normal_pars_vertex>
  3034. #include <morphtarget_pars_vertex>
  3035. #include <skinning_pars_vertex>
  3036. #include <shadowmap_pars_vertex>
  3037. #include <logdepthbuf_pars_vertex>
  3038. #include <clipping_planes_pars_vertex>
  3039. void main() {
  3040. #include <uv_vertex>
  3041. #include <color_vertex>
  3042. #include <morphcolor_vertex>
  3043. #include <batching_vertex>
  3044. #include <beginnormal_vertex>
  3045. #include <morphinstance_vertex>
  3046. #include <morphnormal_vertex>
  3047. #include <skinbase_vertex>
  3048. #include <skinnormal_vertex>
  3049. #include <defaultnormal_vertex>
  3050. #include <normal_vertex>
  3051. #include <begin_vertex>
  3052. #include <morphtarget_vertex>
  3053. #include <skinning_vertex>
  3054. #include <displacementmap_vertex>
  3055. #include <project_vertex>
  3056. #include <logdepthbuf_vertex>
  3057. #include <clipping_planes_vertex>
  3058. vViewPosition = - mvPosition.xyz;
  3059. #include <worldpos_vertex>
  3060. #include <envmap_vertex>
  3061. #include <shadowmap_vertex>
  3062. #include <fog_vertex>
  3063. }`,h_=`#define PHONG
  3064. uniform vec3 diffuse;
  3065. uniform vec3 emissive;
  3066. uniform vec3 specular;
  3067. uniform float shininess;
  3068. uniform float opacity;
  3069. #include <common>
  3070. #include <packing>
  3071. #include <dithering_pars_fragment>
  3072. #include <color_pars_fragment>
  3073. #include <uv_pars_fragment>
  3074. #include <map_pars_fragment>
  3075. #include <alphamap_pars_fragment>
  3076. #include <alphatest_pars_fragment>
  3077. #include <alphahash_pars_fragment>
  3078. #include <aomap_pars_fragment>
  3079. #include <lightmap_pars_fragment>
  3080. #include <emissivemap_pars_fragment>
  3081. #include <envmap_common_pars_fragment>
  3082. #include <envmap_pars_fragment>
  3083. #include <fog_pars_fragment>
  3084. #include <bsdfs>
  3085. #include <lights_pars_begin>
  3086. #include <normal_pars_fragment>
  3087. #include <lights_phong_pars_fragment>
  3088. #include <shadowmap_pars_fragment>
  3089. #include <bumpmap_pars_fragment>
  3090. #include <normalmap_pars_fragment>
  3091. #include <specularmap_pars_fragment>
  3092. #include <logdepthbuf_pars_fragment>
  3093. #include <clipping_planes_pars_fragment>
  3094. void main() {
  3095. vec4 diffuseColor = vec4( diffuse, opacity );
  3096. #include <clipping_planes_fragment>
  3097. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3098. vec3 totalEmissiveRadiance = emissive;
  3099. #include <logdepthbuf_fragment>
  3100. #include <map_fragment>
  3101. #include <color_fragment>
  3102. #include <alphamap_fragment>
  3103. #include <alphatest_fragment>
  3104. #include <alphahash_fragment>
  3105. #include <specularmap_fragment>
  3106. #include <normal_fragment_begin>
  3107. #include <normal_fragment_maps>
  3108. #include <emissivemap_fragment>
  3109. #include <lights_phong_fragment>
  3110. #include <lights_fragment_begin>
  3111. #include <lights_fragment_maps>
  3112. #include <lights_fragment_end>
  3113. #include <aomap_fragment>
  3114. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3115. #include <envmap_fragment>
  3116. #include <opaque_fragment>
  3117. #include <tonemapping_fragment>
  3118. #include <colorspace_fragment>
  3119. #include <fog_fragment>
  3120. #include <premultiplied_alpha_fragment>
  3121. #include <dithering_fragment>
  3122. }`,u_=`#define STANDARD
  3123. varying vec3 vViewPosition;
  3124. #ifdef USE_TRANSMISSION
  3125. varying vec3 vWorldPosition;
  3126. #endif
  3127. #include <common>
  3128. #include <batching_pars_vertex>
  3129. #include <uv_pars_vertex>
  3130. #include <displacementmap_pars_vertex>
  3131. #include <color_pars_vertex>
  3132. #include <fog_pars_vertex>
  3133. #include <normal_pars_vertex>
  3134. #include <morphtarget_pars_vertex>
  3135. #include <skinning_pars_vertex>
  3136. #include <shadowmap_pars_vertex>
  3137. #include <logdepthbuf_pars_vertex>
  3138. #include <clipping_planes_pars_vertex>
  3139. void main() {
  3140. #include <uv_vertex>
  3141. #include <color_vertex>
  3142. #include <morphinstance_vertex>
  3143. #include <morphcolor_vertex>
  3144. #include <batching_vertex>
  3145. #include <beginnormal_vertex>
  3146. #include <morphnormal_vertex>
  3147. #include <skinbase_vertex>
  3148. #include <skinnormal_vertex>
  3149. #include <defaultnormal_vertex>
  3150. #include <normal_vertex>
  3151. #include <begin_vertex>
  3152. #include <morphtarget_vertex>
  3153. #include <skinning_vertex>
  3154. #include <displacementmap_vertex>
  3155. #include <project_vertex>
  3156. #include <logdepthbuf_vertex>
  3157. #include <clipping_planes_vertex>
  3158. vViewPosition = - mvPosition.xyz;
  3159. #include <worldpos_vertex>
  3160. #include <shadowmap_vertex>
  3161. #include <fog_vertex>
  3162. #ifdef USE_TRANSMISSION
  3163. vWorldPosition = worldPosition.xyz;
  3164. #endif
  3165. }`,d_=`#define STANDARD
  3166. #ifdef PHYSICAL
  3167. #define IOR
  3168. #define USE_SPECULAR
  3169. #endif
  3170. uniform vec3 diffuse;
  3171. uniform vec3 emissive;
  3172. uniform float roughness;
  3173. uniform float metalness;
  3174. uniform float opacity;
  3175. #ifdef IOR
  3176. uniform float ior;
  3177. #endif
  3178. #ifdef USE_SPECULAR
  3179. uniform float specularIntensity;
  3180. uniform vec3 specularColor;
  3181. #ifdef USE_SPECULAR_COLORMAP
  3182. uniform sampler2D specularColorMap;
  3183. #endif
  3184. #ifdef USE_SPECULAR_INTENSITYMAP
  3185. uniform sampler2D specularIntensityMap;
  3186. #endif
  3187. #endif
  3188. #ifdef USE_CLEARCOAT
  3189. uniform float clearcoat;
  3190. uniform float clearcoatRoughness;
  3191. #endif
  3192. #ifdef USE_DISPERSION
  3193. uniform float dispersion;
  3194. #endif
  3195. #ifdef USE_IRIDESCENCE
  3196. uniform float iridescence;
  3197. uniform float iridescenceIOR;
  3198. uniform float iridescenceThicknessMinimum;
  3199. uniform float iridescenceThicknessMaximum;
  3200. #endif
  3201. #ifdef USE_SHEEN
  3202. uniform vec3 sheenColor;
  3203. uniform float sheenRoughness;
  3204. #ifdef USE_SHEEN_COLORMAP
  3205. uniform sampler2D sheenColorMap;
  3206. #endif
  3207. #ifdef USE_SHEEN_ROUGHNESSMAP
  3208. uniform sampler2D sheenRoughnessMap;
  3209. #endif
  3210. #endif
  3211. #ifdef USE_ANISOTROPY
  3212. uniform vec2 anisotropyVector;
  3213. #ifdef USE_ANISOTROPYMAP
  3214. uniform sampler2D anisotropyMap;
  3215. #endif
  3216. #endif
  3217. varying vec3 vViewPosition;
  3218. #include <common>
  3219. #include <packing>
  3220. #include <dithering_pars_fragment>
  3221. #include <color_pars_fragment>
  3222. #include <uv_pars_fragment>
  3223. #include <map_pars_fragment>
  3224. #include <alphamap_pars_fragment>
  3225. #include <alphatest_pars_fragment>
  3226. #include <alphahash_pars_fragment>
  3227. #include <aomap_pars_fragment>
  3228. #include <lightmap_pars_fragment>
  3229. #include <emissivemap_pars_fragment>
  3230. #include <iridescence_fragment>
  3231. #include <cube_uv_reflection_fragment>
  3232. #include <envmap_common_pars_fragment>
  3233. #include <envmap_physical_pars_fragment>
  3234. #include <fog_pars_fragment>
  3235. #include <lights_pars_begin>
  3236. #include <normal_pars_fragment>
  3237. #include <lights_physical_pars_fragment>
  3238. #include <transmission_pars_fragment>
  3239. #include <shadowmap_pars_fragment>
  3240. #include <bumpmap_pars_fragment>
  3241. #include <normalmap_pars_fragment>
  3242. #include <clearcoat_pars_fragment>
  3243. #include <iridescence_pars_fragment>
  3244. #include <roughnessmap_pars_fragment>
  3245. #include <metalnessmap_pars_fragment>
  3246. #include <logdepthbuf_pars_fragment>
  3247. #include <clipping_planes_pars_fragment>
  3248. void main() {
  3249. vec4 diffuseColor = vec4( diffuse, opacity );
  3250. #include <clipping_planes_fragment>
  3251. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3252. vec3 totalEmissiveRadiance = emissive;
  3253. #include <logdepthbuf_fragment>
  3254. #include <map_fragment>
  3255. #include <color_fragment>
  3256. #include <alphamap_fragment>
  3257. #include <alphatest_fragment>
  3258. #include <alphahash_fragment>
  3259. #include <roughnessmap_fragment>
  3260. #include <metalnessmap_fragment>
  3261. #include <normal_fragment_begin>
  3262. #include <normal_fragment_maps>
  3263. #include <clearcoat_normal_fragment_begin>
  3264. #include <clearcoat_normal_fragment_maps>
  3265. #include <emissivemap_fragment>
  3266. #include <lights_physical_fragment>
  3267. #include <lights_fragment_begin>
  3268. #include <lights_fragment_maps>
  3269. #include <lights_fragment_end>
  3270. #include <aomap_fragment>
  3271. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3272. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3273. #include <transmission_fragment>
  3274. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3275. #ifdef USE_SHEEN
  3276. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3277. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3278. #endif
  3279. #ifdef USE_CLEARCOAT
  3280. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3281. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3282. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3283. #endif
  3284. #include <opaque_fragment>
  3285. #include <tonemapping_fragment>
  3286. #include <colorspace_fragment>
  3287. #include <fog_fragment>
  3288. #include <premultiplied_alpha_fragment>
  3289. #include <dithering_fragment>
  3290. }`,f_=`#define TOON
  3291. varying vec3 vViewPosition;
  3292. #include <common>
  3293. #include <batching_pars_vertex>
  3294. #include <uv_pars_vertex>
  3295. #include <displacementmap_pars_vertex>
  3296. #include <color_pars_vertex>
  3297. #include <fog_pars_vertex>
  3298. #include <normal_pars_vertex>
  3299. #include <morphtarget_pars_vertex>
  3300. #include <skinning_pars_vertex>
  3301. #include <shadowmap_pars_vertex>
  3302. #include <logdepthbuf_pars_vertex>
  3303. #include <clipping_planes_pars_vertex>
  3304. void main() {
  3305. #include <uv_vertex>
  3306. #include <color_vertex>
  3307. #include <morphinstance_vertex>
  3308. #include <morphcolor_vertex>
  3309. #include <batching_vertex>
  3310. #include <beginnormal_vertex>
  3311. #include <morphnormal_vertex>
  3312. #include <skinbase_vertex>
  3313. #include <skinnormal_vertex>
  3314. #include <defaultnormal_vertex>
  3315. #include <normal_vertex>
  3316. #include <begin_vertex>
  3317. #include <morphtarget_vertex>
  3318. #include <skinning_vertex>
  3319. #include <displacementmap_vertex>
  3320. #include <project_vertex>
  3321. #include <logdepthbuf_vertex>
  3322. #include <clipping_planes_vertex>
  3323. vViewPosition = - mvPosition.xyz;
  3324. #include <worldpos_vertex>
  3325. #include <shadowmap_vertex>
  3326. #include <fog_vertex>
  3327. }`,p_=`#define TOON
  3328. uniform vec3 diffuse;
  3329. uniform vec3 emissive;
  3330. uniform float opacity;
  3331. #include <common>
  3332. #include <packing>
  3333. #include <dithering_pars_fragment>
  3334. #include <color_pars_fragment>
  3335. #include <uv_pars_fragment>
  3336. #include <map_pars_fragment>
  3337. #include <alphamap_pars_fragment>
  3338. #include <alphatest_pars_fragment>
  3339. #include <alphahash_pars_fragment>
  3340. #include <aomap_pars_fragment>
  3341. #include <lightmap_pars_fragment>
  3342. #include <emissivemap_pars_fragment>
  3343. #include <gradientmap_pars_fragment>
  3344. #include <fog_pars_fragment>
  3345. #include <bsdfs>
  3346. #include <lights_pars_begin>
  3347. #include <normal_pars_fragment>
  3348. #include <lights_toon_pars_fragment>
  3349. #include <shadowmap_pars_fragment>
  3350. #include <bumpmap_pars_fragment>
  3351. #include <normalmap_pars_fragment>
  3352. #include <logdepthbuf_pars_fragment>
  3353. #include <clipping_planes_pars_fragment>
  3354. void main() {
  3355. vec4 diffuseColor = vec4( diffuse, opacity );
  3356. #include <clipping_planes_fragment>
  3357. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3358. vec3 totalEmissiveRadiance = emissive;
  3359. #include <logdepthbuf_fragment>
  3360. #include <map_fragment>
  3361. #include <color_fragment>
  3362. #include <alphamap_fragment>
  3363. #include <alphatest_fragment>
  3364. #include <alphahash_fragment>
  3365. #include <normal_fragment_begin>
  3366. #include <normal_fragment_maps>
  3367. #include <emissivemap_fragment>
  3368. #include <lights_toon_fragment>
  3369. #include <lights_fragment_begin>
  3370. #include <lights_fragment_maps>
  3371. #include <lights_fragment_end>
  3372. #include <aomap_fragment>
  3373. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3374. #include <opaque_fragment>
  3375. #include <tonemapping_fragment>
  3376. #include <colorspace_fragment>
  3377. #include <fog_fragment>
  3378. #include <premultiplied_alpha_fragment>
  3379. #include <dithering_fragment>
  3380. }`,m_=`uniform float size;
  3381. uniform float scale;
  3382. #include <common>
  3383. #include <color_pars_vertex>
  3384. #include <fog_pars_vertex>
  3385. #include <morphtarget_pars_vertex>
  3386. #include <logdepthbuf_pars_vertex>
  3387. #include <clipping_planes_pars_vertex>
  3388. #ifdef USE_POINTS_UV
  3389. varying vec2 vUv;
  3390. uniform mat3 uvTransform;
  3391. #endif
  3392. void main() {
  3393. #ifdef USE_POINTS_UV
  3394. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3395. #endif
  3396. #include <color_vertex>
  3397. #include <morphinstance_vertex>
  3398. #include <morphcolor_vertex>
  3399. #include <begin_vertex>
  3400. #include <morphtarget_vertex>
  3401. #include <project_vertex>
  3402. gl_PointSize = size;
  3403. #ifdef USE_SIZEATTENUATION
  3404. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3405. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3406. #endif
  3407. #include <logdepthbuf_vertex>
  3408. #include <clipping_planes_vertex>
  3409. #include <worldpos_vertex>
  3410. #include <fog_vertex>
  3411. }`,g_=`uniform vec3 diffuse;
  3412. uniform float opacity;
  3413. #include <common>
  3414. #include <color_pars_fragment>
  3415. #include <map_particle_pars_fragment>
  3416. #include <alphatest_pars_fragment>
  3417. #include <alphahash_pars_fragment>
  3418. #include <fog_pars_fragment>
  3419. #include <logdepthbuf_pars_fragment>
  3420. #include <clipping_planes_pars_fragment>
  3421. void main() {
  3422. vec4 diffuseColor = vec4( diffuse, opacity );
  3423. #include <clipping_planes_fragment>
  3424. vec3 outgoingLight = vec3( 0.0 );
  3425. #include <logdepthbuf_fragment>
  3426. #include <map_particle_fragment>
  3427. #include <color_fragment>
  3428. #include <alphatest_fragment>
  3429. #include <alphahash_fragment>
  3430. outgoingLight = diffuseColor.rgb;
  3431. #include <opaque_fragment>
  3432. #include <tonemapping_fragment>
  3433. #include <colorspace_fragment>
  3434. #include <fog_fragment>
  3435. #include <premultiplied_alpha_fragment>
  3436. }`,__=`#include <common>
  3437. #include <batching_pars_vertex>
  3438. #include <fog_pars_vertex>
  3439. #include <morphtarget_pars_vertex>
  3440. #include <skinning_pars_vertex>
  3441. #include <logdepthbuf_pars_vertex>
  3442. #include <shadowmap_pars_vertex>
  3443. void main() {
  3444. #include <batching_vertex>
  3445. #include <beginnormal_vertex>
  3446. #include <morphinstance_vertex>
  3447. #include <morphnormal_vertex>
  3448. #include <skinbase_vertex>
  3449. #include <skinnormal_vertex>
  3450. #include <defaultnormal_vertex>
  3451. #include <begin_vertex>
  3452. #include <morphtarget_vertex>
  3453. #include <skinning_vertex>
  3454. #include <project_vertex>
  3455. #include <logdepthbuf_vertex>
  3456. #include <worldpos_vertex>
  3457. #include <shadowmap_vertex>
  3458. #include <fog_vertex>
  3459. }`,x_=`uniform vec3 color;
  3460. uniform float opacity;
  3461. #include <common>
  3462. #include <packing>
  3463. #include <fog_pars_fragment>
  3464. #include <bsdfs>
  3465. #include <lights_pars_begin>
  3466. #include <logdepthbuf_pars_fragment>
  3467. #include <shadowmap_pars_fragment>
  3468. #include <shadowmask_pars_fragment>
  3469. void main() {
  3470. #include <logdepthbuf_fragment>
  3471. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3472. #include <tonemapping_fragment>
  3473. #include <colorspace_fragment>
  3474. #include <fog_fragment>
  3475. }`,v_=`uniform float rotation;
  3476. uniform vec2 center;
  3477. #include <common>
  3478. #include <uv_pars_vertex>
  3479. #include <fog_pars_vertex>
  3480. #include <logdepthbuf_pars_vertex>
  3481. #include <clipping_planes_pars_vertex>
  3482. void main() {
  3483. #include <uv_vertex>
  3484. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  3485. vec2 scale;
  3486. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  3487. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  3488. #ifndef USE_SIZEATTENUATION
  3489. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3490. if ( isPerspective ) scale *= - mvPosition.z;
  3491. #endif
  3492. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3493. vec2 rotatedPosition;
  3494. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3495. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3496. mvPosition.xy += rotatedPosition;
  3497. gl_Position = projectionMatrix * mvPosition;
  3498. #include <logdepthbuf_vertex>
  3499. #include <clipping_planes_vertex>
  3500. #include <fog_vertex>
  3501. }`,y_=`uniform vec3 diffuse;
  3502. uniform float opacity;
  3503. #include <common>
  3504. #include <uv_pars_fragment>
  3505. #include <map_pars_fragment>
  3506. #include <alphamap_pars_fragment>
  3507. #include <alphatest_pars_fragment>
  3508. #include <alphahash_pars_fragment>
  3509. #include <fog_pars_fragment>
  3510. #include <logdepthbuf_pars_fragment>
  3511. #include <clipping_planes_pars_fragment>
  3512. void main() {
  3513. vec4 diffuseColor = vec4( diffuse, opacity );
  3514. #include <clipping_planes_fragment>
  3515. vec3 outgoingLight = vec3( 0.0 );
  3516. #include <logdepthbuf_fragment>
  3517. #include <map_fragment>
  3518. #include <alphamap_fragment>
  3519. #include <alphatest_fragment>
  3520. #include <alphahash_fragment>
  3521. outgoingLight = diffuseColor.rgb;
  3522. #include <opaque_fragment>
  3523. #include <tonemapping_fragment>
  3524. #include <colorspace_fragment>
  3525. #include <fog_fragment>
  3526. }`,Vt={alphahash_fragment:Hp,alphahash_pars_fragment:Gp,alphamap_fragment:Wp,alphamap_pars_fragment:Xp,alphatest_fragment:qp,alphatest_pars_fragment:Yp,aomap_fragment:Zp,aomap_pars_fragment:Jp,batching_pars_vertex:$p,batching_vertex:Kp,begin_vertex:Qp,beginnormal_vertex:jp,bsdfs:tm,iridescence_fragment:em,bumpmap_pars_fragment:nm,clipping_planes_fragment:im,clipping_planes_pars_fragment:sm,clipping_planes_pars_vertex:rm,clipping_planes_vertex:am,color_fragment:om,color_pars_fragment:lm,color_pars_vertex:cm,color_vertex:hm,common:um,cube_uv_reflection_fragment:dm,defaultnormal_vertex:fm,displacementmap_pars_vertex:pm,displacementmap_vertex:mm,emissivemap_fragment:gm,emissivemap_pars_fragment:_m,colorspace_fragment:xm,colorspace_pars_fragment:vm,envmap_fragment:ym,envmap_common_pars_fragment:Mm,envmap_pars_fragment:Sm,envmap_pars_vertex:bm,envmap_physical_pars_fragment:Dm,envmap_vertex:Am,fog_vertex:wm,fog_pars_vertex:Em,fog_fragment:Tm,fog_pars_fragment:Cm,gradientmap_pars_fragment:Rm,lightmap_pars_fragment:Pm,lights_lambert_fragment:Im,lights_lambert_pars_fragment:Lm,lights_pars_begin:Um,lights_toon_fragment:Nm,lights_toon_pars_fragment:Fm,lights_phong_fragment:Om,lights_phong_pars_fragment:Bm,lights_physical_fragment:zm,lights_physical_pars_fragment:km,lights_fragment_begin:Vm,lights_fragment_maps:Hm,lights_fragment_end:Gm,logdepthbuf_fragment:Wm,logdepthbuf_pars_fragment:Xm,logdepthbuf_pars_vertex:qm,logdepthbuf_vertex:Ym,map_fragment:Zm,map_pars_fragment:Jm,map_particle_fragment:$m,map_particle_pars_fragment:Km,metalnessmap_fragment:Qm,metalnessmap_pars_fragment:jm,morphinstance_vertex:tg,morphcolor_vertex:eg,morphnormal_vertex:ng,morphtarget_pars_vertex:ig,morphtarget_vertex:sg,normal_fragment_begin:rg,normal_fragment_maps:ag,normal_pars_fragment:og,normal_pars_vertex:lg,normal_vertex:cg,normalmap_pars_fragment:hg,clearcoat_normal_fragment_begin:ug,clearcoat_normal_fragment_maps:dg,clearcoat_pars_fragment:fg,iridescence_pars_fragment:pg,opaque_fragment:mg,packing:gg,premultiplied_alpha_fragment:_g,project_vertex:xg,dithering_fragment:vg,dithering_pars_fragment:yg,roughnessmap_fragment:Mg,roughnessmap_pars_fragment:Sg,shadowmap_pars_fragment:bg,shadowmap_pars_vertex:Ag,shadowmap_vertex:wg,shadowmask_pars_fragment:Eg,skinbase_vertex:Tg,skinning_pars_vertex:Cg,skinning_vertex:Rg,skinnormal_vertex:Pg,specularmap_fragment:Ig,specularmap_pars_fragment:Lg,tonemapping_fragment:Ug,tonemapping_pars_fragment:Dg,transmission_fragment:Ng,transmission_pars_fragment:Fg,uv_pars_fragment:Og,uv_pars_vertex:Bg,uv_vertex:zg,worldpos_vertex:kg,background_vert:Vg,background_frag:Hg,backgroundCube_vert:Gg,backgroundCube_frag:Wg,cube_vert:Xg,cube_frag:qg,depth_vert:Yg,depth_frag:Zg,distanceRGBA_vert:Jg,distanceRGBA_frag:$g,equirect_vert:Kg,equirect_frag:Qg,linedashed_vert:jg,linedashed_frag:t_,meshbasic_vert:e_,meshbasic_frag:n_,meshlambert_vert:i_,meshlambert_frag:s_,meshmatcap_vert:r_,meshmatcap_frag:a_,meshnormal_vert:o_,meshnormal_frag:l_,meshphong_vert:c_,meshphong_frag:h_,meshphysical_vert:u_,meshphysical_frag:d_,meshtoon_vert:f_,meshtoon_frag:p_,points_vert:m_,points_frag:g_,shadow_vert:__,shadow_frag:x_,sprite_vert:v_,sprite_frag:y_},ct={common:{diffuse:{value:new pt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Bt}},envmap:{envMap:{value:null},envMapRotation:{value:new Bt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Bt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Bt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Bt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Bt},normalScale:{value:new Y(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Bt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Bt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Bt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Bt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new pt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new pt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0},uvTransform:{value:new Bt}},sprite:{diffuse:{value:new pt(16777215)},opacity:{value:1},center:{value:new Y(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}}},nn={basic:{uniforms:Ue([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.fog]),vertexShader:Vt.meshbasic_vert,fragmentShader:Vt.meshbasic_frag},lambert:{uniforms:Ue([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,ct.lights,{emissive:{value:new pt(0)}}]),vertexShader:Vt.meshlambert_vert,fragmentShader:Vt.meshlambert_frag},phong:{uniforms:Ue([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,ct.lights,{emissive:{value:new pt(0)},specular:{value:new pt(1118481)},shininess:{value:30}}]),vertexShader:Vt.meshphong_vert,fragmentShader:Vt.meshphong_frag},standard:{uniforms:Ue([ct.common,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.roughnessmap,ct.metalnessmap,ct.fog,ct.lights,{emissive:{value:new pt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag},toon:{uniforms:Ue([ct.common,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.gradientmap,ct.fog,ct.lights,{emissive:{value:new pt(0)}}]),vertexShader:Vt.meshtoon_vert,fragmentShader:Vt.meshtoon_frag},matcap:{uniforms:Ue([ct.common,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,{matcap:{value:null}}]),vertexShader:Vt.meshmatcap_vert,fragmentShader:Vt.meshmatcap_frag},points:{uniforms:Ue([ct.points,ct.fog]),vertexShader:Vt.points_vert,fragmentShader:Vt.points_frag},dashed:{uniforms:Ue([ct.common,ct.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vt.linedashed_vert,fragmentShader:Vt.linedashed_frag},depth:{uniforms:Ue([ct.common,ct.displacementmap]),vertexShader:Vt.depth_vert,fragmentShader:Vt.depth_frag},normal:{uniforms:Ue([ct.common,ct.bumpmap,ct.normalmap,ct.displacementmap,{opacity:{value:1}}]),vertexShader:Vt.meshnormal_vert,fragmentShader:Vt.meshnormal_frag},sprite:{uniforms:Ue([ct.sprite,ct.fog]),vertexShader:Vt.sprite_vert,fragmentShader:Vt.sprite_frag},background:{uniforms:{uvTransform:{value:new Bt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Vt.background_vert,fragmentShader:Vt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Bt}},vertexShader:Vt.backgroundCube_vert,fragmentShader:Vt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Vt.cube_vert,fragmentShader:Vt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vt.equirect_vert,fragmentShader:Vt.equirect_frag},distanceRGBA:{uniforms:Ue([ct.common,ct.displacementmap,{referencePosition:{value:new E},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vt.distanceRGBA_vert,fragmentShader:Vt.distanceRGBA_frag},shadow:{uniforms:Ue([ct.lights,ct.fog,{color:{value:new pt(0)},opacity:{value:1}}]),vertexShader:Vt.shadow_vert,fragmentShader:Vt.shadow_frag}};nn.physical={uniforms:Ue([nn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Bt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Bt},clearcoatNormalScale:{value:new Y(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Bt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Bt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Bt},sheen:{value:0},sheenColor:{value:new pt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Bt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Bt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Bt},transmissionSamplerSize:{value:new Y},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Bt},attenuationDistance:{value:0},attenuationColor:{value:new pt(0)},specularColor:{value:new pt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Bt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Bt},anisotropyVector:{value:new Y},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Bt}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag};const Xr={r:0,b:0,g:0},di=new Xe,M_=new Rt;function S_(r,t,e,n,i,s,a){const o=new pt(0);let l=s===!0?0:1,c,h,u=null,d=0,f=null;function m(v){let x=v.isScene===!0?v.background:null;return x&&x.isTexture&&(x=(v.backgroundBlurriness>0?e:t).get(x)),x}function _(v){let x=!1;const y=m(v);y===null?p(o,l):y&&y.isColor&&(p(y,1),x=!0);const P=r.xr.getEnvironmentBlendMode();P==="additive"?n.buffers.color.setClear(0,0,0,1,a):P==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function g(v,x){const y=m(x);y&&(y.isCubeTexture||y.mapping===Ri)?(h===void 0&&(h=new ge(new Ti(1,1,1),new en({name:"BackgroundCubeMaterial",uniforms:Zi(nn.backgroundCube.uniforms),vertexShader:nn.backgroundCube.vertexShader,fragmentShader:nn.backgroundCube.fragmentShader,side:Pe,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(P,w,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),di.copy(x.backgroundRotation),di.x*=-1,di.y*=-1,di.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(di.y*=-1,di.z*=-1),h.material.uniforms.envMap.value=y,h.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(M_.makeRotationFromEuler(di)),h.material.toneMapped=Kt.getTransfer(y.colorSpace)!==se,(u!==y||d!==y.version||f!==r.toneMapping)&&(h.material.needsUpdate=!0,u=y,d=y.version,f=r.toneMapping),h.layers.enableAll(),v.unshift(h,h.geometry,h.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new ge(new cs(2,2),new en({name:"BackgroundMaterial",uniforms:Zi(nn.background.uniforms),vertexShader:nn.background.vertexShader,fragmentShader:nn.background.fragmentShader,side:mn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=Kt.getTransfer(y.colorSpace)!==se,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||f!==r.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,f=r.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function p(v,x){v.getRGB(Xr,Hh(r)),n.buffers.color.setClear(Xr.r,Xr.g,Xr.b,x,a)}return{getClearColor:function(){return o},setClearColor:function(v,x=1){o.set(v),l=x,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,p(o,l)},render:_,addToRenderList:g}}function b_(r,t){const e=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=d(null);let s=i,a=!1;function o(M,I,k,O,V){let q=!1;const H=u(O,k,I);s!==H&&(s=H,c(s.object)),q=f(M,O,k,V),q&&m(M,O,k,V),V!==null&&t.update(V,r.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,y(M,I,k,O),V!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(V).buffer))}function l(){return r.createVertexArray()}function c(M){return r.bindVertexArray(M)}function h(M){return r.deleteVertexArray(M)}function u(M,I,k){const O=k.wireframe===!0;let V=n[M.id];V===void 0&&(V={},n[M.id]=V);let q=V[I.id];q===void 0&&(q={},V[I.id]=q);let H=q[O];return H===void 0&&(H=d(l()),q[O]=H),H}function d(M){const I=[],k=[],O=[];for(let V=0;V<e;V++)I[V]=0,k[V]=0,O[V]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:k,attributeDivisors:O,object:M,attributes:{},index:null}}function f(M,I,k,O){const V=s.attributes,q=I.attributes;let H=0;const nt=k.getAttributes();for(const G in nt)if(nt[G].location>=0){const Mt=V[G];let vt=q[G];if(vt===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(vt=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(vt=M.instanceColor)),Mt===void 0||Mt.attribute!==vt||vt&&Mt.data!==vt.data)return!0;H++}return s.attributesNum!==H||s.index!==O}function m(M,I,k,O){const V={},q=I.attributes;let H=0;const nt=k.getAttributes();for(const G in nt)if(nt[G].location>=0){let Mt=q[G];Mt===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(Mt=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(Mt=M.instanceColor));const vt={};vt.attribute=Mt,Mt&&Mt.data&&(vt.data=Mt.data),V[G]=vt,H++}s.attributes=V,s.attributesNum=H,s.index=O}function _(){const M=s.newAttributes;for(let I=0,k=M.length;I<k;I++)M[I]=0}function g(M){p(M,0)}function p(M,I){const k=s.newAttributes,O=s.enabledAttributes,V=s.attributeDivisors;k[M]=1,O[M]===0&&(r.enableVertexAttribArray(M),O[M]=1),V[M]!==I&&(r.vertexAttribDivisor(M,I),V[M]=I)}function v(){const M=s.newAttributes,I=s.enabledAttributes;for(let k=0,O=I.length;k<O;k++)I[k]!==M[k]&&(r.disableVertexAttribArray(k),I[k]=0)}function x(M,I,k,O,V,q,H){H===!0?r.vertexAttribIPointer(M,I,k,V,q):r.vertexAttribPointer(M,I,k,O,V,q)}function y(M,I,k,O){_();const V=O.attributes,q=k.getAttributes(),H=I.defaultAttributeValues;for(const nt in q){const G=q[nt];if(G.location>=0){let mt=V[nt];if(mt===void 0&&(nt==="instanceMatrix"&&M.instanceMatrix&&(mt=M.instanceMatrix),nt==="instanceColor"&&M.instanceColor&&(mt=M.instanceColor)),mt!==void 0){const Mt=mt.normalized,vt=mt.itemSize,Gt=t.get(mt);if(Gt===void 0)continue;const Jt=Gt.buffer,W=Gt.type,it=Gt.bytesPerElement,yt=W===r.INT||W===r.UNSIGNED_INT||mt.gpuType===eo;if(mt.isInterleavedBufferAttribute){const lt=mt.data,Ft=lt.stride,zt=mt.offset;if(lt.isInstancedInterleavedBuffer){for(let Dt=0;Dt<G.locationSize;Dt++)p(G.location+Dt,lt.meshPerAttribute);M.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=lt.meshPerAttribute*lt.count)}else for(let Dt=0;Dt<G.locationSize;Dt++)g(G.location+Dt);r.bindBuffer(r.ARRAY_BUFFER,Jt);for(let Dt=0;Dt<G.locationSize;Dt++)x(G.location+Dt,vt/G.locationSize,W,Mt,Ft*it,(zt+vt/G.locationSize*Dt)*it,yt)}else{if(mt.isInstancedBufferAttribute){for(let lt=0;lt<G.locationSize;lt++)p(G.location+lt,mt.meshPerAttribute);M.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=mt.meshPerAttribute*mt.count)}else for(let lt=0;lt<G.locationSize;lt++)g(G.location+lt);r.bindBuffer(r.ARRAY_BUFFER,Jt);for(let lt=0;lt<G.locationSize;lt++)x(G.location+lt,vt/G.locationSize,W,Mt,vt*it,vt/G.locationSize*lt*it,yt)}}else if(H!==void 0){const Mt=H[nt];if(Mt!==void 0)switch(Mt.length){case 2:r.vertexAttrib2fv(G.location,Mt);break;case 3:r.vertexAttrib3fv(G.location,Mt);break;case 4:r.vertexAttrib4fv(G.location,Mt);break;default:r.vertexAttrib1fv(G.location,Mt)}}}}v()}function P(){R();for(const M in n){const I=n[M];for(const k in I){const O=I[k];for(const V in O)h(O[V].object),delete O[V];delete I[k]}delete n[M]}}function w(M){if(n[M.id]===void 0)return;const I=n[M.id];for(const k in I){const O=I[k];for(const V in O)h(O[V].object),delete O[V];delete I[k]}delete n[M.id]}function T(M){for(const I in n){const k=n[I];if(k[M.id]===void 0)continue;const O=k[M.id];for(const V in O)h(O[V].object),delete O[V];delete k[M.id]}}function R(){b(),a=!0,s!==i&&(s=i,c(s.object))}function b(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:R,resetDefaultState:b,dispose:P,releaseStatesOfGeometry:w,releaseStatesOfProgram:T,initAttributes:_,enableAttribute:g,disableUnusedAttributes:v}}function A_(r,t,e){let n;function i(c){n=c}function s(c,h){r.drawArrays(n,c,h),e.update(h,n,1)}function a(c,h,u){u!==0&&(r.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function o(c,h,u){if(u===0)return;const d=t.get("WEBGL_multi_draw");if(d===null)for(let f=0;f<u;f++)this.render(c[f],h[f]);else{d.multiDrawArraysWEBGL(n,c,0,h,0,u);let f=0;for(let m=0;m<u;m++)f+=h[m];e.update(f,n,1)}}function l(c,h,u,d){if(u===0)return;const f=t.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<c.length;m++)a(c[m],h[m],d[m]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let m=0;for(let _=0;_<u;_++)m+=h[_];for(let _=0;_<d.length;_++)e.update(m,n,d[_])}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function w_(r,t,e,n){let i;function s(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){const w=t.get("EXT_texture_filter_anisotropic");i=r.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(w){return!(w!==Fe&&n.convert(w)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(w){const T=w===vs&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(w!==vn&&n.convert(w)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Ve&&!T)}function l(w){if(w==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),f=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_TEXTURE_SIZE),_=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),p=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),v=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,P=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:f,maxTextureSize:m,maxCubemapSize:_,maxAttributes:g,maxVertexUniforms:p,maxVaryings:v,maxFragmentUniforms:x,vertexTextures:y,maxSamples:P}}function E_(r){const t=this;let e=null,n=0,i=!1,s=!1;const a=new Wn,o=new Bt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const m=u.clippingPlanes,_=u.clipIntersection,g=u.clipShadows,p=r.get(u);if(!i||m===null||m.length===0||s&&!g)s?h(null):c();else{const v=s?0:n,x=v*4;let y=p.clippingState||null;l.value=y,y=h(m,d,x,f);for(let P=0;P!==x;++P)y[P]=e[P];p.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,m){const _=u!==null?u.length:0;let g=null;if(_!==0){if(g=l.value,m!==!0||g===null){const p=f+_*4,v=d.matrixWorldInverse;o.getNormalMatrix(v),(g===null||g.length<p)&&(g=new Float32Array(p));for(let x=0,y=f;x!==_;++x,y+=4)a.copy(u[x]).applyMatrix4(v,o),a.normal.toArray(g,y),g[y+3]=a.constant}l.value=g,l.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,g}}function T_(r){let t=new WeakMap;function e(a,o){return o===fs?a.mapping=xn:o===ps&&(a.mapping=Nn),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===fs||o===ps)if(t.has(a)){const l=t.get(a).texture;return e(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Yh(l.height);return c.fromEquirectangularTexture(r,a),t.set(a,c),a.addEventListener("dispose",i),e(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}class qr extends Gr{constructor(t=-1,e=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-t,a=n+t,o=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const Ki=4,Jh=[.125,.215,.35,.446,.526,.582],fi=20,ll=new qr,$h=new pt;let cl=null,hl=0,ul=0,dl=!1;const pi=(1+Math.sqrt(5))/2,Qi=1/pi,Kh=[new E(-pi,Qi,0),new E(pi,Qi,0),new E(-Qi,0,pi),new E(Qi,0,pi),new E(0,pi,-Qi),new E(0,pi,Qi),new E(-1,1,-1),new E(1,1,-1),new E(-1,1,1),new E(1,1,1)];class fl{constructor(t){this._renderer=t,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(t,e=0,n=.1,i=100){cl=this._renderer.getRenderTarget(),hl=this._renderer.getActiveCubeFace(),ul=this._renderer.getActiveMipmapLevel(),dl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,i,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=tu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(cl,hl,ul),this._renderer.xr.enabled=dl,t.scissorTest=!1,Yr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===xn||t.mapping===Nn?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),cl=this._renderer.getRenderTarget(),hl=this._renderer.getActiveCubeFace(),ul=this._renderer.getActiveMipmapLevel(),dl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:pe,minFilter:pe,generateMipmaps:!1,type:vs,format:Fe,colorSpace:Mn,depthBuffer:!1},i=Qh(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Qh(t,e,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=C_(s)),this._blurMaterial=R_(s,t,e)}return i}_compileMaterial(t){const e=new ge(this._lodPlanes[0],t);this._renderer.compile(e,ll)}_sceneToCubeUV(t,e,n,i){const o=new be(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor($h),h.toneMapping=_n,h.autoClear=!1;const f=new Hn({name:"PMREM.Background",side:Pe,depthWrite:!1,depthTest:!1}),m=new ge(new Ti,f);let _=!1;const g=t.background;g?g.isColor&&(f.color.copy(g),t.background=null,_=!0):(f.color.copy($h),_=!0);for(let p=0;p<6;p++){const v=p%3;v===0?(o.up.set(0,l[p],0),o.lookAt(c[p],0,0)):v===1?(o.up.set(0,0,l[p]),o.lookAt(0,c[p],0)):(o.up.set(0,l[p],0),o.lookAt(0,0,c[p]));const x=this._cubeSize;Yr(i,v*x,p>2?x:0,x,x),h.setRenderTarget(i),_&&h.render(m,o),h.render(t,o)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=g}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===xn||t.mapping===Nn;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=tu()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jh());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new ge(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=t;const l=this._cubeSize;Yr(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,ll)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;s<i;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Kh[(i-s-1)%Kh.length];this._blur(t,s-1,s,a,o)}e.autoClear=n}_blur(t,e,n,i,s){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,i,"latitudinal",s),this._halfBlur(a,t,n,n,i,"longitudinal",s)}_halfBlur(t,e,n,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new ge(this._lodPlanes[i],c),d=c.uniforms,f=this._sizeLods[n]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*fi-1),_=s/m,g=isFinite(s)?1+Math.floor(h*_):fi;g>fi&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${fi}`);const p=[];let v=0;for(let T=0;T<fi;++T){const R=T/_,b=Math.exp(-R*R/2);p.push(b),T===0?v+=b:T<g&&(v+=2*b)}for(let T=0;T<p.length;T++)p[T]=p[T]/v;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:x}=this;d.dTheta.value=m,d.mipInt.value=x-n;const y=this._sizeLods[i],P=3*y*(i>x-Ki?i-x+Ki:0),w=4*(this._cubeSize-y);Yr(e,P,w,3*y,2*y),l.setRenderTarget(e),l.render(u,ll)}}function C_(r){const t=[],e=[],n=[];let i=r;const s=r-Ki+1+Jh.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>r-Ki?l=Jh[a-r+Ki-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,_=3,g=2,p=1,v=new Float32Array(_*m*f),x=new Float32Array(g*m*f),y=new Float32Array(p*m*f);for(let w=0;w<f;w++){const T=w%3*2/3-1,R=w>2?0:-1,b=[T,R,0,T+2/3,R,0,T+2/3,R+1,0,T,R,0,T+2/3,R+1,0,T,R+1,0];v.set(b,_*m*w),x.set(d,g*m*w);const M=[w,w,w,w,w,w];y.set(M,p*m*w)}const P=new Ht;P.setAttribute("position",new te(v,_)),P.setAttribute("uv",new te(x,g)),P.setAttribute("faceIndex",new te(y,p)),t.push(P),i>Ki&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Qh(r,t,e){const n=new Ke(r,t,e);return n.texture.mapping=Ri,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Yr(r,t,e,n,i){r.viewport.set(t,e,n,i),r.scissor.set(t,e,n,i)}function R_(r,t,e){const n=new Float32Array(fi),i=new E(0,1,0);return new en({name:"SphericalGaussianBlur",defines:{n:fi,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:pl(),fragmentShader:`
  3527. precision mediump float;
  3528. precision mediump int;
  3529. varying vec3 vOutputDirection;
  3530. uniform sampler2D envMap;
  3531. uniform int samples;
  3532. uniform float weights[ n ];
  3533. uniform bool latitudinal;
  3534. uniform float dTheta;
  3535. uniform float mipInt;
  3536. uniform vec3 poleAxis;
  3537. #define ENVMAP_TYPE_CUBE_UV
  3538. #include <cube_uv_reflection_fragment>
  3539. vec3 getSample( float theta, vec3 axis ) {
  3540. float cosTheta = cos( theta );
  3541. // Rodrigues' axis-angle rotation
  3542. vec3 sampleDirection = vOutputDirection * cosTheta
  3543. + cross( axis, vOutputDirection ) * sin( theta )
  3544. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3545. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3546. }
  3547. void main() {
  3548. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3549. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3550. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3551. }
  3552. axis = normalize( axis );
  3553. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3554. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3555. for ( int i = 1; i < n; i++ ) {
  3556. if ( i >= samples ) {
  3557. break;
  3558. }
  3559. float theta = dTheta * float( i );
  3560. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3561. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3562. }
  3563. }
  3564. `,blending:gn,depthTest:!1,depthWrite:!1})}function jh(){return new en({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:pl(),fragmentShader:`
  3565. precision mediump float;
  3566. precision mediump int;
  3567. varying vec3 vOutputDirection;
  3568. uniform sampler2D envMap;
  3569. #include <common>
  3570. void main() {
  3571. vec3 outputDirection = normalize( vOutputDirection );
  3572. vec2 uv = equirectUv( outputDirection );
  3573. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3574. }
  3575. `,blending:gn,depthTest:!1,depthWrite:!1})}function tu(){return new en({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:pl(),fragmentShader:`
  3576. precision mediump float;
  3577. precision mediump int;
  3578. uniform float flipEnvMap;
  3579. varying vec3 vOutputDirection;
  3580. uniform samplerCube envMap;
  3581. void main() {
  3582. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3583. }
  3584. `,blending:gn,depthTest:!1,depthWrite:!1})}function pl(){return`
  3585. precision mediump float;
  3586. precision mediump int;
  3587. attribute float faceIndex;
  3588. varying vec3 vOutputDirection;
  3589. // RH coordinate system; PMREM face-indexing convention
  3590. vec3 getDirection( vec2 uv, float face ) {
  3591. uv = 2.0 * uv - 1.0;
  3592. vec3 direction = vec3( uv, 1.0 );
  3593. if ( face == 0.0 ) {
  3594. direction = direction.zyx; // ( 1, v, u ) pos x
  3595. } else if ( face == 1.0 ) {
  3596. direction = direction.xzy;
  3597. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3598. } else if ( face == 2.0 ) {
  3599. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3600. } else if ( face == 3.0 ) {
  3601. direction = direction.zyx;
  3602. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3603. } else if ( face == 4.0 ) {
  3604. direction = direction.xzy;
  3605. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3606. } else if ( face == 5.0 ) {
  3607. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3608. }
  3609. return direction;
  3610. }
  3611. void main() {
  3612. vOutputDirection = getDirection( uv, faceIndex );
  3613. gl_Position = vec4( position, 1.0 );
  3614. }
  3615. `}function P_(r){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===fs||l===ps,h=l===xn||l===Nn;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new fl(r)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return c&&f&&f.height>0||h&&f&&i(f)?(e===null&&(e=new fl(r)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",s),u.texture):null}}}return o}function i(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function I_(r){const t={};function e(n){if(t[n]!==void 0)return t[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return t[n]=i,i}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const i=e(n);return i===null&&Vo("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function L_(r,t,e,n){const i={},s=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const m in d.attributes)t.remove(d.attributes[m]);for(const m in d.morphAttributes){const _=d.morphAttributes[m];for(let g=0,p=_.length;g<p;g++)t.remove(_[g])}d.removeEventListener("dispose",a),delete i[d.id];const f=s.get(d);f&&(t.remove(f),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,e.memory.geometries++),d}function l(u){const d=u.attributes;for(const m in d)t.update(d[m],r.ARRAY_BUFFER);const f=u.morphAttributes;for(const m in f){const _=f[m];for(let g=0,p=_.length;g<p;g++)t.update(_[g],r.ARRAY_BUFFER)}}function c(u){const d=[],f=u.index,m=u.attributes.position;let _=0;if(f!==null){const v=f.array;_=f.version;for(let x=0,y=v.length;x<y;x+=3){const P=v[x+0],w=v[x+1],T=v[x+2];d.push(P,w,w,T,T,P)}}else if(m!==void 0){const v=m.array;_=m.version;for(let x=0,y=v.length/3-1;x<y;x+=3){const P=x+0,w=x+1,T=x+2;d.push(P,w,w,T,T,P)}}else return;const g=new(yh(d)?sl:il)(d,1);g.version=_;const p=s.get(u);p&&t.remove(p),s.set(u,g)}function h(u){const d=s.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return s.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function U_(r,t,e){let n;function i(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,f){r.drawElements(n,f,s,d*a),e.update(f,n,1)}function c(d,f,m){m!==0&&(r.drawElementsInstanced(n,f,s,d*a,m),e.update(f,n,m))}function h(d,f,m){if(m===0)return;const _=t.get("WEBGL_multi_draw");if(_===null)for(let g=0;g<m;g++)this.render(d[g]/a,f[g]);else{_.multiDrawElementsWEBGL(n,f,0,s,d,0,m);let g=0;for(let p=0;p<m;p++)g+=f[p];e.update(g,n,1)}}function u(d,f,m,_){if(m===0)return;const g=t.get("WEBGL_multi_draw");if(g===null)for(let p=0;p<d.length;p++)c(d[p]/a,f[p],_[p]);else{g.multiDrawElementsInstancedWEBGL(n,f,0,s,d,0,_,0,m);let p=0;for(let v=0;v<m;v++)p+=f[v];for(let v=0;v<_.length;v++)e.update(p,n,_[v])}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function D_(r){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(e.calls++,a){case r.TRIANGLES:e.triangles+=o*(s/3);break;case r.LINES:e.lines+=o*(s/2);break;case r.LINE_STRIP:e.lines+=o*(s-1);break;case r.LINE_LOOP:e.lines+=o*s;break;case r.POINTS:e.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}function N_(r,t,e){const n=new WeakMap,i=new ee;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let b=function(){T.dispose(),n.delete(o),o.removeEventListener("dispose",b)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,m=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],v=o.morphAttributes.color||[];let x=0;f===!0&&(x=1),m===!0&&(x=2),_===!0&&(x=3);let y=o.attributes.position.count*x,P=1;y>t.maxTextureSize&&(P=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize);const w=new Float32Array(y*P*4*u),T=new Ar(w,y,P,u);T.type=Ve,T.needsUpdate=!0;const R=x*4;for(let M=0;M<u;M++){const I=g[M],k=p[M],O=v[M],V=y*P*4*M;for(let q=0;q<I.count;q++){const H=q*R;f===!0&&(i.fromBufferAttribute(I,q),w[V+H+0]=i.x,w[V+H+1]=i.y,w[V+H+2]=i.z,w[V+H+3]=0),m===!0&&(i.fromBufferAttribute(k,q),w[V+H+4]=i.x,w[V+H+5]=i.y,w[V+H+6]=i.z,w[V+H+7]=0),_===!0&&(i.fromBufferAttribute(O,q),w[V+H+8]=i.x,w[V+H+9]=i.y,w[V+H+10]=i.z,w[V+H+11]=O.itemSize===4?i.w:1)}}d={count:u,texture:T,size:new Y(y,P)},n.set(o,d),o.addEventListener("dispose",b)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(r,"morphTexture",a.morphTexture,e);else{let f=0;for(let _=0;_<c.length;_++)f+=c[_];const m=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(r,"morphTargetBaseInfluence",m),l.getUniforms().setValue(r,"morphTargetInfluences",c)}l.getUniforms().setValue(r,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(r,"morphTargetsTextureSize",d.size)}return{update:s}}function F_(r,t,e,n){let i=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,u=t.get(l,h);if(i.get(u)!==c&&(t.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(e.update(l.instanceMatrix,r.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,r.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;i.get(d)!==c&&(d.update(),i.set(d,c))}return u}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:s,dispose:a}}class ml extends he{constructor(t,e,n,i,s,a,o,l,c,h=ei){if(h!==ei&&h!==ni)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===ei&&(n=jn),n===void 0&&h===ni&&(n=ti),super(null,i,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:Me,this.minFilter=l!==void 0?l:Me,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const eu=new he,nu=new ml(1,1);nu.compareFunction=Oo;const iu=new Ar,su=new Wo,ru=new Ns,au=[],ou=[],lu=new Float32Array(16),cu=new Float32Array(9),hu=new Float32Array(4);function ji(r,t,e){const n=r[0];if(n<=0||n>0)return r;const i=t*e;let s=au[i];if(s===void 0&&(s=new Float32Array(i),au[i]=s),t!==0){n.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=e,r[a].toArray(s,o)}return s}function _e(r,t){if(r.length!==t.length)return!1;for(let e=0,n=r.length;e<n;e++)if(r[e]!==t[e])return!1;return!0}function xe(r,t){for(let e=0,n=t.length;e<n;e++)r[e]=t[e]}function Zr(r,t){let e=ou[t];e===void 0&&(e=new Int32Array(t),ou[t]=e);for(let n=0;n!==t;++n)e[n]=r.allocateTextureUnit();return e}function O_(r,t){const e=this.cache;e[0]!==t&&(r.uniform1f(this.addr,t),e[0]=t)}function B_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(r.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(_e(e,t))return;r.uniform2fv(this.addr,t),xe(e,t)}}function z_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(r.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(r.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(_e(e,t))return;r.uniform3fv(this.addr,t),xe(e,t)}}function k_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(r.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(_e(e,t))return;r.uniform4fv(this.addr,t),xe(e,t)}}function V_(r,t){const e=this.cache,n=t.elements;if(n===void 0){if(_e(e,t))return;r.uniformMatrix2fv(this.addr,!1,t),xe(e,t)}else{if(_e(e,n))return;hu.set(n),r.uniformMatrix2fv(this.addr,!1,hu),xe(e,n)}}function H_(r,t){const e=this.cache,n=t.elements;if(n===void 0){if(_e(e,t))return;r.uniformMatrix3fv(this.addr,!1,t),xe(e,t)}else{if(_e(e,n))return;cu.set(n),r.uniformMatrix3fv(this.addr,!1,cu),xe(e,n)}}function G_(r,t){const e=this.cache,n=t.elements;if(n===void 0){if(_e(e,t))return;r.uniformMatrix4fv(this.addr,!1,t),xe(e,t)}else{if(_e(e,n))return;lu.set(n),r.uniformMatrix4fv(this.addr,!1,lu),xe(e,n)}}function W_(r,t){const e=this.cache;e[0]!==t&&(r.uniform1i(this.addr,t),e[0]=t)}function X_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(r.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(_e(e,t))return;r.uniform2iv(this.addr,t),xe(e,t)}}function q_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(r.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(_e(e,t))return;r.uniform3iv(this.addr,t),xe(e,t)}}function Y_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(r.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(_e(e,t))return;r.uniform4iv(this.addr,t),xe(e,t)}}function Z_(r,t){const e=this.cache;e[0]!==t&&(r.uniform1ui(this.addr,t),e[0]=t)}function J_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(r.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(_e(e,t))return;r.uniform2uiv(this.addr,t),xe(e,t)}}function $_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(r.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(_e(e,t))return;r.uniform3uiv(this.addr,t),xe(e,t)}}function K_(r,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(r.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(_e(e,t))return;r.uniform4uiv(this.addr,t),xe(e,t)}}function Q_(r,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i);const s=this.type===r.SAMPLER_2D_SHADOW?nu:eu;e.setTexture2D(t||s,i)}function j_(r,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||su,i)}function t0(r,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||ru,i)}function e0(r,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||iu,i)}function n0(r){switch(r){case 5126:return O_;case 35664:return B_;case 35665:return z_;case 35666:return k_;case 35674:return V_;case 35675:return H_;case 35676:return G_;case 5124:case 35670:return W_;case 35667:case 35671:return X_;case 35668:case 35672:return q_;case 35669:case 35673:return Y_;case 5125:return Z_;case 36294:return J_;case 36295:return $_;case 36296:return K_;case 35678:case 36198:case 36298:case 36306:case 35682:return Q_;case 35679:case 36299:case 36307:return j_;case 35680:case 36300:case 36308:case 36293:return t0;case 36289:case 36303:case 36311:case 36292:return e0}}function i0(r,t){r.uniform1fv(this.addr,t)}function s0(r,t){const e=ji(t,this.size,2);r.uniform2fv(this.addr,e)}function r0(r,t){const e=ji(t,this.size,3);r.uniform3fv(this.addr,e)}function a0(r,t){const e=ji(t,this.size,4);r.uniform4fv(this.addr,e)}function o0(r,t){const e=ji(t,this.size,4);r.uniformMatrix2fv(this.addr,!1,e)}function l0(r,t){const e=ji(t,this.size,9);r.uniformMatrix3fv(this.addr,!1,e)}function c0(r,t){const e=ji(t,this.size,16);r.uniformMatrix4fv(this.addr,!1,e)}function h0(r,t){r.uniform1iv(this.addr,t)}function u0(r,t){r.uniform2iv(this.addr,t)}function d0(r,t){r.uniform3iv(this.addr,t)}function f0(r,t){r.uniform4iv(this.addr,t)}function p0(r,t){r.uniform1uiv(this.addr,t)}function m0(r,t){r.uniform2uiv(this.addr,t)}function g0(r,t){r.uniform3uiv(this.addr,t)}function _0(r,t){r.uniform4uiv(this.addr,t)}function x0(r,t,e){const n=this.cache,i=t.length,s=Zr(e,i);_e(n,s)||(r.uniform1iv(this.addr,s),xe(n,s));for(let a=0;a!==i;++a)e.setTexture2D(t[a]||eu,s[a])}function v0(r,t,e){const n=this.cache,i=t.length,s=Zr(e,i);_e(n,s)||(r.uniform1iv(this.addr,s),xe(n,s));for(let a=0;a!==i;++a)e.setTexture3D(t[a]||su,s[a])}function y0(r,t,e){const n=this.cache,i=t.length,s=Zr(e,i);_e(n,s)||(r.uniform1iv(this.addr,s),xe(n,s));for(let a=0;a!==i;++a)e.setTextureCube(t[a]||ru,s[a])}function M0(r,t,e){const n=this.cache,i=t.length,s=Zr(e,i);_e(n,s)||(r.uniform1iv(this.addr,s),xe(n,s));for(let a=0;a!==i;++a)e.setTexture2DArray(t[a]||iu,s[a])}function S0(r){switch(r){case 5126:return i0;case 35664:return s0;case 35665:return r0;case 35666:return a0;case 35674:return o0;case 35675:return l0;case 35676:return c0;case 5124:case 35670:return h0;case 35667:case 35671:return u0;case 35668:case 35672:return d0;case 35669:case 35673:return f0;case 5125:return p0;case 36294:return m0;case 36295:return g0;case 36296:return _0;case 35678:case 36198:case 36298:case 36306:case 35682:return x0;case 35679:case 36299:case 36307:return v0;case 35680:case 36300:case 36308:case 36293:return y0;case 36289:case 36303:case 36311:case 36292:return M0}}class b0{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=n0(e.type)}}class A0{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=S0(e.type)}}class w0{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(t,e[o.id],n)}}}const gl=/(\w+)(\])?(\[|\.)?/g;function uu(r,t){r.seq.push(t),r.map[t.id]=t}function E0(r,t,e){const n=r.name,i=n.length;for(gl.lastIndex=0;;){const s=gl.exec(n),a=gl.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){uu(e,c===void 0?new b0(o,r,t):new A0(o,r,t));break}else{let u=e.map[o];u===void 0&&(u=new w0(o),uu(e,u)),e=u}}}class Jr{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const s=t.getActiveUniform(e,i),a=t.getUniformLocation(e,s.name);E0(s,a,this)}}setValue(t,e,n,i){const s=this.map[e];s!==void 0&&s.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let s=0,a=e.length;s!==a;++s){const o=e[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,s=t.length;i!==s;++i){const a=t[i];a.id in e&&n.push(a)}return n}}function du(r,t,e){const n=r.createShader(t);return r.shaderSource(n,e),r.compileShader(n),n}const T0=37297;let C0=0;function R0(r,t){const e=r.split(`
  3616. `),n=[],i=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let a=i;a<s;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
  3617. `)}function P0(r){const t=Kt.getPrimaries(Kt.workingColorSpace),e=Kt.getPrimaries(r);let n;switch(t===e?n="":t===ws&&e===As?n="LinearDisplayP3ToLinearSRGB":t===As&&e===ws&&(n="LinearSRGBToLinearDisplayP3"),r){case Mn:case Ss:return[n,"LinearTransferOETF"];case Je:case Sr:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),[n,"LinearTransferOETF"]}}function fu(r,t,e){const n=r.getShaderParameter(t,r.COMPILE_STATUS),i=r.getShaderInfoLog(t).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return e.toUpperCase()+`
  3618. `+i+`
  3619. `+R0(r.getShaderSource(t),a)}else return i}function I0(r,t){const e=P0(t);return`vec4 ${r}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}function L0(r,t){let e;switch(t){case Gc:e="Linear";break;case Wc:e="Reinhard";break;case Xc:e="OptimizedCineon";break;case qc:e="ACESFilmic";break;case Zc:e="AgX";break;case Jc:e="Neutral";break;case Yc:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+r+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function U0(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Os).join(`
  3620. `)}function D0(r){const t=[];for(const e in r){const n=r[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
  3621. `)}function N0(r,t){const e={},n=r.getProgramParameter(t,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(t,i),a=s.name;let o=1;s.type===r.FLOAT_MAT2&&(o=2),s.type===r.FLOAT_MAT3&&(o=3),s.type===r.FLOAT_MAT4&&(o=4),e[a]={type:s.type,location:r.getAttribLocation(t,a),locationSize:o}}return e}function Os(r){return r!==""}function pu(r,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function mu(r,t){return r.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const F0=/^[ \t]*#include +<([\w\d./]+)>/gm;function _l(r){return r.replace(F0,B0)}const O0=new Map;function B0(r,t){let e=Vt[t];if(e===void 0){const n=O0.get(t);if(n!==void 0)e=Vt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return _l(e)}const z0=/#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 gu(r){return r.replace(z0,k0)}function k0(r,t,e,n){let i="";for(let s=parseInt(t);s<parseInt(e);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function _u(r){let t=`precision ${r.precision} float;
  3622. precision ${r.precision} int;
  3623. precision ${r.precision} sampler2D;
  3624. precision ${r.precision} samplerCube;
  3625. precision ${r.precision} sampler3D;
  3626. precision ${r.precision} sampler2DArray;
  3627. precision ${r.precision} sampler2DShadow;
  3628. precision ${r.precision} samplerCubeShadow;
  3629. precision ${r.precision} sampler2DArrayShadow;
  3630. precision ${r.precision} isampler2D;
  3631. precision ${r.precision} isampler3D;
  3632. precision ${r.precision} isamplerCube;
  3633. precision ${r.precision} isampler2DArray;
  3634. precision ${r.precision} usampler2D;
  3635. precision ${r.precision} usampler3D;
  3636. precision ${r.precision} usamplerCube;
  3637. precision ${r.precision} usampler2DArray;
  3638. `;return r.precision==="highp"?t+=`
  3639. #define HIGH_PRECISION`:r.precision==="mediump"?t+=`
  3640. #define MEDIUM_PRECISION`:r.precision==="lowp"&&(t+=`
  3641. #define LOW_PRECISION`),t}function V0(r){let t="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===Ja?t="SHADOWMAP_TYPE_PCF":r.shadowMapType===mc?t="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===ln&&(t="SHADOWMAP_TYPE_VSM"),t}function H0(r){let t="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case xn:case Nn:t="ENVMAP_TYPE_CUBE";break;case Ri:t="ENVMAP_TYPE_CUBE_UV";break}return t}function G0(r){let t="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case Nn:t="ENVMAP_MODE_REFRACTION";break}return t}function W0(r){let t="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case ds:t="ENVMAP_BLENDING_MULTIPLY";break;case Vc:t="ENVMAP_BLENDING_MIX";break;case Hc:t="ENVMAP_BLENDING_ADD";break}return t}function X0(r){const t=r.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function q0(r,t,e,n){const i=r.getContext(),s=e.defines;let a=e.vertexShader,o=e.fragmentShader;const l=V0(e),c=H0(e),h=G0(e),u=W0(e),d=X0(e),f=U0(e),m=D0(s),_=i.createProgram();let g,p,v=e.glslVersion?"#version "+e.glslVersion+`
  3642. `:"";e.isRawShaderMaterial?(g=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Os).join(`
  3643. `),g.length>0&&(g+=`
  3644. `),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Os).join(`
  3645. `),p.length>0&&(p+=`
  3646. `)):(g=[_u(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","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",`
  3647. `].filter(Os).join(`
  3648. `),p=[_u(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==_n?"#define TONE_MAPPING":"",e.toneMapping!==_n?Vt.tonemapping_pars_fragment:"",e.toneMapping!==_n?L0("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Vt.colorspace_pars_fragment,I0("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
  3649. `].filter(Os).join(`
  3650. `)),a=_l(a),a=pu(a,e),a=mu(a,e),o=_l(o),o=pu(o,e),o=mu(o,e),a=gu(a),o=gu(o),e.isRawShaderMaterial!==!0&&(v=`#version 300 es
  3651. `,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3652. `)+`
  3653. `+g,p=["#define varying in",e.glslVersion===Bo?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Bo?"":"#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(`
  3654. `)+`
  3655. `+p);const x=v+g+a,y=v+p+o,P=du(i,i.VERTEX_SHADER,x),w=du(i,i.FRAGMENT_SHADER,y);i.attachShader(_,P),i.attachShader(_,w),e.index0AttributeName!==void 0?i.bindAttribLocation(_,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function T(I){if(r.debug.checkShaderErrors){const k=i.getProgramInfoLog(_).trim(),O=i.getShaderInfoLog(P).trim(),V=i.getShaderInfoLog(w).trim();let q=!0,H=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(q=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,_,P,w);else{const nt=fu(i,P,"vertex"),G=fu(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
  3656. Material Name: `+I.name+`
  3657. Material Type: `+I.type+`
  3658. Program Info Log: `+k+`
  3659. `+nt+`
  3660. `+G)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(O===""||V==="")&&(H=!1);H&&(I.diagnostics={runnable:q,programLog:k,vertexShader:{log:O,prefix:g},fragmentShader:{log:V,prefix:p}})}i.deleteShader(P),i.deleteShader(w),R=new Jr(i,_),b=N0(i,_)}let R;this.getUniforms=function(){return R===void 0&&T(this),R};let b;this.getAttributes=function(){return b===void 0&&T(this),b};let M=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=i.getProgramParameter(_,T0)),M},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=C0++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=P,this.fragmentShader=w,this}let Y0=0;class Z0{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new J0(t),e.set(t,n)),n}}class J0{constructor(t){this.id=Y0++,this.code=t,this.usedTimes=0}}function $0(r,t,e,n,i,s,a){const o=new Ir,l=new Z0,c=new Set,h=[],u=i.logarithmicDepthBuffer,d=i.vertexTextures;let f=i.precision;const m={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 _(b){return c.add(b),b===0?"uv":`uv${b}`}function g(b,M,I,k,O){const V=k.fog,q=O.geometry,H=b.isMeshStandardMaterial?k.environment:null,nt=(b.isMeshStandardMaterial?e:t).get(b.envMap||H),G=nt&&nt.mapping===Ri?nt.image.height:null,mt=m[b.type];b.precision!==null&&(f=i.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));const Mt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,vt=Mt!==void 0?Mt.length:0;let Gt=0;q.morphAttributes.position!==void 0&&(Gt=1),q.morphAttributes.normal!==void 0&&(Gt=2),q.morphAttributes.color!==void 0&&(Gt=3);let Jt,W,it,yt;if(mt){const ne=nn[mt];Jt=ne.vertexShader,W=ne.fragmentShader}else Jt=b.vertexShader,W=b.fragmentShader,l.update(b),it=l.getVertexShaderID(b),yt=l.getFragmentShaderID(b);const lt=r.getRenderTarget(),Ft=O.isInstancedMesh===!0,zt=O.isBatchedMesh===!0,Dt=!!b.map,L=!!b.matcap,Z=!!nt,Q=!!b.aoMap,st=!!b.lightMap,tt=!!b.bumpMap,et=!!b.normalMap,gt=!!b.displacementMap,dt=!!b.emissiveMap,Nt=!!b.metalnessMap,C=!!b.roughnessMap,S=b.anisotropy>0,z=b.clearcoat>0,K=b.dispersion>0,$=b.iridescence>0,j=b.sheen>0,Et=b.transmission>0,ht=S&&!!b.anisotropyMap,ut=z&&!!b.clearcoatMap,kt=z&&!!b.clearcoatNormalMap,rt=z&&!!b.clearcoatRoughnessMap,At=$&&!!b.iridescenceMap,Xt=$&&!!b.iridescenceThicknessMap,Lt=j&&!!b.sheenColorMap,ft=j&&!!b.sheenRoughnessMap,Wt=!!b.specularMap,qt=!!b.specularColorMap,ue=!!b.specularIntensityMap,U=Et&&!!b.transmissionMap,_t=Et&&!!b.thicknessMap,X=!!b.gradientMap,J=!!b.alphaMap,ot=b.alphaTest>0,Ut=!!b.alphaHash,$t=!!b.extensions;let de=_n;b.toneMapped&&(lt===null||lt.isXRRenderTarget===!0)&&(de=r.toneMapping);const ve={shaderID:mt,shaderType:b.type,shaderName:b.name,vertexShader:Jt,fragmentShader:W,defines:b.defines,customVertexShaderID:it,customFragmentShaderID:yt,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,batching:zt,batchingColor:zt&&O._colorsTexture!==null,instancing:Ft,instancingColor:Ft&&O.instanceColor!==null,instancingMorph:Ft&&O.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:lt===null?r.outputColorSpace:lt.isXRRenderTarget===!0?lt.texture.colorSpace:Mn,alphaToCoverage:!!b.alphaToCoverage,map:Dt,matcap:L,envMap:Z,envMapMode:Z&&nt.mapping,envMapCubeUVHeight:G,aoMap:Q,lightMap:st,bumpMap:tt,normalMap:et,displacementMap:d&&gt,emissiveMap:dt,normalMapObjectSpace:et&&b.normalMapType===uh,normalMapTangentSpace:et&&b.normalMapType===Fn,metalnessMap:Nt,roughnessMap:C,anisotropy:S,anisotropyMap:ht,clearcoat:z,clearcoatMap:ut,clearcoatNormalMap:kt,clearcoatRoughnessMap:rt,dispersion:K,iridescence:$,iridescenceMap:At,iridescenceThicknessMap:Xt,sheen:j,sheenColorMap:Lt,sheenRoughnessMap:ft,specularMap:Wt,specularColorMap:qt,specularIntensityMap:ue,transmission:Et,transmissionMap:U,thicknessMap:_t,gradientMap:X,opaque:b.transparent===!1&&b.blending===Qn&&b.alphaToCoverage===!1,alphaMap:J,alphaTest:ot,alphaHash:Ut,combine:b.combine,mapUv:Dt&&_(b.map.channel),aoMapUv:Q&&_(b.aoMap.channel),lightMapUv:st&&_(b.lightMap.channel),bumpMapUv:tt&&_(b.bumpMap.channel),normalMapUv:et&&_(b.normalMap.channel),displacementMapUv:gt&&_(b.displacementMap.channel),emissiveMapUv:dt&&_(b.emissiveMap.channel),metalnessMapUv:Nt&&_(b.metalnessMap.channel),roughnessMapUv:C&&_(b.roughnessMap.channel),anisotropyMapUv:ht&&_(b.anisotropyMap.channel),clearcoatMapUv:ut&&_(b.clearcoatMap.channel),clearcoatNormalMapUv:kt&&_(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&_(b.clearcoatRoughnessMap.channel),iridescenceMapUv:At&&_(b.iridescenceMap.channel),iridescenceThicknessMapUv:Xt&&_(b.iridescenceThicknessMap.channel),sheenColorMapUv:Lt&&_(b.sheenColorMap.channel),sheenRoughnessMapUv:ft&&_(b.sheenRoughnessMap.channel),specularMapUv:Wt&&_(b.specularMap.channel),specularColorMapUv:qt&&_(b.specularColorMap.channel),specularIntensityMapUv:ue&&_(b.specularIntensityMap.channel),transmissionMapUv:U&&_(b.transmissionMap.channel),thicknessMapUv:_t&&_(b.thicknessMap.channel),alphaMapUv:J&&_(b.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(et||S),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!q.attributes.uv&&(Dt||J),fog:!!V,useFog:b.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:u,skinning:O.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:vt,morphTextureStride:Gt,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:b.dithering,shadowMapEnabled:r.shadowMap.enabled&&I.length>0,shadowMapType:r.shadowMap.type,toneMapping:de,decodeVideoTexture:Dt&&b.map.isVideoTexture===!0&&Kt.getTransfer(b.map.colorSpace)===se,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===cn,flipSided:b.side===Pe,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:$t&&b.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:$t&&b.extensions.multiDraw===!0&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return ve.vertexUv1s=c.has(1),ve.vertexUv2s=c.has(2),ve.vertexUv3s=c.has(3),c.clear(),ve}function p(b){const M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(const I in b.defines)M.push(I),M.push(b.defines[I]);return b.isRawShaderMaterial===!1&&(v(M,b),x(M,b),M.push(r.outputColorSpace)),M.push(b.customProgramCacheKey),M.join()}function v(b,M){b.push(M.precision),b.push(M.outputColorSpace),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.mapUv),b.push(M.alphaMapUv),b.push(M.lightMapUv),b.push(M.aoMapUv),b.push(M.bumpMapUv),b.push(M.normalMapUv),b.push(M.displacementMapUv),b.push(M.emissiveMapUv),b.push(M.metalnessMapUv),b.push(M.roughnessMapUv),b.push(M.anisotropyMapUv),b.push(M.clearcoatMapUv),b.push(M.clearcoatNormalMapUv),b.push(M.clearcoatRoughnessMapUv),b.push(M.iridescenceMapUv),b.push(M.iridescenceThicknessMapUv),b.push(M.sheenColorMapUv),b.push(M.sheenRoughnessMapUv),b.push(M.specularMapUv),b.push(M.specularColorMapUv),b.push(M.specularIntensityMapUv),b.push(M.transmissionMapUv),b.push(M.thicknessMapUv),b.push(M.combine),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.numLightProbes),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function x(b,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),b.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.skinning&&o.enable(4),M.morphTargets&&o.enable(5),M.morphNormals&&o.enable(6),M.morphColors&&o.enable(7),M.premultipliedAlpha&&o.enable(8),M.shadowMapEnabled&&o.enable(9),M.doubleSided&&o.enable(10),M.flipSided&&o.enable(11),M.useDepthPacking&&o.enable(12),M.dithering&&o.enable(13),M.transmission&&o.enable(14),M.sheen&&o.enable(15),M.opaque&&o.enable(16),M.pointsUvs&&o.enable(17),M.decodeVideoTexture&&o.enable(18),M.alphaToCoverage&&o.enable(19),b.push(o.mask)}function y(b){const M=m[b.type];let I;if(M){const k=nn[M];I=Gh.clone(k.uniforms)}else I=b.uniforms;return I}function P(b,M){let I;for(let k=0,O=h.length;k<O;k++){const V=h[k];if(V.cacheKey===M){I=V,++I.usedTimes;break}}return I===void 0&&(I=new q0(r,M,b,s),h.push(I)),I}function w(b){if(--b.usedTimes===0){const M=h.indexOf(b);h[M]=h[h.length-1],h.pop(),b.destroy()}}function T(b){l.remove(b)}function R(){l.dispose()}return{getParameters:g,getProgramCacheKey:p,getUniforms:y,acquireProgram:P,releaseProgram:w,releaseShaderCache:T,programs:h,dispose:R}}function K0(){let r=new WeakMap;function t(s){let a=r.get(s);return a===void 0&&(a={},r.set(s,a)),a}function e(s){r.delete(s)}function n(s,a,o){r.get(s)[a]=o}function i(){r=new WeakMap}return{get:t,remove:e,update:n,dispose:i}}function Q0(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.material.id!==t.material.id?r.material.id-t.material.id:r.z!==t.z?r.z-t.z:r.id-t.id}function xu(r,t){return r.groupOrder!==t.groupOrder?r.groupOrder-t.groupOrder:r.renderOrder!==t.renderOrder?r.renderOrder-t.renderOrder:r.z!==t.z?t.z-r.z:r.id-t.id}function vu(){const r=[];let t=0;const e=[],n=[],i=[];function s(){t=0,e.length=0,n.length=0,i.length=0}function a(u,d,f,m,_,g){let p=r[t];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:m,renderOrder:u.renderOrder,z:_,group:g},r[t]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=m,p.renderOrder=u.renderOrder,p.z=_,p.group=g),t++,p}function o(u,d,f,m,_,g){const p=a(u,d,f,m,_,g);f.transmission>0?n.push(p):f.transparent===!0?i.push(p):e.push(p)}function l(u,d,f,m,_,g){const p=a(u,d,f,m,_,g);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):e.unshift(p)}function c(u,d){e.length>1&&e.sort(u||Q0),n.length>1&&n.sort(d||xu),i.length>1&&i.sort(d||xu)}function h(){for(let u=t,d=r.length;u<d;u++){const f=r[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:e,transmissive:n,transparent:i,init:s,push:o,unshift:l,finish:h,sort:c}}function j0(){let r=new WeakMap;function t(n,i){const s=r.get(n);let a;return s===void 0?(a=new vu,r.set(n,[a])):i>=s.length?(a=new vu,s.push(a)):a=s[i],a}function e(){r=new WeakMap}return{get:t,dispose:e}}function tx(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new E,color:new pt};break;case"SpotLight":e={position:new E,direction:new E,color:new pt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new E,color:new pt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new E,skyColor:new pt,groundColor:new pt};break;case"RectAreaLight":e={color:new pt,position:new E,halfWidth:new E,halfHeight:new E};break}return r[t.id]=e,e}}}function ex(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Y};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Y};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Y,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[t.id]=e,e}}}let nx=0;function ix(r,t){return(t.castShadow?2:0)-(r.castShadow?2:0)+(t.map?1:0)-(r.map?1:0)}function sx(r){const t=new tx,e=ex(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new E);const i=new E,s=new Rt,a=new Rt;function o(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,m=0,_=0,g=0,p=0,v=0,x=0,y=0,P=0,w=0,T=0;c.sort(ix);for(let b=0,M=c.length;b<M;b++){const I=c[b],k=I.color,O=I.intensity,V=I.distance,q=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)h+=k.r*O,u+=k.g*O,d+=k.b*O;else if(I.isLightProbe){for(let H=0;H<9;H++)n.probe[H].addScaledVector(I.sh.coefficients[H],O);T++}else if(I.isDirectionalLight){const H=t.get(I);if(H.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const nt=I.shadow,G=e.get(I);G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,n.directionalShadow[f]=G,n.directionalShadowMap[f]=q,n.directionalShadowMatrix[f]=I.shadow.matrix,v++}n.directional[f]=H,f++}else if(I.isSpotLight){const H=t.get(I);H.position.setFromMatrixPosition(I.matrixWorld),H.color.copy(k).multiplyScalar(O),H.distance=V,H.coneCos=Math.cos(I.angle),H.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),H.decay=I.decay,n.spot[_]=H;const nt=I.shadow;if(I.map&&(n.spotLightMap[P]=I.map,P++,nt.updateMatrices(I),I.castShadow&&w++),n.spotLightMatrix[_]=nt.matrix,I.castShadow){const G=e.get(I);G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,n.spotShadow[_]=G,n.spotShadowMap[_]=q,y++}_++}else if(I.isRectAreaLight){const H=t.get(I);H.color.copy(k).multiplyScalar(O),H.halfWidth.set(I.width*.5,0,0),H.halfHeight.set(0,I.height*.5,0),n.rectArea[g]=H,g++}else if(I.isPointLight){const H=t.get(I);if(H.color.copy(I.color).multiplyScalar(I.intensity),H.distance=I.distance,H.decay=I.decay,I.castShadow){const nt=I.shadow,G=e.get(I);G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,G.shadowCameraNear=nt.camera.near,G.shadowCameraFar=nt.camera.far,n.pointShadow[m]=G,n.pointShadowMap[m]=q,n.pointShadowMatrix[m]=I.shadow.matrix,x++}n.point[m]=H,m++}else if(I.isHemisphereLight){const H=t.get(I);H.skyColor.copy(I.color).multiplyScalar(O),H.groundColor.copy(I.groundColor).multiplyScalar(O),n.hemi[p]=H,p++}}g>0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ct.LTC_FLOAT_1,n.rectAreaLTC2=ct.LTC_FLOAT_2):(n.rectAreaLTC1=ct.LTC_HALF_1,n.rectAreaLTC2=ct.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const R=n.hash;(R.directionalLength!==f||R.pointLength!==m||R.spotLength!==_||R.rectAreaLength!==g||R.hemiLength!==p||R.numDirectionalShadows!==v||R.numPointShadows!==x||R.numSpotShadows!==y||R.numSpotMaps!==P||R.numLightProbes!==T)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=g,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=y,n.spotShadowMap.length=y,n.directionalShadowMatrix.length=v,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=y+P-w,n.spotLightMap.length=P,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=T,R.directionalLength=f,R.pointLength=m,R.spotLength=_,R.rectAreaLength=g,R.hemiLength=p,R.numDirectionalShadows=v,R.numPointShadows=x,R.numSpotShadows=y,R.numSpotMaps=P,R.numLightProbes=T,n.version=nx++)}function l(c,h){let u=0,d=0,f=0,m=0,_=0;const g=h.matrixWorldInverse;for(let p=0,v=c.length;p<v;p++){const x=c[p];if(x.isDirectionalLight){const y=n.directional[u];y.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),y.direction.sub(i),y.direction.transformDirection(g),u++}else if(x.isSpotLight){const y=n.spot[f];y.position.setFromMatrixPosition(x.matrixWorld),y.position.applyMatrix4(g),y.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),y.direction.sub(i),y.direction.transformDirection(g),f++}else if(x.isRectAreaLight){const y=n.rectArea[m];y.position.setFromMatrixPosition(x.matrixWorld),y.position.applyMatrix4(g),a.identity(),s.copy(x.matrixWorld),s.premultiply(g),a.extractRotation(s),y.halfWidth.set(x.width*.5,0,0),y.halfHeight.set(0,x.height*.5,0),y.halfWidth.applyMatrix4(a),y.halfHeight.applyMatrix4(a),m++}else if(x.isPointLight){const y=n.point[d];y.position.setFromMatrixPosition(x.matrixWorld),y.position.applyMatrix4(g),d++}else if(x.isHemisphereLight){const y=n.hemi[_];y.direction.setFromMatrixPosition(x.matrixWorld),y.direction.transformDirection(g),_++}}}return{setup:o,setupView:l,state:n}}function yu(r){const t=new sx(r),e=[],n=[];function i(h){c.camera=h,e.length=0,n.length=0}function s(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function rx(r){let t=new WeakMap;function e(i,s=0){const a=t.get(i);let o;return a===void 0?(o=new yu(r),t.set(i,[o])):s>=a.length?(o=new yu(r),a.push(o)):o=a[s],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class xl extends Te{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ch,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class vl extends Te{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const ax=`void main() {
  3661. gl_Position = vec4( position, 1.0 );
  3662. }`,ox=`uniform sampler2D shadow_pass;
  3663. uniform vec2 resolution;
  3664. uniform float radius;
  3665. #include <packing>
  3666. void main() {
  3667. const float samples = float( VSM_SAMPLES );
  3668. float mean = 0.0;
  3669. float squared_mean = 0.0;
  3670. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3671. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3672. for ( float i = 0.0; i < samples; i ++ ) {
  3673. float uvOffset = uvStart + i * uvStride;
  3674. #ifdef HORIZONTAL_PASS
  3675. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3676. mean += distribution.x;
  3677. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3678. #else
  3679. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3680. mean += depth;
  3681. squared_mean += depth * depth;
  3682. #endif
  3683. }
  3684. mean = mean / samples;
  3685. squared_mean = squared_mean / samples;
  3686. float std_dev = sqrt( squared_mean - mean * mean );
  3687. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3688. }`;function lx(r,t,e){let n=new Fs;const i=new Y,s=new Y,a=new ee,o=new xl({depthPacking:hh}),l=new vl,c={},h=e.maxTextureSize,u={[mn]:Pe,[Pe]:mn,[cn]:cn},d=new en({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Y},radius:{value:4}},vertexShader:ax,fragmentShader:ox}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new Ht;m.setAttribute("position",new te(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new ge(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ja;let p=this.type;this.render=function(w,T,R){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;const b=r.getRenderTarget(),M=r.getActiveCubeFace(),I=r.getActiveMipmapLevel(),k=r.state;k.setBlending(gn),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const O=p!==ln&&this.type===ln,V=p===ln&&this.type!==ln;for(let q=0,H=w.length;q<H;q++){const nt=w[q],G=nt.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",nt,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const mt=G.getFrameExtents();if(i.multiply(mt),s.copy(G.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/mt.x),i.x=s.x*mt.x,G.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/mt.y),i.y=s.y*mt.y,G.mapSize.y=s.y)),G.map===null||O===!0||V===!0){const vt=this.type!==ln?{minFilter:Me,magFilter:Me}:{};G.map!==null&&G.map.dispose(),G.map=new Ke(i.x,i.y,vt),G.map.texture.name=nt.name+".shadowMap",G.camera.updateProjectionMatrix()}r.setRenderTarget(G.map),r.clear();const Mt=G.getViewportCount();for(let vt=0;vt<Mt;vt++){const Gt=G.getViewport(vt);a.set(s.x*Gt.x,s.y*Gt.y,s.x*Gt.z,s.y*Gt.w),k.viewport(a),G.updateMatrices(nt,vt),n=G.getFrustum(),y(T,R,G.camera,nt,this.type)}G.isPointLightShadow!==!0&&this.type===ln&&v(G,R),G.needsUpdate=!1}p=this.type,g.needsUpdate=!1,r.setRenderTarget(b,M,I)};function v(w,T){const R=t.update(_);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new Ke(i.x,i.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.renderBufferDirect(T,null,R,d,_,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(T,null,R,f,_,null)}function x(w,T,R,b){let M=null;const I=R.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(I!==void 0)M=I;else if(M=R.isPointLight===!0?l:o,r.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0){const k=M.uuid,O=T.uuid;let V=c[k];V===void 0&&(V={},c[k]=V);let q=V[O];q===void 0&&(q=M.clone(),V[O]=q,T.addEventListener("dispose",P)),M=q}if(M.visible=T.visible,M.wireframe=T.wireframe,b===ln?M.side=T.shadowSide!==null?T.shadowSide:T.side:M.side=T.shadowSide!==null?T.shadowSide:u[T.side],M.alphaMap=T.alphaMap,M.alphaTest=T.alphaTest,M.map=T.map,M.clipShadows=T.clipShadows,M.clippingPlanes=T.clippingPlanes,M.clipIntersection=T.clipIntersection,M.displacementMap=T.displacementMap,M.displacementScale=T.displacementScale,M.displacementBias=T.displacementBias,M.wireframeLinewidth=T.wireframeLinewidth,M.linewidth=T.linewidth,R.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const k=r.properties.get(M);k.light=R}return M}function y(w,T,R,b,M){if(w.visible===!1)return;if(w.layers.test(T.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&M===ln)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,w.matrixWorld);const O=t.update(w),V=w.material;if(Array.isArray(V)){const q=O.groups;for(let H=0,nt=q.length;H<nt;H++){const G=q[H],mt=V[G.materialIndex];if(mt&&mt.visible){const Mt=x(w,mt,b,M);w.onBeforeShadow(r,w,T,R,O,Mt,G),r.renderBufferDirect(R,null,O,Mt,w,G),w.onAfterShadow(r,w,T,R,O,Mt,G)}}}else if(V.visible){const q=x(w,V,b,M);w.onBeforeShadow(r,w,T,R,O,q,null),r.renderBufferDirect(R,null,O,q,w,null),w.onAfterShadow(r,w,T,R,O,q,null)}}const k=w.children;for(let O=0,V=k.length;O<V;O++)y(k[O],T,R,b,M)}function P(w){w.target.removeEventListener("dispose",P);for(const R in c){const b=c[R],M=w.target.uuid;M in b&&(b[M].dispose(),delete b[M])}}}function cx(r){function t(){let U=!1;const _t=new ee;let X=null;const J=new ee(0,0,0,0);return{setMask:function(ot){X!==ot&&!U&&(r.colorMask(ot,ot,ot,ot),X=ot)},setLocked:function(ot){U=ot},setClear:function(ot,Ut,$t,de,ve){ve===!0&&(ot*=de,Ut*=de,$t*=de),_t.set(ot,Ut,$t,de),J.equals(_t)===!1&&(r.clearColor(ot,Ut,$t,de),J.copy(_t))},reset:function(){U=!1,X=null,J.set(-1,0,0,0)}}}function e(){let U=!1,_t=null,X=null,J=null;return{setTest:function(ot){ot?yt(r.DEPTH_TEST):lt(r.DEPTH_TEST)},setMask:function(ot){_t!==ot&&!U&&(r.depthMask(ot),_t=ot)},setFunc:function(ot){if(X!==ot){switch(ot){case Dc:r.depthFunc(r.NEVER);break;case Nc:r.depthFunc(r.ALWAYS);break;case Fc:r.depthFunc(r.LESS);break;case us:r.depthFunc(r.LEQUAL);break;case Oc:r.depthFunc(r.EQUAL);break;case Bc:r.depthFunc(r.GEQUAL);break;case zc:r.depthFunc(r.GREATER);break;case kc:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}X=ot}},setLocked:function(ot){U=ot},setClear:function(ot){J!==ot&&(r.clearDepth(ot),J=ot)},reset:function(){U=!1,_t=null,X=null,J=null}}}function n(){let U=!1,_t=null,X=null,J=null,ot=null,Ut=null,$t=null,de=null,ve=null;return{setTest:function(ne){U||(ne?yt(r.STENCIL_TEST):lt(r.STENCIL_TEST))},setMask:function(ne){_t!==ne&&!U&&(r.stencilMask(ne),_t=ne)},setFunc:function(ne,an,on){(X!==ne||J!==an||ot!==on)&&(r.stencilFunc(ne,an,on),X=ne,J=an,ot=on)},setOp:function(ne,an,on){(Ut!==ne||$t!==an||de!==on)&&(r.stencilOp(ne,an,on),Ut=ne,$t=an,de=on)},setLocked:function(ne){U=ne},setClear:function(ne){ve!==ne&&(r.clearStencil(ne),ve=ne)},reset:function(){U=!1,_t=null,X=null,J=null,ot=null,Ut=null,$t=null,de=null,ve=null}}}const i=new t,s=new e,a=new n,o=new WeakMap,l=new WeakMap;let c={},h={},u=new WeakMap,d=[],f=null,m=!1,_=null,g=null,p=null,v=null,x=null,y=null,P=null,w=new pt(0,0,0),T=0,R=!1,b=null,M=null,I=null,k=null,O=null;const V=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,H=0;const nt=r.getParameter(r.VERSION);nt.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(nt)[1]),q=H>=1):nt.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(nt)[1]),q=H>=2);let G=null,mt={};const Mt=r.getParameter(r.SCISSOR_BOX),vt=r.getParameter(r.VIEWPORT),Gt=new ee().fromArray(Mt),Jt=new ee().fromArray(vt);function W(U,_t,X,J){const ot=new Uint8Array(4),Ut=r.createTexture();r.bindTexture(U,Ut),r.texParameteri(U,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(U,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let $t=0;$t<X;$t++)U===r.TEXTURE_3D||U===r.TEXTURE_2D_ARRAY?r.texImage3D(_t,0,r.RGBA,1,1,J,0,r.RGBA,r.UNSIGNED_BYTE,ot):r.texImage2D(_t+$t,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,ot);return Ut}const it={};it[r.TEXTURE_2D]=W(r.TEXTURE_2D,r.TEXTURE_2D,1),it[r.TEXTURE_CUBE_MAP]=W(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),it[r.TEXTURE_2D_ARRAY]=W(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),it[r.TEXTURE_3D]=W(r.TEXTURE_3D,r.TEXTURE_3D,1,1),i.setClear(0,0,0,1),s.setClear(1),a.setClear(0),yt(r.DEPTH_TEST),s.setFunc(us),tt(!1),et(Za),yt(r.CULL_FACE),Q(gn);function yt(U){c[U]!==!0&&(r.enable(U),c[U]=!0)}function lt(U){c[U]!==!1&&(r.disable(U),c[U]=!1)}function Ft(U,_t){return h[U]!==_t?(r.bindFramebuffer(U,_t),h[U]=_t,U===r.DRAW_FRAMEBUFFER&&(h[r.FRAMEBUFFER]=_t),U===r.FRAMEBUFFER&&(h[r.DRAW_FRAMEBUFFER]=_t),!0):!1}function zt(U,_t){let X=d,J=!1;if(U){X=u.get(_t),X===void 0&&(X=[],u.set(_t,X));const ot=U.textures;if(X.length!==ot.length||X[0]!==r.COLOR_ATTACHMENT0){for(let Ut=0,$t=ot.length;Ut<$t;Ut++)X[Ut]=r.COLOR_ATTACHMENT0+Ut;X.length=ot.length,J=!0}}else X[0]!==r.BACK&&(X[0]=r.BACK,J=!0);J&&r.drawBuffers(X)}function Dt(U){return f!==U?(r.useProgram(U),f=U,!0):!1}const L={[Dn]:r.FUNC_ADD,[_c]:r.FUNC_SUBTRACT,[xc]:r.FUNC_REVERSE_SUBTRACT};L[vc]=r.MIN,L[yc]=r.MAX;const Z={[Mc]:r.ZERO,[Sc]:r.ONE,[bc]:r.SRC_COLOR,[ur]:r.SRC_ALPHA,[Rc]:r.SRC_ALPHA_SATURATE,[Tc]:r.DST_COLOR,[wc]:r.DST_ALPHA,[Ac]:r.ONE_MINUS_SRC_COLOR,[dr]:r.ONE_MINUS_SRC_ALPHA,[Cc]:r.ONE_MINUS_DST_COLOR,[Ec]:r.ONE_MINUS_DST_ALPHA,[Pc]:r.CONSTANT_COLOR,[Ic]:r.ONE_MINUS_CONSTANT_COLOR,[Lc]:r.CONSTANT_ALPHA,[Uc]:r.ONE_MINUS_CONSTANT_ALPHA};function Q(U,_t,X,J,ot,Ut,$t,de,ve,ne){if(U===gn){m===!0&&(lt(r.BLEND),m=!1);return}if(m===!1&&(yt(r.BLEND),m=!0),U!==gc){if(U!==_||ne!==R){if((g!==Dn||x!==Dn)&&(r.blendEquation(r.FUNC_ADD),g=Dn,x=Dn),ne)switch(U){case Qn:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case $a:r.blendFunc(r.ONE,r.ONE);break;case Ka:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Qa:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case Qn:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case $a:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case Ka:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Qa:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}p=null,v=null,y=null,P=null,w.set(0,0,0),T=0,_=U,R=ne}return}ot=ot||_t,Ut=Ut||X,$t=$t||J,(_t!==g||ot!==x)&&(r.blendEquationSeparate(L[_t],L[ot]),g=_t,x=ot),(X!==p||J!==v||Ut!==y||$t!==P)&&(r.blendFuncSeparate(Z[X],Z[J],Z[Ut],Z[$t]),p=X,v=J,y=Ut,P=$t),(de.equals(w)===!1||ve!==T)&&(r.blendColor(de.r,de.g,de.b,ve),w.copy(de),T=ve),_=U,R=!1}function st(U,_t){U.side===cn?lt(r.CULL_FACE):yt(r.CULL_FACE);let X=U.side===Pe;_t&&(X=!X),tt(X),U.blending===Qn&&U.transparent===!1?Q(gn):Q(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),s.setFunc(U.depthFunc),s.setTest(U.depthTest),s.setMask(U.depthWrite),i.setMask(U.colorWrite);const J=U.stencilWrite;a.setTest(J),J&&(a.setMask(U.stencilWriteMask),a.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),a.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),dt(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?yt(r.SAMPLE_ALPHA_TO_COVERAGE):lt(r.SAMPLE_ALPHA_TO_COVERAGE)}function tt(U){b!==U&&(U?r.frontFace(r.CW):r.frontFace(r.CCW),b=U)}function et(U){U!==fc?(yt(r.CULL_FACE),U!==M&&(U===Za?r.cullFace(r.BACK):U===pc?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):lt(r.CULL_FACE),M=U}function gt(U){U!==I&&(q&&r.lineWidth(U),I=U)}function dt(U,_t,X){U?(yt(r.POLYGON_OFFSET_FILL),(k!==_t||O!==X)&&(r.polygonOffset(_t,X),k=_t,O=X)):lt(r.POLYGON_OFFSET_FILL)}function Nt(U){U?yt(r.SCISSOR_TEST):lt(r.SCISSOR_TEST)}function C(U){U===void 0&&(U=r.TEXTURE0+V-1),G!==U&&(r.activeTexture(U),G=U)}function S(U,_t,X){X===void 0&&(G===null?X=r.TEXTURE0+V-1:X=G);let J=mt[X];J===void 0&&(J={type:void 0,texture:void 0},mt[X]=J),(J.type!==U||J.texture!==_t)&&(G!==X&&(r.activeTexture(X),G=X),r.bindTexture(U,_t||it[U]),J.type=U,J.texture=_t)}function z(){const U=mt[G];U!==void 0&&U.type!==void 0&&(r.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function K(){try{r.compressedTexImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function $(){try{r.compressedTexImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function j(){try{r.texSubImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Et(){try{r.texSubImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ht(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ut(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function kt(){try{r.texStorage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function rt(){try{r.texStorage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function At(){try{r.texImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Xt(){try{r.texImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Lt(U){Gt.equals(U)===!1&&(r.scissor(U.x,U.y,U.z,U.w),Gt.copy(U))}function ft(U){Jt.equals(U)===!1&&(r.viewport(U.x,U.y,U.z,U.w),Jt.copy(U))}function Wt(U,_t){let X=l.get(_t);X===void 0&&(X=new WeakMap,l.set(_t,X));let J=X.get(U);J===void 0&&(J=r.getUniformBlockIndex(_t,U.name),X.set(U,J))}function qt(U,_t){const J=l.get(_t).get(U);o.get(_t)!==J&&(r.uniformBlockBinding(_t,J,U.__bindingPointIndex),o.set(_t,J))}function ue(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.blendColor(0,0,0,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),c={},G=null,mt={},h={},u=new WeakMap,d=[],f=null,m=!1,_=null,g=null,p=null,v=null,x=null,y=null,P=null,w=new pt(0,0,0),T=0,R=!1,b=null,M=null,I=null,k=null,O=null,Gt.set(0,0,r.canvas.width,r.canvas.height),Jt.set(0,0,r.canvas.width,r.canvas.height),i.reset(),s.reset(),a.reset()}return{buffers:{color:i,depth:s,stencil:a},enable:yt,disable:lt,bindFramebuffer:Ft,drawBuffers:zt,useProgram:Dt,setBlending:Q,setMaterial:st,setFlipSided:tt,setCullFace:et,setLineWidth:gt,setPolygonOffset:dt,setScissorTest:Nt,activeTexture:C,bindTexture:S,unbindTexture:z,compressedTexImage2D:K,compressedTexImage3D:$,texImage2D:At,texImage3D:Xt,updateUBOMapping:Wt,uniformBlockBinding:qt,texStorage2D:kt,texStorage3D:rt,texSubImage2D:j,texSubImage3D:Et,compressedTexSubImage2D:ht,compressedTexSubImage3D:ut,scissor:Lt,viewport:ft,reset:ue}}function hx(r,t,e,n,i,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Y,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(C,S){return f?new OffscreenCanvas(C,S):Rs("canvas")}function _(C,S,z){let K=1;const $=Nt(C);if(($.width>z||$.height>z)&&(K=z/Math.max($.width,$.height)),K<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const j=Math.floor(K*$.width),Et=Math.floor(K*$.height);u===void 0&&(u=m(j,Et));const ht=S?m(j,Et):u;return ht.width=j,ht.height=Et,ht.getContext("2d").drawImage(C,0,0,j,Et),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+j+"x"+Et+")."),ht}else return"data"in C&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),C;return C}function g(C){return C.generateMipmaps&&C.minFilter!==Me&&C.minFilter!==pe}function p(C){r.generateMipmap(C)}function v(C,S,z,K,$=!1){if(C!==null){if(r[C]!==void 0)return r[C];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let j=S;if(S===r.RED&&(z===r.FLOAT&&(j=r.R32F),z===r.HALF_FLOAT&&(j=r.R16F),z===r.UNSIGNED_BYTE&&(j=r.R8)),S===r.RED_INTEGER&&(z===r.UNSIGNED_BYTE&&(j=r.R8UI),z===r.UNSIGNED_SHORT&&(j=r.R16UI),z===r.UNSIGNED_INT&&(j=r.R32UI),z===r.BYTE&&(j=r.R8I),z===r.SHORT&&(j=r.R16I),z===r.INT&&(j=r.R32I)),S===r.RG&&(z===r.FLOAT&&(j=r.RG32F),z===r.HALF_FLOAT&&(j=r.RG16F),z===r.UNSIGNED_BYTE&&(j=r.RG8)),S===r.RG_INTEGER&&(z===r.UNSIGNED_BYTE&&(j=r.RG8UI),z===r.UNSIGNED_SHORT&&(j=r.RG16UI),z===r.UNSIGNED_INT&&(j=r.RG32UI),z===r.BYTE&&(j=r.RG8I),z===r.SHORT&&(j=r.RG16I),z===r.INT&&(j=r.RG32I)),S===r.RGB&&z===r.UNSIGNED_INT_5_9_9_9_REV&&(j=r.RGB9_E5),S===r.RGBA){const Et=$?bs:Kt.getTransfer(K);z===r.FLOAT&&(j=r.RGBA32F),z===r.HALF_FLOAT&&(j=r.RGBA16F),z===r.UNSIGNED_BYTE&&(j=Et===se?r.SRGB8_ALPHA8:r.RGBA8),z===r.UNSIGNED_SHORT_4_4_4_4&&(j=r.RGBA4),z===r.UNSIGNED_SHORT_5_5_5_1&&(j=r.RGB5_A1)}return(j===r.R16F||j===r.R32F||j===r.RG16F||j===r.RG32F||j===r.RGBA16F||j===r.RGBA32F)&&t.get("EXT_color_buffer_float"),j}function x(C,S){let z;return C?S===null||S===jn||S===ti?z=r.DEPTH24_STENCIL8:S===Ve?z=r.DEPTH32F_STENCIL8:S===xs&&(z=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===jn||S===ti?z=r.DEPTH_COMPONENT24:S===Ve?z=r.DEPTH_COMPONENT32F:S===xs&&(z=r.DEPTH_COMPONENT16),z}function y(C,S){return g(C)===!0||C.isFramebufferTexture&&C.minFilter!==Me&&C.minFilter!==pe?Math.log2(Math.max(S.width,S.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?S.mipmaps.length:1}function P(C){const S=C.target;S.removeEventListener("dispose",P),T(S),S.isVideoTexture&&h.delete(S)}function w(C){const S=C.target;S.removeEventListener("dispose",w),b(S)}function T(C){const S=n.get(C);if(S.__webglInit===void 0)return;const z=C.source,K=d.get(z);if(K){const $=K[S.__cacheKey];$.usedTimes--,$.usedTimes===0&&R(C),Object.keys(K).length===0&&d.delete(z)}n.remove(C)}function R(C){const S=n.get(C);r.deleteTexture(S.__webglTexture);const z=C.source,K=d.get(z);delete K[S.__cacheKey],a.memory.textures--}function b(C){const S=n.get(C);if(C.depthTexture&&C.depthTexture.dispose(),C.isWebGLCubeRenderTarget)for(let K=0;K<6;K++){if(Array.isArray(S.__webglFramebuffer[K]))for(let $=0;$<S.__webglFramebuffer[K].length;$++)r.deleteFramebuffer(S.__webglFramebuffer[K][$]);else r.deleteFramebuffer(S.__webglFramebuffer[K]);S.__webglDepthbuffer&&r.deleteRenderbuffer(S.__webglDepthbuffer[K])}else{if(Array.isArray(S.__webglFramebuffer))for(let K=0;K<S.__webglFramebuffer.length;K++)r.deleteFramebuffer(S.__webglFramebuffer[K]);else r.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&r.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&r.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let K=0;K<S.__webglColorRenderbuffer.length;K++)S.__webglColorRenderbuffer[K]&&r.deleteRenderbuffer(S.__webglColorRenderbuffer[K]);S.__webglDepthRenderbuffer&&r.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const z=C.textures;for(let K=0,$=z.length;K<$;K++){const j=n.get(z[K]);j.__webglTexture&&(r.deleteTexture(j.__webglTexture),a.memory.textures--),n.remove(z[K])}n.remove(C)}let M=0;function I(){M=0}function k(){const C=M;return C>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+i.maxTextures),M+=1,C}function O(C){const S=[];return S.push(C.wrapS),S.push(C.wrapT),S.push(C.wrapR||0),S.push(C.magFilter),S.push(C.minFilter),S.push(C.anisotropy),S.push(C.internalFormat),S.push(C.format),S.push(C.type),S.push(C.generateMipmaps),S.push(C.premultiplyAlpha),S.push(C.flipY),S.push(C.unpackAlignment),S.push(C.colorSpace),S.join()}function V(C,S){const z=n.get(C);if(C.isVideoTexture&&gt(C),C.isRenderTargetTexture===!1&&C.version>0&&z.__version!==C.version){const K=C.image;if(K===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(K.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Jt(z,C,S);return}}e.bindTexture(r.TEXTURE_2D,z.__webglTexture,r.TEXTURE0+S)}function q(C,S){const z=n.get(C);if(C.version>0&&z.__version!==C.version){Jt(z,C,S);return}e.bindTexture(r.TEXTURE_2D_ARRAY,z.__webglTexture,r.TEXTURE0+S)}function H(C,S){const z=n.get(C);if(C.version>0&&z.__version!==C.version){Jt(z,C,S);return}e.bindTexture(r.TEXTURE_3D,z.__webglTexture,r.TEXTURE0+S)}function nt(C,S){const z=n.get(C);if(C.version>0&&z.__version!==C.version){W(z,C,S);return}e.bindTexture(r.TEXTURE_CUBE_MAP,z.__webglTexture,r.TEXTURE0+S)}const G={[ms]:r.REPEAT,[Ze]:r.CLAMP_TO_EDGE,[gs]:r.MIRRORED_REPEAT},mt={[Me]:r.NEAREST,[to]:r.NEAREST_MIPMAP_NEAREST,[Pi]:r.NEAREST_MIPMAP_LINEAR,[pe]:r.LINEAR,[_s]:r.LINEAR_MIPMAP_NEAREST,[hn]:r.LINEAR_MIPMAP_LINEAR},Mt={[dh]:r.NEVER,[xh]:r.ALWAYS,[fh]:r.LESS,[Oo]:r.LEQUAL,[ph]:r.EQUAL,[_h]:r.GEQUAL,[mh]:r.GREATER,[gh]:r.NOTEQUAL};function vt(C,S){if(S.type===Ve&&t.has("OES_texture_float_linear")===!1&&(S.magFilter===pe||S.magFilter===_s||S.magFilter===Pi||S.magFilter===hn||S.minFilter===pe||S.minFilter===_s||S.minFilter===Pi||S.minFilter===hn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(C,r.TEXTURE_WRAP_S,G[S.wrapS]),r.texParameteri(C,r.TEXTURE_WRAP_T,G[S.wrapT]),(C===r.TEXTURE_3D||C===r.TEXTURE_2D_ARRAY)&&r.texParameteri(C,r.TEXTURE_WRAP_R,G[S.wrapR]),r.texParameteri(C,r.TEXTURE_MAG_FILTER,mt[S.magFilter]),r.texParameteri(C,r.TEXTURE_MIN_FILTER,mt[S.minFilter]),S.compareFunction&&(r.texParameteri(C,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(C,r.TEXTURE_COMPARE_FUNC,Mt[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Me||S.minFilter!==Pi&&S.minFilter!==hn||S.type===Ve&&t.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){const z=t.get("EXT_texture_filter_anisotropic");r.texParameterf(C,z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function Gt(C,S){let z=!1;C.__webglInit===void 0&&(C.__webglInit=!0,S.addEventListener("dispose",P));const K=S.source;let $=d.get(K);$===void 0&&($={},d.set(K,$));const j=O(S);if(j!==C.__cacheKey){$[j]===void 0&&($[j]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,z=!0),$[j].usedTimes++;const Et=$[C.__cacheKey];Et!==void 0&&($[C.__cacheKey].usedTimes--,Et.usedTimes===0&&R(S)),C.__cacheKey=j,C.__webglTexture=$[j].texture}return z}function Jt(C,S,z){let K=r.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(K=r.TEXTURE_2D_ARRAY),S.isData3DTexture&&(K=r.TEXTURE_3D);const $=Gt(C,S),j=S.source;e.bindTexture(K,C.__webglTexture,r.TEXTURE0+z);const Et=n.get(j);if(j.version!==Et.__version||$===!0){e.activeTexture(r.TEXTURE0+z);const ht=Kt.getPrimaries(Kt.workingColorSpace),ut=S.colorSpace===yn?null:Kt.getPrimaries(S.colorSpace),kt=S.colorSpace===yn||ht===ut?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,kt);let rt=_(S.image,!1,i.maxTextureSize);rt=dt(S,rt);const At=s.convert(S.format,S.colorSpace),Xt=s.convert(S.type);let Lt=v(S.internalFormat,At,Xt,S.colorSpace,S.isVideoTexture);vt(K,S);let ft;const Wt=S.mipmaps,qt=S.isVideoTexture!==!0,ue=Et.__version===void 0||$===!0,U=j.dataReady,_t=y(S,rt);if(S.isDepthTexture)Lt=x(S.format===ni,S.type),ue&&(qt?e.texStorage2D(r.TEXTURE_2D,1,Lt,rt.width,rt.height):e.texImage2D(r.TEXTURE_2D,0,Lt,rt.width,rt.height,0,At,Xt,null));else if(S.isDataTexture)if(Wt.length>0){qt&&ue&&e.texStorage2D(r.TEXTURE_2D,_t,Lt,Wt[0].width,Wt[0].height);for(let X=0,J=Wt.length;X<J;X++)ft=Wt[X],qt?U&&e.texSubImage2D(r.TEXTURE_2D,X,0,0,ft.width,ft.height,At,Xt,ft.data):e.texImage2D(r.TEXTURE_2D,X,Lt,ft.width,ft.height,0,At,Xt,ft.data);S.generateMipmaps=!1}else qt?(ue&&e.texStorage2D(r.TEXTURE_2D,_t,Lt,rt.width,rt.height),U&&e.texSubImage2D(r.TEXTURE_2D,0,0,0,rt.width,rt.height,At,Xt,rt.data)):e.texImage2D(r.TEXTURE_2D,0,Lt,rt.width,rt.height,0,At,Xt,rt.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){qt&&ue&&e.texStorage3D(r.TEXTURE_2D_ARRAY,_t,Lt,Wt[0].width,Wt[0].height,rt.depth);for(let X=0,J=Wt.length;X<J;X++)if(ft=Wt[X],S.format!==Fe)if(At!==null)if(qt){if(U)if(S.layerUpdates.size>0){for(const ot of S.layerUpdates){const Ut=ft.width*ft.height;e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,X,0,0,ot,ft.width,ft.height,1,At,ft.data.slice(Ut*ot,Ut*(ot+1)),0,0)}S.clearLayerUpdates()}else e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,X,0,0,0,ft.width,ft.height,rt.depth,At,ft.data,0,0)}else e.compressedTexImage3D(r.TEXTURE_2D_ARRAY,X,Lt,ft.width,ft.height,rt.depth,0,ft.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else qt?U&&e.texSubImage3D(r.TEXTURE_2D_ARRAY,X,0,0,0,ft.width,ft.height,rt.depth,At,Xt,ft.data):e.texImage3D(r.TEXTURE_2D_ARRAY,X,Lt,ft.width,ft.height,rt.depth,0,At,Xt,ft.data)}else{qt&&ue&&e.texStorage2D(r.TEXTURE_2D,_t,Lt,Wt[0].width,Wt[0].height);for(let X=0,J=Wt.length;X<J;X++)ft=Wt[X],S.format!==Fe?At!==null?qt?U&&e.compressedTexSubImage2D(r.TEXTURE_2D,X,0,0,ft.width,ft.height,At,ft.data):e.compressedTexImage2D(r.TEXTURE_2D,X,Lt,ft.width,ft.height,0,ft.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qt?U&&e.texSubImage2D(r.TEXTURE_2D,X,0,0,ft.width,ft.height,At,Xt,ft.data):e.texImage2D(r.TEXTURE_2D,X,Lt,ft.width,ft.height,0,At,Xt,ft.data)}else if(S.isDataArrayTexture)if(qt){if(ue&&e.texStorage3D(r.TEXTURE_2D_ARRAY,_t,Lt,rt.width,rt.height,rt.depth),U)if(S.layerUpdates.size>0){let X;switch(Xt){case r.UNSIGNED_BYTE:switch(At){case r.ALPHA:X=1;break;case r.LUMINANCE:X=1;break;case r.LUMINANCE_ALPHA:X=2;break;case r.RGB:X=3;break;case r.RGBA:X=4;break;default:throw new Error(`Unknown texel size for format ${At}.`)}break;case r.UNSIGNED_SHORT_4_4_4_4:case r.UNSIGNED_SHORT_5_5_5_1:case r.UNSIGNED_SHORT_5_6_5:X=1;break;default:throw new Error(`Unknown texel size for type ${Xt}.`)}const J=rt.width*rt.height*X;for(const ot of S.layerUpdates)e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,ot,rt.width,rt.height,1,At,Xt,rt.data.slice(J*ot,J*(ot+1)));S.clearLayerUpdates()}else e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,rt.width,rt.height,rt.depth,At,Xt,rt.data)}else e.texImage3D(r.TEXTURE_2D_ARRAY,0,Lt,rt.width,rt.height,rt.depth,0,At,Xt,rt.data);else if(S.isData3DTexture)qt?(ue&&e.texStorage3D(r.TEXTURE_3D,_t,Lt,rt.width,rt.height,rt.depth),U&&e.texSubImage3D(r.TEXTURE_3D,0,0,0,0,rt.width,rt.height,rt.depth,At,Xt,rt.data)):e.texImage3D(r.TEXTURE_3D,0,Lt,rt.width,rt.height,rt.depth,0,At,Xt,rt.data);else if(S.isFramebufferTexture){if(ue)if(qt)e.texStorage2D(r.TEXTURE_2D,_t,Lt,rt.width,rt.height);else{let X=rt.width,J=rt.height;for(let ot=0;ot<_t;ot++)e.texImage2D(r.TEXTURE_2D,ot,Lt,X,J,0,At,Xt,null),X>>=1,J>>=1}}else if(Wt.length>0){if(qt&&ue){const X=Nt(Wt[0]);e.texStorage2D(r.TEXTURE_2D,_t,Lt,X.width,X.height)}for(let X=0,J=Wt.length;X<J;X++)ft=Wt[X],qt?U&&e.texSubImage2D(r.TEXTURE_2D,X,0,0,At,Xt,ft):e.texImage2D(r.TEXTURE_2D,X,Lt,At,Xt,ft);S.generateMipmaps=!1}else if(qt){if(ue){const X=Nt(rt);e.texStorage2D(r.TEXTURE_2D,_t,Lt,X.width,X.height)}U&&e.texSubImage2D(r.TEXTURE_2D,0,0,0,At,Xt,rt)}else e.texImage2D(r.TEXTURE_2D,0,Lt,At,Xt,rt);g(S)&&p(K),Et.__version=j.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function W(C,S,z){if(S.image.length!==6)return;const K=Gt(C,S),$=S.source;e.bindTexture(r.TEXTURE_CUBE_MAP,C.__webglTexture,r.TEXTURE0+z);const j=n.get($);if($.version!==j.__version||K===!0){e.activeTexture(r.TEXTURE0+z);const Et=Kt.getPrimaries(Kt.workingColorSpace),ht=S.colorSpace===yn?null:Kt.getPrimaries(S.colorSpace),ut=S.colorSpace===yn||Et===ht?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,ut);const kt=S.isCompressedTexture||S.image[0].isCompressedTexture,rt=S.image[0]&&S.image[0].isDataTexture,At=[];for(let J=0;J<6;J++)!kt&&!rt?At[J]=_(S.image[J],!0,i.maxCubemapSize):At[J]=rt?S.image[J].image:S.image[J],At[J]=dt(S,At[J]);const Xt=At[0],Lt=s.convert(S.format,S.colorSpace),ft=s.convert(S.type),Wt=v(S.internalFormat,Lt,ft,S.colorSpace),qt=S.isVideoTexture!==!0,ue=j.__version===void 0||K===!0,U=$.dataReady;let _t=y(S,Xt);vt(r.TEXTURE_CUBE_MAP,S);let X;if(kt){qt&&ue&&e.texStorage2D(r.TEXTURE_CUBE_MAP,_t,Wt,Xt.width,Xt.height);for(let J=0;J<6;J++){X=At[J].mipmaps;for(let ot=0;ot<X.length;ot++){const Ut=X[ot];S.format!==Fe?Lt!==null?qt?U&&e.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ot,0,0,Ut.width,Ut.height,Lt,Ut.data):e.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ot,Wt,Ut.width,Ut.height,0,Ut.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):qt?U&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ot,0,0,Ut.width,Ut.height,Lt,ft,Ut.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ot,Wt,Ut.width,Ut.height,0,Lt,ft,Ut.data)}}}else{if(X=S.mipmaps,qt&&ue){X.length>0&&_t++;const J=Nt(At[0]);e.texStorage2D(r.TEXTURE_CUBE_MAP,_t,Wt,J.width,J.height)}for(let J=0;J<6;J++)if(rt){qt?U&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,At[J].width,At[J].height,Lt,ft,At[J].data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Wt,At[J].width,At[J].height,0,Lt,ft,At[J].data);for(let ot=0;ot<X.length;ot++){const $t=X[ot].image[J].image;qt?U&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ot+1,0,0,$t.width,$t.height,Lt,ft,$t.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ot+1,Wt,$t.width,$t.height,0,Lt,ft,$t.data)}}else{qt?U&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,Lt,ft,At[J]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Wt,Lt,ft,At[J]);for(let ot=0;ot<X.length;ot++){const Ut=X[ot];qt?U&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ot+1,0,0,Lt,ft,Ut.image[J]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,ot+1,Wt,Lt,ft,Ut.image[J])}}}g(S)&&p(r.TEXTURE_CUBE_MAP),j.__version=$.version,S.onUpdate&&S.onUpdate(S)}C.__version=S.version}function it(C,S,z,K,$,j){const Et=s.convert(z.format,z.colorSpace),ht=s.convert(z.type),ut=v(z.internalFormat,Et,ht,z.colorSpace);if(!n.get(S).__hasExternalTextures){const rt=Math.max(1,S.width>>j),At=Math.max(1,S.height>>j);$===r.TEXTURE_3D||$===r.TEXTURE_2D_ARRAY?e.texImage3D($,j,ut,rt,At,S.depth,0,Et,ht,null):e.texImage2D($,j,ut,rt,At,0,Et,ht,null)}e.bindFramebuffer(r.FRAMEBUFFER,C),et(S)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,K,$,n.get(z).__webglTexture,0,tt(S)):($===r.TEXTURE_2D||$>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,K,$,n.get(z).__webglTexture,j),e.bindFramebuffer(r.FRAMEBUFFER,null)}function yt(C,S,z){if(r.bindRenderbuffer(r.RENDERBUFFER,C),S.depthBuffer){const K=S.depthTexture,$=K&&K.isDepthTexture?K.type:null,j=x(S.stencilBuffer,$),Et=S.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,ht=tt(S);et(S)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,ht,j,S.width,S.height):z?r.renderbufferStorageMultisample(r.RENDERBUFFER,ht,j,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,j,S.width,S.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Et,r.RENDERBUFFER,C)}else{const K=S.textures;for(let $=0;$<K.length;$++){const j=K[$],Et=s.convert(j.format,j.colorSpace),ht=s.convert(j.type),ut=v(j.internalFormat,Et,ht,j.colorSpace),kt=tt(S);z&&et(S)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,kt,ut,S.width,S.height):et(S)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,kt,ut,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,ut,S.width,S.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function lt(C,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(r.FRAMEBUFFER,C),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),V(S.depthTexture,0);const K=n.get(S.depthTexture).__webglTexture,$=tt(S);if(S.depthTexture.format===ei)et(S)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,K,0,$):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,K,0);else if(S.depthTexture.format===ni)et(S)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,K,0,$):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,K,0);else throw new Error("Unknown depthTexture format")}function Ft(C){const S=n.get(C),z=C.isWebGLCubeRenderTarget===!0;if(C.depthTexture&&!S.__autoAllocateDepthBuffer){if(z)throw new Error("target.depthTexture not supported in Cube render targets");lt(S.__webglFramebuffer,C)}else if(z){S.__webglDepthbuffer=[];for(let K=0;K<6;K++)e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer[K]),S.__webglDepthbuffer[K]=r.createRenderbuffer(),yt(S.__webglDepthbuffer[K],C,!1)}else e.bindFramebuffer(r.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer=r.createRenderbuffer(),yt(S.__webglDepthbuffer,C,!1);e.bindFramebuffer(r.FRAMEBUFFER,null)}function zt(C,S,z){const K=n.get(C);S!==void 0&&it(K.__webglFramebuffer,C,C.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),z!==void 0&&Ft(C)}function Dt(C){const S=C.texture,z=n.get(C),K=n.get(S);C.addEventListener("dispose",w);const $=C.textures,j=C.isWebGLCubeRenderTarget===!0,Et=$.length>1;if(Et||(K.__webglTexture===void 0&&(K.__webglTexture=r.createTexture()),K.__version=S.version,a.memory.textures++),j){z.__webglFramebuffer=[];for(let ht=0;ht<6;ht++)if(S.mipmaps&&S.mipmaps.length>0){z.__webglFramebuffer[ht]=[];for(let ut=0;ut<S.mipmaps.length;ut++)z.__webglFramebuffer[ht][ut]=r.createFramebuffer()}else z.__webglFramebuffer[ht]=r.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){z.__webglFramebuffer=[];for(let ht=0;ht<S.mipmaps.length;ht++)z.__webglFramebuffer[ht]=r.createFramebuffer()}else z.__webglFramebuffer=r.createFramebuffer();if(Et)for(let ht=0,ut=$.length;ht<ut;ht++){const kt=n.get($[ht]);kt.__webglTexture===void 0&&(kt.__webglTexture=r.createTexture(),a.memory.textures++)}if(C.samples>0&&et(C)===!1){z.__webglMultisampledFramebuffer=r.createFramebuffer(),z.__webglColorRenderbuffer=[],e.bindFramebuffer(r.FRAMEBUFFER,z.__webglMultisampledFramebuffer);for(let ht=0;ht<$.length;ht++){const ut=$[ht];z.__webglColorRenderbuffer[ht]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,z.__webglColorRenderbuffer[ht]);const kt=s.convert(ut.format,ut.colorSpace),rt=s.convert(ut.type),At=v(ut.internalFormat,kt,rt,ut.colorSpace,C.isXRRenderTarget===!0),Xt=tt(C);r.renderbufferStorageMultisample(r.RENDERBUFFER,Xt,At,C.width,C.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ht,r.RENDERBUFFER,z.__webglColorRenderbuffer[ht])}r.bindRenderbuffer(r.RENDERBUFFER,null),C.depthBuffer&&(z.__webglDepthRenderbuffer=r.createRenderbuffer(),yt(z.__webglDepthRenderbuffer,C,!0)),e.bindFramebuffer(r.FRAMEBUFFER,null)}}if(j){e.bindTexture(r.TEXTURE_CUBE_MAP,K.__webglTexture),vt(r.TEXTURE_CUBE_MAP,S);for(let ht=0;ht<6;ht++)if(S.mipmaps&&S.mipmaps.length>0)for(let ut=0;ut<S.mipmaps.length;ut++)it(z.__webglFramebuffer[ht][ut],C,S,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+ht,ut);else it(z.__webglFramebuffer[ht],C,S,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0);g(S)&&p(r.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(Et){for(let ht=0,ut=$.length;ht<ut;ht++){const kt=$[ht],rt=n.get(kt);e.bindTexture(r.TEXTURE_2D,rt.__webglTexture),vt(r.TEXTURE_2D,kt),it(z.__webglFramebuffer,C,kt,r.COLOR_ATTACHMENT0+ht,r.TEXTURE_2D,0),g(kt)&&p(r.TEXTURE_2D)}e.unbindTexture()}else{let ht=r.TEXTURE_2D;if((C.isWebGL3DRenderTarget||C.isWebGLArrayRenderTarget)&&(ht=C.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY),e.bindTexture(ht,K.__webglTexture),vt(ht,S),S.mipmaps&&S.mipmaps.length>0)for(let ut=0;ut<S.mipmaps.length;ut++)it(z.__webglFramebuffer[ut],C,S,r.COLOR_ATTACHMENT0,ht,ut);else it(z.__webglFramebuffer,C,S,r.COLOR_ATTACHMENT0,ht,0);g(S)&&p(ht),e.unbindTexture()}C.depthBuffer&&Ft(C)}function L(C){const S=C.textures;for(let z=0,K=S.length;z<K;z++){const $=S[z];if(g($)){const j=C.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,Et=n.get($).__webglTexture;e.bindTexture(j,Et),p(j),e.unbindTexture()}}}const Z=[],Q=[];function st(C){if(C.samples>0){if(et(C)===!1){const S=C.textures,z=C.width,K=C.height;let $=r.COLOR_BUFFER_BIT;const j=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Et=n.get(C),ht=S.length>1;if(ht)for(let ut=0;ut<S.length;ut++)e.bindFramebuffer(r.FRAMEBUFFER,Et.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ut,r.RENDERBUFFER,null),e.bindFramebuffer(r.FRAMEBUFFER,Et.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ut,r.TEXTURE_2D,null,0);e.bindFramebuffer(r.READ_FRAMEBUFFER,Et.__webglMultisampledFramebuffer),e.bindFramebuffer(r.DRAW_FRAMEBUFFER,Et.__webglFramebuffer);for(let ut=0;ut<S.length;ut++){if(C.resolveDepthBuffer&&(C.depthBuffer&&($|=r.DEPTH_BUFFER_BIT),C.stencilBuffer&&C.resolveStencilBuffer&&($|=r.STENCIL_BUFFER_BIT)),ht){r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Et.__webglColorRenderbuffer[ut]);const kt=n.get(S[ut]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,kt,0)}r.blitFramebuffer(0,0,z,K,0,0,z,K,$,r.NEAREST),l===!0&&(Z.length=0,Q.length=0,Z.push(r.COLOR_ATTACHMENT0+ut),C.depthBuffer&&C.resolveDepthBuffer===!1&&(Z.push(j),Q.push(j),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,Q)),r.invalidateFramebuffer(r.READ_FRAMEBUFFER,Z))}if(e.bindFramebuffer(r.READ_FRAMEBUFFER,null),e.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),ht)for(let ut=0;ut<S.length;ut++){e.bindFramebuffer(r.FRAMEBUFFER,Et.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ut,r.RENDERBUFFER,Et.__webglColorRenderbuffer[ut]);const kt=n.get(S[ut]).__webglTexture;e.bindFramebuffer(r.FRAMEBUFFER,Et.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+ut,r.TEXTURE_2D,kt,0)}e.bindFramebuffer(r.DRAW_FRAMEBUFFER,Et.__webglMultisampledFramebuffer)}else if(C.depthBuffer&&C.resolveDepthBuffer===!1&&l){const S=C.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[S])}}}function tt(C){return Math.min(i.maxSamples,C.samples)}function et(C){const S=n.get(C);return C.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function gt(C){const S=a.render.frame;h.get(C)!==S&&(h.set(C,S),C.update())}function dt(C,S){const z=C.colorSpace,K=C.format,$=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||z!==Mn&&z!==yn&&(Kt.getTransfer(z)===se?(K!==Fe||$!==vn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",z)),S}function Nt(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=I,this.setTexture2D=V,this.setTexture2DArray=q,this.setTexture3D=H,this.setTextureCube=nt,this.rebindTextures=zt,this.setupRenderTarget=Dt,this.updateRenderTargetMipmap=L,this.updateMultisampleRenderTarget=st,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=it,this.useMultisampledRTT=et}function Mu(r,t){function e(n,i=yn){let s;const a=Kt.getTransfer(i);if(n===vn)return r.UNSIGNED_BYTE;if(n===no)return r.UNSIGNED_SHORT_4_4_4_4;if(n===io)return r.UNSIGNED_SHORT_5_5_5_1;if(n===jc)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===Kc)return r.BYTE;if(n===Qc)return r.SHORT;if(n===xs)return r.UNSIGNED_SHORT;if(n===eo)return r.INT;if(n===jn)return r.UNSIGNED_INT;if(n===Ve)return r.FLOAT;if(n===vs)return r.HALF_FLOAT;if(n===th)return r.ALPHA;if(n===eh)return r.RGB;if(n===Fe)return r.RGBA;if(n===nh)return r.LUMINANCE;if(n===ih)return r.LUMINANCE_ALPHA;if(n===ei)return r.DEPTH_COMPONENT;if(n===ni)return r.DEPTH_STENCIL;if(n===so)return r.RED;if(n===ro)return r.RED_INTEGER;if(n===sh)return r.RG;if(n===ao)return r.RG_INTEGER;if(n===oo)return r.RGBA_INTEGER;if(n===pr||n===mr||n===gr||n===_r)if(a===se)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===pr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===mr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===gr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===_r)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===pr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===mr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===gr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===_r)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===lo||n===co||n===ho||n===uo)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===lo)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===co)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ho)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===uo)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===fo||n===po||n===mo)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===fo||n===po)return a===se?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===mo)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===go||n===_o||n===xo||n===vo||n===yo||n===Mo||n===So||n===bo||n===Ao||n===wo||n===Eo||n===To||n===Co||n===Ro)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===go)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===_o)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===xo)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===vo)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===yo)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Mo)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===So)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===bo)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ao)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===wo)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Eo)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===To)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Co)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ro)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===xr||n===Po||n===Io)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===xr)return a===se?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Po)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Io)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===rh||n===Lo||n===Uo||n===Do)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===xr)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Lo)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Uo)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Do)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===ti?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:e}}class Su extends be{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class ts extends Zt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const ux={type:"move"};class yl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ts,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 ts,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ts,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const _ of t.hand.values()){const g=e.getJointPose(_,n),p=this._getHandJoint(c,_);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(ux)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new ts;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const dx=`
  3689. void main() {
  3690. gl_Position = vec4( position, 1.0 );
  3691. }`,fx=`
  3692. uniform sampler2DArray depthColor;
  3693. uniform float depthWidth;
  3694. uniform float depthHeight;
  3695. void main() {
  3696. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3697. if ( coord.x >= 1.0 ) {
  3698. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3699. } else {
  3700. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3701. }
  3702. }`;class px{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const i=new he,s=t.properties.get(i);s.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new en({vertexShader:dx,fragmentShader:fx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new ge(new cs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}}class mx extends Sn{constructor(t,e){super();const n=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,m=null;const _=new px,g=e.getContextAttributes();let p=null,v=null;const x=[],y=[],P=new Y;let w=null;const T=new be;T.layers.enable(1),T.viewport=new ee;const R=new be;R.layers.enable(2),R.viewport=new ee;const b=[T,R],M=new Su;M.layers.enable(1),M.layers.enable(2);let I=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let it=x[W];return it===void 0&&(it=new yl,x[W]=it),it.getTargetRaySpace()},this.getControllerGrip=function(W){let it=x[W];return it===void 0&&(it=new yl,x[W]=it),it.getGripSpace()},this.getHand=function(W){let it=x[W];return it===void 0&&(it=new yl,x[W]=it),it.getHandSpace()};function O(W){const it=y.indexOf(W.inputSource);if(it===-1)return;const yt=x[it];yt!==void 0&&(yt.update(W.inputSource,W.frame,c||a),yt.dispatchEvent({type:W.type,data:W.inputSource}))}function V(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",q);for(let W=0;W<x.length;W++){const it=y[W];it!==null&&(y[W]=null,x[W].disconnect(it))}I=null,k=null,_.reset(),t.setRenderTarget(p),f=null,d=null,u=null,i=null,v=null,Jt.stop(),n.isPresenting=!1,t.setPixelRatio(w),t.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(W){s=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(W){o=W,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(W){c=W},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(W){if(i=W,i!==null){if(p=t.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",V),i.addEventListener("inputsourceschange",q),g.xrCompatible!==!0&&await e.makeXRCompatible(),w=t.getPixelRatio(),t.getSize(P),i.renderState.layers===void 0){const it={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,e,it),i.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),v=new Ke(f.framebufferWidth,f.framebufferHeight,{format:Fe,type:vn,colorSpace:t.outputColorSpace,stencilBuffer:g.stencil})}else{let it=null,yt=null,lt=null;g.depth&&(lt=g.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,it=g.stencil?ni:ei,yt=g.stencil?ti:jn);const Ft={colorFormat:e.RGBA8,depthFormat:lt,scaleFactor:s};u=new XRWebGLBinding(i,e),d=u.createProjectionLayer(Ft),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),v=new Ke(d.textureWidth,d.textureHeight,{format:Fe,type:vn,depthTexture:new ml(d.textureWidth,d.textureHeight,yt,void 0,void 0,void 0,void 0,void 0,void 0,it),stencilBuffer:g.stencil,colorSpace:t.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),Jt.setContext(i),Jt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function q(W){for(let it=0;it<W.removed.length;it++){const yt=W.removed[it],lt=y.indexOf(yt);lt>=0&&(y[lt]=null,x[lt].disconnect(yt))}for(let it=0;it<W.added.length;it++){const yt=W.added[it];let lt=y.indexOf(yt);if(lt===-1){for(let zt=0;zt<x.length;zt++)if(zt>=y.length){y.push(yt),lt=zt;break}else if(y[zt]===null){y[zt]=yt,lt=zt;break}if(lt===-1)break}const Ft=x[lt];Ft&&Ft.connect(yt)}}const H=new E,nt=new E;function G(W,it,yt){H.setFromMatrixPosition(it.matrixWorld),nt.setFromMatrixPosition(yt.matrixWorld);const lt=H.distanceTo(nt),Ft=it.projectionMatrix.elements,zt=yt.projectionMatrix.elements,Dt=Ft[14]/(Ft[10]-1),L=Ft[14]/(Ft[10]+1),Z=(Ft[9]+1)/Ft[5],Q=(Ft[9]-1)/Ft[5],st=(Ft[8]-1)/Ft[0],tt=(zt[8]+1)/zt[0],et=Dt*st,gt=Dt*tt,dt=lt/(-st+tt),Nt=dt*-st;it.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Nt),W.translateZ(dt),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert();const C=Dt+dt,S=L+dt,z=et-Nt,K=gt+(lt-Nt),$=Z*L/S*C,j=Q*L/S*C;W.projectionMatrix.makePerspective(z,K,$,j,C,S),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}function mt(W,it){it===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(it.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(i===null)return;_.texture!==null&&(W.near=_.depthNear,W.far=_.depthFar),M.near=R.near=T.near=W.near,M.far=R.far=T.far=W.far,(I!==M.near||k!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),I=M.near,k=M.far,T.near=I,T.far=k,R.near=I,R.far=k,T.updateProjectionMatrix(),R.updateProjectionMatrix(),W.updateProjectionMatrix());const it=W.parent,yt=M.cameras;mt(M,it);for(let lt=0;lt<yt.length;lt++)mt(yt[lt],it);yt.length===2?G(M,T,R):M.projectionMatrix.copy(T.projectionMatrix),Mt(W,M,it)};function Mt(W,it,yt){yt===null?W.matrix.copy(it.matrixWorld):(W.matrix.copy(yt.matrixWorld),W.matrix.invert(),W.matrix.multiply(it.matrixWorld)),W.matrix.decompose(W.position,W.quaternion,W.scale),W.updateMatrixWorld(!0),W.projectionMatrix.copy(it.projectionMatrix),W.projectionMatrixInverse.copy(it.projectionMatrixInverse),W.isPerspectiveCamera&&(W.fov=Ii*2*Math.atan(1/W.projectionMatrix.elements[5]),W.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(W){l=W,d!==null&&(d.fixedFoveation=W),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=W)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(M)};let vt=null;function Gt(W,it){if(h=it.getViewerPose(c||a),m=it,h!==null){const yt=h.views;f!==null&&(t.setRenderTargetFramebuffer(v,f.framebuffer),t.setRenderTarget(v));let lt=!1;yt.length!==M.cameras.length&&(M.cameras.length=0,lt=!0);for(let zt=0;zt<yt.length;zt++){const Dt=yt[zt];let L=null;if(f!==null)L=f.getViewport(Dt);else{const Q=u.getViewSubImage(d,Dt);L=Q.viewport,zt===0&&(t.setRenderTargetTextures(v,Q.colorTexture,d.ignoreDepthValues?void 0:Q.depthStencilTexture),t.setRenderTarget(v))}let Z=b[zt];Z===void 0&&(Z=new be,Z.layers.enable(zt),Z.viewport=new ee,b[zt]=Z),Z.matrix.fromArray(Dt.transform.matrix),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.projectionMatrix.fromArray(Dt.projectionMatrix),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert(),Z.viewport.set(L.x,L.y,L.width,L.height),zt===0&&(M.matrix.copy(Z.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),lt===!0&&M.cameras.push(Z)}const Ft=i.enabledFeatures;if(Ft&&Ft.includes("depth-sensing")){const zt=u.getDepthInformation(yt[0]);zt&&zt.isValid&&zt.texture&&_.init(t,zt,i.renderState)}}for(let yt=0;yt<x.length;yt++){const lt=y[yt],Ft=x[yt];lt!==null&&Ft!==void 0&&Ft.update(lt,it,c||a)}vt&&vt(W,it),it.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:it}),m=null}const Jt=new Zh;Jt.setAnimationLoop(Gt),this.setAnimationLoop=function(W){vt=W},this.dispose=function(){}}}const mi=new Xe,gx=new Rt;function _x(r,t){function e(g,p){g.matrixAutoUpdate===!0&&g.updateMatrix(),p.value.copy(g.matrix)}function n(g,p){p.color.getRGB(g.fogColor.value,Hh(r)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function i(g,p,v,x,y){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(g,p):p.isMeshToonMaterial?(s(g,p),u(g,p)):p.isMeshPhongMaterial?(s(g,p),h(g,p)):p.isMeshStandardMaterial?(s(g,p),d(g,p),p.isMeshPhysicalMaterial&&f(g,p,y)):p.isMeshMatcapMaterial?(s(g,p),m(g,p)):p.isMeshDepthMaterial?s(g,p):p.isMeshDistanceMaterial?(s(g,p),_(g,p)):p.isMeshNormalMaterial?s(g,p):p.isLineBasicMaterial?(a(g,p),p.isLineDashedMaterial&&o(g,p)):p.isPointsMaterial?l(g,p,v,x):p.isSpriteMaterial?c(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.bumpMap&&(g.bumpMap.value=p.bumpMap,e(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===Pe&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,e(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===Pe&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,e(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,g.emissiveMapTransform)),p.specularMap&&(g.specularMap.value=p.specularMap,e(p.specularMap,g.specularMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);const v=t.get(p),x=v.envMap,y=v.envMapRotation;x&&(g.envMap.value=x,mi.copy(y),mi.x*=-1,mi.y*=-1,mi.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(mi.y*=-1,mi.z*=-1),g.envMapRotation.value.setFromMatrix4(gx.makeRotationFromEuler(mi)),g.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,g.aoMapTransform))}function a(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform))}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,v,x){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*v,g.scale.value=x*.5,p.map&&(g.map.value=p.map,e(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function u(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function d(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,v){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Pe&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function _(g,p){const v=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function xx(r,t,e,n){let i={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,x){const y=x.program;n.uniformBlockBinding(v,y)}function c(v,x){let y=i[v.id];y===void 0&&(m(v),y=h(v),i[v.id]=y,v.addEventListener("dispose",g));const P=x.program;n.updateUBOMapping(v,P);const w=t.render.frame;s[v.id]!==w&&(d(v),s[v.id]=w)}function h(v){const x=u();v.__bindingPointIndex=x;const y=r.createBuffer(),P=v.__size,w=v.usage;return r.bindBuffer(r.UNIFORM_BUFFER,y),r.bufferData(r.UNIFORM_BUFFER,P,w),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,x,y),y}function u(){for(let v=0;v<o;v++)if(a.indexOf(v)===-1)return a.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){const x=i[v.id],y=v.uniforms,P=v.__cache;r.bindBuffer(r.UNIFORM_BUFFER,x);for(let w=0,T=y.length;w<T;w++){const R=Array.isArray(y[w])?y[w]:[y[w]];for(let b=0,M=R.length;b<M;b++){const I=R[b];if(f(I,w,b,P)===!0){const k=I.__offset,O=Array.isArray(I.value)?I.value:[I.value];let V=0;for(let q=0;q<O.length;q++){const H=O[q],nt=_(H);typeof H=="number"||typeof H=="boolean"?(I.__data[0]=H,r.bufferSubData(r.UNIFORM_BUFFER,k+V,I.__data)):H.isMatrix3?(I.__data[0]=H.elements[0],I.__data[1]=H.elements[1],I.__data[2]=H.elements[2],I.__data[3]=0,I.__data[4]=H.elements[3],I.__data[5]=H.elements[4],I.__data[6]=H.elements[5],I.__data[7]=0,I.__data[8]=H.elements[6],I.__data[9]=H.elements[7],I.__data[10]=H.elements[8],I.__data[11]=0):(H.toArray(I.__data,V),V+=nt.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,k,I.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function f(v,x,y,P){const w=v.value,T=x+"_"+y;if(P[T]===void 0)return typeof w=="number"||typeof w=="boolean"?P[T]=w:P[T]=w.clone(),!0;{const R=P[T];if(typeof w=="number"||typeof w=="boolean"){if(R!==w)return P[T]=w,!0}else if(R.equals(w)===!1)return R.copy(w),!0}return!1}function m(v){const x=v.uniforms;let y=0;const P=16;for(let T=0,R=x.length;T<R;T++){const b=Array.isArray(x[T])?x[T]:[x[T]];for(let M=0,I=b.length;M<I;M++){const k=b[M],O=Array.isArray(k.value)?k.value:[k.value];for(let V=0,q=O.length;V<q;V++){const H=O[V],nt=_(H),G=y%P;G!==0&&P-G<nt.boundary&&(y+=P-G),k.__data=new Float32Array(nt.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=y,y+=nt.storage}}}const w=y%P;return w>0&&(y+=P-w),v.__size=y,v.__cache={},this}function _(v){const x={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){const x=v.target;x.removeEventListener("dispose",g);const y=a.indexOf(x.__bindingPointIndex);a.splice(y,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function p(){for(const v in i)r.deleteBuffer(i[v]);a=[],i={},s={}}return{bind:l,update:c,dispose:p}}class vx{constructor(t={}){const{canvas:e=Mh(),context:n=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=t;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=a;const f=new Uint32Array(4),m=new Int32Array(4);let _=null,g=null;const p=[],v=[];this.domElement=e,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=Je,this.toneMapping=_n,this.toneMappingExposure=1;const x=this;let y=!1,P=0,w=0,T=null,R=-1,b=null;const M=new ee,I=new ee;let k=null;const O=new pt(0);let V=0,q=e.width,H=e.height,nt=1,G=null,mt=null;const Mt=new ee(0,0,q,H),vt=new ee(0,0,q,H);let Gt=!1;const Jt=new Fs;let W=!1,it=!1;const yt=new Rt,lt=new E,Ft={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let zt=!1;function Dt(){return T===null?nt:1}let L=n;function Z(A,D){return e.getContext(A,D)}try{const A={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${hr}`),e.addEventListener("webglcontextlost",_t,!1),e.addEventListener("webglcontextrestored",X,!1),e.addEventListener("webglcontextcreationerror",J,!1),L===null){const D="webgl2";if(L=Z(D,A),L===null)throw Z(D)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let Q,st,tt,et,gt,dt,Nt,C,S,z,K,$,j,Et,ht,ut,kt,rt,At,Xt,Lt,ft,Wt,qt;function ue(){Q=new I_(L),Q.init(),ft=new Mu(L,Q),st=new w_(L,Q,t,ft),tt=new cx(L),et=new D_(L),gt=new K0,dt=new hx(L,Q,tt,gt,st,ft,et),Nt=new T_(x),C=new P_(x),S=new Vp(L),Wt=new b_(L,S),z=new L_(L,S,et,Wt),K=new F_(L,z,S,et),At=new N_(L,st,dt),ut=new E_(gt),$=new $0(x,Nt,C,Q,st,Wt,ut),j=new _x(x,gt),Et=new j0,ht=new rx(Q),rt=new S_(x,Nt,C,tt,K,d,l),kt=new lx(x,K,st),qt=new xx(L,et,st,tt),Xt=new A_(L,Q,et),Lt=new U_(L,Q,et),et.programs=$.programs,x.capabilities=st,x.extensions=Q,x.properties=gt,x.renderLists=Et,x.shadowMap=kt,x.state=tt,x.info=et}ue();const U=new mx(x,L);this.xr=U,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const A=Q.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=Q.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(A){A!==void 0&&(nt=A,this.setSize(q,H,!1))},this.getSize=function(A){return A.set(q,H)},this.setSize=function(A,D,F=!0){if(U.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}q=A,H=D,e.width=Math.floor(A*nt),e.height=Math.floor(D*nt),F===!0&&(e.style.width=A+"px",e.style.height=D+"px"),this.setViewport(0,0,A,D)},this.getDrawingBufferSize=function(A){return A.set(q*nt,H*nt).floor()},this.setDrawingBufferSize=function(A,D,F){q=A,H=D,nt=F,e.width=Math.floor(A*F),e.height=Math.floor(D*F),this.setViewport(0,0,A,D)},this.getCurrentViewport=function(A){return A.copy(M)},this.getViewport=function(A){return A.copy(Mt)},this.setViewport=function(A,D,F,B){A.isVector4?Mt.set(A.x,A.y,A.z,A.w):Mt.set(A,D,F,B),tt.viewport(M.copy(Mt).multiplyScalar(nt).round())},this.getScissor=function(A){return A.copy(vt)},this.setScissor=function(A,D,F,B){A.isVector4?vt.set(A.x,A.y,A.z,A.w):vt.set(A,D,F,B),tt.scissor(I.copy(vt).multiplyScalar(nt).round())},this.getScissorTest=function(){return Gt},this.setScissorTest=function(A){tt.setScissorTest(Gt=A)},this.setOpaqueSort=function(A){G=A},this.setTransparentSort=function(A){mt=A},this.getClearColor=function(A){return A.copy(rt.getClearColor())},this.setClearColor=function(){rt.setClearColor.apply(rt,arguments)},this.getClearAlpha=function(){return rt.getClearAlpha()},this.setClearAlpha=function(){rt.setClearAlpha.apply(rt,arguments)},this.clear=function(A=!0,D=!0,F=!0){let B=0;if(A){let N=!1;if(T!==null){const at=T.texture.format;N=at===oo||at===ao||at===ro}if(N){const at=T.texture.type,xt=at===vn||at===jn||at===xs||at===ti||at===no||at===io,St=rt.getClearColor(),wt=rt.getClearAlpha(),Pt=St.r,It=St.g,Ct=St.b;xt?(f[0]=Pt,f[1]=It,f[2]=Ct,f[3]=wt,L.clearBufferuiv(L.COLOR,0,f)):(m[0]=Pt,m[1]=It,m[2]=Ct,m[3]=wt,L.clearBufferiv(L.COLOR,0,m))}else B|=L.COLOR_BUFFER_BIT}D&&(B|=L.DEPTH_BUFFER_BIT),F&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(B)},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(){e.removeEventListener("webglcontextlost",_t,!1),e.removeEventListener("webglcontextrestored",X,!1),e.removeEventListener("webglcontextcreationerror",J,!1),Et.dispose(),ht.dispose(),gt.dispose(),Nt.dispose(),C.dispose(),K.dispose(),Wt.dispose(),qt.dispose(),$.dispose(),U.dispose(),U.removeEventListener("sessionstart",an),U.removeEventListener("sessionend",on),$n.stop()};function _t(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),y=!0}function X(){console.log("THREE.WebGLRenderer: Context Restored."),y=!1;const A=et.autoReset,D=kt.enabled,F=kt.autoUpdate,B=kt.needsUpdate,N=kt.type;ue(),et.autoReset=A,kt.enabled=D,kt.autoUpdate=F,kt.needsUpdate=B,kt.type=N}function J(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function ot(A){const D=A.target;D.removeEventListener("dispose",ot),Ut(D)}function Ut(A){$t(A),gt.remove(A)}function $t(A){const D=gt.get(A).programs;D!==void 0&&(D.forEach(function(F){$.releaseProgram(F)}),A.isShaderMaterial&&$.releaseShaderCache(A))}this.renderBufferDirect=function(A,D,F,B,N,at){D===null&&(D=Ft);const xt=N.isMesh&&N.matrixWorld.determinant()<0,St=hf(A,D,F,B,N);tt.setMaterial(B,xt);let wt=F.index,Pt=1;if(B.wireframe===!0){if(wt=z.getWireframeAttribute(F),wt===void 0)return;Pt=2}const It=F.drawRange,Ct=F.attributes.position;let Qt=It.start*Pt,ae=(It.start+It.count)*Pt;at!==null&&(Qt=Math.max(Qt,at.start*Pt),ae=Math.min(ae,(at.start+at.count)*Pt)),wt!==null?(Qt=Math.max(Qt,0),ae=Math.min(ae,wt.count)):Ct!=null&&(Qt=Math.max(Qt,0),ae=Math.min(ae,Ct.count));const oe=ae-Qt;if(oe<0||oe===1/0)return;Wt.setup(N,B,St,F,wt);let ke,jt=Xt;if(wt!==null&&(ke=S.get(wt),jt=Lt,jt.setIndex(ke)),N.isMesh)B.wireframe===!0?(tt.setLineWidth(B.wireframeLinewidth*Dt()),jt.setMode(L.LINES)):jt.setMode(L.TRIANGLES);else if(N.isLine){let Tt=B.linewidth;Tt===void 0&&(Tt=1),tt.setLineWidth(Tt*Dt()),N.isLineSegments?jt.setMode(L.LINES):N.isLineLoop?jt.setMode(L.LINE_LOOP):jt.setMode(L.LINE_STRIP)}else N.isPoints?jt.setMode(L.POINTS):N.isSprite&&jt.setMode(L.TRIANGLES);if(N.isBatchedMesh)N._multiDrawInstances!==null?jt.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances):jt.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else if(N.isInstancedMesh)jt.renderInstances(Qt,oe,N.count);else if(F.isInstancedBufferGeometry){const Tt=F._maxInstanceCount!==void 0?F._maxInstanceCount:1/0,Re=Math.min(F.instanceCount,Tt);jt.renderInstances(Qt,oe,Re)}else jt.render(Qt,oe)};function de(A,D,F){A.transparent===!0&&A.side===cn&&A.forceSinglePass===!1?(A.side=Pe,A.needsUpdate=!0,lr(A,D,F),A.side=mn,A.needsUpdate=!0,lr(A,D,F),A.side=cn):lr(A,D,F)}this.compile=function(A,D,F=null){F===null&&(F=A),g=ht.get(F),g.init(D),v.push(g),F.traverseVisible(function(N){N.isLight&&N.layers.test(D.layers)&&(g.pushLight(N),N.castShadow&&g.pushShadow(N))}),A!==F&&A.traverseVisible(function(N){N.isLight&&N.layers.test(D.layers)&&(g.pushLight(N),N.castShadow&&g.pushShadow(N))}),g.setupLights();const B=new Set;return A.traverse(function(N){const at=N.material;if(at)if(Array.isArray(at))for(let xt=0;xt<at.length;xt++){const St=at[xt];de(St,F,N),B.add(St)}else de(at,F,N),B.add(at)}),v.pop(),g=null,B},this.compileAsync=function(A,D,F=null){const B=this.compile(A,D,F);return new Promise(N=>{function at(){if(B.forEach(function(xt){gt.get(xt).currentProgram.isReady()&&B.delete(xt)}),B.size===0){N(A);return}setTimeout(at,10)}Q.get("KHR_parallel_shader_compile")!==null?at():setTimeout(at,10)})};let ve=null;function ne(A){ve&&ve(A)}function an(){$n.stop()}function on(){$n.start()}const $n=new Zh;$n.setAnimationLoop(ne),typeof self<"u"&&$n.setContext(self),this.setAnimationLoop=function(A){ve=A,U.setAnimationLoop(A),A===null?$n.stop():$n.start()},U.addEventListener("sessionstart",an),U.addEventListener("sessionend",on),this.render=function(A,D){if(D!==void 0&&D.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(y===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),D.parent===null&&D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),U.enabled===!0&&U.isPresenting===!0&&(U.cameraAutoUpdate===!0&&U.updateCamera(D),D=U.getCamera()),A.isScene===!0&&A.onBeforeRender(x,A,D,T),g=ht.get(A,v.length),g.init(D),v.push(g),yt.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),Jt.setFromProjectionMatrix(yt),it=this.localClippingEnabled,W=ut.init(this.clippingPlanes,it),_=Et.get(A,p.length),_.init(),p.push(_),U.enabled===!0&&U.isPresenting===!0){const at=x.xr.getDepthSensingMesh();at!==null&&Wa(at,D,-1/0,x.sortObjects)}Wa(A,D,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(G,mt),zt=U.enabled===!1||U.isPresenting===!1||U.hasDepthSensing()===!1,zt&&rt.addToRenderList(_,A),this.info.render.frame++,W===!0&&ut.beginShadows();const F=g.state.shadowsArray;kt.render(F,A,D),W===!0&&ut.endShadows(),this.info.autoReset===!0&&this.info.reset();const B=_.opaque,N=_.transmissive;if(g.setupLights(),D.isArrayCamera){const at=D.cameras;if(N.length>0)for(let xt=0,St=at.length;xt<St;xt++){const wt=at[xt];lc(B,N,A,wt)}zt&&rt.render(A);for(let xt=0,St=at.length;xt<St;xt++){const wt=at[xt];oc(_,A,wt,wt.viewport)}}else N.length>0&&lc(B,N,A,D),zt&&rt.render(A),oc(_,A,D);T!==null&&(dt.updateMultisampleRenderTarget(T),dt.updateRenderTargetMipmap(T)),A.isScene===!0&&A.onAfterRender(x,A,D),Wt.resetDefaultState(),R=-1,b=null,v.pop(),v.length>0?(g=v[v.length-1],W===!0&&ut.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,p.pop(),p.length>0?_=p[p.length-1]:_=null};function Wa(A,D,F,B){if(A.visible===!1)return;if(A.layers.test(D.layers)){if(A.isGroup)F=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(D);else if(A.isLight)g.pushLight(A),A.castShadow&&g.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||Jt.intersectsSprite(A)){B&&lt.setFromMatrixPosition(A.matrixWorld).applyMatrix4(yt);const xt=K.update(A),St=A.material;St.visible&&_.push(A,xt,St,F,lt.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||Jt.intersectsObject(A))){const xt=K.update(A),St=A.material;if(B&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),lt.copy(A.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),lt.copy(xt.boundingSphere.center)),lt.applyMatrix4(A.matrixWorld).applyMatrix4(yt)),Array.isArray(St)){const wt=xt.groups;for(let Pt=0,It=wt.length;Pt<It;Pt++){const Ct=wt[Pt],Qt=St[Ct.materialIndex];Qt&&Qt.visible&&_.push(A,xt,Qt,F,lt.z,Ct)}}else St.visible&&_.push(A,xt,St,F,lt.z,null)}}const at=A.children;for(let xt=0,St=at.length;xt<St;xt++)Wa(at[xt],D,F,B)}function oc(A,D,F,B){const N=A.opaque,at=A.transmissive,xt=A.transparent;g.setupLightsView(F),W===!0&&ut.setGlobalState(x.clippingPlanes,F),B&&tt.viewport(M.copy(B)),N.length>0&&or(N,D,F),at.length>0&&or(at,D,F),xt.length>0&&or(xt,D,F),tt.buffers.depth.setTest(!0),tt.buffers.depth.setMask(!0),tt.buffers.color.setMask(!0),tt.setPolygonOffset(!1)}function lc(A,D,F,B){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[B.id]===void 0&&(g.state.transmissionRenderTarget[B.id]=new Ke(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float")?vs:vn,minFilter:hn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Kt.workingColorSpace}));const at=g.state.transmissionRenderTarget[B.id],xt=B.viewport||M;at.setSize(xt.z,xt.w);const St=x.getRenderTarget();x.setRenderTarget(at),x.getClearColor(O),V=x.getClearAlpha(),V<1&&x.setClearColor(16777215,.5),zt?rt.render(F):x.clear();const wt=x.toneMapping;x.toneMapping=_n;const Pt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),g.setupLightsView(B),W===!0&&ut.setGlobalState(x.clippingPlanes,B),or(A,F,B),dt.updateMultisampleRenderTarget(at),dt.updateRenderTargetMipmap(at),Q.has("WEBGL_multisampled_render_to_texture")===!1){let It=!1;for(let Ct=0,Qt=D.length;Ct<Qt;Ct++){const ae=D[Ct],oe=ae.object,ke=ae.geometry,jt=ae.material,Tt=ae.group;if(jt.side===cn&&oe.layers.test(B.layers)){const Re=jt.side;jt.side=Pe,jt.needsUpdate=!0,cc(oe,F,B,ke,jt,Tt),jt.side=Re,jt.needsUpdate=!0,It=!0}}It===!0&&(dt.updateMultisampleRenderTarget(at),dt.updateRenderTargetMipmap(at))}x.setRenderTarget(St),x.setClearColor(O,V),Pt!==void 0&&(B.viewport=Pt),x.toneMapping=wt}function or(A,D,F){const B=D.isScene===!0?D.overrideMaterial:null;for(let N=0,at=A.length;N<at;N++){const xt=A[N],St=xt.object,wt=xt.geometry,Pt=B===null?xt.material:B,It=xt.group;St.layers.test(F.layers)&&cc(St,D,F,wt,Pt,It)}}function cc(A,D,F,B,N,at){A.onBeforeRender(x,D,F,B,N,at),A.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),N.onBeforeRender(x,D,F,B,A,at),N.transparent===!0&&N.side===cn&&N.forceSinglePass===!1?(N.side=Pe,N.needsUpdate=!0,x.renderBufferDirect(F,D,B,N,A,at),N.side=mn,N.needsUpdate=!0,x.renderBufferDirect(F,D,B,N,A,at),N.side=cn):x.renderBufferDirect(F,D,B,N,A,at),A.onAfterRender(x,D,F,B,N,at)}function lr(A,D,F){D.isScene!==!0&&(D=Ft);const B=gt.get(A),N=g.state.lights,at=g.state.shadowsArray,xt=N.state.version,St=$.getParameters(A,N.state,at,D,F),wt=$.getProgramCacheKey(St);let Pt=B.programs;B.environment=A.isMeshStandardMaterial?D.environment:null,B.fog=D.fog,B.envMap=(A.isMeshStandardMaterial?C:Nt).get(A.envMap||B.environment),B.envMapRotation=B.environment!==null&&A.envMap===null?D.environmentRotation:A.envMapRotation,Pt===void 0&&(A.addEventListener("dispose",ot),Pt=new Map,B.programs=Pt);let It=Pt.get(wt);if(It!==void 0){if(B.currentProgram===It&&B.lightsStateVersion===xt)return uc(A,St),It}else St.uniforms=$.getUniforms(A),A.onBuild(F,St,x),A.onBeforeCompile(St,x),It=$.acquireProgram(St,wt),Pt.set(wt,It),B.uniforms=St.uniforms;const Ct=B.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Ct.clippingPlanes=ut.uniform),uc(A,St),B.needsLights=df(A),B.lightsStateVersion=xt,B.needsLights&&(Ct.ambientLightColor.value=N.state.ambient,Ct.lightProbe.value=N.state.probe,Ct.directionalLights.value=N.state.directional,Ct.directionalLightShadows.value=N.state.directionalShadow,Ct.spotLights.value=N.state.spot,Ct.spotLightShadows.value=N.state.spotShadow,Ct.rectAreaLights.value=N.state.rectArea,Ct.ltc_1.value=N.state.rectAreaLTC1,Ct.ltc_2.value=N.state.rectAreaLTC2,Ct.pointLights.value=N.state.point,Ct.pointLightShadows.value=N.state.pointShadow,Ct.hemisphereLights.value=N.state.hemi,Ct.directionalShadowMap.value=N.state.directionalShadowMap,Ct.directionalShadowMatrix.value=N.state.directionalShadowMatrix,Ct.spotShadowMap.value=N.state.spotShadowMap,Ct.spotLightMatrix.value=N.state.spotLightMatrix,Ct.spotLightMap.value=N.state.spotLightMap,Ct.pointShadowMap.value=N.state.pointShadowMap,Ct.pointShadowMatrix.value=N.state.pointShadowMatrix),B.currentProgram=It,B.uniformsList=null,It}function hc(A){if(A.uniformsList===null){const D=A.currentProgram.getUniforms();A.uniformsList=Jr.seqWithValue(D.seq,A.uniforms)}return A.uniformsList}function uc(A,D){const F=gt.get(A);F.outputColorSpace=D.outputColorSpace,F.batching=D.batching,F.batchingColor=D.batchingColor,F.instancing=D.instancing,F.instancingColor=D.instancingColor,F.instancingMorph=D.instancingMorph,F.skinning=D.skinning,F.morphTargets=D.morphTargets,F.morphNormals=D.morphNormals,F.morphColors=D.morphColors,F.morphTargetsCount=D.morphTargetsCount,F.numClippingPlanes=D.numClippingPlanes,F.numIntersection=D.numClipIntersection,F.vertexAlphas=D.vertexAlphas,F.vertexTangents=D.vertexTangents,F.toneMapping=D.toneMapping}function hf(A,D,F,B,N){D.isScene!==!0&&(D=Ft),dt.resetTextureUnits();const at=D.fog,xt=B.isMeshStandardMaterial?D.environment:null,St=T===null?x.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:Mn,wt=(B.isMeshStandardMaterial?C:Nt).get(B.envMap||xt),Pt=B.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,It=!!F.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ct=!!F.morphAttributes.position,Qt=!!F.morphAttributes.normal,ae=!!F.morphAttributes.color;let oe=_n;B.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(oe=x.toneMapping);const ke=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,jt=ke!==void 0?ke.length:0,Tt=gt.get(B),Re=g.state.lights;if(W===!0&&(it===!0||A!==b)){const Ye=A===b&&B.id===R;ut.setState(B,A,Ye)}let ie=!1;B.version===Tt.__version?(Tt.needsLights&&Tt.lightsStateVersion!==Re.state.version||Tt.outputColorSpace!==St||N.isBatchedMesh&&Tt.batching===!1||!N.isBatchedMesh&&Tt.batching===!0||N.isBatchedMesh&&Tt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Tt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Tt.instancing===!1||!N.isInstancedMesh&&Tt.instancing===!0||N.isSkinnedMesh&&Tt.skinning===!1||!N.isSkinnedMesh&&Tt.skinning===!0||N.isInstancedMesh&&Tt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Tt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Tt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Tt.instancingMorph===!1&&N.morphTexture!==null||Tt.envMap!==wt||B.fog===!0&&Tt.fog!==at||Tt.numClippingPlanes!==void 0&&(Tt.numClippingPlanes!==ut.numPlanes||Tt.numIntersection!==ut.numIntersection)||Tt.vertexAlphas!==Pt||Tt.vertexTangents!==It||Tt.morphTargets!==Ct||Tt.morphNormals!==Qt||Tt.morphColors!==ae||Tt.toneMapping!==oe||Tt.morphTargetsCount!==jt)&&(ie=!0):(ie=!0,Tt.__version=B.version);let pn=Tt.currentProgram;ie===!0&&(pn=lr(B,D,N));let cr=!1,Kn=!1,Xa=!1;const ye=pn.getUniforms(),Un=Tt.uniforms;if(tt.useProgram(pn.program)&&(cr=!0,Kn=!0,Xa=!0),B.id!==R&&(R=B.id,Kn=!0),cr||b!==A){ye.setValue(L,"projectionMatrix",A.projectionMatrix),ye.setValue(L,"viewMatrix",A.matrixWorldInverse);const Ye=ye.map.cameraPosition;Ye!==void 0&&Ye.setValue(L,lt.setFromMatrixPosition(A.matrixWorld)),st.logarithmicDepthBuffer&&ye.setValue(L,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ye.setValue(L,"isOrthographic",A.isOrthographicCamera===!0),b!==A&&(b=A,Kn=!0,Xa=!0)}if(N.isSkinnedMesh){ye.setOptional(L,N,"bindMatrix"),ye.setOptional(L,N,"bindMatrixInverse");const Ye=N.skeleton;Ye&&(Ye.boneTexture===null&&Ye.computeBoneTexture(),ye.setValue(L,"boneTexture",Ye.boneTexture,dt))}N.isBatchedMesh&&(ye.setOptional(L,N,"batchingTexture"),ye.setValue(L,"batchingTexture",N._matricesTexture,dt),ye.setOptional(L,N,"batchingColorTexture"),N._colorsTexture!==null&&ye.setValue(L,"batchingColorTexture",N._colorsTexture,dt));const qa=F.morphAttributes;if((qa.position!==void 0||qa.normal!==void 0||qa.color!==void 0)&&At.update(N,F,pn),(Kn||Tt.receiveShadow!==N.receiveShadow)&&(Tt.receiveShadow=N.receiveShadow,ye.setValue(L,"receiveShadow",N.receiveShadow)),B.isMeshGouraudMaterial&&B.envMap!==null&&(Un.envMap.value=wt,Un.flipEnvMap.value=wt.isCubeTexture&&wt.isRenderTargetTexture===!1?-1:1),B.isMeshStandardMaterial&&B.envMap===null&&D.environment!==null&&(Un.envMapIntensity.value=D.environmentIntensity),Kn&&(ye.setValue(L,"toneMappingExposure",x.toneMappingExposure),Tt.needsLights&&uf(Un,Xa),at&&B.fog===!0&&j.refreshFogUniforms(Un,at),j.refreshMaterialUniforms(Un,B,nt,H,g.state.transmissionRenderTarget[A.id]),Jr.upload(L,hc(Tt),Un,dt)),B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Jr.upload(L,hc(Tt),Un,dt),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ye.setValue(L,"center",N.center),ye.setValue(L,"modelViewMatrix",N.modelViewMatrix),ye.setValue(L,"normalMatrix",N.normalMatrix),ye.setValue(L,"modelMatrix",N.matrixWorld),B.isShaderMaterial||B.isRawShaderMaterial){const Ye=B.uniformsGroups;for(let Ya=0,ff=Ye.length;Ya<ff;Ya++){const dc=Ye[Ya];qt.update(dc,pn),qt.bind(dc,pn)}}return pn}function uf(A,D){A.ambientLightColor.needsUpdate=D,A.lightProbe.needsUpdate=D,A.directionalLights.needsUpdate=D,A.directionalLightShadows.needsUpdate=D,A.pointLights.needsUpdate=D,A.pointLightShadows.needsUpdate=D,A.spotLights.needsUpdate=D,A.spotLightShadows.needsUpdate=D,A.rectAreaLights.needsUpdate=D,A.hemisphereLights.needsUpdate=D}function df(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(A,D,F){gt.get(A.texture).__webglTexture=D,gt.get(A.depthTexture).__webglTexture=F;const B=gt.get(A);B.__hasExternalTextures=!0,B.__autoAllocateDepthBuffer=F===void 0,B.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),B.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(A,D){const F=gt.get(A);F.__webglFramebuffer=D,F.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(A,D=0,F=0){T=A,P=D,w=F;let B=!0,N=null,at=!1,xt=!1;if(A){const wt=gt.get(A);wt.__useDefaultFramebuffer!==void 0?(tt.bindFramebuffer(L.FRAMEBUFFER,null),B=!1):wt.__webglFramebuffer===void 0?dt.setupRenderTarget(A):wt.__hasExternalTextures&&dt.rebindTextures(A,gt.get(A.texture).__webglTexture,gt.get(A.depthTexture).__webglTexture);const Pt=A.texture;(Pt.isData3DTexture||Pt.isDataArrayTexture||Pt.isCompressedArrayTexture)&&(xt=!0);const It=gt.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(It[D])?N=It[D][F]:N=It[D],at=!0):A.samples>0&&dt.useMultisampledRTT(A)===!1?N=gt.get(A).__webglMultisampledFramebuffer:Array.isArray(It)?N=It[F]:N=It,M.copy(A.viewport),I.copy(A.scissor),k=A.scissorTest}else M.copy(Mt).multiplyScalar(nt).floor(),I.copy(vt).multiplyScalar(nt).floor(),k=Gt;if(tt.bindFramebuffer(L.FRAMEBUFFER,N)&&B&&tt.drawBuffers(A,N),tt.viewport(M),tt.scissor(I),tt.setScissorTest(k),at){const wt=gt.get(A.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+D,wt.__webglTexture,F)}else if(xt){const wt=gt.get(A.texture),Pt=D||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,wt.__webglTexture,F||0,Pt)}R=-1},this.readRenderTargetPixels=function(A,D,F,B,N,at,xt){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=gt.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&xt!==void 0&&(St=St[xt]),St){tt.bindFramebuffer(L.FRAMEBUFFER,St);try{const wt=A.texture,Pt=wt.format,It=wt.type;if(!st.textureFormatReadable(Pt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!st.textureTypeReadable(It)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}D>=0&&D<=A.width-B&&F>=0&&F<=A.height-N&&L.readPixels(D,F,B,N,ft.convert(Pt),ft.convert(It),at)}finally{const wt=T!==null?gt.get(T).__webglFramebuffer:null;tt.bindFramebuffer(L.FRAMEBUFFER,wt)}}},this.readRenderTargetPixelsAsync=async function(A,D,F,B,N,at,xt){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=gt.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&xt!==void 0&&(St=St[xt]),St){tt.bindFramebuffer(L.FRAMEBUFFER,St);try{const wt=A.texture,Pt=wt.format,It=wt.type;if(!st.textureFormatReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!st.textureTypeReadable(It))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(D>=0&&D<=A.width-B&&F>=0&&F<=A.height-N){const Ct=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ct),L.bufferData(L.PIXEL_PACK_BUFFER,at.byteLength,L.STREAM_READ),L.readPixels(D,F,B,N,ft.convert(Pt),ft.convert(It),0),L.flush();const Qt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);await dp(L,Qt,4);try{L.bindBuffer(L.PIXEL_PACK_BUFFER,Ct),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,at)}finally{L.deleteBuffer(Ct),L.deleteSync(Qt)}return at}}finally{const wt=T!==null?gt.get(T).__webglFramebuffer:null;tt.bindFramebuffer(L.FRAMEBUFFER,wt)}}},this.copyFramebufferToTexture=function(A,D=null,F=0){A.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),D=arguments[0]||null,A=arguments[1]);const B=Math.pow(2,-F),N=Math.floor(A.image.width*B),at=Math.floor(A.image.height*B),xt=D!==null?D.x:0,St=D!==null?D.y:0;dt.setTexture2D(A,0),L.copyTexSubImage2D(L.TEXTURE_2D,F,0,0,xt,St,N,at),tt.unbindTexture()},this.copyTextureToTexture=function(A,D,F=null,B=null,N=0){A.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),B=arguments[0]||null,A=arguments[1],D=arguments[2],N=arguments[3]||0,F=null);let at,xt,St,wt,Pt,It;F!==null?(at=F.max.x-F.min.x,xt=F.max.y-F.min.y,St=F.min.x,wt=F.min.y):(at=A.image.width,xt=A.image.height,St=0,wt=0),B!==null?(Pt=B.x,It=B.y):(Pt=0,It=0);const Ct=ft.convert(D.format),Qt=ft.convert(D.type);dt.setTexture2D(D,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,D.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,D.unpackAlignment);const ae=L.getParameter(L.UNPACK_ROW_LENGTH),oe=L.getParameter(L.UNPACK_IMAGE_HEIGHT),ke=L.getParameter(L.UNPACK_SKIP_PIXELS),jt=L.getParameter(L.UNPACK_SKIP_ROWS),Tt=L.getParameter(L.UNPACK_SKIP_IMAGES),Re=A.isCompressedTexture?A.mipmaps[N]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Re.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Re.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,St),L.pixelStorei(L.UNPACK_SKIP_ROWS,wt),A.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,N,Pt,It,at,xt,Ct,Qt,Re.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,N,Pt,It,Re.width,Re.height,Ct,Re.data):L.texSubImage2D(L.TEXTURE_2D,N,Pt,It,Ct,Qt,Re),L.pixelStorei(L.UNPACK_ROW_LENGTH,ae),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,oe),L.pixelStorei(L.UNPACK_SKIP_PIXELS,ke),L.pixelStorei(L.UNPACK_SKIP_ROWS,jt),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Tt),N===0&&D.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),tt.unbindTexture()},this.copyTextureToTexture3D=function(A,D,F=null,B=null,N=0){A.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),F=arguments[0]||null,B=arguments[1]||null,A=arguments[2],D=arguments[3],N=arguments[4]||0);let at,xt,St,wt,Pt,It,Ct,Qt,ae;const oe=A.isCompressedTexture?A.mipmaps[N]:A.image;F!==null?(at=F.max.x-F.min.x,xt=F.max.y-F.min.y,St=F.max.z-F.min.z,wt=F.min.x,Pt=F.min.y,It=F.min.z):(at=oe.width,xt=oe.height,St=oe.depth,wt=0,Pt=0,It=0),B!==null?(Ct=B.x,Qt=B.y,ae=B.z):(Ct=0,Qt=0,ae=0);const ke=ft.convert(D.format),jt=ft.convert(D.type);let Tt;if(D.isData3DTexture)dt.setTexture3D(D,0),Tt=L.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)dt.setTexture2DArray(D,0),Tt=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,D.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,D.unpackAlignment);const Re=L.getParameter(L.UNPACK_ROW_LENGTH),ie=L.getParameter(L.UNPACK_IMAGE_HEIGHT),pn=L.getParameter(L.UNPACK_SKIP_PIXELS),cr=L.getParameter(L.UNPACK_SKIP_ROWS),Kn=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,oe.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,oe.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,wt),L.pixelStorei(L.UNPACK_SKIP_ROWS,Pt),L.pixelStorei(L.UNPACK_SKIP_IMAGES,It),A.isDataTexture||A.isData3DTexture?L.texSubImage3D(Tt,N,Ct,Qt,ae,at,xt,St,ke,jt,oe.data):D.isCompressedArrayTexture?L.compressedTexSubImage3D(Tt,N,Ct,Qt,ae,at,xt,St,ke,oe.data):L.texSubImage3D(Tt,N,Ct,Qt,ae,at,xt,St,ke,jt,oe),L.pixelStorei(L.UNPACK_ROW_LENGTH,Re),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ie),L.pixelStorei(L.UNPACK_SKIP_PIXELS,pn),L.pixelStorei(L.UNPACK_SKIP_ROWS,cr),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Kn),N===0&&D.generateMipmaps&&L.generateMipmap(Tt),tt.unbindTexture()},this.initRenderTarget=function(A){gt.get(A).__webglFramebuffer===void 0&&dt.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?dt.setTextureCube(A,0):A.isData3DTexture?dt.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?dt.setTexture2DArray(A,0):dt.setTexture2D(A,0),tt.unbindTexture()},this.resetState=function(){P=0,w=0,T=null,tt.reset(),Wt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return un}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Sr?"display-p3":"srgb",e.unpackColorSpace=Kt.workingColorSpace===Ss?"display-p3":"srgb"}}class Ca{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new pt(t),this.density=e}clone(){return new Ca(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Ra{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new pt(t),this.near=e,this.far=n}clone(){return new Ra(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class bu extends Zt{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 Xe,this.environmentIntensity=1,this.environmentRotation=new Xe,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class $r{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Es,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=He()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Vo("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=He()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=He()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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 De=new E;class Ci{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)De.fromBufferAttribute(this,e),De.applyMatrix4(t),this.setXYZ(e,De.x,De.y,De.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)De.fromBufferAttribute(this,e),De.applyNormalMatrix(t),this.setXYZ(e,De.x,De.y,De.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)De.fromBufferAttribute(this,e),De.transformDirection(t),this.setXYZ(e,De.x,De.y,De.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Ie(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Ot(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Ot(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Ot(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Ot(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Ot(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ie(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ie(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ie(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ie(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array),i=Ot(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ot(e,this.array),n=Ot(n,this.array),i=Ot(i,this.array),s=Ot(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return new te(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ci(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ml extends Te{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new pt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let es;const Bs=new E,ns=new E,is=new E,ss=new Y,zs=new Y,Au=new Rt,Kr=new E,ks=new E,Qr=new E,wu=new Y,Sl=new Y,Eu=new Y;class Tu extends Zt{constructor(t=new Ml){if(super(),this.isSprite=!0,this.type="Sprite",es===void 0){es=new Ht;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new $r(e,5);es.setIndex([0,1,2,0,2,3]),es.setAttribute("position",new Ci(n,3,0,!1)),es.setAttribute("uv",new Ci(n,2,3,!1))}this.geometry=es,this.material=t,this.center=new Y(.5,.5)}raycast(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),ns.setFromMatrixScale(this.matrixWorld),Au.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),is.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ns.multiplyScalar(-is.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const a=this.center;jr(Kr.set(-.5,-.5,0),is,a,ns,i,s),jr(ks.set(.5,-.5,0),is,a,ns,i,s),jr(Qr.set(.5,.5,0),is,a,ns,i,s),wu.set(0,0),Sl.set(1,0),Eu.set(1,1);let o=t.ray.intersectTriangle(Kr,ks,Qr,!1,Bs);if(o===null&&(jr(ks.set(-.5,.5,0),is,a,ns,i,s),Sl.set(0,1),o=t.ray.intersectTriangle(Kr,Qr,ks,!1,Bs),o===null))return;const l=t.ray.origin.distanceTo(Bs);l<t.near||l>t.far||e.push({distance:l,point:Bs.clone(),uv:qe.getInterpolation(Bs,Kr,ks,Qr,wu,Sl,Eu,new Y),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function jr(r,t,e,n,i,s){ss.subVectors(r,e).addScalar(.5).multiply(n),i!==void 0?(zs.x=s*ss.x-i*ss.y,zs.y=i*ss.x+s*ss.y):zs.copy(ss),r.copy(t),r.x+=zs.x,r.y+=zs.y,r.applyMatrix4(Au)}const ta=new E,Cu=new E;class Ru extends Zt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let n=0,i=e.length;n<i;n++){const s=e[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);const i=this.levels;let s;for(s=0;s<i.length&&!(e<i[s].distance);s++);return i.splice(s,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let s=e[n].distance;if(e[n].object.visible&&(s-=s*e[n].hysteresis),t<s)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){ta.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(ta);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){ta.setFromMatrixPosition(t.matrixWorld),Cu.setFromMatrixPosition(this.matrixWorld);const n=ta.distanceTo(Cu)/t.zoom;e[0].object.visible=!0;let i,s;for(i=1,s=e.length;i<s;i++){let a=e[i].distance;if(e[i].object.visible&&(a-=a*e[i].hysteresis),n>=a)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);this.autoUpdate===!1&&(e.object.autoUpdate=!1),e.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const a=n[i];e.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return e}}const Pu=new E,Iu=new ee,Lu=new ee,yx=new E,Uu=new Rt,ea=new E,bl=new we,Du=new Rt,Al=new Bi;class Nu extends ge{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ja,this.bindMatrix=new Rt,this.bindMatrixInverse=new Rt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new Le),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,ea),this.boundingBox.expandByPoint(ea)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new we),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,ea),this.boundingSphere.expandByPoint(ea)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),bl.copy(this.boundingSphere),bl.applyMatrix4(i),t.ray.intersectsSphere(bl)!==!1&&(Du.copy(i).invert(),Al.copy(t.ray).applyMatrix4(Du),!(this.boundingBox!==null&&Al.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,Al)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new ee,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===ja?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===$c?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;Iu.fromBufferAttribute(i.attributes.skinIndex,t),Lu.fromBufferAttribute(i.attributes.skinWeight,t),Pu.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const a=Lu.getComponent(s);if(a!==0){const o=Iu.getComponent(s);Uu.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),e.addScaledVector(yx.copy(Pu).applyMatrix4(Uu),a)}}return e.applyMatrix4(this.bindMatrixInverse)}}class wl extends Zt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Rn extends he{constructor(t=null,e=1,n=1,i,s,a,o,l,c=Me,h=Me,u,d){super(null,a,o,l,c,h,i,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Fu=new Rt,Mx=new Rt;class Pa{constructor(t=[],e=[]){this.uuid=He(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Rt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const n=new Rt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,a=t.length;s<a;s++){const o=t[s]?t[s].matrixWorld:Mx;Fu.multiplyMatrices(o,e[s]),Fu.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Pa(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new Rn(e,t,t,Fe,Ve);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const s=t.bones[n];let a=e[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new wl),this.bones.push(a),this.boneInverses.push(new Rt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,s=e.length;i<s;i++){const a=e[i];t.bones.push(a.uuid);const o=n[i];t.boneInverses.push(o.toArray())}return t}}class rs extends te{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const as=new Rt,Ou=new Rt,na=[],Bu=new Le,Sx=new Rt,Vs=new ge,Hs=new we;class zu extends ge{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new rs(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Sx)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new Le),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,as),Bu.copy(t.boundingBox).applyMatrix4(as),this.boundingBox.union(Bu)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new we),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,as),Hs.copy(t.boundingSphere).applyMatrix4(as),this.boundingSphere.union(Hs)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,s=n.length+1,a=t*s+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Vs.geometry=this.geometry,Vs.material=this.material,Vs.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Hs.copy(this.boundingSphere),Hs.applyMatrix4(n),t.ray.intersectsSphere(Hs)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,as),Ou.multiplyMatrices(n,as),Vs.matrixWorld=Ou,Vs.raycast(t,na);for(let a=0,o=na.length;a<o;a++){const l=na[a];l.instanceId=s,l.object=this,e.push(l)}na.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new rs(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Rn(new Float32Array(i*this.count),i,this.count,so,Ve));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=i*t;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function bx(r,t){return r.z-t.z}function Ax(r,t){return t.z-r.z}class wx{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e){const n=this.pool,i=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1});const s=n[this.index];i.push(s),this.index++,s.start=t.start,s.count=t.count,s.z=e}reset(){this.list.length=0,this.index=0}}const os="batchId",Xn=new Rt,El=new Rt,Ex=new Rt,Tx=new pt(1,1,1),ku=new Rt,Tl=new Fs,ia=new Le,gi=new we,Gs=new E,Vu=new E,Cx=new E,Cl=new wx,Ce=new ge,sa=[];function Rx(r,t,e=0){const n=t.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==t.array.constructor){const i=r.count;for(let s=0;s<i;s++)for(let a=0;a<n;a++)t.setComponent(s+e,a,r.getComponent(s,a))}else t.array.set(r.array,e*n);t.needsUpdate=!0}class Hu extends ge{get maxGeometryCount(){return this._maxGeometryCount}constructor(t,e,n=e*2,i){super(new Ht,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture(),this._colorsTexture=null}_initMatricesTexture(){let t=Math.sqrt(this._maxGeometryCount*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4),n=new Rn(e,t,t,Fe,Ve);this._matricesTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxGeometryCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),n=new Rn(e,t,t,Fe,Ve);n.colorSpace=Kt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){const e=this.geometry,n=this._maxVertexCount,i=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in t.attributes){const l=t.getAttribute(o),{array:c,itemSize:h,normalized:u}=l,d=new c.constructor(n*h),f=new te(d,h,u);e.setAttribute(o,f)}if(t.getIndex()!==null){const o=n>65536?new Uint32Array(s):new Uint16Array(s);e.setIndex(new te(o,1))}const a=i>65536?new Uint32Array(n):new Uint16Array(n);e.setAttribute(os,new te(a,1)),this._geometryInitialized=!0}}_validateGeometry(t){if(t.getAttribute(os))throw new Error(`BatchedMesh: Geometry cannot use attribute "${os}"`);const e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(n===os)continue;if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),s=e.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Le);const t=this._geometryCount,e=this.boundingBox,n=this._active;e.makeEmpty();for(let i=0;i<t;i++)n[i]!==!1&&(this.getMatrixAt(i,Xn),this.getBoundingBoxAt(i,ia).applyMatrix4(Xn),e.union(ia))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new we);const t=this._geometryCount,e=this.boundingSphere,n=this._active;e.makeEmpty();for(let i=0;i<t;i++)n[i]!==!1&&(this.getMatrixAt(i,Xn),this.getBoundingSphereAt(i,gi).applyMatrix4(Xn),e.union(gi))}addGeometry(t,e=-1,n=-1){if(this._initializeGeometry(t),this._validateGeometry(t),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),e===-1?i.vertexCount=t.getAttribute("position").count:i.vertexCount=e,s===null?i.vertexStart=0:i.vertexStart=s.vertexStart+s.vertexCount;const c=t.getIndex(),h=c!==null;if(h&&(n===-1?i.indexCount=c.count:i.indexCount=n,s===null?i.indexStart=0:i.indexStart=s.indexStart+s.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._visibility,d=this._active,f=this._matricesTexture,m=this._matricesTexture.image.data,_=this._colorsTexture;u.push(!0),d.push(!0);const g=this._geometryCount;this._geometryCount++,Ex.toArray(m,g*16),f.needsUpdate=!0,_!==null&&(Tx.toArray(_.image.data,g*4),_.needsUpdate=!0),a.push(i),o.push({start:h?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Le,sphereInitialized:!1,sphere:new we});const p=this.geometry.getAttribute(os);for(let v=0;v<i.vertexCount;v++)p.setX(i.vertexStart+v,g);return p.needsUpdate=!0,this.setGeometryAt(g,t),g}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=n.getIndex()!==null,s=n.getIndex(),a=e.getIndex(),o=this._reservedRanges[t];if(i&&a.count>o.indexCount||e.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const f in n.attributes){if(f===os)continue;const m=e.getAttribute(f),_=n.getAttribute(f);Rx(m,_,l);const g=m.itemSize;for(let p=m.count,v=c;p<v;p++){const x=l+p;for(let y=0;y<g;y++)_.setComponent(x,y,0)}_.needsUpdate=!0,_.addUpdateRange(l*g,c*g)}if(i){const f=o.indexStart;for(let m=0;m<a.count;m++)s.setX(f+m,l+a.getX(m));for(let m=a.count,_=o.indexCount;m<_;m++)s.setX(f+m,l);s.needsUpdate=!0,s.addUpdateRange(f,o.indexCount)}const h=this._bounds[t];e.boundingBox!==null?(h.box.copy(e.boundingBox),h.boxInitialized=!0):h.boxInitialized=!1,e.boundingSphere!==null?(h.sphere.copy(e.boundingSphere),h.sphereInitialized=!0):h.sphereInitialized=!1;const u=this._drawRanges[t],d=e.getAttribute("position");return u.count=i?a.count:d.count,this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._active;return t>=e.length||e[t]===!1?this:(e[t]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(t){return this._multiDrawInstances===null?null:this._multiDrawInstances[t]}setInstanceCountAt(t,e){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[t]=e,t}getBoundingBoxAt(t,e){if(this._active[t]===!1)return null;const i=this._bounds[t],s=i.box,a=this.geometry;if(i.boxInitialized===!1){s.makeEmpty();const o=a.index,l=a.attributes.position,c=this._drawRanges[t];for(let h=c.start,u=c.start+c.count;h<u;h++){let d=h;o&&(d=o.getX(d)),s.expandByPoint(Gs.fromBufferAttribute(l,d))}i.boxInitialized=!0}return e.copy(s),e}getBoundingSphereAt(t,e){if(this._active[t]===!1)return null;const i=this._bounds[t],s=i.sphere,a=this.geometry;if(i.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(t,ia),ia.getCenter(s.center);const o=a.index,l=a.attributes.position,c=this._drawRanges[t];let h=0;for(let u=c.start,d=c.start+c.count;u<d;u++){let f=u;o&&(f=o.getX(f)),Gs.fromBufferAttribute(l,f),h=Math.max(h,s.center.distanceToSquared(Gs))}s.radius=Math.sqrt(h),i.sphereInitialized=!0}return e.copy(s),e}setMatrixAt(t,e){const n=this._active,i=this._matricesTexture,s=this._matricesTexture.image.data,a=this._geometryCount;return t>=a||n[t]===!1?this:(e.toArray(s,t*16),i.needsUpdate=!0,this)}getMatrixAt(t,e){const n=this._active,i=this._matricesTexture.image.data,s=this._geometryCount;return t>=s||n[t]===!1?null:e.fromArray(i,t*16)}setColorAt(t,e){this._colorsTexture===null&&this._initColorsTexture();const n=this._active,i=this._colorsTexture,s=this._colorsTexture.image.data,a=this._geometryCount;return t>=a||n[t]===!1?this:(e.toArray(s,t*4),i.needsUpdate=!0,this)}getColorAt(t,e){const n=this._active,i=this._colorsTexture.image.data,s=this._geometryCount;return t>=s||n[t]===!1?null:e.fromArray(i,t*4)}setVisibleAt(t,e){const n=this._visibility,i=this._active,s=this._geometryCount;return t>=s||i[t]===!1||n[t]===e?this:(n[t]=e,this._visibilityChanged=!0,this)}getVisibleAt(t){const e=this._visibility,n=this._active,i=this._geometryCount;return t>=i||n[t]===!1?!1:e[t]}raycast(t,e){const n=this._visibility,i=this._active,s=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,l=this.geometry;Ce.material=this.material,Ce.geometry.index=l.index,Ce.geometry.attributes=l.attributes,Ce.geometry.boundingBox===null&&(Ce.geometry.boundingBox=new Le),Ce.geometry.boundingSphere===null&&(Ce.geometry.boundingSphere=new we);for(let c=0;c<a;c++){if(!n[c]||!i[c])continue;const h=s[c];Ce.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(c,Ce.matrixWorld).premultiply(o),this.getBoundingBoxAt(c,Ce.geometry.boundingBox),this.getBoundingSphereAt(c,Ce.geometry.boundingSphere),Ce.raycast(t,sa);for(let u=0,d=sa.length;u<d;u++){const f=sa[u];f.object=this,f.batchId=c,e.push(f)}sa.length=0}Ce.material=null,Ce.geometry.index=null,Ce.geometry.attributes={},Ce.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._drawRanges=t._drawRanges.map(e=>({...e})),this._reservedRanges=t._reservedRanges.map(e=>({...e})),this._visibility=t._visibility.slice(),this._active=t._active.slice(),this._bounds=t._bounds.map(e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()})),this._maxGeometryCount=t._maxGeometryCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,h=this._multiDrawStarts,u=this._multiDrawCounts,d=this._drawRanges,f=this.perObjectFrustumCulled;f&&(ku.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Tl.setFromProjectionMatrix(ku,t.coordinateSystem));let m=0;if(this.sortObjects){El.copy(this.matrixWorld).invert(),Gs.setFromMatrixPosition(n.matrixWorld).applyMatrix4(El),Vu.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(El);for(let p=0,v=c.length;p<v;p++)if(c[p]&&l[p]){this.getMatrixAt(p,Xn),this.getBoundingSphereAt(p,gi).applyMatrix4(Xn);let x=!1;if(f&&(x=!Tl.intersectsSphere(gi)),!x){const y=Cx.subVectors(gi.center,Gs).dot(Vu);Cl.push(d[p],y)}}const _=Cl.list,g=this.customSort;g===null?_.sort(s.transparent?Ax:bx):g.call(this,_,n);for(let p=0,v=_.length;p<v;p++){const x=_[p];h[m]=x.start*o,u[m]=x.count,m++}Cl.reset()}else for(let _=0,g=c.length;_<g;_++)if(c[_]&&l[_]){let p=!1;if(f&&(this.getMatrixAt(_,Xn),this.getBoundingSphereAt(_,gi).applyMatrix4(Xn),p=!Tl.intersectsSphere(gi)),!p){const v=d[_];h[m]=v.start*o,u[m]=v.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,s,a){this.onBeforeRender(t,null,i,s,a)}}class Ne extends Te{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new pt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const ra=new E,aa=new E,Gu=new Rt,Ws=new Bi,oa=new we,Rl=new E,Wu=new E;class qn extends Zt{constructor(t=new Ht,e=new Ne){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[0];for(let i=1,s=e.count;i<s;i++)ra.fromBufferAttribute(e,i-1),aa.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=ra.distanceTo(aa);t.setAttribute("lineDistance",new bt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,s=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),oa.copy(n.boundingSphere),oa.applyMatrix4(i),oa.radius+=s,t.ray.intersectsSphere(oa)===!1)return;Gu.copy(i).invert(),Ws.copy(t.ray).applyMatrix4(Gu);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),m=Math.min(h.count,a.start+a.count);for(let _=f,g=m-1;_<g;_+=c){const p=h.getX(_),v=h.getX(_+1),x=la(this,t,Ws,l,p,v);x&&e.push(x)}if(this.isLineLoop){const _=h.getX(m-1),g=h.getX(f),p=la(this,t,Ws,l,_,g);p&&e.push(p)}}else{const f=Math.max(0,a.start),m=Math.min(d.count,a.start+a.count);for(let _=f,g=m-1;_<g;_+=c){const p=la(this,t,Ws,l,_,_+1);p&&e.push(p)}if(this.isLineLoop){const _=la(this,t,Ws,l,m-1,f);_&&e.push(_)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function la(r,t,e,n,i,s){const a=r.geometry.attributes.position;if(ra.fromBufferAttribute(a,i),aa.fromBufferAttribute(a,s),e.distanceSqToSegment(ra,aa,Rl,Wu)>n)return;Rl.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(Rl);if(!(l<t.near||l>t.far))return{distance:l,point:Wu.clone().applyMatrix4(r.matrixWorld),index:i,face:null,faceIndex:null,object:r}}const Xu=new E,qu=new E;class dn extends qn{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,s=e.count;i<s;i+=2)Xu.fromBufferAttribute(e,i),qu.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Xu.distanceTo(qu);t.setAttribute("lineDistance",new bt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Yu extends qn{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Pl extends Te{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new pt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Zu=new Rt,Il=new Bi,ca=new we,ha=new E;class Ju extends Zt{constructor(t=new Ht,e=new Pl){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,s=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ca.copy(n.boundingSphere),ca.applyMatrix4(i),ca.radius+=s,t.ray.intersectsSphere(ca)===!1)return;Zu.copy(i).invert(),Il.copy(t.ray).applyMatrix4(Zu);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let m=d,_=f;m<_;m++){const g=c.getX(m);ha.fromBufferAttribute(u,g),$u(ha,g,l,i,t,e,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let m=d,_=f;m<_;m++)ha.fromBufferAttribute(u,m),$u(ha,m,l,i,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function $u(r,t,e,n,i,s,a){const o=Il.distanceSqToPoint(r);if(o<e){const l=new E;Il.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,object:a})}}class Px extends he{constructor(t,e,n,i,s,a,o,l,c){super(t,e,n,i,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:pe,this.magFilter=s!==void 0?s:pe,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Ix extends he{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Me,this.minFilter=Me,this.generateMipmaps=!1,this.needsUpdate=!0}}class ua extends he{constructor(t,e,n,i,s,a,o,l,c,h,u,d){super(null,a,o,l,c,h,i,s,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class Lx extends ua{constructor(t,e,n,i,s,a){super(t,e,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Ze,this.layerUpdates=new Set}addLayerUpdates(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ux extends ua{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,xn),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class Dx extends he{constructor(t,e,n,i,s,a,o,l,c){super(t,e,n,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class sn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),s=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const s=n.length;let a;e?a=e:a=t*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(s-1);const h=n[i],d=n[i+1]-h,f=(a-h)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=e||(a.isVector2?new Y:new E);return l.copy(o).sub(a).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new E,i=[],s=[],a=[],o=new E,l=new Rt;for(let f=0;f<=t;f++){const m=f/t;i[f]=this.getTangentAt(m,new E)}s[0]=new E,a[0]=new E;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(le(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(o,m))}a[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(le(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(o.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),a[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class da extends sn{constructor(t=0,e=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new Y){const n=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(a?s=0:s=i),this.aClockwise===!0&&!a&&(s===i?s=-i:s=s-i);const o=this.aStartAngle+t*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class Ku extends da{constructor(t,e,n,i,s,a){super(t,e,n,n,i,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Ll(){let r=0,t=0,e=0,n=0;function i(s,a,o,l){r=s,t=o,e=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){i(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,h,u){let d=(a-s)/c-(o-s)/(c+h)+(o-a)/h,f=(o-a)/h-(l-a)/(h+u)+(l-o)/u;d*=h,f*=h,i(a,o,d,f)},calc:function(s){const a=s*s,o=a*s;return r+t*s+e*a+n*o}}}const fa=new E,Ul=new Ll,Dl=new Ll,Nl=new Ll;class Qu extends sn{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new E){const n=e,i=this.points,s=i.length,a=(s-(this.closed?0:1))*t;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=i[(o-1)%s]:(fa.subVectors(i[0],i[1]).add(i[0]),c=fa);const u=i[o%s],d=i[(o+1)%s];if(this.closed||o+2<s?h=i[(o+2)%s]:(fa.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=fa),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(u),f),_=Math.pow(u.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(h),f);_<1e-4&&(_=1),m<1e-4&&(m=_),g<1e-4&&(g=_),Ul.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,m,_,g),Dl.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,m,_,g),Nl.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,m,_,g)}else this.curveType==="catmullrom"&&(Ul.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),Dl.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Nl.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Ul.calc(l),Dl.calc(l),Nl.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(new E().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function ju(r,t,e,n,i){const s=(n-t)*.5,a=(i-e)*.5,o=r*r,l=r*o;return(2*e-2*n+s+a)*l+(-3*e+3*n-2*s-a)*o+s*r+e}function Nx(r,t){const e=1-r;return e*e*t}function Fx(r,t){return 2*(1-r)*r*t}function Ox(r,t){return r*r*t}function Xs(r,t,e,n){return Nx(r,t)+Fx(r,e)+Ox(r,n)}function Bx(r,t){const e=1-r;return e*e*e*t}function zx(r,t){const e=1-r;return 3*e*e*r*t}function kx(r,t){return 3*(1-r)*r*r*t}function Vx(r,t){return r*r*r*t}function qs(r,t,e,n,i){return Bx(r,t)+zx(r,e)+kx(r,n)+Vx(r,i)}class Fl extends sn{constructor(t=new Y,e=new Y,n=new Y,i=new Y){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new Y){const n=e,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(qs(t,i.x,s.x,a.x,o.x),qs(t,i.y,s.y,a.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class td extends sn{constructor(t=new E,e=new E,n=new E,i=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new E){const n=e,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(qs(t,i.x,s.x,a.x,o.x),qs(t,i.y,s.y,a.y,o.y),qs(t,i.z,s.z,a.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Ol extends sn{constructor(t=new Y,e=new Y){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Y){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Y){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class ed extends sn{constructor(t=new E,e=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new E){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new E){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Bl extends sn{constructor(t=new Y,e=new Y,n=new Y){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new Y){const n=e,i=this.v0,s=this.v1,a=this.v2;return n.set(Xs(t,i.x,s.x,a.x),Xs(t,i.y,s.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class zl extends sn{constructor(t=new E,e=new E,n=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new E){const n=e,i=this.v0,s=this.v1,a=this.v2;return n.set(Xs(t,i.x,s.x,a.x),Xs(t,i.y,s.y,a.y),Xs(t,i.z,s.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class kl extends sn{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new Y){const n=e,i=this.points,s=(i.length-1)*t,a=Math.floor(s),o=s-a,l=i[a===0?a:a-1],c=i[a],h=i[a>i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(ju(o,l.x,c.x,h.x,u.x),ju(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const i=t.points[e];this.points.push(new Y().fromArray(i))}return this}}var pa=Object.freeze({__proto__:null,ArcCurve:Ku,CatmullRomCurve3:Qu,CubicBezierCurve:Fl,CubicBezierCurve3:td,EllipseCurve:da,LineCurve:Ol,LineCurve3:ed,QuadraticBezierCurve:Bl,QuadraticBezierCurve3:zl,SplineCurve:kl});class nd extends sn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new pa[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const a=i[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const a=s[i],o=a.isEllipseCurve?t*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,l=a.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const i=t.curves[e];this.curves.push(new pa[i.type]().fromJSON(i))}return this}}class Ys extends nd{constructor(t){super(),this.type="Path",this.currentPoint=new Y,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new Ol(this.currentPoint.clone(),new Y(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){const s=new Bl(this.currentPoint.clone(),new Y(t,e),new Y(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,s,a){const o=new Fl(this.currentPoint.clone(),new Y(t,e),new Y(n,i),new Y(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new kl(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+o,e+l,n,i,s,a),this}absarc(t,e,n,i,s,a){return this.absellipse(t,e,n,n,i,s,a),this}ellipse(t,e,n,i,s,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,i,s,a,o,l),this}absellipse(t,e,n,i,s,a,o,l){const c=new da(t,e,n,i,s,a,o,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class sr extends Ht{constructor(t=[new Y(0,-.5),new Y(.5,0),new Y(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=le(i,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/e,u=new E,d=new Y,f=new E,m=new E,_=new E;let g=0,p=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,p=t[v+1].y-t[v].y,f.x=p*1,f.y=-g,f.z=p*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(_.x,_.y,_.z);break;default:g=t[v+1].x-t[v].x,p=t[v+1].y-t[v].y,f.x=p*1,f.y=-g,f.z=p*0,m.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),l.push(f.x,f.y,f.z),_.copy(m)}for(let v=0;v<=e;v++){const x=n+v*h*i,y=Math.sin(x),P=Math.cos(x);for(let w=0;w<=t.length-1;w++){u.x=t[w].x*y,u.y=t[w].y,u.z=t[w].x*P,a.push(u.x,u.y,u.z),d.x=v/e,d.y=w/(t.length-1),o.push(d.x,d.y);const T=l[3*w+0]*y,R=l[3*w+1],b=l[3*w+0]*P;c.push(T,R,b)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){const y=x+v*t.length,P=y,w=y+t.length,T=y+t.length+1,R=y+1;s.push(P,w,R),s.push(T,R,w)}this.setIndex(s),this.setAttribute("position",new bt(a,3)),this.setAttribute("uv",new bt(o,2)),this.setAttribute("normal",new bt(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new sr(t.points,t.segments,t.phiStart,t.phiLength)}}class Ia extends sr{constructor(t=1,e=1,n=4,i=8){const s=new Ys;s.absarc(0,-e/2,t,Math.PI*1.5,0),s.absarc(0,e/2,t,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:n,radialSegments:i}}static fromJSON(t){return new Ia(t.radius,t.length,t.capSegments,t.radialSegments)}}class La extends Ht{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const s=[],a=[],o=[],l=[],c=new E,h=new Y;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*i;c.x=t*Math.cos(f),c.y=t*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new bt(a,3)),this.setAttribute("normal",new bt(o,3)),this.setAttribute("uv",new bt(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new La(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class hs extends Ht{constructor(t=1,e=1,n=1,i=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const h=[],u=[],d=[],f=[];let m=0;const _=[],g=n/2;let p=0;v(),a===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new bt(u,3)),this.setAttribute("normal",new bt(d,3)),this.setAttribute("uv",new bt(f,2));function v(){const y=new E,P=new E;let w=0;const T=(e-t)/n;for(let R=0;R<=s;R++){const b=[],M=R/s,I=M*(e-t)+t;for(let k=0;k<=i;k++){const O=k/i,V=O*l+o,q=Math.sin(V),H=Math.cos(V);P.x=I*q,P.y=-M*n+g,P.z=I*H,u.push(P.x,P.y,P.z),y.set(q,T,H).normalize(),d.push(y.x,y.y,y.z),f.push(O,1-M),b.push(m++)}_.push(b)}for(let R=0;R<i;R++)for(let b=0;b<s;b++){const M=_[b][R],I=_[b+1][R],k=_[b+1][R+1],O=_[b][R+1];h.push(M,I,O),h.push(I,k,O),w+=6}c.addGroup(p,w,0),p+=w}function x(y){const P=m,w=new Y,T=new E;let R=0;const b=y===!0?t:e,M=y===!0?1:-1;for(let k=1;k<=i;k++)u.push(0,g*M,0),d.push(0,M,0),f.push(.5,.5),m++;const I=m;for(let k=0;k<=i;k++){const V=k/i*l+o,q=Math.cos(V),H=Math.sin(V);T.x=b*H,T.y=g*M,T.z=b*q,u.push(T.x,T.y,T.z),d.push(0,M,0),w.x=q*.5+.5,w.y=H*.5*M+.5,f.push(w.x,w.y),m++}for(let k=0;k<i;k++){const O=P+k,V=I+k;y===!0?h.push(V,V+1,O):h.push(V+1,V,O),R+=3}c.addGroup(p,R,y===!0?1:2),p+=R}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new hs(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ua extends hs{constructor(t=1,e=1,n=32,i=1,s=!1,a=0,o=Math.PI*2){super(0,t,e,n,i,s,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(t){return new Ua(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Jn extends Ht{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const s=[],a=[];o(i),c(n),h(),this.setAttribute("position",new bt(s,3)),this.setAttribute("normal",new bt(s.slice(),3)),this.setAttribute("uv",new bt(a,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function o(v){const x=new E,y=new E,P=new E;for(let w=0;w<e.length;w+=3)f(e[w+0],x),f(e[w+1],y),f(e[w+2],P),l(x,y,P,v)}function l(v,x,y,P){const w=P+1,T=[];for(let R=0;R<=w;R++){T[R]=[];const b=v.clone().lerp(y,R/w),M=x.clone().lerp(y,R/w),I=w-R;for(let k=0;k<=I;k++)k===0&&R===w?T[R][k]=b:T[R][k]=b.clone().lerp(M,k/I)}for(let R=0;R<w;R++)for(let b=0;b<2*(w-R)-1;b++){const M=Math.floor(b/2);b%2===0?(d(T[R][M+1]),d(T[R+1][M]),d(T[R][M])):(d(T[R][M+1]),d(T[R+1][M+1]),d(T[R+1][M]))}}function c(v){const x=new E;for(let y=0;y<s.length;y+=3)x.x=s[y+0],x.y=s[y+1],x.z=s[y+2],x.normalize().multiplyScalar(v),s[y+0]=x.x,s[y+1]=x.y,s[y+2]=x.z}function h(){const v=new E;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];const y=g(v)/2/Math.PI+.5,P=p(v)/Math.PI+.5;a.push(y,1-P)}m(),u()}function u(){for(let v=0;v<a.length;v+=6){const x=a[v+0],y=a[v+2],P=a[v+4],w=Math.max(x,y,P),T=Math.min(x,y,P);w>.9&&T<.1&&(x<.2&&(a[v+0]+=1),y<.2&&(a[v+2]+=1),P<.2&&(a[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){const y=v*3;x.x=t[y+0],x.y=t[y+1],x.z=t[y+2]}function m(){const v=new E,x=new E,y=new E,P=new E,w=new Y,T=new Y,R=new Y;for(let b=0,M=0;b<s.length;b+=9,M+=6){v.set(s[b+0],s[b+1],s[b+2]),x.set(s[b+3],s[b+4],s[b+5]),y.set(s[b+6],s[b+7],s[b+8]),w.set(a[M+0],a[M+1]),T.set(a[M+2],a[M+3]),R.set(a[M+4],a[M+5]),P.copy(v).add(x).add(y).divideScalar(3);const I=g(P);_(w,M+0,v,I),_(T,M+2,x,I),_(R,M+4,y,I)}}function _(v,x,y,P){P<0&&v.x===1&&(a[x]=v.x-1),y.x===0&&y.z===0&&(a[x]=P/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function p(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jn(t.vertices,t.indices,t.radius,t.details)}}class Da extends Jn{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Da(t.radius,t.detail)}}const ma=new E,ga=new E,Vl=new E,_a=new qe;class id extends Ht{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){const i=Math.pow(10,4),s=Math.cos(ai*e),a=t.getIndex(),o=t.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],h=["a","b","c"],u=new Array(3),d={},f=[];for(let m=0;m<l;m+=3){a?(c[0]=a.getX(m),c[1]=a.getX(m+1),c[2]=a.getX(m+2)):(c[0]=m,c[1]=m+1,c[2]=m+2);const{a:_,b:g,c:p}=_a;if(_.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),p.fromBufferAttribute(o,c[2]),_a.getNormal(Vl),u[0]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,u[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,u[2]=`${Math.round(p.x*i)},${Math.round(p.y*i)},${Math.round(p.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let v=0;v<3;v++){const x=(v+1)%3,y=u[v],P=u[x],w=_a[h[v]],T=_a[h[x]],R=`${y}_${P}`,b=`${P}_${y}`;b in d&&d[b]?(Vl.dot(d[b].normal)<=s&&(f.push(w.x,w.y,w.z),f.push(T.x,T.y,T.z)),d[b]=null):R in d||(d[R]={index0:c[v],index1:c[x],normal:Vl.clone()})}}for(const m in d)if(d[m]){const{index0:_,index1:g}=d[m];ma.fromBufferAttribute(o,_),ga.fromBufferAttribute(o,g),f.push(ma.x,ma.y,ma.z),f.push(ga.x,ga.y,ga.z)}this.setAttribute("position",new bt(f,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class _i extends Ys{constructor(t){super(t),this.uuid=He(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const i=t.holes[e];this.holes.push(new Ys().fromJSON(i))}return this}}const Hx={triangulate:function(r,t,e=2){const n=t&&t.length,i=n?t[0]*e:r.length;let s=sd(r,0,i,e,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,h,u,d,f;if(n&&(s=Yx(r,t,s,e)),r.length>80*e){o=c=r[0],l=h=r[1];for(let m=e;m<i;m+=e)u=r[m],d=r[m+1],u<o&&(o=u),d<l&&(l=d),u>c&&(c=u),d>h&&(h=d);f=Math.max(c-o,h-l),f=f!==0?32767/f:0}return Zs(s,a,e,o,l,f,0),a}};function sd(r,t,e,n,i){let s,a;if(i===sv(r,t,e,n)>0)for(s=t;s<e;s+=n)a=od(s,r[s],r[s+1],a);else for(s=e-n;s>=t;s-=n)a=od(s,r[s],r[s+1],a);return a&&xa(a,a.next)&&($s(a),a=a.next),a}function xi(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(xa(e,e.next)||re(e.prev,e,e.next)===0)){if($s(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Zs(r,t,e,n,i,s,a){if(!r)return;!a&&s&&Qx(r,n,i,s);let o=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?Wx(r,n,i,s):Gx(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(c.i/e|0),$s(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=Xx(xi(r),t,e),Zs(r,t,e,n,i,s,2)):a===2&&qx(r,t,e,n,i,s):Zs(xi(r),t,e,n,i,s,1);break}}}function Gx(r){const t=r.prev,e=r,n=r.next;if(re(t,e,n)>=0)return!1;const i=t.x,s=e.x,a=n.x,o=t.y,l=e.y,c=n.y,h=i<s?i<a?i:a:s<a?s:a,u=o<l?o<c?o:c:l<c?l:c,d=i>s?i>a?i:a:s>a?s:a,f=o>l?o>c?o:c:l>c?l:c;let m=n.next;for(;m!==t;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=f&&ls(i,o,s,l,a,c,m.x,m.y)&&re(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Wx(r,t,e,n){const i=r.prev,s=r,a=r.next;if(re(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,h=i.y,u=s.y,d=a.y,f=o<l?o<c?o:c:l<c?l:c,m=h<u?h<d?h:d:u<d?u:d,_=o>l?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,p=Hl(f,m,t,e,n),v=Hl(_,g,t,e,n);let x=r.prevZ,y=r.nextZ;for(;x&&x.z>=p&&y&&y.z<=v;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==a&&ls(o,h,l,u,c,d,x.x,x.y)&&re(x.prev,x,x.next)>=0||(x=x.prevZ,y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==i&&y!==a&&ls(o,h,l,u,c,d,y.x,y.y)&&re(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;x&&x.z>=p;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==a&&ls(o,h,l,u,c,d,x.x,x.y)&&re(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=v;){if(y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==i&&y!==a&&ls(o,h,l,u,c,d,y.x,y.y)&&re(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Xx(r,t,e){let n=r;do{const i=n.prev,s=n.next.next;!xa(i,s)&&rd(i,n,n.next,s)&&Js(i,s)&&Js(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),$s(n),$s(n.next),n=r=s),n=n.next}while(n!==r);return xi(n)}function qx(r,t,e,n,i,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&ev(a,o)){let l=ad(a,o);a=xi(a,a.next),l=xi(l,l.next),Zs(a,t,e,n,i,s,0),Zs(l,t,e,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function Yx(r,t,e,n){const i=[];let s,a,o,l,c;for(s=0,a=t.length;s<a;s++)o=t[s]*n,l=s<a-1?t[s+1]*n:r.length,c=sd(r,o,l,n,!1),c===c.next&&(c.steiner=!0),i.push(tv(c));for(i.sort(Zx),s=0;s<i.length;s++)e=Jx(i[s],e);return e}function Zx(r,t){return r.x-t.x}function Jx(r,t){const e=$x(r,t);if(!e)return t;const n=ad(e,r);return xi(n,n.next),xi(e,e.next)}function $x(r,t){let e=t,n=-1/0,i;const s=r.x,a=r.y;do{if(a<=e.y&&a>=e.next.y&&e.next.y!==e.y){const d=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>n&&(n=d,i=e.x<e.next.x?e:e.next,d===s))return i}e=e.next}while(e!==t);if(!i)return null;const o=i,l=i.x,c=i.y;let h=1/0,u;e=i;do s>=e.x&&e.x>=l&&s!==e.x&&ls(a<c?s:n,a,l,c,a<c?n:s,a,e.x,e.y)&&(u=Math.abs(a-e.y)/(s-e.x),Js(e,r)&&(u<h||u===h&&(e.x>i.x||e.x===i.x&&Kx(i,e)))&&(i=e,h=u)),e=e.next;while(e!==o);return i}function Kx(r,t){return re(r.prev,r,t.prev)<0&&re(t.next,r,r.next)<0}function Qx(r,t,e,n){let i=r;do i.z===0&&(i.z=Hl(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,jx(i)}function jx(r){let t,e,n,i,s,a,o,l,c=1;do{for(e=r,r=null,s=null,a=0;e;){for(a++,n=e,o=0,t=0;t<c&&(o++,n=n.nextZ,!!n);t++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;e=n}s.nextZ=null,c*=2}while(a>1);return r}function Hl(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function tv(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function ls(r,t,e,n,i,s,a,o){return(i-a)*(t-o)>=(r-a)*(s-o)&&(r-a)*(n-o)>=(e-a)*(t-o)&&(e-a)*(s-o)>=(i-a)*(n-o)}function ev(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!nv(r,t)&&(Js(r,t)&&Js(t,r)&&iv(r,t)&&(re(r.prev,r,t.prev)||re(r,t.prev,t))||xa(r,t)&&re(r.prev,r,r.next)>0&&re(t.prev,t,t.next)>0)}function re(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function xa(r,t){return r.x===t.x&&r.y===t.y}function rd(r,t,e,n){const i=ya(re(r,t,e)),s=ya(re(r,t,n)),a=ya(re(e,n,r)),o=ya(re(e,n,t));return!!(i!==s&&a!==o||i===0&&va(r,e,t)||s===0&&va(r,n,t)||a===0&&va(e,r,n)||o===0&&va(e,t,n))}function va(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ya(r){return r>0?1:r<0?-1:0}function nv(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&rd(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Js(r,t){return re(r.prev,r,r.next)<0?re(r,t,r.next)>=0&&re(r,r.prev,t)>=0:re(r,t,r.prev)<0||re(r,r.next,t)<0}function iv(r,t){let e=r,n=!1;const i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function ad(r,t){const e=new Gl(r.i,r.x,r.y),n=new Gl(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function od(r,t,e,n){const i=new Gl(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function $s(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Gl(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sv(r,t,e,n){let i=0;for(let s=t,a=e-n;s<e;s+=n)i+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return i}class fn{static area(t){const e=t.length;let n=0;for(let i=e-1,s=0;s<e;i=s++)n+=t[i].x*t[s].y-t[s].x*t[i].y;return n*.5}static isClockWise(t){return fn.area(t)<0}static triangulateShape(t,e){const n=[],i=[],s=[];ld(t),cd(n,t);let a=t.length;e.forEach(ld);for(let l=0;l<e.length;l++)i.push(a),a+=e[l].length,cd(n,e[l]);const o=Hx.triangulate(n,i);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function ld(r){const t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function cd(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}class Na extends Ht{constructor(t=new _i([new Y(.5,.5),new Y(-.5,.5),new Y(-.5,-.5),new Y(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,i=[],s=[];for(let o=0,l=t.length;o<l;o++){const c=t[o];a(c)}this.setAttribute("position",new bt(i,3)),this.setAttribute("uv",new bt(s,2)),this.computeVertexNormals();function a(o){const l=[],c=e.curveSegments!==void 0?e.curveSegments:12,h=e.steps!==void 0?e.steps:1,u=e.depth!==void 0?e.depth:1;let d=e.bevelEnabled!==void 0?e.bevelEnabled:!0,f=e.bevelThickness!==void 0?e.bevelThickness:.2,m=e.bevelSize!==void 0?e.bevelSize:f-.1,_=e.bevelOffset!==void 0?e.bevelOffset:0,g=e.bevelSegments!==void 0?e.bevelSegments:3;const p=e.extrudePath,v=e.UVGenerator!==void 0?e.UVGenerator:rv;let x,y=!1,P,w,T,R;p&&(x=p.getSpacedPoints(h),y=!0,d=!1,P=p.computeFrenetFrames(h,!1),w=new E,T=new E,R=new E),d||(g=0,f=0,m=0,_=0);const b=o.extractPoints(c);let M=b.shape;const I=b.holes;if(!fn.isClockWise(M)){M=M.reverse();for(let Z=0,Q=I.length;Z<Q;Z++){const st=I[Z];fn.isClockWise(st)&&(I[Z]=st.reverse())}}const O=fn.triangulateShape(M,I),V=M;for(let Z=0,Q=I.length;Z<Q;Z++){const st=I[Z];M=M.concat(st)}function q(Z,Q,st){return Q||console.error("THREE.ExtrudeGeometry: vec does not exist"),Z.clone().addScaledVector(Q,st)}const H=M.length,nt=O.length;function G(Z,Q,st){let tt,et,gt;const dt=Z.x-Q.x,Nt=Z.y-Q.y,C=st.x-Z.x,S=st.y-Z.y,z=dt*dt+Nt*Nt,K=dt*S-Nt*C;if(Math.abs(K)>Number.EPSILON){const $=Math.sqrt(z),j=Math.sqrt(C*C+S*S),Et=Q.x-Nt/$,ht=Q.y+dt/$,ut=st.x-S/j,kt=st.y+C/j,rt=((ut-Et)*S-(kt-ht)*C)/(dt*S-Nt*C);tt=Et+dt*rt-Z.x,et=ht+Nt*rt-Z.y;const At=tt*tt+et*et;if(At<=2)return new Y(tt,et);gt=Math.sqrt(At/2)}else{let $=!1;dt>Number.EPSILON?C>Number.EPSILON&&($=!0):dt<-Number.EPSILON?C<-Number.EPSILON&&($=!0):Math.sign(Nt)===Math.sign(S)&&($=!0),$?(tt=-Nt,et=dt,gt=Math.sqrt(z)):(tt=dt,et=Nt,gt=Math.sqrt(z/2))}return new Y(tt/gt,et/gt)}const mt=[];for(let Z=0,Q=V.length,st=Q-1,tt=Z+1;Z<Q;Z++,st++,tt++)st===Q&&(st=0),tt===Q&&(tt=0),mt[Z]=G(V[Z],V[st],V[tt]);const Mt=[];let vt,Gt=mt.concat();for(let Z=0,Q=I.length;Z<Q;Z++){const st=I[Z];vt=[];for(let tt=0,et=st.length,gt=et-1,dt=tt+1;tt<et;tt++,gt++,dt++)gt===et&&(gt=0),dt===et&&(dt=0),vt[tt]=G(st[tt],st[gt],st[dt]);Mt.push(vt),Gt=Gt.concat(vt)}for(let Z=0;Z<g;Z++){const Q=Z/g,st=f*Math.cos(Q*Math.PI/2),tt=m*Math.sin(Q*Math.PI/2)+_;for(let et=0,gt=V.length;et<gt;et++){const dt=q(V[et],mt[et],tt);lt(dt.x,dt.y,-st)}for(let et=0,gt=I.length;et<gt;et++){const dt=I[et];vt=Mt[et];for(let Nt=0,C=dt.length;Nt<C;Nt++){const S=q(dt[Nt],vt[Nt],tt);lt(S.x,S.y,-st)}}}const Jt=m+_;for(let Z=0;Z<H;Z++){const Q=d?q(M[Z],Gt[Z],Jt):M[Z];y?(T.copy(P.normals[0]).multiplyScalar(Q.x),w.copy(P.binormals[0]).multiplyScalar(Q.y),R.copy(x[0]).add(T).add(w),lt(R.x,R.y,R.z)):lt(Q.x,Q.y,0)}for(let Z=1;Z<=h;Z++)for(let Q=0;Q<H;Q++){const st=d?q(M[Q],Gt[Q],Jt):M[Q];y?(T.copy(P.normals[Z]).multiplyScalar(st.x),w.copy(P.binormals[Z]).multiplyScalar(st.y),R.copy(x[Z]).add(T).add(w),lt(R.x,R.y,R.z)):lt(st.x,st.y,u/h*Z)}for(let Z=g-1;Z>=0;Z--){const Q=Z/g,st=f*Math.cos(Q*Math.PI/2),tt=m*Math.sin(Q*Math.PI/2)+_;for(let et=0,gt=V.length;et<gt;et++){const dt=q(V[et],mt[et],tt);lt(dt.x,dt.y,u+st)}for(let et=0,gt=I.length;et<gt;et++){const dt=I[et];vt=Mt[et];for(let Nt=0,C=dt.length;Nt<C;Nt++){const S=q(dt[Nt],vt[Nt],tt);y?lt(S.x,S.y+x[h-1].y,x[h-1].x+st):lt(S.x,S.y,u+st)}}}W(),it();function W(){const Z=i.length/3;if(d){let Q=0,st=H*Q;for(let tt=0;tt<nt;tt++){const et=O[tt];Ft(et[2]+st,et[1]+st,et[0]+st)}Q=h+g*2,st=H*Q;for(let tt=0;tt<nt;tt++){const et=O[tt];Ft(et[0]+st,et[1]+st,et[2]+st)}}else{for(let Q=0;Q<nt;Q++){const st=O[Q];Ft(st[2],st[1],st[0])}for(let Q=0;Q<nt;Q++){const st=O[Q];Ft(st[0]+H*h,st[1]+H*h,st[2]+H*h)}}n.addGroup(Z,i.length/3-Z,0)}function it(){const Z=i.length/3;let Q=0;yt(V,Q),Q+=V.length;for(let st=0,tt=I.length;st<tt;st++){const et=I[st];yt(et,Q),Q+=et.length}n.addGroup(Z,i.length/3-Z,1)}function yt(Z,Q){let st=Z.length;for(;--st>=0;){const tt=st;let et=st-1;et<0&&(et=Z.length-1);for(let gt=0,dt=h+g*2;gt<dt;gt++){const Nt=H*gt,C=H*(gt+1),S=Q+tt+Nt,z=Q+et+Nt,K=Q+et+C,$=Q+tt+C;zt(S,z,K,$)}}}function lt(Z,Q,st){l.push(Z),l.push(Q),l.push(st)}function Ft(Z,Q,st){Dt(Z),Dt(Q),Dt(st);const tt=i.length/3,et=v.generateTopUV(n,i,tt-3,tt-2,tt-1);L(et[0]),L(et[1]),L(et[2])}function zt(Z,Q,st,tt){Dt(Z),Dt(Q),Dt(tt),Dt(Q),Dt(st),Dt(tt);const et=i.length/3,gt=v.generateSideWallUV(n,i,et-6,et-3,et-2,et-1);L(gt[0]),L(gt[1]),L(gt[3]),L(gt[1]),L(gt[2]),L(gt[3])}function Dt(Z){i.push(l[Z*3+0]),i.push(l[Z*3+1]),i.push(l[Z*3+2])}function L(Z){s.push(Z.x),s.push(Z.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return av(e,n,t)}static fromJSON(t,e){const n=[];for(let s=0,a=t.shapes.length;s<a;s++){const o=e[t.shapes[s]];n.push(o)}const i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new pa[i.type]().fromJSON(i)),new Na(n,t.options)}}const rv={generateTopUV:function(r,t,e,n,i){const s=t[e*3],a=t[e*3+1],o=t[n*3],l=t[n*3+1],c=t[i*3],h=t[i*3+1];return[new Y(s,a),new Y(o,l),new Y(c,h)]},generateSideWallUV:function(r,t,e,n,i,s){const a=t[e*3],o=t[e*3+1],l=t[e*3+2],c=t[n*3],h=t[n*3+1],u=t[n*3+2],d=t[i*3],f=t[i*3+1],m=t[i*3+2],_=t[s*3],g=t[s*3+1],p=t[s*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new Y(a,1-l),new Y(c,1-u),new Y(d,1-m),new Y(_,1-p)]:[new Y(o,1-l),new Y(h,1-u),new Y(f,1-m),new Y(g,1-p)]}};function av(r,t,e){if(e.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];e.shapes.push(s.uuid)}else e.shapes.push(r.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class Fa extends Jn{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Fa(t.radius,t.detail)}}class rr extends Jn{constructor(t=1,e=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new rr(t.radius,t.detail)}}class Oa extends Ht{constructor(t=.5,e=1,n=32,i=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],l=[],c=[],h=[];let u=t;const d=(e-t)/i,f=new E,m=new Y;for(let _=0;_<=i;_++){for(let g=0;g<=n;g++){const p=s+g/n*a;f.x=u*Math.cos(p),f.y=u*Math.sin(p),l.push(f.x,f.y,f.z),c.push(0,0,1),m.x=(f.x/e+1)/2,m.y=(f.y/e+1)/2,h.push(m.x,m.y)}u+=d}for(let _=0;_<i;_++){const g=_*(n+1);for(let p=0;p<n;p++){const v=p+g,x=v,y=v+n+1,P=v+n+2,w=v+1;o.push(x,y,w),o.push(y,P,w)}}this.setIndex(o),this.setAttribute("position",new bt(l,3)),this.setAttribute("normal",new bt(c,3)),this.setAttribute("uv",new bt(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Oa(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class Ba extends Ht{constructor(t=new _i([new Y(0,.5),new Y(-.5,-.5),new Y(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],i=[],s=[],a=[];let o=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(o,l,h),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new bt(i,3)),this.setAttribute("normal",new bt(s,3)),this.setAttribute("uv",new bt(a,2));function c(h){const u=i.length/3,d=h.extractPoints(e);let f=d.shape;const m=d.holes;fn.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,p=m.length;g<p;g++){const v=m[g];fn.isClockWise(v)===!0&&(m[g]=v.reverse())}const _=fn.triangulateShape(f,m);for(let g=0,p=m.length;g<p;g++){const v=m[g];f=f.concat(v)}for(let g=0,p=f.length;g<p;g++){const v=f[g];i.push(v.x,v.y,0),s.push(0,0,1),a.push(v.x,v.y)}for(let g=0,p=_.length;g<p;g++){const v=_[g],x=v[0]+u,y=v[1]+u,P=v[2]+u;n.push(x,y,P),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return ov(e,t)}static fromJSON(t,e){const n=[];for(let i=0,s=t.shapes.length;i<s;i++){const a=e[t.shapes[i]];n.push(a)}return new Ba(n,t.curveSegments)}}function ov(r,t){if(t.shapes=[],Array.isArray(r))for(let e=0,n=r.length;e<n;e++){const i=r[e];t.shapes.push(i.uuid)}else t.shapes.push(r.uuid);return t}class ar extends Ht{constructor(t=1,e=32,n=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new E,d=new E,f=[],m=[],_=[],g=[];for(let p=0;p<=n;p++){const v=[],x=p/n;let y=0;p===0&&a===0?y=.5/e:p===n&&l===Math.PI&&(y=-.5/e);for(let P=0;P<=e;P++){const w=P/e;u.x=-t*Math.cos(i+w*s)*Math.sin(a+x*o),u.y=t*Math.cos(a+x*o),u.z=t*Math.sin(i+w*s)*Math.sin(a+x*o),m.push(u.x,u.y,u.z),d.copy(u).normalize(),_.push(d.x,d.y,d.z),g.push(w+y,1-x),v.push(c++)}h.push(v)}for(let p=0;p<n;p++)for(let v=0;v<e;v++){const x=h[p][v+1],y=h[p][v],P=h[p+1][v],w=h[p+1][v+1];(p!==0||a>0)&&f.push(x,y,w),(p!==n-1||l<Math.PI)&&f.push(y,P,w)}this.setIndex(f),this.setAttribute("position",new bt(m,3)),this.setAttribute("normal",new bt(_,3)),this.setAttribute("uv",new bt(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ar(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class za extends Jn{constructor(t=1,e=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new za(t.radius,t.detail)}}class ka extends Ht{constructor(t=1,e=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],h=new E,u=new E,d=new E;for(let f=0;f<=n;f++)for(let m=0;m<=i;m++){const _=m/i*s,g=f/n*Math.PI*2;u.x=(t+e*Math.cos(g))*Math.cos(_),u.y=(t+e*Math.cos(g))*Math.sin(_),u.z=e*Math.sin(g),o.push(u.x,u.y,u.z),h.x=t*Math.cos(_),h.y=t*Math.sin(_),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(m/i),c.push(f/n)}for(let f=1;f<=n;f++)for(let m=1;m<=i;m++){const _=(i+1)*f+m-1,g=(i+1)*(f-1)+m-1,p=(i+1)*(f-1)+m,v=(i+1)*f+m;a.push(_,g,v),a.push(g,p,v)}this.setIndex(a),this.setAttribute("position",new bt(o,3)),this.setAttribute("normal",new bt(l,3)),this.setAttribute("uv",new bt(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ka(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Va extends Ht{constructor(t=1,e=.4,n=64,i=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:s,q:a},n=Math.floor(n),i=Math.floor(i);const o=[],l=[],c=[],h=[],u=new E,d=new E,f=new E,m=new E,_=new E,g=new E,p=new E;for(let x=0;x<=n;++x){const y=x/n*s*Math.PI*2;v(y,s,a,t,f),v(y+.01,s,a,t,m),g.subVectors(m,f),p.addVectors(m,f),_.crossVectors(g,p),p.crossVectors(_,g),_.normalize(),p.normalize();for(let P=0;P<=i;++P){const w=P/i*Math.PI*2,T=-e*Math.cos(w),R=e*Math.sin(w);u.x=f.x+(T*p.x+R*_.x),u.y=f.y+(T*p.y+R*_.y),u.z=f.z+(T*p.z+R*_.z),l.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),h.push(x/n),h.push(P/i)}}for(let x=1;x<=n;x++)for(let y=1;y<=i;y++){const P=(i+1)*(x-1)+(y-1),w=(i+1)*x+(y-1),T=(i+1)*x+y,R=(i+1)*(x-1)+y;o.push(P,w,R),o.push(w,T,R)}this.setIndex(o),this.setAttribute("position",new bt(l,3)),this.setAttribute("normal",new bt(c,3)),this.setAttribute("uv",new bt(h,2));function v(x,y,P,w,T){const R=Math.cos(x),b=Math.sin(x),M=P/y*x,I=Math.cos(M);T.x=w*(2+I)*.5*R,T.y=w*(2+I)*b*.5,T.z=w*Math.sin(M)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Va(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class Ha extends Ht{constructor(t=new zl(new E(-1,-1,0),new E(-1,1,0),new E(1,1,0)),e=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:s};const a=t.computeFrenetFrames(e,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new E,l=new E,c=new Y;let h=new E;const u=[],d=[],f=[],m=[];_(),this.setIndex(m),this.setAttribute("position",new bt(u,3)),this.setAttribute("normal",new bt(d,3)),this.setAttribute("uv",new bt(f,2));function _(){for(let x=0;x<e;x++)g(x);g(s===!1?e:0),v(),p()}function g(x){h=t.getPointAt(x/e,h);const y=a.normals[x],P=a.binormals[x];for(let w=0;w<=i;w++){const T=w/i*Math.PI*2,R=Math.sin(T),b=-Math.cos(T);l.x=b*y.x+R*P.x,l.y=b*y.y+R*P.y,l.z=b*y.z+R*P.z,l.normalize(),d.push(l.x,l.y,l.z),o.x=h.x+n*l.x,o.y=h.y+n*l.y,o.z=h.z+n*l.z,u.push(o.x,o.y,o.z)}}function p(){for(let x=1;x<=e;x++)for(let y=1;y<=i;y++){const P=(i+1)*(x-1)+(y-1),w=(i+1)*x+(y-1),T=(i+1)*x+y,R=(i+1)*(x-1)+y;m.push(P,w,R),m.push(w,T,R)}}function v(){for(let x=0;x<=e;x++)for(let y=0;y<=i;y++)c.x=x/e,c.y=y/i,f.push(c.x,c.y)}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new Ha(new pa[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class hd extends Ht{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},t!==null){const e=[],n=new Set,i=new E,s=new E;if(t.index!==null){const a=t.attributes.position,o=t.index;let l=t.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,h=l.length;c<h;++c){const u=l[c],d=u.start,f=u.count;for(let m=d,_=d+f;m<_;m+=3)for(let g=0;g<3;g++){const p=o.getX(m+g),v=o.getX(m+(g+1)%3);i.fromBufferAttribute(a,p),s.fromBufferAttribute(a,v),ud(i,s,n)===!0&&(e.push(i.x,i.y,i.z),e.push(s.x,s.y,s.z))}}}else{const a=t.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const h=3*o+c,u=3*o+(c+1)%3;i.fromBufferAttribute(a,h),s.fromBufferAttribute(a,u),ud(i,s,n)===!0&&(e.push(i.x,i.y,i.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new bt(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function ud(r,t,e){const n=`${r.x},${r.y},${r.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${r.x},${r.y},${r.z}`;return e.has(n)===!0||e.has(i)===!0?!1:(e.add(n),e.add(i),!0)}var dd=Object.freeze({__proto__:null,BoxGeometry:Ti,CapsuleGeometry:Ia,CircleGeometry:La,ConeGeometry:Ua,CylinderGeometry:hs,DodecahedronGeometry:Da,EdgesGeometry:id,ExtrudeGeometry:Na,IcosahedronGeometry:Fa,LatheGeometry:sr,OctahedronGeometry:rr,PlaneGeometry:cs,PolyhedronGeometry:Jn,RingGeometry:Oa,ShapeGeometry:Ba,SphereGeometry:ar,TetrahedronGeometry:za,TorusGeometry:ka,TorusKnotGeometry:Va,TubeGeometry:Ha,WireframeGeometry:hd});class fd extends Te{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new pt(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class pd extends en{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Wl extends Te{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new pt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xe,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class md extends Wl{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Y(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return le(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new pt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new pt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new pt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class gd extends Te{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new pt(16777215),this.specular=new pt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xe,this.combine=ds,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class _d extends Te{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new pt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class xd extends Te{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class vd extends Te{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xe,this.combine=ds,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class yd extends Te{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new pt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new Y(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Md extends Ne{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function vi(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function Sd(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function bd(r){function t(i,s){return r[i]-r[s]}const e=r.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function Xl(r,t,e){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=e[s]*t;for(let l=0;l!==t;++l)i[a++]=r[o+l]}return i}function ql(r,t,e,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(t.push(s.time),e.push.apply(e,a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(t.push(s.time),a.toArray(e,e.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(t.push(s.time),e.push(a)),s=r[i++];while(s!==void 0)}function lv(r,t,e,n,i=30){const s=r.clone();s.name=t;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],h=c.getValueSize(),u=[],d=[];for(let f=0;f<c.times.length;++f){const m=c.times[f]*i;if(!(m<e||m>=n)){u.push(c.times[f]);for(let _=0;_<h;++_)d.push(c.values[f*h+_])}}u.length!==0&&(c.times=vi(u,c.times.constructor),c.values=vi(d,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function cv(r,t=0,e=r,n=30){n<=0&&(n=30);const i=e.tracks.length,s=t/n;for(let a=0;a<i;++a){const o=e.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(p){return p.name===o.name&&p.ValueTypeName===l});if(c===void 0)continue;let h=0;const u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0;const f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);const m=o.times.length-1;let _;if(s<=o.times[0]){const p=h,v=u-h;_=o.values.slice(p,v)}else if(s>=o.times[m]){const p=m*u+h,v=p+u-h;_=o.values.slice(p,v)}else{const p=o.createInterpolant(),v=h,x=u-h;p.evaluate(s),_=p.resultBuffer.slice(v,x)}l==="quaternion"&&new Oe().fromArray(_).normalize().conjugate().toArray(_);const g=c.times.length;for(let p=0;p<g;++p){const v=p*f+d;if(l==="quaternion")Oe.multiplyQuaternionsFlat(c.values,v,_,0,c.values,v);else{const x=f-d*2;for(let y=0;y<x;++y)c.values[v+y]-=_[y]}}}return r.blendMode=No,r}const hv={convertArray:vi,isTypedArray:Sd,getKeyframeOrder:bd,sortedArray:Xl,flattenJSON:ql,subclip:lv,makeClipAdditive:cv};class Ks{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],s=e[n-1];t:{e:{let a;n:{i:if(!(t<i)){for(let o=n+2;;){if(i===void 0){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=e[++n],t<i)break e}a=e.length;break n}if(!(t>=s)){const o=e[1];t<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=e[--n-1],t>=s)break e}a=n,n=0;break n}break t}for(;n<a;){const o=n+a>>>1;t<e[o]?a=o:n=o+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let a=0;a!==i;++a)e[a]=n[s+a];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Ad extends Ks{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ii,endingEnd:ii}}intervalChanged_(t,e,n){const i=this.parameterPositions;let s=t-2,a=t+1,o=i[s],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case si:s=t,o=2*e-n;break;case Ms:s=i.length-2,o=e+i[s]-i[s+1];break;default:s=t,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case si:a=t,l=2*n-e;break;case Ms:a=1,l=n+i[1]-i[0];break;default:a=t-1,l=e}const c=(n-e)*.5,h=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(t,e,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(n-e)/(i-e),_=m*m,g=_*m,p=-d*g+2*d*_-d*m,v=(1+d)*g+(-1.5-2*d)*_+(-.5+d)*m+1,x=(-1-f)*g+(1.5+f)*_+.5*m,y=f*g-f*_;for(let P=0;P!==o;++P)s[P]=p*a[h+P]+v*a[c+P]+x*a[l+P]+y*a[u+P];return s}}class Yl extends Ks{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=(n-e)/(i-e),u=1-h;for(let d=0;d!==o;++d)s[d]=a[c+d]*u+a[l+d]*h;return s}}class wd extends Ks{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class rn{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=vi(e,this.TimeBufferType),this.values=vi(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:vi(t.times,Array),values:vi(t.values,Array)};const i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new wd(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Yl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Ad(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case ys:e=this.InterpolantFactoryMethodDiscrete;break;case vr:e=this.InterpolantFactoryMethodLinear;break;case yr:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ys;case this.InterpolantFactoryMethodLinear:return vr;case this.InterpolantFactoryMethodSmooth:return yr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let s=0,a=i-1;for(;s!==i&&n[s]<t;)++s;for(;a!==-1&&n[a]>e;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),t=!1;break}a=l}if(i!==void 0&&Sd(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===yr,s=t.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=t[o],h=t[o+1];if(c!==h&&(o!==1||c!==t[0]))if(i)l=!0;else{const u=o*n,d=u-n,f=u+n;for(let m=0;m!==n;++m){const _=e[u+m];if(_!==e[d+m]||_!==e[f+m]){l=!0;break}}}if(l){if(o!==a){t[a]=t[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)e[d+f]=e[u+f]}++a}}if(s>0){t[a]=t[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)e[l+c]=e[o+c];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}rn.prototype.TimeBufferType=Float32Array,rn.prototype.ValueBufferType=Float32Array,rn.prototype.DefaultInterpolation=vr;class yi extends rn{constructor(t,e,n){super(t,e,n)}}yi.prototype.ValueTypeName="bool",yi.prototype.ValueBufferType=Array,yi.prototype.DefaultInterpolation=ys,yi.prototype.InterpolantFactoryMethodLinear=void 0,yi.prototype.InterpolantFactoryMethodSmooth=void 0;class Zl extends rn{}Zl.prototype.ValueTypeName="color";class Qs extends rn{}Qs.prototype.ValueTypeName="number";class Ed extends Ks{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-e)/(i-e);let c=t*o;for(let h=c+o;c!==h;c+=4)Oe.slerpFlat(s,0,a,c-o,a,c,l);return s}}class js extends rn{InterpolantFactoryMethodLinear(t){return new Ed(this.times,this.values,this.getValueSize(),t)}}js.prototype.ValueTypeName="quaternion",js.prototype.InterpolantFactoryMethodSmooth=void 0;class Mi extends rn{constructor(t,e,n){super(t,e,n)}}Mi.prototype.ValueTypeName="string",Mi.prototype.ValueBufferType=Array,Mi.prototype.DefaultInterpolation=ys,Mi.prototype.InterpolantFactoryMethodLinear=void 0,Mi.prototype.InterpolantFactoryMethodSmooth=void 0;class tr extends rn{}tr.prototype.ValueTypeName="vector";class er{constructor(t="",e=-1,n=[],i=Mr){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=He(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(dv(n[a]).scale(i));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,a=n.length;s!==a;++s)e.push(rn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const s=e.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=bd(l);l=Xl(l,1,h),c=Xl(c,1,h),!i&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Qs(".morphTargetInfluences["+e[o].name+"]",l,c).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=t.length;o<l;o++){const c=t[o],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,m,_){if(f.length!==0){const g=[],p=[];ql(f,g,p,m),g.length!==0&&_.push(new u(d,g,p))}},i=[],s=t.name||"default",a=t.fps||30,o=t.blendMode;let l=t.length||-1;const c=t.hierarchy||[];for(let u=0;u<c.length;u++){const d=c[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let m;for(m=0;m<d.length;m++)if(d[m].morphTargets)for(let _=0;_<d[m].morphTargets.length;_++)f[d[m].morphTargets[_]]=-1;for(const _ in f){const g=[],p=[];for(let v=0;v!==d[m].morphTargets.length;++v){const x=d[m];g.push(x.time),p.push(x.morphTarget===_?1:0)}i.push(new Qs(".morphTargetInfluence["+_+"]",g,p))}l=f.length*a}else{const f=".bones["+e[u].name+"]";n(tr,f+".position",d,"pos",i),n(js,f+".quaternion",d,"rot",i),n(tr,f+".scale",d,"scl",i)}}return i.length===0?null:new this(s,l,i,o)}resetDuration(){const t=this.tracks;let e=0;for(let n=0,i=t.length;n!==i;++n){const s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function uv(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Qs;case"vector":case"vector2":case"vector3":case"vector4":return tr;case"color":return Zl;case"quaternion":return js;case"bool":case"boolean":return yi;case"string":return Mi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function dv(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=uv(r.type);if(r.times===void 0){const e=[],n=[];ql(r.keys,e,n,"value"),r.times=e,r.values=n}return t.parse!==void 0?t.parse(r):new t(r.name,r.times,r.values,r.interpolation)}const Pn={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(this.files[r]=t)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class Jl{constructor(t,e,n){const i=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){o++,s===!1&&i.onStart!==void 0&&i.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){const f=c[u],m=c[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return m}return null}}}const Td=new Jl;class ze{constructor(t){this.manager=t!==void 0?t:Td,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}ze.DEFAULT_MATERIAL_NAME="__DEFAULT";const In={};class fv extends Error{constructor(t,e){super(t),this.response=e}}class Ln extends ze{constructor(t){super(t)}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=Pn.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(In[t]!==void 0){In[t].push({onLoad:e,onProgress:n,onError:i});return}In[t]=[],In[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=In[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0;let _=0;const g=new ReadableStream({start(p){v();function v(){u.read().then(({done:x,value:y})=>{if(x)p.close();else{_+=y.byteLength;const P=new ProgressEvent("progress",{lengthComputable:m,loaded:_,total:f});for(let w=0,T=h.length;w<T;w++){const R=h[w];R.onProgress&&R.onProgress(P)}p.enqueue(y),v()}},x=>{p.error(x)})}}});return new Response(g)}else throw new fv(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{Pn.add(t,c);const h=In[t];delete In[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(c)}}).catch(c=>{const h=In[t];if(h===void 0)throw this.manager.itemError(t),c;delete In[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class pv extends ze{constructor(t){super(t)}load(t,e,n,i){const s=this,a=new Ln(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(o){try{e(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){const e=[];for(let n=0;n<t.length;n++){const i=er.parse(t[n]);e.push(i)}return e}}class mv extends ze{constructor(t){super(t)}load(t,e,n,i){const s=this,a=[],o=new ua,l=new Ln(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function h(u){l.load(t[u],function(d){const f=s.parse(d,!0);a[u]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},c+=1,c===6&&(f.mipmapCount===1&&(o.minFilter=pe),o.image=a,o.format=f.format,o.needsUpdate=!0,e&&e(o))},n,i)}if(Array.isArray(t))for(let u=0,d=t.length;u<d;++u)h(u);else l.load(t,function(u){const d=s.parse(u,!0);if(d.isCubemap){const f=d.mipmaps.length/d.mipmapCount;for(let m=0;m<f;m++){a[m]={mipmaps:[]};for(let _=0;_<d.mipmapCount;_++)a[m].mipmaps.push(d.mipmaps[m*d.mipmapCount+_]),a[m].format=d.format,a[m].width=d.width,a[m].height=d.height}o.image=a}else o.image.width=d.width,o.image.height=d.height,o.mipmaps=d.mipmaps;d.mipmapCount===1&&(o.minFilter=pe),o.format=d.format,o.needsUpdate=!0,e&&e(o)},n,i);return o}}class nr extends ze{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=Pn.get(t);if(a!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0),a;const o=Rs("img");function l(){h(),Pn.add(t,this),e&&e(this),s.manager.itemEnd(t)}function c(u){h(),i&&i(u),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(t),o.src=t,o}}class gv extends ze{constructor(t){super(t)}load(t,e,n,i){const s=new Ns;s.colorSpace=Je;const a=new nr(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(t[c],function(h){s.images[c]=h,o++,o===6&&(s.needsUpdate=!0,e&&e(s))},void 0,i)}for(let c=0;c<t.length;++c)l(c);return s}}class _v extends ze{constructor(t){super(t)}load(t,e,n,i){const s=this,a=new Rn,o=new Ln(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(t,function(l){let c;try{c=s.parse(l)}catch(h){if(i!==void 0)i(h);else{console.error(h);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:Ze,a.wrapT=c.wrapT!==void 0?c.wrapT:Ze,a.magFilter=c.magFilter!==void 0?c.magFilter:pe,a.minFilter=c.minFilter!==void 0?c.minFilter:pe,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=hn),c.mipmapCount===1&&(a.minFilter=pe),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,e&&e(a,c)},n,i),a}}class xv extends ze{constructor(t){super(t)}load(t,e,n,i){const s=new he,a=new nr(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){s.image=o,s.needsUpdate=!0,e!==void 0&&e(s)},n,i),s}}class Yn extends Zt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new pt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}}class Cd extends Yn{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Zt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new pt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const $l=new Rt,Rd=new E,Pd=new E;class Kl{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Y(512,512),this.map=null,this.mapPass=null,this.matrix=new Rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Fs,this._frameExtents=new Y(1,1),this._viewportCount=1,this._viewports=[new ee(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Rd.setFromMatrixPosition(t.matrixWorld),e.position.copy(Rd),Pd.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Pd),e.updateMatrixWorld(),$l.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix($l),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply($l)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class vv extends Kl{constructor(){super(new be(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,n=Ii*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Id extends Yn{constructor(t,e,n=0,i=Math.PI/3,s=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Zt.DEFAULT_UP),this.updateMatrix(),this.target=new Zt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new vv}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Ld=new Rt,ir=new E,Ql=new E;class yv extends Kl{constructor(){super(new be(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Y(4,2),this._viewportCount=6,this._viewports=[new ee(2,1,1,1),new ee(0,1,1,1),new ee(3,1,1,1),new ee(1,1,1,1),new ee(3,0,1,1),new ee(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,i=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),ir.setFromMatrixPosition(t.matrixWorld),n.position.copy(ir),Ql.copy(n.position),Ql.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Ql),n.updateMatrixWorld(),i.makeTranslation(-ir.x,-ir.y,-ir.z),Ld.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ld)}}class Ud extends Yn{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new yv}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Mv extends Kl{constructor(){super(new qr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Dd extends Yn{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Zt.DEFAULT_UP),this.updateMatrix(),this.target=new Zt,this.shadow=new Mv}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Nd extends Yn{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Fd extends Yn{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class Od{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new E)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const n=t.x,i=t.y,s=t.z,a=this.coefficients;return e.copy(a[0]).multiplyScalar(.282095),e.addScaledVector(a[1],.488603*i),e.addScaledVector(a[2],.488603*s),e.addScaledVector(a[3],.488603*n),e.addScaledVector(a[4],1.092548*(n*i)),e.addScaledVector(a[5],1.092548*(i*s)),e.addScaledVector(a[6],.315392*(3*s*s-1)),e.addScaledVector(a[7],1.092548*(n*s)),e.addScaledVector(a[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){const n=t.x,i=t.y,s=t.z,a=this.coefficients;return e.copy(a[0]).multiplyScalar(.886227),e.addScaledVector(a[1],2*.511664*i),e.addScaledVector(a[2],2*.511664*s),e.addScaledVector(a[3],2*.511664*n),e.addScaledVector(a[4],2*.429043*n*i),e.addScaledVector(a[5],2*.429043*i*s),e.addScaledVector(a[6],.743125*s*s-.247708),e.addScaledVector(a[7],2*.429043*n*s),e.addScaledVector(a[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+i*3);return this}toArray(t=[],e=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+i*3);return t}static getBasisAt(t,e){const n=t.x,i=t.y,s=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*s,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*n*s,e[8]=.546274*(n*n-i*i)}}class Bd extends Yn{constructor(t=new Od,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Ga extends ze{constructor(t){super(t),this.textures={}}load(t,e,n,i){const s=this,a=new Ln(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(t,function(o){try{e(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){const e=this.textures;function n(s){return e[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),e[s]}const i=Ga.createMaterialFromType(t.type);if(t.uuid!==void 0&&(i.uuid=t.uuid),t.name!==void 0&&(i.name=t.name),t.color!==void 0&&i.color!==void 0&&i.color.setHex(t.color),t.roughness!==void 0&&(i.roughness=t.roughness),t.metalness!==void 0&&(i.metalness=t.metalness),t.sheen!==void 0&&(i.sheen=t.sheen),t.sheenColor!==void 0&&(i.sheenColor=new pt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(i.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(t.emissive),t.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(t.specular),t.specularIntensity!==void 0&&(i.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(i.shininess=t.shininess),t.clearcoat!==void 0&&(i.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(i.dispersion=t.dispersion),t.iridescence!==void 0&&(i.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(i.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(i.transmission=t.transmission),t.thickness!==void 0&&(i.thickness=t.thickness),t.attenuationDistance!==void 0&&(i.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(i.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(i.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(i.fog=t.fog),t.flatShading!==void 0&&(i.flatShading=t.flatShading),t.blending!==void 0&&(i.blending=t.blending),t.combine!==void 0&&(i.combine=t.combine),t.side!==void 0&&(i.side=t.side),t.shadowSide!==void 0&&(i.shadowSide=t.shadowSide),t.opacity!==void 0&&(i.opacity=t.opacity),t.transparent!==void 0&&(i.transparent=t.transparent),t.alphaTest!==void 0&&(i.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(i.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(i.depthFunc=t.depthFunc),t.depthTest!==void 0&&(i.depthTest=t.depthTest),t.depthWrite!==void 0&&(i.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(i.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(i.blendSrc=t.blendSrc),t.blendDst!==void 0&&(i.blendDst=t.blendDst),t.blendEquation!==void 0&&(i.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(i.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(i.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(i.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(i.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(i.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(i.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(i.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(i.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(i.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(i.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(i.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(i.rotation=t.rotation),t.linewidth!==void 0&&(i.linewidth=t.linewidth),t.dashSize!==void 0&&(i.dashSize=t.dashSize),t.gapSize!==void 0&&(i.gapSize=t.gapSize),t.scale!==void 0&&(i.scale=t.scale),t.polygonOffset!==void 0&&(i.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(i.dithering=t.dithering),t.alphaToCoverage!==void 0&&(i.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(i.forceSinglePass=t.forceSinglePass),t.visible!==void 0&&(i.visible=t.visible),t.toneMapped!==void 0&&(i.toneMapped=t.toneMapped),t.userData!==void 0&&(i.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const s in t.uniforms){const a=t.uniforms[s];switch(i.uniforms[s]={},a.type){case"t":i.uniforms[s].value=n(a.value);break;case"c":i.uniforms[s].value=new pt().setHex(a.value);break;case"v2":i.uniforms[s].value=new Y().fromArray(a.value);break;case"v3":i.uniforms[s].value=new E().fromArray(a.value);break;case"v4":i.uniforms[s].value=new ee().fromArray(a.value);break;case"m3":i.uniforms[s].value=new Bt().fromArray(a.value);break;case"m4":i.uniforms[s].value=new Rt().fromArray(a.value);break;default:i.uniforms[s].value=a.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(const s in t.extensions)i.extensions[s]=t.extensions[s];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let s=t.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new Y().fromArray(s)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new Y().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){const e={ShadowMaterial:fd,SpriteMaterial:Ml,RawShaderMaterial:pd,ShaderMaterial:en,PointsMaterial:Pl,MeshPhysicalMaterial:md,MeshStandardMaterial:Wl,MeshPhongMaterial:gd,MeshToonMaterial:_d,MeshNormalMaterial:xd,MeshLambertMaterial:vd,MeshDepthMaterial:xl,MeshDistanceMaterial:vl,MeshBasicMaterial:Hn,MeshMatcapMaterial:yd,LineDashedMaterial:Md,LineBasicMaterial:Ne,Material:Te};return new e[t]}}class jl{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch{return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class zd extends Ht{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class kd extends ze{constructor(t){super(t)}load(t,e,n,i){const s=this,a=new Ln(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(t,function(o){try{e(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){const e={},n={};function i(f,m){if(e[m]!==void 0)return e[m];const g=f.interleavedBuffers[m],p=s(f,g.buffer),v=Li(g.type,p),x=new $r(v,g.stride);return x.uuid=g.uuid,e[m]=x,x}function s(f,m){if(n[m]!==void 0)return n[m];const g=f.arrayBuffers[m],p=new Uint32Array(g).buffer;return n[m]=p,p}const a=t.isInstancedBufferGeometry?new zd:new Ht,o=t.data.index;if(o!==void 0){const f=Li(o.type,o.array);a.setIndex(new te(f,1))}const l=t.data.attributes;for(const f in l){const m=l[f];let _;if(m.isInterleavedBufferAttribute){const g=i(t.data,m.data);_=new Ci(g,m.itemSize,m.offset,m.normalized)}else{const g=Li(m.type,m.array),p=m.isInstancedBufferAttribute?rs:te;_=new p(g,m.itemSize,m.normalized)}m.name!==void 0&&(_.name=m.name),m.usage!==void 0&&_.setUsage(m.usage),a.setAttribute(f,_)}const c=t.data.morphAttributes;if(c)for(const f in c){const m=c[f],_=[];for(let g=0,p=m.length;g<p;g++){const v=m[g];let x;if(v.isInterleavedBufferAttribute){const y=i(t.data,v.data);x=new Ci(y,v.itemSize,v.offset,v.normalized)}else{const y=Li(v.type,v.array);x=new te(y,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),_.push(x)}a.morphAttributes[f]=_}t.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=t.data.groups||t.data.drawcalls||t.data.offsets;if(u!==void 0)for(let f=0,m=u.length;f!==m;++f){const _=u[f];a.addGroup(_.start,_.count,_.materialIndex)}const d=t.data.boundingSphere;if(d!==void 0){const f=new E;d.center!==void 0&&f.fromArray(d.center),a.boundingSphere=new we(f,d.radius)}return t.name&&(a.name=t.name),t.userData&&(a.userData=t.userData),a}}class Sv extends ze{constructor(t){super(t)}load(t,e,n,i){const s=this,a=this.path===""?jl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||a;const o=new Ln(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(l){let c=null;try{c=JSON.parse(l)}catch(u){i!==void 0&&i(u),console.error("THREE:ObjectLoader: Can't parse "+t+".",u.message);return}const h=c.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+t)),console.error("THREE.ObjectLoader: Can't load "+t);return}s.parse(c,e)},n,i)}async loadAsync(t,e){const n=this,i=this.path===""?jl.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;const s=new Ln(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(t,e),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+t);return await n.parseAsync(o)}parse(t,e){const n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,i),a=this.parseImages(t.images,function(){e!==void 0&&e(c)}),o=this.parseTextures(t.textures,a),l=this.parseMaterials(t.materials,o),c=this.parseObject(t.object,s,l,o,n),h=this.parseSkeletons(t.skeletons,c);if(this.bindSkeletons(c,h),e!==void 0){let u=!1;for(const d in a)if(a[d].data instanceof HTMLImageElement){u=!0;break}u===!1&&e(c)}return c}async parseAsync(t){const e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),s=await this.parseImagesAsync(t.images),a=this.parseTextures(t.textures,s),o=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,i,o,a,e),c=this.parseSkeletons(t.skeletons,l);return this.bindSkeletons(l,c),l}parseShapes(t){const e={};if(t!==void 0)for(let n=0,i=t.length;n<i;n++){const s=new _i().fromJSON(t[n]);e[s.uuid]=s}return e}parseSkeletons(t,e){const n={},i={};if(e.traverse(function(s){s.isBone&&(i[s.uuid]=s)}),t!==void 0)for(let s=0,a=t.length;s<a;s++){const o=new Pa().fromJSON(t[s],i);n[o.uuid]=o}return n}parseGeometries(t,e){const n={};if(t!==void 0){const i=new kd;for(let s=0,a=t.length;s<a;s++){let o;const l=t[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=i.parse(l);break;default:l.type in dd?o=dd[l.type].fromJSON(l,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),n[l.uuid]=o}}return n}parseMaterials(t,e){const n={},i={};if(t!==void 0){const s=new Ga;s.setTextures(e);for(let a=0,o=t.length;a<o;a++){const l=t[a];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),i[l.uuid]=n[l.uuid]}}return i}parseAnimations(t){const e={};if(t!==void 0)for(let n=0;n<t.length;n++){const i=t[n],s=er.parse(i);e[s.uuid]=s}return e}parseImages(t,e){const n=this,i={};let s;function a(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return a(h)}else return l.data?{data:Li(l.type,l.data),width:l.width,height:l.height}:null}if(t!==void 0&&t.length>0){const l=new Jl(e);s=new nr(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=t.length;c<h;c++){const u=t[c],d=u.url;if(Array.isArray(d)){const f=[];for(let m=0,_=d.length;m<_;m++){const g=d[m],p=o(g);p!==null&&(p instanceof HTMLImageElement?f.push(p):f.push(new Rn(p.data,p.width,p.height)))}i[u.uuid]=new oi(f)}else{const f=o(u.url);i[u.uuid]=new oi(f)}}}return i}async parseImagesAsync(t){const e=this,n={};let i;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:e.resourcePath+o;return await i.loadAsync(l)}else return a.data?{data:Li(a.type,a.data),width:a.width,height:a.height}:null}if(t!==void 0&&t.length>0){i=new nr(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=t.length;a<o;a++){const l=t[a],c=l.url;if(Array.isArray(c)){const h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u],m=await s(f);m!==null&&(m instanceof HTMLImageElement?h.push(m):h.push(new Rn(m.data,m.width,m.height)))}n[l.uuid]=new oi(h)}else{const h=await s(l.url);n[l.uuid]=new oi(h)}}}return n}parseTextures(t,e){function n(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const i={};if(t!==void 0)for(let s=0,a=t.length;s<a;s++){const o=t[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),e[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=e[o.image],c=l.data;let h;Array.isArray(c)?(h=new Ns,c.length===6&&(h.needsUpdate=!0)):(c&&c.data?h=new Rn:h=new he,c&&(h.needsUpdate=!0)),h.source=l,h.uuid=o.uuid,o.name!==void 0&&(h.name=o.name),o.mapping!==void 0&&(h.mapping=n(o.mapping,bv)),o.channel!==void 0&&(h.channel=o.channel),o.offset!==void 0&&h.offset.fromArray(o.offset),o.repeat!==void 0&&h.repeat.fromArray(o.repeat),o.center!==void 0&&h.center.fromArray(o.center),o.rotation!==void 0&&(h.rotation=o.rotation),o.wrap!==void 0&&(h.wrapS=n(o.wrap[0],Vd),h.wrapT=n(o.wrap[1],Vd)),o.format!==void 0&&(h.format=o.format),o.internalFormat!==void 0&&(h.internalFormat=o.internalFormat),o.type!==void 0&&(h.type=o.type),o.colorSpace!==void 0&&(h.colorSpace=o.colorSpace),o.minFilter!==void 0&&(h.minFilter=n(o.minFilter,Hd)),o.magFilter!==void 0&&(h.magFilter=n(o.magFilter,Hd)),o.anisotropy!==void 0&&(h.anisotropy=o.anisotropy),o.flipY!==void 0&&(h.flipY=o.flipY),o.generateMipmaps!==void 0&&(h.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(h.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(h.compareFunction=o.compareFunction),o.userData!==void 0&&(h.userData=o.userData),i[o.uuid]=h}return i}parseObject(t,e,n,i,s){let a;function o(d){return e[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),e[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const f=[];for(let m=0,_=d.length;m<_;m++){const g=d[m];n[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),f.push(n[g])}return f}return n[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),n[d]}}function c(d){return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),i[d]}let h,u;switch(t.type){case"Scene":a=new bu,t.background!==void 0&&(Number.isInteger(t.background)?a.background=new pt(t.background):a.background=c(t.background)),t.environment!==void 0&&(a.environment=c(t.environment)),t.fog!==void 0&&(t.fog.type==="Fog"?a.fog=new Ra(t.fog.color,t.fog.near,t.fog.far):t.fog.type==="FogExp2"&&(a.fog=new Ca(t.fog.color,t.fog.density)),t.fog.name!==""&&(a.fog.name=t.fog.name)),t.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=t.backgroundBlurriness),t.backgroundIntensity!==void 0&&(a.backgroundIntensity=t.backgroundIntensity),t.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(t.backgroundRotation),t.environmentIntensity!==void 0&&(a.environmentIntensity=t.environmentIntensity),t.environmentRotation!==void 0&&a.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":a=new be(t.fov,t.aspect,t.near,t.far),t.focus!==void 0&&(a.focus=t.focus),t.zoom!==void 0&&(a.zoom=t.zoom),t.filmGauge!==void 0&&(a.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(a.filmOffset=t.filmOffset),t.view!==void 0&&(a.view=Object.assign({},t.view));break;case"OrthographicCamera":a=new qr(t.left,t.right,t.top,t.bottom,t.near,t.far),t.zoom!==void 0&&(a.zoom=t.zoom),t.view!==void 0&&(a.view=Object.assign({},t.view));break;case"AmbientLight":a=new Nd(t.color,t.intensity);break;case"DirectionalLight":a=new Dd(t.color,t.intensity);break;case"PointLight":a=new Ud(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":a=new Fd(t.color,t.intensity,t.width,t.height);break;case"SpotLight":a=new Id(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":a=new Cd(t.color,t.groundColor,t.intensity);break;case"LightProbe":a=new Bd().fromJSON(t);break;case"SkinnedMesh":h=o(t.geometry),u=l(t.material),a=new Nu(h,u),t.bindMode!==void 0&&(a.bindMode=t.bindMode),t.bindMatrix!==void 0&&a.bindMatrix.fromArray(t.bindMatrix),t.skeleton!==void 0&&(a.skeleton=t.skeleton);break;case"Mesh":h=o(t.geometry),u=l(t.material),a=new ge(h,u);break;case"InstancedMesh":h=o(t.geometry),u=l(t.material);const d=t.count,f=t.instanceMatrix,m=t.instanceColor;a=new zu(h,u,d),a.instanceMatrix=new rs(new Float32Array(f.array),16),m!==void 0&&(a.instanceColor=new rs(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":h=o(t.geometry),u=l(t.material),a=new Hu(t.maxGeometryCount,t.maxVertexCount,t.maxIndexCount,u),a.geometry=h,a.perObjectFrustumCulled=t.perObjectFrustumCulled,a.sortObjects=t.sortObjects,a._drawRanges=t.drawRanges,a._reservedRanges=t.reservedRanges,a._visibility=t.visibility,a._active=t.active,a._bounds=t.bounds.map(_=>{const g=new Le;g.min.fromArray(_.boxMin),g.max.fromArray(_.boxMax);const p=new we;return p.radius=_.sphereRadius,p.center.fromArray(_.sphereCenter),{boxInitialized:_.boxInitialized,box:g,sphereInitialized:_.sphereInitialized,sphere:p}}),a._maxGeometryCount=t.maxGeometryCount,a._maxVertexCount=t.maxVertexCount,a._maxIndexCount=t.maxIndexCount,a._geometryInitialized=t.geometryInitialized,a._geometryCount=t.geometryCount,a._matricesTexture=c(t.matricesTexture.uuid),t.colorsTexture!==void 0&&(a._colorsTexture=c(t.colorsTexture.uuid));break;case"LOD":a=new Ru;break;case"Line":a=new qn(o(t.geometry),l(t.material));break;case"LineLoop":a=new Yu(o(t.geometry),l(t.material));break;case"LineSegments":a=new dn(o(t.geometry),l(t.material));break;case"PointCloud":case"Points":a=new Ju(o(t.geometry),l(t.material));break;case"Sprite":a=new Tu(l(t.material));break;case"Group":a=new ts;break;case"Bone":a=new wl;break;default:a=new Zt}if(a.uuid=t.uuid,t.name!==void 0&&(a.name=t.name),t.matrix!==void 0?(a.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=t.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(t.position!==void 0&&a.position.fromArray(t.position),t.rotation!==void 0&&a.rotation.fromArray(t.rotation),t.quaternion!==void 0&&a.quaternion.fromArray(t.quaternion),t.scale!==void 0&&a.scale.fromArray(t.scale)),t.up!==void 0&&a.up.fromArray(t.up),t.castShadow!==void 0&&(a.castShadow=t.castShadow),t.receiveShadow!==void 0&&(a.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.bias!==void 0&&(a.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(a.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(a.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(a.visible=t.visible),t.frustumCulled!==void 0&&(a.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(a.renderOrder=t.renderOrder),t.userData!==void 0&&(a.userData=t.userData),t.layers!==void 0&&(a.layers.mask=t.layers),t.children!==void 0){const d=t.children;for(let f=0;f<d.length;f++)a.add(this.parseObject(d[f],e,n,i,s))}if(t.animations!==void 0){const d=t.animations;for(let f=0;f<d.length;f++){const m=d[f];a.animations.push(s[m])}}if(t.type==="LOD"){t.autoUpdate!==void 0&&(a.autoUpdate=t.autoUpdate);const d=t.levels;for(let f=0;f<d.length;f++){const m=d[f],_=a.getObjectByProperty("uuid",m.object);_!==void 0&&a.addLevel(_,m.distance,m.hysteresis)}}return a}bindSkeletons(t,e){Object.keys(e).length!==0&&t.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=e[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}}const bv={UVMapping:fr,CubeReflectionMapping:xn,CubeRefractionMapping:Nn,EquirectangularReflectionMapping:fs,EquirectangularRefractionMapping:ps,CubeUVReflectionMapping:Ri},Vd={RepeatWrapping:ms,ClampToEdgeWrapping:Ze,MirroredRepeatWrapping:gs},Hd={NearestFilter:Me,NearestMipmapNearestFilter:to,NearestMipmapLinearFilter:Pi,LinearFilter:pe,LinearMipmapNearestFilter:_s,LinearMipmapLinearFilter:hn};class Av extends ze{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=Pn.get(t);if(a!==void 0){if(s.manager.itemStart(t),a.then){a.then(c=>{e&&e(c),s.manager.itemEnd(t)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(t,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Pn.add(t,c),e&&e(c),s.manager.itemEnd(t),c}).catch(function(c){i&&i(c),Pn.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});Pn.add(t,l),s.manager.itemStart(t)}}let Ma;class tc{static getContext(){return Ma===void 0&&(Ma=new(window.AudioContext||window.webkitAudioContext)),Ma}static setContext(t){Ma=t}}class wv extends ze{constructor(t){super(t)}load(t,e,n,i){const s=this,a=new Ln(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(l){try{const c=l.slice(0);tc.getContext().decodeAudioData(c,function(u){e(u)}).catch(o)}catch(c){o(c)}},n,i);function o(l){i?i(l):console.error(l),s.manager.itemError(t)}}}const Gd=new Rt,Wd=new Rt,Si=new Rt;class Ev{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new be,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new be,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Si.copy(t.projectionMatrix);const i=e.eyeSep/2,s=i*e.near/e.focus,a=e.near*Math.tan(ai*e.fov*.5)/e.zoom;let o,l;Wd.elements[12]=-i,Gd.elements[12]=i,o=-a*e.aspect+s,l=a*e.aspect+s,Si.elements[0]=2*e.near/(l-o),Si.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Si),o=-a*e.aspect-s,l=a*e.aspect-s,Si.elements[0]=2*e.near/(l-o),Si.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Si)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Wd),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Gd)}}class Xd{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=qd(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=qd();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function qd(){return(typeof performance>"u"?Date:performance).now()}const bi=new E,Yd=new Oe,Tv=new E,Ai=new E;class Cv extends Zt{constructor(){super(),this.type="AudioListener",this.context=tc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Xd}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(bi,Yd,Tv),Ai.set(0,0,-1).applyQuaternion(Yd),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(bi.x,i),e.positionY.linearRampToValueAtTime(bi.y,i),e.positionZ.linearRampToValueAtTime(bi.z,i),e.forwardX.linearRampToValueAtTime(Ai.x,i),e.forwardY.linearRampToValueAtTime(Ai.y,i),e.forwardZ.linearRampToValueAtTime(Ai.z,i),e.upX.linearRampToValueAtTime(n.x,i),e.upY.linearRampToValueAtTime(n.y,i),e.upZ.linearRampToValueAtTime(n.z,i)}else e.setPosition(bi.x,bi.y,bi.z),e.setOrientation(Ai.x,Ai.y,Ai.z,n.x,n.y,n.z)}}class Zd extends Zt{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),this._connected===!0?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=t,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=t,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}const wi=new E,Jd=new Oe,Rv=new E,Ei=new E;class Pv extends Zd{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(wi,Jd,Rv),Ei.set(0,0,1).applyQuaternion(Jd);const e=this.panner;if(e.positionX){const n=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(wi.x,n),e.positionY.linearRampToValueAtTime(wi.y,n),e.positionZ.linearRampToValueAtTime(wi.z,n),e.orientationX.linearRampToValueAtTime(Ei.x,n),e.orientationY.linearRampToValueAtTime(Ei.y,n),e.orientationZ.linearRampToValueAtTime(Ei.z,n)}else e.setPosition(wi.x,wi.y,wi.z),e.setOrientation(Ei.x,Ei.y,Ei.z)}}class Iv{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}}class $d{constructor(t,e,n){this.binding=t,this.valueSize=n;let i,s,a;switch(e){case"quaternion":i=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const n=this.buffer,i=this.valueSize,s=t*i+i;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==i;++o)n[s+o]=n[o];a=e}else{a+=e;const o=e/a;this._mixBufferRegion(n,s,0,o,i)}this.cumulativeWeight=a}accumulateAdditive(t){const e=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,n=this.buffer,i=t*e+e,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=e*this._origIndex;this._mixBufferRegion(n,i,l,1-s,e)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(n[l]!==n[l+e]){o.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let s=n,a=i;s!==a;++s)e[s]=e[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,s){if(i>=.5)for(let a=0;a!==s;++a)t[e+a]=t[n+a]}_slerp(t,e,n,i){Oe.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,s){const a=this._workIndex*s;Oe.multiplyQuaternionsFlat(t,a,t,e,t,n),Oe.slerpFlat(t,e,t,e,t,a,i)}_lerp(t,e,n,i,s){const a=1-i;for(let o=0;o!==s;++o){const l=e+o;t[l]=t[l]*a+t[n+o]*i}}_lerpAdditive(t,e,n,i,s){for(let a=0;a!==s;++a){const o=e+a;t[o]=t[o]+t[n+a]*i}}}const ec="\\[\\]\\.:\\/",Lv=new RegExp("["+ec+"]","g"),nc="[^"+ec+"]",Uv="[^"+ec.replace("\\.","")+"]",Dv=/((?:WC+[\/:])*)/.source.replace("WC",nc),Nv=/(WCOD+)?/.source.replace("WCOD",Uv),Fv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nc),Ov=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nc),Bv=new RegExp("^"+Dv+Nv+Fv+Ov+"$"),zv=["material","materials","bones","map"];class kv{constructor(t,e,n){const i=n||Yt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class Yt{constructor(t,e,n){this.path=e,this.parsedPath=n||Yt.parseTrackName(e),this.node=Yt.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Yt.Composite(t,e,n):new Yt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Lv,"")}static parseTrackName(t){const e=Bv.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);zv.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===e||o.uuid===e)return o;const l=n(o.children);if(l)return l}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let s=e.propertyIndex;if(t||(t=Yt.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===c){c=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}const a=t[i];if(a===void 0){const c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Yt.Composite=kv,Yt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Yt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Yt.prototype.GetterByBindingType=[Yt.prototype._getValue_direct,Yt.prototype._getValue_array,Yt.prototype._getValue_arrayElement,Yt.prototype._getValue_toArray],Yt.prototype.SetterByBindingTypeAndVersioning=[[Yt.prototype._setValue_direct,Yt.prototype._setValue_direct_setNeedsUpdate,Yt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Yt.prototype._setValue_array,Yt.prototype._setValue_array_setNeedsUpdate,Yt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Yt.prototype._setValue_arrayElement,Yt.prototype._setValue_arrayElement_setNeedsUpdate,Yt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Yt.prototype._setValue_fromArray,Yt.prototype._setValue_fromArray_setNeedsUpdate,Yt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Vv{constructor(){this.isAnimationObjectGroup=!0,this.uuid=He(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let n=0,i=arguments.length;n!==i;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,a=s.length;let o,l=t.length,c=this.nCachedObjects_;for(let h=0,u=arguments.length;h!==u;++h){const d=arguments[h],f=d.uuid;let m=e[f];if(m===void 0){m=l++,e[f]=m,t.push(d);for(let _=0,g=a;_!==g;++_)s[_].push(new Yt(d,n[_],i[_]))}else if(m<c){o=t[m];const _=--c,g=t[_];e[g.uuid]=m,t[m]=g,e[f]=_,t[_]=d;for(let p=0,v=a;p!==v;++p){const x=s[p],y=x[_];let P=x[m];x[m]=y,P===void 0&&(P=new Yt(d,n[p],i[p])),x[_]=P}}else t[m]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,h=e[c];if(h!==void 0&&h>=s){const u=s++,d=t[u];e[d.uuid]=h,t[h]=d,e[c]=u,t[u]=l;for(let f=0,m=i;f!==m;++f){const _=n[f],g=_[u],p=_[h];_[h]=g,_[u]=p}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,a=t.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=e[h];if(u!==void 0)if(delete e[h],u<s){const d=--s,f=t[d],m=--a,_=t[m];e[f.uuid]=u,t[u]=f,e[_.uuid]=d,t[d]=_,t.pop();for(let g=0,p=i;g!==p;++g){const v=n[g],x=v[d],y=v[m];v[u]=x,v[d]=y,v.pop()}}else{const d=--a,f=t[d];d>0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let m=0,_=i;m!==_;++m){const g=n[m];g[u]=g[d],g.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const s=this._bindings;if(i!==void 0)return s[i];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=s.length,n[t]=i,a.push(t),o.push(e),s.push(u);for(let d=h,f=l.length;d!==f;++d){const m=l[d];u[d]=new Yt(m,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){const i=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=t[o];e[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class Kd{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const s=e.tracks,a=s.length,o=new Array(a),l={endingStart:ii,endingEnd:ii};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=oh,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const i=this._clip.duration,s=t._clip.duration,a=s/i,o=i/s;t.warp(1,a,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,s=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=t/a,c[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);const a=this._updateTime(e),o=this._updateWeight(t);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case No:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Mr:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(i,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,s=this._loopCount;const a=n===lh;if(t===0)return s===-1?i:a&&(s&1)===1?e-i:i;if(n===ah){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=e||i<0){const o=Math.floor(i/e);i-=e*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){const c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(s&1)===1)return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=si,i.endingEnd=si):(t?i.endingStart=this.zeroSlopeAtStart?si:ii:i.endingStart=Ms,e?i.endingEnd=this.zeroSlopeAtEnd?si:ii:i.endingEnd=Ms)}_scheduleFading(t,e,n){const i=this._mixer,s=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=e,o[1]=s+t,l[1]=n,this}}const Hv=new Float32Array(1);class Gv extends Sn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,s=i.length,a=t._propertyBindings,o=t._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=i[u],f=d.name;let m=h[f];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}const _=e&&e._propertyBindings[u].binding.parsedPath;m=new $d(Yt.create(n,f,_),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const n=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,n)}const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){const i=this._actions,s=this._actionsByClip;let a=s[e];if(a===void 0)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=a;else{const o=a.knownActions;t._byClipCacheIndex=o.length,o.push(t)}t._cacheIndex=i.length,i.push(t),a.actionByRoot[n]=t}_removeInactiveAction(t){const e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],h=t._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),t._byClipCacheIndex=null;const u=o.actionByRoot,d=(t._localRoot||this._root).uuid;delete u[d],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){const e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_takeBackAction(t){const e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_addInactiveBinding(t,e,n){const i=this._bindingsByRootAndName,s=this._bindings;let a=i[e];a===void 0&&(a={},i[e]=a),a[n]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,n=t.binding,i=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,o=a[i],l=e[e.length-1],c=t._cacheIndex;l._cacheIndex=c,e[c]=l,e.pop(),delete o[s],Object.keys(o).length===0&&delete a[i]}_lendBinding(t){const e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_takeBackBinding(t){const e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,s=e[i];t._cacheIndex=i,e[i]=t,s._cacheIndex=n,e[n]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let n=t[e];return n===void 0&&(n=new Yl(new Float32Array(2),new Float32Array(2),1,Hv),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){const e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,s=e[i];t.__cacheIndex=i,e[i]=t,s.__cacheIndex=n,e[n]=s}clipAction(t,e,n){const i=e||this._root,s=i.uuid;let a=typeof t=="string"?er.findByName(i,t):t;const o=a!==null?a.uuid:t,l=this._actionsByClip[o];let c=null;if(n===void 0&&(a!==null?n=a.blendMode:n=Mr),l!==void 0){const u=l.actionByRoot[s];if(u!==void 0&&u.blendMode===n)return u;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const h=new Kd(this,a,e,n);return this._bindAction(h,c),this._addInactiveAction(h,o,s),h}existingAction(t,e){const n=e||this._root,i=n.uuid,s=typeof t=="string"?er.findByName(n,t):t,a=s?s.uuid:t,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[i]||null}stopAllAction(){const t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,s=Math.sign(t),a=this._accuIndex^=1;for(let c=0;c!==n;++c)e[c]._update(i,t,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,n=t.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const h=c._cacheIndex,u=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,e[h]=u,e.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(t){const e=t.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,l=o[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,s=i[e];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(t,e){const n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class ac{constructor(t){this.value=t}clone(){return new ac(this.value.clone===void 0?this.value:this.value.clone())}}let Wv=0;class Xv extends Sn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Wv++}),this.name="",this.usage=Es,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return e!==-1&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let n=0,i=e.length;n<i;n++){const s=Array.isArray(e[n])?e[n]:[e[n]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class qv extends $r{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class Yv{constructor(t,e,n,i,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=s,this.version=0}set needsUpdate(t){t===!0&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}}const Qd=new Rt;class Zv{constructor(t,e,n=0,i=1/0){this.ray=new Bi(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new Ir,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Qd.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Qd),this}intersectObject(t,e=!0,n=[]){return ic(t,this,n,e),n.sort(jd),n}intersectObjects(t,e=!0,n=[]){for(let i=0,s=t.length;i<s;i++)ic(t[i],this,n,e);return n.sort(jd),n}}function jd(r,t){return r.distance-t.distance}function ic(r,t,e,n){let i=!0;if(r.layers.test(t.layers)&&r.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){const s=r.children;for(let a=0,o=s.length;a<o;a++)ic(s[a],t,e,!0)}}class Jv{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(le(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class $v{constructor(t=1,e=0,n=0){return this.radius=t,this.theta=e,this.y=n,this}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return new this.constructor().copy(this)}}const tf=new Y;class Kv{constructor(t=new Y(1/0,1/0),e=new Y(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=tf.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,tf).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ef=new E,Sa=new E;class Qv{constructor(t=new E,e=new E){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){ef.subVectors(t,this.start),Sa.subVectors(this.end,this.start);const n=Sa.dot(Sa);let s=Sa.dot(ef)/n;return e&&(s=le(s,0,1)),s}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const nf=new E;class jv extends Zt{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new Ht,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,h=o/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new bt(i,3));const s=new Ne({fog:!1,toneMapped:!1});this.cone=new dn(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),nf.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(nf),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Zn=new E,ba=new Rt,sc=new Rt;class ty extends dn{constructor(t){const e=sf(t),n=new Ht,i=[],s=[],a=new pt(0,0,1),o=new pt(0,1,0);for(let c=0;c<e.length;c++){const h=e[c];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}n.setAttribute("position",new bt(i,3)),n.setAttribute("color",new bt(s,3));const l=new Ne({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,n=this.geometry,i=n.getAttribute("position");sc.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<e.length;s++){const o=e[s];o.parent&&o.parent.isBone&&(ba.multiplyMatrices(sc,o.matrixWorld),Zn.setFromMatrixPosition(ba),i.setXYZ(a,Zn.x,Zn.y,Zn.z),ba.multiplyMatrices(sc,o.parent.matrixWorld),Zn.setFromMatrixPosition(ba),i.setXYZ(a+1,Zn.x,Zn.y,Zn.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}}function sf(r){const t=[];r.isBone===!0&&t.push(r);for(let e=0;e<r.children.length;e++)t.push.apply(t,sf(r.children[e]));return t}class ey extends ge{constructor(t,e,n){const i=new ar(e,4,2),s=new Hn({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=t,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const ny=new E,rf=new pt,af=new pt;class iy extends Zt{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new rr(e);i.rotateY(Math.PI*.5),this.material=new Hn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),a=new Float32Array(s.count*3);i.setAttribute("color",new te(a,3)),this.add(new ge(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");rf.copy(this.light.color),af.copy(this.light.groundColor);for(let n=0,i=e.count;n<i;n++){const s=n<i/2?rf:af;e.setXYZ(n,s.r,s.g,s.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(ny.setFromMatrixPosition(this.light.matrixWorld).negate())}}class sy extends dn{constructor(t=10,e=10,n=4473924,i=8947848){n=new pt(n),i=new pt(i);const s=e/2,a=t/e,o=t/2,l=[],c=[];for(let d=0,f=0,m=-o;d<=e;d++,m+=a){l.push(-o,0,m,o,0,m),l.push(m,0,-o,m,0,o);const _=d===s?n:i;_.toArray(c,f),f+=3,_.toArray(c,f),f+=3,_.toArray(c,f),f+=3,_.toArray(c,f),f+=3}const h=new Ht;h.setAttribute("position",new bt(l,3)),h.setAttribute("color",new bt(c,3));const u=new Ne({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class ry extends dn{constructor(t=10,e=16,n=8,i=64,s=4473924,a=8947848){s=new pt(s),a=new pt(a);const o=[],l=[];if(e>1)for(let u=0;u<e;u++){const d=u/e*(Math.PI*2),f=Math.sin(d)*t,m=Math.cos(d)*t;o.push(0,0,0),o.push(f,0,m);const _=u&1?s:a;l.push(_.r,_.g,_.b),l.push(_.r,_.g,_.b)}for(let u=0;u<n;u++){const d=u&1?s:a,f=t-t/n*u;for(let m=0;m<i;m++){let _=m/i*(Math.PI*2),g=Math.sin(_)*f,p=Math.cos(_)*f;o.push(g,0,p),l.push(d.r,d.g,d.b),_=(m+1)/i*(Math.PI*2),g=Math.sin(_)*f,p=Math.cos(_)*f,o.push(g,0,p),l.push(d.r,d.g,d.b)}}const c=new Ht;c.setAttribute("position",new bt(o,3)),c.setAttribute("color",new bt(l,3));const h=new Ne({vertexColors:!0,toneMapped:!1});super(c,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const of=new E,Aa=new E,lf=new E;class ay extends Zt{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new Ht;i.setAttribute("position",new bt([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const s=new Ne({fog:!1,toneMapped:!1});this.lightPlane=new qn(i,s),this.add(this.lightPlane),i=new Ht,i.setAttribute("position",new bt([0,0,0,0,0,1],3)),this.targetLine=new qn(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),of.setFromMatrixPosition(this.light.matrixWorld),Aa.setFromMatrixPosition(this.light.target.matrixWorld),lf.subVectors(Aa,of),this.lightPlane.lookAt(Aa),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Aa),this.targetLine.scale.z=lf.length()}}const wa=new E,ce=new Gr;class oy extends dn{constructor(t){const e=new Ht,n=new Ne({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(m,_){l(m),l(_)}function l(m){i.push(0,0,0),s.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(i.length/3-1)}e.setAttribute("position",new bt(i,3)),e.setAttribute("color",new bt(s,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new pt(16755200),h=new pt(16711680),u=new pt(43775),d=new pt(16777215),f=new pt(3355443);this.setColors(c,h,u,d,f)}setColors(t,e,n,i,s){const o=this.geometry.getAttribute("color");o.setXYZ(0,t.r,t.g,t.b),o.setXYZ(1,t.r,t.g,t.b),o.setXYZ(2,t.r,t.g,t.b),o.setXYZ(3,t.r,t.g,t.b),o.setXYZ(4,t.r,t.g,t.b),o.setXYZ(5,t.r,t.g,t.b),o.setXYZ(6,t.r,t.g,t.b),o.setXYZ(7,t.r,t.g,t.b),o.setXYZ(8,t.r,t.g,t.b),o.setXYZ(9,t.r,t.g,t.b),o.setXYZ(10,t.r,t.g,t.b),o.setXYZ(11,t.r,t.g,t.b),o.setXYZ(12,t.r,t.g,t.b),o.setXYZ(13,t.r,t.g,t.b),o.setXYZ(14,t.r,t.g,t.b),o.setXYZ(15,t.r,t.g,t.b),o.setXYZ(16,t.r,t.g,t.b),o.setXYZ(17,t.r,t.g,t.b),o.setXYZ(18,t.r,t.g,t.b),o.setXYZ(19,t.r,t.g,t.b),o.setXYZ(20,t.r,t.g,t.b),o.setXYZ(21,t.r,t.g,t.b),o.setXYZ(22,t.r,t.g,t.b),o.setXYZ(23,t.r,t.g,t.b),o.setXYZ(24,e.r,e.g,e.b),o.setXYZ(25,e.r,e.g,e.b),o.setXYZ(26,e.r,e.g,e.b),o.setXYZ(27,e.r,e.g,e.b),o.setXYZ(28,e.r,e.g,e.b),o.setXYZ(29,e.r,e.g,e.b),o.setXYZ(30,e.r,e.g,e.b),o.setXYZ(31,e.r,e.g,e.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,i.r,i.g,i.b),o.setXYZ(39,i.r,i.g,i.b),o.setXYZ(40,s.r,s.g,s.b),o.setXYZ(41,s.r,s.g,s.b),o.setXYZ(42,s.r,s.g,s.b),o.setXYZ(43,s.r,s.g,s.b),o.setXYZ(44,s.r,s.g,s.b),o.setXYZ(45,s.r,s.g,s.b),o.setXYZ(46,s.r,s.g,s.b),o.setXYZ(47,s.r,s.g,s.b),o.setXYZ(48,s.r,s.g,s.b),o.setXYZ(49,s.r,s.g,s.b),o.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap,n=1,i=1;ce.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),fe("c",e,t,ce,0,0,-1),fe("t",e,t,ce,0,0,1),fe("n1",e,t,ce,-n,-i,-1),fe("n2",e,t,ce,n,-i,-1),fe("n3",e,t,ce,-n,i,-1),fe("n4",e,t,ce,n,i,-1),fe("f1",e,t,ce,-n,-i,1),fe("f2",e,t,ce,n,-i,1),fe("f3",e,t,ce,-n,i,1),fe("f4",e,t,ce,n,i,1),fe("u1",e,t,ce,n*.7,i*1.1,-1),fe("u2",e,t,ce,-n*.7,i*1.1,-1),fe("u3",e,t,ce,0,i*2,-1),fe("cf1",e,t,ce,-n,0,1),fe("cf2",e,t,ce,n,0,1),fe("cf3",e,t,ce,0,-i,1),fe("cf4",e,t,ce,0,i,1),fe("cn1",e,t,ce,-n,0,-1),fe("cn2",e,t,ce,n,0,-1),fe("cn3",e,t,ce,0,-i,-1),fe("cn4",e,t,ce,0,i,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function fe(r,t,e,n,i,s,a){wa.set(i,s,a).unproject(n);const o=t[r];if(o!==void 0){const l=e.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],wa.x,wa.y,wa.z)}}const Ea=new Le;class ly extends dn{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(8*3),s=new Ht;s.setIndex(new te(n,1)),s.setAttribute("position",new te(i,3)),super(s,new Ne({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(t!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Ea.setFromObject(this.object),Ea.isEmpty())return;const e=Ea.min,n=Ea.max,i=this.geometry.attributes.position,s=i.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=e.x,s[4]=n.y,s[5]=n.z,s[6]=e.x,s[7]=e.y,s[8]=n.z,s[9]=n.x,s[10]=e.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=e.z,s[15]=e.x,s[16]=n.y,s[17]=e.z,s[18]=e.x,s[19]=e.y,s[20]=e.z,s[21]=n.x,s[22]=e.y,s[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class cy extends dn{constructor(t,e=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ht;s.setIndex(new te(n,1)),s.setAttribute("position",new bt(i,3)),super(s,new Ne({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class hy extends qn{constructor(t,e=1,n=16776960){const i=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Ht;a.setAttribute("position",new bt(s,3)),a.computeBoundingSphere(),super(a,new Ne({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Ht;l.setAttribute("position",new bt(o,3)),l.computeBoundingSphere(),this.add(new ge(l,new Hn({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const cf=new E;let Ta,rc;class uy extends Zt{constructor(t=new E(0,0,1),e=new E(0,0,0),n=1,i=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Ta===void 0&&(Ta=new Ht,Ta.setAttribute("position",new bt([0,0,0,0,1,0],3)),rc=new hs(0,.5,1,5,1),rc.translate(0,-.5,0)),this.position.copy(e),this.line=new qn(Ta,new Ne({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ge(rc,new Hn({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,s,a)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{cf.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(cf,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class dy extends dn{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ht;i.setAttribute("position",new bt(e,3)),i.setAttribute("color",new bt(n,3));const s=new Ne({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){const i=new pt,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class fy{constructor(){this.type="ShapePath",this.color=new pt,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Ys,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,s,a){return this.currentPath.bezierCurveTo(t,e,n,i,s,a),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(p){const v=[];for(let x=0,y=p.length;x<y;x++){const P=p[x],w=new _i;w.curves=P.curves,v.push(w)}return v}function n(p,v){const x=v.length;let y=!1;for(let P=x-1,w=0;w<x;P=w++){let T=v[P],R=v[w],b=R.x-T.x,M=R.y-T.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(T=v[w],b=-b,R=v[P],M=-M),p.y<T.y||p.y>R.y)continue;if(p.y===T.y){if(p.x===T.x)return!0}else{const I=M*(p.x-T.x)-b*(p.y-T.y);if(I===0)return!0;if(I<0)continue;y=!y}}else{if(p.y!==T.y)continue;if(R.x<=p.x&&p.x<=T.x||T.x<=p.x&&p.x<=R.x)return!0}}return y}const i=fn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new _i,l.curves=o.curves,c.push(l),c;let h=!i(s[0].getPoints());h=t?!h:h;const u=[],d=[];let f=[],m=0,_;d[m]=void 0,f[m]=[];for(let p=0,v=s.length;p<v;p++)o=s[p],_=o.getPoints(),a=i(_),a=t?!a:a,a?(!h&&d[m]&&m++,d[m]={s:new _i,p:_},d[m].s.curves=o.curves,h&&m++,f[m]=[]):f[m].push({h:o,p:_[0]});if(!d[0])return e(s);if(d.length>1){let p=!1,v=0;for(let x=0,y=d.length;x<y;x++)u[x]=[];for(let x=0,y=d.length;x<y;x++){const P=f[x];for(let w=0;w<P.length;w++){const T=P[w];let R=!0;for(let b=0;b<d.length;b++)n(T.p,d[b].p)&&(x!==b&&v++,R?(R=!1,u[b].push(T)):p=!0);R&&u[x].push(T)}}v>0&&p===!1&&(f=u)}let g;for(let p=0,v=d.length;p<v;p++){l=d[p].s,c.push(l),g=f[p];for(let x=0,y=g.length;x<y;x++)l.holes.push(g[x].h)}return c}}class py extends Ke{constructor(t=1,e=1,n=1,i={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(t,e,{...i,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:hr}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=hr);export{qc as ACESFilmicToneMapping,Dn as AddEquation,Hc as AddOperation,No as AdditiveAnimationBlendMode,$a as AdditiveBlending,Zc as AgXToneMapping,th as AlphaFormat,xh as AlwaysCompare,Nc as AlwaysDepth,Fo as AlwaysStencilFunc,Nd as AmbientLight,Kd as AnimationAction,er as AnimationClip,pv as AnimationLoader,Gv as AnimationMixer,Vv as AnimationObjectGroup,hv as AnimationUtils,Ku as ArcCurve,Su as ArrayCamera,uy as ArrowHelper,ja as AttachedBindMode,Zd as Audio,Iv as AudioAnalyser,tc as AudioContext,Cv as AudioListener,wv as AudioLoader,dy as AxesHelper,Pe as BackSide,ch as BasicDepthPacking,_f as BasicShadowMap,Hu as BatchedMesh,wl as Bone,yi as BooleanKeyframeTrack,Kv as Box2,Le as Box3,cy as Box3Helper,Ti as BoxGeometry,ly as BoxHelper,te as BufferAttribute,Ht as BufferGeometry,kd as BufferGeometryLoader,Kc as ByteType,Pn as Cache,Gr as Camera,oy as CameraHelper,Dx as CanvasTexture,Ia as CapsuleGeometry,Qu as CatmullRomCurve3,Xc as CineonToneMapping,La as CircleGeometry,Ze as ClampToEdgeWrapping,Xd as Clock,pt as Color,Zl as ColorKeyframeTrack,Kt as ColorManagement,Lx as CompressedArrayTexture,Ux as CompressedCubeTexture,ua as CompressedTexture,mv as CompressedTextureLoader,Ua as ConeGeometry,Lc as ConstantAlphaFactor,Pc as ConstantColorFactor,qh as CubeCamera,xn as CubeReflectionMapping,Nn as CubeRefractionMapping,Ns as CubeTexture,gv as CubeTextureLoader,Ri as CubeUVReflectionMapping,Fl as CubicBezierCurve,td as CubicBezierCurve3,Ad as CubicInterpolant,Za as CullFaceBack,pc as CullFaceFront,gf as CullFaceFrontBack,fc as CullFaceNone,sn as Curve,nd as CurvePath,gc as CustomBlending,Yc as CustomToneMapping,hs as CylinderGeometry,$v as Cylindrical,Wo as Data3DTexture,Ar as DataArrayTexture,Rn as DataTexture,_v as DataTextureLoader,Tp as DataUtils,Cf as DecrementStencilOp,Pf as DecrementWrapStencilOp,Td as DefaultLoadingManager,ei as DepthFormat,ni as DepthStencilFormat,ml as DepthTexture,$c as DetachedBindMode,Dd as DirectionalLight,ay as DirectionalLightHelper,wd as DiscreteInterpolant,Sr as DisplayP3ColorSpace,Da as DodecahedronGeometry,cn as DoubleSide,wc as DstAlphaFactor,Tc as DstColorFactor,Xf as DynamicCopyUsage,zf as DynamicDrawUsage,Hf as DynamicReadUsage,id as EdgesGeometry,da as EllipseCurve,ph as EqualCompare,Oc as EqualDepth,Df as EqualStencilFunc,fs as EquirectangularReflectionMapping,ps as EquirectangularRefractionMapping,Xe as Euler,Sn as EventDispatcher,Na as ExtrudeGeometry,Ln as FileLoader,Up as Float16BufferAttribute,bt as Float32BufferAttribute,Ve as FloatType,Ra as Fog,Ca as FogExp2,Ix as FramebufferTexture,mn as FrontSide,Fs as Frustum,Yv as GLBufferAttribute,Yf as GLSL1,Bo as GLSL3,mh as GreaterCompare,zc as GreaterDepth,_h as GreaterEqualCompare,Bc as GreaterEqualDepth,Bf as GreaterEqualStencilFunc,Ff as GreaterStencilFunc,sy as GridHelper,ts as Group,vs as HalfFloatType,Cd as HemisphereLight,iy as HemisphereLightHelper,Fa as IcosahedronGeometry,Av as ImageBitmapLoader,nr as ImageLoader,wh as ImageUtils,Tf as IncrementStencilOp,Rf as IncrementWrapStencilOp,rs as InstancedBufferAttribute,zd as InstancedBufferGeometry,qv as InstancedInterleavedBuffer,zu as InstancedMesh,Ip as Int16BufferAttribute,Lp as Int32BufferAttribute,Cp as Int8BufferAttribute,eo as IntType,$r as InterleavedBuffer,Ci as InterleavedBufferAttribute,Ks as Interpolant,ys as InterpolateDiscrete,vr as InterpolateLinear,yr as InterpolateSmooth,If as InvertStencilOp,ri as KeepStencilOp,rn as KeyframeTrack,Ru as LOD,sr as LatheGeometry,Ir as Layers,fh as LessCompare,Fc as LessDepth,Oo as LessEqualCompare,us as LessEqualDepth,Nf as LessEqualStencilFunc,Uf as LessStencilFunc,Yn as Light,Bd as LightProbe,qn as Line,Qv as Line3,Ne as LineBasicMaterial,Ol as LineCurve,ed as LineCurve3,Md as LineDashedMaterial,Yu as LineLoop,dn as LineSegments,Ss as LinearDisplayP3ColorSpace,pe as LinearFilter,Yl as LinearInterpolant,Mf as LinearMipMapLinearFilter,yf as LinearMipMapNearestFilter,hn as LinearMipmapLinearFilter,_s as LinearMipmapNearestFilter,Mn as LinearSRGBColorSpace,Gc as LinearToneMapping,bs as LinearTransfer,ze as Loader,jl as LoaderUtils,Jl as LoadingManager,ah as LoopOnce,lh as LoopPingPong,oh as LoopRepeat,ih as LuminanceAlphaFormat,nh as LuminanceFormat,pf as MOUSE,Te as Material,Ga as MaterialLoader,hp as MathUtils,Bt as Matrix3,Rt as Matrix4,yc as MaxEquation,ge as Mesh,Hn as MeshBasicMaterial,xl as MeshDepthMaterial,vl as MeshDistanceMaterial,vd as MeshLambertMaterial,yd as MeshMatcapMaterial,xd as MeshNormalMaterial,gd as MeshPhongMaterial,md as MeshPhysicalMaterial,Wl as MeshStandardMaterial,_d as MeshToonMaterial,vc as MinEquation,gs as MirroredRepeatWrapping,Vc as MixOperation,Qa as MultiplyBlending,ds as MultiplyOperation,Me as NearestFilter,vf as NearestMipMapLinearFilter,xf as NearestMipMapNearestFilter,Pi as NearestMipmapLinearFilter,to as NearestMipmapNearestFilter,Jc as NeutralToneMapping,dh as NeverCompare,Dc as NeverDepth,Lf as NeverStencilFunc,gn as NoBlending,yn as NoColorSpace,_n as NoToneMapping,Mr as NormalAnimationBlendMode,Qn as NormalBlending,gh as NotEqualCompare,kc as NotEqualDepth,Of as NotEqualStencilFunc,Qs as NumberKeyframeTrack,Zt as Object3D,Sv as ObjectLoader,uh as ObjectSpaceNormalMap,rr as OctahedronGeometry,Sc as OneFactor,Uc as OneMinusConstantAlphaFactor,Ic as OneMinusConstantColorFactor,Ec as OneMinusDstAlphaFactor,Cc as OneMinusDstColorFactor,dr as OneMinusSrcAlphaFactor,Ac as OneMinusSrcColorFactor,qr as OrthographicCamera,ws as P3Primaries,Ja as PCFShadowMap,mc as PCFSoftShadowMap,fl as PMREMGenerator,Ys as Path,be as PerspectiveCamera,Wn as Plane,cs as PlaneGeometry,hy as PlaneHelper,Ud as PointLight,ey as PointLightHelper,Ju as Points,Pl as PointsMaterial,ry as PolarGridHelper,Jn as PolyhedronGeometry,Pv as PositionalAudio,Yt as PropertyBinding,$d as PropertyMixer,Bl as QuadraticBezierCurve,zl as QuadraticBezierCurve3,Oe as Quaternion,js as QuaternionKeyframeTrack,Ed as QuaternionLinearInterpolant,Uo as RED_GREEN_RGTC2_Format,rh as RED_RGTC1_Format,hr as REVISION,hh as RGBADepthPacking,Fe as RGBAFormat,oo as RGBAIntegerFormat,To as RGBA_ASTC_10x10_Format,Ao as RGBA_ASTC_10x5_Format,wo as RGBA_ASTC_10x6_Format,Eo as RGBA_ASTC_10x8_Format,Co as RGBA_ASTC_12x10_Format,Ro as RGBA_ASTC_12x12_Format,go as RGBA_ASTC_4x4_Format,_o as RGBA_ASTC_5x4_Format,xo as RGBA_ASTC_5x5_Format,vo as RGBA_ASTC_6x5_Format,yo as RGBA_ASTC_6x6_Format,Mo as RGBA_ASTC_8x5_Format,So as RGBA_ASTC_8x6_Format,bo as RGBA_ASTC_8x8_Format,xr as RGBA_BPTC_Format,mo as RGBA_ETC2_EAC_Format,uo as RGBA_PVRTC_2BPPV1_Format,ho as RGBA_PVRTC_4BPPV1_Format,mr as RGBA_S3TC_DXT1_Format,gr as RGBA_S3TC_DXT3_Format,_r as RGBA_S3TC_DXT5_Format,eh as RGBFormat,Po as RGB_BPTC_SIGNED_Format,Io as RGB_BPTC_UNSIGNED_Format,fo as RGB_ETC1_Format,po as RGB_ETC2_Format,co as RGB_PVRTC_2BPPV1_Format,lo as RGB_PVRTC_4BPPV1_Format,pr as RGB_S3TC_DXT1_Format,sh as RGFormat,ao as RGIntegerFormat,pd as RawShaderMaterial,Bi as Ray,Zv as Raycaster,As as Rec709Primaries,Fd as RectAreaLight,so as RedFormat,ro as RedIntegerFormat,Wc as ReinhardToneMapping,Eh as RenderTarget,ms as RepeatWrapping,Ef as ReplaceStencilOp,xc as ReverseSubtractEquation,Oa as RingGeometry,Do as SIGNED_RED_GREEN_RGTC2_Format,Lo as SIGNED_RED_RGTC1_Format,Je as SRGBColorSpace,se as SRGBTransfer,bu as Scene,Vt as ShaderChunk,nn as ShaderLib,en as ShaderMaterial,fd as ShadowMaterial,_i as Shape,Ba as ShapeGeometry,fy as ShapePath,fn as ShapeUtils,Qc as ShortType,Pa as Skeleton,ty as SkeletonHelper,Nu as SkinnedMesh,oi as Source,we as Sphere,ar as SphereGeometry,Jv as Spherical,Od as SphericalHarmonics3,kl as SplineCurve,Id as SpotLight,jv as SpotLightHelper,Tu as Sprite,Ml as SpriteMaterial,ur as SrcAlphaFactor,Rc as SrcAlphaSaturateFactor,bc as SrcColorFactor,Wf as StaticCopyUsage,Es as StaticDrawUsage,Vf as StaticReadUsage,Ev as StereoCamera,qf as StreamCopyUsage,kf as StreamDrawUsage,Gf as StreamReadUsage,Mi as StringKeyframeTrack,_c as SubtractEquation,Ka as SubtractiveBlending,mf as TOUCH,Fn as TangentSpaceNormalMap,za as TetrahedronGeometry,he as Texture,xv as TextureLoader,ka as TorusGeometry,Va as TorusKnotGeometry,qe as Triangle,Af as TriangleFanDrawMode,bf as TriangleStripDrawMode,Sf as TrianglesDrawMode,Ha as TubeGeometry,fr as UVMapping,il as Uint16BufferAttribute,sl as Uint32BufferAttribute,Rp as Uint8BufferAttribute,Pp as Uint8ClampedBufferAttribute,ac as Uniform,Xv as UniformsGroup,ct as UniformsLib,Gh as UniformsUtils,vn as UnsignedByteType,ti as UnsignedInt248Type,jc as UnsignedInt5999Type,jn as UnsignedIntType,no as UnsignedShort4444Type,io as UnsignedShort5551Type,xs as UnsignedShortType,ln as VSMShadowMap,Y as Vector2,E as Vector3,ee as Vector4,tr as VectorKeyframeTrack,Px as VideoTexture,_p as WebGL3DRenderTarget,gp as WebGLArrayRenderTarget,un as WebGLCoordinateSystem,Yh as WebGLCubeRenderTarget,py as WebGLMultipleRenderTargets,Ke as WebGLRenderTarget,vx as WebGLRenderer,Mu as WebGLUtils,Ts as WebGPUCoordinateSystem,hd as WireframeGeometry,Ms as WrapAroundEnding,ii as ZeroCurvatureEnding,Mc as ZeroFactor,si as ZeroSlopeEnding,wf as ZeroStencilOp,Mh as createCanvasElement};