index-a7a577f3.js 697 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494
  1. var Ec=Object.defineProperty;var Lc=(e,t,i)=>t in e?Ec(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var wi=(e,t,i)=>(Lc(e,typeof t!="symbol"?t+"":t,i),i);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=t(n);fetch(n.href,r)}})();const ca="125",Pc=0,ha=1,Rc=2,ua=1,da=2,$n=3,Gt=0,Ze=1,on=2,pa=1,er=0,Bi=1,ko=2,fa=3,ma=4,Cc=5,sn=100,Nc=101,Ic=102,ga=103,va=104,Fc=200,Oc=201,Dc=202,Uc=203,_a=204,xa=205,zc=206,kc=207,Hc=208,Bc=209,Gc=210,Vc=0,Wc=1,jc=2,Ho=3,Xc=4,Yc=5,qc=6,Qc=7,Or=0,Zc=1,Jc=2,tr=0,Kc=1,$c=2,eh=3,th=4,ih=5,ya=300,Bo=301,Go=302,ba=303,wa=304,Vo=306,Wo=307,Mi=1e3,ut=1001,Dr=1002,rt=1003,jo=1004,Xo=1005,qe=1006,Ma=1007,an=1008,Ta=1008,Ur=1009,nh=1010,rh=1011,zr=1012,oh=1013,ir=1014,li=1015,kr=1016,sh=1017,ah=1018,lh=1019,nr=1020,ch=1021,Ti=1022,wt=1023,hh=1024,uh=1025,Gi=1026,rr=1027,dh=1028,ph=1029,fh=1030,mh=1031,gh=1032,vh=1033,Aa=33776,Sa=33777,Ea=33778,La=33779,Pa=35840,Ra=35841,Ca=35842,Na=35843,_h=36196,Ia=37492,Fa=37496,xh=37808,yh=37809,bh=37810,wh=37811,Mh=37812,Th=37813,Ah=37814,Sh=37815,Eh=37816,Lh=37817,Ph=37818,Rh=37819,Ch=37820,Nh=37821,Ih=36492,Fh=37840,Oh=37841,Dh=37842,Uh=37843,zh=37844,kh=37845,Hh=37846,Bh=37847,Gh=37848,Vh=37849,Wh=37850,jh=37851,Xh=37852,Yh=37853,Yo=2200,qh=2201,Qh=2202,or=2300,ln=2301,qo=2302,cn=2400,hn=2401,Hr=2402,Qo=2500,Oa=2501,Zh=0,Jh=1,Da=2,sr=3e3,Vi=3001,Kh=3007,$h=3002,eu=3003,tu=3004,iu=3005,nu=3006,ru=3200,ou=3201,Wi=0,su=1,Zo=7680,au=519,Br=35044,ar=35048,Ua="300 es";function ci(){}Object.assign(ci.prototype,{addEventListener:function(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)},hasEventListener:function(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1},removeEventListener:function(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const n=i.indexOf(t);n!==-1&&i.splice(n,1)}},dispatchEvent:function(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const i=t.slice(0);for(let n=0,r=i.length;n<r;n++)i[n].call(this,e)}}});const at=[];for(let e=0;e<256;e++)at[e]=(e<16?"0":"")+e.toString(16);let Gr=1234567;const Se={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(at[e&255]+at[e>>8&255]+at[e>>16&255]+at[e>>24&255]+"-"+at[t&255]+at[t>>8&255]+"-"+at[t>>16&15|64]+at[t>>24&255]+"-"+at[i&63|128]+at[i>>8&255]+"-"+at[i>>16&255]+at[i>>24&255]+at[n&255]+at[n>>8&255]+at[n>>16&255]+at[n>>24&255]).toUpperCase()},clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},damp:function(e,t,i,n){return Se.lerp(e,t,1-Math.exp(-i*n))},pingpong:function(e,t=1){return t-Math.abs(Se.euclideanModulo(e,t*2)-t)},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(e*6-15)+10))},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return e!==void 0&&(Gr=e%2147483647),Gr=Gr*16807%2147483647,(Gr-1)/2147483646},degToRad:function(e){return e*Se.DEG2RAD},radToDeg:function(e){return e*Se.RAD2DEG},isPowerOfTwo:function(e){return(e&e-1)===0&&e!==0},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,i,n,r){const o=Math.cos,s=Math.sin,a=o(i/2),l=s(i/2),c=o((t+n)/2),h=s((t+n)/2),u=o((t-n)/2),d=s((t-n)/2),f=o((n-t)/2),m=s((n-t)/2);switch(r){case"XYX":e.set(a*h,l*u,l*d,a*c);break;case"YZY":e.set(l*d,a*h,l*u,a*c);break;case"ZXZ":e.set(l*u,l*d,a*h,a*c);break;case"XZX":e.set(a*h,l*m,l*f,a*c);break;case"YXY":e.set(l*f,a*h,l*m,a*c);break;case"ZYZ":e.set(l*m,l*f,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class le{constructor(t=0,i=0){Object.defineProperty(this,"isVector2",{value:!0}),this.x=t,this.y=i}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,i){return this.x=t,this.y=i,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,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;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,i){return i!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,i)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this}sub(t,i){return i!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,i)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.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 i=this.x,n=this.y,r=t.elements;return this.x=r[0]*i+r[3]*n+r[6],this.y=r[1]*i+r[4]*n+r[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,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this}clampLength(t,i){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(i,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,n=this.y-t.y;return i*i+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,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this}lerpVectors(t,i,n){return this.x=t.x+(i.x-t.x)*n,this.y=t.y+(i.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t}fromBufferAttribute(t,i,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(i),this.y=t.getY(i),this}rotateAround(t,i){const n=Math.cos(i),r=Math.sin(i),o=this.x-t.x,s=this.y-t.y;return this.x=o*n-s*r+t.x,this.y=o*r+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}class Ft{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,i,n,r,o,s,a,l,c){const h=this.elements;return h[0]=t,h[1]=r,h[2]=a,h[3]=i,h[4]=o,h[5]=l,h[6]=n,h[7]=s,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return new this.constructor().fromArray(this.elements)}copy(t){const i=this.elements,n=t.elements;return i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=n[3],i[4]=n[4],i[5]=n[5],i[6]=n[6],i[7]=n[7],i[8]=n[8],this}extractBasis(t,i,n){return t.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const i=t.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const n=t.elements,r=i.elements,o=this.elements,s=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],v=r[0],_=r[3],g=r[6],p=r[1],E=r[4],S=r[7],T=r[2],x=r[5],L=r[8];return o[0]=s*v+a*p+l*T,o[3]=s*_+a*E+l*x,o[6]=s*g+a*S+l*L,o[1]=c*v+h*p+u*T,o[4]=c*_+h*E+u*x,o[7]=c*g+h*S+u*L,o[2]=d*v+f*p+m*T,o[5]=d*_+f*E+m*x,o[8]=d*g+f*S+m*L,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=t,i[4]*=t,i[7]*=t,i[2]*=t,i[5]*=t,i[8]*=t,this}determinant(){const t=this.elements,i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return i*s*h-i*a*c-n*o*h+n*a*l+r*o*c-r*s*l}invert(){const t=this.elements,i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*s-a*c,d=a*l-h*o,f=c*o-s*l,m=i*u+n*d+r*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return t[0]=u*v,t[1]=(r*c-h*n)*v,t[2]=(a*n-r*s)*v,t[3]=d*v,t[4]=(h*i-r*l)*v,t[5]=(r*o-a*i)*v,t[6]=f*v,t[7]=(n*l-c*i)*v,t[8]=(s*i-n*o)*v,this}transpose(){let t;const i=this.elements;return t=i[1],i[1]=i[3],i[3]=t,t=i[2],i[2]=i[6],i[6]=t,t=i[5],i[5]=i[7],i[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).copy(this).invert().transpose()}transposeIntoArray(t){const i=this.elements;return t[0]=i[0],t[1]=i[3],t[2]=i[6],t[3]=i[1],t[4]=i[4],t[5]=i[7],t[6]=i[2],t[7]=i[5],t[8]=i[8],this}setUvTransform(t,i,n,r,o,s,a){const l=Math.cos(o),c=Math.sin(o);return this.set(n*l,n*c,-n*(l*s+c*a)+s+t,-r*c,r*l,-r*(-c*s+l*a)+a+i,0,0,1),this}scale(t,i){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=i,n[4]*=i,n[7]*=i,this}rotate(t){const i=Math.cos(t),n=Math.sin(t),r=this.elements,o=r[0],s=r[3],a=r[6],l=r[1],c=r[4],h=r[7];return r[0]=i*o+n*l,r[3]=i*s+n*c,r[6]=i*a+n*h,r[1]=-n*o+i*l,r[4]=-n*s+i*c,r[7]=-n*a+i*h,this}translate(t,i){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=i*n[2],n[4]+=i*n[5],n[7]+=i*n[8],this}equals(t){const i=this.elements,n=t.elements;for(let r=0;r<9;r++)if(i[r]!==n[r])return!1;return!0}fromArray(t,i=0){for(let n=0;n<9;n++)this.elements[n]=t[n+i];return this}toArray(t=[],i=0){const n=this.elements;return t[i]=n[0],t[i+1]=n[1],t[i+2]=n[2],t[i+3]=n[3],t[i+4]=n[4],t[i+5]=n[5],t[i+6]=n[6],t[i+7]=n[7],t[i+8]=n[8],t}}let un;const dn={getDataURL:function(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{un===void 0&&(un=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),un.width=e.width,un.height=e.height;const i=un.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=un}return t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}};let lu=0;function He(e=He.DEFAULT_IMAGE,t=He.DEFAULT_MAPPING,i=ut,n=ut,r=qe,o=an,s=wt,a=Ur,l=1,c=sr){Object.defineProperty(this,"id",{value:lu++}),this.uuid=Se.generateUUID(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new le(0,0),this.repeat=new le(1,1),this.center=new le(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ft,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null}He.DEFAULT_IMAGE=void 0,He.DEFAULT_MAPPING=ya,He.prototype=Object.assign(Object.create(ci.prototype),{constructor:He,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){const n=this.image;if(n.uuid===void 0&&(n.uuid=Se.generateUUID()),!t&&e.images[n.uuid]===void 0){let r;if(Array.isArray(n)){r=[];for(let o=0,s=n.length;o<s;o++)n[o].isDataTexture?r.push(Jo(n[o].image)):r.push(Jo(n[o]))}else r=Jo(n);e.images[n.uuid]={uuid:n.uuid,url:r}}i.image=n.uuid}return t||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping!==ya)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Mi:e.x=e.x-Math.floor(e.x);break;case ut:e.x=e.x<0?0:1;break;case Dr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Mi:e.y=e.y-Math.floor(e.y);break;case ut:e.y=e.y<0?0:1;break;case Dr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(He.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}});function Jo(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap?dn.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}class ke{constructor(t=0,i=0,n=0,r=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=t,this.y=i,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,i,n,r){return this.x=t,this.y=i,this.z=n,this.w=r,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,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;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,i){return i!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,i)):(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,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this.w=t.w+i.w,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this.w+=t.w*i,this}sub(t,i){return i!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,i)):(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,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this.w=t.w-i.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 i=this.x,n=this.y,r=this.z,o=this.w,s=t.elements;return this.x=s[0]*i+s[4]*n+s[8]*r+s[12]*o,this.y=s[1]*i+s[5]*n+s[9]*r+s[13]*o,this.z=s[2]*i+s[6]*n+s[10]*r+s[14]*o,this.w=s[3]*i+s[7]*n+s[11]*r+s[15]*o,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const i=Math.sqrt(1-t.w*t.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/i,this.y=t.y/i,this.z=t.z/i),this}setAxisAngleFromRotationMatrix(t){let i,n,r,o;const s=t.elements,a=s[0],l=s[4],c=s[8],h=s[1],u=s[5],d=s[9],f=s[2],m=s[6],v=s[10];if(Math.abs(l-h)<.01&&Math.abs(c-f)<.01&&Math.abs(d-m)<.01){if(Math.abs(l+h)<.1&&Math.abs(c+f)<.1&&Math.abs(d+m)<.1&&Math.abs(a+u+v-3)<.1)return this.set(1,0,0,0),this;i=Math.PI;const g=(a+1)/2,p=(u+1)/2,E=(v+1)/2,S=(l+h)/4,T=(c+f)/4,x=(d+m)/4;return g>p&&g>E?g<.01?(n=0,r=.707106781,o=.707106781):(n=Math.sqrt(g),r=S/n,o=T/n):p>E?p<.01?(n=.707106781,r=0,o=.707106781):(r=Math.sqrt(p),n=S/r,o=x/r):E<.01?(n=.707106781,r=.707106781,o=0):(o=Math.sqrt(E),n=T/o,r=x/o),this.set(n,r,o,i),this}let _=Math.sqrt((m-d)*(m-d)+(c-f)*(c-f)+(h-l)*(h-l));return Math.abs(_)<.001&&(_=1),this.x=(m-d)/_,this.y=(c-f)/_,this.z=(h-l)/_,this.w=Math.acos((a+u+v-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,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this.w=Math.max(t.w,Math.min(i.w,this.w)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this.w=Math.max(t,Math.min(i,this.w)),this}clampLength(t,i){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(i,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(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,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this.w+=(t.w-this.w)*i,this}lerpVectors(t,i,n){return this.x=t.x+(i.x-t.x)*n,this.y=t.y+(i.y-t.y)*n,this.z=t.z+(i.z-t.z)*n,this.w=t.w+(i.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,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this.w=t[i+3],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,t}fromBufferAttribute(t,i,n){return n!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this.w=t.getW(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}class ji extends ci{constructor(t,i,n){super(),Object.defineProperty(this,"isWebGLRenderTarget",{value:!0}),this.width=t,this.height=i,this.scissor=new ke(0,0,t,i),this.scissorTest=!1,this.viewport=new ke(0,0,t,i),n=n||{},this.texture=new He(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=i,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:qe,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null}setSize(t,i){(this.width!==t||this.height!==i)&&(this.width=t,this.height=i,this.texture.image.width=t,this.texture.image.height=i,this.dispose()),this.viewport.set(0,0,t,i),this.scissor.set(0,0,t,i)}clone(){return new this.constructor().copy(this)}copy(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class tt{constructor(t=0,i=0,n=0,r=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=t,this._y=i,this._z=n,this._w=r}static slerp(t,i,n,r){return n.copy(t).slerp(i,r)}static slerpFlat(t,i,n,r,o,s,a){let l=n[r+0],c=n[r+1],h=n[r+2],u=n[r+3];const d=o[s+0],f=o[s+1],m=o[s+2],v=o[s+3];if(u!==v||l!==d||c!==f||h!==m){let _=1-a;const g=l*d+c*f+h*m+u*v,p=g>=0?1:-1,E=1-g*g;if(E>Number.EPSILON){const T=Math.sqrt(E),x=Math.atan2(T,g*p);_=Math.sin(_*x)/T,a=Math.sin(a*x)/T}const S=a*p;if(l=l*_+d*S,c=c*_+f*S,h=h*_+m*S,u=u*_+v*S,_===1-a){const T=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=T,c*=T,h*=T,u*=T}}t[i]=l,t[i+1]=c,t[i+2]=h,t[i+3]=u}static multiplyQuaternionsFlat(t,i,n,r,o,s){const a=n[r],l=n[r+1],c=n[r+2],h=n[r+3],u=o[s],d=o[s+1],f=o[s+2],m=o[s+3];return t[i]=a*m+h*u+l*f-c*d,t[i+1]=l*m+h*d+c*u-a*f,t[i+2]=c*m+h*f+a*d-l*u,t[i+3]=h*m-a*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,i,n,r){return this._x=t,this._y=i,this._z=n,this._w=r,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,i){if(!(t&&t.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=t._x,r=t._y,o=t._z,s=t._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(r/2),u=a(o/2),d=l(n/2),f=l(r/2),m=l(o/2);switch(s){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: "+s)}return i!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,i){const n=i/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const i=t.elements,n=i[0],r=i[4],o=i[8],s=i[1],a=i[5],l=i[9],c=i[2],h=i[6],u=i[10],d=n+a+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(o-c)*f,this._z=(s-r)*f}else if(n>a&&n>u){const f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(r+s)/f,this._z=(o+c)/f}else if(a>u){const f=2*Math.sqrt(1+a-n-u);this._w=(o-c)/f,this._x=(r+s)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-a);this._w=(s-r)/f,this._x=(o+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,i){let n=t.dot(i)+1;return n<1e-6?(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*i.z-t.z*i.y,this._y=t.z*i.x-t.x*i.z,this._z=t.x*i.y-t.y*i.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Se.clamp(this.dot(t),-1,1)))}rotateTowards(t,i){const n=this.angleTo(t);if(n===0)return this;const r=Math.min(1,i/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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,i){return i!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,i)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,i){const n=t._x,r=t._y,o=t._z,s=t._w,a=i._x,l=i._y,c=i._z,h=i._w;return this._x=n*h+s*a+r*c-o*l,this._y=r*h+s*l+o*a-n*c,this._z=o*h+s*c+n*l-r*a,this._w=s*h-n*a-r*l-o*c,this._onChangeCallback(),this}slerp(t,i){if(i===0)return this;if(i===1)return this.copy(t);const n=this._x,r=this._y,o=this._z,s=this._w;let a=s*t._w+n*t._x+r*t._y+o*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=r,this._z=o,this;const l=1-a*a;if(l<=Number.EPSILON){const f=1-i;return this._w=f*s+i*this._w,this._x=f*n+i*this._x,this._y=f*r+i*this._y,this._z=f*o+i*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),u=Math.sin((1-i)*h)/c,d=Math.sin(i*h)/c;return this._w=s*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=o*u+this._z*d,this._onChangeCallback(),this}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,i=0){return this._x=t[i],this._y=t[i+1],this._z=t[i+2],this._w=t[i+3],this._onChangeCallback(),this}toArray(t=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._w,t}fromBufferAttribute(t,i){return this._x=t.getX(i),this._y=t.getY(i),this._z=t.getZ(i),this._w=t.getW(i),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}class A{constructor(t=0,i=0,n=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=t,this.y=i,this.z=n}set(t,i,n){return n===void 0&&(n=this.z),this.x=t,this.y=i,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,i){switch(t){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;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,i){return i!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,i)):(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,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this}sub(t,i){return i!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,i)):(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,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this}multiply(t,i){return i!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,i)):(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,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(za.setFromEuler(t))}applyAxisAngle(t,i){return this.applyQuaternion(za.setFromAxisAngle(t,i))}applyMatrix3(t){const i=this.x,n=this.y,r=this.z,o=t.elements;return this.x=o[0]*i+o[3]*n+o[6]*r,this.y=o[1]*i+o[4]*n+o[7]*r,this.z=o[2]*i+o[5]*n+o[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const i=this.x,n=this.y,r=this.z,o=t.elements,s=1/(o[3]*i+o[7]*n+o[11]*r+o[15]);return this.x=(o[0]*i+o[4]*n+o[8]*r+o[12])*s,this.y=(o[1]*i+o[5]*n+o[9]*r+o[13])*s,this.z=(o[2]*i+o[6]*n+o[10]*r+o[14])*s,this}applyQuaternion(t){const i=this.x,n=this.y,r=this.z,o=t.x,s=t.y,a=t.z,l=t.w,c=l*i+s*r-a*n,h=l*n+a*i-o*r,u=l*r+o*n-s*i,d=-o*i-s*n-a*r;return this.x=c*l+d*-o+h*-a-u*-s,this.y=h*l+d*-s+u*-o-c*-a,this.z=u*l+d*-a+c*-s-h*-o,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const i=this.x,n=this.y,r=this.z,o=t.elements;return this.x=o[0]*i+o[4]*n+o[8]*r,this.y=o[1]*i+o[5]*n+o[9]*r,this.z=o[2]*i+o[6]*n+o[10]*r,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,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this}clampScalar(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this}clampLength(t,i){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(i,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this}lerpVectors(t,i,n){return this.x=t.x+(i.x-t.x)*n,this.y=t.y+(i.y-t.y)*n,this.z=t.z+(i.z-t.z)*n,this}cross(t,i){return i!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,i)):this.crossVectors(this,t)}crossVectors(t,i){const n=t.x,r=t.y,o=t.z,s=i.x,a=i.y,l=i.z;return this.x=r*l-o*a,this.y=o*s-n*l,this.z=n*a-r*s,this}projectOnVector(t){const i=t.lengthSq();if(i===0)return this.set(0,0,0);const n=t.dot(this)/i;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ko.copy(this).projectOnVector(t),this.sub(Ko)}reflect(t){return this.sub(Ko.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const i=Math.sqrt(this.lengthSq()*t.lengthSq());if(i===0)return Math.PI/2;const n=this.dot(t)/i;return Math.acos(Se.clamp(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const i=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return i*i+n*n+r*r}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,i,n){const r=Math.sin(i)*t;return this.x=r*Math.sin(n),this.y=Math.cos(i)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,i,n){return this.x=t*Math.sin(i),this.y=n,this.z=t*Math.cos(i),this}setFromMatrixPosition(t){const i=t.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(t){const i=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=i,this.y=n,this.z=r,this}setFromMatrixColumn(t,i){return this.fromArray(t.elements,i*4)}setFromMatrix3Column(t,i){return this.fromArray(t.elements,i*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,i=0){return this.x=t[i],this.y=t[i+1],this.z=t[i+2],this}toArray(t=[],i=0){return t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t}fromBufferAttribute(t,i,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(i),this.y=t.getY(i),this.z=t.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}const Ko=new A,za=new tt;class dt{constructor(t,i){Object.defineProperty(this,"isBox3",{value:!0}),this.min=t!==void 0?t:new A(1/0,1/0,1/0),this.max=i!==void 0?i:new A(-1/0,-1/0,-1/0)}set(t,i){return this.min.copy(t),this.max.copy(i),this}setFromArray(t){let i=1/0,n=1/0,r=1/0,o=-1/0,s=-1/0,a=-1/0;for(let l=0,c=t.length;l<c;l+=3){const h=t[l],u=t[l+1],d=t[l+2];h<i&&(i=h),u<n&&(n=u),d<r&&(r=d),h>o&&(o=h),u>s&&(s=u),d>a&&(a=d)}return this.min.set(i,n,r),this.max.set(o,s,a),this}setFromBufferAttribute(t){let i=1/0,n=1/0,r=1/0,o=-1/0,s=-1/0,a=-1/0;for(let l=0,c=t.count;l<c;l++){const h=t.getX(l),u=t.getY(l),d=t.getZ(l);h<i&&(i=h),u<n&&(n=u),d<r&&(r=d),h>o&&(o=h),u>s&&(s=u),d>a&&(a=d)}return this.min.set(i,n,r),this.max.set(o,s,a),this}setFromPoints(t){this.makeEmpty();for(let i=0,n=t.length;i<n;i++)this.expandByPoint(t[i]);return this}setFromCenterAndSize(t,i){const n=lr.copy(i).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t){return this.makeEmpty(),this.expandByObject(t)}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 t===void 0&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new A),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return t===void 0&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new A),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){t.updateWorldMatrix(!1,!1);const i=t.geometry;i!==void 0&&(i.boundingBox===null&&i.computeBoundingBox(),es.copy(i.boundingBox),es.applyMatrix4(t.matrixWorld),this.union(es));const n=t.children;for(let r=0,o=n.length;r<o;r++)this.expandByObject(n[r]);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,i){return i===void 0&&(console.warn("THREE.Box3: .getParameter() target is now required"),i=new A),i.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,lr),lr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let i,n;return t.normal.x>0?(i=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(i=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(i+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(i+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(i+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(i+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),i<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(cr),Vr.subVectors(this.max,cr),pn.subVectors(t.a,cr),fn.subVectors(t.b,cr),mn.subVectors(t.c,cr),Ai.subVectors(fn,pn),Si.subVectors(mn,fn),Xi.subVectors(pn,mn);let i=[0,-Ai.z,Ai.y,0,-Si.z,Si.y,0,-Xi.z,Xi.y,Ai.z,0,-Ai.x,Si.z,0,-Si.x,Xi.z,0,-Xi.x,-Ai.y,Ai.x,0,-Si.y,Si.x,0,-Xi.y,Xi.x,0];return!$o(i,pn,fn,mn,Vr)||(i=[1,0,0,0,1,0,0,0,1],!$o(i,pn,fn,mn,Vr))?!1:(Wr.crossVectors(Ai,Si),i=[Wr.x,Wr.y,Wr.z],$o(i,pn,fn,mn,Vr))}clampPoint(t,i){return i===void 0&&(console.warn("THREE.Box3: .clampPoint() target is now required"),i=new A),i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return lr.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return t===void 0&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=this.getSize(lr).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:(hi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),hi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),hi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),hi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),hi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),hi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),hi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),hi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(hi),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)}}function $o(e,t,i,n,r){for(let o=0,s=e.length-3;o<=s;o+=3){Yi.fromArray(e,o);const a=r.x*Math.abs(Yi.x)+r.y*Math.abs(Yi.y)+r.z*Math.abs(Yi.z),l=t.dot(Yi),c=i.dot(Yi),h=n.dot(Yi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const hi=[new A,new A,new A,new A,new A,new A,new A,new A],lr=new A,es=new dt,pn=new A,fn=new A,mn=new A,Ai=new A,Si=new A,Xi=new A,cr=new A,Vr=new A,Wr=new A,Yi=new A,cu=new dt;class Zt{constructor(t,i){this.center=t!==void 0?t:new A,this.radius=i!==void 0?i:-1}set(t,i){return this.center.copy(t),this.radius=i,this}setFromPoints(t,i){const n=this.center;i!==void 0?n.copy(i):cu.setFromPoints(t).getCenter(n);let r=0;for(let o=0,s=t.length;o<s;o++)r=Math.max(r,n.distanceToSquared(t[o]));return this.radius=Math.sqrt(r),this}clone(){return new this.constructor().copy(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 i=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=i*i}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,i){const n=this.center.distanceToSquared(t);return i===void 0&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),i=new A),i.copy(t),n>this.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i}getBoundingBox(t){return t===void 0&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new dt),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}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}}const ui=new A,ts=new A,jr=new A,Ei=new A,is=new A,Xr=new A,ns=new A;class qi{constructor(t,i){this.origin=t!==void 0?t:new A,this.direction=i!==void 0?i:new A(0,0,-1)}set(t,i){return this.origin.copy(t),this.direction.copy(i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,i){return i===void 0&&(console.warn("THREE.Ray: .at() target is now required"),i=new A),i.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ui)),this}closestPointToPoint(t,i){i===void 0&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),i=new A),i.subVectors(t,this.origin);const n=i.dot(this.direction);return n<0?i.copy(this.origin):i.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const i=ui.subVectors(t,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(t):(ui.copy(this.direction).multiplyScalar(i).add(this.origin),ui.distanceToSquared(t))}distanceSqToSegment(t,i,n,r){ts.copy(t).add(i).multiplyScalar(.5),jr.copy(i).sub(t).normalize(),Ei.copy(this.origin).sub(ts);const o=t.distanceTo(i)*.5,s=-this.direction.dot(jr),a=Ei.dot(this.direction),l=-Ei.dot(jr),c=Ei.lengthSq(),h=Math.abs(1-s*s);let u,d,f,m;if(h>0)if(u=s*l-a,d=s*a-l,m=o*h,u>=0)if(d>=-m)if(d<=m){const v=1/h;u*=v,d*=v,f=u*(u+s*d+2*a)+d*(s*u+d+2*l)+c}else d=o,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*l)+c;else d=-o,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-s*o+a)),d=u>0?-o:Math.min(Math.max(-o,-l),o),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-o,-l),o),f=d*(d+2*l)+c):(u=Math.max(0,-(s*o+a)),d=u>0?o:Math.min(Math.max(-o,-l),o),f=-u*u+d*(d+2*l)+c);else d=s>0?-o:o,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(jr).multiplyScalar(d).add(ts),f}intersectSphere(t,i){ui.subVectors(t.center,this.origin);const n=ui.dot(this.direction),r=ui.dot(ui)-n*n,o=t.radius*t.radius;if(r>o)return null;const s=Math.sqrt(o-r),a=n-s,l=n+s;return a<0&&l<0?null:a<0?this.at(l,i):this.at(a,i)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const i=t.normal.dot(this.direction);if(i===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/i;return n>=0?n:null}intersectPlane(t,i){const n=this.distanceToPlane(t);return n===null?null:this.at(n,i)}intersectsPlane(t){const i=t.distanceToPoint(this.origin);return i===0||t.normal.dot(this.direction)*i<0}intersectBox(t,i){let n,r,o,s,a,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,r=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,r=(t.min.x-d.x)*c),h>=0?(o=(t.min.y-d.y)*h,s=(t.max.y-d.y)*h):(o=(t.max.y-d.y)*h,s=(t.min.y-d.y)*h),n>s||o>r||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),u>=0?(a=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||a>r)||((a>n||n!==n)&&(n=a),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,i)}intersectsBox(t){return this.intersectBox(t,ui)!==null}intersectTriangle(t,i,n,r,o){is.subVectors(i,t),Xr.subVectors(n,t),ns.crossVectors(is,Xr);let s=this.direction.dot(ns),a;if(s>0){if(r)return null;a=1}else if(s<0)a=-1,s=-s;else return null;Ei.subVectors(this.origin,t);const l=a*this.direction.dot(Xr.crossVectors(Ei,Xr));if(l<0)return null;const c=a*this.direction.dot(is.cross(Ei));if(c<0||l+c>s)return null;const h=-a*Ei.dot(ns);return h<0?null:this.at(h/s,o)}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)}}class Re{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,i,n,r,o,s,a,l,c,h,u,d,f,m,v,_){const g=this.elements;return g[0]=t,g[4]=i,g[8]=n,g[12]=r,g[1]=o,g[5]=s,g[9]=a,g[13]=l,g[2]=c,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=m,g[11]=v,g[15]=_,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 Re().fromArray(this.elements)}copy(t){const i=this.elements,n=t.elements;return i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=n[3],i[4]=n[4],i[5]=n[5],i[6]=n[6],i[7]=n[7],i[8]=n[8],i[9]=n[9],i[10]=n[10],i[11]=n[11],i[12]=n[12],i[13]=n[13],i[14]=n[14],i[15]=n[15],this}copyPosition(t){const i=this.elements,n=t.elements;return i[12]=n[12],i[13]=n[13],i[14]=n[14],this}setFromMatrix3(t){const i=t.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(t,i,n){return t.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,i,n){return this.set(t.x,i.x,n.x,0,t.y,i.y,n.y,0,t.z,i.z,n.z,0,0,0,0,1),this}extractRotation(t){const i=this.elements,n=t.elements,r=1/gn.setFromMatrixColumn(t,0).length(),o=1/gn.setFromMatrixColumn(t,1).length(),s=1/gn.setFromMatrixColumn(t,2).length();return i[0]=n[0]*r,i[1]=n[1]*r,i[2]=n[2]*r,i[3]=0,i[4]=n[4]*o,i[5]=n[5]*o,i[6]=n[6]*o,i[7]=0,i[8]=n[8]*s,i[9]=n[9]*s,i[10]=n[10]*s,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const i=this.elements,n=t.x,r=t.y,o=t.z,s=Math.cos(n),a=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(o),u=Math.sin(o);if(t.order==="XYZ"){const d=s*h,f=s*u,m=a*h,v=a*u;i[0]=l*h,i[4]=-l*u,i[8]=c,i[1]=f+m*c,i[5]=d-v*c,i[9]=-a*l,i[2]=v-d*c,i[6]=m+f*c,i[10]=s*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,m=c*h,v=c*u;i[0]=d+v*a,i[4]=m*a-f,i[8]=s*c,i[1]=s*u,i[5]=s*h,i[9]=-a,i[2]=f*a-m,i[6]=v+d*a,i[10]=s*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,m=c*h,v=c*u;i[0]=d-v*a,i[4]=-s*u,i[8]=m+f*a,i[1]=f+m*a,i[5]=s*h,i[9]=v-d*a,i[2]=-s*c,i[6]=a,i[10]=s*l}else if(t.order==="ZYX"){const d=s*h,f=s*u,m=a*h,v=a*u;i[0]=l*h,i[4]=m*c-f,i[8]=d*c+v,i[1]=l*u,i[5]=v*c+d,i[9]=f*c-m,i[2]=-c,i[6]=a*l,i[10]=s*l}else if(t.order==="YZX"){const d=s*l,f=s*c,m=a*l,v=a*c;i[0]=l*h,i[4]=v-d*u,i[8]=m*u+f,i[1]=u,i[5]=s*h,i[9]=-a*h,i[2]=-c*h,i[6]=f*u+m,i[10]=d-v*u}else if(t.order==="XZY"){const d=s*l,f=s*c,m=a*l,v=a*c;i[0]=l*h,i[4]=-u,i[8]=c*h,i[1]=d*u+v,i[5]=s*h,i[9]=f*u-m,i[2]=m*u-f,i[6]=a*h,i[10]=v*u+d}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(t){return this.compose(hu,t,uu)}lookAt(t,i,n){const r=this.elements;return St.subVectors(t,i),St.lengthSq()===0&&(St.z=1),St.normalize(),Li.crossVectors(n,St),Li.lengthSq()===0&&(Math.abs(n.z)===1?St.x+=1e-4:St.z+=1e-4,St.normalize(),Li.crossVectors(n,St)),Li.normalize(),Yr.crossVectors(St,Li),r[0]=Li.x,r[4]=Yr.x,r[8]=St.x,r[1]=Li.y,r[5]=Yr.y,r[9]=St.y,r[2]=Li.z,r[6]=Yr.z,r[10]=St.z,this}multiply(t,i){return i!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,i)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,i){const n=t.elements,r=i.elements,o=this.elements,s=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],v=n[6],_=n[10],g=n[14],p=n[3],E=n[7],S=n[11],T=n[15],x=r[0],L=r[4],W=r[8],U=r[12],B=r[1],H=r[5],j=r[9],G=r[13],D=r[2],k=r[6],Y=r[10],Z=r[14],$=r[3],ne=r[7],ae=r[11],de=r[15];return o[0]=s*x+a*B+l*D+c*$,o[4]=s*L+a*H+l*k+c*ne,o[8]=s*W+a*j+l*Y+c*ae,o[12]=s*U+a*G+l*Z+c*de,o[1]=h*x+u*B+d*D+f*$,o[5]=h*L+u*H+d*k+f*ne,o[9]=h*W+u*j+d*Y+f*ae,o[13]=h*U+u*G+d*Z+f*de,o[2]=m*x+v*B+_*D+g*$,o[6]=m*L+v*H+_*k+g*ne,o[10]=m*W+v*j+_*Y+g*ae,o[14]=m*U+v*G+_*Z+g*de,o[3]=p*x+E*B+S*D+T*$,o[7]=p*L+E*H+S*k+T*ne,o[11]=p*W+E*j+S*Y+T*ae,o[15]=p*U+E*G+S*Z+T*de,this}multiplyScalar(t){const i=this.elements;return i[0]*=t,i[4]*=t,i[8]*=t,i[12]*=t,i[1]*=t,i[5]*=t,i[9]*=t,i[13]*=t,i[2]*=t,i[6]*=t,i[10]*=t,i[14]*=t,i[3]*=t,i[7]*=t,i[11]*=t,i[15]*=t,this}determinant(){const t=this.elements,i=t[0],n=t[4],r=t[8],o=t[12],s=t[1],a=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],v=t[7],_=t[11],g=t[15];return m*(+o*l*u-r*c*u-o*a*d+n*c*d+r*a*f-n*l*f)+v*(+i*l*f-i*c*d+o*s*d-r*s*f+r*c*h-o*l*h)+_*(+i*c*u-i*a*f-o*s*u+n*s*f+o*a*h-n*c*h)+g*(-r*a*h-i*l*u+i*a*d+r*s*u-n*s*d+n*l*h)}transpose(){const t=this.elements;let i;return i=t[1],t[1]=t[4],t[4]=i,i=t[2],t[2]=t[8],t[8]=i,i=t[6],t[6]=t[9],t[9]=i,i=t[3],t[3]=t[12],t[12]=i,i=t[7],t[7]=t[13],t[13]=i,i=t[11],t[11]=t[14],t[14]=i,this}setPosition(t,i,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=i,r[14]=n),this}invert(){const t=this.elements,i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],v=t[13],_=t[14],g=t[15],p=u*_*c-v*d*c+v*l*f-a*_*f-u*l*g+a*d*g,E=m*d*c-h*_*c-m*l*f+s*_*f+h*l*g-s*d*g,S=h*v*c-m*u*c+m*a*f-s*v*f-h*a*g+s*u*g,T=m*u*l-h*v*l-m*a*d+s*v*d+h*a*_-s*u*_,x=i*p+n*E+r*S+o*T;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/x;return t[0]=p*L,t[1]=(v*d*o-u*_*o-v*r*f+n*_*f+u*r*g-n*d*g)*L,t[2]=(a*_*o-v*l*o+v*r*c-n*_*c-a*r*g+n*l*g)*L,t[3]=(u*l*o-a*d*o-u*r*c+n*d*c+a*r*f-n*l*f)*L,t[4]=E*L,t[5]=(h*_*o-m*d*o+m*r*f-i*_*f-h*r*g+i*d*g)*L,t[6]=(m*l*o-s*_*o-m*r*c+i*_*c+s*r*g-i*l*g)*L,t[7]=(s*d*o-h*l*o+h*r*c-i*d*c-s*r*f+i*l*f)*L,t[8]=S*L,t[9]=(m*u*o-h*v*o-m*n*f+i*v*f+h*n*g-i*u*g)*L,t[10]=(s*v*o-m*a*o+m*n*c-i*v*c-s*n*g+i*a*g)*L,t[11]=(h*a*o-s*u*o-h*n*c+i*u*c+s*n*f-i*a*f)*L,t[12]=T*L,t[13]=(h*v*r-m*u*r+m*n*d-i*v*d-h*n*_+i*u*_)*L,t[14]=(m*a*r-s*v*r-m*n*l+i*v*l+s*n*_-i*a*_)*L,t[15]=(s*u*r-h*a*r+h*n*l-i*u*l-s*n*d+i*a*d)*L,this}scale(t){const i=this.elements,n=t.x,r=t.y,o=t.z;return i[0]*=n,i[4]*=r,i[8]*=o,i[1]*=n,i[5]*=r,i[9]*=o,i[2]*=n,i[6]*=r,i[10]*=o,i[3]*=n,i[7]*=r,i[11]*=o,this}getMaxScaleOnAxis(){const t=this.elements,i=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],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(i,n,r))}makeTranslation(t,i,n){return this.set(1,0,0,t,0,1,0,i,0,0,1,n,0,0,0,1),this}makeRotationX(t){const i=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,i,-n,0,0,n,i,0,0,0,0,1),this}makeRotationY(t){const i=Math.cos(t),n=Math.sin(t);return this.set(i,0,n,0,0,1,0,0,-n,0,i,0,0,0,0,1),this}makeRotationZ(t){const i=Math.cos(t),n=Math.sin(t);return this.set(i,-n,0,0,n,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,i){const n=Math.cos(i),r=Math.sin(i),o=1-n,s=t.x,a=t.y,l=t.z,c=o*s,h=o*a;return this.set(c*s+n,c*a-r*l,c*l+r*a,0,c*a+r*l,h*a+n,h*l-r*s,0,c*l-r*a,h*l+r*s,o*l*l+n,0,0,0,0,1),this}makeScale(t,i,n){return this.set(t,0,0,0,0,i,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,i,n){return this.set(1,i,n,0,t,1,n,0,t,i,1,0,0,0,0,1),this}compose(t,i,n){const r=this.elements,o=i._x,s=i._y,a=i._z,l=i._w,c=o+o,h=s+s,u=a+a,d=o*c,f=o*h,m=o*u,v=s*h,_=s*u,g=a*u,p=l*c,E=l*h,S=l*u,T=n.x,x=n.y,L=n.z;return r[0]=(1-(v+g))*T,r[1]=(f+S)*T,r[2]=(m-E)*T,r[3]=0,r[4]=(f-S)*x,r[5]=(1-(d+g))*x,r[6]=(_+p)*x,r[7]=0,r[8]=(m+E)*L,r[9]=(_-p)*L,r[10]=(1-(d+v))*L,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,i,n){const r=this.elements;let o=gn.set(r[0],r[1],r[2]).length();const s=gn.set(r[4],r[5],r[6]).length(),a=gn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),t.x=r[12],t.y=r[13],t.z=r[14],Vt.copy(this);const l=1/o,c=1/s,h=1/a;return Vt.elements[0]*=l,Vt.elements[1]*=l,Vt.elements[2]*=l,Vt.elements[4]*=c,Vt.elements[5]*=c,Vt.elements[6]*=c,Vt.elements[8]*=h,Vt.elements[9]*=h,Vt.elements[10]*=h,i.setFromRotationMatrix(Vt),n.x=o,n.y=s,n.z=a,this}makePerspective(t,i,n,r,o,s){s===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,l=2*o/(i-t),c=2*o/(n-r),h=(i+t)/(i-t),u=(n+r)/(n-r),d=-(s+o)/(s-o),f=-2*s*o/(s-o);return a[0]=l,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=c,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,i,n,r,o,s){const a=this.elements,l=1/(i-t),c=1/(n-r),h=1/(s-o),u=(i+t)*l,d=(n+r)*c,f=(s+o)*h;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const i=this.elements,n=t.elements;for(let r=0;r<16;r++)if(i[r]!==n[r])return!1;return!0}fromArray(t,i=0){for(let n=0;n<16;n++)this.elements[n]=t[n+i];return this}toArray(t=[],i=0){const n=this.elements;return t[i]=n[0],t[i+1]=n[1],t[i+2]=n[2],t[i+3]=n[3],t[i+4]=n[4],t[i+5]=n[5],t[i+6]=n[6],t[i+7]=n[7],t[i+8]=n[8],t[i+9]=n[9],t[i+10]=n[10],t[i+11]=n[11],t[i+12]=n[12],t[i+13]=n[13],t[i+14]=n[14],t[i+15]=n[15],t}}const gn=new A,Vt=new Re,hu=new A(0,0,0),uu=new A(1,1,1),Li=new A,Yr=new A,St=new A;class Qn{constructor(t=0,i=0,n=0,r=Qn.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=t,this._y=i,this._z=n,this._order=r}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,i,n,r){return this._x=t,this._y=i,this._z=n,this._order=r||this._order,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,i,n){const r=Se.clamp,o=t.elements,s=o[0],a=o[4],l=o[8],c=o[1],h=o[5],u=o[9],d=o[2],f=o[6],m=o[10];switch(i=i||this._order,i){case"XYZ":this._y=Math.asin(r(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,h),this._z=0);break;case"YXZ":this._x=Math.asin(-r(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(r(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,n!==!1&&this._onChangeCallback(),this}setFromQuaternion(t,i,n){return ka.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ka,i,n)}setFromVector3(t,i){return this.set(t.x,t.y,t.z,i||this._order)}reorder(t){return Ha.setFromEuler(this),this.setFromQuaternion(Ha,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=[],i=0){return t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new A(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Qn.DefaultOrder="XYZ",Qn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];const ka=new Re,Ha=new tt;class Ba{constructor(){this.mask=1}set(t){this.mask=1<<t|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}}let du=0;const Ga=new A,vn=new tt,di=new Re,qr=new A,hr=new A,pu=new A,fu=new tt,Va=new A(1,0,0),Wa=new A(0,1,0),ja=new A(0,0,1),mu={type:"added"},Xa={type:"removed"};function we(){Object.defineProperty(this,"id",{value:du++}),this.uuid=Se.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=we.DefaultUp.clone();const e=new A,t=new Qn,i=new tt,n=new A(1,1,1);function r(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Re},normalMatrix:{value:new Ft}}),this.matrix=new Re,this.matrixWorld=new Re,this.matrixAutoUpdate=we.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Ba,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}we.DefaultUp=new A(0,1,0),we.DefaultMatrixAutoUpdate=!0,we.prototype=Object.assign(Object.create(ci.prototype),{constructor:we,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(e,t){return vn.setFromAxisAngle(e,t),this.quaternion.multiply(vn),this},rotateOnWorldAxis:function(e,t){return vn.setFromAxisAngle(e,t),this.quaternion.premultiply(vn),this},rotateX:function(e){return this.rotateOnAxis(Va,e)},rotateY:function(e){return this.rotateOnAxis(Wa,e)},rotateZ:function(e){return this.rotateOnAxis(ja,e)},translateOnAxis:function(e,t){return Ga.copy(e).applyQuaternion(this.quaternion),this.position.add(Ga.multiplyScalar(t)),this},translateX:function(e){return this.translateOnAxis(Va,e)},translateY:function(e){return this.translateOnAxis(Wa,e)},translateZ:function(e){return this.translateOnAxis(ja,e)},localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(e){return e.applyMatrix4(di.copy(this.matrixWorld).invert())},lookAt:function(e,t,i){e.isVector3?qr.copy(e):qr.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),hr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?di.lookAt(hr,qr,this.up):di.lookAt(qr,hr,this.up),this.quaternion.setFromRotationMatrix(di),n&&(di.extractRotation(n.matrixWorld),vn.setFromRotationMatrix(di),this.quaternion.premultiply(vn.invert()))},add:function(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(mu)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)},remove:function(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Xa)),this},clear:function(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(Xa)}return this.children.length=0,this},attach:function(e){return this.updateWorldMatrix(!0,!1),di.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),di.multiply(e.parent.matrixWorld)),e.applyMatrix4(di),e.updateWorldMatrix(!1,!1),this.add(e),this},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const r=this.children[i].getObjectByProperty(e,t);if(r!==void 0)return r}},getWorldPosition:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),e=new A),this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),e=new tt),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hr,e,pu),e},getWorldScale:function(e){return e===void 0&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),e=new A),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hr,fu,e),e},getWorldDirection:function(e){e===void 0&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),e=new A),this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()},raycast:function(){},traverse:function(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)},traverseVisible:function(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)},traverseAncestors:function(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)},updateWorldMatrix:function(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const n=this.children;for(let r=0,o=n.length;r<o;r++)n[r].updateWorldMatrix(!1,!0)}},toJSON:function(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON());function r(s,a){return s[a.uuid]===void 0&&(s[a.uuid]=a.toJSON(e)),a.uuid}if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const s=this.geometry.parameters;if(s!==void 0&&s.shapes!==void 0){const a=s.shapes;if(Array.isArray(a))for(let l=0,c=a.length;l<c;l++){const h=a[l];r(e.shapes,h)}else r(e.shapes,a)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const s=[];for(let a=0,l=this.material.length;a<l;a++)s.push(r(e.materials,this.material[a]));n.material=s}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let s=0;s<this.children.length;s++)n.children.push(this.children[s].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let s=0;s<this.animations.length;s++){const a=this.animations[s];n.animations.push(r(e.animations,a))}}if(t){const s=o(e.geometries),a=o(e.materials),l=o(e.textures),c=o(e.images),h=o(e.shapes),u=o(e.skeletons),d=o(e.animations);s.length>0&&(i.geometries=s),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),h.length>0&&(i.shapes=h),u.length>0&&(i.skeletons=u),d.length>0&&(i.animations=d)}return i.object=n,i;function o(s){const a=[];for(const l in s){const c=s[l];delete c.metadata,a.push(c)}return a}},clone:function(e){return new this.constructor().copy(this,e)},copy:function(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}});const rs=new A,gu=new A,vu=new Ft;class pi{constructor(t,i){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=t!==void 0?t:new A(1,0,0),this.constant=i!==void 0?i:0}set(t,i){return this.normal.copy(t),this.constant=i,this}setComponents(t,i,n,r){return this.normal.set(t,i,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,i){return this.normal.copy(t),this.constant=-i.dot(this.normal),this}setFromCoplanarPoints(t,i,n){const r=rs.subVectors(n,i).cross(gu.subVectors(t,i)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}clone(){return new this.constructor().copy(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,i){return i===void 0&&(console.warn("THREE.Plane: .projectPoint() target is now required"),i=new A),i.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,i){i===void 0&&(console.warn("THREE.Plane: .intersectLine() target is now required"),i=new A);const n=t.delta(rs),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(t.start)===0?i.copy(t.start):void 0;const o=-(t.start.dot(this.normal)+this.constant)/r;if(!(o<0||o>1))return i.copy(n).multiplyScalar(o).add(t.start)}intersectsLine(t){const i=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return i<0&&n>0||n<0&&i>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t===void 0&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new A),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,i){const n=i||vu.getNormalMatrix(t),r=this.coplanarPoint(rs).applyMatrix4(t),o=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(o),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}const Wt=new A,fi=new A,os=new A,mi=new A,_n=new A,xn=new A,Ya=new A,ss=new A,as=new A,ls=new A;class xt{constructor(t,i,n){this.a=t!==void 0?t:new A,this.b=i!==void 0?i:new A,this.c=n!==void 0?n:new A}static getNormal(t,i,n,r){r===void 0&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new A),r.subVectors(n,i),Wt.subVectors(t,i),r.cross(Wt);const o=r.lengthSq();return o>0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(t,i,n,r,o){Wt.subVectors(r,i),fi.subVectors(n,i),os.subVectors(t,i);const s=Wt.dot(Wt),a=Wt.dot(fi),l=Wt.dot(os),c=fi.dot(fi),h=fi.dot(os),u=s*c-a*a;if(o===void 0&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),o=new A),u===0)return o.set(-2,-1,-1);const d=1/u,f=(c*l-a*h)*d,m=(s*h-a*l)*d;return o.set(1-f-m,m,f)}static containsPoint(t,i,n,r){return this.getBarycoord(t,i,n,r,mi),mi.x>=0&&mi.y>=0&&mi.x+mi.y<=1}static getUV(t,i,n,r,o,s,a,l){return this.getBarycoord(t,i,n,r,mi),l.set(0,0),l.addScaledVector(o,mi.x),l.addScaledVector(s,mi.y),l.addScaledVector(a,mi.z),l}static isFrontFacing(t,i,n,r){return Wt.subVectors(n,i),fi.subVectors(t,i),Wt.cross(fi).dot(r)<0}set(t,i,n){return this.a.copy(t),this.b.copy(i),this.c.copy(n),this}setFromPointsAndIndices(t,i,n,r){return this.a.copy(t[i]),this.b.copy(t[n]),this.c.copy(t[r]),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 Wt.subVectors(this.c,this.b),fi.subVectors(this.a,this.b),Wt.cross(fi).length()*.5}getMidpoint(t){return t===void 0&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new A),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return xt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t===void 0&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new pi),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,i){return xt.getBarycoord(t,this.a,this.b,this.c,i)}getUV(t,i,n,r,o){return xt.getUV(t,this.a,this.b,this.c,i,n,r,o)}containsPoint(t){return xt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return xt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,i){i===void 0&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),i=new A);const n=this.a,r=this.b,o=this.c;let s,a;_n.subVectors(r,n),xn.subVectors(o,n),ss.subVectors(t,n);const l=_n.dot(ss),c=xn.dot(ss);if(l<=0&&c<=0)return i.copy(n);as.subVectors(t,r);const h=_n.dot(as),u=xn.dot(as);if(h>=0&&u<=h)return i.copy(r);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return s=l/(l-h),i.copy(n).addScaledVector(_n,s);ls.subVectors(t,o);const f=_n.dot(ls),m=xn.dot(ls);if(m>=0&&f<=m)return i.copy(o);const v=f*c-l*m;if(v<=0&&c>=0&&m<=0)return a=c/(c-m),i.copy(n).addScaledVector(xn,a);const _=h*m-f*u;if(_<=0&&u-h>=0&&f-m>=0)return Ya.subVectors(o,r),a=(u-h)/(u-h+(f-m)),i.copy(r).addScaledVector(Ya,a);const g=1/(_+v+d);return s=v*g,a=d*g,i.copy(n).addScaledVector(_n,s).addScaledVector(xn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const qa={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},jt={h:0,s:0,l:0},Qr={h:0,s:0,l:0};function cs(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*6*(2/3-i):e}function hs(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function us(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}class he{constructor(t,i,n){return Object.defineProperty(this,"isColor",{value:!0}),i===void 0&&n===void 0?this.set(t):this.setRGB(t,i,n)}set(t){return t&&t.isColor?this.copy(t):typeof t=="number"?this.setHex(t):typeof t=="string"&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,this}setRGB(t,i,n){return this.r=t,this.g=i,this.b=n,this}setHSL(t,i,n){if(t=Se.euclideanModulo(t,1),i=Se.clamp(i,0,1),n=Se.clamp(n,0,1),i===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+i):n+i-n*i,o=2*n-r;this.r=cs(o,r,t+1/3),this.g=cs(o,r,t),this.b=cs(o,r,t-1/3)}return this}setStyle(t){function i(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let r;const o=n[1],s=n[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,i(r[4]),this;if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,i(r[4]),this;break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s)){const a=parseFloat(r[1])/360,l=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return i(r[4]),this.setHSL(a,l,c)}break}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=n[1],o=r.length;if(o===3)return this.r=parseInt(r.charAt(0)+r.charAt(0),16)/255,this.g=parseInt(r.charAt(1)+r.charAt(1),16)/255,this.b=parseInt(r.charAt(2)+r.charAt(2),16)/255,this;if(o===6)return this.r=parseInt(r.charAt(0)+r.charAt(1),16)/255,this.g=parseInt(r.charAt(2)+r.charAt(3),16)/255,this.b=parseInt(r.charAt(4)+r.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const i=qa[t];return i!==void 0?this.setHex(i):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}copyGammaToLinear(t,i=2){return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this}copyLinearToGamma(t,i=2){const n=i>0?1/i:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=hs(t.r),this.g=hs(t.g),this.b=hs(t.b),this}copyLinearToSRGB(t){return this.r=us(t.r),this.g=us(t.g),this.b=us(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){t===void 0&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});const i=this.r,n=this.g,r=this.b,o=Math.max(i,n,r),s=Math.min(i,n,r);let a,l;const c=(s+o)/2;if(s===o)a=0,l=0;else{const h=o-s;switch(l=c<=.5?h/(o+s):h/(2-o-s),o){case i:a=(n-r)/h+(n<r?6:0);break;case n:a=(r-i)/h+2;break;case r:a=(i-n)/h+4;break}a/=6}return t.h=a,t.s=l,t.l=c,t}getStyle(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"}offsetHSL(t,i,n){return this.getHSL(jt),jt.h+=t,jt.s+=i,jt.l+=n,this.setHSL(jt.h,jt.s,jt.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,i){return this.r=t.r+i.r,this.g=t.g+i.g,this.b=t.b+i.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,i){return this.r+=(t.r-this.r)*i,this.g+=(t.g-this.g)*i,this.b+=(t.b-this.b)*i,this}lerpColors(t,i,n){return this.r=t.r+(i.r-t.r)*n,this.g=t.g+(i.g-t.g)*n,this.b=t.b+(i.b-t.b)*n,this}lerpHSL(t,i){this.getHSL(jt),t.getHSL(Qr);const n=Se.lerp(jt.h,Qr.h,i),r=Se.lerp(jt.s,Qr.s,i),o=Se.lerp(jt.l,Qr.l,i);return this.setHSL(n,r,o),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,i=0){return this.r=t[i],this.g=t[i+1],this.b=t[i+2],this}toArray(t=[],i=0){return t[i]=this.r,t[i+1]=this.g,t[i+2]=this.b,t}fromBufferAttribute(t,i){return this.r=t.getX(i),this.g=t.getY(i),this.b=t.getZ(i),t.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}he.NAMES=qa,he.prototype.r=1,he.prototype.g=1,he.prototype.b=1;class _u{constructor(t,i,n,r,o,s=0){this.a=t,this.b=i,this.c=n,this.normal=r&&r.isVector3?r:new A,this.vertexNormals=Array.isArray(r)?r:[],this.color=o&&o.isColor?o:new he,this.vertexColors=Array.isArray(o)?o:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let i=0,n=t.vertexNormals.length;i<n;i++)this.vertexNormals[i]=t.vertexNormals[i].clone();for(let i=0,n=t.vertexColors.length;i<n;i++)this.vertexColors[i]=t.vertexColors[i].clone();return this}}let xu=0;function Me(){Object.defineProperty(this,"id",{value:xu++}),this.uuid=Se.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=Bi,this.side=Gt,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=_a,this.blendDst=xa,this.blendEquation=sn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Ho,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=au,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Zo,this.stencilZFail=Zo,this.stencilZPass=Zo,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.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Me.prototype=Object.assign(Object.create(ci.prototype),{constructor:Me,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=i===pa;continue}const n=this[t];if(n===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i}},toJSON:function(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,this.combine!==void 0&&(i.combine=this.combine),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.size!==void 0&&(i.size=this.size),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Bi&&(i.blending=this.blending),this.flatShading===!0&&(i.flatShading=this.flatShading),this.side!==Gt&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.morphTargets===!0&&(i.morphTargets=!0),this.morphNormals===!0&&(i.morphNormals=!0),this.skinning===!0&&(i.skinning=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData);function n(r){const o=[];for(const s in r){const a=r[s];delete a.metadata,o.push(a)}return o}if(t){const r=n(e.textures),o=n(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i},clone:function(){return new this.constructor().copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const n=t.length;i=new Array(n);for(let r=0;r!==n;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Me.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}});function vt(e){Me.call(this),this.type="MeshBasicMaterial",this.color=new he(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Or,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(e)}vt.prototype=Object.create(Me.prototype),vt.prototype.constructor=vt,vt.prototype.isMeshBasicMaterial=!0,vt.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this};const Be=new A,Zr=new le;function Le(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i===!0,this.usage=Br,this.updateRange={offset:0,count:-1},this.version=0}Object.defineProperty(Le.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(Le.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=t.array[i+n];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let o=e[n];o===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),o=new he),t[i++]=o.r,t[i++]=o.g,t[i++]=o.b}return this},copyVector2sArray:function(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let o=e[n];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),o=new le),t[i++]=o.x,t[i++]=o.y}return this},copyVector3sArray:function(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let o=e[n];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),o=new A),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z}return this},copyVector4sArray:function(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let o=e[n];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),o=new ke),t[i++]=o.x,t[i++]=o.y,t[i++]=o.z,t[i++]=o.w}return this},applyMatrix3:function(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Zr.fromBufferAttribute(this,t),Zr.applyMatrix3(e),this.setXY(t,Zr.x,Zr.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Be.fromBufferAttribute(this,t),Be.applyMatrix3(e),this.setXYZ(t,Be.x,Be.y,Be.z);return this},applyMatrix4:function(e){for(let t=0,i=this.count;t<i;t++)Be.x=this.getX(t),Be.y=this.getY(t),Be.z=this.getZ(t),Be.applyMatrix4(e),this.setXYZ(t,Be.x,Be.y,Be.z);return this},applyNormalMatrix:function(e){for(let t=0,i=this.count;t<i;t++)Be.x=this.getX(t),Be.y=this.getY(t),Be.z=this.getZ(t),Be.applyNormalMatrix(e),this.setXYZ(t,Be.x,Be.y,Be.z);return this},transformDirection:function(e){for(let t=0,i=this.count;t<i;t++)Be.x=this.getX(t),Be.y=this.getY(t),Be.z=this.getZ(t),Be.transformDirection(e),this.setXYZ(t,Be.x,Be.y,Be.z);return this},set:function(e,t=0){return this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this},setXYZ:function(e,t,i,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this},setXYZW:function(e,t,i,n,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}});function ds(e,t,i){Le.call(this,new Int8Array(e),t,i)}ds.prototype=Object.create(Le.prototype),ds.prototype.constructor=ds;function ps(e,t,i){Le.call(this,new Uint8Array(e),t,i)}ps.prototype=Object.create(Le.prototype),ps.prototype.constructor=ps;function fs(e,t,i){Le.call(this,new Uint8ClampedArray(e),t,i)}fs.prototype=Object.create(Le.prototype),fs.prototype.constructor=fs;function ms(e,t,i){Le.call(this,new Int16Array(e),t,i)}ms.prototype=Object.create(Le.prototype),ms.prototype.constructor=ms;function ur(e,t,i){Le.call(this,new Uint16Array(e),t,i)}ur.prototype=Object.create(Le.prototype),ur.prototype.constructor=ur;function gs(e,t,i){Le.call(this,new Int32Array(e),t,i)}gs.prototype=Object.create(Le.prototype),gs.prototype.constructor=gs;function dr(e,t,i){Le.call(this,new Uint32Array(e),t,i)}dr.prototype=Object.create(Le.prototype),dr.prototype.constructor=dr;function Jr(e,t,i){Le.call(this,new Uint16Array(e),t,i)}Jr.prototype=Object.create(Le.prototype),Jr.prototype.constructor=Jr,Jr.prototype.isFloat16BufferAttribute=!0;function Fe(e,t,i){Le.call(this,new Float32Array(e),t,i)}Fe.prototype=Object.create(Le.prototype),Fe.prototype.constructor=Fe;function vs(e,t,i){Le.call(this,new Float64Array(e),t,i)}vs.prototype=Object.create(Le.prototype),vs.prototype.constructor=vs;function Qa(e){if(e.length===0)return-1/0;let t=e[0];for(let i=1,n=e.length;i<n;++i)e[i]>t&&(t=e[i]);return t}const yu={Int8Array,Uint8Array,Uint8ClampedArray:typeof Uint8ClampedArray<"u"?Uint8ClampedArray:Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Kr(e,t){return new yu[e](t)}let bu=0;const Jt=new Re,_s=new we,yn=new A,Et=new dt,pr=new dt,ot=new A;function De(){Object.defineProperty(this,"id",{value:bu++}),this.uuid=Se.generateUUID(),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={}}De.prototype=Object.assign(Object.create(ci.prototype),{constructor:De,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){return Array.isArray(e)?this.index=new(Qa(e)>65535?dr:ur)(e,1):this.index=e,this},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},hasAttribute:function(e){return this.attributes[e]!==void 0},addGroup:function(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new Ft().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},rotateX:function(e){return Jt.makeRotationX(e),this.applyMatrix4(Jt),this},rotateY:function(e){return Jt.makeRotationY(e),this.applyMatrix4(Jt),this},rotateZ:function(e){return Jt.makeRotationZ(e),this.applyMatrix4(Jt),this},translate:function(e,t,i){return Jt.makeTranslation(e,t,i),this.applyMatrix4(Jt),this},scale:function(e,t,i){return Jt.makeScale(e,t,i),this.applyMatrix4(Jt),this},lookAt:function(e){return _s.lookAt(e),_s.updateMatrix(),this.applyMatrix4(_s.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(yn).negate(),this.translate(yn.x,yn.y,yn.z),this},setFromPoints:function(e){const t=[];for(let i=0,n=e.length;i<n;i++){const r=e[i];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Fe(t,3)),this},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new dt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const r=t[i];Et.setFromBufferAttribute(r),this.morphTargetsRelative?(ot.addVectors(this.boundingBox.min,Et.min),this.boundingBox.expandByPoint(ot),ot.addVectors(this.boundingBox.max,Et.max),this.boundingBox.expandByPoint(ot)):(this.boundingBox.expandByPoint(Et.min),this.boundingBox.expandByPoint(Et.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:function(){this.boundingSphere===null&&(this.boundingSphere=new Zt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new A,1/0);return}if(e){const i=this.boundingSphere.center;if(Et.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const s=t[r];pr.setFromBufferAttribute(s),this.morphTargetsRelative?(ot.addVectors(Et.min,pr.min),Et.expandByPoint(ot),ot.addVectors(Et.max,pr.max),Et.expandByPoint(ot)):(Et.expandByPoint(pr.min),Et.expandByPoint(pr.max))}Et.getCenter(i);let n=0;for(let r=0,o=e.count;r<o;r++)ot.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(ot));if(t)for(let r=0,o=t.length;r<o;r++){const s=t[r],a=this.morphTargetsRelative;for(let l=0,c=s.count;l<c;l++)ot.fromBufferAttribute(s,l),a&&(yn.fromBufferAttribute(e,l),ot.add(yn)),n=Math.max(n,i.distanceToSquared(ot))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeTangents:function(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.array,n=t.position.array,r=t.normal.array,o=t.uv.array,s=n.length/3;t.tangent===void 0&&this.setAttribute("tangent",new Le(new Float32Array(4*s),4));const a=t.tangent.array,l=[],c=[];for(let U=0;U<s;U++)l[U]=new A,c[U]=new A;const h=new A,u=new A,d=new A,f=new le,m=new le,v=new le,_=new A,g=new A;function p(U,B,H){h.fromArray(n,U*3),u.fromArray(n,B*3),d.fromArray(n,H*3),f.fromArray(o,U*2),m.fromArray(o,B*2),v.fromArray(o,H*2),u.sub(h),d.sub(h),m.sub(f),v.sub(f);const j=1/(m.x*v.y-v.x*m.y);isFinite(j)&&(_.copy(u).multiplyScalar(v.y).addScaledVector(d,-m.y).multiplyScalar(j),g.copy(d).multiplyScalar(m.x).addScaledVector(u,-v.x).multiplyScalar(j),l[U].add(_),l[B].add(_),l[H].add(_),c[U].add(g),c[B].add(g),c[H].add(g))}let E=this.groups;E.length===0&&(E=[{start:0,count:i.length}]);for(let U=0,B=E.length;U<B;++U){const H=E[U],j=H.start,G=H.count;for(let D=j,k=j+G;D<k;D+=3)p(i[D+0],i[D+1],i[D+2])}const S=new A,T=new A,x=new A,L=new A;function W(U){x.fromArray(r,U*3),L.copy(x);const B=l[U];S.copy(B),S.sub(x.multiplyScalar(x.dot(B))).normalize(),T.crossVectors(L,B);const H=T.dot(c[U])<0?-1:1;a[U*4]=S.x,a[U*4+1]=S.y,a[U*4+2]=S.z,a[U*4+3]=H}for(let U=0,B=E.length;U<B;++U){const H=E[U],j=H.start,G=H.count;for(let D=j,k=j+G;D<k;D+=3)W(i[D+0]),W(i[D+1]),W(i[D+2])}},computeVertexNormals:function(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Le(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let u=0,d=i.count;u<d;u++)i.setXYZ(u,0,0,0);const n=new A,r=new A,o=new A,s=new A,a=new A,l=new A,c=new A,h=new A;if(e)for(let u=0,d=e.count;u<d;u+=3){const f=e.getX(u+0),m=e.getX(u+1),v=e.getX(u+2);n.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),o.fromBufferAttribute(t,v),c.subVectors(o,r),h.subVectors(n,r),c.cross(h),s.fromBufferAttribute(i,f),a.fromBufferAttribute(i,m),l.fromBufferAttribute(i,v),s.add(c),a.add(c),l.add(c),i.setXYZ(f,s.x,s.y,s.z),i.setXYZ(m,a.x,a.y,a.z),i.setXYZ(v,l.x,l.y,l.z)}else for(let u=0,d=t.count;u<d;u+=3)n.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),o.fromBufferAttribute(t,u+2),c.subVectors(o,r),h.subVectors(n,r),c.cross(h),i.setXYZ(u+0,c.x,c.y,c.z),i.setXYZ(u+1,c.x,c.y,c.z),i.setXYZ(u+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}},merge:function(e,t){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const i=this.attributes;for(const n in i){if(e.attributes[n]===void 0)continue;const r=i[n].array,o=e.attributes[n],s=o.array,a=o.itemSize*t,l=Math.min(s.length,r.length-a);for(let c=0,h=a;c<l;c++,h++)r[h]=s[c]}return this},normalizeNormals:function(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ot.fromBufferAttribute(e,t),ot.normalize(),e.setXYZ(t,ot.x,ot.y,ot.z)},toNonIndexed:function(){function e(s,a){const l=s.array,c=s.itemSize,h=s.normalized,u=new l.constructor(a.length*c);let d=0,f=0;for(let m=0,v=a.length;m<v;m++){d=a[m]*c;for(let _=0;_<c;_++)u[f++]=l[d++]}return new Le(u,c,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new De,i=this.index.array,n=this.attributes;for(const s in n){const a=n[s],l=e(a,i);t.setAttribute(s,l)}const r=this.morphAttributes;for(const s in r){const a=[],l=r[s];for(let c=0,h=l.length;c<h;c++){const u=l[c],d=e(u,i);a.push(d)}t.morphAttributes[s]=a}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let s=0,a=o.length;s<a;s++){const l=o[s];t.addGroup(l.start,l.count,l.materialIndex)}return t},toJSON:function(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const a=this.parameters;for(const l in a)a[l]!==void 0&&(e[l]=a[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const a in i){const l=i[a],c=l.toJSON(e.data);l.name!==""&&(c.name=l.name),e.data.attributes[a]=c}const n={};let r=!1;for(const a in this.morphAttributes){const l=this.morphAttributes[a],c=[];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=d.toJSON(e.data);d.name!==""&&(f.name=d.name),c.push(f)}c.length>0&&(n[a]=c,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const s=this.boundingSphere;return s!==null&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e},clone:function(){return new De().copy(this)},copy:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const n=e.attributes;for(const l in n){const c=n[l];this.setAttribute(l,c.clone(t))}const r=e.morphAttributes;for(const l in r){const c=[],h=r[l];for(let u=0,d=h.length;u<d;u++)c.push(h[u].clone(t));this.morphAttributes[l]=c}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,c=o.length;l<c;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const s=e.boundingBox;s!==null&&(this.boundingBox=s.clone());const a=e.boundingSphere;return a!==null&&(this.boundingSphere=a.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});const Za=new Re,bn=new qi,xs=new Zt,Pi=new A,Ri=new A,Ci=new A,ys=new A,bs=new A,ws=new A,$r=new A,eo=new A,to=new A,io=new le,no=new le,ro=new le,Ms=new A,oo=new A;function Oe(e=new De,t=new vt){we.call(this),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}Oe.prototype=Object.assign(Object.create(we.prototype),{constructor:Oe,isMesh:!0,copy:function(e){return we.prototype.copy.call(this,e),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const s=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;if(n===void 0||(i.boundingSphere===null&&i.computeBoundingSphere(),xs.copy(i.boundingSphere),xs.applyMatrix4(r),e.ray.intersectsSphere(xs)===!1)||(Za.copy(r).invert(),bn.copy(e.ray).applyMatrix4(Za),i.boundingBox!==null&&bn.intersectsBox(i.boundingBox)===!1))return;let o;if(i.isBufferGeometry){const s=i.index,a=i.attributes.position,l=i.morphAttributes.position,c=i.morphTargetsRelative,h=i.attributes.uv,u=i.attributes.uv2,d=i.groups,f=i.drawRange;if(s!==null)if(Array.isArray(n))for(let m=0,v=d.length;m<v;m++){const _=d[m],g=n[_.materialIndex],p=Math.max(_.start,f.start),E=Math.min(_.start+_.count,f.start+f.count);for(let S=p,T=E;S<T;S+=3){const x=s.getX(S),L=s.getX(S+1),W=s.getX(S+2);o=so(this,g,e,bn,a,l,c,h,u,x,L,W),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=_.materialIndex,t.push(o))}}else{const m=Math.max(0,f.start),v=Math.min(s.count,f.start+f.count);for(let _=m,g=v;_<g;_+=3){const p=s.getX(_),E=s.getX(_+1),S=s.getX(_+2);o=so(this,n,e,bn,a,l,c,h,u,p,E,S),o&&(o.faceIndex=Math.floor(_/3),t.push(o))}}else if(a!==void 0)if(Array.isArray(n))for(let m=0,v=d.length;m<v;m++){const _=d[m],g=n[_.materialIndex],p=Math.max(_.start,f.start),E=Math.min(_.start+_.count,f.start+f.count);for(let S=p,T=E;S<T;S+=3){const x=S,L=S+1,W=S+2;o=so(this,g,e,bn,a,l,c,h,u,x,L,W),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=_.materialIndex,t.push(o))}}else{const m=Math.max(0,f.start),v=Math.min(a.count,f.start+f.count);for(let _=m,g=v;_<g;_+=3){const p=_,E=_+1,S=_+2;o=so(this,n,e,bn,a,l,c,h,u,p,E,S),o&&(o.faceIndex=Math.floor(_/3),t.push(o))}}}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}});function wu(e,t,i,n,r,o,s,a){let l;if(t.side===Ze?l=n.intersectTriangle(s,o,r,!0,a):l=n.intersectTriangle(r,o,s,t.side!==on,a),l===null)return null;oo.copy(a),oo.applyMatrix4(e.matrixWorld);const c=i.ray.origin.distanceTo(oo);return c<i.near||c>i.far?null:{distance:c,point:oo.clone(),object:e}}function so(e,t,i,n,r,o,s,a,l,c,h,u){Pi.fromBufferAttribute(r,c),Ri.fromBufferAttribute(r,h),Ci.fromBufferAttribute(r,u);const d=e.morphTargetInfluences;if(t.morphTargets&&o&&d){$r.set(0,0,0),eo.set(0,0,0),to.set(0,0,0);for(let m=0,v=o.length;m<v;m++){const _=d[m],g=o[m];_!==0&&(ys.fromBufferAttribute(g,c),bs.fromBufferAttribute(g,h),ws.fromBufferAttribute(g,u),s?($r.addScaledVector(ys,_),eo.addScaledVector(bs,_),to.addScaledVector(ws,_)):($r.addScaledVector(ys.sub(Pi),_),eo.addScaledVector(bs.sub(Ri),_),to.addScaledVector(ws.sub(Ci),_)))}Pi.add($r),Ri.add(eo),Ci.add(to)}e.isSkinnedMesh&&(e.boneTransform(c,Pi),e.boneTransform(h,Ri),e.boneTransform(u,Ci));const f=wu(e,t,i,n,Pi,Ri,Ci,Ms);if(f){a&&(io.fromBufferAttribute(a,c),no.fromBufferAttribute(a,h),ro.fromBufferAttribute(a,u),f.uv=xt.getUV(Ms,Pi,Ri,Ci,io,no,ro,new le)),l&&(io.fromBufferAttribute(l,c),no.fromBufferAttribute(l,h),ro.fromBufferAttribute(l,u),f.uv2=xt.getUV(Ms,Pi,Ri,Ci,io,no,ro,new le));const m=new _u(c,h,u);xt.getNormal(Pi,Ri,Ci,m.normal),f.face=m}return f}class gi extends De{constructor(t=1,i=1,n=1,r=1,o=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:i,depth:n,widthSegments:r,heightSegments:o,depthSegments:s};const a=this;r=Math.floor(r),o=Math.floor(o),s=Math.floor(s);const l=[],c=[],h=[],u=[];let d=0,f=0;m("z","y","x",-1,-1,n,i,t,s,o,0),m("z","y","x",1,-1,n,i,-t,s,o,1),m("x","z","y",1,1,t,n,i,r,s,2),m("x","z","y",1,-1,t,n,-i,r,s,3),m("x","y","z",1,-1,t,i,n,r,o,4),m("x","y","z",-1,-1,t,i,-n,r,o,5),this.setIndex(l),this.setAttribute("position",new Fe(c,3)),this.setAttribute("normal",new Fe(h,3)),this.setAttribute("uv",new Fe(u,2));function m(v,_,g,p,E,S,T,x,L,W,U){const B=S/L,H=T/W,j=S/2,G=T/2,D=x/2,k=L+1,Y=W+1;let Z=0,$=0;const ne=new A;for(let ae=0;ae<Y;ae++){const de=ae*H-G;for(let ce=0;ce<k;ce++){const ye=ce*B-j;ne[v]=ye*p,ne[_]=de*E,ne[g]=D,c.push(ne.x,ne.y,ne.z),ne[v]=0,ne[_]=0,ne[g]=x>0?1:-1,h.push(ne.x,ne.y,ne.z),u.push(ce/L),u.push(1-ae/W),Z+=1}}for(let ae=0;ae<W;ae++)for(let de=0;de<L;de++){const ce=d+de+k*ae,ye=d+de+k*(ae+1),Ne=d+(de+1)+k*(ae+1),ie=d+(de+1)+k*ae;l.push(ce,ye,ie),l.push(ye,Ne,ie),$+=6}a.addGroup(f,$,U),f+=$,d+=Z}}}function wn(e){const t={};for(const i in e){t[i]={};for(const n in e[i]){const r=e[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?t[i][n]=r.clone():Array.isArray(r)?t[i][n]=r.slice():t[i][n]=r}}return t}function pt(e){const t={};for(let i=0;i<e.length;i++){const n=wn(e[i]);for(const r in n)t[r]=n[r]}return t}const Ja={clone:wn,merge:pt};var Mu=`void main() {
  2. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3. }`,Tu=`void main() {
  4. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  5. }`;function Qe(e){Me.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=Mu,this.fragmentShader=Tu,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}Qe.prototype=Object.create(Me.prototype),Qe.prototype.constructor=Qe,Qe.prototype.isShaderMaterial=!0,Qe.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=wn(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this},Qe.prototype.toJSON=function(e){const t=Me.prototype.toJSON.call(this,e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t};function Ni(){we.call(this),this.type="Camera",this.matrixWorldInverse=new Re,this.projectionMatrix=new Re,this.projectionMatrixInverse=new Re}Ni.prototype=Object.assign(Object.create(we.prototype),{constructor:Ni,isCamera:!0,copy:function(e,t){return we.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){e===void 0&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new A),this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){we.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(e,t){we.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return new this.constructor().copy(this)}});function $e(e=50,t=1,i=.1,n=2e3){Ni.call(this),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}$e.prototype=Object.assign(Object.create(Ni.prototype),{constructor:$e,isPerspectiveCamera:!0,copy:function(e,t){return Ni.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){const t=.5*this.getFilmHeight()/e;this.fov=Se.RAD2DEG*2*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){const e=Math.tan(Se.DEG2RAD*.5*this.fov);return .5*this.getFilmHeight()/e},getEffectiveFOV:function(){return Se.RAD2DEG*2*Math.atan(Math.tan(Se.DEG2RAD*.5*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,i,n,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const e=this.near;let t=e*Math.tan(Se.DEG2RAD*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const o=this.view;if(this.view!==null&&this.view.enabled){const a=o.fullWidth,l=o.fullHeight;r+=o.offsetX*n/a,t-=o.offsetY*i/l,n*=o.width/a,i*=o.height/l}const s=this.filmOffset;s!==0&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){const t=we.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});const Mn=90,Tn=1;function An(e,t,i){if(we.call(this),this.type="CubeCamera",i.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=i;const n=new $e(Mn,Tn,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new A(1,0,0)),this.add(n);const r=new $e(Mn,Tn,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new A(-1,0,0)),this.add(r);const o=new $e(Mn,Tn,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new A(0,1,0)),this.add(o);const s=new $e(Mn,Tn,e,t);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(new A(0,-1,0)),this.add(s);const a=new $e(Mn,Tn,e,t);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new A(0,0,1)),this.add(a);const l=new $e(Mn,Tn,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new A(0,0,-1)),this.add(l),this.update=function(c,h){this.parent===null&&this.updateMatrixWorld();const u=c.xr.enabled,d=c.getRenderTarget();c.xr.enabled=!1;const f=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,c.setRenderTarget(i,0),c.render(h,n),c.setRenderTarget(i,1),c.render(h,r),c.setRenderTarget(i,2),c.render(h,o),c.setRenderTarget(i,3),c.render(h,s),c.setRenderTarget(i,4),c.render(h,a),i.texture.generateMipmaps=f,c.setRenderTarget(i,5),c.render(h,l),c.setRenderTarget(d),c.xr.enabled=u}}An.prototype=Object.create(we.prototype),An.prototype.constructor=An;function Ii(e,t,i,n,r,o,s,a,l,c){e=e!==void 0?e:[],t=t!==void 0?t:Bo,s=s!==void 0?s:Ti,He.call(this,e,t,i,n,r,o,s,a,l,c),this.flipY=!1,this._needsFlipEnvMap=!0}Ii.prototype=Object.create(He.prototype),Ii.prototype.constructor=Ii,Ii.prototype.isCubeTexture=!0,Object.defineProperty(Ii.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});class Au extends ji{constructor(t,i,n){Number.isInteger(i)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),i=n),super(t,t,i),Object.defineProperty(this,"isWebGLCubeRenderTarget",{value:!0}),i=i||{},this.texture=new Ii(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,i){this.texture.type=i.type,this.texture.format=wt,this.texture.encoding=i.encoding,this.texture.generateMipmaps=i.generateMipmaps,this.texture.minFilter=i.minFilter,this.texture.magFilter=i.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
  6. varying vec3 vWorldDirection;
  7. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  8. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  9. }
  10. void main() {
  11. vWorldDirection = transformDirection( position, modelMatrix );
  12. #include <begin_vertex>
  13. #include <project_vertex>
  14. }
  15. `,fragmentShader:`
  16. uniform sampler2D tEquirect;
  17. varying vec3 vWorldDirection;
  18. #include <common>
  19. void main() {
  20. vec3 direction = normalize( vWorldDirection );
  21. vec2 sampleUV = equirectUv( direction );
  22. gl_FragColor = texture2D( tEquirect, sampleUV );
  23. }
  24. `},r=new gi(5,5,5),o=new Qe({name:"CubemapFromEquirect",uniforms:wn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ze,blending:er});o.uniforms.tEquirect.value=i;const s=new Oe(r,o),a=i.minFilter;return i.minFilter===an&&(i.minFilter=qe),new An(1,10,this).update(t,s),i.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,i,n,r){const o=t.getRenderTarget();for(let s=0;s<6;s++)t.setRenderTarget(this,s),t.clear(i,n,r);t.setRenderTarget(o)}}function Sn(e,t,i,n,r,o,s,a,l,c,h,u){He.call(this,null,o,s,a,l,c,n,r,h,u),this.image={data:e||null,width:t||1,height:i||1},this.magFilter=l!==void 0?l:rt,this.minFilter=c!==void 0?c:rt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Sn.prototype=Object.create(He.prototype),Sn.prototype.constructor=Sn,Sn.prototype.isDataTexture=!0;const En=new Zt,ao=new A;class lo{constructor(t,i,n,r,o,s){this.planes=[t!==void 0?t:new pi,i!==void 0?i:new pi,n!==void 0?n:new pi,r!==void 0?r:new pi,o!==void 0?o:new pi,s!==void 0?s:new pi]}set(t,i,n,r,o,s){const a=this.planes;return a[0].copy(t),a[1].copy(i),a[2].copy(n),a[3].copy(r),a[4].copy(o),a[5].copy(s),this}clone(){return new this.constructor().copy(this)}copy(t){const i=this.planes;for(let n=0;n<6;n++)i[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){const i=this.planes,n=t.elements,r=n[0],o=n[1],s=n[2],a=n[3],l=n[4],c=n[5],h=n[6],u=n[7],d=n[8],f=n[9],m=n[10],v=n[11],_=n[12],g=n[13],p=n[14],E=n[15];return i[0].setComponents(a-r,u-l,v-d,E-_).normalize(),i[1].setComponents(a+r,u+l,v+d,E+_).normalize(),i[2].setComponents(a+o,u+c,v+f,E+g).normalize(),i[3].setComponents(a-o,u-c,v-f,E-g).normalize(),i[4].setComponents(a-s,u-h,v-m,E-p).normalize(),i[5].setComponents(a+s,u+h,v+m,E+p).normalize(),this}intersectsObject(t){const i=t.geometry;return i.boundingSphere===null&&i.computeBoundingSphere(),En.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(En)}intersectsSprite(t){return En.center.set(0,0,0),En.radius=.7071067811865476,En.applyMatrix4(t.matrixWorld),this.intersectsSphere(En)}intersectsSphere(t){const i=this.planes,n=t.center,r=-t.radius;for(let o=0;o<6;o++)if(i[o].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const i=this.planes;for(let n=0;n<6;n++){const r=i[n];if(ao.x=r.normal.x>0?t.max.x:t.min.x,ao.y=r.normal.y>0?t.max.y:t.min.y,ao.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(ao)<0)return!1}return!0}containsPoint(t){const i=this.planes;for(let n=0;n<6;n++)if(i[n].distanceToPoint(t)<0)return!1;return!0}}function Ka(){let e=null,t=!1,i=null,n=null;function r(o,s){i(o,s),n=e.requestAnimationFrame(r)}return{start:function(){t!==!0&&i!==null&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(o){i=o},setContext:function(o){e=o}}}function Su(e,t){const i=t.isWebGL2,n=new WeakMap;function r(c,h){const u=c.array,d=c.usage,f=e.createBuffer();e.bindBuffer(h,f),e.bufferData(h,u,d),c.onUploadCallback();let m=5126;return u instanceof Float32Array?m=5126:u instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):u instanceof Uint16Array?c.isFloat16BufferAttribute?i?m=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):m=5123:u instanceof Int16Array?m=5122:u instanceof Uint32Array?m=5125:u instanceof Int32Array?m=5124:u instanceof Int8Array?m=5120:u instanceof Uint8Array&&(m=5121),{buffer:f,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function o(c,h,u){const d=h.array,f=h.updateRange;e.bindBuffer(u,c),f.count===-1?e.bufferSubData(u,0,d):(i?e.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):e.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);const h=n.get(c);h&&(e.deleteBuffer(h.buffer),n.delete(c))}function l(c,h){if(c.isGLBufferAttribute){const d=n.get(c);(!d||d.version<c.version)&&n.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const u=n.get(c);u===void 0?n.set(c,r(c,h)):u.version<c.version&&(o(u.buffer,c,h),u.version=c.version)}return{get:s,remove:a,update:l}}class Kt extends De{constructor(t=1,i=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:i,widthSegments:n,heightSegments:r};const o=t/2,s=i/2,a=Math.floor(n),l=Math.floor(r),c=a+1,h=l+1,u=t/a,d=i/l,f=[],m=[],v=[],_=[];for(let g=0;g<h;g++){const p=g*d-s;for(let E=0;E<c;E++){const S=E*u-o;m.push(S,-p,0),v.push(0,0,1),_.push(E/a),_.push(1-g/l)}}for(let g=0;g<l;g++)for(let p=0;p<a;p++){const E=p+c*g,S=p+c*(g+1),T=p+1+c*(g+1),x=p+1+c*g;f.push(E,S,x),f.push(S,T,x)}this.setIndex(f),this.setAttribute("position",new Fe(m,3)),this.setAttribute("normal",new Fe(v,3)),this.setAttribute("uv",new Fe(_,2))}}var Eu=`#ifdef USE_ALPHAMAP
  25. diffuseColor.a *= texture2D( alphaMap, vUv ).g;
  26. #endif`,Lu=`#ifdef USE_ALPHAMAP
  27. uniform sampler2D alphaMap;
  28. #endif`,Pu=`#ifdef ALPHATEST
  29. if ( diffuseColor.a < ALPHATEST ) discard;
  30. #endif`,Ru=`#ifdef USE_AOMAP
  31. float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
  32. reflectedLight.indirectDiffuse *= ambientOcclusion;
  33. #if defined( USE_ENVMAP ) && defined( STANDARD )
  34. float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
  35. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
  36. #endif
  37. #endif`,Cu=`#ifdef USE_AOMAP
  38. uniform sampler2D aoMap;
  39. uniform float aoMapIntensity;
  40. #endif`,Nu="vec3 transformed = vec3( position );",Iu=`vec3 objectNormal = vec3( normal );
  41. #ifdef USE_TANGENT
  42. vec3 objectTangent = vec3( tangent.xyz );
  43. #endif`,Fu=`vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
  44. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  45. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  46. vec4 r = roughness * c0 + c1;
  47. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  48. return vec2( -1.04, 1.04 ) * a004 + r.zw;
  49. }
  50. float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  51. #if defined ( PHYSICALLY_CORRECT_LIGHTS )
  52. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  53. if( cutoffDistance > 0.0 ) {
  54. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  55. }
  56. return distanceFalloff;
  57. #else
  58. if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  59. return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
  60. }
  61. return 1.0;
  62. #endif
  63. }
  64. vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
  65. return RECIPROCAL_PI * diffuseColor;
  66. }
  67. vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
  68. float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
  69. return ( 1.0 - specularColor ) * fresnel + specularColor;
  70. }
  71. vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {
  72. float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
  73. vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;
  74. return Fr * fresnel + F0;
  75. }
  76. float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
  77. float a2 = pow2( alpha );
  78. float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  79. float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  80. return 1.0 / ( gl * gv );
  81. }
  82. float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  83. float a2 = pow2( alpha );
  84. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  85. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  86. return 0.5 / max( gv + gl, EPSILON );
  87. }
  88. float D_GGX( const in float alpha, const in float dotNH ) {
  89. float a2 = pow2( alpha );
  90. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  91. return RECIPROCAL_PI * a2 / pow2( denom );
  92. }
  93. vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
  94. float alpha = pow2( roughness );
  95. vec3 halfDir = normalize( incidentLight.direction + viewDir );
  96. float dotNL = saturate( dot( normal, incidentLight.direction ) );
  97. float dotNV = saturate( dot( normal, viewDir ) );
  98. float dotNH = saturate( dot( normal, halfDir ) );
  99. float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
  100. vec3 F = F_Schlick( specularColor, dotLH );
  101. float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  102. float D = D_GGX( alpha, dotNH );
  103. return F * ( G * D );
  104. }
  105. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  106. const float LUT_SIZE = 64.0;
  107. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  108. const float LUT_BIAS = 0.5 / LUT_SIZE;
  109. float dotNV = saturate( dot( N, V ) );
  110. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  111. uv = uv * LUT_SCALE + LUT_BIAS;
  112. return uv;
  113. }
  114. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  115. float l = length( f );
  116. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  117. }
  118. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  119. float x = dot( v1, v2 );
  120. float y = abs( x );
  121. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  122. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  123. float v = a / b;
  124. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  125. return cross( v1, v2 ) * theta_sintheta;
  126. }
  127. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  128. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  129. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  130. vec3 lightNormal = cross( v1, v2 );
  131. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  132. vec3 T1, T2;
  133. T1 = normalize( V - N * dot( V, N ) );
  134. T2 = - cross( N, T1 );
  135. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  136. vec3 coords[ 4 ];
  137. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  138. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  139. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  140. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  141. coords[ 0 ] = normalize( coords[ 0 ] );
  142. coords[ 1 ] = normalize( coords[ 1 ] );
  143. coords[ 2 ] = normalize( coords[ 2 ] );
  144. coords[ 3 ] = normalize( coords[ 3 ] );
  145. vec3 vectorFormFactor = vec3( 0.0 );
  146. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  147. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  148. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  149. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  150. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  151. return vec3( result );
  152. }
  153. vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
  154. float dotNV = saturate( dot( normal, viewDir ) );
  155. vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
  156. return specularColor * brdf.x + brdf.y;
  157. }
  158. void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  159. float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
  160. vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
  161. vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
  162. vec3 FssEss = F * brdf.x + brdf.y;
  163. float Ess = brdf.x + brdf.y;
  164. float Ems = 1.0 - Ess;
  165. vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  166. singleScatter += FssEss;
  167. multiScatter += Fms * Ems;
  168. }
  169. float G_BlinnPhong_Implicit( ) {
  170. return 0.25;
  171. }
  172. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  173. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  174. }
  175. vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
  176. vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
  177. float dotNH = saturate( dot( geometry.normal, halfDir ) );
  178. float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
  179. vec3 F = F_Schlick( specularColor, dotLH );
  180. float G = G_BlinnPhong_Implicit( );
  181. float D = D_BlinnPhong( shininess, dotNH );
  182. return F * ( G * D );
  183. }
  184. float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
  185. return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
  186. }
  187. float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
  188. return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
  189. }
  190. #if defined( USE_SHEEN )
  191. float D_Charlie(float roughness, float NoH) {
  192. float invAlpha = 1.0 / roughness;
  193. float cos2h = NoH * NoH;
  194. float sin2h = max(1.0 - cos2h, 0.0078125); return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
  195. }
  196. float V_Neubelt(float NoV, float NoL) {
  197. return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
  198. }
  199. vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {
  200. vec3 N = geometry.normal;
  201. vec3 V = geometry.viewDir;
  202. vec3 H = normalize( V + L );
  203. float dotNH = saturate( dot( N, H ) );
  204. return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );
  205. }
  206. #endif`,Ou=`#ifdef USE_BUMPMAP
  207. uniform sampler2D bumpMap;
  208. uniform float bumpScale;
  209. vec2 dHdxy_fwd() {
  210. vec2 dSTdx = dFdx( vUv );
  211. vec2 dSTdy = dFdy( vUv );
  212. float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
  213. float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
  214. float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
  215. return vec2( dBx, dBy );
  216. }
  217. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
  218. vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
  219. vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
  220. vec3 vN = surf_norm;
  221. vec3 R1 = cross( vSigmaY, vN );
  222. vec3 R2 = cross( vN, vSigmaX );
  223. float fDet = dot( vSigmaX, R1 );
  224. fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  225. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  226. return normalize( abs( fDet ) * surf_norm - vGrad );
  227. }
  228. #endif`,Du=`#if NUM_CLIPPING_PLANES > 0
  229. vec4 plane;
  230. #pragma unroll_loop_start
  231. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  232. plane = clippingPlanes[ i ];
  233. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  234. }
  235. #pragma unroll_loop_end
  236. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  237. bool clipped = true;
  238. #pragma unroll_loop_start
  239. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  240. plane = clippingPlanes[ i ];
  241. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  242. }
  243. #pragma unroll_loop_end
  244. if ( clipped ) discard;
  245. #endif
  246. #endif`,Uu=`#if NUM_CLIPPING_PLANES > 0
  247. varying vec3 vClipPosition;
  248. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  249. #endif`,zu=`#if NUM_CLIPPING_PLANES > 0
  250. varying vec3 vClipPosition;
  251. #endif`,ku=`#if NUM_CLIPPING_PLANES > 0
  252. vClipPosition = - mvPosition.xyz;
  253. #endif`,Hu=`#ifdef USE_COLOR
  254. diffuseColor.rgb *= vColor;
  255. #endif`,Bu=`#ifdef USE_COLOR
  256. varying vec3 vColor;
  257. #endif`,Gu=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  258. varying vec3 vColor;
  259. #endif`,Vu=`#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  260. vColor = vec3( 1.0 );
  261. #endif
  262. #ifdef USE_COLOR
  263. vColor.xyz *= color.xyz;
  264. #endif
  265. #ifdef USE_INSTANCING_COLOR
  266. vColor.xyz *= instanceColor.xyz;
  267. #endif`,Wu=`#define PI 3.141592653589793
  268. #define PI2 6.283185307179586
  269. #define PI_HALF 1.5707963267948966
  270. #define RECIPROCAL_PI 0.3183098861837907
  271. #define RECIPROCAL_PI2 0.15915494309189535
  272. #define EPSILON 1e-6
  273. #ifndef saturate
  274. #define saturate(a) clamp( a, 0.0, 1.0 )
  275. #endif
  276. #define whiteComplement(a) ( 1.0 - saturate( a ) )
  277. float pow2( const in float x ) { return x*x; }
  278. float pow3( const in float x ) { return x*x*x; }
  279. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  280. float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
  281. highp float rand( const in vec2 uv ) {
  282. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  283. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  284. return fract(sin(sn) * c);
  285. }
  286. #ifdef HIGH_PRECISION
  287. float precisionSafeLength( vec3 v ) { return length( v ); }
  288. #else
  289. float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  290. float precisionSafeLength( vec3 v ) {
  291. float maxComponent = max3( abs( v ) );
  292. return length( v / maxComponent ) * maxComponent;
  293. }
  294. #endif
  295. struct IncidentLight {
  296. vec3 color;
  297. vec3 direction;
  298. bool visible;
  299. };
  300. struct ReflectedLight {
  301. vec3 directDiffuse;
  302. vec3 directSpecular;
  303. vec3 indirectDiffuse;
  304. vec3 indirectSpecular;
  305. };
  306. struct GeometricContext {
  307. vec3 position;
  308. vec3 normal;
  309. vec3 viewDir;
  310. #ifdef CLEARCOAT
  311. vec3 clearcoatNormal;
  312. #endif
  313. };
  314. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  315. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  316. }
  317. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  318. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  319. }
  320. vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
  321. float distance = dot( planeNormal, point - pointOnPlane );
  322. return - distance * planeNormal + point;
  323. }
  324. float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
  325. return sign( dot( point - pointOnPlane, planeNormal ) );
  326. }
  327. vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
  328. return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
  329. }
  330. mat3 transposeMat3( const in mat3 m ) {
  331. mat3 tmp;
  332. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  333. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  334. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  335. return tmp;
  336. }
  337. float linearToRelativeLuminance( const in vec3 color ) {
  338. vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
  339. return dot( weights, color.rgb );
  340. }
  341. bool isPerspectiveMatrix( mat4 m ) {
  342. return m[ 2 ][ 3 ] == - 1.0;
  343. }
  344. vec2 equirectUv( in vec3 dir ) {
  345. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  346. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  347. return vec2( u, v );
  348. }`,ju=`#ifdef ENVMAP_TYPE_CUBE_UV
  349. #define cubeUV_maxMipLevel 8.0
  350. #define cubeUV_minMipLevel 4.0
  351. #define cubeUV_maxTileSize 256.0
  352. #define cubeUV_minTileSize 16.0
  353. float getFace( vec3 direction ) {
  354. vec3 absDirection = abs( direction );
  355. float face = - 1.0;
  356. if ( absDirection.x > absDirection.z ) {
  357. if ( absDirection.x > absDirection.y )
  358. face = direction.x > 0.0 ? 0.0 : 3.0;
  359. else
  360. face = direction.y > 0.0 ? 1.0 : 4.0;
  361. } else {
  362. if ( absDirection.z > absDirection.y )
  363. face = direction.z > 0.0 ? 2.0 : 5.0;
  364. else
  365. face = direction.y > 0.0 ? 1.0 : 4.0;
  366. }
  367. return face;
  368. }
  369. vec2 getUV( vec3 direction, float face ) {
  370. vec2 uv;
  371. if ( face == 0.0 ) {
  372. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  373. } else if ( face == 1.0 ) {
  374. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  375. } else if ( face == 2.0 ) {
  376. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  377. } else if ( face == 3.0 ) {
  378. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  379. } else if ( face == 4.0 ) {
  380. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  381. } else {
  382. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  383. }
  384. return 0.5 * ( uv + 1.0 );
  385. }
  386. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  387. float face = getFace( direction );
  388. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  389. mipInt = max( mipInt, cubeUV_minMipLevel );
  390. float faceSize = exp2( mipInt );
  391. float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );
  392. vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );
  393. vec2 f = fract( uv );
  394. uv += 0.5 - f;
  395. if ( face > 2.0 ) {
  396. uv.y += faceSize;
  397. face -= 3.0;
  398. }
  399. uv.x += face * faceSize;
  400. if ( mipInt < cubeUV_maxMipLevel ) {
  401. uv.y += 2.0 * cubeUV_maxTileSize;
  402. }
  403. uv.y += filterInt * 2.0 * cubeUV_minTileSize;
  404. uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );
  405. uv *= texelSize;
  406. vec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
  407. uv.x += texelSize;
  408. vec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
  409. uv.y += texelSize;
  410. vec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
  411. uv.x -= texelSize;
  412. vec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;
  413. vec3 tm = mix( tl, tr, f.x );
  414. vec3 bm = mix( bl, br, f.x );
  415. return mix( tm, bm, f.y );
  416. }
  417. #define r0 1.0
  418. #define v0 0.339
  419. #define m0 - 2.0
  420. #define r1 0.8
  421. #define v1 0.276
  422. #define m1 - 1.0
  423. #define r4 0.4
  424. #define v4 0.046
  425. #define m4 2.0
  426. #define r5 0.305
  427. #define v5 0.016
  428. #define m5 3.0
  429. #define r6 0.21
  430. #define v6 0.0038
  431. #define m6 4.0
  432. float roughnessToMip( float roughness ) {
  433. float mip = 0.0;
  434. if ( roughness >= r1 ) {
  435. mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
  436. } else if ( roughness >= r4 ) {
  437. mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
  438. } else if ( roughness >= r5 ) {
  439. mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
  440. } else if ( roughness >= r6 ) {
  441. mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
  442. } else {
  443. mip = - 2.0 * log2( 1.16 * roughness ); }
  444. return mip;
  445. }
  446. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  447. float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );
  448. float mipF = fract( mip );
  449. float mipInt = floor( mip );
  450. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  451. if ( mipF == 0.0 ) {
  452. return vec4( color0, 1.0 );
  453. } else {
  454. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  455. return vec4( mix( color0, color1, mipF ), 1.0 );
  456. }
  457. }
  458. #endif`,Xu=`vec3 transformedNormal = objectNormal;
  459. #ifdef USE_INSTANCING
  460. mat3 m = mat3( instanceMatrix );
  461. transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
  462. transformedNormal = m * transformedNormal;
  463. #endif
  464. transformedNormal = normalMatrix * transformedNormal;
  465. #ifdef FLIP_SIDED
  466. transformedNormal = - transformedNormal;
  467. #endif
  468. #ifdef USE_TANGENT
  469. vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  470. #ifdef FLIP_SIDED
  471. transformedTangent = - transformedTangent;
  472. #endif
  473. #endif`,Yu=`#ifdef USE_DISPLACEMENTMAP
  474. uniform sampler2D displacementMap;
  475. uniform float displacementScale;
  476. uniform float displacementBias;
  477. #endif`,qu=`#ifdef USE_DISPLACEMENTMAP
  478. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
  479. #endif`,Qu=`#ifdef USE_EMISSIVEMAP
  480. vec4 emissiveColor = texture2D( emissiveMap, vUv );
  481. emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
  482. totalEmissiveRadiance *= emissiveColor.rgb;
  483. #endif`,Zu=`#ifdef USE_EMISSIVEMAP
  484. uniform sampler2D emissiveMap;
  485. #endif`,Ju="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ku=`
  486. vec4 LinearToLinear( in vec4 value ) {
  487. return value;
  488. }
  489. vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
  490. return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
  491. }
  492. vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
  493. return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
  494. }
  495. vec4 sRGBToLinear( in vec4 value ) {
  496. return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
  497. }
  498. vec4 LinearTosRGB( in vec4 value ) {
  499. 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 );
  500. }
  501. vec4 RGBEToLinear( in vec4 value ) {
  502. return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
  503. }
  504. vec4 LinearToRGBE( in vec4 value ) {
  505. float maxComponent = max( max( value.r, value.g ), value.b );
  506. float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
  507. return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
  508. }
  509. vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
  510. return vec4( value.rgb * value.a * maxRange, 1.0 );
  511. }
  512. vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
  513. float maxRGB = max( value.r, max( value.g, value.b ) );
  514. float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
  515. M = ceil( M * 255.0 ) / 255.0;
  516. return vec4( value.rgb / ( M * maxRange ), M );
  517. }
  518. vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
  519. return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
  520. }
  521. vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
  522. float maxRGB = max( value.r, max( value.g, value.b ) );
  523. float D = max( maxRange / maxRGB, 1.0 );
  524. D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
  525. return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
  526. }
  527. const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
  528. vec4 LinearToLogLuv( in vec4 value ) {
  529. vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
  530. Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
  531. vec4 vResult;
  532. vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
  533. float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
  534. vResult.w = fract( Le );
  535. vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
  536. return vResult;
  537. }
  538. const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
  539. vec4 LogLuvToLinear( in vec4 value ) {
  540. float Le = value.z * 255.0 + value.w;
  541. vec3 Xp_Y_XYZp;
  542. Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
  543. Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
  544. Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
  545. vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
  546. return vec4( max( vRGB, 0.0 ), 1.0 );
  547. }`,$u=`#ifdef USE_ENVMAP
  548. #ifdef ENV_WORLDPOS
  549. vec3 cameraToFrag;
  550. if ( isOrthographic ) {
  551. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  552. } else {
  553. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  554. }
  555. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  556. #ifdef ENVMAP_MODE_REFLECTION
  557. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  558. #else
  559. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  560. #endif
  561. #else
  562. vec3 reflectVec = vReflect;
  563. #endif
  564. #ifdef ENVMAP_TYPE_CUBE
  565. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  566. #elif defined( ENVMAP_TYPE_CUBE_UV )
  567. vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
  568. #else
  569. vec4 envColor = vec4( 0.0 );
  570. #endif
  571. #ifndef ENVMAP_TYPE_CUBE_UV
  572. envColor = envMapTexelToLinear( envColor );
  573. #endif
  574. #ifdef ENVMAP_BLENDING_MULTIPLY
  575. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  576. #elif defined( ENVMAP_BLENDING_MIX )
  577. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  578. #elif defined( ENVMAP_BLENDING_ADD )
  579. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  580. #endif
  581. #endif`,ed=`#ifdef USE_ENVMAP
  582. uniform float envMapIntensity;
  583. uniform float flipEnvMap;
  584. uniform int maxMipLevel;
  585. #ifdef ENVMAP_TYPE_CUBE
  586. uniform samplerCube envMap;
  587. #else
  588. uniform sampler2D envMap;
  589. #endif
  590. #endif`,td=`#ifdef USE_ENVMAP
  591. uniform float reflectivity;
  592. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
  593. #define ENV_WORLDPOS
  594. #endif
  595. #ifdef ENV_WORLDPOS
  596. varying vec3 vWorldPosition;
  597. uniform float refractionRatio;
  598. #else
  599. varying vec3 vReflect;
  600. #endif
  601. #endif`,id=`#ifdef USE_ENVMAP
  602. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
  603. #define ENV_WORLDPOS
  604. #endif
  605. #ifdef ENV_WORLDPOS
  606. varying vec3 vWorldPosition;
  607. #else
  608. varying vec3 vReflect;
  609. uniform float refractionRatio;
  610. #endif
  611. #endif`,nd=`#ifdef USE_ENVMAP
  612. #ifdef ENV_WORLDPOS
  613. vWorldPosition = worldPosition.xyz;
  614. #else
  615. vec3 cameraToVertex;
  616. if ( isOrthographic ) {
  617. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  618. } else {
  619. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  620. }
  621. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  622. #ifdef ENVMAP_MODE_REFLECTION
  623. vReflect = reflect( cameraToVertex, worldNormal );
  624. #else
  625. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  626. #endif
  627. #endif
  628. #endif`,rd=`#ifdef USE_FOG
  629. fogDepth = - mvPosition.z;
  630. #endif`,od=`#ifdef USE_FOG
  631. varying float fogDepth;
  632. #endif`,sd=`#ifdef USE_FOG
  633. #ifdef FOG_EXP2
  634. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
  635. #else
  636. float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
  637. #endif
  638. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  639. #endif`,ad=`#ifdef USE_FOG
  640. uniform vec3 fogColor;
  641. varying float fogDepth;
  642. #ifdef FOG_EXP2
  643. uniform float fogDensity;
  644. #else
  645. uniform float fogNear;
  646. uniform float fogFar;
  647. #endif
  648. #endif`,ld=`#ifdef USE_GRADIENTMAP
  649. uniform sampler2D gradientMap;
  650. #endif
  651. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  652. float dotNL = dot( normal, lightDirection );
  653. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  654. #ifdef USE_GRADIENTMAP
  655. return texture2D( gradientMap, coord ).rgb;
  656. #else
  657. return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
  658. #endif
  659. }`,cd=`#ifdef USE_LIGHTMAP
  660. vec4 lightMapTexel= texture2D( lightMap, vUv2 );
  661. reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  662. #endif`,hd=`#ifdef USE_LIGHTMAP
  663. uniform sampler2D lightMap;
  664. uniform float lightMapIntensity;
  665. #endif`,ud=`vec3 diffuse = vec3( 1.0 );
  666. GeometricContext geometry;
  667. geometry.position = mvPosition.xyz;
  668. geometry.normal = normalize( transformedNormal );
  669. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
  670. GeometricContext backGeometry;
  671. backGeometry.position = geometry.position;
  672. backGeometry.normal = -geometry.normal;
  673. backGeometry.viewDir = geometry.viewDir;
  674. vLightFront = vec3( 0.0 );
  675. vIndirectFront = vec3( 0.0 );
  676. #ifdef DOUBLE_SIDED
  677. vLightBack = vec3( 0.0 );
  678. vIndirectBack = vec3( 0.0 );
  679. #endif
  680. IncidentLight directLight;
  681. float dotNL;
  682. vec3 directLightColor_Diffuse;
  683. vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
  684. vIndirectFront += getLightProbeIrradiance( lightProbe, geometry );
  685. #ifdef DOUBLE_SIDED
  686. vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
  687. vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );
  688. #endif
  689. #if NUM_POINT_LIGHTS > 0
  690. #pragma unroll_loop_start
  691. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  692. getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );
  693. dotNL = dot( geometry.normal, directLight.direction );
  694. directLightColor_Diffuse = PI * directLight.color;
  695. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  696. #ifdef DOUBLE_SIDED
  697. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  698. #endif
  699. }
  700. #pragma unroll_loop_end
  701. #endif
  702. #if NUM_SPOT_LIGHTS > 0
  703. #pragma unroll_loop_start
  704. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  705. getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );
  706. dotNL = dot( geometry.normal, directLight.direction );
  707. directLightColor_Diffuse = PI * directLight.color;
  708. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  709. #ifdef DOUBLE_SIDED
  710. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  711. #endif
  712. }
  713. #pragma unroll_loop_end
  714. #endif
  715. #if NUM_DIR_LIGHTS > 0
  716. #pragma unroll_loop_start
  717. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  718. getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );
  719. dotNL = dot( geometry.normal, directLight.direction );
  720. directLightColor_Diffuse = PI * directLight.color;
  721. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  722. #ifdef DOUBLE_SIDED
  723. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  724. #endif
  725. }
  726. #pragma unroll_loop_end
  727. #endif
  728. #if NUM_HEMI_LIGHTS > 0
  729. #pragma unroll_loop_start
  730. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  731. vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
  732. #ifdef DOUBLE_SIDED
  733. vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
  734. #endif
  735. }
  736. #pragma unroll_loop_end
  737. #endif`,dd=`uniform bool receiveShadow;
  738. uniform vec3 ambientLightColor;
  739. uniform vec3 lightProbe[ 9 ];
  740. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  741. float x = normal.x, y = normal.y, z = normal.z;
  742. vec3 result = shCoefficients[ 0 ] * 0.886227;
  743. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  744. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  745. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  746. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  747. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  748. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  749. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  750. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  751. return result;
  752. }
  753. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {
  754. vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
  755. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  756. return irradiance;
  757. }
  758. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  759. vec3 irradiance = ambientLightColor;
  760. #ifndef PHYSICALLY_CORRECT_LIGHTS
  761. irradiance *= PI;
  762. #endif
  763. return irradiance;
  764. }
  765. #if NUM_DIR_LIGHTS > 0
  766. struct DirectionalLight {
  767. vec3 direction;
  768. vec3 color;
  769. };
  770. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  771. void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
  772. directLight.color = directionalLight.color;
  773. directLight.direction = directionalLight.direction;
  774. directLight.visible = true;
  775. }
  776. #endif
  777. #if NUM_POINT_LIGHTS > 0
  778. struct PointLight {
  779. vec3 position;
  780. vec3 color;
  781. float distance;
  782. float decay;
  783. };
  784. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  785. void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
  786. vec3 lVector = pointLight.position - geometry.position;
  787. directLight.direction = normalize( lVector );
  788. float lightDistance = length( lVector );
  789. directLight.color = pointLight.color;
  790. directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
  791. directLight.visible = ( directLight.color != vec3( 0.0 ) );
  792. }
  793. #endif
  794. #if NUM_SPOT_LIGHTS > 0
  795. struct SpotLight {
  796. vec3 position;
  797. vec3 direction;
  798. vec3 color;
  799. float distance;
  800. float decay;
  801. float coneCos;
  802. float penumbraCos;
  803. };
  804. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  805. void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
  806. vec3 lVector = spotLight.position - geometry.position;
  807. directLight.direction = normalize( lVector );
  808. float lightDistance = length( lVector );
  809. float angleCos = dot( directLight.direction, spotLight.direction );
  810. if ( angleCos > spotLight.coneCos ) {
  811. float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  812. directLight.color = spotLight.color;
  813. directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
  814. directLight.visible = true;
  815. } else {
  816. directLight.color = vec3( 0.0 );
  817. directLight.visible = false;
  818. }
  819. }
  820. #endif
  821. #if NUM_RECT_AREA_LIGHTS > 0
  822. struct RectAreaLight {
  823. vec3 color;
  824. vec3 position;
  825. vec3 halfWidth;
  826. vec3 halfHeight;
  827. };
  828. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  829. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  830. #endif
  831. #if NUM_HEMI_LIGHTS > 0
  832. struct HemisphereLight {
  833. vec3 direction;
  834. vec3 skyColor;
  835. vec3 groundColor;
  836. };
  837. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  838. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
  839. float dotNL = dot( geometry.normal, hemiLight.direction );
  840. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  841. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  842. #ifndef PHYSICALLY_CORRECT_LIGHTS
  843. irradiance *= PI;
  844. #endif
  845. return irradiance;
  846. }
  847. #endif`,pd=`#if defined( USE_ENVMAP )
  848. #ifdef ENVMAP_MODE_REFRACTION
  849. uniform float refractionRatio;
  850. #endif
  851. vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
  852. vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
  853. #ifdef ENVMAP_TYPE_CUBE
  854. vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
  855. #ifdef TEXTURE_LOD_EXT
  856. vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
  857. #else
  858. vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
  859. #endif
  860. envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
  861. #elif defined( ENVMAP_TYPE_CUBE_UV )
  862. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  863. #else
  864. vec4 envMapColor = vec4( 0.0 );
  865. #endif
  866. return PI * envMapColor.rgb * envMapIntensity;
  867. }
  868. float getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {
  869. float maxMIPLevelScalar = float( maxMIPLevel );
  870. float sigma = PI * roughness * roughness / ( 1.0 + roughness );
  871. float desiredMIPLevel = maxMIPLevelScalar + log2( sigma );
  872. return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
  873. }
  874. vec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {
  875. #ifdef ENVMAP_MODE_REFLECTION
  876. vec3 reflectVec = reflect( -viewDir, normal );
  877. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  878. #else
  879. vec3 reflectVec = refract( -viewDir, normal, refractionRatio );
  880. #endif
  881. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  882. float specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );
  883. #ifdef ENVMAP_TYPE_CUBE
  884. vec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
  885. #ifdef TEXTURE_LOD_EXT
  886. vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
  887. #else
  888. vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
  889. #endif
  890. envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
  891. #elif defined( ENVMAP_TYPE_CUBE_UV )
  892. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  893. #endif
  894. return envMapColor.rgb * envMapIntensity;
  895. }
  896. #endif`,fd=`ToonMaterial material;
  897. material.diffuseColor = diffuseColor.rgb;`,md=`varying vec3 vViewPosition;
  898. #ifndef FLAT_SHADED
  899. varying vec3 vNormal;
  900. #endif
  901. struct ToonMaterial {
  902. vec3 diffuseColor;
  903. };
  904. void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  905. vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
  906. #ifndef PHYSICALLY_CORRECT_LIGHTS
  907. irradiance *= PI;
  908. #endif
  909. reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  910. }
  911. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  912. reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  913. }
  914. #define RE_Direct RE_Direct_Toon
  915. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
  916. #define Material_LightProbeLOD( material ) (0)`,gd=`BlinnPhongMaterial material;
  917. material.diffuseColor = diffuseColor.rgb;
  918. material.specularColor = specular;
  919. material.specularShininess = shininess;
  920. material.specularStrength = specularStrength;`,vd=`varying vec3 vViewPosition;
  921. #ifndef FLAT_SHADED
  922. varying vec3 vNormal;
  923. #endif
  924. struct BlinnPhongMaterial {
  925. vec3 diffuseColor;
  926. vec3 specularColor;
  927. float specularShininess;
  928. float specularStrength;
  929. };
  930. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  931. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  932. vec3 irradiance = dotNL * directLight.color;
  933. #ifndef PHYSICALLY_CORRECT_LIGHTS
  934. irradiance *= PI;
  935. #endif
  936. reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  937. reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
  938. }
  939. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  940. reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  941. }
  942. #define RE_Direct RE_Direct_BlinnPhong
  943. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
  944. #define Material_LightProbeLOD( material ) (0)`,_d=`PhysicalMaterial material;
  945. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  946. vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
  947. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  948. material.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;
  949. material.specularRoughness = min( material.specularRoughness, 1.0 );
  950. #ifdef REFLECTIVITY
  951. material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
  952. #else
  953. material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
  954. #endif
  955. #ifdef CLEARCOAT
  956. material.clearcoat = clearcoat;
  957. material.clearcoatRoughness = clearcoatRoughness;
  958. #ifdef USE_CLEARCOATMAP
  959. material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
  960. #endif
  961. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  962. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
  963. #endif
  964. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  965. material.clearcoatRoughness += geometryRoughness;
  966. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  967. #endif
  968. #ifdef USE_SHEEN
  969. material.sheenColor = sheen;
  970. #endif`,xd=`struct PhysicalMaterial {
  971. vec3 diffuseColor;
  972. float specularRoughness;
  973. vec3 specularColor;
  974. #ifdef CLEARCOAT
  975. float clearcoat;
  976. float clearcoatRoughness;
  977. #endif
  978. #ifdef USE_SHEEN
  979. vec3 sheenColor;
  980. #endif
  981. };
  982. #define MAXIMUM_SPECULAR_COEFFICIENT 0.16
  983. #define DEFAULT_SPECULAR_COEFFICIENT 0.04
  984. float clearcoatDHRApprox( const in float roughness, const in float dotNL ) {
  985. return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );
  986. }
  987. #if NUM_RECT_AREA_LIGHTS > 0
  988. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  989. vec3 normal = geometry.normal;
  990. vec3 viewDir = geometry.viewDir;
  991. vec3 position = geometry.position;
  992. vec3 lightPos = rectAreaLight.position;
  993. vec3 halfWidth = rectAreaLight.halfWidth;
  994. vec3 halfHeight = rectAreaLight.halfHeight;
  995. vec3 lightColor = rectAreaLight.color;
  996. float roughness = material.specularRoughness;
  997. vec3 rectCoords[ 4 ];
  998. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  999. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1000. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1001. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1002. vec4 t1 = texture2D( ltc_1, uv );
  1003. vec4 t2 = texture2D( ltc_2, uv );
  1004. mat3 mInv = mat3(
  1005. vec3( t1.x, 0, t1.y ),
  1006. vec3( 0, 1, 0 ),
  1007. vec3( t1.z, 0, t1.w )
  1008. );
  1009. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1010. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1011. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1012. }
  1013. #endif
  1014. void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1015. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  1016. vec3 irradiance = dotNL * directLight.color;
  1017. #ifndef PHYSICALLY_CORRECT_LIGHTS
  1018. irradiance *= PI;
  1019. #endif
  1020. #ifdef CLEARCOAT
  1021. float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
  1022. vec3 ccIrradiance = ccDotNL * directLight.color;
  1023. #ifndef PHYSICALLY_CORRECT_LIGHTS
  1024. ccIrradiance *= PI;
  1025. #endif
  1026. float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
  1027. reflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
  1028. #else
  1029. float clearcoatDHR = 0.0;
  1030. #endif
  1031. #ifdef USE_SHEEN
  1032. reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(
  1033. material.specularRoughness,
  1034. directLight.direction,
  1035. geometry,
  1036. material.sheenColor
  1037. );
  1038. #else
  1039. reflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);
  1040. #endif
  1041. reflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  1042. }
  1043. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1044. reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
  1045. }
  1046. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1047. #ifdef CLEARCOAT
  1048. float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
  1049. reflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );
  1050. float ccDotNL = ccDotNV;
  1051. float clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );
  1052. #else
  1053. float clearcoatDHR = 0.0;
  1054. #endif
  1055. float clearcoatInv = 1.0 - clearcoatDHR;
  1056. vec3 singleScattering = vec3( 0.0 );
  1057. vec3 multiScattering = vec3( 0.0 );
  1058. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1059. BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
  1060. vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
  1061. reflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;
  1062. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1063. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1064. }
  1065. #define RE_Direct RE_Direct_Physical
  1066. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1067. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1068. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1069. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1070. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1071. }`,yd=`
  1072. GeometricContext geometry;
  1073. geometry.position = - vViewPosition;
  1074. geometry.normal = normal;
  1075. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1076. #ifdef CLEARCOAT
  1077. geometry.clearcoatNormal = clearcoatNormal;
  1078. #endif
  1079. IncidentLight directLight;
  1080. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1081. PointLight pointLight;
  1082. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1083. PointLightShadow pointLightShadow;
  1084. #endif
  1085. #pragma unroll_loop_start
  1086. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1087. pointLight = pointLights[ i ];
  1088. getPointDirectLightIrradiance( pointLight, geometry, directLight );
  1089. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1090. pointLightShadow = pointLightShadows[ i ];
  1091. directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1092. #endif
  1093. RE_Direct( directLight, geometry, material, reflectedLight );
  1094. }
  1095. #pragma unroll_loop_end
  1096. #endif
  1097. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1098. SpotLight spotLight;
  1099. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1100. SpotLightShadow spotLightShadow;
  1101. #endif
  1102. #pragma unroll_loop_start
  1103. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1104. spotLight = spotLights[ i ];
  1105. getSpotDirectLightIrradiance( spotLight, geometry, directLight );
  1106. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1107. spotLightShadow = spotLightShadows[ i ];
  1108. directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
  1109. #endif
  1110. RE_Direct( directLight, geometry, material, reflectedLight );
  1111. }
  1112. #pragma unroll_loop_end
  1113. #endif
  1114. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1115. DirectionalLight directionalLight;
  1116. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1117. DirectionalLightShadow directionalLightShadow;
  1118. #endif
  1119. #pragma unroll_loop_start
  1120. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1121. directionalLight = directionalLights[ i ];
  1122. getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );
  1123. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1124. directionalLightShadow = directionalLightShadows[ i ];
  1125. directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1126. #endif
  1127. RE_Direct( directLight, geometry, material, reflectedLight );
  1128. }
  1129. #pragma unroll_loop_end
  1130. #endif
  1131. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1132. RectAreaLight rectAreaLight;
  1133. #pragma unroll_loop_start
  1134. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1135. rectAreaLight = rectAreaLights[ i ];
  1136. RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
  1137. }
  1138. #pragma unroll_loop_end
  1139. #endif
  1140. #if defined( RE_IndirectDiffuse )
  1141. vec3 iblIrradiance = vec3( 0.0 );
  1142. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1143. irradiance += getLightProbeIrradiance( lightProbe, geometry );
  1144. #if ( NUM_HEMI_LIGHTS > 0 )
  1145. #pragma unroll_loop_start
  1146. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1147. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
  1148. }
  1149. #pragma unroll_loop_end
  1150. #endif
  1151. #endif
  1152. #if defined( RE_IndirectSpecular )
  1153. vec3 radiance = vec3( 0.0 );
  1154. vec3 clearcoatRadiance = vec3( 0.0 );
  1155. #endif`,bd=`#if defined( RE_IndirectDiffuse )
  1156. #ifdef USE_LIGHTMAP
  1157. vec4 lightMapTexel= texture2D( lightMap, vUv2 );
  1158. vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  1159. #ifndef PHYSICALLY_CORRECT_LIGHTS
  1160. lightMapIrradiance *= PI;
  1161. #endif
  1162. irradiance += lightMapIrradiance;
  1163. #endif
  1164. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1165. iblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );
  1166. #endif
  1167. #endif
  1168. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1169. radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );
  1170. #ifdef CLEARCOAT
  1171. clearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );
  1172. #endif
  1173. #endif`,wd=`#if defined( RE_IndirectDiffuse )
  1174. RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
  1175. #endif
  1176. #if defined( RE_IndirectSpecular )
  1177. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
  1178. #endif`,Md=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  1179. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1180. #endif`,Td=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  1181. uniform float logDepthBufFC;
  1182. varying float vFragDepth;
  1183. varying float vIsPerspective;
  1184. #endif`,Ad=`#ifdef USE_LOGDEPTHBUF
  1185. #ifdef USE_LOGDEPTHBUF_EXT
  1186. varying float vFragDepth;
  1187. varying float vIsPerspective;
  1188. #else
  1189. uniform float logDepthBufFC;
  1190. #endif
  1191. #endif`,Sd=`#ifdef USE_LOGDEPTHBUF
  1192. #ifdef USE_LOGDEPTHBUF_EXT
  1193. vFragDepth = 1.0 + gl_Position.w;
  1194. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1195. #else
  1196. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  1197. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  1198. gl_Position.z *= gl_Position.w;
  1199. }
  1200. #endif
  1201. #endif`,Ed=`#ifdef USE_MAP
  1202. vec4 texelColor = texture2D( map, vUv );
  1203. texelColor = mapTexelToLinear( texelColor );
  1204. diffuseColor *= texelColor;
  1205. #endif`,Ld=`#ifdef USE_MAP
  1206. uniform sampler2D map;
  1207. #endif`,Pd=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1208. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1209. #endif
  1210. #ifdef USE_MAP
  1211. vec4 mapTexel = texture2D( map, uv );
  1212. diffuseColor *= mapTexelToLinear( mapTexel );
  1213. #endif
  1214. #ifdef USE_ALPHAMAP
  1215. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1216. #endif`,Rd=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1217. uniform mat3 uvTransform;
  1218. #endif
  1219. #ifdef USE_MAP
  1220. uniform sampler2D map;
  1221. #endif
  1222. #ifdef USE_ALPHAMAP
  1223. uniform sampler2D alphaMap;
  1224. #endif`,Cd=`float metalnessFactor = metalness;
  1225. #ifdef USE_METALNESSMAP
  1226. vec4 texelMetalness = texture2D( metalnessMap, vUv );
  1227. metalnessFactor *= texelMetalness.b;
  1228. #endif`,Nd=`#ifdef USE_METALNESSMAP
  1229. uniform sampler2D metalnessMap;
  1230. #endif`,Id=`#ifdef USE_MORPHNORMALS
  1231. objectNormal *= morphTargetBaseInfluence;
  1232. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  1233. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  1234. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  1235. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  1236. #endif`,Fd=`#ifdef USE_MORPHTARGETS
  1237. uniform float morphTargetBaseInfluence;
  1238. #ifndef USE_MORPHNORMALS
  1239. uniform float morphTargetInfluences[ 8 ];
  1240. #else
  1241. uniform float morphTargetInfluences[ 4 ];
  1242. #endif
  1243. #endif`,Od=`#ifdef USE_MORPHTARGETS
  1244. transformed *= morphTargetBaseInfluence;
  1245. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  1246. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  1247. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  1248. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  1249. #ifndef USE_MORPHNORMALS
  1250. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  1251. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  1252. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  1253. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  1254. #endif
  1255. #endif`,Dd=`#ifdef FLAT_SHADED
  1256. vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
  1257. vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
  1258. vec3 normal = normalize( cross( fdx, fdy ) );
  1259. #else
  1260. vec3 normal = normalize( vNormal );
  1261. #ifdef DOUBLE_SIDED
  1262. normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1263. #endif
  1264. #ifdef USE_TANGENT
  1265. vec3 tangent = normalize( vTangent );
  1266. vec3 bitangent = normalize( vBitangent );
  1267. #ifdef DOUBLE_SIDED
  1268. tangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1269. bitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1270. #endif
  1271. #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
  1272. mat3 vTBN = mat3( tangent, bitangent, normal );
  1273. #endif
  1274. #endif
  1275. #endif
  1276. vec3 geometryNormal = normal;`,Ud=`#ifdef OBJECTSPACE_NORMALMAP
  1277. normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  1278. #ifdef FLIP_SIDED
  1279. normal = - normal;
  1280. #endif
  1281. #ifdef DOUBLE_SIDED
  1282. normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1283. #endif
  1284. normal = normalize( normalMatrix * normal );
  1285. #elif defined( TANGENTSPACE_NORMALMAP )
  1286. vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  1287. mapN.xy *= normalScale;
  1288. #ifdef USE_TANGENT
  1289. normal = normalize( vTBN * mapN );
  1290. #else
  1291. normal = perturbNormal2Arb( -vViewPosition, normal, mapN );
  1292. #endif
  1293. #elif defined( USE_BUMPMAP )
  1294. normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
  1295. #endif`,zd=`#ifdef USE_NORMALMAP
  1296. uniform sampler2D normalMap;
  1297. uniform vec2 normalScale;
  1298. #endif
  1299. #ifdef OBJECTSPACE_NORMALMAP
  1300. uniform mat3 normalMatrix;
  1301. #endif
  1302. #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
  1303. vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {
  1304. vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
  1305. vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
  1306. vec2 st0 = dFdx( vUv.st );
  1307. vec2 st1 = dFdy( vUv.st );
  1308. float scale = sign( st1.t * st0.s - st0.t * st1.s );
  1309. vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
  1310. vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
  1311. vec3 N = normalize( surf_norm );
  1312. mat3 tsn = mat3( S, T, N );
  1313. mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  1314. return normalize( tsn * mapN );
  1315. }
  1316. #endif`,kd=`#ifdef CLEARCOAT
  1317. vec3 clearcoatNormal = geometryNormal;
  1318. #endif`,Hd=`#ifdef USE_CLEARCOAT_NORMALMAP
  1319. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
  1320. clearcoatMapN.xy *= clearcoatNormalScale;
  1321. #ifdef USE_TANGENT
  1322. clearcoatNormal = normalize( vTBN * clearcoatMapN );
  1323. #else
  1324. clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );
  1325. #endif
  1326. #endif`,Bd=`#ifdef USE_CLEARCOATMAP
  1327. uniform sampler2D clearcoatMap;
  1328. #endif
  1329. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1330. uniform sampler2D clearcoatRoughnessMap;
  1331. #endif
  1332. #ifdef USE_CLEARCOAT_NORMALMAP
  1333. uniform sampler2D clearcoatNormalMap;
  1334. uniform vec2 clearcoatNormalScale;
  1335. #endif`,Gd=`vec3 packNormalToRGB( const in vec3 normal ) {
  1336. return normalize( normal ) * 0.5 + 0.5;
  1337. }
  1338. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1339. return 2.0 * rgb.xyz - 1.0;
  1340. }
  1341. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  1342. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  1343. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  1344. const float ShiftRight8 = 1. / 256.;
  1345. vec4 packDepthToRGBA( const in float v ) {
  1346. vec4 r = vec4( fract( v * PackFactors ), v );
  1347. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  1348. }
  1349. float unpackRGBAToDepth( const in vec4 v ) {
  1350. return dot( v, UnpackFactors );
  1351. }
  1352. vec4 pack2HalfToRGBA( vec2 v ) {
  1353. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
  1354. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
  1355. }
  1356. vec2 unpackRGBATo2Half( vec4 v ) {
  1357. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1358. }
  1359. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1360. return ( viewZ + near ) / ( near - far );
  1361. }
  1362. float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
  1363. return linearClipZ * ( near - far ) - near;
  1364. }
  1365. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1366. return (( near + viewZ ) * far ) / (( far - near ) * viewZ );
  1367. }
  1368. float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
  1369. return ( near * far ) / ( ( far - near ) * invClipZ - far );
  1370. }`,Vd=`#ifdef PREMULTIPLIED_ALPHA
  1371. gl_FragColor.rgb *= gl_FragColor.a;
  1372. #endif`,Wd=`vec4 mvPosition = vec4( transformed, 1.0 );
  1373. #ifdef USE_INSTANCING
  1374. mvPosition = instanceMatrix * mvPosition;
  1375. #endif
  1376. mvPosition = modelViewMatrix * mvPosition;
  1377. gl_Position = projectionMatrix * mvPosition;`,jd=`#ifdef DITHERING
  1378. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1379. #endif`,Xd=`#ifdef DITHERING
  1380. vec3 dithering( vec3 color ) {
  1381. float grid_position = rand( gl_FragCoord.xy );
  1382. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1383. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1384. return color + dither_shift_RGB;
  1385. }
  1386. #endif`,Yd=`float roughnessFactor = roughness;
  1387. #ifdef USE_ROUGHNESSMAP
  1388. vec4 texelRoughness = texture2D( roughnessMap, vUv );
  1389. roughnessFactor *= texelRoughness.g;
  1390. #endif`,qd=`#ifdef USE_ROUGHNESSMAP
  1391. uniform sampler2D roughnessMap;
  1392. #endif`,Qd=`#ifdef USE_SHADOWMAP
  1393. #if NUM_DIR_LIGHT_SHADOWS > 0
  1394. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1395. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1396. struct DirectionalLightShadow {
  1397. float shadowBias;
  1398. float shadowNormalBias;
  1399. float shadowRadius;
  1400. vec2 shadowMapSize;
  1401. };
  1402. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1403. #endif
  1404. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1405. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1406. varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
  1407. struct SpotLightShadow {
  1408. float shadowBias;
  1409. float shadowNormalBias;
  1410. float shadowRadius;
  1411. vec2 shadowMapSize;
  1412. };
  1413. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1414. #endif
  1415. #if NUM_POINT_LIGHT_SHADOWS > 0
  1416. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1417. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1418. struct PointLightShadow {
  1419. float shadowBias;
  1420. float shadowNormalBias;
  1421. float shadowRadius;
  1422. vec2 shadowMapSize;
  1423. float shadowCameraNear;
  1424. float shadowCameraFar;
  1425. };
  1426. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1427. #endif
  1428. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1429. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  1430. }
  1431. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1432. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1433. }
  1434. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  1435. float occlusion = 1.0;
  1436. vec2 distribution = texture2DDistribution( shadow, uv );
  1437. float hard_shadow = step( compare , distribution.x );
  1438. if (hard_shadow != 1.0 ) {
  1439. float distance = compare - distribution.x ;
  1440. float variance = max( 0.00000, distribution.y * distribution.y );
  1441. 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 );
  1442. }
  1443. return occlusion;
  1444. }
  1445. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1446. float shadow = 1.0;
  1447. shadowCoord.xyz /= shadowCoord.w;
  1448. shadowCoord.z += shadowBias;
  1449. bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
  1450. bool inFrustum = all( inFrustumVec );
  1451. bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
  1452. bool frustumTest = all( frustumTestVec );
  1453. if ( frustumTest ) {
  1454. #if defined( SHADOWMAP_TYPE_PCF )
  1455. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1456. float dx0 = - texelSize.x * shadowRadius;
  1457. float dy0 = - texelSize.y * shadowRadius;
  1458. float dx1 = + texelSize.x * shadowRadius;
  1459. float dy1 = + texelSize.y * shadowRadius;
  1460. float dx2 = dx0 / 2.0;
  1461. float dy2 = dy0 / 2.0;
  1462. float dx3 = dx1 / 2.0;
  1463. float dy3 = dy1 / 2.0;
  1464. shadow = (
  1465. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1466. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1467. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1468. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1469. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1470. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1471. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1472. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1473. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1474. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1475. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1476. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1477. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1478. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1479. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1480. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1481. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1482. ) * ( 1.0 / 17.0 );
  1483. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1484. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1485. float dx = texelSize.x;
  1486. float dy = texelSize.y;
  1487. vec2 uv = shadowCoord.xy;
  1488. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1489. uv -= f * texelSize;
  1490. shadow = (
  1491. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1492. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1493. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1494. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1495. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1496. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1497. f.x ) +
  1498. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1499. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1500. f.x ) +
  1501. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1502. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1503. f.y ) +
  1504. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1505. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1506. f.y ) +
  1507. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1508. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1509. f.x ),
  1510. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1511. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1512. f.x ),
  1513. f.y )
  1514. ) * ( 1.0 / 9.0 );
  1515. #elif defined( SHADOWMAP_TYPE_VSM )
  1516. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1517. #else
  1518. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1519. #endif
  1520. }
  1521. return shadow;
  1522. }
  1523. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1524. vec3 absV = abs( v );
  1525. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1526. absV *= scaleToCube;
  1527. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1528. vec2 planar = v.xy;
  1529. float almostATexel = 1.5 * texelSizeY;
  1530. float almostOne = 1.0 - almostATexel;
  1531. if ( absV.z >= almostOne ) {
  1532. if ( v.z > 0.0 )
  1533. planar.x = 4.0 - v.x;
  1534. } else if ( absV.x >= almostOne ) {
  1535. float signX = sign( v.x );
  1536. planar.x = v.z * signX + 2.0 * signX;
  1537. } else if ( absV.y >= almostOne ) {
  1538. float signY = sign( v.y );
  1539. planar.x = v.x + 2.0 * signY + 2.0;
  1540. planar.y = v.z * signY - 2.0;
  1541. }
  1542. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1543. }
  1544. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1545. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1546. vec3 lightToPosition = shadowCoord.xyz;
  1547. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1548. vec3 bd3D = normalize( lightToPosition );
  1549. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1550. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1551. return (
  1552. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1553. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1554. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1555. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1556. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1557. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1558. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1559. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1560. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1561. ) * ( 1.0 / 9.0 );
  1562. #else
  1563. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1564. #endif
  1565. }
  1566. #endif`,Zd=`#ifdef USE_SHADOWMAP
  1567. #if NUM_DIR_LIGHT_SHADOWS > 0
  1568. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1569. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1570. struct DirectionalLightShadow {
  1571. float shadowBias;
  1572. float shadowNormalBias;
  1573. float shadowRadius;
  1574. vec2 shadowMapSize;
  1575. };
  1576. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1577. #endif
  1578. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1579. uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
  1580. varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
  1581. struct SpotLightShadow {
  1582. float shadowBias;
  1583. float shadowNormalBias;
  1584. float shadowRadius;
  1585. vec2 shadowMapSize;
  1586. };
  1587. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1588. #endif
  1589. #if NUM_POINT_LIGHT_SHADOWS > 0
  1590. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1591. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1592. struct PointLightShadow {
  1593. float shadowBias;
  1594. float shadowNormalBias;
  1595. float shadowRadius;
  1596. vec2 shadowMapSize;
  1597. float shadowCameraNear;
  1598. float shadowCameraFar;
  1599. };
  1600. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1601. #endif
  1602. #endif`,Jd=`#ifdef USE_SHADOWMAP
  1603. #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
  1604. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1605. vec4 shadowWorldPosition;
  1606. #endif
  1607. #if NUM_DIR_LIGHT_SHADOWS > 0
  1608. #pragma unroll_loop_start
  1609. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1610. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1611. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1612. }
  1613. #pragma unroll_loop_end
  1614. #endif
  1615. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1616. #pragma unroll_loop_start
  1617. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1618. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
  1619. vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
  1620. }
  1621. #pragma unroll_loop_end
  1622. #endif
  1623. #if NUM_POINT_LIGHT_SHADOWS > 0
  1624. #pragma unroll_loop_start
  1625. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1626. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1627. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1628. }
  1629. #pragma unroll_loop_end
  1630. #endif
  1631. #endif`,Kd=`float getShadowMask() {
  1632. float shadow = 1.0;
  1633. #ifdef USE_SHADOWMAP
  1634. #if NUM_DIR_LIGHT_SHADOWS > 0
  1635. DirectionalLightShadow directionalLight;
  1636. #pragma unroll_loop_start
  1637. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1638. directionalLight = directionalLightShadows[ i ];
  1639. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1640. }
  1641. #pragma unroll_loop_end
  1642. #endif
  1643. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1644. SpotLightShadow spotLight;
  1645. #pragma unroll_loop_start
  1646. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1647. spotLight = spotLightShadows[ i ];
  1648. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
  1649. }
  1650. #pragma unroll_loop_end
  1651. #endif
  1652. #if NUM_POINT_LIGHT_SHADOWS > 0
  1653. PointLightShadow pointLight;
  1654. #pragma unroll_loop_start
  1655. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1656. pointLight = pointLightShadows[ i ];
  1657. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1658. }
  1659. #pragma unroll_loop_end
  1660. #endif
  1661. #endif
  1662. return shadow;
  1663. }`,$d=`#ifdef USE_SKINNING
  1664. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1665. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1666. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1667. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1668. #endif`,ep=`#ifdef USE_SKINNING
  1669. uniform mat4 bindMatrix;
  1670. uniform mat4 bindMatrixInverse;
  1671. #ifdef BONE_TEXTURE
  1672. uniform highp sampler2D boneTexture;
  1673. uniform int boneTextureSize;
  1674. mat4 getBoneMatrix( const in float i ) {
  1675. float j = i * 4.0;
  1676. float x = mod( j, float( boneTextureSize ) );
  1677. float y = floor( j / float( boneTextureSize ) );
  1678. float dx = 1.0 / float( boneTextureSize );
  1679. float dy = 1.0 / float( boneTextureSize );
  1680. y = dy * ( y + 0.5 );
  1681. vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
  1682. vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
  1683. vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
  1684. vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
  1685. mat4 bone = mat4( v1, v2, v3, v4 );
  1686. return bone;
  1687. }
  1688. #else
  1689. uniform mat4 boneMatrices[ MAX_BONES ];
  1690. mat4 getBoneMatrix( const in float i ) {
  1691. mat4 bone = boneMatrices[ int(i) ];
  1692. return bone;
  1693. }
  1694. #endif
  1695. #endif`,tp=`#ifdef USE_SKINNING
  1696. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  1697. vec4 skinned = vec4( 0.0 );
  1698. skinned += boneMatX * skinVertex * skinWeight.x;
  1699. skinned += boneMatY * skinVertex * skinWeight.y;
  1700. skinned += boneMatZ * skinVertex * skinWeight.z;
  1701. skinned += boneMatW * skinVertex * skinWeight.w;
  1702. transformed = ( bindMatrixInverse * skinned ).xyz;
  1703. #endif`,ip=`#ifdef USE_SKINNING
  1704. mat4 skinMatrix = mat4( 0.0 );
  1705. skinMatrix += skinWeight.x * boneMatX;
  1706. skinMatrix += skinWeight.y * boneMatY;
  1707. skinMatrix += skinWeight.z * boneMatZ;
  1708. skinMatrix += skinWeight.w * boneMatW;
  1709. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  1710. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  1711. #ifdef USE_TANGENT
  1712. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  1713. #endif
  1714. #endif`,np=`float specularStrength;
  1715. #ifdef USE_SPECULARMAP
  1716. vec4 texelSpecular = texture2D( specularMap, vUv );
  1717. specularStrength = texelSpecular.r;
  1718. #else
  1719. specularStrength = 1.0;
  1720. #endif`,rp=`#ifdef USE_SPECULARMAP
  1721. uniform sampler2D specularMap;
  1722. #endif`,op=`#if defined( TONE_MAPPING )
  1723. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  1724. #endif`,sp=`#ifndef saturate
  1725. #define saturate(a) clamp( a, 0.0, 1.0 )
  1726. #endif
  1727. uniform float toneMappingExposure;
  1728. vec3 LinearToneMapping( vec3 color ) {
  1729. return toneMappingExposure * color;
  1730. }
  1731. vec3 ReinhardToneMapping( vec3 color ) {
  1732. color *= toneMappingExposure;
  1733. return saturate( color / ( vec3( 1.0 ) + color ) );
  1734. }
  1735. vec3 OptimizedCineonToneMapping( vec3 color ) {
  1736. color *= toneMappingExposure;
  1737. color = max( vec3( 0.0 ), color - 0.004 );
  1738. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  1739. }
  1740. vec3 RRTAndODTFit( vec3 v ) {
  1741. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  1742. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  1743. return a / b;
  1744. }
  1745. vec3 ACESFilmicToneMapping( vec3 color ) {
  1746. const mat3 ACESInputMat = mat3(
  1747. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  1748. vec3( 0.04823, 0.01566, 0.83777 )
  1749. );
  1750. const mat3 ACESOutputMat = mat3(
  1751. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  1752. vec3( -0.07367, -0.00605, 1.07602 )
  1753. );
  1754. color *= toneMappingExposure / 0.6;
  1755. color = ACESInputMat * color;
  1756. color = RRTAndODTFit( color );
  1757. color = ACESOutputMat * color;
  1758. return saturate( color );
  1759. }
  1760. vec3 CustomToneMapping( vec3 color ) { return color; }`,ap=`#ifdef USE_TRANSMISSIONMAP
  1761. totalTransmission *= texture2D( transmissionMap, vUv ).r;
  1762. #endif`,lp=`#ifdef USE_TRANSMISSIONMAP
  1763. uniform sampler2D transmissionMap;
  1764. #endif`,cp=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
  1765. varying vec2 vUv;
  1766. #endif`,hp=`#ifdef USE_UV
  1767. #ifdef UVS_VERTEX_ONLY
  1768. vec2 vUv;
  1769. #else
  1770. varying vec2 vUv;
  1771. #endif
  1772. uniform mat3 uvTransform;
  1773. #endif`,up=`#ifdef USE_UV
  1774. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  1775. #endif`,dp=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1776. varying vec2 vUv2;
  1777. #endif`,pp=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1778. attribute vec2 uv2;
  1779. varying vec2 vUv2;
  1780. uniform mat3 uv2Transform;
  1781. #endif`,fp=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1782. vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
  1783. #endif`,mp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
  1784. vec4 worldPosition = vec4( transformed, 1.0 );
  1785. #ifdef USE_INSTANCING
  1786. worldPosition = instanceMatrix * worldPosition;
  1787. #endif
  1788. worldPosition = modelMatrix * worldPosition;
  1789. #endif`,gp=`uniform sampler2D t2D;
  1790. varying vec2 vUv;
  1791. void main() {
  1792. vec4 texColor = texture2D( t2D, vUv );
  1793. gl_FragColor = mapTexelToLinear( texColor );
  1794. #include <tonemapping_fragment>
  1795. #include <encodings_fragment>
  1796. }`,vp=`varying vec2 vUv;
  1797. uniform mat3 uvTransform;
  1798. void main() {
  1799. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  1800. gl_Position = vec4( position.xy, 1.0, 1.0 );
  1801. }`,_p=`#include <envmap_common_pars_fragment>
  1802. uniform float opacity;
  1803. varying vec3 vWorldDirection;
  1804. #include <cube_uv_reflection_fragment>
  1805. void main() {
  1806. vec3 vReflect = vWorldDirection;
  1807. #include <envmap_fragment>
  1808. gl_FragColor = envColor;
  1809. gl_FragColor.a *= opacity;
  1810. #include <tonemapping_fragment>
  1811. #include <encodings_fragment>
  1812. }`,xp=`varying vec3 vWorldDirection;
  1813. #include <common>
  1814. void main() {
  1815. vWorldDirection = transformDirection( position, modelMatrix );
  1816. #include <begin_vertex>
  1817. #include <project_vertex>
  1818. gl_Position.z = gl_Position.w;
  1819. }`,yp=`#if DEPTH_PACKING == 3200
  1820. uniform float opacity;
  1821. #endif
  1822. #include <common>
  1823. #include <packing>
  1824. #include <uv_pars_fragment>
  1825. #include <map_pars_fragment>
  1826. #include <alphamap_pars_fragment>
  1827. #include <logdepthbuf_pars_fragment>
  1828. #include <clipping_planes_pars_fragment>
  1829. varying vec2 vHighPrecisionZW;
  1830. void main() {
  1831. #include <clipping_planes_fragment>
  1832. vec4 diffuseColor = vec4( 1.0 );
  1833. #if DEPTH_PACKING == 3200
  1834. diffuseColor.a = opacity;
  1835. #endif
  1836. #include <map_fragment>
  1837. #include <alphamap_fragment>
  1838. #include <alphatest_fragment>
  1839. #include <logdepthbuf_fragment>
  1840. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  1841. #if DEPTH_PACKING == 3200
  1842. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  1843. #elif DEPTH_PACKING == 3201
  1844. gl_FragColor = packDepthToRGBA( fragCoordZ );
  1845. #endif
  1846. }`,bp=`#include <common>
  1847. #include <uv_pars_vertex>
  1848. #include <displacementmap_pars_vertex>
  1849. #include <morphtarget_pars_vertex>
  1850. #include <skinning_pars_vertex>
  1851. #include <logdepthbuf_pars_vertex>
  1852. #include <clipping_planes_pars_vertex>
  1853. varying vec2 vHighPrecisionZW;
  1854. void main() {
  1855. #include <uv_vertex>
  1856. #include <skinbase_vertex>
  1857. #ifdef USE_DISPLACEMENTMAP
  1858. #include <beginnormal_vertex>
  1859. #include <morphnormal_vertex>
  1860. #include <skinnormal_vertex>
  1861. #endif
  1862. #include <begin_vertex>
  1863. #include <morphtarget_vertex>
  1864. #include <skinning_vertex>
  1865. #include <displacementmap_vertex>
  1866. #include <project_vertex>
  1867. #include <logdepthbuf_vertex>
  1868. #include <clipping_planes_vertex>
  1869. vHighPrecisionZW = gl_Position.zw;
  1870. }`,wp=`#define DISTANCE
  1871. uniform vec3 referencePosition;
  1872. uniform float nearDistance;
  1873. uniform float farDistance;
  1874. varying vec3 vWorldPosition;
  1875. #include <common>
  1876. #include <packing>
  1877. #include <uv_pars_fragment>
  1878. #include <map_pars_fragment>
  1879. #include <alphamap_pars_fragment>
  1880. #include <clipping_planes_pars_fragment>
  1881. void main () {
  1882. #include <clipping_planes_fragment>
  1883. vec4 diffuseColor = vec4( 1.0 );
  1884. #include <map_fragment>
  1885. #include <alphamap_fragment>
  1886. #include <alphatest_fragment>
  1887. float dist = length( vWorldPosition - referencePosition );
  1888. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  1889. dist = saturate( dist );
  1890. gl_FragColor = packDepthToRGBA( dist );
  1891. }`,Mp=`#define DISTANCE
  1892. varying vec3 vWorldPosition;
  1893. #include <common>
  1894. #include <uv_pars_vertex>
  1895. #include <displacementmap_pars_vertex>
  1896. #include <morphtarget_pars_vertex>
  1897. #include <skinning_pars_vertex>
  1898. #include <clipping_planes_pars_vertex>
  1899. void main() {
  1900. #include <uv_vertex>
  1901. #include <skinbase_vertex>
  1902. #ifdef USE_DISPLACEMENTMAP
  1903. #include <beginnormal_vertex>
  1904. #include <morphnormal_vertex>
  1905. #include <skinnormal_vertex>
  1906. #endif
  1907. #include <begin_vertex>
  1908. #include <morphtarget_vertex>
  1909. #include <skinning_vertex>
  1910. #include <displacementmap_vertex>
  1911. #include <project_vertex>
  1912. #include <worldpos_vertex>
  1913. #include <clipping_planes_vertex>
  1914. vWorldPosition = worldPosition.xyz;
  1915. }`,Tp=`uniform sampler2D tEquirect;
  1916. varying vec3 vWorldDirection;
  1917. #include <common>
  1918. void main() {
  1919. vec3 direction = normalize( vWorldDirection );
  1920. vec2 sampleUV = equirectUv( direction );
  1921. vec4 texColor = texture2D( tEquirect, sampleUV );
  1922. gl_FragColor = mapTexelToLinear( texColor );
  1923. #include <tonemapping_fragment>
  1924. #include <encodings_fragment>
  1925. }`,Ap=`varying vec3 vWorldDirection;
  1926. #include <common>
  1927. void main() {
  1928. vWorldDirection = transformDirection( position, modelMatrix );
  1929. #include <begin_vertex>
  1930. #include <project_vertex>
  1931. }`,Sp=`uniform vec3 diffuse;
  1932. uniform float opacity;
  1933. uniform float dashSize;
  1934. uniform float totalSize;
  1935. varying float vLineDistance;
  1936. #include <common>
  1937. #include <color_pars_fragment>
  1938. #include <fog_pars_fragment>
  1939. #include <logdepthbuf_pars_fragment>
  1940. #include <clipping_planes_pars_fragment>
  1941. void main() {
  1942. #include <clipping_planes_fragment>
  1943. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  1944. discard;
  1945. }
  1946. vec3 outgoingLight = vec3( 0.0 );
  1947. vec4 diffuseColor = vec4( diffuse, opacity );
  1948. #include <logdepthbuf_fragment>
  1949. #include <color_fragment>
  1950. outgoingLight = diffuseColor.rgb;
  1951. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  1952. #include <tonemapping_fragment>
  1953. #include <encodings_fragment>
  1954. #include <fog_fragment>
  1955. #include <premultiplied_alpha_fragment>
  1956. }`,Ep=`uniform float scale;
  1957. attribute float lineDistance;
  1958. varying float vLineDistance;
  1959. #include <common>
  1960. #include <color_pars_vertex>
  1961. #include <fog_pars_vertex>
  1962. #include <morphtarget_pars_vertex>
  1963. #include <logdepthbuf_pars_vertex>
  1964. #include <clipping_planes_pars_vertex>
  1965. void main() {
  1966. vLineDistance = scale * lineDistance;
  1967. #include <color_vertex>
  1968. #include <begin_vertex>
  1969. #include <morphtarget_vertex>
  1970. #include <project_vertex>
  1971. #include <logdepthbuf_vertex>
  1972. #include <clipping_planes_vertex>
  1973. #include <fog_vertex>
  1974. }`,Lp=`uniform vec3 diffuse;
  1975. uniform float opacity;
  1976. #ifndef FLAT_SHADED
  1977. varying vec3 vNormal;
  1978. #endif
  1979. #include <common>
  1980. #include <dithering_pars_fragment>
  1981. #include <color_pars_fragment>
  1982. #include <uv_pars_fragment>
  1983. #include <uv2_pars_fragment>
  1984. #include <map_pars_fragment>
  1985. #include <alphamap_pars_fragment>
  1986. #include <aomap_pars_fragment>
  1987. #include <lightmap_pars_fragment>
  1988. #include <envmap_common_pars_fragment>
  1989. #include <envmap_pars_fragment>
  1990. #include <cube_uv_reflection_fragment>
  1991. #include <fog_pars_fragment>
  1992. #include <specularmap_pars_fragment>
  1993. #include <logdepthbuf_pars_fragment>
  1994. #include <clipping_planes_pars_fragment>
  1995. void main() {
  1996. #include <clipping_planes_fragment>
  1997. vec4 diffuseColor = vec4( diffuse, opacity );
  1998. #include <logdepthbuf_fragment>
  1999. #include <map_fragment>
  2000. #include <color_fragment>
  2001. #include <alphamap_fragment>
  2002. #include <alphatest_fragment>
  2003. #include <specularmap_fragment>
  2004. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2005. #ifdef USE_LIGHTMAP
  2006. vec4 lightMapTexel= texture2D( lightMap, vUv2 );
  2007. reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  2008. #else
  2009. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2010. #endif
  2011. #include <aomap_fragment>
  2012. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2013. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2014. #include <envmap_fragment>
  2015. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2016. #include <tonemapping_fragment>
  2017. #include <encodings_fragment>
  2018. #include <fog_fragment>
  2019. #include <premultiplied_alpha_fragment>
  2020. #include <dithering_fragment>
  2021. }`,Pp=`#include <common>
  2022. #include <uv_pars_vertex>
  2023. #include <uv2_pars_vertex>
  2024. #include <envmap_pars_vertex>
  2025. #include <color_pars_vertex>
  2026. #include <fog_pars_vertex>
  2027. #include <morphtarget_pars_vertex>
  2028. #include <skinning_pars_vertex>
  2029. #include <logdepthbuf_pars_vertex>
  2030. #include <clipping_planes_pars_vertex>
  2031. void main() {
  2032. #include <uv_vertex>
  2033. #include <uv2_vertex>
  2034. #include <color_vertex>
  2035. #include <skinbase_vertex>
  2036. #ifdef USE_ENVMAP
  2037. #include <beginnormal_vertex>
  2038. #include <morphnormal_vertex>
  2039. #include <skinnormal_vertex>
  2040. #include <defaultnormal_vertex>
  2041. #endif
  2042. #include <begin_vertex>
  2043. #include <morphtarget_vertex>
  2044. #include <skinning_vertex>
  2045. #include <project_vertex>
  2046. #include <logdepthbuf_vertex>
  2047. #include <worldpos_vertex>
  2048. #include <clipping_planes_vertex>
  2049. #include <envmap_vertex>
  2050. #include <fog_vertex>
  2051. }`,Rp=`uniform vec3 diffuse;
  2052. uniform vec3 emissive;
  2053. uniform float opacity;
  2054. varying vec3 vLightFront;
  2055. varying vec3 vIndirectFront;
  2056. #ifdef DOUBLE_SIDED
  2057. varying vec3 vLightBack;
  2058. varying vec3 vIndirectBack;
  2059. #endif
  2060. #include <common>
  2061. #include <packing>
  2062. #include <dithering_pars_fragment>
  2063. #include <color_pars_fragment>
  2064. #include <uv_pars_fragment>
  2065. #include <uv2_pars_fragment>
  2066. #include <map_pars_fragment>
  2067. #include <alphamap_pars_fragment>
  2068. #include <aomap_pars_fragment>
  2069. #include <lightmap_pars_fragment>
  2070. #include <emissivemap_pars_fragment>
  2071. #include <envmap_common_pars_fragment>
  2072. #include <envmap_pars_fragment>
  2073. #include <cube_uv_reflection_fragment>
  2074. #include <bsdfs>
  2075. #include <lights_pars_begin>
  2076. #include <fog_pars_fragment>
  2077. #include <shadowmap_pars_fragment>
  2078. #include <shadowmask_pars_fragment>
  2079. #include <specularmap_pars_fragment>
  2080. #include <logdepthbuf_pars_fragment>
  2081. #include <clipping_planes_pars_fragment>
  2082. void main() {
  2083. #include <clipping_planes_fragment>
  2084. vec4 diffuseColor = vec4( diffuse, opacity );
  2085. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2086. vec3 totalEmissiveRadiance = emissive;
  2087. #include <logdepthbuf_fragment>
  2088. #include <map_fragment>
  2089. #include <color_fragment>
  2090. #include <alphamap_fragment>
  2091. #include <alphatest_fragment>
  2092. #include <specularmap_fragment>
  2093. #include <emissivemap_fragment>
  2094. #ifdef DOUBLE_SIDED
  2095. reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
  2096. #else
  2097. reflectedLight.indirectDiffuse += vIndirectFront;
  2098. #endif
  2099. #include <lightmap_fragment>
  2100. reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
  2101. #ifdef DOUBLE_SIDED
  2102. reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
  2103. #else
  2104. reflectedLight.directDiffuse = vLightFront;
  2105. #endif
  2106. reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();
  2107. #include <aomap_fragment>
  2108. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2109. #include <envmap_fragment>
  2110. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2111. #include <tonemapping_fragment>
  2112. #include <encodings_fragment>
  2113. #include <fog_fragment>
  2114. #include <premultiplied_alpha_fragment>
  2115. #include <dithering_fragment>
  2116. }`,Cp=`#define LAMBERT
  2117. varying vec3 vLightFront;
  2118. varying vec3 vIndirectFront;
  2119. #ifdef DOUBLE_SIDED
  2120. varying vec3 vLightBack;
  2121. varying vec3 vIndirectBack;
  2122. #endif
  2123. #include <common>
  2124. #include <uv_pars_vertex>
  2125. #include <uv2_pars_vertex>
  2126. #include <envmap_pars_vertex>
  2127. #include <bsdfs>
  2128. #include <lights_pars_begin>
  2129. #include <color_pars_vertex>
  2130. #include <fog_pars_vertex>
  2131. #include <morphtarget_pars_vertex>
  2132. #include <skinning_pars_vertex>
  2133. #include <shadowmap_pars_vertex>
  2134. #include <logdepthbuf_pars_vertex>
  2135. #include <clipping_planes_pars_vertex>
  2136. void main() {
  2137. #include <uv_vertex>
  2138. #include <uv2_vertex>
  2139. #include <color_vertex>
  2140. #include <beginnormal_vertex>
  2141. #include <morphnormal_vertex>
  2142. #include <skinbase_vertex>
  2143. #include <skinnormal_vertex>
  2144. #include <defaultnormal_vertex>
  2145. #include <begin_vertex>
  2146. #include <morphtarget_vertex>
  2147. #include <skinning_vertex>
  2148. #include <project_vertex>
  2149. #include <logdepthbuf_vertex>
  2150. #include <clipping_planes_vertex>
  2151. #include <worldpos_vertex>
  2152. #include <envmap_vertex>
  2153. #include <lights_lambert_vertex>
  2154. #include <shadowmap_vertex>
  2155. #include <fog_vertex>
  2156. }`,Np=`#define MATCAP
  2157. uniform vec3 diffuse;
  2158. uniform float opacity;
  2159. uniform sampler2D matcap;
  2160. varying vec3 vViewPosition;
  2161. #ifndef FLAT_SHADED
  2162. varying vec3 vNormal;
  2163. #endif
  2164. #include <common>
  2165. #include <dithering_pars_fragment>
  2166. #include <color_pars_fragment>
  2167. #include <uv_pars_fragment>
  2168. #include <map_pars_fragment>
  2169. #include <alphamap_pars_fragment>
  2170. #include <fog_pars_fragment>
  2171. #include <bumpmap_pars_fragment>
  2172. #include <normalmap_pars_fragment>
  2173. #include <logdepthbuf_pars_fragment>
  2174. #include <clipping_planes_pars_fragment>
  2175. void main() {
  2176. #include <clipping_planes_fragment>
  2177. vec4 diffuseColor = vec4( diffuse, opacity );
  2178. #include <logdepthbuf_fragment>
  2179. #include <map_fragment>
  2180. #include <color_fragment>
  2181. #include <alphamap_fragment>
  2182. #include <alphatest_fragment>
  2183. #include <normal_fragment_begin>
  2184. #include <normal_fragment_maps>
  2185. vec3 viewDir = normalize( vViewPosition );
  2186. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  2187. vec3 y = cross( viewDir, x );
  2188. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  2189. #ifdef USE_MATCAP
  2190. vec4 matcapColor = texture2D( matcap, uv );
  2191. matcapColor = matcapTexelToLinear( matcapColor );
  2192. #else
  2193. vec4 matcapColor = vec4( 1.0 );
  2194. #endif
  2195. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  2196. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2197. #include <tonemapping_fragment>
  2198. #include <encodings_fragment>
  2199. #include <fog_fragment>
  2200. #include <premultiplied_alpha_fragment>
  2201. #include <dithering_fragment>
  2202. }`,Ip=`#define MATCAP
  2203. varying vec3 vViewPosition;
  2204. #ifndef FLAT_SHADED
  2205. varying vec3 vNormal;
  2206. #endif
  2207. #include <common>
  2208. #include <uv_pars_vertex>
  2209. #include <color_pars_vertex>
  2210. #include <displacementmap_pars_vertex>
  2211. #include <fog_pars_vertex>
  2212. #include <morphtarget_pars_vertex>
  2213. #include <skinning_pars_vertex>
  2214. #include <logdepthbuf_pars_vertex>
  2215. #include <clipping_planes_pars_vertex>
  2216. void main() {
  2217. #include <uv_vertex>
  2218. #include <color_vertex>
  2219. #include <beginnormal_vertex>
  2220. #include <morphnormal_vertex>
  2221. #include <skinbase_vertex>
  2222. #include <skinnormal_vertex>
  2223. #include <defaultnormal_vertex>
  2224. #ifndef FLAT_SHADED
  2225. vNormal = normalize( transformedNormal );
  2226. #endif
  2227. #include <begin_vertex>
  2228. #include <morphtarget_vertex>
  2229. #include <skinning_vertex>
  2230. #include <displacementmap_vertex>
  2231. #include <project_vertex>
  2232. #include <logdepthbuf_vertex>
  2233. #include <clipping_planes_vertex>
  2234. #include <fog_vertex>
  2235. vViewPosition = - mvPosition.xyz;
  2236. }`,Fp=`#define TOON
  2237. uniform vec3 diffuse;
  2238. uniform vec3 emissive;
  2239. uniform float opacity;
  2240. #include <common>
  2241. #include <packing>
  2242. #include <dithering_pars_fragment>
  2243. #include <color_pars_fragment>
  2244. #include <uv_pars_fragment>
  2245. #include <uv2_pars_fragment>
  2246. #include <map_pars_fragment>
  2247. #include <alphamap_pars_fragment>
  2248. #include <aomap_pars_fragment>
  2249. #include <lightmap_pars_fragment>
  2250. #include <emissivemap_pars_fragment>
  2251. #include <gradientmap_pars_fragment>
  2252. #include <fog_pars_fragment>
  2253. #include <bsdfs>
  2254. #include <lights_pars_begin>
  2255. #include <lights_toon_pars_fragment>
  2256. #include <shadowmap_pars_fragment>
  2257. #include <bumpmap_pars_fragment>
  2258. #include <normalmap_pars_fragment>
  2259. #include <logdepthbuf_pars_fragment>
  2260. #include <clipping_planes_pars_fragment>
  2261. void main() {
  2262. #include <clipping_planes_fragment>
  2263. vec4 diffuseColor = vec4( diffuse, opacity );
  2264. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2265. vec3 totalEmissiveRadiance = emissive;
  2266. #include <logdepthbuf_fragment>
  2267. #include <map_fragment>
  2268. #include <color_fragment>
  2269. #include <alphamap_fragment>
  2270. #include <alphatest_fragment>
  2271. #include <normal_fragment_begin>
  2272. #include <normal_fragment_maps>
  2273. #include <emissivemap_fragment>
  2274. #include <lights_toon_fragment>
  2275. #include <lights_fragment_begin>
  2276. #include <lights_fragment_maps>
  2277. #include <lights_fragment_end>
  2278. #include <aomap_fragment>
  2279. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2280. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2281. #include <tonemapping_fragment>
  2282. #include <encodings_fragment>
  2283. #include <fog_fragment>
  2284. #include <premultiplied_alpha_fragment>
  2285. #include <dithering_fragment>
  2286. }`,Op=`#define TOON
  2287. varying vec3 vViewPosition;
  2288. #ifndef FLAT_SHADED
  2289. varying vec3 vNormal;
  2290. #endif
  2291. #include <common>
  2292. #include <uv_pars_vertex>
  2293. #include <uv2_pars_vertex>
  2294. #include <displacementmap_pars_vertex>
  2295. #include <color_pars_vertex>
  2296. #include <fog_pars_vertex>
  2297. #include <morphtarget_pars_vertex>
  2298. #include <skinning_pars_vertex>
  2299. #include <shadowmap_pars_vertex>
  2300. #include <logdepthbuf_pars_vertex>
  2301. #include <clipping_planes_pars_vertex>
  2302. void main() {
  2303. #include <uv_vertex>
  2304. #include <uv2_vertex>
  2305. #include <color_vertex>
  2306. #include <beginnormal_vertex>
  2307. #include <morphnormal_vertex>
  2308. #include <skinbase_vertex>
  2309. #include <skinnormal_vertex>
  2310. #include <defaultnormal_vertex>
  2311. #ifndef FLAT_SHADED
  2312. vNormal = normalize( transformedNormal );
  2313. #endif
  2314. #include <begin_vertex>
  2315. #include <morphtarget_vertex>
  2316. #include <skinning_vertex>
  2317. #include <displacementmap_vertex>
  2318. #include <project_vertex>
  2319. #include <logdepthbuf_vertex>
  2320. #include <clipping_planes_vertex>
  2321. vViewPosition = - mvPosition.xyz;
  2322. #include <worldpos_vertex>
  2323. #include <shadowmap_vertex>
  2324. #include <fog_vertex>
  2325. }`,Dp=`#define PHONG
  2326. uniform vec3 diffuse;
  2327. uniform vec3 emissive;
  2328. uniform vec3 specular;
  2329. uniform float shininess;
  2330. uniform float opacity;
  2331. #include <common>
  2332. #include <packing>
  2333. #include <dithering_pars_fragment>
  2334. #include <color_pars_fragment>
  2335. #include <uv_pars_fragment>
  2336. #include <uv2_pars_fragment>
  2337. #include <map_pars_fragment>
  2338. #include <alphamap_pars_fragment>
  2339. #include <aomap_pars_fragment>
  2340. #include <lightmap_pars_fragment>
  2341. #include <emissivemap_pars_fragment>
  2342. #include <envmap_common_pars_fragment>
  2343. #include <envmap_pars_fragment>
  2344. #include <cube_uv_reflection_fragment>
  2345. #include <fog_pars_fragment>
  2346. #include <bsdfs>
  2347. #include <lights_pars_begin>
  2348. #include <lights_phong_pars_fragment>
  2349. #include <shadowmap_pars_fragment>
  2350. #include <bumpmap_pars_fragment>
  2351. #include <normalmap_pars_fragment>
  2352. #include <specularmap_pars_fragment>
  2353. #include <logdepthbuf_pars_fragment>
  2354. #include <clipping_planes_pars_fragment>
  2355. void main() {
  2356. #include <clipping_planes_fragment>
  2357. vec4 diffuseColor = vec4( diffuse, opacity );
  2358. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2359. vec3 totalEmissiveRadiance = emissive;
  2360. #include <logdepthbuf_fragment>
  2361. #include <map_fragment>
  2362. #include <color_fragment>
  2363. #include <alphamap_fragment>
  2364. #include <alphatest_fragment>
  2365. #include <specularmap_fragment>
  2366. #include <normal_fragment_begin>
  2367. #include <normal_fragment_maps>
  2368. #include <emissivemap_fragment>
  2369. #include <lights_phong_fragment>
  2370. #include <lights_fragment_begin>
  2371. #include <lights_fragment_maps>
  2372. #include <lights_fragment_end>
  2373. #include <aomap_fragment>
  2374. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  2375. #include <envmap_fragment>
  2376. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2377. #include <tonemapping_fragment>
  2378. #include <encodings_fragment>
  2379. #include <fog_fragment>
  2380. #include <premultiplied_alpha_fragment>
  2381. #include <dithering_fragment>
  2382. }`,Up=`#define PHONG
  2383. varying vec3 vViewPosition;
  2384. #ifndef FLAT_SHADED
  2385. varying vec3 vNormal;
  2386. #endif
  2387. #include <common>
  2388. #include <uv_pars_vertex>
  2389. #include <uv2_pars_vertex>
  2390. #include <displacementmap_pars_vertex>
  2391. #include <envmap_pars_vertex>
  2392. #include <color_pars_vertex>
  2393. #include <fog_pars_vertex>
  2394. #include <morphtarget_pars_vertex>
  2395. #include <skinning_pars_vertex>
  2396. #include <shadowmap_pars_vertex>
  2397. #include <logdepthbuf_pars_vertex>
  2398. #include <clipping_planes_pars_vertex>
  2399. void main() {
  2400. #include <uv_vertex>
  2401. #include <uv2_vertex>
  2402. #include <color_vertex>
  2403. #include <beginnormal_vertex>
  2404. #include <morphnormal_vertex>
  2405. #include <skinbase_vertex>
  2406. #include <skinnormal_vertex>
  2407. #include <defaultnormal_vertex>
  2408. #ifndef FLAT_SHADED
  2409. vNormal = normalize( transformedNormal );
  2410. #endif
  2411. #include <begin_vertex>
  2412. #include <morphtarget_vertex>
  2413. #include <skinning_vertex>
  2414. #include <displacementmap_vertex>
  2415. #include <project_vertex>
  2416. #include <logdepthbuf_vertex>
  2417. #include <clipping_planes_vertex>
  2418. vViewPosition = - mvPosition.xyz;
  2419. #include <worldpos_vertex>
  2420. #include <envmap_vertex>
  2421. #include <shadowmap_vertex>
  2422. #include <fog_vertex>
  2423. }`,zp=`#define STANDARD
  2424. #ifdef PHYSICAL
  2425. #define REFLECTIVITY
  2426. #define CLEARCOAT
  2427. #define TRANSMISSION
  2428. #endif
  2429. uniform vec3 diffuse;
  2430. uniform vec3 emissive;
  2431. uniform float roughness;
  2432. uniform float metalness;
  2433. uniform float opacity;
  2434. #ifdef TRANSMISSION
  2435. uniform float transmission;
  2436. #endif
  2437. #ifdef REFLECTIVITY
  2438. uniform float reflectivity;
  2439. #endif
  2440. #ifdef CLEARCOAT
  2441. uniform float clearcoat;
  2442. uniform float clearcoatRoughness;
  2443. #endif
  2444. #ifdef USE_SHEEN
  2445. uniform vec3 sheen;
  2446. #endif
  2447. varying vec3 vViewPosition;
  2448. #ifndef FLAT_SHADED
  2449. varying vec3 vNormal;
  2450. #ifdef USE_TANGENT
  2451. varying vec3 vTangent;
  2452. varying vec3 vBitangent;
  2453. #endif
  2454. #endif
  2455. #include <common>
  2456. #include <packing>
  2457. #include <dithering_pars_fragment>
  2458. #include <color_pars_fragment>
  2459. #include <uv_pars_fragment>
  2460. #include <uv2_pars_fragment>
  2461. #include <map_pars_fragment>
  2462. #include <alphamap_pars_fragment>
  2463. #include <aomap_pars_fragment>
  2464. #include <lightmap_pars_fragment>
  2465. #include <emissivemap_pars_fragment>
  2466. #include <transmissionmap_pars_fragment>
  2467. #include <bsdfs>
  2468. #include <cube_uv_reflection_fragment>
  2469. #include <envmap_common_pars_fragment>
  2470. #include <envmap_physical_pars_fragment>
  2471. #include <fog_pars_fragment>
  2472. #include <lights_pars_begin>
  2473. #include <lights_physical_pars_fragment>
  2474. #include <shadowmap_pars_fragment>
  2475. #include <bumpmap_pars_fragment>
  2476. #include <normalmap_pars_fragment>
  2477. #include <clearcoat_pars_fragment>
  2478. #include <roughnessmap_pars_fragment>
  2479. #include <metalnessmap_pars_fragment>
  2480. #include <logdepthbuf_pars_fragment>
  2481. #include <clipping_planes_pars_fragment>
  2482. void main() {
  2483. #include <clipping_planes_fragment>
  2484. vec4 diffuseColor = vec4( diffuse, opacity );
  2485. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2486. vec3 totalEmissiveRadiance = emissive;
  2487. #ifdef TRANSMISSION
  2488. float totalTransmission = transmission;
  2489. #endif
  2490. #include <logdepthbuf_fragment>
  2491. #include <map_fragment>
  2492. #include <color_fragment>
  2493. #include <alphamap_fragment>
  2494. #include <alphatest_fragment>
  2495. #include <roughnessmap_fragment>
  2496. #include <metalnessmap_fragment>
  2497. #include <normal_fragment_begin>
  2498. #include <normal_fragment_maps>
  2499. #include <clearcoat_normal_fragment_begin>
  2500. #include <clearcoat_normal_fragment_maps>
  2501. #include <emissivemap_fragment>
  2502. #include <transmissionmap_fragment>
  2503. #include <lights_physical_fragment>
  2504. #include <lights_fragment_begin>
  2505. #include <lights_fragment_maps>
  2506. #include <lights_fragment_end>
  2507. #include <aomap_fragment>
  2508. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  2509. #ifdef TRANSMISSION
  2510. diffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );
  2511. #endif
  2512. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2513. #include <tonemapping_fragment>
  2514. #include <encodings_fragment>
  2515. #include <fog_fragment>
  2516. #include <premultiplied_alpha_fragment>
  2517. #include <dithering_fragment>
  2518. }`,kp=`#define STANDARD
  2519. varying vec3 vViewPosition;
  2520. #ifndef FLAT_SHADED
  2521. varying vec3 vNormal;
  2522. #ifdef USE_TANGENT
  2523. varying vec3 vTangent;
  2524. varying vec3 vBitangent;
  2525. #endif
  2526. #endif
  2527. #include <common>
  2528. #include <uv_pars_vertex>
  2529. #include <uv2_pars_vertex>
  2530. #include <displacementmap_pars_vertex>
  2531. #include <color_pars_vertex>
  2532. #include <fog_pars_vertex>
  2533. #include <morphtarget_pars_vertex>
  2534. #include <skinning_pars_vertex>
  2535. #include <shadowmap_pars_vertex>
  2536. #include <logdepthbuf_pars_vertex>
  2537. #include <clipping_planes_pars_vertex>
  2538. void main() {
  2539. #include <uv_vertex>
  2540. #include <uv2_vertex>
  2541. #include <color_vertex>
  2542. #include <beginnormal_vertex>
  2543. #include <morphnormal_vertex>
  2544. #include <skinbase_vertex>
  2545. #include <skinnormal_vertex>
  2546. #include <defaultnormal_vertex>
  2547. #ifndef FLAT_SHADED
  2548. vNormal = normalize( transformedNormal );
  2549. #ifdef USE_TANGENT
  2550. vTangent = normalize( transformedTangent );
  2551. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  2552. #endif
  2553. #endif
  2554. #include <begin_vertex>
  2555. #include <morphtarget_vertex>
  2556. #include <skinning_vertex>
  2557. #include <displacementmap_vertex>
  2558. #include <project_vertex>
  2559. #include <logdepthbuf_vertex>
  2560. #include <clipping_planes_vertex>
  2561. vViewPosition = - mvPosition.xyz;
  2562. #include <worldpos_vertex>
  2563. #include <shadowmap_vertex>
  2564. #include <fog_vertex>
  2565. }`,Hp=`#define NORMAL
  2566. uniform float opacity;
  2567. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2568. varying vec3 vViewPosition;
  2569. #endif
  2570. #ifndef FLAT_SHADED
  2571. varying vec3 vNormal;
  2572. #ifdef USE_TANGENT
  2573. varying vec3 vTangent;
  2574. varying vec3 vBitangent;
  2575. #endif
  2576. #endif
  2577. #include <packing>
  2578. #include <uv_pars_fragment>
  2579. #include <bumpmap_pars_fragment>
  2580. #include <normalmap_pars_fragment>
  2581. #include <logdepthbuf_pars_fragment>
  2582. #include <clipping_planes_pars_fragment>
  2583. void main() {
  2584. #include <clipping_planes_fragment>
  2585. #include <logdepthbuf_fragment>
  2586. #include <normal_fragment_begin>
  2587. #include <normal_fragment_maps>
  2588. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  2589. }`,Bp=`#define NORMAL
  2590. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2591. varying vec3 vViewPosition;
  2592. #endif
  2593. #ifndef FLAT_SHADED
  2594. varying vec3 vNormal;
  2595. #ifdef USE_TANGENT
  2596. varying vec3 vTangent;
  2597. varying vec3 vBitangent;
  2598. #endif
  2599. #endif
  2600. #include <common>
  2601. #include <uv_pars_vertex>
  2602. #include <displacementmap_pars_vertex>
  2603. #include <morphtarget_pars_vertex>
  2604. #include <skinning_pars_vertex>
  2605. #include <logdepthbuf_pars_vertex>
  2606. #include <clipping_planes_pars_vertex>
  2607. void main() {
  2608. #include <uv_vertex>
  2609. #include <beginnormal_vertex>
  2610. #include <morphnormal_vertex>
  2611. #include <skinbase_vertex>
  2612. #include <skinnormal_vertex>
  2613. #include <defaultnormal_vertex>
  2614. #ifndef FLAT_SHADED
  2615. vNormal = normalize( transformedNormal );
  2616. #ifdef USE_TANGENT
  2617. vTangent = normalize( transformedTangent );
  2618. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  2619. #endif
  2620. #endif
  2621. #include <begin_vertex>
  2622. #include <morphtarget_vertex>
  2623. #include <skinning_vertex>
  2624. #include <displacementmap_vertex>
  2625. #include <project_vertex>
  2626. #include <logdepthbuf_vertex>
  2627. #include <clipping_planes_vertex>
  2628. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2629. vViewPosition = - mvPosition.xyz;
  2630. #endif
  2631. }`,Gp=`uniform vec3 diffuse;
  2632. uniform float opacity;
  2633. #include <common>
  2634. #include <color_pars_fragment>
  2635. #include <map_particle_pars_fragment>
  2636. #include <fog_pars_fragment>
  2637. #include <logdepthbuf_pars_fragment>
  2638. #include <clipping_planes_pars_fragment>
  2639. void main() {
  2640. #include <clipping_planes_fragment>
  2641. vec3 outgoingLight = vec3( 0.0 );
  2642. vec4 diffuseColor = vec4( diffuse, opacity );
  2643. #include <logdepthbuf_fragment>
  2644. #include <map_particle_fragment>
  2645. #include <color_fragment>
  2646. #include <alphatest_fragment>
  2647. outgoingLight = diffuseColor.rgb;
  2648. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2649. #include <tonemapping_fragment>
  2650. #include <encodings_fragment>
  2651. #include <fog_fragment>
  2652. #include <premultiplied_alpha_fragment>
  2653. }`,Vp=`uniform float size;
  2654. uniform float scale;
  2655. #include <common>
  2656. #include <color_pars_vertex>
  2657. #include <fog_pars_vertex>
  2658. #include <morphtarget_pars_vertex>
  2659. #include <logdepthbuf_pars_vertex>
  2660. #include <clipping_planes_pars_vertex>
  2661. void main() {
  2662. #include <color_vertex>
  2663. #include <begin_vertex>
  2664. #include <morphtarget_vertex>
  2665. #include <project_vertex>
  2666. gl_PointSize = size;
  2667. #ifdef USE_SIZEATTENUATION
  2668. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  2669. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  2670. #endif
  2671. #include <logdepthbuf_vertex>
  2672. #include <clipping_planes_vertex>
  2673. #include <worldpos_vertex>
  2674. #include <fog_vertex>
  2675. }`,Wp=`uniform vec3 color;
  2676. uniform float opacity;
  2677. #include <common>
  2678. #include <packing>
  2679. #include <fog_pars_fragment>
  2680. #include <bsdfs>
  2681. #include <lights_pars_begin>
  2682. #include <shadowmap_pars_fragment>
  2683. #include <shadowmask_pars_fragment>
  2684. void main() {
  2685. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  2686. #include <tonemapping_fragment>
  2687. #include <encodings_fragment>
  2688. #include <fog_fragment>
  2689. }`,jp=`#include <common>
  2690. #include <fog_pars_vertex>
  2691. #include <shadowmap_pars_vertex>
  2692. void main() {
  2693. #include <begin_vertex>
  2694. #include <project_vertex>
  2695. #include <worldpos_vertex>
  2696. #include <beginnormal_vertex>
  2697. #include <morphnormal_vertex>
  2698. #include <skinbase_vertex>
  2699. #include <skinnormal_vertex>
  2700. #include <defaultnormal_vertex>
  2701. #include <shadowmap_vertex>
  2702. #include <fog_vertex>
  2703. }`,Xp=`uniform vec3 diffuse;
  2704. uniform float opacity;
  2705. #include <common>
  2706. #include <uv_pars_fragment>
  2707. #include <map_pars_fragment>
  2708. #include <alphamap_pars_fragment>
  2709. #include <fog_pars_fragment>
  2710. #include <logdepthbuf_pars_fragment>
  2711. #include <clipping_planes_pars_fragment>
  2712. void main() {
  2713. #include <clipping_planes_fragment>
  2714. vec3 outgoingLight = vec3( 0.0 );
  2715. vec4 diffuseColor = vec4( diffuse, opacity );
  2716. #include <logdepthbuf_fragment>
  2717. #include <map_fragment>
  2718. #include <alphamap_fragment>
  2719. #include <alphatest_fragment>
  2720. outgoingLight = diffuseColor.rgb;
  2721. gl_FragColor = vec4( outgoingLight, diffuseColor.a );
  2722. #include <tonemapping_fragment>
  2723. #include <encodings_fragment>
  2724. #include <fog_fragment>
  2725. }`,Yp=`uniform float rotation;
  2726. uniform vec2 center;
  2727. #include <common>
  2728. #include <uv_pars_vertex>
  2729. #include <fog_pars_vertex>
  2730. #include <logdepthbuf_pars_vertex>
  2731. #include <clipping_planes_pars_vertex>
  2732. void main() {
  2733. #include <uv_vertex>
  2734. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  2735. vec2 scale;
  2736. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  2737. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  2738. #ifndef USE_SIZEATTENUATION
  2739. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  2740. if ( isPerspective ) scale *= - mvPosition.z;
  2741. #endif
  2742. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  2743. vec2 rotatedPosition;
  2744. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  2745. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  2746. mvPosition.xy += rotatedPosition;
  2747. gl_Position = projectionMatrix * mvPosition;
  2748. #include <logdepthbuf_vertex>
  2749. #include <clipping_planes_vertex>
  2750. #include <fog_vertex>
  2751. }`;const Ie={alphamap_fragment:Eu,alphamap_pars_fragment:Lu,alphatest_fragment:Pu,aomap_fragment:Ru,aomap_pars_fragment:Cu,begin_vertex:Nu,beginnormal_vertex:Iu,bsdfs:Fu,bumpmap_pars_fragment:Ou,clipping_planes_fragment:Du,clipping_planes_pars_fragment:Uu,clipping_planes_pars_vertex:zu,clipping_planes_vertex:ku,color_fragment:Hu,color_pars_fragment:Bu,color_pars_vertex:Gu,color_vertex:Vu,common:Wu,cube_uv_reflection_fragment:ju,defaultnormal_vertex:Xu,displacementmap_pars_vertex:Yu,displacementmap_vertex:qu,emissivemap_fragment:Qu,emissivemap_pars_fragment:Zu,encodings_fragment:Ju,encodings_pars_fragment:Ku,envmap_fragment:$u,envmap_common_pars_fragment:ed,envmap_pars_fragment:td,envmap_pars_vertex:id,envmap_physical_pars_fragment:pd,envmap_vertex:nd,fog_vertex:rd,fog_pars_vertex:od,fog_fragment:sd,fog_pars_fragment:ad,gradientmap_pars_fragment:ld,lightmap_fragment:cd,lightmap_pars_fragment:hd,lights_lambert_vertex:ud,lights_pars_begin:dd,lights_toon_fragment:fd,lights_toon_pars_fragment:md,lights_phong_fragment:gd,lights_phong_pars_fragment:vd,lights_physical_fragment:_d,lights_physical_pars_fragment:xd,lights_fragment_begin:yd,lights_fragment_maps:bd,lights_fragment_end:wd,logdepthbuf_fragment:Md,logdepthbuf_pars_fragment:Td,logdepthbuf_pars_vertex:Ad,logdepthbuf_vertex:Sd,map_fragment:Ed,map_pars_fragment:Ld,map_particle_fragment:Pd,map_particle_pars_fragment:Rd,metalnessmap_fragment:Cd,metalnessmap_pars_fragment:Nd,morphnormal_vertex:Id,morphtarget_pars_vertex:Fd,morphtarget_vertex:Od,normal_fragment_begin:Dd,normal_fragment_maps:Ud,normalmap_pars_fragment:zd,clearcoat_normal_fragment_begin:kd,clearcoat_normal_fragment_maps:Hd,clearcoat_pars_fragment:Bd,packing:Gd,premultiplied_alpha_fragment:Vd,project_vertex:Wd,dithering_fragment:jd,dithering_pars_fragment:Xd,roughnessmap_fragment:Yd,roughnessmap_pars_fragment:qd,shadowmap_pars_fragment:Qd,shadowmap_pars_vertex:Zd,shadowmap_vertex:Jd,shadowmask_pars_fragment:Kd,skinbase_vertex:$d,skinning_pars_vertex:ep,skinning_vertex:tp,skinnormal_vertex:ip,specularmap_fragment:np,specularmap_pars_fragment:rp,tonemapping_fragment:op,tonemapping_pars_fragment:sp,transmissionmap_fragment:ap,transmissionmap_pars_fragment:lp,uv_pars_fragment:cp,uv_pars_vertex:hp,uv_vertex:up,uv2_pars_fragment:dp,uv2_pars_vertex:pp,uv2_vertex:fp,worldpos_vertex:mp,background_frag:gp,background_vert:vp,cube_frag:_p,cube_vert:xp,depth_frag:yp,depth_vert:bp,distanceRGBA_frag:wp,distanceRGBA_vert:Mp,equirect_frag:Tp,equirect_vert:Ap,linedashed_frag:Sp,linedashed_vert:Ep,meshbasic_frag:Lp,meshbasic_vert:Pp,meshlambert_frag:Rp,meshlambert_vert:Cp,meshmatcap_frag:Np,meshmatcap_vert:Ip,meshtoon_frag:Fp,meshtoon_vert:Op,meshphong_frag:Dp,meshphong_vert:Up,meshphysical_frag:zp,meshphysical_vert:kp,normal_frag:Hp,normal_vert:Bp,points_frag:Gp,points_vert:Vp,shadow_frag:Wp,shadow_vert:jp,sprite_frag:Xp,sprite_vert:Yp},me={common:{diffuse:{value:new he(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Ft},uv2Transform:{value:new Ft},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new le(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new he(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:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{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 he(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ft}},sprite:{diffuse:{value:new he(15658734)},opacity:{value:1},center:{value:new le(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ft}}},$t={basic:{uniforms:pt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:Ie.meshbasic_vert,fragmentShader:Ie.meshbasic_frag},lambert:{uniforms:pt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.fog,me.lights,{emissive:{value:new he(0)}}]),vertexShader:Ie.meshlambert_vert,fragmentShader:Ie.meshlambert_frag},phong:{uniforms:pt([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new he(0)},specular:{value:new he(1118481)},shininess:{value:30}}]),vertexShader:Ie.meshphong_vert,fragmentShader:Ie.meshphong_frag},standard:{uniforms:pt([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new he(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ie.meshphysical_vert,fragmentShader:Ie.meshphysical_frag},toon:{uniforms:pt([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new he(0)}}]),vertexShader:Ie.meshtoon_vert,fragmentShader:Ie.meshtoon_frag},matcap:{uniforms:pt([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:Ie.meshmatcap_vert,fragmentShader:Ie.meshmatcap_frag},points:{uniforms:pt([me.points,me.fog]),vertexShader:Ie.points_vert,fragmentShader:Ie.points_frag},dashed:{uniforms:pt([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ie.linedashed_vert,fragmentShader:Ie.linedashed_frag},depth:{uniforms:pt([me.common,me.displacementmap]),vertexShader:Ie.depth_vert,fragmentShader:Ie.depth_frag},normal:{uniforms:pt([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:Ie.normal_vert,fragmentShader:Ie.normal_frag},sprite:{uniforms:pt([me.sprite,me.fog]),vertexShader:Ie.sprite_vert,fragmentShader:Ie.sprite_frag},background:{uniforms:{uvTransform:{value:new Ft},t2D:{value:null}},vertexShader:Ie.background_vert,fragmentShader:Ie.background_frag},cube:{uniforms:pt([me.envmap,{opacity:{value:1}}]),vertexShader:Ie.cube_vert,fragmentShader:Ie.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ie.equirect_vert,fragmentShader:Ie.equirect_frag},distanceRGBA:{uniforms:pt([me.common,me.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ie.distanceRGBA_vert,fragmentShader:Ie.distanceRGBA_frag},shadow:{uniforms:pt([me.lights,me.fog,{color:{value:new he(0)},opacity:{value:1}}]),vertexShader:Ie.shadow_vert,fragmentShader:Ie.shadow_frag}};$t.physical={uniforms:pt([$t.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new le(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new he(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:Ie.meshphysical_vert,fragmentShader:Ie.meshphysical_frag};function qp(e,t,i,n,r){const o=new he(0);let s=0,a,l,c=null,h=0,u=null;function d(m,v,_,g){let p=v.isScene===!0?v.background:null;p&&p.isTexture&&(p=t.get(p));const E=e.xr,S=E.getSession&&E.getSession();S&&S.environmentBlendMode==="additive"&&(p=null),p===null?f(o,s):p&&p.isColor&&(f(p,1),g=!0),(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),p&&(p.isCubeTexture||p.isWebGLCubeRenderTarget||p.mapping===Vo)?(l===void 0&&(l=new Oe(new gi(1,1,1),new Qe({name:"BackgroundCubeMaterial",uniforms:wn($t.cube.uniforms),vertexShader:$t.cube.vertexShader,fragmentShader:$t.cube.fragmentShader,side:Ze,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(T,x,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),p.isWebGLCubeRenderTarget&&(p=p.texture),l.material.uniforms.envMap.value=p,l.material.uniforms.flipEnvMap.value=p.isCubeTexture&&p._needsFlipEnvMap?-1:1,(c!==p||h!==p.version||u!==e.toneMapping)&&(l.material.needsUpdate=!0,c=p,h=p.version,u=e.toneMapping),m.unshift(l,l.geometry,l.material,0,0,null)):p&&p.isTexture&&(a===void 0&&(a=new Oe(new Kt(2,2),new Qe({name:"BackgroundMaterial",uniforms:wn($t.background.uniforms),vertexShader:$t.background.vertexShader,fragmentShader:$t.background.fragmentShader,side:Gt,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(a)),a.material.uniforms.t2D.value=p,p.matrixAutoUpdate===!0&&p.updateMatrix(),a.material.uniforms.uvTransform.value.copy(p.matrix),(c!==p||h!==p.version||u!==e.toneMapping)&&(a.material.needsUpdate=!0,c=p,h=p.version,u=e.toneMapping),m.unshift(a,a.geometry,a.material,0,0,null))}function f(m,v){i.buffers.color.setClear(m.r,m.g,m.b,v,r)}return{getClearColor:function(){return o},setClearColor:function(m,v=1){o.set(m),s=v,f(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(m){s=m,f(o,s)},render:d}}function Qp(e,t,i,n){const r=e.getParameter(34921),o=n.isWebGL2?null:t.get("OES_vertex_array_object"),s=n.isWebGL2||o!==null,a={},l=v(null);let c=l;function h(G,D,k,Y,Z){let $=!1;if(s){const ne=m(Y,k,D);c!==ne&&(c=ne,d(c.object)),$=_(Y,Z),$&&g(Y,Z)}else{const ne=D.wireframe===!0;(c.geometry!==Y.id||c.program!==k.id||c.wireframe!==ne)&&(c.geometry=Y.id,c.program=k.id,c.wireframe=ne,$=!0)}G.isInstancedMesh===!0&&($=!0),Z!==null&&i.update(Z,34963),$&&(L(G,D,k,Y),Z!==null&&e.bindBuffer(34963,i.get(Z).buffer))}function u(){return n.isWebGL2?e.createVertexArray():o.createVertexArrayOES()}function d(G){return n.isWebGL2?e.bindVertexArray(G):o.bindVertexArrayOES(G)}function f(G){return n.isWebGL2?e.deleteVertexArray(G):o.deleteVertexArrayOES(G)}function m(G,D,k){const Y=k.wireframe===!0;let Z=a[G.id];Z===void 0&&(Z={},a[G.id]=Z);let $=Z[D.id];$===void 0&&($={},Z[D.id]=$);let ne=$[Y];return ne===void 0&&(ne=v(u()),$[Y]=ne),ne}function v(G){const D=[],k=[],Y=[];for(let Z=0;Z<r;Z++)D[Z]=0,k[Z]=0,Y[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:k,attributeDivisors:Y,object:G,attributes:{},index:null}}function _(G,D){const k=c.attributes,Y=G.attributes;let Z=0;for(const $ in Y){const ne=k[$],ae=Y[$];if(ne===void 0||ne.attribute!==ae||ne.data!==ae.data)return!0;Z++}return c.attributesNum!==Z||c.index!==D}function g(G,D){const k={},Y=G.attributes;let Z=0;for(const $ in Y){const ne=Y[$],ae={};ae.attribute=ne,ne.data&&(ae.data=ne.data),k[$]=ae,Z++}c.attributes=k,c.attributesNum=Z,c.index=D}function p(){const G=c.newAttributes;for(let D=0,k=G.length;D<k;D++)G[D]=0}function E(G){S(G,0)}function S(G,D){const k=c.newAttributes,Y=c.enabledAttributes,Z=c.attributeDivisors;k[G]=1,Y[G]===0&&(e.enableVertexAttribArray(G),Y[G]=1),Z[G]!==D&&((n.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](G,D),Z[G]=D)}function T(){const G=c.newAttributes,D=c.enabledAttributes;for(let k=0,Y=D.length;k<Y;k++)D[k]!==G[k]&&(e.disableVertexAttribArray(k),D[k]=0)}function x(G,D,k,Y,Z,$){n.isWebGL2===!0&&(k===5124||k===5125)?e.vertexAttribIPointer(G,D,k,Z,$):e.vertexAttribPointer(G,D,k,Y,Z,$)}function L(G,D,k,Y){if(n.isWebGL2===!1&&(G.isInstancedMesh||Y.isInstancedBufferGeometry)&&t.get("ANGLE_instanced_arrays")===null)return;p();const Z=Y.attributes,$=k.getAttributes(),ne=D.defaultAttributeValues;for(const ae in $){const de=$[ae];if(de>=0){const ce=Z[ae];if(ce!==void 0){const ye=ce.normalized,Ne=ce.itemSize,ie=i.get(ce);if(ie===void 0)continue;const M=ie.buffer,w=ie.type,O=ie.bytesPerElement;if(ce.isInterleavedBufferAttribute){const P=ce.data,F=P.stride,R=ce.offset;P&&P.isInstancedInterleavedBuffer?(S(de,P.meshPerAttribute),Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=P.meshPerAttribute*P.count)):E(de),e.bindBuffer(34962,M),x(de,Ne,w,ye,F*O,R*O)}else ce.isInstancedBufferAttribute?(S(de,ce.meshPerAttribute),Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=ce.meshPerAttribute*ce.count)):E(de),e.bindBuffer(34962,M),x(de,Ne,w,ye,0,0)}else if(ae==="instanceMatrix"){const ye=i.get(G.instanceMatrix);if(ye===void 0)continue;const Ne=ye.buffer,ie=ye.type;S(de+0,1),S(de+1,1),S(de+2,1),S(de+3,1),e.bindBuffer(34962,Ne),e.vertexAttribPointer(de+0,4,ie,!1,64,0),e.vertexAttribPointer(de+1,4,ie,!1,64,16),e.vertexAttribPointer(de+2,4,ie,!1,64,32),e.vertexAttribPointer(de+3,4,ie,!1,64,48)}else if(ae==="instanceColor"){const ye=i.get(G.instanceColor);if(ye===void 0)continue;const Ne=ye.buffer,ie=ye.type;S(de,1),e.bindBuffer(34962,Ne),e.vertexAttribPointer(de,3,ie,!1,12,0)}else if(ne!==void 0){const ye=ne[ae];if(ye!==void 0)switch(ye.length){case 2:e.vertexAttrib2fv(de,ye);break;case 3:e.vertexAttrib3fv(de,ye);break;case 4:e.vertexAttrib4fv(de,ye);break;default:e.vertexAttrib1fv(de,ye)}}}}T()}function W(){H();for(const G in a){const D=a[G];for(const k in D){const Y=D[k];for(const Z in Y)f(Y[Z].object),delete Y[Z];delete D[k]}delete a[G]}}function U(G){if(a[G.id]===void 0)return;const D=a[G.id];for(const k in D){const Y=D[k];for(const Z in Y)f(Y[Z].object),delete Y[Z];delete D[k]}delete a[G.id]}function B(G){for(const D in a){const k=a[D];if(k[G.id]===void 0)continue;const Y=k[G.id];for(const Z in Y)f(Y[Z].object),delete Y[Z];delete k[G.id]}}function H(){j(),c!==l&&(c=l,d(c.object))}function j(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:H,resetDefaultState:j,dispose:W,releaseStatesOfGeometry:U,releaseStatesOfProgram:B,initAttributes:p,enableAttribute:E,disableUnusedAttributes:T}}function Zp(e,t,i,n){const r=n.isWebGL2;let o;function s(c){o=c}function a(c,h){e.drawArrays(o,c,h),i.update(h,o,1)}function l(c,h,u){if(u===0)return;let d,f;if(r)d=e,f="drawArraysInstanced";else if(d=t.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](o,c,h,u),i.update(h,o,u)}this.setMode=s,this.render=a,this.renderInstances=l}function Jp(e,t,i){let n;function r(){if(n!==void 0)return n;const x=t.get("EXT_texture_filter_anisotropic");return x!==null?n=e.getParameter(x.MAX_TEXTURE_MAX_ANISOTROPY_EXT):n=0,n}function o(x){if(x==="highp"){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";x="mediump"}return x==="mediump"&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&e instanceof WebGL2ComputeRenderingContext;let a=i.precision!==void 0?i.precision:"highp";const l=o(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=i.logarithmicDepthBuffer===!0,h=e.getParameter(34930),u=e.getParameter(35660),d=e.getParameter(3379),f=e.getParameter(34076),m=e.getParameter(34921),v=e.getParameter(36347),_=e.getParameter(36348),g=e.getParameter(36349),p=u>0,E=s||!!t.get("OES_texture_float"),S=p&&E,T=s?e.getParameter(36183):0;return{isWebGL2:s,getMaxAnisotropy:r,getMaxPrecision:o,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:f,maxAttributes:m,maxVertexUniforms:v,maxVaryings:_,maxFragmentUniforms:g,vertexTextures:p,floatFragmentTextures:E,floatVertexTextures:S,maxSamples:T}}function Kp(e){const t=this;let i=null,n=0,r=!1,o=!1;const s=new pi,a=new Ft,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d,f){const m=u.length!==0||d||n!==0||r;return r=d,i=h(u,f,0),n=u.length,m},this.beginShadows=function(){o=!0,h(null)},this.endShadows=function(){o=!1,c()},this.setState=function(u,d,f){const m=u.clippingPlanes,v=u.clipIntersection,_=u.clipShadows,g=e.get(u);if(!r||m===null||m.length===0||o&&!_)o?h(null):c();else{const p=o?0:n,E=p*4;let S=g.clippingState||null;l.value=S,S=h(m,d,E,f);for(let T=0;T!==E;++T)S[T]=i[T];g.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=p}};function c(){l.value!==i&&(l.value=i,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,m){const v=u!==null?u.length:0;let _=null;if(v!==0){if(_=l.value,m!==!0||_===null){const g=f+v*4,p=d.matrixWorldInverse;a.getNormalMatrix(p),(_===null||_.length<g)&&(_=new Float32Array(g));for(let E=0,S=f;E!==v;++E,S+=4)s.copy(u[E]).applyMatrix4(p,a),s.normal.toArray(_,S),_[S+3]=s.constant}l.value=_,l.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,_}}function $p(e){let t=new WeakMap;function i(s,a){return a===ba?s.mapping=Bo:a===wa&&(s.mapping=Go),s}function n(s){if(s&&s.isTexture){const a=s.mapping;if(a===ba||a===wa)if(t.has(s)){const l=t.get(s).texture;return i(l,s.mapping)}else{const l=s.image;if(l&&l.height>0){const c=e.getRenderList(),h=e.getRenderTarget(),u=new Au(l.height/2);return u.fromEquirectangularTexture(e,s),t.set(s,u),e.setRenderTarget(h),e.setRenderList(c),s.addEventListener("dispose",r),i(u.texture,s.mapping)}else return null}}return s}function r(s){const a=s.target;a.removeEventListener("dispose",r);const l=t.get(a);l!==void 0&&(t.delete(a),l.dispose())}function o(){t=new WeakMap}return{get:n,dispose:o}}function ef(e){const t={};function i(n){if(t[n]!==void 0)return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(n){return i(n)!==null},init:function(n){n.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(n){const r=i(n);return r===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function tf(e,t,i,n){const r={},o=new WeakMap;function s(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const m in d.attributes)t.remove(d.attributes[m]);d.removeEventListener("dispose",s),delete r[d.id];const f=o.get(d);f&&(t.remove(f),o.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,i.memory.geometries--}function a(u,d){return r[d.id]===!0||(d.addEventListener("dispose",s),r[d.id]=!0,i.memory.geometries++),d}function l(u){const d=u.attributes;for(const m in d)t.update(d[m],34962);const f=u.morphAttributes;for(const m in f){const v=f[m];for(let _=0,g=v.length;_<g;_++)t.update(v[_],34962)}}function c(u){const d=[],f=u.index,m=u.attributes.position;let v=0;if(f!==null){const p=f.array;v=f.version;for(let E=0,S=p.length;E<S;E+=3){const T=p[E+0],x=p[E+1],L=p[E+2];d.push(T,x,x,L,L,T)}}else{const p=m.array;v=m.version;for(let E=0,S=p.length/3-1;E<S;E+=3){const T=E+0,x=E+1,L=E+2;d.push(T,x,x,L,L,T)}}const _=new(Qa(d)>65535?dr:ur)(d,1);_.version=v;const g=o.get(u);g&&t.remove(g),o.set(u,_)}function h(u){const d=o.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return o.get(u)}return{get:a,update:l,getWireframeAttribute:h}}function nf(e,t,i,n){const r=n.isWebGL2;let o;function s(d){o=d}let a,l;function c(d){a=d.type,l=d.bytesPerElement}function h(d,f){e.drawElements(o,f,a,d*l),i.update(f,o,1)}function u(d,f,m){if(m===0)return;let v,_;if(r)v=e,_="drawElementsInstanced";else if(v=t.get("ANGLE_instanced_arrays"),_="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[_](o,f,a,d*l,m),i.update(f,o,m)}this.setMode=s,this.setIndex=c,this.render=h,this.renderInstances=u}function rf(e){const t={geometries:0,textures:0},i={frame:0,calls:0,triangles:0,points:0,lines:0};function n(o,s,a){switch(i.calls++,s){case 4:i.triangles+=a*(o/3);break;case 1:i.lines+=a*(o/2);break;case 3:i.lines+=a*(o-1);break;case 2:i.lines+=a*o;break;case 0:i.points+=a*o;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function r(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0}return{memory:t,render:i,programs:null,autoReset:!0,reset:r,update:n}}function of(e,t){return e[0]-t[0]}function sf(e,t){return Math.abs(t[1])-Math.abs(e[1])}function af(e){const t={},i=new Float32Array(8),n=[];for(let o=0;o<8;o++)n[o]=[o,0];function r(o,s,a,l){const c=o.morphTargetInfluences,h=c===void 0?0:c.length;let u=t[s.id];if(u===void 0){u=[];for(let _=0;_<h;_++)u[_]=[_,0];t[s.id]=u}for(let _=0;_<h;_++){const g=u[_];g[0]=_,g[1]=c[_]}u.sort(sf);for(let _=0;_<8;_++)_<h&&u[_][1]?(n[_][0]=u[_][0],n[_][1]=u[_][1]):(n[_][0]=Number.MAX_SAFE_INTEGER,n[_][1]=0);n.sort(of);const d=a.morphTargets&&s.morphAttributes.position,f=a.morphNormals&&s.morphAttributes.normal;let m=0;for(let _=0;_<8;_++){const g=n[_],p=g[0],E=g[1];p!==Number.MAX_SAFE_INTEGER&&E?(d&&s.getAttribute("morphTarget"+_)!==d[p]&&s.setAttribute("morphTarget"+_,d[p]),f&&s.getAttribute("morphNormal"+_)!==f[p]&&s.setAttribute("morphNormal"+_,f[p]),i[_]=E,m+=E):(d&&s.hasAttribute("morphTarget"+_)===!0&&s.deleteAttribute("morphTarget"+_),f&&s.hasAttribute("morphNormal"+_)===!0&&s.deleteAttribute("morphNormal"+_),i[_]=0)}const v=s.morphTargetsRelative?1:1-m;l.getUniforms().setValue(e,"morphTargetBaseInfluence",v),l.getUniforms().setValue(e,"morphTargetInfluences",i)}return{update:r}}function lf(e,t,i,n){let r=new WeakMap;function o(l){const c=n.render.frame,h=l.geometry,u=t.get(l,h);return r.get(u)!==c&&(t.update(u),r.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),i.update(l.instanceMatrix,34962),l.instanceColor!==null&&i.update(l.instanceColor,34962)),u}function s(){r=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),i.remove(c.instanceMatrix),c.instanceColor!==null&&i.remove(c.instanceColor)}return{update:o,dispose:s}}function Ln(e=null,t=1,i=1,n=1){He.call(this,null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=rt,this.minFilter=rt,this.wrapR=ut,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Ln.prototype=Object.create(He.prototype),Ln.prototype.constructor=Ln,Ln.prototype.isDataTexture2DArray=!0;function fr(e=null,t=1,i=1,n=1){He.call(this,null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=rt,this.minFilter=rt,this.wrapR=ut,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}fr.prototype=Object.create(He.prototype),fr.prototype.constructor=fr,fr.prototype.isDataTexture3D=!0;const $a=new He,cf=new Ln,hf=new fr,el=new Ii,tl=[],il=[],nl=new Float32Array(16),rl=new Float32Array(9),ol=new Float32Array(4);function Pn(e,t,i){const n=e[0];if(n<=0||n>0)return e;const r=t*i;let o=tl[r];if(o===void 0&&(o=new Float32Array(r),tl[r]=o),t!==0){n.toArray(o,0);for(let s=1,a=0;s!==t;++s)a+=i,e[s].toArray(o,a)}return o}function Ot(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0}function Lt(e,t){for(let i=0,n=t.length;i<n;i++)e[i]=t[i]}function sl(e,t){let i=il[t];i===void 0&&(i=new Int32Array(t),il[t]=i);for(let n=0;n!==t;++n)i[n]=e.allocateTextureUnit();return i}function uf(e,t){const i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function df(e,t){const i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Ot(i,t))return;e.uniform2fv(this.addr,t),Lt(i,t)}}function pf(e,t){const i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(t.r!==void 0)(i[0]!==t.r||i[1]!==t.g||i[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(Ot(i,t))return;e.uniform3fv(this.addr,t),Lt(i,t)}}function ff(e,t){const i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Ot(i,t))return;e.uniform4fv(this.addr,t),Lt(i,t)}}function mf(e,t){const i=this.cache,n=t.elements;if(n===void 0){if(Ot(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),Lt(i,t)}else{if(Ot(i,n))return;ol.set(n),e.uniformMatrix2fv(this.addr,!1,ol),Lt(i,n)}}function gf(e,t){const i=this.cache,n=t.elements;if(n===void 0){if(Ot(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),Lt(i,t)}else{if(Ot(i,n))return;rl.set(n),e.uniformMatrix3fv(this.addr,!1,rl),Lt(i,n)}}function vf(e,t){const i=this.cache,n=t.elements;if(n===void 0){if(Ot(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),Lt(i,t)}else{if(Ot(i,n))return;nl.set(n),e.uniformMatrix4fv(this.addr,!1,nl),Lt(i,n)}}function _f(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.safeSetTexture2D(t||$a,r)}function xf(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(t||cf,r)}function yf(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(t||hf,r)}function bf(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.safeSetTextureCube(t||el,r)}function wf(e,t){const i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function Mf(e,t){const i=this.cache;Ot(i,t)||(e.uniform2iv(this.addr,t),Lt(i,t))}function Tf(e,t){const i=this.cache;Ot(i,t)||(e.uniform3iv(this.addr,t),Lt(i,t))}function Af(e,t){const i=this.cache;Ot(i,t)||(e.uniform4iv(this.addr,t),Lt(i,t))}function Sf(e,t){const i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function Ef(e){switch(e){case 5126:return uf;case 35664:return df;case 35665:return pf;case 35666:return ff;case 35674:return mf;case 35675:return gf;case 35676:return vf;case 5124:case 35670:return wf;case 35667:case 35671:return Mf;case 35668:case 35672:return Tf;case 35669:case 35673:return Af;case 5125:return Sf;case 35678:case 36198:case 36298:case 36306:case 35682:return _f;case 35679:case 36299:case 36307:return yf;case 35680:case 36300:case 36308:case 36293:return bf;case 36289:case 36303:case 36311:case 36292:return xf}}function Lf(e,t){e.uniform1fv(this.addr,t)}function Pf(e,t){e.uniform1iv(this.addr,t)}function Rf(e,t){e.uniform2iv(this.addr,t)}function Cf(e,t){e.uniform3iv(this.addr,t)}function Nf(e,t){e.uniform4iv(this.addr,t)}function If(e,t){const i=Pn(t,this.size,2);e.uniform2fv(this.addr,i)}function Ff(e,t){const i=Pn(t,this.size,3);e.uniform3fv(this.addr,i)}function Of(e,t){const i=Pn(t,this.size,4);e.uniform4fv(this.addr,i)}function Df(e,t){const i=Pn(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function Uf(e,t){const i=Pn(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function zf(e,t){const i=Pn(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function kf(e,t,i){const n=t.length,r=sl(i,n);e.uniform1iv(this.addr,r);for(let o=0;o!==n;++o)i.safeSetTexture2D(t[o]||$a,r[o])}function Hf(e,t,i){const n=t.length,r=sl(i,n);e.uniform1iv(this.addr,r);for(let o=0;o!==n;++o)i.safeSetTextureCube(t[o]||el,r[o])}function Bf(e){switch(e){case 5126:return Lf;case 35664:return If;case 35665:return Ff;case 35666:return Of;case 35674:return Df;case 35675:return Uf;case 35676:return zf;case 5124:case 35670:return Pf;case 35667:case 35671:return Rf;case 35668:case 35672:return Cf;case 35669:case 35673:return Nf;case 35678:case 36198:case 36298:case 36306:case 35682:return kf;case 35680:case 36300:case 36308:case 36293:return Hf}}function Gf(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=Ef(t.type)}function al(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=Bf(t.type)}al.prototype.updateCache=function(e){const t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Lt(t,e)};function ll(e){this.id=e,this.seq=[],this.map={}}ll.prototype.setValue=function(e,t,i){const n=this.seq;for(let r=0,o=n.length;r!==o;++r){const s=n[r];s.setValue(e,t[s.id],i)}};const Ts=/(\w+)(\])?(\[|\.)?/g;function cl(e,t){e.seq.push(t),e.map[t.id]=t}function Vf(e,t,i){const n=e.name,r=n.length;for(Ts.lastIndex=0;;){const o=Ts.exec(n),s=Ts.lastIndex;let a=o[1];const l=o[2]==="]",c=o[3];if(l&&(a=a|0),c===void 0||c==="["&&s+2===r){cl(i,c===void 0?new Gf(a,e,t):new al(a,e,t));break}else{let h=i.map[a];h===void 0&&(h=new ll(a),cl(i,h)),i=h}}}function Fi(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,35718);for(let n=0;n<i;++n){const r=e.getActiveUniform(t,n),o=e.getUniformLocation(t,r.name);Vf(r,o,this)}}Fi.prototype.setValue=function(e,t,i,n){const r=this.map[t];r!==void 0&&r.setValue(e,i,n)},Fi.prototype.setOptional=function(e,t,i){const n=t[i];n!==void 0&&this.setValue(e,i,n)},Fi.upload=function(e,t,i,n){for(let r=0,o=t.length;r!==o;++r){const s=t[r],a=i[s.id];a.needsUpdate!==!1&&s.setValue(e,a.value,n)}},Fi.seqWithValue=function(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const o=e[n];o.id in t&&i.push(o)}return i};function hl(e,t,i){const n=e.createShader(t);return e.shaderSource(n,i),e.compileShader(n),n}let Wf=0;function jf(e){const t=e.split(`
  2752. `);for(let i=0;i<t.length;i++)t[i]=i+1+": "+t[i];return t.join(`
  2753. `)}function ul(e){switch(e){case sr:return["Linear","( value )"];case Vi:return["sRGB","( value )"];case $h:return["RGBE","( value )"];case tu:return["RGBM","( value, 7.0 )"];case iu:return["RGBM","( value, 16.0 )"];case nu:return["RGBD","( value, 256.0 )"];case Kh:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case eu:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function dl(e,t,i){const n=e.getShaderParameter(t,35713),r=e.getShaderInfoLog(t).trim();if(n&&r==="")return"";const o=e.getShaderSource(t);return"THREE.WebGLShader: gl.getShaderInfoLog() "+i+`
  2754. `+r+jf(o)}function mr(e,t){const i=ul(t);return"vec4 "+e+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function Xf(e,t){const i=ul(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function Yf(e,t){let i;switch(t){case Kc:i="Linear";break;case $c:i="Reinhard";break;case eh:i="OptimizedCineon";break;case th:i="ACESFilmic";break;case ih:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function qf(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||e.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(gr).join(`
  2755. `)}function Qf(e){const t=[];for(const i in e){const n=e[i];n!==!1&&t.push("#define "+i+" "+n)}return t.join(`
  2756. `)}function Zf(e,t){const i={},n=e.getProgramParameter(t,35721);for(let r=0;r<n;r++){const o=e.getActiveAttrib(t,r).name;i[o]=e.getAttribLocation(t,o)}return i}function gr(e){return e!==""}function pl(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).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/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function fl(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Jf=/^[ \t]*#include +<([\w\d./]+)>/gm;function As(e){return e.replace(Jf,Kf)}function Kf(e,t){const i=Ie[t];if(i===void 0)throw new Error("Can not resolve #include <"+t+">");return As(i)}const $f=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,em=/#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 ml(e){return e.replace(em,gl).replace($f,tm)}function tm(e,t,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),gl(e,t,i,n)}function gl(e,t,i,n){let r="";for(let o=parseInt(t);o<parseInt(i);o++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+o+" ]").replace(/UNROLLED_LOOP_INDEX/g,o);return r}function vl(e){let t="precision "+e.precision+` float;
  2757. precision `+e.precision+" int;";return e.precision==="highp"?t+=`
  2758. #define HIGH_PRECISION`:e.precision==="mediump"?t+=`
  2759. #define MEDIUM_PRECISION`:e.precision==="lowp"&&(t+=`
  2760. #define LOW_PRECISION`),t}function im(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===ua?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===da?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===$n&&(t="SHADOWMAP_TYPE_VSM"),t}function nm(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case Bo:case Go:t="ENVMAP_TYPE_CUBE";break;case Vo:case Wo:t="ENVMAP_TYPE_CUBE_UV";break}return t}function rm(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case Go:case Wo:t="ENVMAP_MODE_REFRACTION";break}return t}function om(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case Or:t="ENVMAP_BLENDING_MULTIPLY";break;case Zc:t="ENVMAP_BLENDING_MIX";break;case Jc:t="ENVMAP_BLENDING_ADD";break}return t}function sm(e,t,i,n){const r=e.getContext(),o=i.defines;let s=i.vertexShader,a=i.fragmentShader;const l=im(i),c=nm(i),h=rm(i),u=om(i),d=e.gammaFactor>0?e.gammaFactor:1,f=i.isWebGL2?"":qf(i),m=Qf(o),v=r.createProgram();let _,g,p=i.glslVersion?"#version "+i.glslVersion+`
  2761. `:"";i.isRawShaderMaterial?(_=[m].filter(gr).join(`
  2762. `),_.length>0&&(_+=`
  2763. `),g=[f,m].filter(gr).join(`
  2764. `),g.length>0&&(g+=`
  2765. `)):(_=[vl(i),"#define SHADER_NAME "+i.shaderName,m,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&i.flatShading===!1?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#ifdef USE_COLOR"," attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  2766. `].filter(gr).join(`
  2767. `),g=[f,vl(i),"#define SHADER_NAME "+i.shaderName,m,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.envMap?"#define "+h:"",i.envMap?"#define "+u:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==tr?"#define TONE_MAPPING":"",i.toneMapping!==tr?Ie.tonemapping_pars_fragment:"",i.toneMapping!==tr?Yf("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",Ie.encodings_pars_fragment,i.map?mr("mapTexelToLinear",i.mapEncoding):"",i.matcap?mr("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?mr("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?mr("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMap?mr("lightMapTexelToLinear",i.lightMapEncoding):"",Xf("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",`
  2768. `].filter(gr).join(`
  2769. `)),s=As(s),s=pl(s,i),s=fl(s,i),a=As(a),a=pl(a,i),a=fl(a,i),s=ml(s),a=ml(a),i.isWebGL2&&i.isRawShaderMaterial!==!0&&(p=`#version 300 es
  2770. `,_=["#define attribute in","#define varying out","#define texture2D texture"].join(`
  2771. `)+`
  2772. `+_,g=["#define varying in",i.glslVersion===Ua?"":"out highp vec4 pc_fragColor;",i.glslVersion===Ua?"":"#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(`
  2773. `)+`
  2774. `+g);const E=p+_+s,S=p+g+a,T=hl(r,35633,E),x=hl(r,35632,S);if(r.attachShader(v,T),r.attachShader(v,x),i.index0AttributeName!==void 0?r.bindAttribLocation(v,0,i.index0AttributeName):i.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v),e.debug.checkShaderErrors){const U=r.getProgramInfoLog(v).trim(),B=r.getShaderInfoLog(T).trim(),H=r.getShaderInfoLog(x).trim();let j=!0,G=!0;if(r.getProgramParameter(v,35714)===!1){j=!1;const D=dl(r,T,"vertex"),k=dl(r,x,"fragment");console.error("THREE.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(v,35715),"gl.getProgramInfoLog",U,D,k)}else U!==""?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",U):(B===""||H==="")&&(G=!1);G&&(this.diagnostics={runnable:j,programLog:U,vertexShader:{log:B,prefix:_},fragmentShader:{log:H,prefix:g}})}r.deleteShader(T),r.deleteShader(x);let L;this.getUniforms=function(){return L===void 0&&(L=new Fi(r,v)),L};let W;return this.getAttributes=function(){return W===void 0&&(W=Zf(r,v)),W},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.name=i.shaderName,this.id=Wf++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=x,this}function am(e,t,i,n,r,o){const s=[],a=n.isWebGL2,l=n.logarithmicDepthBuffer,c=n.floatVertexTextures,h=n.maxVertexUniforms,u=n.vertexTextures;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},m=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function v(x){const L=x.skeleton.bones;if(c)return 1024;{const W=Math.floor((h-20)/4),U=Math.min(W,L.length);return U<L.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+L.length+" bones. This GPU supports "+U+"."),0):U}}function _(x){let L;return x&&x.isTexture?L=x.encoding:x&&x.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),L=x.texture.encoding):L=sr,L}function g(x,L,W,U,B){const H=U.fog,j=x.isMeshStandardMaterial?U.environment:null,G=t.get(x.envMap||j),D=f[x.type],k=B.isSkinnedMesh?v(B):0;x.precision!==null&&(d=n.getMaxPrecision(x.precision),d!==x.precision&&console.warn("THREE.WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));let Y,Z;if(D){const ne=$t[D];Y=ne.vertexShader,Z=ne.fragmentShader}else Y=x.vertexShader,Z=x.fragmentShader;const $=e.getRenderTarget();return{isWebGL2:a,shaderID:D,shaderName:x.type,vertexShader:Y,fragmentShader:Z,defines:x.defines,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,instancing:B.isInstancedMesh===!0,instancingColor:B.isInstancedMesh===!0&&B.instanceColor!==null,supportsVertexTextures:u,outputEncoding:$!==null?_($.texture):e.outputEncoding,map:!!x.map,mapEncoding:_(x.map),matcap:!!x.matcap,matcapEncoding:_(x.matcap),envMap:!!G,envMapMode:G&&G.mapping,envMapEncoding:_(G),envMapCubeUV:!!G&&(G.mapping===Vo||G.mapping===Wo),lightMap:!!x.lightMap,lightMapEncoding:_(x.lightMap),aoMap:!!x.aoMap,emissiveMap:!!x.emissiveMap,emissiveMapEncoding:_(x.emissiveMap),bumpMap:!!x.bumpMap,normalMap:!!x.normalMap,objectSpaceNormalMap:x.normalMapType===su,tangentSpaceNormalMap:x.normalMapType===Wi,clearcoatMap:!!x.clearcoatMap,clearcoatRoughnessMap:!!x.clearcoatRoughnessMap,clearcoatNormalMap:!!x.clearcoatNormalMap,displacementMap:!!x.displacementMap,roughnessMap:!!x.roughnessMap,metalnessMap:!!x.metalnessMap,specularMap:!!x.specularMap,alphaMap:!!x.alphaMap,gradientMap:!!x.gradientMap,sheen:!!x.sheen,transmissionMap:!!x.transmissionMap,combine:x.combine,vertexTangents:x.normalMap&&x.vertexTangents,vertexColors:x.vertexColors,vertexUvs:!!x.map||!!x.bumpMap||!!x.normalMap||!!x.specularMap||!!x.alphaMap||!!x.emissiveMap||!!x.roughnessMap||!!x.metalnessMap||!!x.clearcoatMap||!!x.clearcoatRoughnessMap||!!x.clearcoatNormalMap||!!x.displacementMap||!!x.transmissionMap,uvsVertexOnly:!(x.map||x.bumpMap||x.normalMap||x.specularMap||x.alphaMap||x.emissiveMap||x.roughnessMap||x.metalnessMap||x.clearcoatNormalMap||x.transmissionMap)&&!!x.displacementMap,fog:!!H,useFog:x.fog,fogExp2:H&&H.isFogExp2,flatShading:x.flatShading,sizeAttenuation:x.sizeAttenuation,logarithmicDepthBuffer:l,skinning:x.skinning&&k>0,maxBones:k,useVertexTexture:c,morphTargets:x.morphTargets,morphNormals:x.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:L.directional.length,numPointLights:L.point.length,numSpotLights:L.spot.length,numRectAreaLights:L.rectArea.length,numHemiLights:L.hemi.length,numDirLightShadows:L.directionalShadowMap.length,numPointLightShadows:L.pointShadowMap.length,numSpotLightShadows:L.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&W.length>0,shadowMapType:e.shadowMap.type,toneMapping:x.toneMapped?e.toneMapping:tr,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:x.premultipliedAlpha,alphaTest:x.alphaTest,doubleSided:x.side===on,flipSided:x.side===Ze,depthPacking:x.depthPacking!==void 0?x.depthPacking:!1,index0AttributeName:x.index0AttributeName,extensionDerivatives:x.extensions&&x.extensions.derivatives,extensionFragDepth:x.extensions&&x.extensions.fragDepth,extensionDrawBuffers:x.extensions&&x.extensions.drawBuffers,extensionShaderTextureLOD:x.extensions&&x.extensions.shaderTextureLOD,rendererExtensionFragDepth:a||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:a||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:a||i.has("EXT_shader_texture_lod"),customProgramCacheKey:x.customProgramCacheKey()}}function p(x){const L=[];if(x.shaderID?L.push(x.shaderID):(L.push(x.fragmentShader),L.push(x.vertexShader)),x.defines!==void 0)for(const W in x.defines)L.push(W),L.push(x.defines[W]);if(x.isRawShaderMaterial===!1){for(let W=0;W<m.length;W++)L.push(x[m[W]]);L.push(e.outputEncoding),L.push(e.gammaFactor)}return L.push(x.customProgramCacheKey),L.join()}function E(x){const L=f[x.type];let W;if(L){const U=$t[L];W=Ja.clone(U.uniforms)}else W=x.uniforms;return W}function S(x,L){let W;for(let U=0,B=s.length;U<B;U++){const H=s[U];if(H.cacheKey===L){W=H,++W.usedTimes;break}}return W===void 0&&(W=new sm(e,L,x,r),s.push(W)),W}function T(x){if(--x.usedTimes===0){const L=s.indexOf(x);s[L]=s[s.length-1],s.pop(),x.destroy()}}return{getParameters:g,getProgramCacheKey:p,getUniforms:E,acquireProgram:S,releaseProgram:T,programs:s}}function lm(){let e=new WeakMap;function t(o){let s=e.get(o);return s===void 0&&(s={},e.set(o,s)),s}function i(o){e.delete(o)}function n(o,s,a){e.get(o)[s]=a}function r(){e=new WeakMap}return{get:t,remove:i,update:n,dispose:r}}function cm(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function hm(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function _l(e){const t=[];let i=0;const n=[],r=[],o={id:-1};function s(){i=0,n.length=0,r.length=0}function a(d,f,m,v,_,g){let p=t[i];const E=e.get(m);return p===void 0?(p={id:d.id,object:d,geometry:f,material:m,program:E.program||o,groupOrder:v,renderOrder:d.renderOrder,z:_,group:g},t[i]=p):(p.id=d.id,p.object=d,p.geometry=f,p.material=m,p.program=E.program||o,p.groupOrder=v,p.renderOrder=d.renderOrder,p.z=_,p.group=g),i++,p}function l(d,f,m,v,_,g){const p=a(d,f,m,v,_,g);(m.transparent===!0?r:n).push(p)}function c(d,f,m,v,_,g){const p=a(d,f,m,v,_,g);(m.transparent===!0?r:n).unshift(p)}function h(d,f){n.length>1&&n.sort(d||cm),r.length>1&&r.sort(f||hm)}function u(){for(let d=i,f=t.length;d<f;d++){const m=t[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.program=null,m.group=null}}return{opaque:n,transparent:r,init:s,push:l,unshift:c,finish:u,sort:h}}function um(e){let t=new WeakMap;function i(r,o){const s=t.get(r);let a;return s===void 0?(a=new _l(e),t.set(r,new WeakMap),t.get(r).set(o,a)):(a=s.get(o),a===void 0&&(a=new _l(e),s.set(o,a))),a}function n(){t=new WeakMap}return{get:i,dispose:n}}function dm(){const e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new A,color:new he};break;case"SpotLight":i={position:new A,direction:new A,color:new he,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new A,color:new he,distance:0,decay:0};break;case"HemisphereLight":i={direction:new A,skyColor:new he,groundColor:new he};break;case"RectAreaLight":i={color:new he,position:new A,halfWidth:new A,halfHeight:new A};break}return e[t.id]=i,i}}}function pm(){const e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let i;switch(t.type){case"DirectionalLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new le};break;case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new le};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new le,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=i,i}}}let fm=0;function mm(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function gm(e,t){const i=new dm,n=pm(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let h=0;h<9;h++)r.probe.push(new A);const o=new A,s=new Re,a=new Re;function l(h){let u=0,d=0,f=0;for(let L=0;L<9;L++)r.probe[L].set(0,0,0);let m=0,v=0,_=0,g=0,p=0,E=0,S=0,T=0;h.sort(mm);for(let L=0,W=h.length;L<W;L++){const U=h[L],B=U.color,H=U.intensity,j=U.distance,G=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)u+=B.r*H,d+=B.g*H,f+=B.b*H;else if(U.isLightProbe)for(let D=0;D<9;D++)r.probe[D].addScaledVector(U.sh.coefficients[D],H);else if(U.isDirectionalLight){const D=i.get(U);if(D.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const k=U.shadow,Y=n.get(U);Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,r.directionalShadow[m]=Y,r.directionalShadowMap[m]=G,r.directionalShadowMatrix[m]=U.shadow.matrix,E++}r.directional[m]=D,m++}else if(U.isSpotLight){const D=i.get(U);if(D.position.setFromMatrixPosition(U.matrixWorld),D.color.copy(B).multiplyScalar(H),D.distance=j,D.coneCos=Math.cos(U.angle),D.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),D.decay=U.decay,U.castShadow){const k=U.shadow,Y=n.get(U);Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,r.spotShadow[_]=Y,r.spotShadowMap[_]=G,r.spotShadowMatrix[_]=U.shadow.matrix,T++}r.spot[_]=D,_++}else if(U.isRectAreaLight){const D=i.get(U);D.color.copy(B).multiplyScalar(H),D.halfWidth.set(U.width*.5,0,0),D.halfHeight.set(0,U.height*.5,0),r.rectArea[g]=D,g++}else if(U.isPointLight){const D=i.get(U);if(D.color.copy(U.color).multiplyScalar(U.intensity),D.distance=U.distance,D.decay=U.decay,U.castShadow){const k=U.shadow,Y=n.get(U);Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,Y.shadowCameraNear=k.camera.near,Y.shadowCameraFar=k.camera.far,r.pointShadow[v]=Y,r.pointShadowMap[v]=G,r.pointShadowMatrix[v]=U.shadow.matrix,S++}r.point[v]=D,v++}else if(U.isHemisphereLight){const D=i.get(U);D.skyColor.copy(U.color).multiplyScalar(H),D.groundColor.copy(U.groundColor).multiplyScalar(H),r.hemi[p]=D,p++}}g>0&&(t.isWebGL2||e.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=me.LTC_FLOAT_1,r.rectAreaLTC2=me.LTC_FLOAT_2):e.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=me.LTC_HALF_1,r.rectAreaLTC2=me.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=u,r.ambient[1]=d,r.ambient[2]=f;const x=r.hash;(x.directionalLength!==m||x.pointLength!==v||x.spotLength!==_||x.rectAreaLength!==g||x.hemiLength!==p||x.numDirectionalShadows!==E||x.numPointShadows!==S||x.numSpotShadows!==T)&&(r.directional.length=m,r.spot.length=_,r.rectArea.length=g,r.point.length=v,r.hemi.length=p,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=S,r.spotShadowMatrix.length=T,x.directionalLength=m,x.pointLength=v,x.spotLength=_,x.rectAreaLength=g,x.hemiLength=p,x.numDirectionalShadows=E,x.numPointShadows=S,x.numSpotShadows=T,r.version=fm++)}function c(h,u){let d=0,f=0,m=0,v=0,_=0;const g=u.matrixWorldInverse;for(let p=0,E=h.length;p<E;p++){const S=h[p];if(S.isDirectionalLight){const T=r.directional[d];T.direction.setFromMatrixPosition(S.matrixWorld),o.setFromMatrixPosition(S.target.matrixWorld),T.direction.sub(o),T.direction.transformDirection(g),d++}else if(S.isSpotLight){const T=r.spot[m];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(g),T.direction.setFromMatrixPosition(S.matrixWorld),o.setFromMatrixPosition(S.target.matrixWorld),T.direction.sub(o),T.direction.transformDirection(g),m++}else if(S.isRectAreaLight){const T=r.rectArea[v];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(g),a.identity(),s.copy(S.matrixWorld),s.premultiply(g),a.extractRotation(s),T.halfWidth.set(S.width*.5,0,0),T.halfHeight.set(0,S.height*.5,0),T.halfWidth.applyMatrix4(a),T.halfHeight.applyMatrix4(a),v++}else if(S.isPointLight){const T=r.point[f];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(g),f++}else if(S.isHemisphereLight){const T=r.hemi[_];T.direction.setFromMatrixPosition(S.matrixWorld),T.direction.transformDirection(g),T.direction.normalize(),_++}}}return{setup:l,setupView:c,state:r}}function xl(e,t){const i=new gm(e,t),n=[],r=[];function o(){n.length=0,r.length=0}function s(h){n.push(h)}function a(h){r.push(h)}function l(){i.setup(n)}function c(h){i.setupView(n,h)}return{init:o,state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:l,setupLightsView:c,pushLight:s,pushShadow:a}}function vm(e,t){let i=new WeakMap;function n(o,s=0){let a;return i.has(o)===!1?(a=new xl(e,t),i.set(o,[]),i.get(o).push(a)):s>=i.get(o).length?(a=new xl(e,t),i.get(o).push(a)):a=i.get(o)[s],a}function r(){i=new WeakMap}return{get:n,dispose:r}}function Qi(e){Me.call(this),this.type="MeshDepthMaterial",this.depthPacking=ru,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}Qi.prototype=Object.create(Me.prototype),Qi.prototype.constructor=Qi,Qi.prototype.isMeshDepthMaterial=!0,Qi.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this};function Zi(e){Me.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new A,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}Zi.prototype=Object.create(Me.prototype),Zi.prototype.constructor=Zi,Zi.prototype.isMeshDistanceMaterial=!0,Zi.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this};var _m=`uniform sampler2D shadow_pass;
  2775. uniform vec2 resolution;
  2776. uniform float radius;
  2777. #include <packing>
  2778. void main() {
  2779. float mean = 0.0;
  2780. float squared_mean = 0.0;
  2781. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
  2782. for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {
  2783. #ifdef HORIZONTAL_PASS
  2784. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
  2785. mean += distribution.x;
  2786. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  2787. #else
  2788. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );
  2789. mean += depth;
  2790. squared_mean += depth * depth;
  2791. #endif
  2792. }
  2793. mean = mean * HALF_SAMPLE_RATE;
  2794. squared_mean = squared_mean * HALF_SAMPLE_RATE;
  2795. float std_dev = sqrt( squared_mean - mean * mean );
  2796. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  2797. }`,xm=`void main() {
  2798. gl_Position = vec4( position, 1.0 );
  2799. }`;function yl(e,t,i){let n=new lo;const r=new le,o=new le,s=new ke,a=[],l=[],c={},h={0:Ze,1:Gt,2:on},u=new Qe({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new le},radius:{value:4}},vertexShader:xm,fragmentShader:_m}),d=u.clone();d.defines.HORIZONTAL_PASS=1;const f=new De;f.setAttribute("position",new Le(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Oe(f,u),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ua,this.render=function(T,x,L){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||T.length===0)return;const W=e.getRenderTarget(),U=e.getActiveCubeFace(),B=e.getActiveMipmapLevel(),H=e.state;H.setBlending(er),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);for(let j=0,G=T.length;j<G;j++){const D=T[j],k=D.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",D,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);const Y=k.getFrameExtents();if(r.multiply(Y),o.copy(k.mapSize),(r.x>i||r.y>i)&&(r.x>i&&(o.x=Math.floor(i/Y.x),r.x=o.x*Y.x,k.mapSize.x=o.x),r.y>i&&(o.y=Math.floor(i/Y.y),r.y=o.y*Y.y,k.mapSize.y=o.y)),k.map===null&&!k.isPointLightShadow&&this.type===$n){const $={minFilter:qe,magFilter:qe,format:wt};k.map=new ji(r.x,r.y,$),k.map.texture.name=D.name+".shadowMap",k.mapPass=new ji(r.x,r.y,$),k.camera.updateProjectionMatrix()}if(k.map===null){const $={minFilter:rt,magFilter:rt,format:wt};k.map=new ji(r.x,r.y,$),k.map.texture.name=D.name+".shadowMap",k.camera.updateProjectionMatrix()}e.setRenderTarget(k.map),e.clear();const Z=k.getViewportCount();for(let $=0;$<Z;$++){const ne=k.getViewport($);s.set(o.x*ne.x,o.y*ne.y,o.x*ne.z,o.y*ne.w),H.viewport(s),k.updateMatrices(D,$),n=k.getFrustum(),S(x,L,k.camera,D,this.type)}!k.isPointLightShadow&&this.type===$n&&_(k,L),k.needsUpdate=!1}v.needsUpdate=!1,e.setRenderTarget(W,U,B)};function _(T,x){const L=t.update(m);u.uniforms.shadow_pass.value=T.map.texture,u.uniforms.resolution.value=T.mapSize,u.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(x,null,L,u,m,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(x,null,L,d,m,null)}function g(T,x,L){const W=T<<0|x<<1|L<<2;let U=a[W];return U===void 0&&(U=new Qi({depthPacking:ou,morphTargets:T,skinning:x}),a[W]=U),U}function p(T,x,L){const W=T<<0|x<<1|L<<2;let U=l[W];return U===void 0&&(U=new Zi({morphTargets:T,skinning:x}),l[W]=U),U}function E(T,x,L,W,U,B,H){let j=null,G=g,D=T.customDepthMaterial;if(W.isPointLight===!0&&(G=p,D=T.customDistanceMaterial),D===void 0){let k=!1;L.morphTargets===!0&&(k=x.morphAttributes&&x.morphAttributes.position&&x.morphAttributes.position.length>0);let Y=!1;T.isSkinnedMesh===!0&&(L.skinning===!0?Y=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",T));const Z=T.isInstancedMesh===!0;j=G(k,Y,Z)}else j=D;if(e.localClippingEnabled&&L.clipShadows===!0&&L.clippingPlanes.length!==0){const k=j.uuid,Y=L.uuid;let Z=c[k];Z===void 0&&(Z={},c[k]=Z);let $=Z[Y];$===void 0&&($=j.clone(),Z[Y]=$),j=$}return j.visible=L.visible,j.wireframe=L.wireframe,H===$n?j.side=L.shadowSide!==null?L.shadowSide:L.side:j.side=L.shadowSide!==null?L.shadowSide:h[L.side],j.clipShadows=L.clipShadows,j.clippingPlanes=L.clippingPlanes,j.clipIntersection=L.clipIntersection,j.wireframeLinewidth=L.wireframeLinewidth,j.linewidth=L.linewidth,W.isPointLight===!0&&j.isMeshDistanceMaterial===!0&&(j.referencePosition.setFromMatrixPosition(W.matrixWorld),j.nearDistance=U,j.farDistance=B),j}function S(T,x,L,W,U){if(T.visible===!1)return;if(T.layers.test(x.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&U===$n)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(L.matrixWorldInverse,T.matrixWorld);const H=t.update(T),j=T.material;if(Array.isArray(j)){const G=H.groups;for(let D=0,k=G.length;D<k;D++){const Y=G[D],Z=j[Y.materialIndex];if(Z&&Z.visible){const $=E(T,H,Z,W,L.near,L.far,U);e.renderBufferDirect(L,null,H,$,T,Y)}}}else if(j.visible){const G=E(T,H,j,W,L.near,L.far,U);e.renderBufferDirect(L,null,H,G,T,null)}}const B=T.children;for(let H=0,j=B.length;H<j;H++)S(B[H],x,L,W,U)}}function ym(e,t,i){const n=i.isWebGL2;function r(){let z=!1;const te=new ke;let re=null;const ue=new ke(0,0,0,0);return{setMask:function(se){re!==se&&!z&&(e.colorMask(se,se,se,se),re=se)},setLocked:function(se){z=se},setClear:function(se,ge,ve,be,pe){pe===!0&&(se*=be,ge*=be,ve*=be),te.set(se,ge,ve,be),ue.equals(te)===!1&&(e.clearColor(se,ge,ve,be),ue.copy(te))},reset:function(){z=!1,re=null,ue.set(-1,0,0,0)}}}function o(){let z=!1,te=null,re=null,ue=null;return{setTest:function(se){se?ae(2929):de(2929)},setMask:function(se){te!==se&&!z&&(e.depthMask(se),te=se)},setFunc:function(se){if(re!==se){if(se)switch(se){case Vc:e.depthFunc(512);break;case Wc:e.depthFunc(519);break;case jc:e.depthFunc(513);break;case Ho:e.depthFunc(515);break;case Xc:e.depthFunc(514);break;case Yc:e.depthFunc(518);break;case qc:e.depthFunc(516);break;case Qc:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);re=se}},setLocked:function(se){z=se},setClear:function(se){ue!==se&&(e.clearDepth(se),ue=se)},reset:function(){z=!1,te=null,re=null,ue=null}}}function s(){let z=!1,te=null,re=null,ue=null,se=null,ge=null,ve=null,be=null,pe=null;return{setTest:function(_e){z||(_e?ae(2960):de(2960))},setMask:function(_e){te!==_e&&!z&&(e.stencilMask(_e),te=_e)},setFunc:function(_e,Te,Ke){(re!==_e||ue!==Te||se!==Ke)&&(e.stencilFunc(_e,Te,Ke),re=_e,ue=Te,se=Ke)},setOp:function(_e,Te,Ke){(ge!==_e||ve!==Te||be!==Ke)&&(e.stencilOp(_e,Te,Ke),ge=_e,ve=Te,be=Ke)},setLocked:function(_e){z=_e},setClear:function(_e){pe!==_e&&(e.clearStencil(_e),pe=_e)},reset:function(){z=!1,te=null,re=null,ue=null,se=null,ge=null,ve=null,be=null,pe=null}}}const a=new r,l=new o,c=new s;let h={},u=null,d=null,f=null,m=null,v=null,_=null,g=null,p=null,E=null,S=!1,T=null,x=null,L=null,W=null,U=null;const B=e.getParameter(35661);let H=!1,j=0;const G=e.getParameter(7938);G.indexOf("WebGL")!==-1?(j=parseFloat(/^WebGL (\d)/.exec(G)[1]),H=j>=1):G.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=j>=2);let D=null,k={};const Y=new ke,Z=new ke;function $(z,te,re){const ue=new Uint8Array(4),se=e.createTexture();e.bindTexture(z,se),e.texParameteri(z,10241,9728),e.texParameteri(z,10240,9728);for(let ge=0;ge<re;ge++)e.texImage2D(te+ge,0,6408,1,1,0,6408,5121,ue);return se}const ne={};ne[3553]=$(3553,3553,1),ne[34067]=$(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),ae(2929),l.setFunc(Ho),w(!1),O(ha),ae(2884),ie(er);function ae(z){h[z]!==!0&&(e.enable(z),h[z]=!0)}function de(z){h[z]!==!1&&(e.disable(z),h[z]=!1)}function ce(z){return u!==z?(e.useProgram(z),u=z,!0):!1}const ye={[sn]:32774,[Nc]:32778,[Ic]:32779};if(n)ye[ga]=32775,ye[va]=32776;else{const z=t.get("EXT_blend_minmax");z!==null&&(ye[ga]=z.MIN_EXT,ye[va]=z.MAX_EXT)}const Ne={[Fc]:0,[Oc]:1,[Dc]:768,[_a]:770,[Gc]:776,[Hc]:774,[zc]:772,[Uc]:769,[xa]:771,[Bc]:775,[kc]:773};function ie(z,te,re,ue,se,ge,ve,be){if(z===er){d&&(de(3042),d=!1);return}if(d||(ae(3042),d=!0),z!==Cc){if(z!==f||be!==S){if((m!==sn||g!==sn)&&(e.blendEquation(32774),m=sn,g=sn),be)switch(z){case Bi:e.blendFuncSeparate(1,771,1,771);break;case ko:e.blendFunc(1,1);break;case fa:e.blendFuncSeparate(0,0,769,771);break;case ma:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case Bi:e.blendFuncSeparate(770,771,1,771);break;case ko:e.blendFunc(770,1);break;case fa:e.blendFunc(0,769);break;case ma:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}v=null,_=null,p=null,E=null,f=z,S=be}return}se=se||te,ge=ge||re,ve=ve||ue,(te!==m||se!==g)&&(e.blendEquationSeparate(ye[te],ye[se]),m=te,g=se),(re!==v||ue!==_||ge!==p||ve!==E)&&(e.blendFuncSeparate(Ne[re],Ne[ue],Ne[ge],Ne[ve]),v=re,_=ue,p=ge,E=ve),f=z,S=null}function M(z,te){z.side===on?de(2884):ae(2884);let re=z.side===Ze;te&&(re=!re),w(re),z.blending===Bi&&z.transparent===!1?ie(er):ie(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.premultipliedAlpha),l.setFunc(z.depthFunc),l.setTest(z.depthTest),l.setMask(z.depthWrite),a.setMask(z.colorWrite);const ue=z.stencilWrite;c.setTest(ue),ue&&(c.setMask(z.stencilWriteMask),c.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),c.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),F(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits)}function w(z){T!==z&&(z?e.frontFace(2304):e.frontFace(2305),T=z)}function O(z){z!==Pc?(ae(2884),z!==x&&(z===ha?e.cullFace(1029):z===Rc?e.cullFace(1028):e.cullFace(1032))):de(2884),x=z}function P(z){z!==L&&(H&&e.lineWidth(z),L=z)}function F(z,te,re){z?(ae(32823),(W!==te||U!==re)&&(e.polygonOffset(te,re),W=te,U=re)):de(32823)}function R(z){z?ae(3089):de(3089)}function N(z){z===void 0&&(z=33984+B-1),D!==z&&(e.activeTexture(z),D=z)}function I(z,te){D===null&&N();let re=k[D];re===void 0&&(re={type:void 0,texture:void 0},k[D]=re),(re.type!==z||re.texture!==te)&&(e.bindTexture(z,te||ne[z]),re.type=z,re.texture=te)}function V(){const z=k[D];z!==void 0&&z.type!==void 0&&(e.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function X(){try{e.compressedTexImage2D.apply(e,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Q(){try{e.texImage2D.apply(e,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function b(){try{e.texImage3D.apply(e,arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function y(z){Y.equals(z)===!1&&(e.scissor(z.x,z.y,z.z,z.w),Y.copy(z))}function J(z){Z.equals(z)===!1&&(e.viewport(z.x,z.y,z.z,z.w),Z.copy(z))}function q(){h={},D=null,k={},u=null,d=null,f=null,m=null,v=null,_=null,g=null,p=null,E=null,S=!1,T=null,x=null,L=null,W=null,U=null,a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:ae,disable:de,useProgram:ce,setBlending:ie,setMaterial:M,setFlipSided:w,setCullFace:O,setLineWidth:P,setPolygonOffset:F,setScissorTest:R,activeTexture:N,bindTexture:I,unbindTexture:V,compressedTexImage2D:X,texImage2D:Q,texImage3D:b,scissor:y,viewport:J,reset:q}}function bm(e,t,i,n,r,o,s){const a=r.isWebGL2,l=r.maxTextures,c=r.maxCubemapSize,h=r.maxTextureSize,u=r.maxSamples,d=new WeakMap;let f,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(b,y){return m?new OffscreenCanvas(b,y):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function _(b,y,J,q){let z=1;if((b.width>q||b.height>q)&&(z=q/Math.max(b.width,b.height)),z<1||y===!0)if(typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&b instanceof ImageBitmap){const te=y?Se.floorPowerOfTwo:Math.floor,re=te(z*b.width),ue=te(z*b.height);f===void 0&&(f=v(re,ue));const se=J?v(re,ue):f;return se.width=re,se.height=ue,se.getContext("2d").drawImage(b,0,0,re,ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+b.width+"x"+b.height+") to ("+re+"x"+ue+")."),se}else return"data"in b&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+b.width+"x"+b.height+")."),b;return b}function g(b){return Se.isPowerOfTwo(b.width)&&Se.isPowerOfTwo(b.height)}function p(b){return a?!1:b.wrapS!==ut||b.wrapT!==ut||b.minFilter!==rt&&b.minFilter!==qe}function E(b,y){return b.generateMipmaps&&y&&b.minFilter!==rt&&b.minFilter!==qe}function S(b,y,J,q){e.generateMipmap(b);const z=n.get(y);z.__maxMipLevel=Math.log(Math.max(J,q))*Math.LOG2E}function T(b,y,J){if(a===!1)return y;if(b!==null){if(e[b]!==void 0)return e[b];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let q=y;return y===6403&&(J===5126&&(q=33326),J===5131&&(q=33325),J===5121&&(q=33321)),y===6407&&(J===5126&&(q=34837),J===5131&&(q=34843),J===5121&&(q=32849)),y===6408&&(J===5126&&(q=34836),J===5131&&(q=34842),J===5121&&(q=32856)),(q===33325||q===33326||q===34842||q===34836)&&t.get("EXT_color_buffer_float"),q}function x(b){return b===rt||b===jo||b===Xo?9728:9729}function L(b){const y=b.target;y.removeEventListener("dispose",L),U(y),y.isVideoTexture&&d.delete(y),s.memory.textures--}function W(b){const y=b.target;y.removeEventListener("dispose",W),B(y),s.memory.textures--}function U(b){const y=n.get(b);y.__webglInit!==void 0&&(e.deleteTexture(y.__webglTexture),n.remove(b))}function B(b){const y=n.get(b),J=n.get(b.texture);if(b){if(J.__webglTexture!==void 0&&e.deleteTexture(J.__webglTexture),b.depthTexture&&b.depthTexture.dispose(),b.isWebGLCubeRenderTarget)for(let q=0;q<6;q++)e.deleteFramebuffer(y.__webglFramebuffer[q]),y.__webglDepthbuffer&&e.deleteRenderbuffer(y.__webglDepthbuffer[q]);else e.deleteFramebuffer(y.__webglFramebuffer),y.__webglDepthbuffer&&e.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&e.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer&&e.deleteRenderbuffer(y.__webglColorRenderbuffer),y.__webglDepthRenderbuffer&&e.deleteRenderbuffer(y.__webglDepthRenderbuffer);n.remove(b.texture),n.remove(b)}}let H=0;function j(){H=0}function G(){const b=H;return b>=l&&console.warn("THREE.WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+l),H+=1,b}function D(b,y){const J=n.get(b);if(b.isVideoTexture&&N(b),b.version>0&&J.__version!==b.version){const q=b.image;if(q===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ce(J,b,y);return}}i.activeTexture(33984+y),i.bindTexture(3553,J.__webglTexture)}function k(b,y){const J=n.get(b);if(b.version>0&&J.__version!==b.version){ce(J,b,y);return}i.activeTexture(33984+y),i.bindTexture(35866,J.__webglTexture)}function Y(b,y){const J=n.get(b);if(b.version>0&&J.__version!==b.version){ce(J,b,y);return}i.activeTexture(33984+y),i.bindTexture(32879,J.__webglTexture)}function Z(b,y){const J=n.get(b);if(b.version>0&&J.__version!==b.version){ye(J,b,y);return}i.activeTexture(33984+y),i.bindTexture(34067,J.__webglTexture)}const $={[Mi]:10497,[ut]:33071,[Dr]:33648},ne={[rt]:9728,[jo]:9984,[Xo]:9986,[qe]:9729,[Ma]:9985,[an]:9987};function ae(b,y,J){J?(e.texParameteri(b,10242,$[y.wrapS]),e.texParameteri(b,10243,$[y.wrapT]),(b===32879||b===35866)&&e.texParameteri(b,32882,$[y.wrapR]),e.texParameteri(b,10240,ne[y.magFilter]),e.texParameteri(b,10241,ne[y.minFilter])):(e.texParameteri(b,10242,33071),e.texParameteri(b,10243,33071),(b===32879||b===35866)&&e.texParameteri(b,32882,33071),(y.wrapS!==ut||y.wrapT!==ut)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(b,10240,x(y.magFilter)),e.texParameteri(b,10241,x(y.minFilter)),y.minFilter!==rt&&y.minFilter!==qe&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));const q=t.get("EXT_texture_filter_anisotropic");if(q){if(y.type===li&&t.get("OES_texture_float_linear")===null||y.type===kr&&(a||t.get("OES_texture_half_float_linear"))===null)return;(y.anisotropy>1||n.get(y).__currentAnisotropy)&&(e.texParameterf(b,q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,r.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy)}}function de(b,y){b.__webglInit===void 0&&(b.__webglInit=!0,y.addEventListener("dispose",L),b.__webglTexture=e.createTexture(),s.memory.textures++)}function ce(b,y,J){let q=3553;y.isDataTexture2DArray&&(q=35866),y.isDataTexture3D&&(q=32879),de(b,y),i.activeTexture(33984+J),i.bindTexture(q,b.__webglTexture),e.pixelStorei(37440,y.flipY),e.pixelStorei(37441,y.premultiplyAlpha),e.pixelStorei(3317,y.unpackAlignment);const z=p(y)&&g(y.image)===!1,te=_(y.image,z,!1,h),re=g(te)||a,ue=o.convert(y.format);let se=o.convert(y.type),ge=T(y.internalFormat,ue,se);ae(q,y,re);let ve;const be=y.mipmaps;if(y.isDepthTexture)ge=6402,a?y.type===li?ge=36012:y.type===ir?ge=33190:y.type===nr?ge=35056:ge=33189:y.type===li&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),y.format===Gi&&ge===6402&&y.type!==zr&&y.type!==ir&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),y.type=zr,se=o.convert(y.type)),y.format===rr&&ge===6402&&(ge=34041,y.type!==nr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),y.type=nr,se=o.convert(y.type))),i.texImage2D(3553,0,ge,te.width,te.height,0,ue,se,null);else if(y.isDataTexture)if(be.length>0&&re){for(let pe=0,_e=be.length;pe<_e;pe++)ve=be[pe],i.texImage2D(3553,pe,ge,ve.width,ve.height,0,ue,se,ve.data);y.generateMipmaps=!1,b.__maxMipLevel=be.length-1}else i.texImage2D(3553,0,ge,te.width,te.height,0,ue,se,te.data),b.__maxMipLevel=0;else if(y.isCompressedTexture){for(let pe=0,_e=be.length;pe<_e;pe++)ve=be[pe],y.format!==wt&&y.format!==Ti?ue!==null?i.compressedTexImage2D(3553,pe,ge,ve.width,ve.height,0,ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,pe,ge,ve.width,ve.height,0,ue,se,ve.data);b.__maxMipLevel=be.length-1}else if(y.isDataTexture2DArray)i.texImage3D(35866,0,ge,te.width,te.height,te.depth,0,ue,se,te.data),b.__maxMipLevel=0;else if(y.isDataTexture3D)i.texImage3D(32879,0,ge,te.width,te.height,te.depth,0,ue,se,te.data),b.__maxMipLevel=0;else if(be.length>0&&re){for(let pe=0,_e=be.length;pe<_e;pe++)ve=be[pe],i.texImage2D(3553,pe,ge,ue,se,ve);y.generateMipmaps=!1,b.__maxMipLevel=be.length-1}else i.texImage2D(3553,0,ge,ue,se,te),b.__maxMipLevel=0;E(y,re)&&S(q,y,te.width,te.height),b.__version=y.version,y.onUpdate&&y.onUpdate(y)}function ye(b,y,J){if(y.image.length!==6)return;de(b,y),i.activeTexture(33984+J),i.bindTexture(34067,b.__webglTexture),e.pixelStorei(37440,y.flipY),e.pixelStorei(37441,y.premultiplyAlpha),e.pixelStorei(3317,y.unpackAlignment);const q=y&&(y.isCompressedTexture||y.image[0].isCompressedTexture),z=y.image[0]&&y.image[0].isDataTexture,te=[];for(let pe=0;pe<6;pe++)!q&&!z?te[pe]=_(y.image[pe],!1,!0,c):te[pe]=z?y.image[pe].image:y.image[pe];const re=te[0],ue=g(re)||a,se=o.convert(y.format),ge=o.convert(y.type),ve=T(y.internalFormat,se,ge);ae(34067,y,ue);let be;if(q){for(let pe=0;pe<6;pe++){be=te[pe].mipmaps;for(let _e=0;_e<be.length;_e++){const Te=be[_e];y.format!==wt&&y.format!==Ti?se!==null?i.compressedTexImage2D(34069+pe,_e,ve,Te.width,Te.height,0,Te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+pe,_e,ve,Te.width,Te.height,0,se,ge,Te.data)}}b.__maxMipLevel=be.length-1}else{be=y.mipmaps;for(let pe=0;pe<6;pe++)if(z){i.texImage2D(34069+pe,0,ve,te[pe].width,te[pe].height,0,se,ge,te[pe].data);for(let _e=0;_e<be.length;_e++){const Te=be[_e].image[pe].image;i.texImage2D(34069+pe,_e+1,ve,Te.width,Te.height,0,se,ge,Te.data)}}else{i.texImage2D(34069+pe,0,ve,se,ge,te[pe]);for(let _e=0;_e<be.length;_e++){const Te=be[_e];i.texImage2D(34069+pe,_e+1,ve,se,ge,Te.image[pe])}}b.__maxMipLevel=be.length}E(y,ue)&&S(34067,y,re.width,re.height),b.__version=y.version,y.onUpdate&&y.onUpdate(y)}function Ne(b,y,J,q){const z=o.convert(y.texture.format),te=o.convert(y.texture.type),re=T(y.texture.internalFormat,z,te);i.texImage2D(q,0,re,y.width,y.height,0,z,te,null),e.bindFramebuffer(36160,b),e.framebufferTexture2D(36160,J,q,n.get(y.texture).__webglTexture,0),e.bindFramebuffer(36160,null)}function ie(b,y,J){if(e.bindRenderbuffer(36161,b),y.depthBuffer&&!y.stencilBuffer){let q=33189;if(J){const z=y.depthTexture;z&&z.isDepthTexture&&(z.type===li?q=36012:z.type===ir&&(q=33190));const te=R(y);e.renderbufferStorageMultisample(36161,te,q,y.width,y.height)}else e.renderbufferStorage(36161,q,y.width,y.height);e.framebufferRenderbuffer(36160,36096,36161,b)}else if(y.depthBuffer&&y.stencilBuffer){if(J){const q=R(y);e.renderbufferStorageMultisample(36161,q,35056,y.width,y.height)}else e.renderbufferStorage(36161,34041,y.width,y.height);e.framebufferRenderbuffer(36160,33306,36161,b)}else{const q=o.convert(y.texture.format),z=o.convert(y.texture.type),te=T(y.texture.internalFormat,q,z);if(J){const re=R(y);e.renderbufferStorageMultisample(36161,re,te,y.width,y.height)}else e.renderbufferStorage(36161,te,y.width,y.height)}e.bindRenderbuffer(36161,null)}function M(b,y){if(y&&y.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,b),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(y.depthTexture).__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)&&(y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0),D(y.depthTexture,0);const J=n.get(y.depthTexture).__webglTexture;if(y.depthTexture.format===Gi)e.framebufferTexture2D(36160,36096,3553,J,0);else if(y.depthTexture.format===rr)e.framebufferTexture2D(36160,33306,3553,J,0);else throw new Error("Unknown depthTexture format")}function w(b){const y=n.get(b),J=b.isWebGLCubeRenderTarget===!0;if(b.depthTexture){if(J)throw new Error("target.depthTexture not supported in Cube render targets");M(y.__webglFramebuffer,b)}else if(J){y.__webglDepthbuffer=[];for(let q=0;q<6;q++)e.bindFramebuffer(36160,y.__webglFramebuffer[q]),y.__webglDepthbuffer[q]=e.createRenderbuffer(),ie(y.__webglDepthbuffer[q],b,!1)}else e.bindFramebuffer(36160,y.__webglFramebuffer),y.__webglDepthbuffer=e.createRenderbuffer(),ie(y.__webglDepthbuffer,b,!1);e.bindFramebuffer(36160,null)}function O(b){const y=n.get(b),J=n.get(b.texture);b.addEventListener("dispose",W),J.__webglTexture=e.createTexture(),s.memory.textures++;const q=b.isWebGLCubeRenderTarget===!0,z=b.isWebGLMultisampleRenderTarget===!0,te=g(b)||a;if(a&&b.texture.format===Ti&&(b.texture.type===li||b.texture.type===kr)&&(b.texture.format=wt,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),q){y.__webglFramebuffer=[];for(let re=0;re<6;re++)y.__webglFramebuffer[re]=e.createFramebuffer()}else if(y.__webglFramebuffer=e.createFramebuffer(),z)if(a){y.__webglMultisampledFramebuffer=e.createFramebuffer(),y.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,y.__webglColorRenderbuffer);const re=o.convert(b.texture.format),ue=o.convert(b.texture.type),se=T(b.texture.internalFormat,re,ue),ge=R(b);e.renderbufferStorageMultisample(36161,ge,se,b.width,b.height),e.bindFramebuffer(36160,y.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,y.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),b.depthBuffer&&(y.__webglDepthRenderbuffer=e.createRenderbuffer(),ie(y.__webglDepthRenderbuffer,b,!0)),e.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(q){i.bindTexture(34067,J.__webglTexture),ae(34067,b.texture,te);for(let re=0;re<6;re++)Ne(y.__webglFramebuffer[re],b,36064,34069+re);E(b.texture,te)&&S(34067,b.texture,b.width,b.height),i.bindTexture(34067,null)}else i.bindTexture(3553,J.__webglTexture),ae(3553,b.texture,te),Ne(y.__webglFramebuffer,b,36064,3553),E(b.texture,te)&&S(3553,b.texture,b.width,b.height),i.bindTexture(3553,null);b.depthBuffer&&w(b)}function P(b){const y=b.texture,J=g(b)||a;if(E(y,J)){const q=b.isWebGLCubeRenderTarget?34067:3553,z=n.get(y).__webglTexture;i.bindTexture(q,z),S(q,y,b.width,b.height),i.bindTexture(q,null)}}function F(b){if(b.isWebGLMultisampleRenderTarget)if(a){const y=n.get(b);e.bindFramebuffer(36008,y.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,y.__webglFramebuffer);const J=b.width,q=b.height;let z=16384;b.depthBuffer&&(z|=256),b.stencilBuffer&&(z|=1024),e.blitFramebuffer(0,0,J,q,0,0,J,q,z,9728),e.bindFramebuffer(36160,y.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function R(b){return a&&b.isWebGLMultisampleRenderTarget?Math.min(u,b.samples):0}function N(b){const y=s.render.frame;d.get(b)!==y&&(d.set(b,y),b.update())}let I=!1,V=!1;function X(b,y){b&&b.isWebGLRenderTarget&&(I===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),I=!0),b=b.texture),D(b,y)}function Q(b,y){b&&b.isWebGLCubeRenderTarget&&(V===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),V=!0),b=b.texture),Z(b,y)}this.allocateTextureUnit=G,this.resetTextureUnits=j,this.setTexture2D=D,this.setTexture2DArray=k,this.setTexture3D=Y,this.setTextureCube=Z,this.setupRenderTarget=O,this.updateRenderTargetMipmap=P,this.updateMultisampleRenderTarget=F,this.safeSetTexture2D=X,this.safeSetTextureCube=Q}function wm(e,t,i){const n=i.isWebGL2;function r(o){let s;if(o===Ur)return 5121;if(o===sh)return 32819;if(o===ah)return 32820;if(o===lh)return 33635;if(o===nh)return 5120;if(o===rh)return 5122;if(o===zr)return 5123;if(o===oh)return 5124;if(o===ir)return 5125;if(o===li)return 5126;if(o===kr)return n?5131:(s=t.get("OES_texture_half_float"),s!==null?s.HALF_FLOAT_OES:null);if(o===ch)return 6406;if(o===Ti)return 6407;if(o===wt)return 6408;if(o===hh)return 6409;if(o===uh)return 6410;if(o===Gi)return 6402;if(o===rr)return 34041;if(o===dh)return 6403;if(o===ph)return 36244;if(o===fh)return 33319;if(o===mh)return 33320;if(o===gh)return 36248;if(o===vh)return 36249;if(o===Aa||o===Sa||o===Ea||o===La)if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(o===Aa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(o===Sa)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(o===Ea)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(o===La)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(o===Pa||o===Ra||o===Ca||o===Na)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(o===Pa)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(o===Ra)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(o===Ca)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(o===Na)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(o===_h)return s=t.get("WEBGL_compressed_texture_etc1"),s!==null?s.COMPRESSED_RGB_ETC1_WEBGL:null;if((o===Ia||o===Fa)&&(s=t.get("WEBGL_compressed_texture_etc"),s!==null)){if(o===Ia)return s.COMPRESSED_RGB8_ETC2;if(o===Fa)return s.COMPRESSED_RGBA8_ETC2_EAC}if(o===xh||o===yh||o===bh||o===wh||o===Mh||o===Th||o===Ah||o===Sh||o===Eh||o===Lh||o===Ph||o===Rh||o===Ch||o===Nh||o===Fh||o===Oh||o===Dh||o===Uh||o===zh||o===kh||o===Hh||o===Bh||o===Gh||o===Vh||o===Wh||o===jh||o===Xh||o===Yh)return s=t.get("WEBGL_compressed_texture_astc"),s!==null?o:null;if(o===Ih)return s=t.get("EXT_texture_compression_bptc"),s!==null?o:null;if(o===nr)return n?34042:(s=t.get("WEBGL_depth_texture"),s!==null?s.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:r}}function Ss(e=[]){$e.call(this),this.cameras=e}Ss.prototype=Object.assign(Object.create($e.prototype),{constructor:Ss,isArrayCamera:!0});function ft(){we.call(this),this.type="Group"}ft.prototype=Object.assign(Object.create(we.prototype),{constructor:ft,isGroup:!0});function vr(){this._targetRay=null,this._grip=null,this._hand=null}Object.assign(vr.prototype,{constructor:vr,getHandSpace:function(){return this._hand===null&&(this._hand=new ft,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},getTargetRaySpace:function(){return this._targetRay===null&&(this._targetRay=new ft,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return this._grip===null&&(this._grip=new ft,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this},disconnect:function(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this},update:function(e,t,i){let n=null,r=null,o=null;const s=this._targetRay,a=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(l&&e.hand){o=!0;for(const m of e.hand.values()){const v=t.getJointPose(m,i);if(l.joints[m.jointName]===void 0){const g=new ft;g.matrixAutoUpdate=!1,g.visible=!1,l.joints[m.jointName]=g,l.add(g)}const _=l.joints[m.jointName];v!==null&&(_.matrix.fromArray(v.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.jointRadius=v.radius),_.visible=v!==null}const c=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],u=c.position.distanceTo(h.position),d=.02,f=.005;l.inputState.pinching&&u>d+f?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=d-f&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else s!==null&&(n=t.getPose(e.targetRaySpace,i),n!==null&&(s.matrix.fromArray(n.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale))),a!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale)));return s!==null&&(s.visible=n!==null),a!==null&&(a.visible=r!==null),l!==null&&(l.visible=o!==null),this}});function bl(e,t){const i=this;let n=null,r=1,o=null,s="local-floor",a=null;const l=[],c=new Map,h=new $e;h.layers.enable(1),h.viewport=new ke;const u=new $e;u.layers.enable(2),u.viewport=new ke;const d=[h,u],f=new Ss;f.layers.enable(1),f.layers.enable(2);let m=null,v=null;this.enabled=!1,this.isPresenting=!1,this.getController=function(B){let H=l[B];return H===void 0&&(H=new vr,l[B]=H),H.getTargetRaySpace()},this.getControllerGrip=function(B){let H=l[B];return H===void 0&&(H=new vr,l[B]=H),H.getGripSpace()},this.getHand=function(B){let H=l[B];return H===void 0&&(H=new vr,l[B]=H),H.getHandSpace()};function _(B){const H=c.get(B.inputSource);H&&H.dispatchEvent({type:B.type,data:B.inputSource})}function g(){c.forEach(function(B,H){B.disconnect(H)}),c.clear(),m=null,v=null,e.setFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),U.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(B){r=B,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(B){s=B,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getSession=function(){return n},this.setSession=async function(B){if(n=B,n!==null){n.addEventListener("select",_),n.addEventListener("selectstart",_),n.addEventListener("selectend",_),n.addEventListener("squeeze",_),n.addEventListener("squeezestart",_),n.addEventListener("squeezeend",_),n.addEventListener("end",g),n.addEventListener("inputsourceschange",p);const H=t.getContextAttributes();H.xrCompatible!==!0&&await t.makeXRCompatible();const j={antialias:H.antialias,alpha:H.alpha,depth:H.depth,stencil:H.stencil,framebufferScaleFactor:r},G=new XRWebGLLayer(n,t,j);n.updateRenderState({baseLayer:G}),o=await n.requestReferenceSpace(s),U.setContext(n),U.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function p(B){const H=n.inputSources;for(let j=0;j<l.length;j++)c.set(H[j],l[j]);for(let j=0;j<B.removed.length;j++){const G=B.removed[j],D=c.get(G);D&&(D.dispatchEvent({type:"disconnected",data:G}),c.delete(G))}for(let j=0;j<B.added.length;j++){const G=B.added[j],D=c.get(G);D&&D.dispatchEvent({type:"connected",data:G})}}const E=new A,S=new A;function T(B,H,j){E.setFromMatrixPosition(H.matrixWorld),S.setFromMatrixPosition(j.matrixWorld);const G=E.distanceTo(S),D=H.projectionMatrix.elements,k=j.projectionMatrix.elements,Y=D[14]/(D[10]-1),Z=D[14]/(D[10]+1),$=(D[9]+1)/D[5],ne=(D[9]-1)/D[5],ae=(D[8]-1)/D[0],de=(k[8]+1)/k[0],ce=Y*ae,ye=Y*de,Ne=G/(-ae+de),ie=Ne*-ae;H.matrixWorld.decompose(B.position,B.quaternion,B.scale),B.translateX(ie),B.translateZ(Ne),B.matrixWorld.compose(B.position,B.quaternion,B.scale),B.matrixWorldInverse.copy(B.matrixWorld).invert();const M=Y+Ne,w=Z+Ne,O=ce-ie,P=ye+(G-ie),F=$*Z/w*M,R=ne*Z/w*M;B.projectionMatrix.makePerspective(O,P,F,R,M,w)}function x(B,H){H===null?B.matrixWorld.copy(B.matrix):B.matrixWorld.multiplyMatrices(H.matrixWorld,B.matrix),B.matrixWorldInverse.copy(B.matrixWorld).invert()}this.getCamera=function(B){f.near=u.near=h.near=B.near,f.far=u.far=h.far=B.far,(m!==f.near||v!==f.far)&&(n.updateRenderState({depthNear:f.near,depthFar:f.far}),m=f.near,v=f.far);const H=B.parent,j=f.cameras;x(f,H);for(let D=0;D<j.length;D++)x(j[D],H);B.matrixWorld.copy(f.matrixWorld),B.matrix.copy(f.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale);const G=B.children;for(let D=0,k=G.length;D<k;D++)G[D].updateMatrixWorld(!0);return j.length===2?T(f,h,u):f.projectionMatrix.copy(h.projectionMatrix),f};let L=null;function W(B,H){if(a=H.getViewerPose(o),a!==null){const G=a.views,D=n.renderState.baseLayer;e.setFramebuffer(D.framebuffer);let k=!1;G.length!==f.cameras.length&&(f.cameras.length=0,k=!0);for(let Y=0;Y<G.length;Y++){const Z=G[Y],$=D.getViewport(Z),ne=d[Y];ne.matrix.fromArray(Z.transform.matrix),ne.projectionMatrix.fromArray(Z.projectionMatrix),ne.viewport.set($.x,$.y,$.width,$.height),Y===0&&f.matrix.copy(ne.matrix),k===!0&&f.cameras.push(ne)}}const j=n.inputSources;for(let G=0;G<l.length;G++){const D=l[G],k=j[G];D.update(k,H,o)}L&&L(B,H)}const U=new Ka;U.setAnimationLoop(W),this.setAnimationLoop=function(B){L=B},this.dispose=function(){}}Object.assign(bl.prototype,ci.prototype);function Mm(e){function t(g,p){g.fogColor.value.copy(p.color),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function i(g,p,E,S){p.isMeshBasicMaterial?n(g,p):p.isMeshLambertMaterial?(n(g,p),l(g,p)):p.isMeshToonMaterial?(n(g,p),h(g,p)):p.isMeshPhongMaterial?(n(g,p),c(g,p)):p.isMeshStandardMaterial?(n(g,p),p.isMeshPhysicalMaterial?d(g,p):u(g,p)):p.isMeshMatcapMaterial?(n(g,p),f(g,p)):p.isMeshDepthMaterial?(n(g,p),m(g,p)):p.isMeshDistanceMaterial?(n(g,p),v(g,p)):p.isMeshNormalMaterial?(n(g,p),_(g,p)):p.isLineBasicMaterial?(r(g,p),p.isLineDashedMaterial&&o(g,p)):p.isPointsMaterial?s(g,p,E,S):p.isSpriteMaterial?a(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function n(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),p.alphaMap&&(g.alphaMap.value=p.alphaMap),p.specularMap&&(g.specularMap.value=p.specularMap);const E=e.get(p).envMap;if(E){g.envMap.value=E,g.flipEnvMap.value=E.isCubeTexture&&E._needsFlipEnvMap?-1:1,g.reflectivity.value=p.reflectivity,g.refractionRatio.value=p.refractionRatio;const x=e.get(E).__maxMipLevel;x!==void 0&&(g.maxMipLevel.value=x)}p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity);let S;p.map?S=p.map:p.specularMap?S=p.specularMap:p.displacementMap?S=p.displacementMap:p.normalMap?S=p.normalMap:p.bumpMap?S=p.bumpMap:p.roughnessMap?S=p.roughnessMap:p.metalnessMap?S=p.metalnessMap:p.alphaMap?S=p.alphaMap:p.emissiveMap?S=p.emissiveMap:p.clearcoatMap?S=p.clearcoatMap:p.clearcoatNormalMap?S=p.clearcoatNormalMap:p.clearcoatRoughnessMap&&(S=p.clearcoatRoughnessMap),S!==void 0&&(S.isWebGLRenderTarget&&(S=S.texture),S.matrixAutoUpdate===!0&&S.updateMatrix(),g.uvTransform.value.copy(S.matrix));let T;p.aoMap?T=p.aoMap:p.lightMap&&(T=p.lightMap),T!==void 0&&(T.isWebGLRenderTarget&&(T=T.texture),T.matrixAutoUpdate===!0&&T.updateMatrix(),g.uv2Transform.value.copy(T.matrix))}function r(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function s(g,p,E,S){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*E,g.scale.value=S*.5,p.map&&(g.map.value=p.map),p.alphaMap&&(g.alphaMap.value=p.alphaMap);let T;p.map?T=p.map:p.alphaMap&&(T=p.alphaMap),T!==void 0&&(T.matrixAutoUpdate===!0&&T.updateMatrix(),g.uvTransform.value.copy(T.matrix))}function a(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),p.alphaMap&&(g.alphaMap.value=p.alphaMap);let E;p.map?E=p.map:p.alphaMap&&(E=p.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),g.uvTransform.value.copy(E.matrix))}function l(g,p){p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap)}function c(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap),p.bumpMap&&(g.bumpMap.value=p.bumpMap,g.bumpScale.value=p.bumpScale,p.side===Ze&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,g.normalScale.value.copy(p.normalScale),p.side===Ze&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias)}function h(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap),p.bumpMap&&(g.bumpMap.value=p.bumpMap,g.bumpScale.value=p.bumpScale,p.side===Ze&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,g.normalScale.value.copy(p.normalScale),p.side===Ze&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias)}function u(g,p){g.roughness.value=p.roughness,g.metalness.value=p.metalness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap),p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap),p.bumpMap&&(g.bumpMap.value=p.bumpMap,g.bumpScale.value=p.bumpScale,p.side===Ze&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,g.normalScale.value.copy(p.normalScale),p.side===Ze&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),e.get(p).envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function d(g,p){u(g,p),g.reflectivity.value=p.reflectivity,g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.sheen&&g.sheen.value.copy(p.sheen),p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap),p.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),g.clearcoatNormalMap.value=p.clearcoatNormalMap,p.side===Ze&&g.clearcoatNormalScale.value.negate()),g.transmission.value=p.transmission,p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap)}function f(g,p){p.matcap&&(g.matcap.value=p.matcap),p.bumpMap&&(g.bumpMap.value=p.bumpMap,g.bumpScale.value=p.bumpScale,p.side===Ze&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,g.normalScale.value.copy(p.normalScale),p.side===Ze&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias)}function m(g,p){p.displacementMap&&(g.displacementMap.value=p.displacementMap,g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias)}function v(g,p){p.displacementMap&&(g.displacementMap.value=p.displacementMap,g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),g.referencePosition.value.copy(p.referencePosition),g.nearDistance.value=p.nearDistance,g.farDistance.value=p.farDistance}function _(g,p){p.bumpMap&&(g.bumpMap.value=p.bumpMap,g.bumpScale.value=p.bumpScale,p.side===Ze&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,g.normalScale.value.copy(p.normalScale),p.side===Ze&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias)}return{refreshFogUniforms:t,refreshMaterialUniforms:i}}function Tm(){const e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.style.display="block",e}function _r(e){e=e||{};const t=e.canvas!==void 0?e.canvas:Tm(),i=e.context!==void 0?e.context:null,n=e.alpha!==void 0?e.alpha:!1,r=e.depth!==void 0?e.depth:!0,o=e.stencil!==void 0?e.stencil:!0,s=e.antialias!==void 0?e.antialias:!1,a=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,l=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,c=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1;let u=null,d=null;const f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=sr,this.physicallyCorrectLights=!1,this.toneMapping=tr,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;const m=this;let v=!1,_=null,g=0,p=0,E=null,S=null,T=-1,x=null;const L=new ke,W=new ke;let U=null,B=t.width,H=t.height,j=1,G=null,D=null;const k=new ke(0,0,B,H),Y=new ke(0,0,B,H);let Z=!1;const $=new lo;let ne=!1,ae=!1;const de=new Re,ce=new A,ye={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ne(){return E===null?j:1}let ie=i;function M(C,ee){for(let K=0;K<C.length;K++){const oe=C[K],fe=t.getContext(oe,ee);if(fe!==null)return fe}return null}try{const C={alpha:n,depth:r,stencil:o,antialias:s,premultipliedAlpha:a,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:h};if(t.addEventListener("webglcontextlost",Te,!1),t.addEventListener("webglcontextrestored",Ke,!1),ie===null){const ee=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ee.shift(),ie=M(ee,C),ie===null)throw M(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}ie.getShaderPrecisionFormat===void 0&&(ie.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(C){throw console.error("THREE.WebGLRenderer: "+C.message),C}let w,O,P,F,R,N,I,V,X,Q,b,y,J,q,z,te,re,ue,se,ge,ve;function be(){w=new ef(ie),O=new Jp(ie,w,e),w.init(O),ge=new wm(ie,w,O),P=new ym(ie,w,O),P.scissor(W.copy(Y).multiplyScalar(j).floor()),P.viewport(L.copy(k).multiplyScalar(j).floor()),F=new rf,R=new lm,N=new bm(ie,w,P,R,O,ge,F),I=new $p(m),V=new Su(ie,O),ve=new Qp(ie,w,V,O),X=new tf(ie,V,F,ve),Q=new lf(ie,X,V,F),re=new af(ie),z=new Kp(R),b=new am(m,I,w,O,ve,z),y=new Mm(R),J=new um(R),q=new vm(w,O),te=new qp(m,I,P,Q,a),ue=new Zp(ie,w,F,O),se=new nf(ie,w,F,O),F.programs=b.programs,m.capabilities=O,m.extensions=w,m.properties=R,m.renderLists=J,m.state=P,m.info=F}be();const pe=new bl(m,ie);this.xr=pe;const _e=new yl(m,Q,O.maxTextureSize);this.shadowMap=_e,this.getContext=function(){return ie},this.getContextAttributes=function(){return ie.getContextAttributes()},this.forceContextLoss=function(){const C=w.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=w.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return j},this.setPixelRatio=function(C){C!==void 0&&(j=C,this.setSize(B,H,!1))},this.getSize=function(C){return C===void 0&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),C=new le),C.set(B,H)},this.setSize=function(C,ee,K){if(pe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=C,H=ee,t.width=Math.floor(C*j),t.height=Math.floor(ee*j),K!==!1&&(t.style.width=C+"px",t.style.height=ee+"px"),this.setViewport(0,0,C,ee)},this.getDrawingBufferSize=function(C){return C===void 0&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),C=new le),C.set(B*j,H*j).floor()},this.setDrawingBufferSize=function(C,ee,K){B=C,H=ee,j=K,t.width=Math.floor(C*K),t.height=Math.floor(ee*K),this.setViewport(0,0,C,ee)},this.getCurrentViewport=function(C){return C===void 0&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),C=new ke),C.copy(L)},this.getViewport=function(C){return C.copy(k)},this.setViewport=function(C,ee,K,oe){C.isVector4?k.set(C.x,C.y,C.z,C.w):k.set(C,ee,K,oe),P.viewport(L.copy(k).multiplyScalar(j).floor())},this.getScissor=function(C){return C.copy(Y)},this.setScissor=function(C,ee,K,oe){C.isVector4?Y.set(C.x,C.y,C.z,C.w):Y.set(C,ee,K,oe),P.scissor(W.copy(Y).multiplyScalar(j).floor())},this.getScissorTest=function(){return Z},this.setScissorTest=function(C){P.setScissorTest(Z=C)},this.setOpaqueSort=function(C){G=C},this.setTransparentSort=function(C){D=C},this.getClearColor=function(C){return C===void 0&&(console.warn("WebGLRenderer: .getClearColor() now requires a Color as an argument"),C=new he),C.copy(te.getClearColor())},this.setClearColor=function(){te.setClearColor.apply(te,arguments)},this.getClearAlpha=function(){return te.getClearAlpha()},this.setClearAlpha=function(){te.setClearAlpha.apply(te,arguments)},this.clear=function(C,ee,K){let oe=0;(C===void 0||C)&&(oe|=16384),(ee===void 0||ee)&&(oe|=256),(K===void 0||K)&&(oe|=1024),ie.clear(oe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Te,!1),t.removeEventListener("webglcontextrestored",Ke,!1),J.dispose(),q.dispose(),R.dispose(),I.dispose(),Q.dispose(),ve.dispose(),pe.dispose(),ht.stop()};function Te(C){C.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function Ke(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1,be()}function ct(C){const ee=C.target;ee.removeEventListener("dispose",ct),zt(ee)}function zt(C){It(C),R.remove(C)}function It(C){const ee=R.get(C).program;ee!==void 0&&b.releaseProgram(ee)}function kt(C,ee){C.render(function(K){m.renderBufferImmediate(K,ee)})}this.renderBufferImmediate=function(C,ee){ve.initAttributes();const K=R.get(C);C.hasPositions&&!K.position&&(K.position=ie.createBuffer()),C.hasNormals&&!K.normal&&(K.normal=ie.createBuffer()),C.hasUvs&&!K.uv&&(K.uv=ie.createBuffer()),C.hasColors&&!K.color&&(K.color=ie.createBuffer());const oe=ee.getAttributes();C.hasPositions&&(ie.bindBuffer(34962,K.position),ie.bufferData(34962,C.positionArray,35048),ve.enableAttribute(oe.position),ie.vertexAttribPointer(oe.position,3,5126,!1,0,0)),C.hasNormals&&(ie.bindBuffer(34962,K.normal),ie.bufferData(34962,C.normalArray,35048),ve.enableAttribute(oe.normal),ie.vertexAttribPointer(oe.normal,3,5126,!1,0,0)),C.hasUvs&&(ie.bindBuffer(34962,K.uv),ie.bufferData(34962,C.uvArray,35048),ve.enableAttribute(oe.uv),ie.vertexAttribPointer(oe.uv,2,5126,!1,0,0)),C.hasColors&&(ie.bindBuffer(34962,K.color),ie.bufferData(34962,C.colorArray,35048),ve.enableAttribute(oe.color),ie.vertexAttribPointer(oe.color,3,5126,!1,0,0)),ve.disableUnusedAttributes(),ie.drawArrays(4,0,C.count),C.count=0},this.renderBufferDirect=function(C,ee,K,oe,fe,Ae){ee===null&&(ee=ye);const Ce=fe.isMesh&&fe.matrixWorld.determinant()<0,ze=Bt(C,ee,oe,fe);P.setMaterial(oe,Ce);let Pe=K.index;const it=K.attributes.position;if(Pe===null){if(it===void 0||it.count===0)return}else if(Pe.count===0)return;let Ye=1;oe.wireframe===!0&&(Pe=X.getWireframeAttribute(K),Ye=2),(oe.morphTargets||oe.morphNormals)&&re.update(fe,K,oe,ze),ve.setup(fe,oe,ze,K,Pe);let Ee,Ve=ue;Pe!==null&&(Ee=V.get(Pe),Ve=se,Ve.setIndex(Ee));const ai=Pe!==null?Pe.count:it.count,We=K.drawRange.start*Ye,Hi=K.drawRange.count*Ye,nt=Ae!==null?Ae.start*Ye:0,zo=Ae!==null?Ae.count*Ye:1/0,bt=Math.max(We,nt),Jn=Math.min(ai,We+Hi,nt+zo)-1,rn=Math.max(0,Jn-bt+1);if(rn!==0){if(fe.isMesh)oe.wireframe===!0?(P.setLineWidth(oe.wireframeLinewidth*Ne()),Ve.setMode(1)):Ve.setMode(4);else if(fe.isLine){let Kn=oe.linewidth;Kn===void 0&&(Kn=1),P.setLineWidth(Kn*Ne()),fe.isLineSegments?Ve.setMode(1):fe.isLineLoop?Ve.setMode(2):Ve.setMode(3)}else fe.isPoints?Ve.setMode(0):fe.isSprite&&Ve.setMode(4);if(fe.isInstancedMesh)Ve.renderInstances(bt,rn,fe.count);else if(K.isInstancedBufferGeometry){const Kn=Math.min(K.instanceCount,K._maxInstanceCount);Ve.renderInstances(bt,rn,Kn)}else Ve.render(bt,rn)}},this.compile=function(C,ee){d=q.get(C),d.init(),C.traverseVisible(function(oe){oe.isLight&&oe.layers.test(ee.layers)&&(d.pushLight(oe),oe.castShadow&&d.pushShadow(oe))}),d.setupLights();const K=new WeakMap;C.traverse(function(oe){const fe=oe.material;if(fe)if(Array.isArray(fe))for(let Ae=0;Ae<fe.length;Ae++){const Ce=fe[Ae];K.has(Ce)===!1&&(et(Ce,C,oe),K.set(Ce))}else K.has(fe)===!1&&(et(fe,C,oe),K.set(fe))})};let Ht=null;function bi(C){pe.isPresenting||Ht&&Ht(C)}const ht=new Ka;ht.setAnimationLoop(bi),typeof window<"u"&&ht.setContext(window),this.setAnimationLoop=function(C){Ht=C,pe.setAnimationLoop(C),C===null?ht.stop():ht.start()},this.render=function(C,ee){let K,oe;if(arguments[2]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),K=arguments[2]),arguments[3]!==void 0&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),oe=arguments[3]),ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;ve.resetDefaultState(),T=-1,x=null,C.autoUpdate===!0&&C.updateMatrixWorld(),ee.parent===null&&ee.updateMatrixWorld(),pe.enabled===!0&&pe.isPresenting===!0&&(ee=pe.getCamera(ee)),C.isScene===!0&&C.onBeforeRender(m,C,ee,K||E),d=q.get(C,f.length),d.init(),f.push(d),de.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),$.setFromProjectionMatrix(de),ae=this.localClippingEnabled,ne=z.init(this.clippingPlanes,ae,ee),u=J.get(C,ee),u.init(),st(C,ee,0,m.sortObjects),u.finish(),m.sortObjects===!0&&u.sort(G,D),ne===!0&&z.beginShadows();const fe=d.state.shadowsArray;_e.render(fe,C,ee),d.setupLights(),d.setupLightsView(ee),ne===!0&&z.endShadows(),this.info.autoReset===!0&&this.info.reset(),K!==void 0&&this.setRenderTarget(K),te.render(u,C,ee,oe);const Ae=u.opaque,Ce=u.transparent;Ae.length>0&&yt(Ae,C,ee),Ce.length>0&&yt(Ce,C,ee),C.isScene===!0&&C.onAfterRender(m,C,ee),E!==null&&(N.updateRenderTargetMipmap(E),N.updateMultisampleRenderTarget(E)),P.buffers.depth.setTest(!0),P.buffers.depth.setMask(!0),P.buffers.color.setMask(!0),P.setPolygonOffset(!1),f.pop(),f.length>0?d=f[f.length-1]:d=null,u=null};function st(C,ee,K,oe){if(C.visible===!1)return;if(C.layers.test(ee.layers)){if(C.isGroup)K=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(ee);else if(C.isLight)d.pushLight(C),C.castShadow&&d.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||$.intersectsSprite(C)){oe&&ce.setFromMatrixPosition(C.matrixWorld).applyMatrix4(de);const Ae=Q.update(C),Ce=C.material;Ce.visible&&u.push(C,Ae,Ce,K,ce.z,null)}}else if(C.isImmediateRenderObject)oe&&ce.setFromMatrixPosition(C.matrixWorld).applyMatrix4(de),u.push(C,null,C.material,K,ce.z,null);else if((C.isMesh||C.isLine||C.isPoints)&&(C.isSkinnedMesh&&C.skeleton.frame!==F.render.frame&&(C.skeleton.update(),C.skeleton.frame=F.render.frame),!C.frustumCulled||$.intersectsObject(C))){oe&&ce.setFromMatrixPosition(C.matrixWorld).applyMatrix4(de);const Ae=Q.update(C),Ce=C.material;if(Array.isArray(Ce)){const ze=Ae.groups;for(let Pe=0,it=ze.length;Pe<it;Pe++){const Ye=ze[Pe],Ee=Ce[Ye.materialIndex];Ee&&Ee.visible&&u.push(C,Ae,Ee,K,ce.z,Ye)}}else Ce.visible&&u.push(C,Ae,Ce,K,ce.z,null)}}const fe=C.children;for(let Ae=0,Ce=fe.length;Ae<Ce;Ae++)st(fe[Ae],ee,K,oe)}function yt(C,ee,K){const oe=ee.isScene===!0?ee.overrideMaterial:null;for(let fe=0,Ae=C.length;fe<Ae;fe++){const Ce=C[fe],ze=Ce.object,Pe=Ce.geometry,it=oe===null?Ce.material:oe,Ye=Ce.group;if(K.isArrayCamera){const Ee=K.cameras;for(let Ve=0,ai=Ee.length;Ve<ai;Ve++){const We=Ee[Ve];ze.layers.test(We.layers)&&(P.viewport(L.copy(We.viewport)),d.setupLightsView(We),Qt(ze,ee,We,Pe,it,Ye))}}else Qt(ze,ee,K,Pe,it,Ye)}}function Qt(C,ee,K,oe,fe,Ae){if(C.onBeforeRender(m,ee,K,oe,fe,Ae),C.modelViewMatrix.multiplyMatrices(K.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),C.isImmediateRenderObject){const Ce=Bt(K,ee,fe,C);P.setMaterial(fe),ve.reset(),kt(C,Ce)}else m.renderBufferDirect(K,ee,oe,fe,C,Ae);C.onAfterRender(m,ee,K,oe,fe,Ae)}function et(C,ee,K){ee.isScene!==!0&&(ee=ye);const oe=R.get(C),fe=d.state.lights,Ae=d.state.shadowsArray,Ce=fe.state.version,ze=b.getParameters(C,fe.state,Ae,ee,K),Pe=b.getProgramCacheKey(ze);let it=oe.program,Ye=!0;if(oe.environment=C.isMeshStandardMaterial?ee.environment:null,oe.fog=ee.fog,oe.envMap=I.get(C.envMap||oe.environment),it===void 0)C.addEventListener("dispose",ct);else if(it.cacheKey!==Pe)It(C);else if(oe.lightsStateVersion!==Ce)Ye=!1;else{if(ze.shaderID!==void 0)return;Ye=!1}Ye&&(ze.uniforms=b.getUniforms(C),C.onBeforeCompile(ze,m),it=b.acquireProgram(ze,Pe),oe.program=it,oe.uniforms=ze.uniforms,oe.outputEncoding=ze.outputEncoding);const Ee=oe.uniforms;(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(oe.numClippingPlanes=z.numPlanes,oe.numIntersection=z.numIntersection,Ee.clippingPlanes=z.uniform),oe.needsLights=Uo(C),oe.lightsStateVersion=Ce,oe.needsLights&&(Ee.ambientLightColor.value=fe.state.ambient,Ee.lightProbe.value=fe.state.probe,Ee.directionalLights.value=fe.state.directional,Ee.directionalLightShadows.value=fe.state.directionalShadow,Ee.spotLights.value=fe.state.spot,Ee.spotLightShadows.value=fe.state.spotShadow,Ee.rectAreaLights.value=fe.state.rectArea,Ee.ltc_1.value=fe.state.rectAreaLTC1,Ee.ltc_2.value=fe.state.rectAreaLTC2,Ee.pointLights.value=fe.state.point,Ee.pointLightShadows.value=fe.state.pointShadow,Ee.hemisphereLights.value=fe.state.hemi,Ee.directionalShadowMap.value=fe.state.directionalShadowMap,Ee.directionalShadowMatrix.value=fe.state.directionalShadowMatrix,Ee.spotShadowMap.value=fe.state.spotShadowMap,Ee.spotShadowMatrix.value=fe.state.spotShadowMatrix,Ee.pointShadowMap.value=fe.state.pointShadowMap,Ee.pointShadowMatrix.value=fe.state.pointShadowMatrix);const Ve=oe.program.getUniforms(),ai=Fi.seqWithValue(Ve.seq,Ee);oe.uniformsList=ai}function Bt(C,ee,K,oe){ee.isScene!==!0&&(ee=ye),N.resetTextureUnits();const fe=ee.fog,Ae=K.isMeshStandardMaterial?ee.environment:null,Ce=E===null?m.outputEncoding:E.texture.encoding,ze=I.get(K.envMap||Ae),Pe=R.get(K),it=d.state.lights;if(ne===!0&&(ae===!0||C!==x)){const nt=C===x&&K.id===T;z.setState(K,C,nt)}K.version===Pe.__version?(K.fog&&Pe.fog!==fe||Pe.environment!==Ae||Pe.needsLights&&Pe.lightsStateVersion!==it.state.version||Pe.numClippingPlanes!==void 0&&(Pe.numClippingPlanes!==z.numPlanes||Pe.numIntersection!==z.numIntersection)||Pe.outputEncoding!==Ce||Pe.envMap!==ze)&&et(K,ee,oe):(et(K,ee,oe),Pe.__version=K.version);let Ye=!1,Ee=!1,Ve=!1;const ai=Pe.program,We=ai.getUniforms(),Hi=Pe.uniforms;if(P.useProgram(ai.program)&&(Ye=!0,Ee=!0,Ve=!0),K.id!==T&&(T=K.id,Ee=!0),Ye||x!==C){if(We.setValue(ie,"projectionMatrix",C.projectionMatrix),O.logarithmicDepthBuffer&&We.setValue(ie,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),x!==C&&(x=C,Ee=!0,Ve=!0),K.isShaderMaterial||K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshStandardMaterial||K.envMap){const nt=We.map.cameraPosition;nt!==void 0&&nt.setValue(ie,ce.setFromMatrixPosition(C.matrixWorld))}(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&We.setValue(ie,"isOrthographic",C.isOrthographicCamera===!0),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial||K.isShadowMaterial||K.skinning)&&We.setValue(ie,"viewMatrix",C.matrixWorldInverse)}if(K.skinning){We.setOptional(ie,oe,"bindMatrix"),We.setOptional(ie,oe,"bindMatrixInverse");const nt=oe.skeleton;if(nt){const zo=nt.bones;if(O.floatVertexTextures){if(nt.boneTexture===null){let bt=Math.sqrt(zo.length*4);bt=Se.ceilPowerOfTwo(bt),bt=Math.max(bt,4);const Jn=new Float32Array(bt*bt*4);Jn.set(nt.boneMatrices);const rn=new Sn(Jn,bt,bt,wt,li);nt.boneMatrices=Jn,nt.boneTexture=rn,nt.boneTextureSize=bt}We.setValue(ie,"boneTexture",nt.boneTexture,N),We.setValue(ie,"boneTextureSize",nt.boneTextureSize)}else We.setOptional(ie,nt,"boneMatrices")}}return(Ee||Pe.receiveShadow!==oe.receiveShadow)&&(Pe.receiveShadow=oe.receiveShadow,We.setValue(ie,"receiveShadow",oe.receiveShadow)),Ee&&(We.setValue(ie,"toneMappingExposure",m.toneMappingExposure),Pe.needsLights&&Zn(Hi,Ve),fe&&K.fog&&y.refreshFogUniforms(Hi,fe),y.refreshMaterialUniforms(Hi,K,j,H),Fi.upload(ie,Pe.uniformsList,Hi,N)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(Fi.upload(ie,Pe.uniformsList,Hi,N),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&We.setValue(ie,"center",oe.center),We.setValue(ie,"modelViewMatrix",oe.modelViewMatrix),We.setValue(ie,"normalMatrix",oe.normalMatrix),We.setValue(ie,"modelMatrix",oe.matrixWorld),ai}function Zn(C,ee){C.ambientLightColor.needsUpdate=ee,C.lightProbe.needsUpdate=ee,C.directionalLights.needsUpdate=ee,C.directionalLightShadows.needsUpdate=ee,C.pointLights.needsUpdate=ee,C.pointLightShadows.needsUpdate=ee,C.spotLights.needsUpdate=ee,C.spotLightShadows.needsUpdate=ee,C.rectAreaLights.needsUpdate=ee,C.hemisphereLights.needsUpdate=ee}function Uo(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.setFramebuffer=function(C){_!==C&&E===null&&ie.bindFramebuffer(36160,C),_=C},this.getActiveCubeFace=function(){return g},this.getActiveMipmapLevel=function(){return p},this.getRenderList=function(){return u},this.setRenderList=function(C){u=C},this.getRenderTarget=function(){return E},this.setRenderTarget=function(C,ee=0,K=0){E=C,g=ee,p=K,C&&R.get(C).__webglFramebuffer===void 0&&N.setupRenderTarget(C);let oe=_,fe=!1;if(C){const Ae=R.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(oe=Ae[ee],fe=!0):C.isWebGLMultisampleRenderTarget?oe=R.get(C).__webglMultisampledFramebuffer:oe=Ae,L.copy(C.viewport),W.copy(C.scissor),U=C.scissorTest}else L.copy(k).multiplyScalar(j).floor(),W.copy(Y).multiplyScalar(j).floor(),U=Z;if(S!==oe&&(ie.bindFramebuffer(36160,oe),S=oe),P.viewport(L),P.scissor(W),P.setScissorTest(U),fe){const Ae=R.get(C.texture);ie.framebufferTexture2D(36160,36064,34069+ee,Ae.__webglTexture,K)}},this.readRenderTargetPixels=function(C,ee,K,oe,fe,Ae,Ce){if(!(C&&C.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ze=R.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ce!==void 0&&(ze=ze[Ce]),ze){let Pe=!1;ze!==S&&(ie.bindFramebuffer(36160,ze),Pe=!0);try{const it=C.texture,Ye=it.format,Ee=it.type;if(Ye!==wt&&ge.convert(Ye)!==ie.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ve=Ee===kr&&(w.has("EXT_color_buffer_half_float")||O.isWebGL2&&w.has("EXT_color_buffer_float"));if(Ee!==Ur&&ge.convert(Ee)!==ie.getParameter(35738)&&!(Ee===li&&(O.isWebGL2||w.has("OES_texture_float")||w.has("WEBGL_color_buffer_float")))&&!Ve){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ie.checkFramebufferStatus(36160)===36053?ee>=0&&ee<=C.width-oe&&K>=0&&K<=C.height-fe&&ie.readPixels(ee,K,oe,fe,ge.convert(Ye),ge.convert(Ee),Ae):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{Pe&&ie.bindFramebuffer(36160,S)}}},this.copyFramebufferToTexture=function(C,ee,K=0){const oe=Math.pow(2,-K),fe=Math.floor(ee.image.width*oe),Ae=Math.floor(ee.image.height*oe),Ce=ge.convert(ee.format);N.setTexture2D(ee,0),ie.copyTexImage2D(3553,K,Ce,C.x,C.y,fe,Ae,0),P.unbindTexture()},this.copyTextureToTexture=function(C,ee,K,oe=0){const fe=ee.image.width,Ae=ee.image.height,Ce=ge.convert(K.format),ze=ge.convert(K.type);N.setTexture2D(K,0),ie.pixelStorei(37440,K.flipY),ie.pixelStorei(37441,K.premultiplyAlpha),ie.pixelStorei(3317,K.unpackAlignment),ee.isDataTexture?ie.texSubImage2D(3553,oe,C.x,C.y,fe,Ae,Ce,ze,ee.image.data):ee.isCompressedTexture?ie.compressedTexSubImage2D(3553,oe,C.x,C.y,ee.mipmaps[0].width,ee.mipmaps[0].height,Ce,ee.mipmaps[0].data):ie.texSubImage2D(3553,oe,C.x,C.y,Ce,ze,ee.image),oe===0&&K.generateMipmaps&&ie.generateMipmap(3553),P.unbindTexture()},this.initTexture=function(C){N.setTexture2D(C,0),P.unbindTexture()},this.resetState=function(){P.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function wl(e){_r.call(this,e)}wl.prototype=Object.assign(Object.create(_r.prototype),{constructor:wl,isWebGL1Renderer:!0});class Es extends we{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,i){return super.copy(t,i),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const i=super.toJSON(t);return this.background!==null&&(i.object.background=this.background.toJSON(t)),this.environment!==null&&(i.object.environment=this.environment.toJSON(t)),this.fog!==null&&(i.object.fog=this.fog.toJSON()),i}}function Pt(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Br,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Se.generateUUID()}Object.defineProperty(Pt.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(Pt.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this},set:function(e,t=0){return this.array.set(e,t),this},clone:function(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Se.generateUUID()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new Pt(t,this.stride);return i.setUsage(this.usage),i},onUpload:function(e){return this.onUploadCallback=e,this},toJSON:function(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Se.generateUUID()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});const Ji=new A;function Oi(e,t,i,n){this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n===!0}Object.defineProperties(Oi.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(e){this.data.needsUpdate=e}}}),Object.assign(Oi.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(e){for(let t=0,i=this.data.count;t<i;t++)Ji.x=this.getX(t),Ji.y=this.getY(t),Ji.z=this.getZ(t),Ji.applyMatrix4(e),this.setXYZ(t,Ji.x,Ji.y,Ji.z);return this},setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this},setXYZ:function(e,t,i,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this},setXYZW:function(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this},clone:function(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new Le(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Oi(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}});function Ki(e){Me.call(this),this.type="SpriteMaterial",this.color=new he(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}Ki.prototype=Object.create(Me.prototype),Ki.prototype.constructor=Ki,Ki.prototype.isSpriteMaterial=!0,Ki.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this};let Rn;const xr=new A,Cn=new A,Nn=new A,In=new le,yr=new le,Ml=new Re,co=new A,br=new A,ho=new A,Tl=new le,Ls=new le,Al=new le;function Sl(e){if(we.call(this),this.type="Sprite",Rn===void 0){Rn=new De;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Pt(t,5);Rn.setIndex([0,1,2,0,2,3]),Rn.setAttribute("position",new Oi(i,3,0,!1)),Rn.setAttribute("uv",new Oi(i,2,3,!1))}this.geometry=Rn,this.material=e!==void 0?e:new Ki,this.center=new le(.5,.5)}Sl.prototype=Object.assign(Object.create(we.prototype),{constructor:Sl,isSprite:!0,raycast:function(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Cn.setFromMatrixScale(this.matrixWorld),Ml.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Nn.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Cn.multiplyScalar(-Nn.z);const i=this.material.rotation;let n,r;i!==0&&(r=Math.cos(i),n=Math.sin(i));const o=this.center;uo(co.set(-.5,-.5,0),Nn,o,Cn,n,r),uo(br.set(.5,-.5,0),Nn,o,Cn,n,r),uo(ho.set(.5,.5,0),Nn,o,Cn,n,r),Tl.set(0,0),Ls.set(1,0),Al.set(1,1);let s=e.ray.intersectTriangle(co,br,ho,!1,xr);if(s===null&&(uo(br.set(-.5,.5,0),Nn,o,Cn,n,r),Ls.set(0,1),s=e.ray.intersectTriangle(co,ho,br,!1,xr),s===null))return;const a=e.ray.origin.distanceTo(xr);a<e.near||a>e.far||t.push({distance:a,point:xr.clone(),uv:xt.getUV(xr,co,br,ho,Tl,Ls,Al,new le),face:null,object:this})},copy:function(e){return we.prototype.copy.call(this,e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}});function uo(e,t,i,n,r,o){In.subVectors(e,i).addScalar(.5).multiply(n),r!==void 0?(yr.x=o*In.x-r*In.y,yr.y=r*In.x+o*In.y):yr.copy(In),e.copy(t),e.x+=yr.x,e.y+=yr.y,e.applyMatrix4(Ml)}const po=new A,El=new A;function Ps(){we.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}Ps.prototype=Object.assign(Object.create(we.prototype),{constructor:Ps,isLOD:!0,copy:function(e){we.prototype.copy.call(this,e,!1);const t=e.levels;for(let i=0,n=t.length;i<n;i++){const r=t[i];this.addLevel(r.object.clone(),r.distance)}return this.autoUpdate=e.autoUpdate,this},addLevel:function(e,t=0){t=Math.abs(t);const i=this.levels;let n;for(n=0;n<i.length&&!(t<i[n].distance);n++);return i.splice(n,0,{distance:t,object:e}),this.add(e),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(e){const t=this.levels;if(t.length>0){let i,n;for(i=1,n=t.length;i<n&&!(e<t[i].distance);i++);return t[i-1].object}return null},raycast:function(e,t){if(this.levels.length>0){po.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(po);this.getObjectForDistance(i).raycast(e,t)}},update:function(e){const t=this.levels;if(t.length>1){po.setFromMatrixPosition(e.matrixWorld),El.setFromMatrixPosition(this.matrixWorld);const i=po.distanceTo(El)/e.zoom;t[0].object.visible=!0;let n,r;for(n=1,r=t.length;n<r&&i>=t[n].distance;n++)t[n-1].object.visible=!1,t[n].object.visible=!0;for(this._currentLevel=n-1;n<r;n++)t[n].object.visible=!1}},toJSON:function(e){const t=we.prototype.toJSON.call(this,e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let n=0,r=i.length;n<r;n++){const o=i[n];t.object.levels.push({object:o.object.uuid,distance:o.distance})}return t}});const Ll=new A,Pl=new ke,Rl=new ke,Am=new A,Cl=new Re;function fo(e,t){e&&e.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Oe.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Re,this.bindMatrixInverse=new Re}fo.prototype=Object.assign(Object.create(Oe.prototype),{constructor:fo,isSkinnedMesh:!0,copy:function(e){return Oe.prototype.copy.call(this,e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this},bind:function(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){const e=new ke,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}},updateMatrixWorld:function(e){Oe.prototype.updateMatrixWorld.call(this,e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(e,t){const i=this.skeleton,n=this.geometry;Pl.fromBufferAttribute(n.attributes.skinIndex,e),Rl.fromBufferAttribute(n.attributes.skinWeight,e),Ll.fromBufferAttribute(n.attributes.position,e).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=Rl.getComponent(r);if(o!==0){const s=Pl.getComponent(r);Cl.multiplyMatrices(i.bones[s].matrixWorld,i.boneInverses[s]),t.addScaledVector(Am.copy(Ll).applyMatrix4(Cl),o)}}return t.applyMatrix4(this.bindMatrixInverse)}});function mo(){we.call(this),this.type="Bone"}mo.prototype=Object.assign(Object.create(we.prototype),{constructor:mo,isBone:!0});const Nl=new Re,Sm=new Re;function go(e=[],t=[]){this.uuid=Se.generateUUID(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}Object.assign(go.prototype,{init:function(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Re)}},calculateInverses:function(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Re;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}},pose:function(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}},update:function(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const s=e[r]?e[r].matrixWorld:Sm;Nl.multiplyMatrices(s,t[r]),Nl.toArray(i,r*16)}n!==null&&(n.needsUpdate=!0)},clone:function(){return new go(this.bones,this.boneInverses)},getBoneByName:function(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}},dispose:function(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)},fromJSON:function(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const r=e.bones[i];let o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new mo),this.bones.push(o),this.boneInverses.push(new Re().fromArray(e.boneInverses[i]))}return this.init(),this},toJSON:function(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,r=t.length;n<r;n++){const o=t[n];e.bones.push(o.uuid);const s=i[n];e.boneInverses.push(s.toArray())}return e}});const Il=new Re,Fl=new Re,vo=[],wr=new Oe;function Ol(e,t,i){Oe.call(this,e,t),this.instanceMatrix=new Le(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}Ol.prototype=Object.assign(Object.create(Oe.prototype),{constructor:Ol,isInstancedMesh:!0,copy:function(e){return Oe.prototype.copy.call(this,e),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this},getColorAt:function(e,t){t.fromArray(this.instanceColor.array,e*3)},getMatrixAt:function(e,t){t.fromArray(this.instanceMatrix.array,e*16)},raycast:function(e,t){const i=this.matrixWorld,n=this.count;if(wr.geometry=this.geometry,wr.material=this.material,wr.material!==void 0)for(let r=0;r<n;r++){this.getMatrixAt(r,Il),Fl.multiplyMatrices(i,Il),wr.matrixWorld=Fl,wr.raycast(e,vo);for(let o=0,s=vo.length;o<s;o++){const a=vo[o];a.instanceId=r,a.object=this,t.push(a)}vo.length=0}},setColorAt:function(e,t){this.instanceColor===null&&(this.instanceColor=new Le(new Float32Array(this.count*3),3)),t.toArray(this.instanceColor.array,e*3)},setMatrixAt:function(e,t){t.toArray(this.instanceMatrix.array,e*16)},updateMorphTargets:function(){},dispose:function(){this.dispatchEvent({type:"dispose"})}});function Rt(e){Me.call(this),this.type="LineBasicMaterial",this.color=new he(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(e)}Rt.prototype=Object.create(Me.prototype),Rt.prototype.constructor=Rt,Rt.prototype.isLineBasicMaterial=!0,Rt.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.morphTargets=e.morphTargets,this};const Dl=new A,Ul=new A,zl=new Re,Rs=new qi,_o=new Zt;function $i(e=new De,t=new Rt){we.call(this),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}$i.prototype=Object.assign(Object.create(we.prototype),{constructor:$i,isLine:!0,copy:function(e){return we.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,i=[0];for(let n=1,r=t.count;n<r;n++)Dl.fromBufferAttribute(t,n-1),Ul.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=Dl.distanceTo(Ul);e.setAttribute("lineDistance",new Fe(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this},raycast:function(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold;if(i.boundingSphere===null&&i.computeBoundingSphere(),_o.copy(i.boundingSphere),_o.applyMatrix4(n),_o.radius+=r,e.ray.intersectsSphere(_o)===!1)return;zl.copy(n).invert(),Rs.copy(e.ray).applyMatrix4(zl);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,a=new A,l=new A,c=new A,h=new A,u=this.isLineSegments?2:1;if(i.isBufferGeometry){const d=i.index,f=i.attributes.position;if(d!==null){const m=d.array;for(let v=0,_=m.length-1;v<_;v+=u){const g=m[v],p=m[v+1];if(a.fromBufferAttribute(f,g),l.fromBufferAttribute(f,p),Rs.distanceSqToSegment(a,l,h,c)>s)continue;h.applyMatrix4(this.matrixWorld);const E=e.ray.origin.distanceTo(h);E<e.near||E>e.far||t.push({distance:E,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else for(let m=0,v=f.count-1;m<v;m+=u){if(a.fromBufferAttribute(f,m),l.fromBufferAttribute(f,m+1),Rs.distanceSqToSegment(a,l,h,c)>s)continue;h.applyMatrix4(this.matrixWorld);const _=e.ray.origin.distanceTo(h);_<e.near||_>e.far||t.push({distance:_,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const s=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const kl=new A,Hl=new A;function Mr(e,t){$i.call(this,e,t),this.type="LineSegments"}Mr.prototype=Object.assign(Object.create($i.prototype),{constructor:Mr,isLineSegments:!0,computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,r=t.count;n<r;n+=2)kl.fromBufferAttribute(t,n),Hl.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+kl.distanceTo(Hl);e.setAttribute("lineDistance",new Fe(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}});function Cs(e,t){$i.call(this,e,t),this.type="LineLoop"}Cs.prototype=Object.assign(Object.create($i.prototype),{constructor:Cs,isLineLoop:!0});function Di(e){Me.call(this),this.type="PointsMaterial",this.color=new he(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}Di.prototype=Object.create(Me.prototype),Di.prototype.constructor=Di,Di.prototype.isPointsMaterial=!0,Di.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this};const Bl=new Re,Ns=new qi,xo=new Zt,yo=new A;function Is(e=new De,t=new Di){we.call(this),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}Is.prototype=Object.assign(Object.create(we.prototype),{constructor:Is,isPoints:!0,copy:function(e){return we.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},raycast:function(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold;if(i.boundingSphere===null&&i.computeBoundingSphere(),xo.copy(i.boundingSphere),xo.applyMatrix4(n),xo.radius+=r,e.ray.intersectsSphere(xo)===!1)return;Bl.copy(n).invert(),Ns.copy(e.ray).applyMatrix4(Bl);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o;if(i.isBufferGeometry){const a=i.index,l=i.attributes.position;if(a!==null){const c=a.array;for(let h=0,u=c.length;h<u;h++){const d=c[h];yo.fromBufferAttribute(l,d),Gl(yo,d,s,n,e,t,this)}}else for(let c=0,h=l.count;c<h;c++)yo.fromBufferAttribute(l,c),Gl(yo,c,s,n,e,t,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const s=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});function Gl(e,t,i,n,r,o,s){const a=Ns.distanceSqToPoint(e);if(a<i){const l=new A;Ns.closestPointToPoint(e,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;o.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,object:s})}}function Vl(e,t,i,n,r,o,s,a,l){He.call(this,e,t,i,n,r,o,s,a,l),this.format=s!==void 0?s:Ti,this.minFilter=o!==void 0?o:qe,this.magFilter=r!==void 0?r:qe,this.generateMipmaps=!1;const c=this;function h(){c.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}Vl.prototype=Object.assign(Object.create(He.prototype),{constructor:Vl,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});function Tr(e,t,i,n,r,o,s,a,l,c,h,u){He.call(this,null,o,s,a,l,c,n,r,h,u),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}Tr.prototype=Object.create(He.prototype),Tr.prototype.constructor=Tr,Tr.prototype.isCompressedTexture=!0;function Ar(e,t,i,n,r,o,s,a,l){He.call(this,e,t,i,n,r,o,s,a,l),this.needsUpdate=!0}Ar.prototype=Object.create(He.prototype),Ar.prototype.constructor=Ar,Ar.prototype.isCanvasTexture=!0;function Sr(e,t,i,n,r,o,s,a,l,c){if(c=c!==void 0?c:Gi,c!==Gi&&c!==rr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&c===Gi&&(i=zr),i===void 0&&c===rr&&(i=nr),He.call(this,null,n,r,o,s,a,c,i,l),this.image={width:e,height:t},this.magFilter=s!==void 0?s:rt,this.minFilter=a!==void 0?a:rt,this.flipY=!1,this.generateMipmaps=!1}Sr.prototype=Object.create(He.prototype),Sr.prototype.constructor=Sr,Sr.prototype.isDepthTexture=!0,new A,new A,new A,new xt;const Em={triangulate:function(e,t,i){i=i||2;const n=t&&t.length,r=n?t[0]*i:e.length;let o=Wl(e,0,r,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c,h,u,d,f;if(n&&(o=Nm(e,t,o,i)),e.length>80*i){a=c=e[0],l=h=e[1];for(let m=i;m<r;m+=i)u=e[m],d=e[m+1],u<a&&(a=u),d<l&&(l=d),u>c&&(c=u),d>h&&(h=d);f=Math.max(c-a,h-l),f=f!==0?1/f:0}return Er(o,s,i,a,l,f),s}};function Wl(e,t,i,n,r){let o,s;if(r===Vm(e,t,i,n)>0)for(o=t;o<i;o+=n)s=Yl(o,e[o],e[o+1],s);else for(o=i-n;o>=t;o-=n)s=Yl(o,e[o],e[o+1],s);return s&&bo(s,s.next)&&(Pr(s),s=s.next),s}function Ui(e,t){if(!e)return e;t||(t=e);let i=e,n;do if(n=!1,!i.steiner&&(bo(i,i.next)||Xe(i.prev,i,i.next)===0)){if(Pr(i),i=t=i.prev,i===i.next)break;n=!0}else i=i.next;while(n||i!==t);return t}function Er(e,t,i,n,r,o,s){if(!e)return;!s&&o&&Um(e,n,r,o);let a=e,l,c;for(;e.prev!==e.next;){if(l=e.prev,c=e.next,o?Pm(e,n,r,o):Lm(e)){t.push(l.i/i),t.push(e.i/i),t.push(c.i/i),Pr(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=Rm(Ui(e),t,i),Er(e,t,i,n,r,o,2)):s===2&&Cm(e,t,i,n,r,o):Er(Ui(e),t,i,n,r,o,1);break}}}function Lm(e){const t=e.prev,i=e,n=e.next;if(Xe(t,i,n)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Fn(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Xe(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Pm(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Xe(r,o,s)>=0)return!1;const a=r.x<o.x?r.x<s.x?r.x:s.x:o.x<s.x?o.x:s.x,l=r.y<o.y?r.y<s.y?r.y:s.y:o.y<s.y?o.y:s.y,c=r.x>o.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,h=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,u=Fs(a,l,t,i,n),d=Fs(c,h,t,i,n);let f=e.prevZ,m=e.nextZ;for(;f&&f.z>=u&&m&&m.z<=d;){if(f!==e.prev&&f!==e.next&&Fn(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Xe(f.prev,f,f.next)>=0||(f=f.prevZ,m!==e.prev&&m!==e.next&&Fn(r.x,r.y,o.x,o.y,s.x,s.y,m.x,m.y)&&Xe(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;f&&f.z>=u;){if(f!==e.prev&&f!==e.next&&Fn(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Xe(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;m&&m.z<=d;){if(m!==e.prev&&m!==e.next&&Fn(r.x,r.y,o.x,o.y,s.x,s.y,m.x,m.y)&&Xe(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Rm(e,t,i){let n=e;do{const r=n.prev,o=n.next.next;!bo(r,o)&&jl(r,n,n.next,o)&&Lr(r,o)&&Lr(o,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(o.i/i),Pr(n),Pr(n.next),n=e=o),n=n.next}while(n!==e);return Ui(n)}function Cm(e,t,i,n,r,o){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Hm(s,a)){let l=Xl(s,a);s=Ui(s,s.next),l=Ui(l,l.next),Er(s,t,i,n,r,o),Er(l,t,i,n,r,o);return}a=a.next}s=s.next}while(s!==e)}function Nm(e,t,i,n){const r=[];let o,s,a,l,c;for(o=0,s=t.length;o<s;o++)a=t[o]*n,l=o<s-1?t[o+1]*n:e.length,c=Wl(e,a,l,n,!1),c===c.next&&(c.steiner=!0),r.push(km(c));for(r.sort(Im),o=0;o<r.length;o++)Fm(r[o],i),i=Ui(i,i.next);return i}function Im(e,t){return e.x-t.x}function Fm(e,t){if(t=Om(e,t),t){const i=Xl(t,e);Ui(t,t.next),Ui(i,i.next)}}function Om(e,t){let i=t;const n=e.x,r=e.y;let o=-1/0,s;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const d=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=n&&d>o){if(o=d,d===n){if(r===i.y)return i;if(r===i.next.y)return i.next}s=i.x<i.next.x?i:i.next}}i=i.next}while(i!==t);if(!s)return null;if(n===o)return s;const a=s,l=s.x,c=s.y;let h=1/0,u;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&Fn(r<c?n:o,r,l,c,r<c?o:n,r,i.x,i.y)&&(u=Math.abs(r-i.y)/(n-i.x),Lr(i,e)&&(u<h||u===h&&(i.x>s.x||i.x===s.x&&Dm(s,i)))&&(s=i,h=u)),i=i.next;while(i!==a);return s}function Dm(e,t){return Xe(e.prev,e,t.prev)<0&&Xe(t.next,e,e.next)<0}function Um(e,t,i,n){let r=e;do r.z===null&&(r.z=Fs(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,zm(r)}function zm(e){let t,i,n,r,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,n=i,a=0,t=0;t<c&&(a++,n=n.nextZ,!!n);t++);for(l=c;a>0||l>0&&n;)a!==0&&(l===0||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1);return e}function Fs(e,t,i,n,r){return e=32767*(e-i)*r,t=32767*(t-n)*r,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function km(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Fn(e,t,i,n,r,o,s,a){return(r-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(n-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(r-s)*(n-a)>=0}function Hm(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Bm(e,t)&&(Lr(e,t)&&Lr(t,e)&&Gm(e,t)&&(Xe(e.prev,e,t.prev)||Xe(e,t.prev,t))||bo(e,t)&&Xe(e.prev,e,e.next)>0&&Xe(t.prev,t,t.next)>0)}function Xe(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function bo(e,t){return e.x===t.x&&e.y===t.y}function jl(e,t,i,n){const r=Mo(Xe(e,t,i)),o=Mo(Xe(e,t,n)),s=Mo(Xe(i,n,e)),a=Mo(Xe(i,n,t));return!!(r!==o&&s!==a||r===0&&wo(e,i,t)||o===0&&wo(e,n,t)||s===0&&wo(i,e,n)||a===0&&wo(i,t,n))}function wo(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Mo(e){return e>0?1:e<0?-1:0}function Bm(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&jl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Lr(e,t){return Xe(e.prev,e,e.next)<0?Xe(e,t,e.next)>=0&&Xe(e,e.prev,t)>=0:Xe(e,t,e.prev)<0||Xe(e,e.next,t)<0}function Gm(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next;while(i!==e);return n}function Xl(e,t){const i=new Os(e.i,e.x,e.y),n=new Os(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Yl(e,t,i,n){const r=new Os(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Pr(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Os(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Vm(e,t,i,n){let r=0;for(let o=t,s=i-n;o<i;o+=n)r+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return r}const zi={area:function(e){const t=e.length;let i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return i*.5},isClockWise:function(e){return zi.area(e)<0},triangulateShape:function(e,t){const i=[],n=[],r=[];ql(e),Ql(i,e);let o=e.length;t.forEach(ql);for(let a=0;a<t.length;a++)n.push(o),o+=t[a].length,Ql(i,t[a]);const s=Em.triangulate(i,n);for(let a=0;a<s.length;a+=3)r.push(s.slice(a,a+3));return r}};function ql(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Ql(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}class Zl extends De{constructor(t,i){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:i},t=Array.isArray(t)?t:[t];const n=this,r=[],o=[];for(let a=0,l=t.length;a<l;a++){const c=t[a];s(c)}this.setAttribute("position",new Fe(r,3)),this.setAttribute("uv",new Fe(o,2)),this.computeVertexNormals();function s(a){const l=[],c=i.curveSegments!==void 0?i.curveSegments:12,h=i.steps!==void 0?i.steps:1;let u=i.depth!==void 0?i.depth:100,d=i.bevelEnabled!==void 0?i.bevelEnabled:!0,f=i.bevelThickness!==void 0?i.bevelThickness:6,m=i.bevelSize!==void 0?i.bevelSize:f-2,v=i.bevelOffset!==void 0?i.bevelOffset:0,_=i.bevelSegments!==void 0?i.bevelSegments:3;const g=i.extrudePath,p=i.UVGenerator!==void 0?i.UVGenerator:Wm;i.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),u=i.amount);let E,S=!1,T,x,L,W;g&&(E=g.getSpacedPoints(h),S=!0,d=!1,T=g.computeFrenetFrames(h,!1),x=new A,L=new A,W=new A),d||(_=0,f=0,m=0,v=0);const U=a.extractPoints(c);let B=U.shape;const H=U.holes;if(!zi.isClockWise(B)){B=B.reverse();for(let R=0,N=H.length;R<N;R++){const I=H[R];zi.isClockWise(I)&&(H[R]=I.reverse())}}const j=zi.triangulateShape(B,H),G=B;for(let R=0,N=H.length;R<N;R++){const I=H[R];B=B.concat(I)}function D(R,N,I){return N||console.error("THREE.ExtrudeGeometry: vec does not exist"),N.clone().multiplyScalar(I).add(R)}const k=B.length,Y=j.length;function Z(R,N,I){let V,X,Q;const b=R.x-N.x,y=R.y-N.y,J=I.x-R.x,q=I.y-R.y,z=b*b+y*y,te=b*q-y*J;if(Math.abs(te)>Number.EPSILON){const re=Math.sqrt(z),ue=Math.sqrt(J*J+q*q),se=N.x-y/re,ge=N.y+b/re,ve=I.x-q/ue,be=I.y+J/ue,pe=((ve-se)*q-(be-ge)*J)/(b*q-y*J);V=se+b*pe-R.x,X=ge+y*pe-R.y;const _e=V*V+X*X;if(_e<=2)return new le(V,X);Q=Math.sqrt(_e/2)}else{let re=!1;b>Number.EPSILON?J>Number.EPSILON&&(re=!0):b<-Number.EPSILON?J<-Number.EPSILON&&(re=!0):Math.sign(y)===Math.sign(q)&&(re=!0),re?(V=-y,X=b,Q=Math.sqrt(z)):(V=b,X=y,Q=Math.sqrt(z/2))}return new le(V/Q,X/Q)}const $=[];for(let R=0,N=G.length,I=N-1,V=R+1;R<N;R++,I++,V++)I===N&&(I=0),V===N&&(V=0),$[R]=Z(G[R],G[I],G[V]);const ne=[];let ae,de=$.concat();for(let R=0,N=H.length;R<N;R++){const I=H[R];ae=[];for(let V=0,X=I.length,Q=X-1,b=V+1;V<X;V++,Q++,b++)Q===X&&(Q=0),b===X&&(b=0),ae[V]=Z(I[V],I[Q],I[b]);ne.push(ae),de=de.concat(ae)}for(let R=0;R<_;R++){const N=R/_,I=f*Math.cos(N*Math.PI/2),V=m*Math.sin(N*Math.PI/2)+v;for(let X=0,Q=G.length;X<Q;X++){const b=D(G[X],$[X],V);M(b.x,b.y,-I)}for(let X=0,Q=H.length;X<Q;X++){const b=H[X];ae=ne[X];for(let y=0,J=b.length;y<J;y++){const q=D(b[y],ae[y],V);M(q.x,q.y,-I)}}}const ce=m+v;for(let R=0;R<k;R++){const N=d?D(B[R],de[R],ce):B[R];S?(L.copy(T.normals[0]).multiplyScalar(N.x),x.copy(T.binormals[0]).multiplyScalar(N.y),W.copy(E[0]).add(L).add(x),M(W.x,W.y,W.z)):M(N.x,N.y,0)}for(let R=1;R<=h;R++)for(let N=0;N<k;N++){const I=d?D(B[N],de[N],ce):B[N];S?(L.copy(T.normals[R]).multiplyScalar(I.x),x.copy(T.binormals[R]).multiplyScalar(I.y),W.copy(E[R]).add(L).add(x),M(W.x,W.y,W.z)):M(I.x,I.y,u/h*R)}for(let R=_-1;R>=0;R--){const N=R/_,I=f*Math.cos(N*Math.PI/2),V=m*Math.sin(N*Math.PI/2)+v;for(let X=0,Q=G.length;X<Q;X++){const b=D(G[X],$[X],V);M(b.x,b.y,u+I)}for(let X=0,Q=H.length;X<Q;X++){const b=H[X];ae=ne[X];for(let y=0,J=b.length;y<J;y++){const q=D(b[y],ae[y],V);S?M(q.x,q.y+E[h-1].y,E[h-1].x+I):M(q.x,q.y,u+I)}}}ye(),Ne();function ye(){const R=r.length/3;if(d){let N=0,I=k*N;for(let V=0;V<Y;V++){const X=j[V];w(X[2]+I,X[1]+I,X[0]+I)}N=h+_*2,I=k*N;for(let V=0;V<Y;V++){const X=j[V];w(X[0]+I,X[1]+I,X[2]+I)}}else{for(let N=0;N<Y;N++){const I=j[N];w(I[2],I[1],I[0])}for(let N=0;N<Y;N++){const I=j[N];w(I[0]+k*h,I[1]+k*h,I[2]+k*h)}}n.addGroup(R,r.length/3-R,0)}function Ne(){const R=r.length/3;let N=0;ie(G,N),N+=G.length;for(let I=0,V=H.length;I<V;I++){const X=H[I];ie(X,N),N+=X.length}n.addGroup(R,r.length/3-R,1)}function ie(R,N){let I=R.length;for(;--I>=0;){const V=I;let X=I-1;X<0&&(X=R.length-1);for(let Q=0,b=h+_*2;Q<b;Q++){const y=k*Q,J=k*(Q+1),q=N+V+y,z=N+X+y,te=N+X+J,re=N+V+J;O(q,z,te,re)}}}function M(R,N,I){l.push(R),l.push(N),l.push(I)}function w(R,N,I){P(R),P(N),P(I);const V=r.length/3,X=p.generateTopUV(n,r,V-3,V-2,V-1);F(X[0]),F(X[1]),F(X[2])}function O(R,N,I,V){P(R),P(N),P(V),P(N),P(I),P(V);const X=r.length/3,Q=p.generateSideWallUV(n,r,X-6,X-3,X-2,X-1);F(Q[0]),F(Q[1]),F(Q[3]),F(Q[1]),F(Q[2]),F(Q[3])}function P(R){r.push(l[R*3+0]),r.push(l[R*3+1]),r.push(l[R*3+2])}function F(R){o.push(R.x),o.push(R.y)}}}toJSON(){const t=De.prototype.toJSON.call(this),i=this.parameters.shapes,n=this.parameters.options;return jm(i,n,t)}}const Wm={generateTopUV:function(e,t,i,n,r){const o=t[i*3],s=t[i*3+1],a=t[n*3],l=t[n*3+1],c=t[r*3],h=t[r*3+1];return[new le(o,s),new le(a,l),new le(c,h)]},generateSideWallUV:function(e,t,i,n,r,o){const s=t[i*3],a=t[i*3+1],l=t[i*3+2],c=t[n*3],h=t[n*3+1],u=t[n*3+2],d=t[r*3],f=t[r*3+1],m=t[r*3+2],v=t[o*3],_=t[o*3+1],g=t[o*3+2];return Math.abs(a-h)<.01?[new le(s,1-l),new le(c,1-u),new le(d,1-m),new le(v,1-g)]:[new le(a,1-l),new le(h,1-u),new le(f,1-m),new le(_,1-g)]}};function jm(e,t,i){if(i.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){const o=e[n];i.shapes.push(o.uuid)}else i.shapes.push(e.uuid);return t.extrudePath!==void 0&&(i.options.extrudePath=t.extrudePath.toJSON()),i}function Ds(e,t,i){De.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i};const n=[],r=[],o=[],s=[],a=1e-5,l=new A,c=new A,h=new A,u=new A,d=new A;e.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const f=t+1;for(let m=0;m<=i;m++){const v=m/i;for(let _=0;_<=t;_++){const g=_/t;e(g,v,c),r.push(c.x,c.y,c.z),g-a>=0?(e(g-a,v,h),u.subVectors(c,h)):(e(g+a,v,h),u.subVectors(h,c)),v-a>=0?(e(g,v-a,h),d.subVectors(c,h)):(e(g,v+a,h),d.subVectors(h,c)),l.crossVectors(u,d).normalize(),o.push(l.x,l.y,l.z),s.push(g,v)}}for(let m=0;m<i;m++)for(let v=0;v<t;v++){const _=m*f+v,g=m*f+v+1,p=(m+1)*f+v+1,E=(m+1)*f+v;n.push(_,g,E),n.push(g,p,E)}this.setIndex(n),this.setAttribute("position",new Fe(r,3)),this.setAttribute("normal",new Fe(o,3)),this.setAttribute("uv",new Fe(s,2))}Ds.prototype=Object.create(De.prototype),Ds.prototype.constructor=Ds;class Xm extends De{constructor(t,i=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:i};const n=[],r=[],o=[],s=[];let a=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(n),this.setAttribute("position",new Fe(r,3)),this.setAttribute("normal",new Fe(o,3)),this.setAttribute("uv",new Fe(s,2));function c(h){const u=r.length/3,d=h.extractPoints(i);let f=d.shape;const m=d.holes;zi.isClockWise(f)===!1&&(f=f.reverse());for(let _=0,g=m.length;_<g;_++){const p=m[_];zi.isClockWise(p)===!0&&(m[_]=p.reverse())}const v=zi.triangulateShape(f,m);for(let _=0,g=m.length;_<g;_++){const p=m[_];f=f.concat(p)}for(let _=0,g=f.length;_<g;_++){const p=f[_];r.push(p.x,p.y,0),o.push(0,0,1),s.push(p.x,p.y)}for(let _=0,g=v.length;_<g;_++){const p=v[_],E=p[0]+u,S=p[1]+u,T=p[2]+u;n.push(E,S,T),l+=3}}}toJSON(){const t=De.prototype.toJSON.call(this),i=this.parameters.shapes;return Ym(i,t)}}function Ym(e,t){if(t.shapes=[],Array.isArray(e))for(let i=0,n=e.length;i<n;i++){const r=e[i];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}class qm extends De{constructor(t=1,i=8,n=6,r=0,o=Math.PI*2,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:i,heightSegments:n,phiStart:r,phiLength:o,thetaStart:s,thetaLength:a},i=Math.max(3,Math.floor(i)),n=Math.max(2,Math.floor(n));const l=Math.min(s+a,Math.PI);let c=0;const h=[],u=new A,d=new A,f=[],m=[],v=[],_=[];for(let g=0;g<=n;g++){const p=[],E=g/n;let S=0;g==0&&s==0?S=.5/i:g==n&&l==Math.PI&&(S=-.5/i);for(let T=0;T<=i;T++){const x=T/i;u.x=-t*Math.cos(r+x*o)*Math.sin(s+E*a),u.y=t*Math.cos(s+E*a),u.z=t*Math.sin(r+x*o)*Math.sin(s+E*a),m.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),_.push(x+S,1-E),p.push(c++)}h.push(p)}for(let g=0;g<n;g++)for(let p=0;p<i;p++){const E=h[g][p+1],S=h[g][p],T=h[g+1][p],x=h[g+1][p+1];(g!==0||s>0)&&f.push(E,S,x),(g!==n-1||l<Math.PI)&&f.push(S,T,x)}this.setIndex(f),this.setAttribute("position",new Fe(m,3)),this.setAttribute("normal",new Fe(v,3)),this.setAttribute("uv",new Fe(_,2))}}function On(e){Me.call(this),this.type="ShadowMaterial",this.color=new he(0),this.transparent=!0,this.setValues(e)}On.prototype=Object.create(Me.prototype),On.prototype.constructor=On,On.prototype.isShadowMaterial=!0,On.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.color.copy(e.color),this};function Rr(e){Qe.call(this,e),this.type="RawShaderMaterial"}Rr.prototype=Object.create(Qe.prototype),Rr.prototype.constructor=Rr,Rr.prototype.isRawShaderMaterial=!0;function Mt(e){Me.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new he(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 he(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(e)}Mt.prototype=Object.create(Me.prototype),Mt.prototype.constructor=Mt,Mt.prototype.isMeshStandardMaterial=!0,Mt.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.vertexTangents=e.vertexTangents,this};function vi(e){Mt.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new le(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(t){this.reflectivity=Se.clamp(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(e)}vi.prototype=Object.create(Mt.prototype),vi.prototype.constructor=vi,vi.prototype.isMeshPhysicalMaterial=!0,vi.prototype.copy=function(e){return Mt.prototype.copy.call(this,e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.reflectivity=e.reflectivity,e.sheen?this.sheen=(this.sheen||new he).copy(e.sheen):this.sheen=null,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this};function en(e){Me.call(this),this.type="MeshPhongMaterial",this.color=new he(16777215),this.specular=new he(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new he(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Or,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}en.prototype=Object.create(Me.prototype),en.prototype.constructor=en,en.prototype.isMeshPhongMaterial=!0,en.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Dn(e){Me.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new he(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new he(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new le(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.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Dn.prototype=Object.create(Me.prototype),Dn.prototype.constructor=Dn,Dn.prototype.isMeshToonMaterial=!0,Dn.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Un(e){Me.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}Un.prototype=Object.create(Me.prototype),Un.prototype.constructor=Un,Un.prototype.isMeshNormalMaterial=!0,Un.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function zn(e){Me.call(this),this.type="MeshLambertMaterial",this.color=new he(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new he(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Or,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}zn.prototype=Object.create(Me.prototype),zn.prototype.constructor=zn,zn.prototype.isMeshLambertMaterial=!0,zn.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function kn(e){Me.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new he(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wi,this.normalScale=new le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}kn.prototype=Object.create(Me.prototype),kn.prototype.constructor=kn,kn.prototype.isMeshMatcapMaterial=!0,kn.prototype.copy=function(e){return Me.prototype.copy.call(this,e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this};function Hn(e){Rt.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}Hn.prototype=Object.create(Rt.prototype),Hn.prototype.constructor=Hn,Hn.prototype.isLineDashedMaterial=!0,Hn.prototype.copy=function(e){return Rt.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this};var Qm=Object.freeze({__proto__:null,ShadowMaterial:On,SpriteMaterial:Ki,RawShaderMaterial:Rr,ShaderMaterial:Qe,PointsMaterial:Di,MeshPhysicalMaterial:vi,MeshStandardMaterial:Mt,MeshPhongMaterial:en,MeshToonMaterial:Dn,MeshNormalMaterial:Un,MeshLambertMaterial:zn,MeshDepthMaterial:Qi,MeshDistanceMaterial:Zi,MeshBasicMaterial:vt,MeshMatcapMaterial:kn,LineDashedMaterial:Hn,LineBasicMaterial:Rt,Material:Me});const je={arraySlice:function(e,t,i){return je.isTypedArray(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){function t(r,o){return e[r]-e[o]}const i=e.length,n=new Array(i);for(let r=0;r!==i;++r)n[r]=r;return n.sort(t),n},sortedArray:function(e,t,i){const n=e.length,r=new e.constructor(n);for(let o=0,s=0;s!==n;++o){const a=i[o]*t;for(let l=0;l!==t;++l)r[s++]=e[a+l]}return r},flattenJSON:function(e,t,i,n){let r=1,o=e[0];for(;o!==void 0&&o[n]===void 0;)o=e[r++];if(o===void 0)return;let s=o[n];if(s!==void 0)if(Array.isArray(s))do s=o[n],s!==void 0&&(t.push(o.time),i.push.apply(i,s)),o=e[r++];while(o!==void 0);else if(s.toArray!==void 0)do s=o[n],s!==void 0&&(t.push(o.time),s.toArray(i,i.length)),o=e[r++];while(o!==void 0);else do s=o[n],s!==void 0&&(t.push(o.time),i.push(s)),o=e[r++];while(o!==void 0)},subclip:function(e,t,i,n,r=30){const o=e.clone();o.name=t;const s=[];for(let l=0;l<o.tracks.length;++l){const c=o.tracks[l],h=c.getValueSize(),u=[],d=[];for(let f=0;f<c.times.length;++f){const m=c.times[f]*r;if(!(m<i||m>=n)){u.push(c.times[f]);for(let v=0;v<h;++v)d.push(c.values[f*h+v])}}u.length!==0&&(c.times=je.convertArray(u,c.times.constructor),c.values=je.convertArray(d,c.values.constructor),s.push(c))}o.tracks=s;let a=1/0;for(let l=0;l<o.tracks.length;++l)a>o.tracks[l].times[0]&&(a=o.tracks[l].times[0]);for(let l=0;l<o.tracks.length;++l)o.tracks[l].shift(-1*a);return o.resetDuration(),o},makeClipAdditive:function(e,t=0,i=e,n=30){n<=0&&(n=30);const r=i.tracks.length,o=t/n;for(let s=0;s<r;++s){const a=i.tracks[s],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=e.tracks.find(function(g){return g.name===a.name&&g.ValueTypeName===l});if(c===void 0)continue;let h=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0;const f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);const m=a.times.length-1;let v;if(o<=a.times[0]){const g=h,p=u-h;v=je.arraySlice(a.values,g,p)}else if(o>=a.times[m]){const g=m*u+h,p=g+u-h;v=je.arraySlice(a.values,g,p)}else{const g=a.createInterpolant(),p=h,E=u-h;g.evaluate(o),v=je.arraySlice(g.resultBuffer,p,E)}l==="quaternion"&&new tt().fromArray(v).normalize().conjugate().toArray(v);const _=c.times.length;for(let g=0;g<_;++g){const p=g*f+d;if(l==="quaternion")tt.multiplyQuaternionsFlat(c.values,p,v,0,c.values,p);else{const E=f-d*2;for(let S=0;S<E;++S)c.values[p+S]-=v[S]}}}return e.blendMode=Oa,e}};function Tt(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i}Object.assign(Tt.prototype,{evaluate:function(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let o;i:{n:if(!(e<n)){for(let s=i+2;;){if(n===void 0){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,r)}if(i===s)break;if(r=n,n=t[++i],e<n)break t}o=t.length;break i}if(!(e>=r)){const s=t[1];e<s&&(i=2,r=s);for(let a=i-2;;){if(r===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(i===a)break;if(n=r,r=t[--i-1],e>=r)break t}o=i,i=0;break i}break e}for(;i<o;){const s=i+o>>>1;e<t[s]?o=s:i=s+1}if(n=t[i],r=t[i-1],r===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(n===void 0)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,r,e)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let o=0;o!==n;++o)t[o]=i[r+o];return t},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Tt.prototype,{beforeStart_:Tt.prototype.copySampleValue_,afterEnd_:Tt.prototype.copySampleValue_});function Us(e,t,i,n){Tt.call(this,e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}Us.prototype=Object.assign(Object.create(Tt.prototype),{constructor:Us,DefaultSettings_:{endingStart:cn,endingEnd:cn},intervalChanged_:function(e,t,i){const n=this.parameterPositions;let r=e-2,o=e+1,s=n[r],a=n[o];if(s===void 0)switch(this.getSettings_().endingStart){case hn:r=e,s=2*t-i;break;case Hr:r=n.length-2,s=t+n[r]-n[r+1];break;default:r=e,s=i}if(a===void 0)switch(this.getSettings_().endingEnd){case hn:o=e,a=2*i-t;break;case Hr:o=1,a=i+n[1]-n[0];break;default:o=e-1,a=t}const l=(i-t)*.5,c=this.valueSize;this._weightPrev=l/(t-s),this._weightNext=l/(a-i),this._offsetPrev=r*c,this._offsetNext=o*c},interpolate_:function(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,l=a-s,c=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,d=this._weightNext,f=(i-t)/(n-t),m=f*f,v=m*f,_=-u*v+2*u*m-u*f,g=(1+u)*v+(-1.5-2*u)*m+(-.5+u)*f+1,p=(-1-d)*v+(1.5+d)*m+.5*f,E=d*v-d*m;for(let S=0;S!==s;++S)r[S]=_*o[c+S]+g*o[l+S]+p*o[a+S]+E*o[h+S];return r}});function To(e,t,i,n){Tt.call(this,e,t,i,n)}To.prototype=Object.assign(Object.create(Tt.prototype),{constructor:To,interpolate_:function(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=e*s,l=a-s,c=(i-t)/(n-t),h=1-c;for(let u=0;u!==s;++u)r[u]=o[l+u]*h+o[a+u]*c;return r}});function zs(e,t,i,n){Tt.call(this,e,t,i,n)}zs.prototype=Object.assign(Object.create(Tt.prototype),{constructor:zs,interpolate_:function(e){return this.copySampleValue_(e-1)}});function mt(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=je.convertArray(t,this.TimeBufferType),this.values=je.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}Object.assign(mt,{toJSON:function(e){const t=e.constructor;let i;if(t.toJSON!==void 0)i=t.toJSON(e);else{i={name:e.name,times:je.convertArray(e.times,Array),values:je.convertArray(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}}),Object.assign(mt.prototype,{constructor:mt,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:ln,InterpolantFactoryMethodDiscrete:function(e){return new zs(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new To(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new Us(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){let t;switch(e){case or:t=this.InterpolantFactoryMethodDiscrete;break;case ln:t=this.InterpolantFactoryMethodLinear;break;case qo:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return or;case this.InterpolantFactoryMethodLinear:return ln;case this.InterpolantFactoryMethodSmooth:return qo}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this},scale:function(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this},trim:function(e,t){const i=this.times,n=i.length;let r=0,o=n-1;for(;r!==n&&i[r]<e;)++r;for(;o!==-1&&i[o]>t;)--o;if(++o,r!==0||o!==n){r>=o&&(o=Math.max(o,1),r=o-1);const s=this.getValueSize();this.times=je.arraySlice(i,r,o),this.values=je.arraySlice(this.values,r*s,o*s)}return this},validate:function(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let s=0;s!==r;s++){const a=i[s];if(typeof a=="number"&&isNaN(a)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,s,a),e=!1;break}if(o!==null&&o>a){console.error("THREE.KeyframeTrack: Out of order keys.",this,s,a,o),e=!1;break}o=a}if(n!==void 0&&je.isTypedArray(n))for(let s=0,a=n.length;s!==a;++s){const l=n[s];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,s,l),e=!1;break}}return e},optimize:function(){const e=je.arraySlice(this.times),t=je.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===qo,r=e.length-1;let o=1;for(let s=1;s<r;++s){let a=!1;const l=e[s],c=e[s+1];if(l!==c&&(s!==1||l!==e[0]))if(n)a=!0;else{const h=s*i,u=h-i,d=h+i;for(let f=0;f!==i;++f){const m=t[h+f];if(m!==t[u+f]||m!==t[d+f]){a=!0;break}}}if(a){if(s!==o){e[o]=e[s];const h=s*i,u=o*i;for(let d=0;d!==i;++d)t[u+d]=t[h+d]}++o}}if(r>0){e[o]=e[r];for(let s=r*i,a=o*i,l=0;l!==i;++l)t[a+l]=t[s+l];++o}return o!==e.length?(this.times=je.arraySlice(e,0,o),this.values=je.arraySlice(t,0,o*i)):(this.times=e,this.values=t),this},clone:function(){const e=je.arraySlice(this.times,0),t=je.arraySlice(this.values,0),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}});function ks(e,t,i){mt.call(this,e,t,i)}ks.prototype=Object.assign(Object.create(mt.prototype),{constructor:ks,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:or,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Hs(e,t,i,n){mt.call(this,e,t,i,n)}Hs.prototype=Object.assign(Object.create(mt.prototype),{constructor:Hs,ValueTypeName:"color"});function Bn(e,t,i,n){mt.call(this,e,t,i,n)}Bn.prototype=Object.assign(Object.create(mt.prototype),{constructor:Bn,ValueTypeName:"number"});function Bs(e,t,i,n){Tt.call(this,e,t,i,n)}Bs.prototype=Object.assign(Object.create(Tt.prototype),{constructor:Bs,interpolate_:function(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(i-t)/(n-t);let l=e*s;for(let c=l+s;l!==c;l+=4)tt.slerpFlat(r,0,o,l-s,o,l,a);return r}});function tn(e,t,i,n){mt.call(this,e,t,i,n)}tn.prototype=Object.assign(Object.create(mt.prototype),{constructor:tn,ValueTypeName:"quaternion",DefaultInterpolation:ln,InterpolantFactoryMethodLinear:function(e){return new Bs(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0});function Gs(e,t,i,n){mt.call(this,e,t,i,n)}Gs.prototype=Object.assign(Object.create(mt.prototype),{constructor:Gs,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:or,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});function Gn(e,t,i,n){mt.call(this,e,t,i,n)}Gn.prototype=Object.assign(Object.create(mt.prototype),{constructor:Gn,ValueTypeName:"vector"});function At(e,t=-1,i,n=Qo){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Se.generateUUID(),this.duration<0&&this.resetDuration()}function Zm(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Bn;case"vector":case"vector2":case"vector3":case"vector4":return Gn;case"color":return Hs;case"quaternion":return tn;case"bool":case"boolean":return ks;case"string":return Gs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Jm(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=Zm(e.type);if(e.times===void 0){const i=[],n=[];je.flattenJSON(e.keys,i,n,"value"),e.times=i,e.values=n}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}Object.assign(At,{parse:function(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let o=0,s=i.length;o!==s;++o)t.push(Jm(i[o]).scale(n));const r=new At(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r},toJSON:function(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=i.length;r!==o;++r)t.push(mt.toJSON(i[r]));return n},CreateFromMorphTargetSequence:function(e,t,i,n){const r=t.length,o=[];for(let s=0;s<r;s++){let a=[],l=[];a.push((s+r-1)%r,s,(s+1)%r),l.push(0,1,0);const c=je.getKeyframeOrder(a);a=je.sortedArray(a,1,c),l=je.sortedArray(l,1,c),!n&&a[0]===0&&(a.push(r),l.push(l[0])),o.push(new Bn(".morphTargetInfluences["+t[s].name+"]",a,l).scale(1/i))}return new At(e,-1,o)},findByName:function(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null},CreateClipsFromMorphTargetSequences:function(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let s=0,a=e.length;s<a;s++){const l=e[s],c=l.name.match(r);if(c&&c.length>1){const h=c[1];let u=n[h];u||(n[h]=u=[]),u.push(l)}}const o=[];for(const s in n)o.push(At.CreateFromMorphTargetSequence(s,n[s],t,i));return o},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(c,h,u,d,f){if(u.length!==0){const m=[],v=[];je.flattenJSON(u,m,v,d),m.length!==0&&f.push(new c(h,m,v))}},n=[],r=e.name||"default",o=e.fps||30,s=e.blendMode;let a=e.length||-1;const l=e.hierarchy||[];for(let c=0;c<l.length;c++){const h=l[c].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const u={};let d;for(d=0;d<h.length;d++)if(h[d].morphTargets)for(let f=0;f<h[d].morphTargets.length;f++)u[h[d].morphTargets[f]]=-1;for(const f in u){const m=[],v=[];for(let _=0;_!==h[d].morphTargets.length;++_){const g=h[d];m.push(g.time),v.push(g.morphTarget===f?1:0)}n.push(new Bn(".morphTargetInfluence["+f+"]",m,v))}a=u.length*(o||1)}else{const u=".bones["+t[c].name+"]";i(Gn,u+".position",h,"pos",n),i(tn,u+".quaternion",h,"rot",n),i(Gn,u+".scale",h,"scl",n)}}return n.length===0?null:new At(r,a,n,s)}}),Object.assign(At.prototype,{resetDuration:function(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this},trim:function(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this},validate:function(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e},optimize:function(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this},clone:function(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new At(this.name,this.duration,e,this.blendMode)},toJSON:function(){return At.toJSON(this)}});const Vn={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function Jl(e,t,i){const n=this;let r=!1,o=0,s=0,a;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(c){s++,r===!1&&n.onStart!==void 0&&n.onStart(c,o,s),r=!0},this.itemEnd=function(c){o++,n.onProgress!==void 0&&n.onProgress(c,o,s),o===s&&(r=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(c){n.onError!==void 0&&n.onError(c)},this.resolveURL=function(c){return a?a(c):c},this.setURLModifier=function(c){return a=c,this},this.addHandler=function(c,h){return l.push(c,h),this},this.removeHandler=function(c){const h=l.indexOf(c);return h!==-1&&l.splice(h,2),this},this.getHandler=function(c){for(let h=0,u=l.length;h<u;h+=2){const d=l[h],f=l[h+1];if(d.global&&(d.lastIndex=0),d.test(c))return f}return null}}const Km=new Jl;function Ue(e){this.manager=e!==void 0?e:Km,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(Ue.prototype,{load:function(){},loadAsync:function(e,t){const i=this;return new Promise(function(n,r){i.load(e,n,t,r)})},parse:function(){},setCrossOrigin:function(e){return this.crossOrigin=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}});const Xt={};function Yt(e){Ue.call(this,e)}Yt.prototype=Object.assign(Object.create(Ue.prototype),{constructor:Yt,load:function(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Vn.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;if(Xt[e]!==void 0){Xt[e].push({onLoad:t,onProgress:i,onError:n});return}const s=/^data:(.*?)(;base64)?,(.*)$/,a=e.match(s);let l;if(a){const c=a[1],h=!!a[2];let u=a[3];u=decodeURIComponent(u),h&&(u=atob(u));try{let d;const f=(this.responseType||"").toLowerCase();switch(f){case"arraybuffer":case"blob":const m=new Uint8Array(u.length);for(let v=0;v<u.length;v++)m[v]=u.charCodeAt(v);f==="blob"?d=new Blob([m.buffer],{type:c}):d=m.buffer;break;case"document":d=new DOMParser().parseFromString(u,c);break;case"json":d=JSON.parse(u);break;default:d=u;break}setTimeout(function(){t&&t(d),r.manager.itemEnd(e)},0)}catch(d){setTimeout(function(){n&&n(d),r.manager.itemError(e),r.manager.itemEnd(e)},0)}}else{Xt[e]=[],Xt[e].push({onLoad:t,onProgress:i,onError:n}),l=new XMLHttpRequest,l.open("GET",e,!0),l.addEventListener("load",function(c){const h=this.response,u=Xt[e];if(delete Xt[e],this.status===200||this.status===0){this.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),Vn.add(e,h);for(let d=0,f=u.length;d<f;d++){const m=u[d];m.onLoad&&m.onLoad(h)}r.manager.itemEnd(e)}else{for(let d=0,f=u.length;d<f;d++){const m=u[d];m.onError&&m.onError(c)}r.manager.itemError(e),r.manager.itemEnd(e)}},!1),l.addEventListener("progress",function(c){const h=Xt[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onProgress&&f.onProgress(c)}},!1),l.addEventListener("error",function(c){const h=Xt[e];delete Xt[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(c)}r.manager.itemError(e),r.manager.itemEnd(e)},!1),l.addEventListener("abort",function(c){const h=Xt[e];delete Xt[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(c)}r.manager.itemError(e),r.manager.itemEnd(e)},!1),this.responseType!==void 0&&(l.responseType=this.responseType),this.withCredentials!==void 0&&(l.withCredentials=this.withCredentials),l.overrideMimeType&&l.overrideMimeType(this.mimeType!==void 0?this.mimeType:"text/plain");for(const c in this.requestHeader)l.setRequestHeader(c,this.requestHeader[c]);l.send(null)}return r.manager.itemStart(e),l},setResponseType:function(e){return this.responseType=e,this},setMimeType:function(e){return this.mimeType=e,this}});function Kl(e){Ue.call(this,e)}Kl.prototype=Object.assign(Object.create(Ue.prototype),{constructor:Kl,load:function(e,t,i,n){const r=this,o=new Yt(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(s){try{t(r.parse(JSON.parse(s)))}catch(a){n?n(a):console.error(a),r.manager.itemError(e)}},i,n)},parse:function(e){const t=[];for(let i=0;i<e.length;i++){const n=At.parse(e[i]);t.push(n)}return t}});function $l(e){Ue.call(this,e)}$l.prototype=Object.assign(Object.create(Ue.prototype),{constructor:$l,load:function(e,t,i,n){const r=this,o=[],s=new Tr,a=new Yt(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let l=0;function c(h){a.load(e[h],function(u){const d=r.parse(u,!0);o[h]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},l+=1,l===6&&(d.mipmapCount===1&&(s.minFilter=qe),s.image=o,s.format=d.format,s.needsUpdate=!0,t&&t(s))},i,n)}if(Array.isArray(e))for(let h=0,u=e.length;h<u;++h)c(h);else a.load(e,function(h){const u=r.parse(h,!0);if(u.isCubemap){const d=u.mipmaps.length/u.mipmapCount;for(let f=0;f<d;f++){o[f]={mipmaps:[]};for(let m=0;m<u.mipmapCount;m++)o[f].mipmaps.push(u.mipmaps[f*u.mipmapCount+m]),o[f].format=u.format,o[f].width=u.width,o[f].height=u.height}s.image=o}else s.image.width=u.width,s.image.height=u.height,s.mipmaps=u.mipmaps;u.mipmapCount===1&&(s.minFilter=qe),s.format=u.format,s.needsUpdate=!0,t&&t(s)},i,n);return s}});function Ao(e){Ue.call(this,e)}Ao.prototype=Object.assign(Object.create(Ue.prototype),{constructor:Ao,load:function(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Vn.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const s=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){s.removeEventListener("load",a,!1),s.removeEventListener("error",l,!1),Vn.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(c){s.removeEventListener("load",a,!1),s.removeEventListener("error",l,!1),n&&n(c),r.manager.itemError(e),r.manager.itemEnd(e)}return s.addEventListener("load",a,!1),s.addEventListener("error",l,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(e),s.src=e,s}});function So(e){Ue.call(this,e)}So.prototype=Object.assign(Object.create(Ue.prototype),{constructor:So,load:function(e,t,i,n){const r=new Ii,o=new Ao(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let s=0;function a(l){o.load(e[l],function(c){r.images[l]=c,s++,s===6&&(r.needsUpdate=!0,t&&t(r))},void 0,n)}for(let l=0;l<e.length;++l)a(l);return r}});function ec(e){Ue.call(this,e)}ec.prototype=Object.assign(Object.create(Ue.prototype),{constructor:ec,load:function(e,t,i,n){const r=this,o=new Sn,s=new Yt(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,function(a){const l=r.parse(a);l&&(l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:ut,o.wrapT=l.wrapT!==void 0?l.wrapT:ut,o.magFilter=l.magFilter!==void 0?l.magFilter:qe,o.minFilter=l.minFilter!==void 0?l.minFilter:qe,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.encoding!==void 0&&(o.encoding=l.encoding),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=an),l.mipmapCount===1&&(o.minFilter=qe),o.needsUpdate=!0,t&&t(o,l))},i,n),o}});function Wn(e){Ue.call(this,e)}Wn.prototype=Object.assign(Object.create(Ue.prototype),{constructor:Wn,load:function(e,t,i,n){const r=new He,o=new Ao(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(s){r.image=s;const a=e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0;r.format=a?Ti:wt,r.needsUpdate=!0,t!==void 0&&t(r)},i,n),r}});function xe(){this.type="Curve",this.arcLengthDivisions=200}Object.assign(xe.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)},getPoints:function(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t},getSpacedPoints:function(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t},getLength:function(){const e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(e===void 0&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),r+=i.distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){const i=this.getLengths();let n=0;const r=i.length;let o;t?o=t:o=e*i[r-1];let s=0,a=r-1,l;for(;s<=a;)if(n=Math.floor(s+(a-s)/2),l=i[n]-o,l<0)s=n+1;else if(l>0)a=n-1;else{a=n;break}if(n=a,i[n]===o)return n/(r-1);const c=i[n],h=i[n+1]-c,u=(o-c)/h;return(n+u)/(r-1)},getTangent:function(e,t){let i=e-1e-4,n=e+1e-4;i<0&&(i=0),n>1&&(n=1);const r=this.getPoint(i),o=this.getPoint(n),s=t||(r.isVector2?new le:new A);return s.copy(o).sub(r).normalize(),s},getTangentAt:function(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)},computeFrenetFrames:function(e,t){const i=new A,n=[],r=[],o=[],s=new A,a=new Re;for(let d=0;d<=e;d++){const f=d/e;n[d]=this.getTangentAt(f,new A),n[d].normalize()}r[0]=new A,o[0]=new A;let l=Number.MAX_VALUE;const c=Math.abs(n[0].x),h=Math.abs(n[0].y),u=Math.abs(n[0].z);c<=l&&(l=c,i.set(1,0,0)),h<=l&&(l=h,i.set(0,1,0)),u<=l&&i.set(0,0,1),s.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],s),o[0].crossVectors(n[0],r[0]);for(let d=1;d<=e;d++){if(r[d]=r[d-1].clone(),o[d]=o[d-1].clone(),s.crossVectors(n[d-1],n[d]),s.length()>Number.EPSILON){s.normalize();const f=Math.acos(Se.clamp(n[d-1].dot(n[d]),-1,1));r[d].applyMatrix4(a.makeRotationAxis(s,f))}o[d].crossVectors(n[d],r[d])}if(t===!0){let d=Math.acos(Se.clamp(r[0].dot(r[e]),-1,1));d/=e,n[0].dot(s.crossVectors(r[0],r[e]))>0&&(d=-d);for(let f=1;f<=e;f++)r[f].applyMatrix4(a.makeRotationAxis(n[f],d*f)),o[f].crossVectors(n[f],r[f])}return{tangents:n,normals:r,binormals:o}},clone:function(){return new this.constructor().copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}});function Dt(e,t,i,n,r,o,s,a){xe.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=i||1,this.yRadius=n||1,this.aStartAngle=r||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=s||!1,this.aRotation=a||0}Dt.prototype=Object.create(xe.prototype),Dt.prototype.constructor=Dt,Dt.prototype.isEllipseCurve=!0,Dt.prototype.getPoint=function(e,t){const i=t||new le,n=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(o?r=0:r=n),this.aClockwise===!0&&!o&&(r===n?r=-n:r=r-n);const s=this.aStartAngle+e*r;let a=this.aX+this.xRadius*Math.cos(s),l=this.aY+this.yRadius*Math.sin(s);if(this.aRotation!==0){const c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),u=a-this.aX,d=l-this.aY;a=u*c-d*h+this.aX,l=u*h+d*c+this.aY}return i.set(a,l)},Dt.prototype.copy=function(e){return xe.prototype.copy.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},Dt.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e},Dt.prototype.fromJSON=function(e){return xe.prototype.fromJSON.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this};function Cr(e,t,i,n,r,o){Dt.call(this,e,t,i,i,n,r,o),this.type="ArcCurve"}Cr.prototype=Object.create(Dt.prototype),Cr.prototype.constructor=Cr,Cr.prototype.isArcCurve=!0;function Vs(){let e=0,t=0,i=0,n=0;function r(o,s,a,l){e=o,t=a,i=-3*o+3*s-2*a-l,n=2*o-2*s+a+l}return{initCatmullRom:function(o,s,a,l,c){r(s,a,c*(a-o),c*(l-s))},initNonuniformCatmullRom:function(o,s,a,l,c,h,u){let d=(s-o)/c-(a-o)/(c+h)+(a-s)/h,f=(a-s)/h-(l-s)/(h+u)+(l-a)/u;d*=h,f*=h,r(s,a,d,f)},calc:function(o){const s=o*o,a=s*o;return e+t*o+i*s+n*a}}}const Eo=new A,Ws=new Vs,js=new Vs,Xs=new Vs;function Ct(e=[],t=!1,i="centripetal",n=.5){xe.call(this),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}Ct.prototype=Object.create(xe.prototype),Ct.prototype.constructor=Ct,Ct.prototype.isCatmullRomCurve3=!0,Ct.prototype.getPoint=function(e,t=new A){const i=t,n=this.points,r=n.length,o=(r-(this.closed?0:1))*e;let s=Math.floor(o),a=o-s;this.closed?s+=s>0?0:(Math.floor(Math.abs(s)/r)+1)*r:a===0&&s===r-1&&(s=r-2,a=1);let l,c;this.closed||s>0?l=n[(s-1)%r]:(Eo.subVectors(n[0],n[1]).add(n[0]),l=Eo);const h=n[s%r],u=n[(s+1)%r];if(this.closed||s+2<r?c=n[(s+2)%r]:(Eo.subVectors(n[r-1],n[r-2]).add(n[r-1]),c=Eo),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let f=Math.pow(l.distanceToSquared(h),d),m=Math.pow(h.distanceToSquared(u),d),v=Math.pow(u.distanceToSquared(c),d);m<1e-4&&(m=1),f<1e-4&&(f=m),v<1e-4&&(v=m),Ws.initNonuniformCatmullRom(l.x,h.x,u.x,c.x,f,m,v),js.initNonuniformCatmullRom(l.y,h.y,u.y,c.y,f,m,v),Xs.initNonuniformCatmullRom(l.z,h.z,u.z,c.z,f,m,v)}else this.curveType==="catmullrom"&&(Ws.initCatmullRom(l.x,h.x,u.x,c.x,this.tension),js.initCatmullRom(l.y,h.y,u.y,c.y,this.tension),Xs.initCatmullRom(l.z,h.z,u.z,c.z,this.tension));return i.set(Ws.calc(a),js.calc(a),Xs.calc(a)),i},Ct.prototype.copy=function(e){xe.prototype.copy.call(this,e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},Ct.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);e.points=[];for(let t=0,i=this.points.length;t<i;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e},Ct.prototype.fromJSON=function(e){xe.prototype.fromJSON.call(this,e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(new A().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this};function tc(e,t,i,n,r){const o=(n-t)*.5,s=(r-i)*.5,a=e*e,l=e*a;return(2*i-2*n+o+s)*l+(-3*i+3*n-2*o-s)*a+o*e+i}function $m(e,t){const i=1-e;return i*i*t}function eg(e,t){return 2*(1-e)*e*t}function tg(e,t){return e*e*t}function Nr(e,t,i,n){return $m(e,t)+eg(e,i)+tg(e,n)}function ig(e,t){const i=1-e;return i*i*i*t}function ng(e,t){const i=1-e;return 3*i*i*e*t}function rg(e,t){return 3*(1-e)*e*e*t}function og(e,t){return e*e*e*t}function Ir(e,t,i,n,r){return ig(e,t)+ng(e,i)+rg(e,n)+og(e,r)}function ei(e=new le,t=new le,i=new le,n=new le){xe.call(this),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}ei.prototype=Object.create(xe.prototype),ei.prototype.constructor=ei,ei.prototype.isCubicBezierCurve=!0,ei.prototype.getPoint=function(e,t=new le){const i=t,n=this.v0,r=this.v1,o=this.v2,s=this.v3;return i.set(Ir(e,n.x,r.x,o.x,s.x),Ir(e,n.y,r.y,o.y,s.y)),i},ei.prototype.copy=function(e){return xe.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},ei.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},ei.prototype.fromJSON=function(e){return xe.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this};function _i(e=new A,t=new A,i=new A,n=new A){xe.call(this),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}_i.prototype=Object.create(xe.prototype),_i.prototype.constructor=_i,_i.prototype.isCubicBezierCurve3=!0,_i.prototype.getPoint=function(e,t=new A){const i=t,n=this.v0,r=this.v1,o=this.v2,s=this.v3;return i.set(Ir(e,n.x,r.x,o.x,s.x),Ir(e,n.y,r.y,o.y,s.y),Ir(e,n.z,r.z,o.z,s.z)),i},_i.prototype.copy=function(e){return xe.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},_i.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},_i.prototype.fromJSON=function(e){return xe.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this};function Nt(e=new le,t=new le){xe.call(this),this.type="LineCurve",this.v1=e,this.v2=t}Nt.prototype=Object.create(xe.prototype),Nt.prototype.constructor=Nt,Nt.prototype.isLineCurve=!0,Nt.prototype.getPoint=function(e,t=new le){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},Nt.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},Nt.prototype.getTangent=function(e,t){const i=t||new le;return i.copy(this.v2).sub(this.v1).normalize(),i},Nt.prototype.copy=function(e){return xe.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Nt.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Nt.prototype.fromJSON=function(e){return xe.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function ti(e=new A,t=new A){xe.call(this),this.type="LineCurve3",this.v1=e,this.v2=t}ti.prototype=Object.create(xe.prototype),ti.prototype.constructor=ti,ti.prototype.isLineCurve3=!0,ti.prototype.getPoint=function(e,t=new A){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},ti.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},ti.prototype.copy=function(e){return xe.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},ti.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},ti.prototype.fromJSON=function(e){return xe.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function ii(e=new le,t=new le,i=new le){xe.call(this),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}ii.prototype=Object.create(xe.prototype),ii.prototype.constructor=ii,ii.prototype.isQuadraticBezierCurve=!0,ii.prototype.getPoint=function(e,t=new le){const i=t,n=this.v0,r=this.v1,o=this.v2;return i.set(Nr(e,n.x,r.x,o.x),Nr(e,n.y,r.y,o.y)),i},ii.prototype.copy=function(e){return xe.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},ii.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},ii.prototype.fromJSON=function(e){return xe.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function xi(e=new A,t=new A,i=new A){xe.call(this),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}xi.prototype=Object.create(xe.prototype),xi.prototype.constructor=xi,xi.prototype.isQuadraticBezierCurve3=!0,xi.prototype.getPoint=function(e,t=new A){const i=t,n=this.v0,r=this.v1,o=this.v2;return i.set(Nr(e,n.x,r.x,o.x),Nr(e,n.y,r.y,o.y),Nr(e,n.z,r.z,o.z)),i},xi.prototype.copy=function(e){return xe.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},xi.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},xi.prototype.fromJSON=function(e){return xe.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this};function ni(e=[]){xe.call(this),this.type="SplineCurve",this.points=e}ni.prototype=Object.create(xe.prototype),ni.prototype.constructor=ni,ni.prototype.isSplineCurve=!0,ni.prototype.getPoint=function(e,t=new le){const i=t,n=this.points,r=(n.length-1)*e,o=Math.floor(r),s=r-o,a=n[o===0?o:o-1],l=n[o],c=n[o>n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return i.set(tc(s,a.x,l.x,c.x,h.x),tc(s,a.y,l.y,c.y,h.y)),i},ni.prototype.copy=function(e){xe.prototype.copy.call(this,e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(n.clone())}return this},ni.prototype.toJSON=function(){const e=xe.prototype.toJSON.call(this);e.points=[];for(let t=0,i=this.points.length;t<i;t++){const n=this.points[t];e.points.push(n.toArray())}return e},ni.prototype.fromJSON=function(e){xe.prototype.fromJSON.call(this,e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const n=e.points[t];this.points.push(new le().fromArray(n))}return this};var sg=Object.freeze({__proto__:null,ArcCurve:Cr,CatmullRomCurve3:Ct,CubicBezierCurve:ei,CubicBezierCurve3:_i,EllipseCurve:Dt,LineCurve:Nt,LineCurve3:ti,QuadraticBezierCurve:ii,QuadraticBezierCurve3:xi,SplineCurve:ni});function nn(){xe.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}nn.prototype=Object.assign(Object.create(xe.prototype),{constructor:nn,add:function(e){this.curves.push(e)},closePath:function(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Nt(t,e))},getPoint:function(e){const t=e*this.getLength(),i=this.getCurveLengths();let n=0;for(;n<i.length;){if(i[n]>=t){const r=i[n]-t,o=this.curves[n],s=o.getLength(),a=s===0?0:1-r/s;return o.getPointAt(a)}n++}return null},getLength:function(){const e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e},getSpacedPoints:function(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t},getPoints:function(e=12){const t=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const o=r[n],s=o&&o.isEllipseCurve?e*2:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e,a=o.getPoints(s);for(let l=0;l<a.length;l++){const c=a[l];i&&i.equals(c)||(t.push(c),i=c)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t},copy:function(e){xe.prototype.copy.call(this,e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this},toJSON:function(){const e=xe.prototype.toJSON.call(this);e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e},fromJSON:function(e){xe.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const n=e.curves[t];this.curves.push(new sg[n.type]().fromJSON(n))}return this}});function ri(e){nn.call(this),this.type="Path",this.currentPoint=new le,e&&this.setFromPoints(e)}ri.prototype=Object.assign(Object.create(nn.prototype),{constructor:ri,setFromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this},moveTo:function(e,t){return this.currentPoint.set(e,t),this},lineTo:function(e,t){const i=new Nt(this.currentPoint.clone(),new le(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this},quadraticCurveTo:function(e,t,i,n){const r=new ii(this.currentPoint.clone(),new le(e,t),new le(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this},bezierCurveTo:function(e,t,i,n,r,o){const s=new ei(this.currentPoint.clone(),new le(e,t),new le(i,n),new le(r,o));return this.curves.push(s),this.currentPoint.set(r,o),this},splineThru:function(e){const t=[this.currentPoint.clone()].concat(e),i=new ni(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this},arc:function(e,t,i,n,r,o){const s=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(e+s,t+a,i,n,r,o),this},absarc:function(e,t,i,n,r,o){return this.absellipse(e,t,i,i,n,r,o),this},ellipse:function(e,t,i,n,r,o,s,a){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,i,n,r,o,s,a),this},absellipse:function(e,t,i,n,r,o,s,a){const l=new Dt(e,t,i,n,r,o,s,a);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this},copy:function(e){return nn.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){const e=nn.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return nn.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}});function jn(e){ri.call(this,e),this.uuid=Se.generateUUID(),this.type="Shape",this.holes=[]}jn.prototype=Object.assign(Object.create(ri.prototype),{constructor:jn,getPointsHoles:function(e){const t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].getPoints(e);return t},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){ri.prototype.copy.call(this,e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const n=e.holes[t];this.holes.push(n.clone())}return this},toJSON:function(){const e=ri.prototype.toJSON.call(this);e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e},fromJSON:function(e){ri.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const n=e.holes[t];this.holes.push(new ri().fromJSON(n))}return this}});function Ge(e,t=1){we.call(this),this.type="Light",this.color=new he(e),this.intensity=t}Ge.prototype=Object.assign(Object.create(we.prototype),{constructor:Ge,isLight:!0,copy:function(e){return we.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){const t=we.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}});function Ys(e,t,i){Ge.call(this,e,i),this.type="HemisphereLight",this.position.copy(we.DefaultUp),this.updateMatrix(),this.groundColor=new he(t)}Ys.prototype=Object.assign(Object.create(Ge.prototype),{constructor:Ys,isHemisphereLight:!0,copy:function(e){return Ge.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}});function yi(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new le(512,512),this.map=null,this.mapPass=null,this.matrix=new Re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new lo,this._frameExtents=new le(1,1),this._viewportCount=1,this._viewports=[new ke(0,0,1,1)]}Object.assign(yi.prototype,{_projScreenMatrix:new Re,_lightPositionWorld:new A,_lookTarget:new A,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(e){const t=this.camera,i=this.matrix,n=this._projScreenMatrix,r=this._lookTarget,o=this._lightPositionWorld;o.setFromMatrixPosition(e.matrixWorld),t.position.copy(o),r.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(r),t.updateMatrixWorld(),n.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(n),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.multiply(t.matrixWorldInverse)},getViewport:function(e){return this._viewports[e]},getFrameExtents:function(){return this._frameExtents},copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}});function qs(){yi.call(this,new $e(50,1,.5,500)),this.focus=1}qs.prototype=Object.assign(Object.create(yi.prototype),{constructor:qs,isSpotLightShadow:!0,updateMatrices:function(e){const t=this.camera,i=Se.RAD2DEG*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(i!==t.fov||n!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),yi.prototype.updateMatrices.call(this,e)}});function Qs(e,t,i,n,r,o){Ge.call(this,e,t),this.type="SpotLight",this.position.copy(we.DefaultUp),this.updateMatrix(),this.target=new we,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(s){this.intensity=s/Math.PI}}),this.distance=i!==void 0?i:0,this.angle=n!==void 0?n:Math.PI/3,this.penumbra=r!==void 0?r:0,this.decay=o!==void 0?o:1,this.shadow=new qs}Qs.prototype=Object.assign(Object.create(Ge.prototype),{constructor:Qs,isSpotLight:!0,copy:function(e){return Ge.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}});function Zs(){yi.call(this,new $e(90,1,.5,500)),this._frameExtents=new le(4,2),this._viewportCount=6,this._viewports=[new ke(2,1,1,1),new ke(0,1,1,1),new ke(3,1,1,1),new ke(1,1,1,1),new ke(3,0,1,1),new ke(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}Zs.prototype=Object.assign(Object.create(yi.prototype),{constructor:Zs,isPointLightShadow:!0,updateMatrices:function(e,t=0){const i=this.camera,n=this.matrix,r=this._lightPositionWorld,o=this._lookTarget,s=this._projScreenMatrix;r.setFromMatrixPosition(e.matrixWorld),i.position.copy(r),o.copy(i.position),o.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(o),i.updateMatrixWorld(),n.makeTranslation(-r.x,-r.y,-r.z),s.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(s)}});function Js(e,t,i,n){Ge.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return this.intensity*4*Math.PI},set:function(r){this.intensity=r/(4*Math.PI)}}),this.distance=i!==void 0?i:0,this.decay=n!==void 0?n:1,this.shadow=new Zs}Js.prototype=Object.assign(Object.create(Ge.prototype),{constructor:Js,isPointLight:!0,copy:function(e){return Ge.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}});function Xn(e=-1,t=1,i=1,n=-1,r=.1,o=2e3){Ni.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=o,this.updateProjectionMatrix()}Xn.prototype=Object.assign(Object.create(Ni.prototype),{constructor:Xn,isOrthographicCamera:!0,copy:function(e,t){return Ni.prototype.copy.call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this},setViewOffset:function(e,t,i,n,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,o=i+e,s=n+t,a=n-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,s-=c*this.view.offsetY,a=s-c*this.view.height}this.projectionMatrix.makeOrthographic(r,o,s,a,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){const t=we.prototype.toJSON.call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}});function Ks(){yi.call(this,new Xn(-5,5,5,-5,.5,500))}Ks.prototype=Object.assign(Object.create(yi.prototype),{constructor:Ks,isDirectionalLightShadow:!0,updateMatrices:function(e){yi.prototype.updateMatrices.call(this,e)}});function Lo(e,t){Ge.call(this,e,t),this.type="DirectionalLight",this.position.copy(we.DefaultUp),this.updateMatrix(),this.target=new we,this.shadow=new Ks}Lo.prototype=Object.assign(Object.create(Ge.prototype),{constructor:Lo,isDirectionalLight:!0,copy:function(e){return Ge.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}});function ic(e,t){Ge.call(this,e,t),this.type="AmbientLight"}ic.prototype=Object.assign(Object.create(Ge.prototype),{constructor:ic,isAmbientLight:!0});function nc(e,t,i,n){Ge.call(this,e,t),this.type="RectAreaLight",this.width=i!==void 0?i:10,this.height=n!==void 0?n:10}nc.prototype=Object.assign(Object.create(Ge.prototype),{constructor:nc,isRectAreaLight:!0,copy:function(e){return Ge.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){const t=Ge.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}});class ag{constructor(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new A)}set(t){for(let i=0;i<9;i++)this.coefficients[i].copy(t[i]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,i){const n=t.x,r=t.y,o=t.z,s=this.coefficients;return i.copy(s[0]).multiplyScalar(.282095),i.addScaledVector(s[1],.488603*r),i.addScaledVector(s[2],.488603*o),i.addScaledVector(s[3],.488603*n),i.addScaledVector(s[4],1.092548*(n*r)),i.addScaledVector(s[5],1.092548*(r*o)),i.addScaledVector(s[6],.315392*(3*o*o-1)),i.addScaledVector(s[7],1.092548*(n*o)),i.addScaledVector(s[8],.546274*(n*n-r*r)),i}getIrradianceAt(t,i){const n=t.x,r=t.y,o=t.z,s=this.coefficients;return i.copy(s[0]).multiplyScalar(.886227),i.addScaledVector(s[1],2*.511664*r),i.addScaledVector(s[2],2*.511664*o),i.addScaledVector(s[3],2*.511664*n),i.addScaledVector(s[4],2*.429043*n*r),i.addScaledVector(s[5],2*.429043*r*o),i.addScaledVector(s[6],.743125*o*o-.247708),i.addScaledVector(s[7],2*.429043*n*o),i.addScaledVector(s[8],.429043*(n*n-r*r)),i}add(t){for(let i=0;i<9;i++)this.coefficients[i].add(t.coefficients[i]);return this}addScaledSH(t,i){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],i);return this}scale(t){for(let i=0;i<9;i++)this.coefficients[i].multiplyScalar(t);return this}lerp(t,i){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],i);return this}equals(t){for(let i=0;i<9;i++)if(!this.coefficients[i].equals(t.coefficients[i]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,i=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(t,i+r*3);return this}toArray(t=[],i=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(t,i+r*3);return t}static getBasisAt(t,i){const n=t.x,r=t.y,o=t.z;i[0]=.282095,i[1]=.488603*r,i[2]=.488603*o,i[3]=.488603*n,i[4]=1.092548*n*r,i[5]=1.092548*r*o,i[6]=.315392*(3*o*o-1),i[7]=1.092548*n*o,i[8]=.546274*(n*n-r*r)}}function oi(e,t){Ge.call(this,void 0,t),this.type="LightProbe",this.sh=e!==void 0?e:new ag}oi.prototype=Object.assign(Object.create(Ge.prototype),{constructor:oi,isLightProbe:!0,copy:function(e){return Ge.prototype.copy.call(this,e),this.sh.copy(e.sh),this},fromJSON:function(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this},toJSON:function(e){const t=Ge.prototype.toJSON.call(this,e);return t.object.sh=this.sh.toArray(),t}});function rc(e){Ue.call(this,e),this.textures={}}rc.prototype=Object.assign(Object.create(Ue.prototype),{constructor:rc,load:function(e,t,i,n){const r=this,o=new Yt(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(s){try{t(r.parse(JSON.parse(s)))}catch(a){n?n(a):console.error(a),r.manager.itemError(e)}},i,n)},parse:function(e){const t=this.textures;function i(r){return t[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),t[r]}const n=new Qm[e.type];if(e.uuid!==void 0&&(n.uuid=e.uuid),e.name!==void 0&&(n.name=e.name),e.color!==void 0&&n.color!==void 0&&n.color.setHex(e.color),e.roughness!==void 0&&(n.roughness=e.roughness),e.metalness!==void 0&&(n.metalness=e.metalness),e.sheen!==void 0&&(n.sheen=new he().setHex(e.sheen)),e.emissive!==void 0&&n.emissive!==void 0&&n.emissive.setHex(e.emissive),e.specular!==void 0&&n.specular!==void 0&&n.specular.setHex(e.specular),e.shininess!==void 0&&(n.shininess=e.shininess),e.clearcoat!==void 0&&(n.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=e.clearcoatRoughness),e.fog!==void 0&&(n.fog=e.fog),e.flatShading!==void 0&&(n.flatShading=e.flatShading),e.blending!==void 0&&(n.blending=e.blending),e.combine!==void 0&&(n.combine=e.combine),e.side!==void 0&&(n.side=e.side),e.opacity!==void 0&&(n.opacity=e.opacity),e.transparent!==void 0&&(n.transparent=e.transparent),e.alphaTest!==void 0&&(n.alphaTest=e.alphaTest),e.depthTest!==void 0&&(n.depthTest=e.depthTest),e.depthWrite!==void 0&&(n.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(n.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(n.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(n.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(n.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(n.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(n.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(n.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(n.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(n.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(n.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(n.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(n.rotation=e.rotation),e.linewidth!==1&&(n.linewidth=e.linewidth),e.dashSize!==void 0&&(n.dashSize=e.dashSize),e.gapSize!==void 0&&(n.gapSize=e.gapSize),e.scale!==void 0&&(n.scale=e.scale),e.polygonOffset!==void 0&&(n.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(n.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(n.polygonOffsetUnits=e.polygonOffsetUnits),e.skinning!==void 0&&(n.skinning=e.skinning),e.morphTargets!==void 0&&(n.morphTargets=e.morphTargets),e.morphNormals!==void 0&&(n.morphNormals=e.morphNormals),e.dithering!==void 0&&(n.dithering=e.dithering),e.vertexTangents!==void 0&&(n.vertexTangents=e.vertexTangents),e.visible!==void 0&&(n.visible=e.visible),e.toneMapped!==void 0&&(n.toneMapped=e.toneMapped),e.userData!==void 0&&(n.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?n.vertexColors=e.vertexColors>0:n.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(n.uniforms[r]={},o.type){case"t":n.uniforms[r].value=i(o.value);break;case"c":n.uniforms[r].value=new he().setHex(o.value);break;case"v2":n.uniforms[r].value=new le().fromArray(o.value);break;case"v3":n.uniforms[r].value=new A().fromArray(o.value);break;case"v4":n.uniforms[r].value=new ke().fromArray(o.value);break;case"m3":n.uniforms[r].value=new Ft().fromArray(o.value);break;case"m4":n.uniforms[r].value=new Re().fromArray(o.value);break;default:n.uniforms[r].value=o.value}}if(e.defines!==void 0&&(n.defines=e.defines),e.vertexShader!==void 0&&(n.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(n.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const r in e.extensions)n.extensions[r]=e.extensions[r];if(e.shading!==void 0&&(n.flatShading=e.shading===1),e.size!==void 0&&(n.size=e.size),e.sizeAttenuation!==void 0&&(n.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(n.map=i(e.map)),e.matcap!==void 0&&(n.matcap=i(e.matcap)),e.alphaMap!==void 0&&(n.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(n.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(n.bumpScale=e.bumpScale),e.normalMap!==void 0&&(n.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(n.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),n.normalScale=new le().fromArray(r)}return e.displacementMap!==void 0&&(n.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(n.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(n.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(n.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(n.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(n.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(n.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(n.specularMap=i(e.specularMap)),e.envMap!==void 0&&(n.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(n.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(n.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(n.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(n.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(n.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(n.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(n.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(n.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(n.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(n.clearcoatNormalScale=new le().fromArray(e.clearcoatNormalScale)),e.transmission!==void 0&&(n.transmission=e.transmission),e.transmissionMap!==void 0&&(n.transmissionMap=i(e.transmissionMap)),n},setTextures:function(e){return this.textures=e,this}});const Yn={decodeText:function(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}},extractUrlBase:function(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substr(0,t+1)}};function Po(){De.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}Po.prototype=Object.assign(Object.create(De.prototype),{constructor:Po,isInstancedBufferGeometry:!0,copy:function(e){return De.prototype.copy.call(this,e),this.instanceCount=e.instanceCount,this},clone:function(){return new this.constructor().copy(this)},toJSON:function(){const e=De.prototype.toJSON.call(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}});function $s(e,t,i,n){typeof i=="number"&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),Le.call(this,e,t,i),this.meshPerAttribute=n||1}$s.prototype=Object.assign(Object.create(Le.prototype),{constructor:$s,isInstancedBufferAttribute:!0,copy:function(e){return Le.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},toJSON:function(){const e=Le.prototype.toJSON.call(this);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}});function oc(e){Ue.call(this,e)}oc.prototype=Object.assign(Object.create(Ue.prototype),{constructor:oc,load:function(e,t,i,n){const r=this,o=new Yt(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(s){try{t(r.parse(JSON.parse(s)))}catch(a){n?n(a):console.error(a),r.manager.itemError(e)}},i,n)},parse:function(e){const t={},i={};function n(u,d){if(t[d]!==void 0)return t[d];const f=u.interleavedBuffers[d],m=r(u,f.buffer),v=Kr(f.type,m),_=new Pt(v,f.stride);return _.uuid=f.uuid,t[d]=_,_}function r(u,d){if(i[d]!==void 0)return i[d];const f=u.arrayBuffers[d],m=new Uint32Array(f).buffer;return i[d]=m,m}const o=e.isInstancedBufferGeometry?new Po:new De,s=e.data.index;if(s!==void 0){const u=Kr(s.type,s.array);o.setIndex(new Le(u,1))}const a=e.data.attributes;for(const u in a){const d=a[u];let f;if(d.isInterleavedBufferAttribute){const m=n(e.data,d.data);f=new Oi(m,d.itemSize,d.offset,d.normalized)}else{const m=Kr(d.type,d.array),v=d.isInstancedBufferAttribute?$s:Le;f=new v(m,d.itemSize,d.normalized)}d.name!==void 0&&(f.name=d.name),o.setAttribute(u,f)}const l=e.data.morphAttributes;if(l)for(const u in l){const d=l[u],f=[];for(let m=0,v=d.length;m<v;m++){const _=d[m];let g;if(_.isInterleavedBufferAttribute){const p=n(e.data,_.data);g=new Oi(p,_.itemSize,_.offset,_.normalized)}else{const p=Kr(_.type,_.array);g=new Le(p,_.itemSize,_.normalized)}_.name!==void 0&&(g.name=_.name),f.push(g)}o.morphAttributes[u]=f}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const c=e.data.groups||e.data.drawcalls||e.data.offsets;if(c!==void 0)for(let u=0,d=c.length;u!==d;++u){const f=c[u];o.addGroup(f.start,f.count,f.materialIndex)}const h=e.data.boundingSphere;if(h!==void 0){const u=new A;h.center!==void 0&&u.fromArray(h.center),o.boundingSphere=new Zt(u,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}});function ea(e){typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),Ue.call(this,e),this.options={premultiplyAlpha:"none"}}ea.prototype=Object.assign(Object.create(Ue.prototype),{constructor:ea,isImageBitmapLoader:!0,setOptions:function(e){return this.options=e,this},load:function(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Vn.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const s={};s.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",fetch(e,s).then(function(a){return a.blob()}).then(function(a){return createImageBitmap(a,r.options)}).then(function(a){Vn.add(e,a),t&&t(a),r.manager.itemEnd(e)}).catch(function(a){n&&n(a),r.manager.itemError(e),r.manager.itemEnd(e)}),r.manager.itemStart(e)}});function sc(){this.type="ShapePath",this.color=new he,this.subPaths=[],this.currentPath=null}Object.assign(sc.prototype,{moveTo:function(e,t){return this.currentPath=new ri,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this},lineTo:function(e,t){return this.currentPath.lineTo(e,t),this},quadraticCurveTo:function(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this},bezierCurveTo:function(e,t,i,n,r,o){return this.currentPath.bezierCurveTo(e,t,i,n,r,o),this},splineThru:function(e){return this.currentPath.splineThru(e),this},toShapes:function(e,t){function i(g){const p=[];for(let E=0,S=g.length;E<S;E++){const T=g[E],x=new jn;x.curves=T.curves,p.push(x)}return p}function n(g,p){const E=p.length;let S=!1;for(let T=E-1,x=0;x<E;T=x++){let L=p[T],W=p[x],U=W.x-L.x,B=W.y-L.y;if(Math.abs(B)>Number.EPSILON){if(B<0&&(L=p[x],U=-U,W=p[T],B=-B),g.y<L.y||g.y>W.y)continue;if(g.y===L.y){if(g.x===L.x)return!0}else{const H=B*(g.x-L.x)-U*(g.y-L.y);if(H===0)return!0;if(H<0)continue;S=!S}}else{if(g.y!==L.y)continue;if(W.x<=g.x&&g.x<=L.x||L.x<=g.x&&g.x<=W.x)return!0}}return S}const r=zi.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return i(o);let s,a,l;const c=[];if(o.length===1)return a=o[0],l=new jn,l.curves=a.curves,c.push(l),c;let h=!r(o[0].getPoints());h=e?!h:h;const u=[],d=[];let f=[],m=0,v;d[m]=void 0,f[m]=[];for(let g=0,p=o.length;g<p;g++)a=o[g],v=a.getPoints(),s=r(v),s=e?!s:s,s?(!h&&d[m]&&m++,d[m]={s:new jn,p:v},d[m].s.curves=a.curves,h&&m++,f[m]=[]):f[m].push({h:a,p:v[0]});if(!d[0])return i(o);if(d.length>1){let g=!1;const p=[];for(let E=0,S=d.length;E<S;E++)u[E]=[];for(let E=0,S=d.length;E<S;E++){const T=f[E];for(let x=0;x<T.length;x++){const L=T[x];let W=!0;for(let U=0;U<d.length;U++)n(L.p,d[U].p)&&(E!==U&&p.push({froms:E,tos:U,hole:x}),W?(W=!1,u[U].push(L)):g=!0);W&&u[E].push(L)}}p.length>0&&(g||(f=u))}let _;for(let g=0,p=d.length;g<p;g++){l=d[g].s,c.push(l),_=f[g];for(let E=0,S=_.length;E<S;E++)l.holes.push(_[E].h)}return c}});class lg{constructor(t){Object.defineProperty(this,"isFont",{value:!0}),this.type="Font",this.data=t}generateShapes(t,i=100){const n=[],r=cg(t,i,this.data);for(let o=0,s=r.length;o<s;o++)Array.prototype.push.apply(n,r[o].toShapes());return n}}function cg(e,t,i){const n=Array.from?Array.from(e):String(e).split(""),r=t/i.resolution,o=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,s=[];let a=0,l=0;for(let c=0;c<n.length;c++){const h=n[c];if(h===`
  2800. `)a=0,l-=o;else{const u=hg(h,r,a,l,i);a+=u.offsetX,s.push(u.path)}}return s}function hg(e,t,i,n,r){const o=r.glyphs[e]||r.glyphs["?"];if(!o){console.error('THREE.Font: character "'+e+'" does not exists in font family '+r.familyName+".");return}const s=new sc;let a,l,c,h,u,d,f,m;if(o.o){const v=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let _=0,g=v.length;_<g;)switch(v[_++]){case"m":a=v[_++]*t+i,l=v[_++]*t+n,s.moveTo(a,l);break;case"l":a=v[_++]*t+i,l=v[_++]*t+n,s.lineTo(a,l);break;case"q":c=v[_++]*t+i,h=v[_++]*t+n,u=v[_++]*t+i,d=v[_++]*t+n,s.quadraticCurveTo(u,d,c,h);break;case"b":c=v[_++]*t+i,h=v[_++]*t+n,u=v[_++]*t+i,d=v[_++]*t+n,f=v[_++]*t+i,m=v[_++]*t+n,s.bezierCurveTo(u,d,f,m,c,h);break}}return{offsetX:o.ha*t,path:s}}function ac(e){Ue.call(this,e)}ac.prototype=Object.assign(Object.create(Ue.prototype),{constructor:ac,load:function(e,t,i,n){const r=this,o=new Yt(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(s){let a;try{a=JSON.parse(s)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),a=JSON.parse(s.substring(65,s.length-2))}const l=r.parse(a);t&&t(l)},i,n)},parse:function(e){return new lg(e)}});let Ro;const ug={getContext:function(){return Ro===void 0&&(Ro=new(window.AudioContext||window.webkitAudioContext)),Ro},setContext:function(e){Ro=e}};function lc(e){Ue.call(this,e)}lc.prototype=Object.assign(Object.create(Ue.prototype),{constructor:lc,load:function(e,t,i,n){const r=this,o=new Yt(r.manager);o.setResponseType("arraybuffer"),o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(s){try{const a=s.slice(0);ug.getContext().decodeAudioData(a,function(l){t(l)})}catch(a){n?n(a):console.error(a),r.manager.itemError(e)}},i,n)}});function cc(e,t,i){oi.call(this,void 0,i);const n=new he().set(e),r=new he().set(t),o=new A(n.r,n.g,n.b),s=new A(r.r,r.g,r.b),a=Math.sqrt(Math.PI),l=a*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(s).multiplyScalar(a),this.sh.coefficients[1].copy(o).sub(s).multiplyScalar(l)}cc.prototype=Object.assign(Object.create(oi.prototype),{constructor:cc,isHemisphereLightProbe:!0,copy:function(e){return oi.prototype.copy.call(this,e),this},toJSON:function(e){return oi.prototype.toJSON.call(this,e)}});function hc(e,t){oi.call(this,void 0,t);const i=new he().set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}hc.prototype=Object.assign(Object.create(oi.prototype),{constructor:hc,isAmbientLightProbe:!0,copy:function(e){return oi.prototype.copy.call(this,e),this},toJSON:function(e){return oi.prototype.toJSON.call(this,e)}});const uc=new Re,dc=new Re;function dg(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new $e,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new $e,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}}Object.assign(dg.prototype,{update:function(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep;const i=e.projectionMatrix.clone(),n=t.eyeSep/2,r=n*t.near/t.focus,o=t.near*Math.tan(Se.DEG2RAD*t.fov*.5)/t.zoom;let s,a;dc.elements[12]=-n,uc.elements[12]=n,s=-o*t.aspect+r,a=o*t.aspect+r,i.elements[0]=2*t.near/(a-s),i.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(i),s=-o*t.aspect-r,a=o*t.aspect-r,i.elements[0]=2*t.near/(a-s),i.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(dc),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(uc)}});class pg{constructor(t){this.autoStart=t!==void 0?t:!0,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=pc(),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 i=pc();t=(i-this.oldTime)/1e3,this.oldTime=i,this.elapsedTime+=t}return t}}function pc(){return(typeof performance>"u"?Date:performance).now()}function fc(e,t,i){this.binding=e,this.valueSize=i;let n,r,o;switch(t){case"quaternion":n=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(fc.prototype,{accumulate:function(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let o=this.cumulativeWeight;if(o===0){for(let s=0;s!==n;++s)i[r+s]=i[s];o=t}else{o+=t;const s=t/o;this._mixBufferRegion(i,r,0,s,n)}this.cumulativeWeight=o},accumulateAdditive:function(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e},apply:function(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const a=t*this._origIndex;this._mixBufferRegion(i,n,a,1-r,t)}o>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let a=t,l=t+t;a!==l;++a)if(i[a]!==i[a+t]){s.setValue(i,n);break}},saveOriginalState:function(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let r=i,o=n;r!==o;++r)t[r]=t[n+r%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)},_setAdditiveIdentityNumeric:function(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]},_select:function(e,t,i,n,r){if(n>=.5)for(let o=0;o!==r;++o)e[t+o]=e[i+o]},_slerp:function(e,t,i,n){tt.slerpFlat(e,t,e,t,e,i,n)},_slerpAdditive:function(e,t,i,n,r){const o=this._workIndex*r;tt.multiplyQuaternionsFlat(e,o,e,t,e,i),tt.slerpFlat(e,t,e,t,e,o,n)},_lerp:function(e,t,i,n,r){const o=1-n;for(let s=0;s!==r;++s){const a=t+s;e[a]=e[a]*o+e[i+s]*n}},_lerpAdditive:function(e,t,i,n,r){for(let o=0;o!==r;++o){const s=t+o;e[s]=e[s]+e[i+o]*n}}});const ta="\\[\\]\\.:\\/",fg=new RegExp("["+ta+"]","g"),ia="[^"+ta+"]",mg="[^"+ta.replace("\\.","")+"]",gg=/((?:WC+[\/:])*)/.source.replace("WC",ia),vg=/(WCOD+)?/.source.replace("WCOD",mg),_g=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ia),xg=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ia),yg=new RegExp("^"+gg+vg+_g+xg+"$"),bg=["material","materials","bones"];function mc(e,t,i){const n=i||gt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}Object.assign(mc.prototype,{getValue:function(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)},setValue:function(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)},bind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}});function gt(e,t,i){this.path=t,this.parsedPath=i||gt.parseTrackName(t),this.node=gt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}Object.assign(gt,{Composite:mc,create:function(e,t,i){return e&&e.isAnimationObjectGroup?new gt.Composite(e,t,i):new gt(e,t,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(fg,"")},parseTrackName:function(e){const t=yg.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=i.nodeName.substring(n+1);bg.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i},findNode:function(e,t){if(!t||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let o=0;o<r.length;o++){const s=r[o];if(s.name===t||s.uuid===t)return s;const a=i(s.children);if(a)return a}return null},n=i(e.children);if(n)return n}return null}}),Object.assign(gt.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,t){e[t]=this.node[this.propertyName]},function(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]},function(e,t){e[t]=this.resolvedProperty[this.propertyIndex]},function(e,t){this.resolvedProperty.toArray(e,t)}],SetterByBindingTypeAndVersioning:[[function(e,t){this.targetObject[this.propertyName]=e[t]},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]},function(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0},function(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty[this.propertyIndex]=e[t]},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty.fromArray(e,t)},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=gt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===l){l=c;break}break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const o=e[n];if(o===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+n+" but it wasn't found.",e);return}let s=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?s=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}a=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(a=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(a=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][s]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(gt.prototype,{_getValue_unbound:gt.prototype.getValue,_setValue_unbound:gt.prototype.setValue});function wg(){this.uuid=Se.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,n=arguments.length;i!==n;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}Object.assign(wg.prototype,{isAnimationObjectGroup:!0,add:function(){const e=this._objects,t=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,o=r.length;let s,a=e.length,l=this.nCachedObjects_;for(let c=0,h=arguments.length;c!==h;++c){const u=arguments[c],d=u.uuid;let f=t[d];if(f===void 0){f=a++,t[d]=f,e.push(u);for(let m=0,v=o;m!==v;++m)r[m].push(new gt(u,i[m],n[m]))}else if(f<l){s=e[f];const m=--l,v=e[m];t[v.uuid]=f,e[f]=v,t[d]=m,e[m]=u;for(let _=0,g=o;_!==g;++_){const p=r[_],E=p[m];let S=p[f];p[f]=E,S===void 0&&(S=new gt(u,i[_],n[_])),p[m]=S}}else e[f]!==s&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l},remove:function(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let o=0,s=arguments.length;o!==s;++o){const a=arguments[o],l=a.uuid,c=t[l];if(c!==void 0&&c>=r){const h=r++,u=e[h];t[u.uuid]=c,e[c]=u,t[l]=h,e[h]=a;for(let d=0,f=n;d!==f;++d){const m=i[d],v=m[h],_=m[c];m[c]=v,m[h]=_}}}this.nCachedObjects_=r},uncache:function(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=e.length;for(let s=0,a=arguments.length;s!==a;++s){const l=arguments[s],c=l.uuid,h=t[c];if(h!==void 0)if(delete t[c],h<r){const u=--r,d=e[u],f=--o,m=e[f];t[d.uuid]=h,e[h]=d,t[m.uuid]=u,e[u]=m,e.pop();for(let v=0,_=n;v!==_;++v){const g=i[v],p=g[u],E=g[f];g[h]=p,g[u]=E,g.pop()}}else{const u=--o,d=e[u];u>0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let f=0,m=n;f!==m;++f){const v=i[f];v[h]=v[u],v.pop()}}}this.nCachedObjects_=r},subscribe_:function(e,t){const i=this._bindingsIndicesByPath;let n=i[e];const r=this._bindings;if(n!==void 0)return r[n];const o=this._paths,s=this._parsedPaths,a=this._objects,l=a.length,c=this.nCachedObjects_,h=new Array(l);n=r.length,i[e]=n,o.push(e),s.push(t),r.push(h);for(let u=c,d=a.length;u!==d;++u){const f=a[u];h[u]=new gt(f,e,t)}return h},unsubscribe_:function(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const n=this._paths,r=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s],l=e[s];t[l]=i,o[i]=a,o.pop(),r[i]=r[s],r.pop(),n[i]=n[s],n.pop()}}});class Mg{constructor(t,i,n=null,r=i.blendMode){this._mixer=t,this._clip=i,this._localRoot=n,this.blendMode=r;const o=i.tracks,s=o.length,a=new Array(s),l={endingStart:cn,endingEnd:cn};for(let c=0;c!==s;++c){const h=o[c].createInterpolant(null);a[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=qh,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,i){return this.loop=t,this.repetitions=i,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,i,n){if(t.fadeOut(i),this.fadeIn(i),n){const r=this._clip.duration,o=t._clip.duration,s=o/r,a=r/o;t.warp(1,s,i),this.warp(a,1,i)}return this}crossFadeTo(t,i,n){return t.crossFadeFrom(this,i,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,i,n){const r=this._mixer,o=r.time,s=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=o,l[1]=o+n,c[0]=t/s,c[1]=i/s,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,i,n,r){if(!this.enabled){this._updateWeight(t);return}const o=this._startTime;if(o!==null){const l=(t-o)*n;if(l<0||n===0)return;this._startTime=null,i=n*l}i*=this._updateTimeScale(t);const s=this._updateTime(i),a=this._updateWeight(t);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Oa:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(s),c[h].accumulateAdditive(a);break;case Qo:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(s),c[h].accumulate(r,a)}}}_updateWeight(t){let i=0;if(this.enabled){i=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(t)[0];i*=r,t>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=i,i}_updateTimeScale(t){let i=0;if(!this.paused){i=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(t)[0];i*=r,t>n.parameterPositions[1]&&(this.stopWarping(),i===0?this.paused=!0:this.timeScale=i)}}return this._effectiveTimeScale=i,i}_updateTime(t){const i=this._clip.duration,n=this.loop;let r=this.time+t,o=this._loopCount;const s=n===Qh;if(t===0)return o===-1?r:s&&(o&1)===1?i-r:r;if(n===Yo){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=i)r=i;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(o===-1&&(t>=0?(o=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),r>=i||r<0){const a=Math.floor(r/i);r-=i*a,o+=Math.abs(a);const l=this.repetitions-o;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=t>0?i:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){const c=t<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=o,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(s&&(o&1)===1)return i-r}return r}_setEndings(t,i,n){const r=this._interpolantSettings;n?(r.endingStart=hn,r.endingEnd=hn):(t?r.endingStart=this.zeroSlopeAtStart?hn:cn:r.endingStart=Hr,i?r.endingEnd=this.zeroSlopeAtEnd?hn:cn:r.endingEnd=Hr)}_scheduleFading(t,i,n){const r=this._mixer,o=r.time;let s=this._weightInterpolant;s===null&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,l=s.sampleValues;return a[0]=o,l[0]=i,a[1]=o+t,l[1]=n,this}}function Co(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}Co.prototype=Object.assign(Object.create(ci.prototype),{constructor:Co,_bindAction:function(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,o=e._propertyBindings,s=e._interpolants,a=i.uuid,l=this._bindingsByRootAndName;let c=l[a];c===void 0&&(c={},l[a]=c);for(let h=0;h!==r;++h){const u=n[h],d=u.name;let f=c[d];if(f!==void 0)o[h]=f;else{if(f=o[h],f!==void 0){f._cacheIndex===null&&(++f.referenceCount,this._addInactiveBinding(f,a,d));continue}const m=t&&t._propertyBindings[h].binding.parsedPath;f=new fc(gt.create(i,d,m),u.ValueTypeName,u.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,d),o[h]=f}s[h].resultBuffer=f.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,i)}const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions},_addInactiveAction:function(e,t,i){const n=this._actions,r=this._actionsByClip;let o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const s=o.knownActions;e._byClipCacheIndex=s.length,s.push(e)}e._cacheIndex=n.length,n.push(e),o.actionByRoot[i]=e},_removeInactiveAction:function(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,s=o[r],a=s.knownActions,l=a[a.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,a[c]=l,a.pop(),e._byClipCacheIndex=null;const h=s.actionByRoot,u=(e._localRoot||this._root).uuid;delete h[u],a.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){const t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){const r=t[i];--r.referenceCount===0&&this._removeInactiveBinding(r)}},_lendAction:function(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r},_takeBackAction:function(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r},_addInactiveBinding:function(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let o=n[t];o===void 0&&(o={},n[t]=o),o[i]=e,e._cacheIndex=r.length,r.push(e)},_removeInactiveBinding:function(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,o=this._bindingsByRootAndName,s=o[n],a=t[t.length-1],l=e._cacheIndex;a._cacheIndex=l,t[l]=a,t.pop(),delete s[r],Object.keys(s).length===0&&delete o[n]},_lendBinding:function(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r},_takeBackBinding:function(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r},_lendControlInterpolant:function(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new To(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=t,e[t]=i),i},_takeBackControlInterpolant:function(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,t,i){const n=t||this._root,r=n.uuid;let o=typeof e=="string"?At.findByName(n,e):e;const s=o!==null?o.uuid:e,a=this._actionsByClip[s];let l=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Qo),a!==void 0){const h=a.actionByRoot[r];if(h!==void 0&&h.blendMode===i)return h;l=a.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;const c=new Mg(this,o,t,i);return this._bindAction(c,l),this._addInactiveAction(c,s,r),c},existingAction:function(e,t){const i=t||this._root,n=i.uuid,r=typeof e=="string"?At.findByName(i,e):e,o=r?r.uuid:e,s=this._actionsByClip[o];return s!==void 0&&s.actionByRoot[n]||null},stopAllAction:function(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this},update:function(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(n,e,r,o);const s=this._bindings,a=this._nActiveBindings;for(let l=0;l!==a;++l)s[l].apply(o);return this},setTime:function(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)},getRoot:function(){return this._root},uncacheClip:function(e){const t=this._actions,i=e.uuid,n=this._actionsByClip,r=n[i];if(r!==void 0){const o=r.knownActions;for(let s=0,a=o.length;s!==a;++s){const l=o[s];this._deactivateAction(l);const c=l._cacheIndex,h=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=c,t[c]=h,t.pop(),this._removeInactiveBindingsForAction(l)}delete n[i]}},uncacheRoot:function(e){const t=e.uuid,i=this._actionsByClip;for(const o in i){const s=i[o].actionByRoot,a=s[t];a!==void 0&&(this._deactivateAction(a),this._removeInactiveAction(a))}const n=this._bindingsByRootAndName,r=n[t];if(r!==void 0)for(const o in r){const s=r[o];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}});function gc(e,t,i){Pt.call(this,e,t),this.meshPerAttribute=i||1}gc.prototype=Object.assign(Object.create(Pt.prototype),{constructor:gc,isInstancedInterleavedBuffer:!0,copy:function(e){return Pt.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},clone:function(e){const t=Pt.prototype.clone.call(this,e);return t.meshPerAttribute=this.meshPerAttribute,t},toJSON:function(e){const t=Pt.prototype.toJSON.call(this,e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}});function vc(e,t,i,n,r){this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}Object.defineProperty(vc.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(vc.prototype,{isGLBufferAttribute:!0,setBuffer:function(e){return this.buffer=e,this},setType:function(e,t){return this.type=e,this.elementSize=t,this},setItemSize:function(e){return this.itemSize=e,this},setCount:function(e){return this.count=e,this}});function _c(e,t,i,n){this.ray=new qi(e,t),this.near=i||0,this.far=n||1/0,this.camera=null,this.layers=new Ba,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function xc(e,t){return e.distance-t.distance}function na(e,t,i,n){if(e.layers.test(t.layers)&&e.raycast(t,i),n===!0){const r=e.children;for(let o=0,s=r.length;o<s;o++)na(r[o],t,i,!0)}}Object.assign(_c.prototype,{set:function(e,t){this.ray.set(e,t)},setFromCamera:function(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)},intersectObject:function(e,t,i){const n=i||[];return na(e,this,n,t),n.sort(xc),n},intersectObjects:function(e,t,i){const n=i||[];if(Array.isArray(e)===!1)return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),n;for(let r=0,o=e.length;r<o;r++)na(e[r],this,n,t);return n.sort(xc),n}});const yc=new le;class Tg{constructor(t,i){Object.defineProperty(this,"isBox2",{value:!0}),this.min=t!==void 0?t:new le(1/0,1/0),this.max=i!==void 0?i:new le(-1/0,-1/0)}set(t,i){return this.min.copy(t),this.max.copy(i),this}setFromPoints(t){this.makeEmpty();for(let i=0,n=t.length;i<n;i++)this.expandByPoint(t[i]);return this}setFromCenterAndSize(t,i){const n=yc.copy(i).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 t===void 0&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new le),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return t===void 0&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new le),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,i){return i===void 0&&(console.warn("THREE.Box2: .getParameter() target is now required"),i=new le),i.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,i){return i===void 0&&(console.warn("THREE.Box2: .clampPoint() target is now required"),i=new le),i.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return yc.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),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)}}function No(e){we.call(this),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}No.prototype=Object.create(we.prototype),No.prototype.constructor=No,No.prototype.isImmediateRenderObject=!0;const ki=new A,Io=new Re,ra=new Re;class Ag extends Mr{constructor(t){const i=bc(t),n=new De,r=[],o=[],s=new he(0,0,1),a=new he(0,1,0);for(let c=0;c<i.length;c++){const h=i[c];h.parent&&h.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),o.push(s.r,s.g,s.b),o.push(a.r,a.g,a.b))}n.setAttribute("position",new Fe(r,3)),n.setAttribute("color",new Fe(o,3));const l=new Rt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=t,this.bones=i,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const i=this.bones,n=this.geometry,r=n.getAttribute("position");ra.copy(this.root.matrixWorld).invert();for(let o=0,s=0;o<i.length;o++){const a=i[o];a.parent&&a.parent.isBone&&(Io.multiplyMatrices(ra,a.matrixWorld),ki.setFromMatrixPosition(Io),r.setXYZ(s,ki.x,ki.y,ki.z),Io.multiplyMatrices(ra,a.parent.matrixWorld),ki.setFromMatrixPosition(Io),r.setXYZ(s+1,ki.x,ki.y,ki.z),s+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}}function bc(e){const t=[];e&&e.isBone&&t.push(e);for(let i=0;i<e.children.length;i++)t.push.apply(t,bc(e.children[i]));return t}class Sg extends Mr{constructor(t=10,i=10,n=4473924,r=8947848){n=new he(n),r=new he(r);const o=i/2,s=t/i,a=t/2,l=[],c=[];for(let d=0,f=0,m=-a;d<=i;d++,m+=s){l.push(-a,0,m,a,0,m),l.push(m,0,-a,m,0,a);const v=d===o?n:r;v.toArray(c,f),f+=3,v.toArray(c,f),f+=3,v.toArray(c,f),f+=3,v.toArray(c,f),f+=3}const h=new De;h.setAttribute("position",new Fe(l,3)),h.setAttribute("color",new Fe(c,3));const u=new Rt({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}}const Eg=new Float32Array(1);new Int32Array(Eg.buffer);const Lg=new vt({side:Ze,depthWrite:!1,depthTest:!1});new Oe(new gi,Lg),xe.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(xe.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(ri.prototype,{fromPoints:function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)}}),Object.create(Ct.prototype),Object.create(Ct.prototype);function wc(e){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Ct.call(this,e),this.type="catmullrom"}wc.prototype=Object.create(Ct.prototype),Object.assign(wc.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),Sg.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},Ag.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(Ue.prototype,{extractUrlBase:function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Yn.extractUrlBase(e)}}),Ue.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(Tg.prototype,{center:function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},size:function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(dt.prototype,{center:function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionSphere:function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},size:function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)}}),Object.assign(Zt.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}}),lo.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Object.assign(Se,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(e){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),Se.floorPowerOfTwo(e)},nextPowerOfTwo:function(e){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),Se.ceilPowerOfTwo(e)}}),Object.assign(Ft.prototype,{flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},multiplyVector3:function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},getInverse:function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()}}),Object.assign(Re.prototype,{extractPosition:function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},flattenToArrayOffset:function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new A().setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector4:function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},crossVector:function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(e,t,i,n,r,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,n,i,r,o)},getInverse:function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()}}),pi.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},Object.assign(tt.prototype,{multiplyVector3:function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},inverse:function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()}}),Object.assign(qi.prototype,{isIntersectionBox:function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},isIntersectionPlane:function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},isIntersectionSphere:function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}),Object.assign(xt.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},midpoint:function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},normal:function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},plane:function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)}}),Object.assign(xt,{barycoordFromPoint:function(e,t,i,n,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),xt.getBarycoord(e,t,i,n,r)},normal:function(e,t,i,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),xt.getNormal(e,t,i,n)}}),Object.assign(jn.prototype,{extractAllPoints:function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},extrude:function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Zl(this,e)},makeGeometry:function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Xm(this,e)}}),Object.assign(le.prototype,{fromAttribute:function(e,t,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(A.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},applyProjection:function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},fromAttribute:function(e,t,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},distanceToManhattan:function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(ke.prototype,{fromAttribute:function(e,t,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(we.prototype,{getChildByName:function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(we.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(Oe.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(Oe.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),Zh},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(Ps.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(go.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),fo.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(xe.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),$e.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),t!==void 0&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Ge.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(Le.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===ar},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(ar)}}}),Object.assign(Le.prototype,{setDynamic:function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(e===!0?ar:Br),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(De.prototype,{addIndex:function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},addAttribute:function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(t&&t.isBufferAttribute)&&!(t&&t.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new Le(arguments[1],arguments[2]))):e==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t)},addDrawCall:function(e,t,i){i!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},applyMatrix:function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}}),Object.defineProperties(De.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(Po.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(e){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=e}}}),Object.defineProperties(_c.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(e){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=e}}}),Object.defineProperties(Pt.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===ar},set:function(e){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(e)}}}),Object.assign(Pt.prototype,{setDynamic:function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(e===!0?ar:Br),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(Zl.prototype,{getArrays:function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")}}),Object.assign(Es.prototype,{dispose:function(){console.error("THREE.Scene: .dispose() has been removed.")}}),Object.defineProperties(Me.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new he}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=e===pa}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(en.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(vi.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(e){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=e}}}),Object.defineProperties(Qe.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.assign(_r.prototype,{clearTarget:function(e,t,i,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,i,n)},animate:function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(_r.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=e===!0?Vi:sr}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(yl.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(ji.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),An.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},An.prototype.clear=function(e,t,i,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,i,n)},dn.crossOrigin=void 0,dn.loadTexture=function(e,t,i,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new Wn;r.setCrossOrigin(this.crossOrigin);const o=r.load(e,i,void 0,n);return t&&(o.mapping=t),o},dn.loadTextureCube=function(e,t,i,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new So;r.setCrossOrigin(this.crossOrigin);const o=r.load(e,i,void 0,n);return t&&(o.mapping=t),o},dn.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},dn.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ca}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ca);var Mc={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = uv;"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join(`
  2801. `),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {"," vec4 texel = texture2D( tDiffuse, vUv );"," gl_FragColor = opacity * texel;","}"].join(`
  2802. `)};function qt(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}Object.assign(qt.prototype,{setSize:function(){},render:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}),qt.FullScreenQuad=function(){var e=new Xn(-1,1,1,-1,0,1),t=new Kt(2,2),i=function(n){this._mesh=new Oe(t,n)};return Object.defineProperty(i.prototype,"material",{get:function(){return this._mesh.material},set:function(n){this._mesh.material=n}}),Object.assign(i.prototype,{dispose:function(){this._mesh.geometry.dispose()},render:function(n){n.render(this._mesh,e)}}),i}();var qn=function(e,t){qt.call(this),this.textureID=t!==void 0?t:"tDiffuse",e instanceof Qe?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Ja.clone(e.uniforms),this.material=new Qe({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new qt.FullScreenQuad(this.material)};qn.prototype=Object.assign(Object.create(qt.prototype),{constructor:qn,render:function(e,t,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}});var Fo=function(e,t){qt.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1};Fo.prototype=Object.assign(Object.create(qt.prototype),{constructor:Fo,render:function(e,t,i){var n=e.getContext(),r=e.state;r.buffers.color.setMask(!1),r.buffers.depth.setMask(!1),r.buffers.color.setLocked(!0),r.buffers.depth.setLocked(!0);var o,s;this.inverse?(o=0,s=1):(o=1,s=0),r.buffers.stencil.setTest(!0),r.buffers.stencil.setOp(n.REPLACE,n.REPLACE,n.REPLACE),r.buffers.stencil.setFunc(n.ALWAYS,o,4294967295),r.buffers.stencil.setClear(s),r.buffers.stencil.setLocked(!0),e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),r.buffers.color.setLocked(!1),r.buffers.depth.setLocked(!1),r.buffers.stencil.setLocked(!1),r.buffers.stencil.setFunc(n.EQUAL,1,4294967295),r.buffers.stencil.setOp(n.KEEP,n.KEEP,n.KEEP),r.buffers.stencil.setLocked(!0)}});var oa=function(){qt.call(this),this.needsSwap=!1};oa.prototype=Object.create(qt.prototype),Object.assign(oa.prototype,{render:function(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}});var Tc=function(e,t){if(this.renderer=e,t===void 0){var i={minFilter:qe,magFilter:qe,format:wt},n=e.getSize(new le);this._pixelRatio=e.getPixelRatio(),this._width=n.width,this._height=n.height,t=new ji(this._width*this._pixelRatio,this._height*this._pixelRatio,i),t.texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],Mc===void 0&&console.error("THREE.EffectComposer relies on CopyShader"),qn===void 0&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new qn(Mc),this.clock=new pg};Object.assign(Tc.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)},insertPass:function(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)},removePass:function(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)},isLastEnabledPass:function(e){for(var t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0},render:function(e){e===void 0&&(e=this.clock.getDelta());var t=this.renderer.getRenderTarget(),i=!1,n,r,o=this.passes.length;for(r=0;r<o;r++)if(n=this.passes[r],n.enabled!==!1){if(n.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),n.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),n.needsSwap){if(i){var s=this.renderer.getContext(),a=this.renderer.state.buffers.stencil;a.setFunc(s.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),a.setFunc(s.EQUAL,1,4294967295)}this.swapBuffers()}Fo!==void 0&&(n instanceof Fo?i=!0:n instanceof oa&&(i=!1))}this.renderer.setRenderTarget(t)},reset:function(e){if(e===void 0){var t=this.renderer.getSize(new le);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(e,t){this._width=e,this._height=t;var i=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(i,n),this.renderTarget2.setSize(i,n);for(var r=0;r<this.passes.length;r++)this.passes[r].setSize(i,n)},setPixelRatio:function(e){this._pixelRatio=e,this.setSize(this._width,this._height)}});var Ac=function(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1};Object.assign(Ac.prototype,{setSize:function(){},render:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}),Ac.FullScreenQuad=function(){var e=new Xn(-1,1,1,-1,0,1),t=new Kt(2,2),i=function(n){this._mesh=new Oe(t,n)};return Object.defineProperty(i.prototype,"material",{get:function(){return this._mesh.material},set:function(n){this._mesh.material=n}}),Object.assign(i.prototype,{dispose:function(){this._mesh.geometry.dispose()},render:function(n){n.render(this._mesh,e)}}),i}();var Oo=function(e,t,i,n,r){qt.call(this),this.scene=e,this.camera=t,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=r!==void 0?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new he};Oo.prototype=Object.assign(Object.create(qt.prototype),{constructor:Oo,render:function(e,t,i){var n=e.autoClear;e.autoClear=!1;var r,o;this.overrideMaterial!==void 0&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this._oldClearColor),r=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:i),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(this._oldClearColor,r),this.overrideMaterial!==void 0&&(this.scene.overrideMaterial=o),e.autoClear=n}});var Pg={uniforms:{tDiffuse:{value:null}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = uv;"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join(`
  2803. `),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {"," vec4 tex = texture2D( tDiffuse, vUv );"," gl_FragColor = LinearTosRGB( tex );","}"].join(`
  2804. `)},Rg={uniforms:{tDiffuse:{value:null},resolution:{value:new le(1/1024,1/512)}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = uv;"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join(`
  2805. `),fragmentShader:["precision highp float;","","uniform sampler2D tDiffuse;","","uniform vec2 resolution;","","varying vec2 vUv;","","// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro ([email protected])","","//----------------------------------------------------------------------------------","// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag","// SDK Version: v3.00","// Email: [email protected]","// Site: http://developer.nvidia.com/","//","// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.","//","// Redistribution and use in source and binary forms, with or without","// modification, are permitted provided that the following conditions","// are met:","// * Redistributions of source code must retain the above copyright","// notice, this list of conditions and the following disclaimer.","// * Redistributions in binary form must reproduce the above copyright","// notice, this list of conditions and the following disclaimer in the","// documentation and/or other materials provided with the distribution.","// * Neither the name of NVIDIA CORPORATION nor the names of its","// contributors may be used to endorse or promote products derived","// from this software without specific prior written permission.","//","// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY","// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE","// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR","// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR","// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,","// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,","// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR","// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY","// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT","// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE","// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.","//","//----------------------------------------------------------------------------------","","#define FXAA_PC 1","#define FXAA_GLSL_100 1","#define FXAA_QUALITY_PRESET 12","","#define FXAA_GREEN_AS_LUMA 1","","/*--------------------------------------------------------------------------*/","#ifndef FXAA_PC_CONSOLE"," //"," // The console algorithm for PC is included"," // for developers targeting really low spec machines."," // Likely better to just run FXAA_PC, and use a really low preset."," //"," #define FXAA_PC_CONSOLE 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_GLSL_120"," #define FXAA_GLSL_120 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_GLSL_130"," #define FXAA_GLSL_130 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_HLSL_3"," #define FXAA_HLSL_3 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_HLSL_4"," #define FXAA_HLSL_4 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_HLSL_5"," #define FXAA_HLSL_5 0","#endif","/*==========================================================================*/","#ifndef FXAA_GREEN_AS_LUMA"," //"," // For those using non-linear color,"," // and either not able to get luma in alpha, or not wanting to,"," // this enables FXAA to run using green as a proxy for luma."," // So with this enabled, no need to pack luma in alpha."," //"," // This will turn off AA on anything which lacks some amount of green."," // Pure red and blue or combination of only R and B, will get no AA."," //"," // Might want to lower the settings for both,"," // fxaaConsoleEdgeThresholdMin"," // fxaaQualityEdgeThresholdMin"," // In order to insure AA does not get turned off on colors"," // which contain a minor amount of green."," //"," // 1 = On."," // 0 = Off."," //"," #define FXAA_GREEN_AS_LUMA 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_EARLY_EXIT"," //"," // Controls algorithm's early exit path."," // On PS3 turning this ON adds 2 cycles to the shader."," // On 360 turning this OFF adds 10ths of a millisecond to the shader."," // Turning this off on console will result in a more blurry image."," // So this defaults to on."," //"," // 1 = On."," // 0 = Off."," //"," #define FXAA_EARLY_EXIT 1","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_DISCARD"," //"," // Only valid for PC OpenGL currently."," // Probably will not work when FXAA_GREEN_AS_LUMA = 1."," //"," // 1 = Use discard on pixels which don't need AA."," // For APIs which enable concurrent TEX+ROP from same surface."," // 0 = Return unchanged color on pixels which don't need AA."," //"," #define FXAA_DISCARD 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_FAST_PIXEL_OFFSET"," //"," // Used for GLSL 120 only."," //"," // 1 = GL API supports fast pixel offsets"," // 0 = do not use fast pixel offsets"," //"," #ifdef GL_EXT_gpu_shader4"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifdef GL_NV_gpu_shader5"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifdef GL_ARB_gpu_shader5"," #define FXAA_FAST_PIXEL_OFFSET 1"," #endif"," #ifndef FXAA_FAST_PIXEL_OFFSET"," #define FXAA_FAST_PIXEL_OFFSET 0"," #endif","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_GATHER4_ALPHA"," //"," // 1 = API supports gather4 on alpha channel."," // 0 = API does not support gather4 on alpha channel."," //"," #if (FXAA_HLSL_5 == 1)"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifdef GL_ARB_gpu_shader5"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifdef GL_NV_gpu_shader5"," #define FXAA_GATHER4_ALPHA 1"," #endif"," #ifndef FXAA_GATHER4_ALPHA"," #define FXAA_GATHER4_ALPHA 0"," #endif","#endif","","","/*============================================================================"," FXAA QUALITY - TUNING KNOBS","------------------------------------------------------------------------------","NOTE the other tuning knobs are now in the shader function inputs!","============================================================================*/","#ifndef FXAA_QUALITY_PRESET"," //"," // Choose the quality preset."," // This needs to be compiled into the shader as it effects code."," // Best option to include multiple presets is to"," // in each shader define the preset, then include this file."," //"," // OPTIONS"," // -----------------------------------------------------------------------"," // 10 to 15 - default medium dither (10=fastest, 15=highest quality)"," // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)"," // 39 - no dither, very expensive"," //"," // NOTES"," // -----------------------------------------------------------------------"," // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)"," // 13 = about same speed as FXAA 3.9 and better than 12"," // 23 = closest to FXAA 3.9 visually and performance wise"," // _ = the lowest digit is directly related to performance"," // _ = the highest digit is directly related to style"," //"," #define FXAA_QUALITY_PRESET 12","#endif","","","/*============================================================================",""," FXAA QUALITY - PRESETS","","============================================================================*/","","/*============================================================================"," FXAA QUALITY - MEDIUM DITHER PRESETS","============================================================================*/","#if (FXAA_QUALITY_PRESET == 10)"," #define FXAA_QUALITY_PS 3"," #define FXAA_QUALITY_P0 1.5"," #define FXAA_QUALITY_P1 3.0"," #define FXAA_QUALITY_P2 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 11)"," #define FXAA_QUALITY_PS 4"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 3.0"," #define FXAA_QUALITY_P3 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 12)"," #define FXAA_QUALITY_PS 5"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 4.0"," #define FXAA_QUALITY_P4 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 13)"," #define FXAA_QUALITY_PS 6"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 4.0"," #define FXAA_QUALITY_P5 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 14)"," #define FXAA_QUALITY_PS 7"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 4.0"," #define FXAA_QUALITY_P6 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 15)"," #define FXAA_QUALITY_PS 8"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 4.0"," #define FXAA_QUALITY_P7 12.0","#endif","","/*============================================================================"," FXAA QUALITY - LOW DITHER PRESETS","============================================================================*/","#if (FXAA_QUALITY_PRESET == 20)"," #define FXAA_QUALITY_PS 3"," #define FXAA_QUALITY_P0 1.5"," #define FXAA_QUALITY_P1 2.0"," #define FXAA_QUALITY_P2 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 21)"," #define FXAA_QUALITY_PS 4"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 22)"," #define FXAA_QUALITY_PS 5"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 23)"," #define FXAA_QUALITY_PS 6"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 24)"," #define FXAA_QUALITY_PS 7"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 3.0"," #define FXAA_QUALITY_P6 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 25)"," #define FXAA_QUALITY_PS 8"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 4.0"," #define FXAA_QUALITY_P7 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 26)"," #define FXAA_QUALITY_PS 9"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 4.0"," #define FXAA_QUALITY_P8 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 27)"," #define FXAA_QUALITY_PS 10"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 4.0"," #define FXAA_QUALITY_P9 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 28)"," #define FXAA_QUALITY_PS 11"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 4.0"," #define FXAA_QUALITY_P10 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 29)"," #define FXAA_QUALITY_PS 12"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.5"," #define FXAA_QUALITY_P2 2.0"," #define FXAA_QUALITY_P3 2.0"," #define FXAA_QUALITY_P4 2.0"," #define FXAA_QUALITY_P5 2.0"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 2.0"," #define FXAA_QUALITY_P10 4.0"," #define FXAA_QUALITY_P11 8.0","#endif","","/*============================================================================"," FXAA QUALITY - EXTREME QUALITY","============================================================================*/","#if (FXAA_QUALITY_PRESET == 39)"," #define FXAA_QUALITY_PS 12"," #define FXAA_QUALITY_P0 1.0"," #define FXAA_QUALITY_P1 1.0"," #define FXAA_QUALITY_P2 1.0"," #define FXAA_QUALITY_P3 1.0"," #define FXAA_QUALITY_P4 1.0"," #define FXAA_QUALITY_P5 1.5"," #define FXAA_QUALITY_P6 2.0"," #define FXAA_QUALITY_P7 2.0"," #define FXAA_QUALITY_P8 2.0"," #define FXAA_QUALITY_P9 2.0"," #define FXAA_QUALITY_P10 4.0"," #define FXAA_QUALITY_P11 8.0","#endif","","","","/*============================================================================",""," API PORTING","","============================================================================*/","#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)"," #define FxaaBool bool"," #define FxaaDiscard discard"," #define FxaaFloat float"," #define FxaaFloat2 vec2"," #define FxaaFloat3 vec3"," #define FxaaFloat4 vec4"," #define FxaaHalf float"," #define FxaaHalf2 vec2"," #define FxaaHalf3 vec3"," #define FxaaHalf4 vec4"," #define FxaaInt2 ivec2"," #define FxaaSat(x) clamp(x, 0.0, 1.0)"," #define FxaaTex sampler2D","#else"," #define FxaaBool bool"," #define FxaaDiscard clip(-1)"," #define FxaaFloat float"," #define FxaaFloat2 float2"," #define FxaaFloat3 float3"," #define FxaaFloat4 float4"," #define FxaaHalf half"," #define FxaaHalf2 half2"," #define FxaaHalf3 half3"," #define FxaaHalf4 half4"," #define FxaaSat(x) saturate(x)","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_GLSL_100 == 1)"," #define FxaaTexTop(t, p) texture2D(t, p, 0.0)"," #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_GLSL_120 == 1)"," // Requires,"," // #version 120"," // And at least,"," // #extension GL_EXT_gpu_shader4 : enable"," // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)"," #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)"," #if (FXAA_FAST_PIXEL_OFFSET == 1)"," #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)"," #else"," #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)"," #endif"," #if (FXAA_GATHER4_ALPHA == 1)"," // use #extension GL_ARB_gpu_shader5 : enable"," #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)"," #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)"," #define FxaaTexGreen4(t, p) textureGather(t, p, 1)"," #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)"," #endif","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_GLSL_130 == 1)",' // Requires "#version 130" or better'," #define FxaaTexTop(t, p) textureLod(t, p, 0.0)"," #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)"," #if (FXAA_GATHER4_ALPHA == 1)"," // use #extension GL_ARB_gpu_shader5 : enable"," #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)"," #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)"," #define FxaaTexGreen4(t, p) textureGather(t, p, 1)"," #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)"," #endif","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_HLSL_3 == 1)"," #define FxaaInt2 float2"," #define FxaaTex sampler2D"," #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))"," #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_HLSL_4 == 1)"," #define FxaaInt2 int2"," struct FxaaTex { SamplerState smpl; Texture2D tex; };"," #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)"," #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_HLSL_5 == 1)"," #define FxaaInt2 int2"," struct FxaaTex { SamplerState smpl; Texture2D tex; };"," #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)"," #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)"," #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)"," #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)"," #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)"," #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)","#endif","","","/*============================================================================"," GREEN AS LUMA OPTION SUPPORT FUNCTION","============================================================================*/","#if (FXAA_GREEN_AS_LUMA == 0)"," FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }","#else"," FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }","#endif","","","","","/*============================================================================",""," FXAA3 QUALITY - PC","","============================================================================*/","#if (FXAA_PC == 1)","/*--------------------------------------------------------------------------*/","FxaaFloat4 FxaaPixelShader("," //"," // Use noperspective interpolation here (turn off perspective interpolation)."," // {xy} = center of pixel"," FxaaFloat2 pos,"," //"," // Used only for FXAA Console, and not used on the 360 version."," // Use noperspective interpolation here (turn off perspective interpolation)."," // {xy_} = upper left of pixel"," // {_zw} = lower right of pixel"," FxaaFloat4 fxaaConsolePosPos,"," //"," // Input color texture."," // {rgb_} = color in linear or perceptual color space"," // if (FXAA_GREEN_AS_LUMA == 0)"," // {__a} = luma in perceptual color space (not linear)"," FxaaTex tex,"," //"," // Only used on the optimized 360 version of FXAA Console.",' // For everything but 360, just use the same input here as for "tex".'," // For 360, same texture, just alias with a 2nd sampler."," // This sampler needs to have an exponent bias of -1."," FxaaTex fxaaConsole360TexExpBiasNegOne,"," //"," // Only used on the optimized 360 version of FXAA Console.",' // For everything but 360, just use the same input here as for "tex".'," // For 360, same texture, just alias with a 3nd sampler."," // This sampler needs to have an exponent bias of -2."," FxaaTex fxaaConsole360TexExpBiasNegTwo,"," //"," // Only used on FXAA Quality."," // This must be from a constant/uniform."," // {x_} = 1.0/screenWidthInPixels"," // {_y} = 1.0/screenHeightInPixels"," FxaaFloat2 fxaaQualityRcpFrame,"," //"," // Only used on FXAA Console."," // This must be from a constant/uniform."," // This effects sub-pixel AA quality and inversely sharpness."," // Where N ranges between,"," // N = 0.50 (default)"," // N = 0.33 (sharper)"," // {x__} = -N/screenWidthInPixels"," // {_y_} = -N/screenHeightInPixels"," // {_z_} = N/screenWidthInPixels"," // {__w} = N/screenHeightInPixels"," FxaaFloat4 fxaaConsoleRcpFrameOpt,"," //"," // Only used on FXAA Console."," // Not used on 360, but used on PS3 and PC."," // This must be from a constant/uniform."," // {x__} = -2.0/screenWidthInPixels"," // {_y_} = -2.0/screenHeightInPixels"," // {_z_} = 2.0/screenWidthInPixels"," // {__w} = 2.0/screenHeightInPixels"," FxaaFloat4 fxaaConsoleRcpFrameOpt2,"," //"," // Only used on FXAA Console."," // Only used on 360 in place of fxaaConsoleRcpFrameOpt2."," // This must be from a constant/uniform."," // {x__} = 8.0/screenWidthInPixels"," // {_y_} = 8.0/screenHeightInPixels"," // {_z_} = -4.0/screenWidthInPixels"," // {__w} = -4.0/screenHeightInPixels"," FxaaFloat4 fxaaConsole360RcpFrameOpt2,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_SUBPIX define."," // It is here now to allow easier tuning."," // Choose the amount of sub-pixel aliasing removal."," // This can effect sharpness."," // 1.00 - upper limit (softer)"," // 0.75 - default amount of filtering"," // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)"," // 0.25 - almost off"," // 0.00 - completely off"," FxaaFloat fxaaQualitySubpix,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define."," // It is here now to allow easier tuning."," // The minimum amount of local contrast required to apply algorithm."," // 0.333 - too little (faster)"," // 0.250 - low quality"," // 0.166 - default"," // 0.125 - high quality"," // 0.063 - overkill (slower)"," FxaaFloat fxaaQualityEdgeThreshold,"," //"," // Only used on FXAA Quality."," // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define."," // It is here now to allow easier tuning."," // Trims the algorithm from processing darks."," // 0.0833 - upper limit (default, the start of visible unfiltered edges)"," // 0.0625 - high quality (faster)"," // 0.0312 - visible limit (slower)"," // Special notes when using FXAA_GREEN_AS_LUMA,"," // Likely want to set this to zero."," // As colors that are mostly not-green"," // will appear very dark in the green channel!"," // Tune by looking at mostly non-green content,"," // then start at zero and increase until aliasing is a problem."," FxaaFloat fxaaQualityEdgeThresholdMin,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define."," // It is here now to allow easier tuning."," // This does not effect PS3, as this needs to be compiled in."," // Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3."," // Due to the PS3 being ALU bound,"," // there are only three safe values here: 2 and 4 and 8."," // These options use the shaders ability to a free *|/ by 2|4|8."," // For all other platforms can be a non-power of two."," // 8.0 is sharper (default!!!)"," // 4.0 is softer"," // 2.0 is really soft (good only for vector graphics inputs)"," FxaaFloat fxaaConsoleEdgeSharpness,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define."," // It is here now to allow easier tuning."," // This does not effect PS3, as this needs to be compiled in."," // Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3."," // Due to the PS3 being ALU bound,"," // there are only two safe values here: 1/4 and 1/8."," // These options use the shaders ability to a free *|/ by 2|4|8."," // The console setting has a different mapping than the quality setting."," // Other platforms can use other values."," // 0.125 leaves less aliasing, but is softer (default!!!)"," // 0.25 leaves more aliasing, and is sharper"," FxaaFloat fxaaConsoleEdgeThreshold,"," //"," // Only used on FXAA Console."," // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define."," // It is here now to allow easier tuning."," // Trims the algorithm from processing darks."," // The console setting has a different mapping than the quality setting."," // This only applies when FXAA_EARLY_EXIT is 1."," // This does not apply to PS3,"," // PS3 was simplified to avoid more shader instructions."," // 0.06 - faster but more aliasing in darks"," // 0.05 - default"," // 0.04 - slower and less aliasing in darks"," // Special notes when using FXAA_GREEN_AS_LUMA,"," // Likely want to set this to zero."," // As colors that are mostly not-green"," // will appear very dark in the green channel!"," // Tune by looking at mostly non-green content,"," // then start at zero and increase until aliasing is a problem."," FxaaFloat fxaaConsoleEdgeThresholdMin,"," //"," // Extra constants for 360 FXAA Console only."," // Use zeros or anything else for other platforms."," // These must be in physical constant registers and NOT immediates."," // Immediates will result in compiler un-optimizing."," // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)"," FxaaFloat4 fxaaConsole360ConstDir",") {","/*--------------------------------------------------------------------------*/"," FxaaFloat2 posM;"," posM.x = pos.x;"," posM.y = pos.y;"," #if (FXAA_GATHER4_ALPHA == 1)"," #if (FXAA_DISCARD == 0)"," FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);"," #if (FXAA_GREEN_AS_LUMA == 0)"," #define lumaM rgbyM.w"," #else"," #define lumaM rgbyM.y"," #endif"," #endif"," #if (FXAA_GREEN_AS_LUMA == 0)"," FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);"," FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));"," #else"," FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);"," FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));"," #endif"," #if (FXAA_DISCARD == 1)"," #define lumaM luma4A.w"," #endif"," #define lumaE luma4A.z"," #define lumaS luma4A.x"," #define lumaSE luma4A.y"," #define lumaNW luma4B.w"," #define lumaN luma4B.z"," #define lumaW luma4B.x"," #else"," FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);"," #if (FXAA_GREEN_AS_LUMA == 0)"," #define lumaM rgbyM.w"," #else"," #define lumaM rgbyM.y"," #endif"," #if (FXAA_GLSL_100 == 1)"," FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));"," #else"," FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));"," #endif"," #endif","/*--------------------------------------------------------------------------*/"," FxaaFloat maxSM = max(lumaS, lumaM);"," FxaaFloat minSM = min(lumaS, lumaM);"," FxaaFloat maxESM = max(lumaE, maxSM);"," FxaaFloat minESM = min(lumaE, minSM);"," FxaaFloat maxWN = max(lumaN, lumaW);"," FxaaFloat minWN = min(lumaN, lumaW);"," FxaaFloat rangeMax = max(maxWN, maxESM);"," FxaaFloat rangeMin = min(minWN, minESM);"," FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;"," FxaaFloat range = rangeMax - rangeMin;"," FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);"," FxaaBool earlyExit = range < rangeMaxClamped;","/*--------------------------------------------------------------------------*/"," if(earlyExit)"," #if (FXAA_DISCARD == 1)"," FxaaDiscard;"," #else"," return rgbyM;"," #endif","/*--------------------------------------------------------------------------*/"," #if (FXAA_GATHER4_ALPHA == 0)"," #if (FXAA_GLSL_100 == 1)"," FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));"," #else"," FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));"," #endif"," #else"," FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));"," FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));"," #endif","/*--------------------------------------------------------------------------*/"," FxaaFloat lumaNS = lumaN + lumaS;"," FxaaFloat lumaWE = lumaW + lumaE;"," FxaaFloat subpixRcpRange = 1.0/range;"," FxaaFloat subpixNSWE = lumaNS + lumaWE;"," FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;"," FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;","/*--------------------------------------------------------------------------*/"," FxaaFloat lumaNESE = lumaNE + lumaSE;"," FxaaFloat lumaNWNE = lumaNW + lumaNE;"," FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;"," FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;","/*--------------------------------------------------------------------------*/"," FxaaFloat lumaNWSW = lumaNW + lumaSW;"," FxaaFloat lumaSWSE = lumaSW + lumaSE;"," FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);"," FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);"," FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;"," FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;"," FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;"," FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;","/*--------------------------------------------------------------------------*/"," FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;"," FxaaFloat lengthSign = fxaaQualityRcpFrame.x;"," FxaaBool horzSpan = edgeHorz >= edgeVert;"," FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;","/*--------------------------------------------------------------------------*/"," if(!horzSpan) lumaN = lumaW;"," if(!horzSpan) lumaS = lumaE;"," if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;"," FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;","/*--------------------------------------------------------------------------*/"," FxaaFloat gradientN = lumaN - lumaM;"," FxaaFloat gradientS = lumaS - lumaM;"," FxaaFloat lumaNN = lumaN + lumaM;"," FxaaFloat lumaSS = lumaS + lumaM;"," FxaaBool pairN = abs(gradientN) >= abs(gradientS);"," FxaaFloat gradient = max(abs(gradientN), abs(gradientS));"," if(pairN) lengthSign = -lengthSign;"," FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);","/*--------------------------------------------------------------------------*/"," FxaaFloat2 posB;"," posB.x = posM.x;"," posB.y = posM.y;"," FxaaFloat2 offNP;"," offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;"," offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;"," if(!horzSpan) posB.x += lengthSign * 0.5;"," if( horzSpan) posB.y += lengthSign * 0.5;","/*--------------------------------------------------------------------------*/"," FxaaFloat2 posN;"," posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;"," posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;"," FxaaFloat2 posP;"," posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;"," posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;"," FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;"," FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));"," FxaaFloat subpixE = subpixC * subpixC;"," FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));","/*--------------------------------------------------------------------------*/"," if(!pairN) lumaNN = lumaSS;"," FxaaFloat gradientScaled = gradient * 1.0/4.0;"," FxaaFloat lumaMM = lumaM - lumaNN * 0.5;"," FxaaFloat subpixF = subpixD * subpixE;"," FxaaBool lumaMLTZero = lumaMM < 0.0;","/*--------------------------------------------------------------------------*/"," lumaEndN -= lumaNN * 0.5;"," lumaEndP -= lumaNN * 0.5;"," FxaaBool doneN = abs(lumaEndN) >= gradientScaled;"," FxaaBool doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;"," FxaaBool doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;","/*--------------------------------------------------------------------------*/"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 3)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 4)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 5)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 6)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 7)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 8)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 9)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 10)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 11)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;","/*--------------------------------------------------------------------------*/"," #if (FXAA_QUALITY_PS > 12)"," if(doneNP) {"," if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));"," if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));"," if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;"," if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;"," doneN = abs(lumaEndN) >= gradientScaled;"," doneP = abs(lumaEndP) >= gradientScaled;"," if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;"," if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;"," doneNP = (!doneN) || (!doneP);"," if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;"," if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }"," #endif","/*--------------------------------------------------------------------------*/"," }","/*--------------------------------------------------------------------------*/"," FxaaFloat dstN = posM.x - posN.x;"," FxaaFloat dstP = posP.x - posM.x;"," if(!horzSpan) dstN = posM.y - posN.y;"," if(!horzSpan) dstP = posP.y - posM.y;","/*--------------------------------------------------------------------------*/"," FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;"," FxaaFloat spanLength = (dstP + dstN);"," FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;"," FxaaFloat spanLengthRcp = 1.0/spanLength;","/*--------------------------------------------------------------------------*/"," FxaaBool directionN = dstN < dstP;"," FxaaFloat dst = min(dstN, dstP);"," FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;"," FxaaFloat subpixG = subpixF * subpixF;"," FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;"," FxaaFloat subpixH = subpixG * fxaaQualitySubpix;","/*--------------------------------------------------------------------------*/"," FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;"," FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);"," if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;"," if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;"," #if (FXAA_DISCARD == 1)"," return FxaaTexTop(tex, posM);"," #else"," return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);"," #endif","}","/*==========================================================================*/","#endif","","void main() {"," gl_FragColor = FxaaPixelShader("," vUv,"," vec4(0.0),"," tDiffuse,"," tDiffuse,"," tDiffuse,"," resolution,"," vec4(0.0),"," vec4(0.0),"," vec4(0.0),"," 0.75,"," 0.166,"," 0.0833,"," 0.0,"," 0.0,"," 0.0,"," vec4(0.0)"," );",""," // TODO avoid querying texture twice for same texel"," gl_FragColor.a = texture2D(tDiffuse, vUv).a;","}"].join(`
  2806. `)};const Ut=(()=>{class e{constructor(){this._name=null,this._components={},this._position=new A,this._rotation=new tt,this._handlers={},this.parent_=null,this.dead_=!1}Destroy(){for(let n in this._components)this._components[n].Destroy();this._components=null,this.parent_=null,this._handlers=null}_RegisterHandler(n,r){n in this._handlers||(this._handlers[n]=[]),this._handlers[n].push(r)}SetParent(n){this.parent_=n}SetName(n){this._name=n}get Name(){return this._name}get Manager(){return this.parent_}SetActive(n){this.parent_.SetActive(this,n)}SetDead(){this.dead_=!0}AddComponent(n){n.SetParent(this),this._components[n.NAME]=n,n.InitComponent()}InitEntity(){for(let n in this._components)this._components[n].InitEntity()}GetComponent(n){return this._components[n]}FindEntity(n){return this.parent_.Get(n)}Broadcast(n){if(n.topic in this._handlers)for(let r of this._handlers[n.topic])r(n)}SetPosition(n){this._position.copy(n),this.Broadcast({topic:"update.position",value:this._position})}SetQuaternion(n){this._rotation.copy(n),this.Broadcast({topic:"update.rotation",value:this._rotation})}get Position(){return this._position}get Quaternion(){return this._rotation}Update(n){for(let r in this._components)this._components[r].Update(n)}}class t{get NAME(){return console.error("Unnamed Component: "+this.constructor.name),"__UNNAMED__"}constructor(){this.parent_=null}Destroy(){}SetParent(n){this.parent_=n}InitComponent(){}InitEntity(){}GetComponent(n){return this.parent_.GetComponent(n)}get Manager(){return this.parent_.Manager}get Parent(){return this.parent_}FindEntity(n){return this.parent_.FindEntity(n)}Broadcast(n){this.parent_.Broadcast(n)}Update(n){}_RegisterHandler(n,r){this.parent_._RegisterHandler(n,r)}}return{Entity:e,Component:t}})(),Fr=(()=>({enabled:!1,foliageEnabled:!0,hardcodedFoliageEnabled:!1,introEnabled:!1,skipOceans:!1,skipClouds:!1,skipFoliageNoise:!1,skipPruning:!1,skipExteriorBlocks:!1,skipAO:!1,skipVariableLuminance:!1,skipGravity:!1,useFlatTerrain:!1,showTools:!0,fixedTerrainOrigin:!1,PLAYER_POS:[-1826.1306923527645,27.940844444445403,-220.6986696117536],PLAYER_ROT:[-.0380279893805328,.3364980691628503,.013601301436886065,.9408176901358577],CAMERA_POS:[0,0],CAMERA_DECCELERATION:[-10,0,-10],INTRO_RATE:5e-4,WORLD_BLOCK_SIZE:16,WORLD_SIZE:24}))(),_t=(()=>({FOG_RANGE:[100,300],UNDERWATER_RANGE:[0,50],FOG_COLOUR:new he(13491953).convertSRGBToLinear(),MOON_COLOUR:new he(8421504).convertSRGBToLinear(),UNDERWATER_COLOUR:new he(3829685).convertSRGBToLinear(),SKY_COLOUR:new he(8175606).convertSRGBToLinear(),PLAYER_POS:[255.311252087425,100,290.98564212457086],PLAYER_ROT:[.02753162419089479,-.7573631733845853,.031998988835540886,.6516280365237096]}))(),Cg=(()=>{const e=`
  2807. varying vec3 vWorldPosition;
  2808. void main() {
  2809. vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
  2810. vWorldPosition = worldPosition.xyz;
  2811. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  2812. }`,t=`
  2813. uniform vec3 topColor;
  2814. uniform vec3 bottomColor;
  2815. uniform vec3 playerPos;
  2816. uniform float offset;
  2817. uniform float exponent;
  2818. uniform float whiteBlend;
  2819. uniform float time;
  2820. uniform samplerCube background;
  2821. varying vec3 vWorldPosition;
  2822. float sdPlane(vec3 p, vec3 n, float h) {
  2823. // n must be normalized
  2824. return dot(p, n) + h;
  2825. }
  2826. void main() {
  2827. vec3 viewDirection = normalize(vWorldPosition - cameraPosition);
  2828. vec3 stars = sRGBToLinear(textureCube(background, viewDirection)).xyz;
  2829. float h = normalize(vWorldPosition + offset).y;
  2830. float t = max(pow(max(h, 0.0), exponent), 0.0);
  2831. float f = exp(min(0.0, -vWorldPosition.y * 0.0125));
  2832. float heightMix = clamp((playerPos.y - 500.0) / 1000.0, 0.0, 1.0);
  2833. heightMix = smoothstep(0.0, 1.0, heightMix);
  2834. heightMix = smoothstep(0.0, 1.0, heightMix);
  2835. float wrapFactor = playerPos.y / 500.0;
  2836. float normalMix = clamp((viewDirection.y + wrapFactor) / (1.0 + wrapFactor), 0.0, 1.0);
  2837. normalMix = pow(normalMix, 0.250);
  2838. vec3 topMix = mix(topColor, stars, heightMix * normalMix);
  2839. // Normal
  2840. vec3 sky = mix(topMix, bottomColor, f);
  2841. // Moon
  2842. // vec3 sky = mix(stars, bottomColor, f);
  2843. float skyMix = clamp(whiteBlend, 0.0, 1.0);
  2844. sky = mix(bottomColor, sky, skyMix * skyMix);
  2845. gl_FragColor = vec4(sky, 1.0);
  2846. // gl_FragColor = vec4(vec3(normalMix * normalMix), 1.0);
  2847. }`,n=class n extends Ut.Component{get NAME(){return n.CLASS_NAME}constructor(){super()}InitEntity(){this.threejs_=new _r({antialias:!1}),this.threejs_.shadowMap.enabled=!0,this.threejs_.shadowMap.type=da,this.threejs_.setPixelRatio(window.devicePixelRatio),this.threejs_.setSize(window.innerWidth,window.innerHeight),this.threejs_.domElement.id="threejs",document.getElementById("container").appendChild(this.threejs_.domElement),window.addEventListener("resize",()=>{this.OnResize_()},!1);const o=60,s=1920/1080,a=.5,l=1e4;this.camera_=new $e(o,s,a,l),this.camera_.position.set(15,50,15),this.camera_.lookAt(0,0,0),this.uiCamera_=new $e(o,s,a,l),this.scene_=new Es,this.scene_.add(this.camera_),this.uiScene_=new Es,this.uiScene_.add(this.uiCamera_);let c=new Lo(8423603,.7);c.position.set(-10,500,10),c.target.position.set(0,0,0),this.scene_.add(c),this.uiScene_.add(c.clone()),this.sun_=c;const h={minFilter:qe,magFilter:qe,format:wt,type:li},u=new ji(window.innerWidth,window.innerHeight,h);u.stencilBuffer=!1,u.depthBuffer=!0,u.depthTexture=new Sr,u.depthTexture.format=Gi,u.depthTexture.type=ir,this.fxaa_=new qn(Rg);const d=new Oo(this.uiScene_,this.uiCamera_);d.clear=!1,this.composer_=new Tc(this.threejs_,u),this.composer_.addPass(new Oo(this.scene_,this.camera_)),this.composer_.addPass(d),this.composer_.addPass(this.fxaa_),this.composer_.addPass(new qn(Pg));const f=new Oe(new gi(.1,.01,.01),new vt({color:new he(16777215),depthWrite:!1,depthTest:!1}));f.position.set(0,0,-2);const m=new Oe(new gi(.01,.1,.01),new vt({color:new he(16777215),depthWrite:!1,depthTest:!1}));m.position.set(0,0,-2),this.uiCamera_.add(f),this.uiCamera_.add(m),this.LoadSky_(),this.OnResize_()}OnResize_(){this.camera_.aspect=window.innerWidth/window.innerHeight,this.camera_.updateProjectionMatrix(),this.threejs_.setSize(window.innerWidth,window.innerHeight),this.composer_.setSize(window.innerWidth,window.innerHeight);const o=this.threejs_.getPixelRatio();this.fxaa_.material.uniforms.resolution.value.x=1/(window.innerWidth*o),this.fxaa_.material.uniforms.resolution.value.y=1/(window.innerHeight*o)}LoadSky_(){const o=new Ys(4344437,16777215,.9);this.scene_.add(o),this.uiScene_.add(o.clone());const s=new So().load(["./resources/terrain/space-posx.jpg","./resources/terrain/space-negx.jpg","./resources/terrain/space-posy.jpg","./resources/terrain/space-negy.jpg","./resources/terrain/space-posz.jpg","./resources/terrain/space-negz.jpg"]);s.encoding=Vi;const a={topColor:{value:_t.SKY_COLOUR.clone()},bottomColor:{value:_t.FOG_COLOUR.clone()},offset:{value:0},exponent:{value:.6},background:{value:s},whiteBlend:{value:0},playerPos:{value:new A},time:{value:0}},l=new qm(5e3,32,15),c=new Qe({uniforms:a,vertexShader:e,fragmentShader:t,side:Ze}),h=new Oe(l,c);this.sky_=h,this.scene_.add(h)}Update(o){const s=this.FindEntity("player");if(!s)return;const a=s._position,l=new A(0,0,-1);l.applyQuaternion(s.Quaternion),l.multiplyScalar(750),this.sun_.position.copy(a),this.sun_.position.add(new A(-50,200,-10)),this.sun_.target.position.copy(a),this.sun_.updateMatrixWorld(),this.sun_.target.updateMatrixWorld(),this.sky_.position.copy(new A(a.x,0,a.z)),this.sky_.material.uniforms.playerPos.value.copy(a),this.sky_.material.uniforms.time.value+=o,this.sky_.material.needsUpdate=!0}Render(){this.uiCamera_.position.copy(this.camera_.position),this.uiCamera_.quaternion.copy(this.camera_.quaternion),this.composer_.render()}};wi(n,"CLASS_NAME","ThreeJSController");let i=n;return{ThreeJSController:i}})(),sa=function(){return{DictIntersection:function(e,t){const i={};for(let n in t)n in e&&(i[n]=e[n]);return i},DictDifference:function(e,t){const i={...e};for(let n in t)delete i[n];return i}}}(),Ng=(()=>{let e=0;class t{constructor(){this.worker_=new Worker(new URL("/Quick_MinecraftClone2/assets/voxel-builder-threaded-worker-ff5d78be.js",self.location),{type:"module"}),this.worker_.onmessage=r=>{this._OnMessage(r)},this.resolve_=null,this.id_=e++}_OnMessage(r){const o=this.resolve_;this.resolve_=null,o(r.data)}get id(){return this.id_}postMessage(r,o){this.resolve_=o,this.worker_.postMessage(r)}}class i{constructor(r){this.workers_=[...Array(r)].map(o=>new t),this.free_=[...this.workers_],this.busy_={},this.queue_=[]}get length(){return this.workers_.length}get Busy(){return this.queue_.length>0||Object.keys(this.busy_).length>0}Enqueue(r,o){this.queue_.push([r,o]),this.PumpQueue_()}PumpQueue_(){for(;this.free_.length>0&&this.queue_.length>0;){const r=this.free_.pop();this.busy_[r.id]=r;const[o,s]=this.queue_.shift();r.postMessage(o,a=>{delete this.busy_[r.id],this.free_.push(r),s(a),this.PumpQueue_()})}}}return{WorkerPool:i}})(),Ig=function(){var e=.5*(Math.sqrt(3)-1),t=(3-Math.sqrt(3))/6,i=1/3,n=1/6,r=(Math.sqrt(5)-1)/4,o=(5-Math.sqrt(5))/20;function s(h){var u;typeof h=="function"?u=h:h?u=l(h):u=Math.random,this.p=a(u),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(var d=0;d<512;d++)this.perm[d]=this.p[d&255],this.permMod12[d]=this.perm[d]%12}s.prototype={grad3:new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),grad4:new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]),noise2D:function(h,u){var d=this.permMod12,f=this.perm,m=this.grad3,v=0,_=0,g=0,p=(h+u)*e,E=Math.floor(h+p),S=Math.floor(u+p),T=(E+S)*t,x=E-T,L=S-T,W=h-x,U=u-L,B,H;W>U?(B=1,H=0):(B=0,H=1);var j=W-B+t,G=U-H+t,D=W-1+2*t,k=U-1+2*t,Y=E&255,Z=S&255,$=.5-W*W-U*U;if($>=0){var ne=d[Y+f[Z]]*3;$*=$,v=$*$*(m[ne]*W+m[ne+1]*U)}var ae=.5-j*j-G*G;if(ae>=0){var de=d[Y+B+f[Z+H]]*3;ae*=ae,_=ae*ae*(m[de]*j+m[de+1]*G)}var ce=.5-D*D-k*k;if(ce>=0){var ye=d[Y+1+f[Z+1]]*3;ce*=ce,g=ce*ce*(m[ye]*D+m[ye+1]*k)}return 70*(v+_+g)},noise3D:function(h,u,d){var f=this.permMod12,m=this.perm,v=this.grad3,_,g,p,E,S=(h+u+d)*i,T=Math.floor(h+S),x=Math.floor(u+S),L=Math.floor(d+S),W=(T+x+L)*n,U=T-W,B=x-W,H=L-W,j=h-U,G=u-B,D=d-H,k,Y,Z,$,ne,ae;j>=G?G>=D?(k=1,Y=0,Z=0,$=1,ne=1,ae=0):j>=D?(k=1,Y=0,Z=0,$=1,ne=0,ae=1):(k=0,Y=0,Z=1,$=1,ne=0,ae=1):G<D?(k=0,Y=0,Z=1,$=0,ne=1,ae=1):j<D?(k=0,Y=1,Z=0,$=0,ne=1,ae=1):(k=0,Y=1,Z=0,$=1,ne=1,ae=0);var de=j-k+n,ce=G-Y+n,ye=D-Z+n,Ne=j-$+2*n,ie=G-ne+2*n,M=D-ae+2*n,w=j-1+3*n,O=G-1+3*n,P=D-1+3*n,F=T&255,R=x&255,N=L&255,I=.6-j*j-G*G-D*D;if(I<0)_=0;else{var V=f[F+m[R+m[N]]]*3;I*=I,_=I*I*(v[V]*j+v[V+1]*G+v[V+2]*D)}var X=.6-de*de-ce*ce-ye*ye;if(X<0)g=0;else{var Q=f[F+k+m[R+Y+m[N+Z]]]*3;X*=X,g=X*X*(v[Q]*de+v[Q+1]*ce+v[Q+2]*ye)}var b=.6-Ne*Ne-ie*ie-M*M;if(b<0)p=0;else{var y=f[F+$+m[R+ne+m[N+ae]]]*3;b*=b,p=b*b*(v[y]*Ne+v[y+1]*ie+v[y+2]*M)}var J=.6-w*w-O*O-P*P;if(J<0)E=0;else{var q=f[F+1+m[R+1+m[N+1]]]*3;J*=J,E=J*J*(v[q]*w+v[q+1]*O+v[q+2]*P)}return 32*(_+g+p+E)},noise4D:function(h,u,d,f){var m=this.perm,v=this.grad4,_,g,p,E,S,T=(h+u+d+f)*r,x=Math.floor(h+T),L=Math.floor(u+T),W=Math.floor(d+T),U=Math.floor(f+T),B=(x+L+W+U)*o,H=x-B,j=L-B,G=W-B,D=U-B,k=h-H,Y=u-j,Z=d-G,$=f-D,ne=0,ae=0,de=0,ce=0;k>Y?ne++:ae++,k>Z?ne++:de++,k>$?ne++:ce++,Y>Z?ae++:de++,Y>$?ae++:ce++,Z>$?de++:ce++;var ye,Ne,ie,M,w,O,P,F,R,N,I,V;ye=ne>=3?1:0,Ne=ae>=3?1:0,ie=de>=3?1:0,M=ce>=3?1:0,w=ne>=2?1:0,O=ae>=2?1:0,P=de>=2?1:0,F=ce>=2?1:0,R=ne>=1?1:0,N=ae>=1?1:0,I=de>=1?1:0,V=ce>=1?1:0;var X=k-ye+o,Q=Y-Ne+o,b=Z-ie+o,y=$-M+o,J=k-w+2*o,q=Y-O+2*o,z=Z-P+2*o,te=$-F+2*o,re=k-R+3*o,ue=Y-N+3*o,se=Z-I+3*o,ge=$-V+3*o,ve=k-1+4*o,be=Y-1+4*o,pe=Z-1+4*o,_e=$-1+4*o,Te=x&255,Ke=L&255,ct=W&255,zt=U&255,It=.6-k*k-Y*Y-Z*Z-$*$;if(It<0)_=0;else{var kt=m[Te+m[Ke+m[ct+m[zt]]]]%32*4;It*=It,_=It*It*(v[kt]*k+v[kt+1]*Y+v[kt+2]*Z+v[kt+3]*$)}var Ht=.6-X*X-Q*Q-b*b-y*y;if(Ht<0)g=0;else{var bi=m[Te+ye+m[Ke+Ne+m[ct+ie+m[zt+M]]]]%32*4;Ht*=Ht,g=Ht*Ht*(v[bi]*X+v[bi+1]*Q+v[bi+2]*b+v[bi+3]*y)}var ht=.6-J*J-q*q-z*z-te*te;if(ht<0)p=0;else{var st=m[Te+w+m[Ke+O+m[ct+P+m[zt+F]]]]%32*4;ht*=ht,p=ht*ht*(v[st]*J+v[st+1]*q+v[st+2]*z+v[st+3]*te)}var yt=.6-re*re-ue*ue-se*se-ge*ge;if(yt<0)E=0;else{var Qt=m[Te+R+m[Ke+N+m[ct+I+m[zt+V]]]]%32*4;yt*=yt,E=yt*yt*(v[Qt]*re+v[Qt+1]*ue+v[Qt+2]*se+v[Qt+3]*ge)}var et=.6-ve*ve-be*be-pe*pe-_e*_e;if(et<0)S=0;else{var Bt=m[Te+1+m[Ke+1+m[ct+1+m[zt+1]]]]%32*4;et*=et,S=et*et*(v[Bt]*ve+v[Bt+1]*be+v[Bt+2]*pe+v[Bt+3]*_e)}return 27*(_+g+p+E+S)}};function a(h){var u,d=new Uint8Array(256);for(u=0;u<256;u++)d[u]=u;for(u=0;u<255;u++){var f=u+~~(h()*(256-u)),m=d[u];d[u]=d[f],d[f]=m}return d}s._buildPermutationTable=a;function l(){var h=0,u=0,d=0,f=1,m=c();h=m(" "),u=m(" "),d=m(" ");for(var v=0;v<arguments.length;v++)h-=m(arguments[v]),h<0&&(h+=1),u-=m(arguments[v]),u<0&&(u+=1),d-=m(arguments[v]),d<0&&(d+=1);return m=null,function(){var _=2091639*h+f*23283064365386963e-26;return h=u,u=d,d=_-(f=_|0)}}function c(){var h=4022871197;return function(u){u=u.toString();for(var d=0;d<u.length;d++){h+=u.charCodeAt(d);var f=.02519603282416938*h;h=f>>>0,f-=h,f*=h,h=f>>>0,f-=h,h+=f*4294967296}return(h>>>0)*23283064365386963e-26}}return{SimplexNoise:s}}(),Je=function(){class e{constructor(i){this.params_=i,this._Init()}_Init(){this._noise=new Ig.SimplexNoise(this.params_.seed)}Get(i,n,r){const o=2**-this.params_.persistence,s=i/this.params_.scale,a=n/this.params_.scale,l=r/this.params_.scale,c=this._noise;let h=1,u=1,d=0,f=0;for(let m=0;m<this.params_.octaves;m++){let v=c.noise3D(s*u,a*u,l*u);f+=v*h,d+=h,h*=o,u*=this.params_.lacunarity}if(f/=d,this.params_.ridged?f=1-Math.abs(f):f=f*.5+.5,f=Math.pow(f,this.params_.exponentiation),this.params_.range){const m=this.params_.range;f=m[0]+(m[1]-m[0])*f}return f*this.params_.height}}return{Noise:e}}(),lt=function(){return{rand_range:function(e,t){return Math.random()*(t-e)+e},rand_normalish:function(){return(Math.random()+Math.random()+Math.random()+Math.random())/4*2-1},rand_int:function(e,t){return Math.round(Math.random()*(t-e)+e)},lerp:function(e,t,i){return e*(i-t)+t},smoothstep:function(e,t,i){return e=e*e*(3-2*e),e*(i-t)+t},smootherstep:function(e,t,i){return e=e*e*e*(e*(e*6-15)+10),e*(i-t)+t},clamp:function(e,t,i){return Math.min(Math.max(e,t),i)},sat:function(e){return Math.min(Math.max(e,0),1)},in_range:(e,t,i)=>e>=t&&e<=i}}(),aa=(()=>{function e(T,x,L,W,U){const B=L.clone().sub(x),H=T.clone().sub(x),j=U-W,G=B.dot(B),D=H.dot(H),k=H.dot(B)/G,Y=Math.sqrt(D-k*k*G),Z=Math.max(0,Y-(k<.5?W:U)),$=Math.abs(k-.5)-.5,ne=j*j+G,ae=lt.sat((j*(Y-W)+k*G)/ne),de=Y-W-ae*j,ce=k-ae;return(de<0&&$<0?-1:1)*Math.sqrt(Math.min(Z*Z+$*$*G,de*de+ce*ce*G))}function t(T,x){return T.length()-x}const i=new A,n=new dt,r=new dt,o=new dt,s=new Zt,a=new tt,l=new tt,c=new tt,h=new A(1,0,0),u=new A(0,1,0),d=new A(0,0,1),f=new A;class m{constructor(x){this.sdfs_=[],this.pos_=x.clone(),this.aabb_=new dt(this.pos_.clone(),this.pos_.clone())}get AABB(){return this.aabb_}AddSphere(x,L,W){s.set(this.pos_.clone(),W),s.translate(L),s.getBoundingBox(n),this.aabb_.union(n);const U=L.clone();this.sdfs_.push(B=>(i.copy(B),i.sub(U),i.sub(this.pos_),t(i,W)<0?x:null))}AddCappedCone(x,L,W,U,B,H){s.set(W.clone(),B),s.getBoundingBox(r),s.set(U.clone(),H),s.getBoundingBox(o),n.makeEmpty(),n.union(r),n.union(o),n.translate(L),n.translate(this.pos_),this.aabb_.union(n);const j=W.clone(),G=U.clone(),D=L.clone();this.sdfs_.push(k=>(i.copy(k),i.sub(D),i.sub(this.pos_),e(i,j,G,B,H)<0?x:null))}Evaluate(x){for(let L=0;L<this.sdfs_.length;++L){const W=this.sdfs_[L](x);if(W)return W}return null}}const v=new Je.Noise({seed:7,octaves:1,scale:1,persistence:.5,lacunarity:2,exponentiation:1,height:1});function _(T,x,L,W){const U=new m(new A(T,x,L));return U.AddSphere("stone",new A,W),U}function g(T,x,L){const W=new m(new A(T,x,L));return W.AddCappedCone("tree_bark",new A,new A,new A(0,20,0),5,5),W}function p(T,x,L){const W=new A(5,15,0),U=new A(-6,0,1),B=new A(9,0,-7),H=new A(8,0,6),j=4,G=v.Get(T,9,L)*2*Math.PI;a.setFromAxisAngle(u,G),W.applyQuaternion(a),U.applyQuaternion(a),B.applyQuaternion(a),H.applyQuaternion(a);const D=new m(new A(T,x,L));return D.AddCappedCone("tree_bark",new A,new A(0,-2,0),W,3,.5),D.AddCappedCone("tree_bark",new A,new A(0,4,0),U,1,1),D.AddCappedCone("tree_bark",new A,new A(0,4,0),B,2,1),D.AddCappedCone("tree_bark",new A,new A(0,4,0),H,2,1),D.AddSphere("tree_leaves",W,j),D}function E(T,x,L){let W=100;v.Get(T,1,L)*20+20,v.Get(T,2,L)*5+4;const U=new m(new A(T,x,L)),B=(.01+v.Get(T,W++,L)*.02)*2*Math.PI,H=v.Get(T,W++,L)*2*Math.PI,j=(G,D,k,Y,Z)=>{if(k=Math.max(k,1),Z>6){a.copy(Y),i.set(0,5,0),i.applyQuaternion(Y),i.add(G),U.AddSphere("tree_leaves",i,5);return}const $=new A(0,D,0),ne=(.03+v.Get(T,W++,L)*.08)*2*Math.PI,ae=(.25+v.Get(T,W++,L)*.25)*2*Math.PI;$.applyQuaternion(Y),$.add(G),U.AddCappedCone("tree_bark",f,G,$,k,k*.6),l.setFromAxisAngle(h,ne),c.setFromAxisAngle(u,ae),a.copy(Y),a.multiply(c),a.multiply(l),j($.clone(),D*.6,k*.6,a.clone(),Z+1);const de=v.Get(T,W++,L)*.01*2*Math.PI,ce=v.Get(T,W++,L)*.25*2*Math.PI;l.setFromAxisAngle(h,-(ne+de)),c.setFromAxisAngle(u,-(ae+ce)),a.copy(Y),a.multiply(c),a.multiply(l),j($.clone(),D*.6,k*.6,a.clone(),Z+1)};return l.setFromAxisAngle(h,B),c.setFromAxisAngle(u,H),a.copy(c),a.multiply(l),j(new A(0,-5,0),20,5,a.clone(),1),U.AddCappedCone("tree_bark",new A,new A(0,3,0),new A(12,-1,0),2,1),U.AddCappedCone("tree_bark",new A,new A(0,4,0),new A(-8,-1,-11),2,1),U.AddCappedCone("tree_bark",new A,new A(0,2,0),new A(-13,-1,-4),2,1),U}function S(T,x,L){let W=100;const U=new m(new A(T,x,L)),B=(.01+v.Get(T,W++,L)*.02)*2*Math.PI,H=v.Get(T,W++,L)*2*Math.PI,j=(D,k,Y,Z,$)=>{if($>7)return;const ne=new A(4,0,0),ae=-.075*2*Math.PI;ne.applyQuaternion(Z),ne.add(D),U.AddCappedCone("tree_leaves",f,D,ne,Y,Y),l.setFromAxisAngle(d,ae),a.copy(Z),a.multiply(l),j(ne.clone(),k,Y,a.clone(),$+1)},G=(D,k,Y,Z,$)=>{if(Y=Math.max(Y,1),$>3){j(D,k,1,new tt,$),c.setFromAxisAngle(u,.33*2*Math.PI),j(D,k,1,c.clone(),$),c.setFromAxisAngle(u,.66*2*Math.PI),j(D,k,1,c.clone(),$);return}const ne=new A(0,k,0),ae=(.05+v.Get(T,W++,L)*.02)*2*Math.PI;ne.applyQuaternion(Z),ne.add(D),U.AddCappedCone("tree_bark",f,D,ne,Y,Y*.6),l.setFromAxisAngle(h,ae),a.copy(Z),a.multiply(l),G(ne.clone(),k*.75,Y*.75,a.clone(),$+1)};return l.setFromAxisAngle(h,B),c.setFromAxisAngle(u,H),a.copy(c),a.multiply(l),G(new A(0,-5,0),15,2,a.clone(),1),U}return{TREE1:p,TREE2:E,PALM_TREE1:S,SPHERE:_,CONE1:g}})(),Fg=(()=>{const e=Math.floor(6.4),t=e+4,i=Math.floor(128*.7);new he(8421631),new he(16777088),new he(16777215),new he(4210752),new he(4259648);function n(m,v){return m<e||m<t?"sand":m>i?"snow":"grass"}new Je.Noise({seed:6,octaves:1,scale:128,persistence:.5,lacunarity:2,exponentiation:4,height:32}),new A;class r{constructor(v){this.params_=v,this.N_Moon_=new Je.Noise({seed:4,octaves:5,scale:1024,persistence:.5,lacunarity:2,exponentiation:4,height:1}),this.N_Craters_=new Je.Noise({seed:7,octaves:1,scale:.99,persistence:.5,lacunarity:2,exponentiation:1,height:1}),this.InitCraters_()}InitCraters_(){this.craters_=[];for(let v=-this.params_.dimensions.x*10;v<=this.params_.dimensions.x*10;v+=8)for(let _=-this.params_.dimensions.z*10;_<=this.params_.dimensions.z*10;_+=8){const g=v+this.params_.offset.x,p=_+this.params_.offset.z;if(this.N_Craters_.Get(g,0,p)>.95){const E=Math.min(this.N_Craters_.Get(g,1,p)**4*100,50)+4;this.craters_.push([new A(g,0,p),E])}}}Get(v,_){const g=this.N_Moon_.Get(v,_,10),p=this.N_Moon_.Get(v,_,20);let E=Math.round(this.N_Moon_.Get(v+g,_+p,0)*64);for(let S=0;S<this.craters_.length;++S){const T=new A(v,0,_),[x,L]=this.craters_[S],W=x.distanceTo(T),U=L;if(W<U*2){const B=L/4,H=Math.abs(W-(U-B)),j=1-lt.sat(H/B)**.5,G=L/10,D=1-lt.sat((W-(U-B*2))/B)**2;E+=j*G+D*-(G*2)}}return["moon",Math.round(E)]}}class o{constructor(v){this.params_=v,this.moon_=new r(v),this.grass_=new l(v),this.sand_=new a(v),this.rocky_=new s(v),this.N_Height_=new Je.Noise({seed:100,octaves:1,scale:4096,persistence:.5,lacunarity:2,exponentiation:1,height:32}),this.N_Roll_=new Je.Noise({seed:200,octaves:1,scale:8,persistence:.5,lacunarity:2,exponentiation:1,height:1}),this.N_=new Je.Noise({seed:4,octaves:.99,scale:1,persistence:.5,lacunarity:2,exponentiation:1,height:4}),this.N_Types_=new Je.Noise({seed:8,octaves:.99,scale:1,persistence:.5,lacunarity:2,exponentiation:1,height:4})}Biome_(v,_,g,p){const E=lt.smootherstep(p,0,1),S=lt.smootherstep(g/128,0,1),T=["sand",0],x=this.moon_.Get(v,_),L=["grass",0],W=["stone",0],U=lt.lerp(E,T[1],L[1]),B=lt.lerp(E,x[1],W[1]),H=lt.lerp(S,U,B),j=E<.5?T[0]:L[0],G=E<.5?x[0]:W[0];return[S<.5?j:G,Math.floor(H)]}Get2(v,_){const g=this.N_Height_.Get(v,0,_),p=Math.floor(g),E=this.N_Moisture_.Get(v,0,_);return this.Biome_(v,_,p,E)}ChooseTerrainType_(v,_){const g=[Math.floor(v/1024),Math.floor(_/1024)],p=[g[0]*1024,g[1]*1024],E=[Math.round(this.N_.Get(g[0],0,g[1])*1024),Math.round(this.N_.Get(g[0],1,g[1])*1024)];E[0]=p[0]+1024*.5,E[1]=p[1]+1024*.5;const S=((v-E[0])**2+(_-E[1])**2)**.5,T=lt.sat((S-1024*.25)/(1024*.25)),x=Math.round(this.N_Types_.Get(g[0],0,g[1]));let L=null;x==0?L=this.rocky_.Get(v,_):x==1?L=this.sand_.Get(v,_):x==2?L=this.grass_.Get(v,_):x==3?L=["snow",15]:x==4&&(L=this.moon_.Get(v,_)),L[1]=lt.lerp(lt.smootherstep(T,0,1),L[1],0);const W=this.N_Roll_.Get(v,2,_);return lt.sat((S-1024*.375)/(1024*.125))>W&&(L[0]="grass"),L[1]<e&&(L[0]="sand"),L}Get(v,_){const g=this.ChooseTerrainType_(v,_);return g[1]=Math.round(g[1]),g}}class s{constructor(v){this.params_=v,this.N_Terrain_=new Je.Noise({seed:9,octaves:6,scale:500.005,persistence:.5,lacunarity:2,exponentiation:6,height:64,ridged:!0}),this.N_Roll_=new Je.Noise({seed:200,octaves:2,scale:8,persistence:.5,lacunarity:2,exponentiation:1,height:1}),this.N_Height_=new Je.Noise({seed:100,octaves:1,scale:64,persistence:.5,lacunarity:2,exponentiation:1,height:1,range:[.25,1]})}Get(v,_){const g=this.N_Terrain_.Get(v,0,_)*this.N_Height_.Get(v,0,_),p=Math.floor(g),E=this.N_Roll_.Get(v,0,_),S=p/32;let T="stone";return E>S&&(T="dirt"),[T,p]}}class a{constructor(v){this.params_=v,this.N_Terrain_=new Je.Noise({seed:4,octaves:4,scale:500.005,persistence:.5,lacunarity:2,exponentiation:6,height:1,range:[-1,1]}),this.N_Height_=new Je.Noise({seed:4,octaves:3,scale:500.005,persistence:.5,lacunarity:2,exponentiation:1,height:64})}Get(v,_){const g=[this.N_Terrain_.Get(v,0,_),this.N_Terrain_.Get(v,1,_)],p=this.N_Height_.Get(v+g[0],0,_+g[1]);return["sand",Math.floor(p)]}}class l{constructor(v){this.params_=v,this.N_Terrain_=new Je.Noise({seed:4,octaves:6,scale:4096,persistence:.5,lacunarity:2,exponentiation:6,height:1}),this.N_Height_=new Je.Noise({seed:4,octaves:3,scale:4096,persistence:.5,lacunarity:2,exponentiation:1,height:512}),this.N_Plateaus_=new Je.Noise({seed:5,octaves:4,scale:512,persistence:.5,lacunarity:2,exponentiation:2,height:1}),this.N_PlateausNum_=new Je.Noise({seed:6,octaves:4,scale:1024,persistence:.5,lacunarity:2,exponentiation:1,height:20}),this.N_Moisture_=new Je.Noise({seed:3,octaves:3,scale:512,persistence:.5,lacunarity:2,exponentiation:4,height:1})}Get(v,_){const g=this.N_Terrain_.Get(v,_,0),p=this.N_Height_.Get(v,_,0);let E=p*g;if(this.N_Plateaus_.Get(v,_,0)>.25){const T=Math.round(10+this.N_PlateausNum_.Get(v,_,0)),x=Math.round(p/T);E=Math.round(E/x)*x}const S=Math.floor(E);return this.N_Moisture_.Get(v,_,0),[n(S),S]}}const c=new Je.Noise({seed:10,octaves:1,scale:.99,persistence:.5,lacunarity:2,exponentiation:4,height:1}),h=new Je.Noise({seed:11,octaves:4,scale:2.01,persistence:.5,lacunarity:2,exponentiation:1,height:1}),u=new Je.Noise({seed:7,octaves:1,scale:.99,persistence:.5,lacunarity:2,exponentiation:1,height:1});class d{constructor(){this.sdfs_=[]}Add(v){this.sdfs_.push(v)}Intersects(v){for(let _=0;_<this.sdfs_.length;++_)if(this.sdfs_[_].AABB.intersectsBox(v))return!0;return!1}Evaluate(v,_,g){const p=new A(v,_,g);for(let E=0;E<this.sdfs_.length;++E){const S=this.sdfs_[E];if(S.AABB.containsPoint(p)){const T=S.Evaluate(p);if(T)return T}}}}class f{constructor(){this.Create_()}Create_(){const v=new Kt(1,1);v.rotateY(Math.PI/2),v.translate(.5,0,0);const _=new Kt(1,1);_.rotateY(-Math.PI/2),_.translate(-.5,0,0);const g=new Kt(1,1);g.rotateX(-Math.PI/2),g.translate(0,.5,0);const p=new Kt(1,1);p.rotateX(Math.PI/2),p.translate(0,-.5,0);const E=new Kt(1,1);E.translate(0,0,.5);const S=new Kt(1,1);S.rotateY(Math.PI),S.translate(0,0,-.5);const T=[v,_,E,S];for(let x of T)for(let L=0;L<x.attributes.uv.array.length;L+=2)x.attributes.uv.array[L+1]=1-x.attributes.uv.array[L+1];this.geometries_=[v,_,g,p,E,S]}Init(v){this.params_=v,this.params_.offset=new A(...v.offset),this.params_.dimensions=new A(...v.dimensions),this.terrainGenerator_=new o(v)}GenerateNoise_(v,_){return this.terrainGenerator_.Get(v,_)}Key_(v,_,g){return v+"."+_+"."+g}PruneHiddenVoxels_(v){const _={};for(let g in v){const p=v[g],E=this.Key_(p.position[0]+1,p.position[1],p.position[2]),S=this.Key_(p.position[0]-1,p.position[1],p.position[2]),T=this.Key_(p.position[0],p.position[1]+1,p.position[2]),x=this.Key_(p.position[0],p.position[1]-1,p.position[2]),L=this.Key_(p.position[0],p.position[1],p.position[2]+1),W=this.Key_(p.position[0],p.position[1],p.position[2]-1),U=[E,S,T,x,L,W];let B=!1;for(let H=0;H<6;++H){const j=U[H]in v;p.facesHidden[H]=j,j||(B=!0)}B&&(_[g]=p)}return _}CreateFoliageSDFs_(){const v=new d;for(let _=-this.params_.dimensions.x*4;_<this.params_.dimensions.x*4;_+=16)for(let g=-this.params_.dimensions.z*4;g<this.params_.dimensions.z*4;g+=16){const p=_+this.params_.offset.x,E=g+this.params_.offset.z;if(u.Get(p,0,E)>.8){const[S,T]=this.GenerateNoise_(p,E),x=T;if(x<=e)continue;if(S=="grass"){let L=aa.TREE1;u.Get(p,1,E)<.15&&(L=aa.TREE2),v.Add(L(p,x,E))}else if(S=="sand"){let L=aa.PALM_TREE1;v.Add(L(p,x,E))}}}return v}CreateTerrain_(){const v={},_=this.params_.dimensions.x+1,g=this.params_.dimensions.x+1;for(let p=-1;p<_;p++)for(let E=-1;E<g;E++){const S=p+this.params_.offset.x,T=E+this.params_.offset.z,[x,L]=this.GenerateNoise_(S,T),W=L,U=this.Key_(S,W,T);v[U]={position:[S,W,T],type:x,visible:!0,facesHidden:[!1,!1,!1,!1,!1],ao:[null,null,null,null,null,null]};let B=L;for(let H=-1;H<=1;H++)for(let j=-1;j<=1;j++){const[G,D]=this.GenerateNoise_(S+H,T+j);B=Math.min(D,B)}if(B<L)for(let H=B+1;H<L;H++){const j=this.Key_(S,H,T);v[j]={position:[S,H,T],type:x,visible:!0,facesHidden:[!1,!1,!1,!1,!1],ao:[null,null,null,null,null,null]},(x=="grass"||x=="snow")&&(v[j].type="dirt")}}return v}ApplySDFsToVoxels_(v,_){const g=this.params_.offset.clone(),p=this.params_.offset.clone().add(this.params_.dimensions),E=new dt(g,p);v.Intersects(E);for(let S=-1;S<this.params_.dimensions.x+1;S++)for(let T=-1;T<this.params_.dimensions.z+1;T++){const x=S+this.params_.offset.x,L=T+this.params_.offset.z,[W,U]=this.GenerateNoise_(x,L);for(let B=0;B<100;B++){const H=U+B,j=this.Key_(x,H,L);if(j in _)continue;const G=v.Evaluate(x,H,L);if(G){let D=0;G=="tree_leaves"&&!Fr.skipFoliageNoise&&(D=u.Get(x,H,L)),D<.7&&(_[j]={position:[x,H,L],type:G,visible:!0,facesHidden:[!1,!1,!1,!1,!1],ao:[null,null,null,null,null,null]})}}}}CreateOcean_(v){const _={};for(let g=-1;g<this.params_.dimensions.x+1;g++)for(let p=-1;p<this.params_.dimensions.z+1;p++){const E=g+this.params_.offset.x,S=p+this.params_.offset.z,[T,x]=this.GenerateNoise_(E,S);if(x<e){const L=this.Key_(E,e,S);_[L]={position:[E,e,S],type:"ocean",visible:!0,facesHidden:[!1,!1,!1,!1,!1],ao:[null,null,null,null,null,null]}}}return _}BuildAO_(v){for(let _ in v){const g=v[_],p=(E,S,T)=>this.Key_(g.position[0]+E,g.position[1]+S,g.position[2]+T)in v?.75:1;g.facesHidden[0]||(g.ao[0]=[p(1,0,1)*p(1,1,0)*p(1,1,1),p(1,0,-1)*p(1,1,0)*p(1,1,-1),p(1,0,1)*p(1,-1,0)*p(1,-1,1),p(1,0,-1)*p(1,-1,0)*p(1,-1,-1)]),g.facesHidden[1]||(g.ao[1]=[p(-1,0,-1)*p(-1,1,0)*p(-1,1,-1),p(-1,0,1)*p(-1,1,0)*p(-1,1,1),p(-1,0,-1)*p(-1,-1,0)*p(-1,-1,-1),p(-1,0,1)*p(-1,-1,0)*p(-1,-1,1)]),g.facesHidden[2]||(g.ao[2]=[p(0,1,-1)*p(-1,1,0)*p(-1,1,-1),p(0,1,-1)*p(1,1,0)*p(1,1,-1),p(0,1,1)*p(-1,1,0)*p(-1,1,1),p(0,1,1)*p(1,1,0)*p(1,1,1)]),g.facesHidden[3]||(g.ao[3]=[p(0,-1,1)*p(-1,-1,0)*p(-1,-1,1),p(0,-1,1)*p(1,-1,0)*p(1,-1,1),p(0,-1,-1)*p(-1,-1,0)*p(-1,-1,-1),p(0,-1,-1)*p(1,-1,0)*p(1,-1,-1)]),g.facesHidden[4]||(g.ao[4]=[p(-1,0,1)*p(0,1,1)*p(-1,1,1),p(1,0,1)*p(0,1,1)*p(1,1,1),p(-1,0,1)*p(0,-1,1)*p(-1,-1,1),p(1,0,1)*p(0,-1,1)*p(1,-1,1)]),g.facesHidden[5]||(g.ao[5]=[p(1,0,-1)*p(0,1,-1)*p(1,1,-1),p(-1,0,-1)*p(0,1,-1)*p(-1,1,-1),p(1,0,-1)*p(0,-1,-1)*p(1,-1,-1),p(-1,0,-1)*p(0,-1,-1)*p(-1,-1,-1)])}return v}ApplyFadeIn_(v){if(this.params_.currentTime<0||this.params_.currentTime>1)return;const _=this.params_.currentTime**2,g=_,p=_+.1-g,E=[];for(let S in v){const T=v[S],x=h.Get(...T.position),L=((T.position[1]+50)/250-g)/p;x<L&&E.push(S)}for(let S=0;S<E.length;++S)delete v[E[S]]}RemoveExteriorVoxels_(v){const _=[],g=this.params_.offset.x,p=this.params_.offset.z,E=this.params_.offset.x+this.params_.dimensions.x,S=this.params_.offset.z+this.params_.dimensions.z;for(let T in v){const x=v[T];(x.position[0]<g||x.position[0]>=E||x.position[2]<p||x.position[2]>=S)&&_.push(T)}for(let T=0;T<_.length;++T)delete v[_[T]]}MergeCustomVoxels_(v){const _=this.params_.customVoxels,g=[];for(let p in _){const E=_[p];E.visible?(E.facesHidden=[!1,!1,!1,!1,!1],E.ao=[null,null,null,null,null,null]):g.push(p)}Object.assign(v,_);for(let p=0;p<g.length;++p)delete v[g[p]]}RemoveVoxelAndFill_(v,_){const g=this.Key_(...v),p={};p[g]={position:[...v],visible:!1};const[E,S]=this.GenerateNoise_(v[0],v[2]);if(v[1]<=S)for(let T=-1;T<=1;T++)for(let x=-1;x<=1;x++)for(let L=-1;L<=1;L++){const W=v[0]+T,U=v[1]+x,B=v[2]+L,[H,j]=this.GenerateNoise_(W,B),G=this.Key_(W,U,B);if(!(G in _)&&U<j){let D="dirt";H=="sand"&&(D="sand"),U<j-2&&(D="stone"),H=="moon"&&(D="moon"),p[G]={position:[W,U,B],type:D,visible:!0}}}return p}Rebuild(){const v=this.CreateTerrain_(),_=this.CreateFoliageSDFs_();this.ApplySDFsToVoxels_(_,v);const g=this.CreateOcean_(v);this.ApplyFadeIn_(g),this.ApplyFadeIn_(v);const p=this.PruneHiddenVoxels_(v),E=this.PruneHiddenVoxels_(g);this.BuildAO_(p);const S=Object.assign({},E,p);this.RemoveExteriorVoxels_(S);const T=this.BuildMeshDataFromVoxels_(S),x=Object.assign({},v,g);this.RemoveExteriorVoxels_(x);for(let L in x){const W=x[L];x[L]={type:W.type,position:W.position,visible:W.visible}}return T.voxels=x,T}PartialRebuild(v,_){const g=Object.assign({},v,_),p=[];for(let T in g){const x=g[T];x.visible?(x.facesHidden=[!1,!1,!1,!1,!1],x.ao=[null,null,null,null,null,null]):p.push(T)}for(let T=0;T<p.length;++T)delete g[p[T]];const E=this.PruneHiddenVoxels_(g);this.BuildAO_(E),this.RemoveExteriorVoxels_(E);const S=this.BuildMeshDataFromVoxels_(E);return S.voxels=v,S}BuildMeshDataFromVoxels_(v){const _={};_.opaque={positions:[],uvs:[],uvSlices:[],normals:[],indices:[],colours:[]},_.transparent={positions:[],uvs:[],uvSlices:[],normals:[],indices:[],colours:[]};for(let S in v){const T=v[S];for(let x=0;x<6;++x){if(T.facesHidden[x])continue;const L=T.type=="ocean"?_.transparent:_.opaque,W=L.positions.length/3,U=[...this.geometries_[x].attributes.position.array];for(let j=0;j<3;++j)for(let G=0;G<4;++G)U[G*3+j]+=T.position[j];L.positions.push(...U),L.uvs.push(...this.geometries_[x].attributes.uv.array),L.normals.push(...this.geometries_[x].attributes.normal.array);const B=c.Get(...T.position)*.1+.9;for(let j=0;j<4;++j){L.uvSlices.push(this.params_.blockTypes[T.type].textures[x]);const G=new he(16777215);G.multiplyScalar(B),T.ao[x]&&G.multiplyScalar(T.ao[x][j]),G.convertSRGBToLinear(),L.colours.push(G.r,G.g,G.b)}const H=[...this.geometries_[x].index.array];for(let j=0;j<H.length;++j)H[j]+=W;L.indices.push(...H)}}const g=4,p=4,E={};for(let S in _){const T=new Float32Array(new ArrayBuffer(g*_[S].positions.length)),x=new Float32Array(new ArrayBuffer(g*_[S].normals.length)),L=new Float32Array(new ArrayBuffer(g*_[S].uvs.length)),W=new Float32Array(new ArrayBuffer(g*_[S].uvSlices.length)),U=new Float32Array(new ArrayBuffer(g*_[S].colours.length)),B=new Uint32Array(new ArrayBuffer(p*_[S].indices.length));T.set(_[S].positions,0),x.set(_[S].normals,0),L.set(_[S].uvs,0),W.set(_[S].uvSlices,0),U.set(_[S].colours,0),B.set(_[S].indices,0),E[S]={positions:T,uvs:L,uvSlices:W,normals:x,colours:U,indices:B}}return E.buildId=this.params_.buildId,E}}return{VoxelBlockBuilder:f}})(),Og=(()=>{class e{constructor(r){this.params_=r,this.voxels_={},this.group_=new ft,this.buildId_=0,this.lastBuiltId_=-1,this.building_=!1,this.dirty_=!1,this.builder_=new Fg.VoxelBlockBuilder,r.scene.add(this.group_)}Destroy(){this.ReleaseAssets_(),this.group_.parent.remove(this.group_)}ReleaseAssets_(){this.group_.traverse(r=>{r.material&&r.material.dispose(),r.geometry&&r.geometry.dispose()}),this.opaqueMesh_&&this.group_.remove(this.opaqueMesh_),this.transparentMesh_&&this.group_.remove(this.transparentMesh_)}Show(){this.group_.visible=!0}Hide(){this.group_.visible=!1}get Destroyed(){return!this.group_.parent}get Dirty(){return this.dirty_}Key_(r,o,s){return r+"."+o+"."+s}InsertVoxelAt(r,o,s){const a=this.Key_(...r);if(a in this.voxels_&&s)return;const l={position:[...r],type:o,visible:!0};this.voxels_[a]=l,this.buildId_++,this.dirty_=!0;const c=this.params_.parent.GetAdjacentBlocks(this.params_.offset.x,this.params_.offset.z);for(let h=-1;h<=1;++h)for(let u=-1;u<=1;++u)for(let d=-1;d<=1;++d)for(let f=0;f<c.length;++f)this.Key_(r[0]+h,r[1]+u,r[2]+d)in c[f].voxels_&&(c[f].buildId_++,c[f].dirty_=!0)}RemoveVoxelAt(r){this.buildId_++,this.dirty_=!0;const o={buildId:this.buildId_,offset:this.params_.offset.toArray(),dimensions:this.params_.dimensions.toArray(),blockTypes:this.params_.blockTypes,currentTime:0};this.builder_.Init(o);const s=this.Key_(...r);this.voxels_[s].visible=!1;const a=this.builder_.RemoveVoxelAndFill_(r,this.voxels_);for(let c in a)this.params_.parent.InsertVoxelAt(a[c].position,a[c].type,!0);const l=this.params_.parent.GetAdjacentBlocks(this.params_.offset.x,this.params_.offset.z);for(let c=-1;c<=1;++c)for(let h=-1;h<=1;++h)for(let u=-1;u<=1;++u)for(let d=0;d<l.length;++d)this.Key_(r[0]+c,r[1]+h,r[2]+u)in l[d].voxels_&&(l[d].buildId_++,l[d].dirty_=!0)}PartialRebuild(){const r=this.params_.parent.GetAdjacentBlocks(this.params_.offset.x,this.params_.offset.z),o={},s=this.params_.offset.x-1,a=this.params_.offset.z-1,l=this.params_.offset.x+this.params_.dimensions.x,c=this.params_.offset.z+this.params_.dimensions.z;for(let d=0;d<r.length;++d){const f=r[d];for(let m in f.voxels_){const v=f.voxels_[m];(v.position[0]==s||v.position[0]==l||v.position[2]==a||v.position[2]==c)&&(o[m]=v)}}const h={buildId:this.buildId_,offset:this.params_.offset.toArray(),dimensions:this.params_.dimensions.toArray(),blockTypes:this.params_.blockTypes,currentTime:0};this.builder_.Init(h);const u=this.builder_.PartialRebuild(this.voxels_,o);this.RebuildMeshFromData(u),this.dirty_=!1}HasVoxelAt(r,o,s){const a=this.Key_(r,o,s);return a in this.voxels_?this.voxels_[a].visible:!1}FindVoxelsNear(r,o){const s=Math.ceil(r.x+(o+1)),a=Math.ceil(r.y+(o+1)),l=Math.ceil(r.z+(o+1)),c=Math.floor(r.x-(o+1)),h=Math.floor(r.y-(o+1)),u=Math.floor(r.z-(o+1)),d=[];for(let f=c;f<=s;++f)for(let m=h;m<=a;++m)for(let v=u;v<=l;++v){const _=this.Key_(f,m,v);_ in this.voxels_&&this.voxels_[_].visible&&d.push(this.voxels_[_])}return d}BuildGeometry_(r,o){const s=new De,a=new Oe(s,o);return a.castShadow=!1,a.receiveShadow=!0,s.setAttribute("position",new Fe(r.positions,3)),s.setAttribute("normal",new Fe(r.normals,3)),s.setAttribute("uv",new Fe(r.uvs,2)),s.setAttribute("uvSlice",new Fe(r.uvSlices,1)),s.setAttribute("colour",new Fe(r.colours,3)),s.setIndex(new Le(r.indices,1)),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,s.attributes.uv.needsUpdate=!0,s.attributes.colour.needsUpdate=!0,s.computeBoundingBox(),s.computeBoundingSphere(),a}RebuildMeshFromData(r){this.ReleaseAssets_(),r.opaque.positions.length>0&&(this.opaqueMesh_=this.BuildGeometry_(r.opaque,this.params_.materialOpaque),this.group_.add(this.opaqueMesh_)),r.transparent.positions.length>0&&(this.transparentMesh_=this.BuildGeometry_(r.transparent,this.params_.materialTransparent),this.group_.add(this.transparentMesh_)),this.voxels_=r.voxels,this.lastBuiltId_=r.buildId}}const t=7;class i{constructor(r){this.old_=[],this.blocks_=[],this.workerPool_=new Ng.WorkerPool(t),this.params_=r,this.currentTime_=.01}OnResult_(r,o){o.subject=="build_chunk_result"&&(r.RebuildMeshFromData(o.data),r.Show())}AllocateBlock(r){const o={...this.params_,...r},s=new e(o);return s.Hide(),this.blocks_.push(s),this.RebuildBlock_(s),s}RebuildBlock_(r){if(r.building_)return;const o={subject:"build_chunk",params:{buildId:r.buildId_,offset:r.params_.offset.toArray(),dimensions:this.params_.dimensions.toArray(),blockTypes:this.params_.blockTypes,currentTime:this.currentTime_}};r.building_=!0,this.workerPool_.Enqueue(o,s=>{r.building_=!1,this.OnResult_(r,s)})}ScheduleDestroy(r){this.old_.push(...r)}DestroyBlocks_(r){for(let o of r)o.Destroy()}get Busy(){return this.workerPool_.Busy}Update(r){this.Busy||(this.DestroyBlocks_(this.old_),this.old_=[]),this.blocks_=this.blocks_.filter(o=>!o.Destroyed);for(let o=0;o<this.blocks_.length;++o)this.blocks_[o].Dirty&&this.blocks_[o].PartialRebuild();this.currentTime_=2}}return{VoxelBuilder_Threaded:i}})(),si=(()=>({VOXEL:{VS:`
  2848. precision mediump float;
  2849. // Attributes, declared by three.js
  2850. // attribute vec3 position;
  2851. // attribute vec3 normal;
  2852. // attribute vec2 uv;
  2853. attribute vec3 colour;
  2854. attribute float uvSlice;
  2855. // Outputs
  2856. varying vec3 vNormal;
  2857. varying vec3 vColour;
  2858. varying vec3 vWorldPosition;
  2859. varying vec3 vUV;
  2860. uniform float fogTime;
  2861. #define saturate(a) clamp( a, 0.0, 1.0 )
  2862. void main(){
  2863. gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
  2864. vNormal = normal;
  2865. vColour = colour;
  2866. vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
  2867. vUV = vec3(uv, uvSlice);
  2868. }
  2869. `,PS:`
  2870. precision mediump float;
  2871. precision mediump sampler2DArray;
  2872. #define saturate(a) clamp( a, 0.0, 1.0 )
  2873. //==========================================================================================
  2874. // hashes
  2875. //==========================================================================================
  2876. float hash1( vec2 p )
  2877. {
  2878. p = 50.0*fract( p*0.3183099 );
  2879. return fract( p.x*p.y*(p.x+p.y) );
  2880. }
  2881. float hash1( float n )
  2882. {
  2883. return fract( n*17.0*fract( n*0.3183099 ) );
  2884. }
  2885. vec2 hash2( float n ) { return fract(sin(vec2(n,n+1.0))*vec2(43758.5453123,22578.1459123)); }
  2886. vec2 hash2( vec2 p )
  2887. {
  2888. const vec2 k = vec2( 0.3183099, 0.3678794 );
  2889. p = p*k + k.yx;
  2890. return fract( 16.0 * k*fract( p.x*p.y*(p.x+p.y)) );
  2891. }
  2892. //==========================================================================================
  2893. // noises
  2894. //==========================================================================================
  2895. // value noise, and its analytical derivatives
  2896. vec4 noised( in vec3 x )
  2897. {
  2898. vec3 p = floor(x);
  2899. vec3 w = fract(x);
  2900. vec3 u = w*w*w*(w*(w*6.0-15.0)+10.0);
  2901. vec3 du = 30.0*w*w*(w*(w-2.0)+1.0);
  2902. float n = p.x + 317.0*p.y + 157.0*p.z;
  2903. float a = hash1(n+0.0);
  2904. float b = hash1(n+1.0);
  2905. float c = hash1(n+317.0);
  2906. float d = hash1(n+318.0);
  2907. float e = hash1(n+157.0);
  2908. float f = hash1(n+158.0);
  2909. float g = hash1(n+474.0);
  2910. float h = hash1(n+475.0);
  2911. float k0 = a;
  2912. float k1 = b - a;
  2913. float k2 = c - a;
  2914. float k3 = e - a;
  2915. float k4 = a - b - c + d;
  2916. float k5 = a - c - e + g;
  2917. float k6 = a - b - e + f;
  2918. float k7 = - a + b + c - d + e - f - g + h;
  2919. return vec4( -1.0+2.0*(k0 + k1*u.x + k2*u.y + k3*u.z + k4*u.x*u.y + k5*u.y*u.z + k6*u.z*u.x + k7*u.x*u.y*u.z),
  2920. 2.0* du * vec3( k1 + k4*u.y + k6*u.z + k7*u.y*u.z,
  2921. k2 + k5*u.z + k4*u.x + k7*u.z*u.x,
  2922. k3 + k6*u.x + k5*u.y + k7*u.x*u.y ) );
  2923. }
  2924. float noise( in vec3 x )
  2925. {
  2926. vec3 p = floor(x);
  2927. vec3 w = fract(x);
  2928. vec3 u = w*w*w*(w*(w*6.0-15.0)+10.0);
  2929. float n = p.x + 317.0*p.y + 157.0*p.z;
  2930. float a = hash1(n+0.0);
  2931. float b = hash1(n+1.0);
  2932. float c = hash1(n+317.0);
  2933. float d = hash1(n+318.0);
  2934. float e = hash1(n+157.0);
  2935. float f = hash1(n+158.0);
  2936. float g = hash1(n+474.0);
  2937. float h = hash1(n+475.0);
  2938. float k0 = a;
  2939. float k1 = b - a;
  2940. float k2 = c - a;
  2941. float k3 = e - a;
  2942. float k4 = a - b - c + d;
  2943. float k5 = a - c - e + g;
  2944. float k6 = a - b - e + f;
  2945. float k7 = - a + b + c - d + e - f - g + h;
  2946. return -1.0+2.0*(k0 + k1*u.x + k2*u.y + k3*u.z + k4*u.x*u.y + k5*u.y*u.z + k6*u.z*u.x + k7*u.x*u.y*u.z);
  2947. }
  2948. vec3 noised( in vec2 x )
  2949. {
  2950. vec2 p = floor(x);
  2951. vec2 w = fract(x);
  2952. vec2 u = w*w*w*(w*(w*6.0-15.0)+10.0);
  2953. vec2 du = 30.0*w*w*(w*(w-2.0)+1.0);
  2954. float a = hash1(p+vec2(0,0));
  2955. float b = hash1(p+vec2(1,0));
  2956. float c = hash1(p+vec2(0,1));
  2957. float d = hash1(p+vec2(1,1));
  2958. float k0 = a;
  2959. float k1 = b - a;
  2960. float k2 = c - a;
  2961. float k4 = a - b - c + d;
  2962. return vec3( -1.0+2.0*(k0 + k1*u.x + k2*u.y + k4*u.x*u.y),
  2963. 2.0* du * vec2( k1 + k4*u.y,
  2964. k2 + k4*u.x ) );
  2965. }
  2966. float noise( in vec2 x )
  2967. {
  2968. vec2 p = floor(x);
  2969. vec2 w = fract(x);
  2970. vec2 u = w*w*w*(w*(w*6.0-15.0)+10.0);
  2971. #if 0
  2972. p *= 0.3183099;
  2973. float kx0 = 50.0*fract( p.x );
  2974. float kx1 = 50.0*fract( p.x+0.3183099 );
  2975. float ky0 = 50.0*fract( p.y );
  2976. float ky1 = 50.0*fract( p.y+0.3183099 );
  2977. float a = fract( kx0*ky0*(kx0+ky0) );
  2978. float b = fract( kx1*ky0*(kx1+ky0) );
  2979. float c = fract( kx0*ky1*(kx0+ky1) );
  2980. float d = fract( kx1*ky1*(kx1+ky1) );
  2981. #else
  2982. float a = hash1(p+vec2(0,0));
  2983. float b = hash1(p+vec2(1,0));
  2984. float c = hash1(p+vec2(0,1));
  2985. float d = hash1(p+vec2(1,1));
  2986. #endif
  2987. return -1.0+2.0*( a + (b-a)*u.x + (c-a)*u.y + (a - b - c + d)*u.x*u.y );
  2988. }
  2989. //==========================================================================================
  2990. // fbm constructions
  2991. //==========================================================================================
  2992. const mat3 m3 = mat3( 0.00, 0.80, 0.60,
  2993. -0.80, 0.36, -0.48,
  2994. -0.60, -0.48, 0.64 );
  2995. const mat3 m3i = mat3( 0.00, -0.80, -0.60,
  2996. 0.80, 0.36, -0.48,
  2997. 0.60, -0.48, 0.64 );
  2998. const mat2 m2 = mat2( 0.80, 0.60,
  2999. -0.60, 0.80 );
  3000. const mat2 m2i = mat2( 0.80, -0.60,
  3001. 0.60, 0.80 );
  3002. //------------------------------------------------------------------------------------------
  3003. float fbm_4( in vec3 x )
  3004. {
  3005. float f = 2.0;
  3006. float s = 0.5;
  3007. float a = 0.0;
  3008. float b = 0.5;
  3009. for( int i=0; i<4; i++ )
  3010. {
  3011. float n = noise(x);
  3012. a += b*n;
  3013. b *= s;
  3014. x = f*m3*x;
  3015. }
  3016. return a;
  3017. }
  3018. vec4 fbmd_8( in vec3 x )
  3019. {
  3020. float f = 1.92;
  3021. float s = 0.5;
  3022. float a = 0.0;
  3023. float b = 0.5;
  3024. vec3 d = vec3(0.0);
  3025. mat3 m = mat3(1.0,0.0,0.0,
  3026. 0.0,1.0,0.0,
  3027. 0.0,0.0,1.0);
  3028. for( int i=0; i<7; i++ )
  3029. {
  3030. vec4 n = noised(x);
  3031. a += b*n.x; // accumulate values
  3032. d += b*m*n.yzw; // accumulate derivatives
  3033. b *= s;
  3034. x = f*m3*x;
  3035. m = f*m3i*m;
  3036. }
  3037. return vec4( a, d );
  3038. }
  3039. vec4 fbmd_4( in vec3 x )
  3040. {
  3041. float f = 1.92;
  3042. float s = 0.5;
  3043. float a = 0.0;
  3044. float b = 0.5;
  3045. vec3 d = vec3(0.0);
  3046. mat3 m = mat3(1.0,0.0,0.0,
  3047. 0.0,1.0,0.0,
  3048. 0.0,0.0,1.0);
  3049. for( int i=0; i<4; i++ )
  3050. {
  3051. vec4 n = noised(x);
  3052. a += b*n.x; // accumulate values
  3053. d += b*m*n.yzw; // accumulate derivatives
  3054. b *= s;
  3055. x = f*m3*x;
  3056. m = f*m3i*m;
  3057. }
  3058. return vec4( a, d );
  3059. }
  3060. float fbm_9( in vec2 x )
  3061. {
  3062. float f = 1.9;
  3063. float s = 0.55;
  3064. float a = 0.0;
  3065. float b = 0.5;
  3066. for( int i=0; i<9; i++ )
  3067. {
  3068. float n = noise(x);
  3069. a += b*n;
  3070. b *= s;
  3071. x = f*m2*x;
  3072. }
  3073. return a;
  3074. }
  3075. vec3 fbmd_9( in vec2 x )
  3076. {
  3077. float f = 1.9;
  3078. float s = 0.55;
  3079. float a = 0.0;
  3080. float b = 0.5;
  3081. vec2 d = vec2(0.0);
  3082. mat2 m = mat2(1.0,0.0,0.0,1.0);
  3083. for( int i=0; i<9; i++ )
  3084. {
  3085. vec3 n = noised(x);
  3086. a += b*n.x; // accumulate values
  3087. d += b*m*n.yz; // accumulate derivatives
  3088. b *= s;
  3089. x = f*m2*x;
  3090. m = f*m2i*m;
  3091. }
  3092. return vec3( a, d );
  3093. }
  3094. float fbm_4( in vec2 x )
  3095. {
  3096. float f = 1.9;
  3097. float s = 0.55;
  3098. float a = 0.0;
  3099. float b = 0.5;
  3100. for( int i=0; i<4; i++ )
  3101. {
  3102. float n = noise(x);
  3103. a += b*n;
  3104. b *= s;
  3105. x = f*m2*x;
  3106. }
  3107. return a;
  3108. }
  3109. float sum( vec3 v ) { return v.x+v.y+v.z; }
  3110. vec4 hash4( vec2 p ) {
  3111. return fract(
  3112. sin(vec4(1.0+dot(p,vec2(37.0,17.0)),
  3113. 2.0+dot(p,vec2(11.0,47.0)),
  3114. 3.0+dot(p,vec2(41.0,29.0)),
  3115. 4.0+dot(p,vec2(23.0,31.0))))*103.0);
  3116. }
  3117. float smootherstep(float a, float b, float x) {
  3118. x = x * x * x * (x * (x * 6.0 - 15.0) + 10.0);
  3119. return x * (b - a) + a;
  3120. }
  3121. uniform vec3 fogColour;
  3122. uniform float fogDensity;
  3123. uniform vec2 fogRange;
  3124. uniform float fogTime;
  3125. uniform float fade;
  3126. uniform float flow;
  3127. uniform sampler2DArray diffuseMap;
  3128. uniform sampler2D noiseMap;
  3129. varying vec3 vUV;
  3130. varying vec3 vNormal;
  3131. varying vec3 vColour;
  3132. varying vec3 vWorldPosition;
  3133. vec4 _FogWithHeight() {
  3134. vec3 fogOrigin = cameraPosition;
  3135. vec3 fogDirection = normalize(vWorldPosition - fogOrigin);
  3136. float fogDepth = distance(vWorldPosition, fogOrigin);
  3137. // vec3 noiseSampleCoord = vWorldPosition * 0.05 + vec3(0, fogTime * 0.5, 0);
  3138. // float noiseSample = fbm_4(noiseSampleCoord + fbm_4(noiseSampleCoord)) * 0.5 + 0.5;
  3139. // fogDepth *= mix(noiseSample, 1.0, saturate((fogDepth - 250.0) / 500.0));
  3140. fogDepth *= fogDepth;
  3141. float heightFactor = 0.025;
  3142. float fogFactor = heightFactor * exp(-fogOrigin.y * fogDensity) * (
  3143. 1.0 - exp(-fogDepth * fogDirection.y * fogDensity)) / fogDirection.y;
  3144. fogFactor = saturate(fogFactor);
  3145. return vec4(fogColour, fogFactor);
  3146. }
  3147. vec4 _Fog() {
  3148. vec3 fogOrigin = cameraPosition;
  3149. vec3 fogDirection = normalize(vWorldPosition - fogOrigin);
  3150. float fogDepth = distance(vWorldPosition, fogOrigin);
  3151. float fogFactor = saturate((fogDepth - fogRange.x) / fogRange.y);
  3152. vec3 noiseSampleCoord = vWorldPosition * 0.05 + vec3(0, fogTime * 0.5, 0);
  3153. float noiseSample = fbm_4(noiseSampleCoord + fbm_4(noiseSampleCoord)) * 0.5 + 0.5;
  3154. float noiseDropoff = saturate((fogDepth - fogRange.x) / fogRange.y);
  3155. noiseDropoff *= noiseDropoff;
  3156. noiseDropoff = mix(noiseSample, 1.0, noiseDropoff);
  3157. fogFactor *= noiseDropoff;
  3158. vec3 fogColourWithNoise = fogColour * noiseDropoff;
  3159. return vec4(fogColourWithNoise, smootherstep(0.0, 1.0, fogFactor));
  3160. }
  3161. void main() {
  3162. vec4 diffuse = sRGBToLinear(texture2D(diffuseMap, vUV));
  3163. vec3 hemiLight1 = vec3(1.0, 1.0, 1.0);
  3164. vec3 hemiLight2 = vec3(0.5, 0.1, 0.5);
  3165. vec3 sunLightDir = normalize(vec3(0.1, 1.0, 0.0));
  3166. vec3 lighting = saturate(dot(vNormal, sunLightDir)) * 0.25 + vColour * 1.0;
  3167. vec4 outColour = vec4(diffuse.xyz * lighting, 0.75 * fade);
  3168. vec3 noiseDir = abs(vNormal);
  3169. vec2 noiseCoords = (
  3170. noiseDir.x * vWorldPosition.yz +
  3171. noiseDir.y * vWorldPosition.xz +
  3172. noiseDir.z * vWorldPosition.xy);
  3173. vec4 noisePixel = texture2D(noiseMap, noiseCoords / 64.0) * 0.2 + 0.8;
  3174. outColour.xyz *= noisePixel.xyz;
  3175. vec4 fog = _FogWithHeight();
  3176. outColour.xyz = mix(outColour.xyz, fog.xyz, fog.w);
  3177. gl_FragColor = outColour;
  3178. }
  3179. `},CLOUD:{VS:`
  3180. precision mediump float;
  3181. // Attributes, declared by three.js
  3182. // attribute vec3 position;
  3183. // attribute vec3 normal;
  3184. // attribute vec2 uv;
  3185. // Outputs
  3186. varying vec3 vWorldPosition;
  3187. varying vec3 vNormal;
  3188. #define saturate(a) clamp( a, 0.0, 1.0 )
  3189. void main(){
  3190. gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
  3191. vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
  3192. vNormal = normal;
  3193. }
  3194. `,PS:`
  3195. precision mediump float;
  3196. precision mediump sampler2DArray;
  3197. varying vec3 vWorldPosition;
  3198. varying vec3 vNormal;
  3199. uniform vec3 cloudMin;
  3200. uniform vec3 cloudMax;
  3201. #define saturate(a) clamp( a, 0.0, 1.0 )
  3202. // https://gist.github.com/DomNomNom/46bb1ce47f68d255fd5d
  3203. float GetAABBDepth(vec3 rayOrigin, vec3 rayDir, vec3 boxMin, vec3 boxMax) {
  3204. vec3 tMin = (boxMin - rayOrigin) / rayDir;
  3205. vec3 tMax = (boxMax - rayOrigin) / rayDir;
  3206. vec3 t1 = min(tMin, tMax);
  3207. vec3 t2 = max(tMin, tMax);
  3208. float tNear = max(max(t1.x, t1.y), t1.z);
  3209. float tFar = min(min(t2.x, t2.y), t2.z);
  3210. return (tFar - tNear);
  3211. }
  3212. vec4 GetCloudShading(vec3 rayOrigin, vec3 rayDir, vec3 boxMin, vec3 boxMax) {
  3213. float depth = GetAABBDepth(rayOrigin, rayDir, boxMin, boxMax);
  3214. float cloudDensity = 0.01;
  3215. float opacity = 1.0 - exp(-cloudDensity * cloudDensity * depth * depth);
  3216. vec3 sunDir = normalize(vec3(-1.0, -4.0, 0.0));
  3217. return vec4(vec3(saturate(dot(sunDir, vNormal)) + 0.75), opacity);
  3218. }
  3219. float sdBox( vec3 p, vec3 b, float r ) {
  3220. vec3 d = abs(p) - b;
  3221. return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)) - r;
  3222. }
  3223. float map( in vec3 pos )
  3224. {
  3225. return sdBox(pos, (cloudMax - cloudMin) * 0.25, 0.0);
  3226. }
  3227. // http://iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
  3228. vec3 calcNormal( in vec3 pos )
  3229. {
  3230. // inspired by tdhooper and klems - a way to prevent the compiler from inlining map() 4 times
  3231. vec3 n = vec3(0.0);
  3232. for( int i=0; i<4; i++ )
  3233. {
  3234. vec3 e = 0.5773*(2.0*vec3((((i+3)>>1)&1),((i>>1)&1),(i&1))-1.0);
  3235. n += e*map(pos+0.0005*e);
  3236. }
  3237. return normalize(n);
  3238. }
  3239. void main() {
  3240. vec3 fixedPosition = (cloudMax + cloudMin) * 0.5;
  3241. vec3 viewDirection = normalize(vWorldPosition - cameraPosition);
  3242. vec4 cloudColour = GetCloudShading(cameraPosition, viewDirection, cloudMin, cloudMax);
  3243. gl_FragColor = cloudColour;
  3244. }
  3245. `},SUN:{VS:`
  3246. precision mediump float;
  3247. // Attributes, declared by three.js
  3248. // attribute vec3 position;
  3249. // attribute vec3 normal;
  3250. // attribute vec2 uv;
  3251. // Outputs
  3252. varying vec3 vWorldPosition;
  3253. varying vec2 vUV;
  3254. #define saturate(a) clamp( a, 0.0, 1.0 )
  3255. void main(){
  3256. gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
  3257. vUV = uv;
  3258. }
  3259. `,PS:`
  3260. precision mediump float;
  3261. precision mediump sampler2DArray;
  3262. varying vec3 vWorldPosition;
  3263. varying vec2 vUV;
  3264. #define saturate(a) clamp( a, 0.0, 1.0 )
  3265. float sdCircle( vec2 p, float r )
  3266. {
  3267. return length(p) - r;
  3268. }
  3269. float sdf_Box(vec2 coords, vec2 bounds) {
  3270. vec2 dist = abs(coords) - bounds;
  3271. return length(max(dist, 0.0)) + min(max(dist.x, dist.y), 0.0);
  3272. }
  3273. float smootherstep(float a, float b, float x) {
  3274. x = clamp((x - a) / (b - a), 0.0, 1.0);
  3275. return x * x * x * (x * ( x * 6.0 - 15.0) + 10.0);
  3276. }
  3277. float hash1( vec2 p )
  3278. {
  3279. p = 50.0*fract( p*0.3183099 );
  3280. return fract( p.x*p.y*(p.x+p.y) );
  3281. }
  3282. float noise( in vec2 x )
  3283. {
  3284. vec2 p = floor(x);
  3285. vec2 w = fract(x);
  3286. vec2 u = w*w*w*(w*(w*6.0-15.0)+10.0);
  3287. float a = hash1(p+vec2(0,0));
  3288. float b = hash1(p+vec2(1,0));
  3289. float c = hash1(p+vec2(0,1));
  3290. float d = hash1(p+vec2(1,1));
  3291. return -1.0+2.0*( a + (b-a)*u.x + (c-a)*u.y + (a - b - c + d)*u.x*u.y );
  3292. }
  3293. void main() {
  3294. vec2 uvStepped = floor(vUV * 32.0) / 32.0;
  3295. float sunRadius = 0.125;
  3296. //float d = 1.0 - clamp(sdCircle(uvStepped - 0.5, sunRadius) / (0.5 - sunRadius), 0.0, 1.0);
  3297. float d = 1.0 - clamp(sdf_Box(uvStepped - 0.5, vec2(sunRadius)) / (0.5 - sunRadius), 0.0, 1.0);
  3298. float noiseValue = noise(uvStepped * 32.0) * 0.1 + 0.9;
  3299. vec4 core = sRGBToLinear(vec4(0.96, 0.9, 0.7, 1.0));
  3300. vec4 corona = sRGBToLinear(vec4(0.5, 0.2, 0.05, 1.0)) * noiseValue;
  3301. vec4 sunColour = mix(corona, core, d * d);
  3302. gl_FragColor = vec4(sunColour.xyz, d);
  3303. }
  3304. `},PLACEMENT:{VS:`
  3305. precision mediump float;
  3306. // Attributes, declared by three.js
  3307. // attribute vec3 position;
  3308. // attribute vec3 normal;
  3309. // attribute vec2 uv;
  3310. // Outputs
  3311. varying vec2 vUV;
  3312. void main(){
  3313. gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
  3314. vUV = uv;
  3315. }
  3316. `,PS:`
  3317. precision mediump float;
  3318. precision mediump sampler2DArray;
  3319. uniform float time;
  3320. uniform vec3 edgeColour;
  3321. #define saturate(a) clamp( a, 0.0, 1.0 )
  3322. varying vec2 vUV;
  3323. float sdf_Box(vec2 coords, vec2 bounds) {
  3324. vec2 dist = abs(coords) - bounds;
  3325. return length(max(dist, 0.0)) + min(max(dist.x, dist.y), 0.0);
  3326. }
  3327. float smootherstep(float a, float b, float x) {
  3328. x = clamp((x - a) / (b - a), 0.0, 1.0);
  3329. return x * x * x * (x * ( x * 6.0 - 15.0) + 10.0);
  3330. }
  3331. void main() {
  3332. float d = sdf_Box(vUV - 0.5, vec2(0.5));
  3333. float s = smoothstep(0.0, 0.1, abs(d));
  3334. float edgeColouring = mix(0.0, 1.0, 1.0 - s);
  3335. float blink = clamp(sin(time * 10.0), 0.0, 1.0) * 0.1 + 0.9;
  3336. gl_FragColor = vec4(edgeColour, edgeColouring * blink);
  3337. }
  3338. `}}))(),Dg=(()=>{function e(i){var n=document.createElement("canvas");n.width=i.width,n.height=i.height;var r=n.getContext("2d");return r.drawImage(i,0,0),r.getImageData(0,0,i.width,i.height)}class t{constructor(){this.Create_(),this.onLoad=()=>{}}Load(n,r){this.LoadAtlas_(n,r)}Create_(){this.manager_=new Jl,this.loader_=new Wn(this.manager_),this.textures_={},this.manager_.onLoad=()=>{this.OnLoad_()}}get Info(){return this.textures_}LoadTexture_(n){const r=this.loader_.load(n);return r.encoding=Vi,r}OnLoad_(){for(let n in this.textures_){const r=this.textures_[n],o=new Uint8Array(r.textures.length*4*16*16);for(let a=0;a<r.textures.length;a++){const l=r.textures[a],c=e(l.image),h=a*(4*16*16);o.set(c.data,h)}const s=new Ln(o,16,16,r.textures.length);s.format=wt,s.type=Ur,s.minFilter=Ta,s.magFilter=rt,s.wrapS=ut,s.wrapT=ut,s.generateMipmaps=!0,s.encoding=Vi,r.atlas=s}this.onLoad()}LoadAtlas_(n,r){this.textures_[n]={textures:r.map(o=>this.LoadTexture_(o)),atlas:null}}}return{TextureAtlas:t}})(),la=(()=>({DEFS:{ocean:{colour:new he(16777215),texture:"ocean.png"},dirt:{colour:new he(16777215),texture:"dirt.png"},sand:{colour:new he(16777215),texture:"sand.png"},stone:{colour:new he(16777215),texture:"stone.png"},tree_bark:{colour:new he(16777215),texture:"tree-bark.png"},tree_leaves:{colour:new he(16777215),texture:"tree-leaves.png"},moon:{colour:new he(16777215),texture:"moon.png"},snow:{colour:new he(16777215),texture:["snow-side.png","snow-side.png","snow.png","snow.png","snow-side.png","snow-side.png"]},grass:{colour:new he(16777215),texture:["grass-side.png","grass-side.png","grass.png","dirt.png","grass-side.png","grass-side.png"]}}}))(),Ug=(()=>{const t=class t extends Ut.Component{get NAME(){return t.CLASS_NAME}constructor(n){super(),this.blocks_={},this.cellDimensions_=new A(n.cellSize,n.cellSize,n.cellSize),this.visibleDimensions_=[n.worldSize,n.worldSize],this.dirtyBlocks_={},this.ids_=0,this.totalTime_=0}InitEntity(){this.scene_=this.FindEntity("renderer").GetComponent("ThreeJSController").scene_,this.materialOpaque_=new Qe({uniforms:{diffuseMap:{value:null},noiseMap:{value:null},fogColour:{value:_t.FOG_COLOUR.clone()},fogDensity:{value:65e-6},fogRange:{value:new le(250,250)},fogTime:{value:0},fade:{value:1},flow:{value:0}},vertexShader:si.VOXEL.VS,fragmentShader:si.VOXEL.PS,side:Gt}),this.materialTransparent_=this.materialOpaque_.clone(),this.materialTransparent_.side=Gt,this.materialTransparent_.transparent=!0,this.LoadTextures_(),this.builder_=new Og.VoxelBuilder_Threaded({scene:this.scene_,dimensions:this.cellDimensions_,materialOpaque:this.materialOpaque_,materialTransparent:this.materialTransparent_,blockTypes:this.blockTypes_})}LoadTextures_(){this.blockTypes_={};const n=new Set;for(let l in la.DEFS){const c=la.DEFS[l];if(this.blockTypes_[l]={textures:[]},c.texture instanceof Array)for(let h=0;h<c.texture.length;++h)n.add(c.texture[h]),this.blockTypes_[l].textures.push(c.texture[h]);else for(let h=0;h<6;++h)n.add(c.texture),this.blockTypes_[l].textures.push(c.texture)}const r=[...n];for(let l in this.blockTypes_)for(let c=0;c<6;++c)this.blockTypes_[l].textures[c]=r.indexOf(this.blockTypes_[l].textures[c]);const o="./resources/minecraft/textures/blocks/",s=new Dg.TextureAtlas;s.Load("diffuse",r.map(l=>o+l)),s.onLoad=()=>{this.materialOpaque_.uniforms.diffuseMap.value=s.Info.diffuse.atlas,this.materialTransparent_.uniforms.diffuseMap.value=s.Info.diffuse.atlas};const a=new Wn().load("./resources/simplex-noise.png");a.wrapS=Mi,a.wrapT=Mi,a.minFilter=Ta,a.magFilter=rt,this.materialOpaque_.uniforms.noiseMap.value=a,this.materialTransparent_.uniforms.noiseMap.value=a}Key_(n,r,o){return n+"."+r+"."+o}BlockIndex_(n,r){const o=Math.floor(n/this.cellDimensions_.x),s=Math.floor(r/this.cellDimensions_.z);return[o,s]}FindBlock_(n,r){const[o,s]=this.BlockIndex_(n,r),a=this.Key_(o,0,s);return a in this.blocks_?this.blocks_[a]:null}GetAdjacentBlocks(n,r){const o=[];for(let s=-1;s<=1;++s)for(let a=-1;a<=1;++a){if(s==0&&a==0)continue;const[l,c]=this.BlockIndex_(n,r),h=this.Key_(l+s,0,c+a);h in this.blocks_&&o.push(this.blocks_[h])}return o}InsertVoxelAt(n,r,o){const s=this.FindBlock_(n[0],n[2]);s&&s.InsertVoxelAt(n,r,o)}RemoveVoxelAt(n){const r=this.FindBlock_(n[0],n[2]);r&&r.RemoveVoxelAt(n)}HasVoxelAt(n,r,o){const s=this.FindBlock_(n,o);return s?s.HasVoxelAt(n,r,o):!1}FindVoxelsNear(n,r){const[o,s]=this.BlockIndex_(n.x-r,n.z-r),[a,l]=this.BlockIndex_(n.x+r,n.z+r),c=[];for(let h=o;h<=a;h++)for(let u=s;u<=l;u++){const d=this.Key_(h,0,u);if(d in this.blocks_){const f=this.blocks_[d];c.push(...f.FindVoxelsNear(n,r))}}return c}FindIntersectionsWithRay(n,r){const o=this.FindVoxelsNear(n.origin,r),s=[],a=h=>{const u=new A(h.position[0],h.position[1],h.position[2]),d=new A(.5,.5,.5),f=new A;f.copy(u),f.sub(d);const m=new A;return m.copy(u),m.add(d),new dt(f,m)},l=o.map(h=>a(h)),c=new A;for(let h=0;h<l.length;++h)n.intersectBox(l[h],c)&&s.push({voxel:o[h],aabb:l[h],intersectionPoint:c.clone(),distance:c.distanceTo(n.origin)});return s.sort((h,u)=>h.distance-u.distance),s}Update(n){this.builder_.Update(n),this.builder_.Busy||this.UpdateTerrain_(),this.totalTime_+=n,this.materialOpaque_.uniforms.fogTime.value=this.totalTime_*.5,this.materialTransparent_.uniforms.fogTime.value=this.totalTime_*.5,this.materialTransparent_.uniforms.flow.value=this.totalTime_*.5;const r=this.FindEntity("renderer").GetComponent("ThreeJSController");r.sky_.material.uniforms.whiteBlend.value=this.builder_.currentTime_,this.FindEntity("player").Position.y<6&&!Fr.skipOceans?(this.materialOpaque_.uniforms.fogRange.value.set(..._t.UNDERWATER_RANGE),this.materialTransparent_.uniforms.fogRange.value.set(..._t.UNDERWATER_RANGE),this.materialOpaque_.uniforms.fogColour.value.copy(_t.UNDERWATER_COLOUR),this.materialTransparent_.uniforms.fogColour.value.copy(_t.UNDERWATER_COLOUR),r.sky_.material.uniforms.bottomColor.value.copy(_t.UNDERWATER_COLOUR)):(this.materialOpaque_.uniforms.fogRange.value.set(..._t.FOG_RANGE),this.materialTransparent_.uniforms.fogRange.value.set(..._t.FOG_RANGE),this.materialOpaque_.uniforms.fogColour.value.copy(_t.FOG_COLOUR),this.materialTransparent_.uniforms.fogColour.value.copy(_t.FOG_COLOUR),r.sky_.material.uniforms.bottomColor.value.copy(_t.FOG_COLOUR)),r.sky_.material.needsUpdate=!0,this.materialOpaque_.needsUpdate=!0,this.materialTransparent_.needsUpdate=!0}UpdateTerrain_(){const n=this.FindEntity("player"),r=this.BlockIndex_(n.Position.x,n.Position.z),o=this.visibleDimensions_[0],s=this.visibleDimensions_[1];let a={};for(let d=-o;d<=o;d++)for(let f=-s;f<=s;f++){const m=d+r[0],v=f+r[1],_=this.Key_(m,0,v);a[_]=[m,v]}const l=sa.DictIntersection(this.blocks_,a),c=sa.DictDifference(a,this.blocks_),h=Object.values(sa.DictDifference(this.blocks_,a));this.builder_.ScheduleDestroy(h),a=l;const u=[];for(let d in c){const[f,m]=c[d],v=((r[0]-f)**2+(r[1]-m)**2)**.5;u.push([v,d,c[d]])}u.sort((d,f)=>d[0]-f[0]);for(let d=0;d<u.length;++d){const f=u[d][1],[m,v]=u[d][2],_=new A(m*this.cellDimensions_.x,0,v*this.cellDimensions_.z);a[f]=this.builder_.AllocateBlock({parent:this,offset:_})}this.blocks_=a}};wi(t,"CLASS_NAME","SparseVoxelCellManager");let e=t;return{SparseVoxelCellManager:e}})(),zg=(()=>{class e{constructor(){this._ids=0,this._entitiesMap={},this._entities=[]}_GenerateName(){return this._ids+=1,"__name__"+this._ids}Get(i){return this._entitiesMap[i]}Filter(i){return this._entities.filter(i)}Add(i,n){n||(n=this._GenerateName()),this._entitiesMap[n]=i,this._entities.push(i),i.SetParent(this),i.SetName(n),i.InitEntity()}SetActive(i,n){const r=this._entities.indexOf(i);if(n){if(r>=0)return;this._entities.push(i)}else{if(r<0)return;this._entities.splice(r,1)}}Update(i){const n=[],r=[];for(let o=0;o<this._entities.length;++o){const s=this._entities[o];s.Update(i),s.dead_?n.push(s):r.push(s)}for(let o=0;o<n.length;++o){const s=n[o];delete this._entitiesMap[s.Name],s.Destroy()}this._entities=r}}return{EntityManager:e}})(),kg=function(){const t=class t extends Ut.Component{get NAME(){return t.CLASS_NAME}constructor(){super(),this.clouds_=[]}InitEntity(){const n=this.FindEntity("renderer").GetComponent("ThreeJSController"),r=new gi(1,1,1);this.group_=new ft;for(let o=0;o<20;++o){const s=lt.rand_int(5,10)*20,a=lt.rand_int(5,10)*20,l=lt.rand_int(-150,150)*10,c=lt.rand_int(0,10)*25,h=lt.rand_int(-150,150)*10,u=new Qe({uniforms:{cloudMin:{value:null},cloudMax:{value:null}},vertexShader:si.CLOUD.VS,fragmentShader:si.CLOUD.PS,side:Gt,transparent:!0}),d=new Oe(r,u);d.position.set(l,c,h),d.scale.set(s,50,a),this.group_.add(d),this.clouds_.push(d)}this.group_.visible=!Fr.skipClouds,n.scene_.add(this.group_),this.CreateSun_()}CreateSun_(){const n=new Kt(300,300),r=new Qe({uniforms:{},vertexShader:si.SUN.VS,fragmentShader:si.SUN.PS,side:Gt,transparent:!0,blending:ko}),o=new Oe(n,r);o.position.set(692,39,-286),o.rotateX(.5*2*Math.PI),o.lookAt(0,0,0),this.group_.add(o)}Update(n){const r=this.FindEntity("player").Position;this.group_.position.set(r.x,250,r.z);for(let o=0;o<this.clouds_.length;++o){const s=this.clouds_[o];s.updateMatrixWorld(!0);const a=s.material;a.uniforms.cloudMin.value=new A(-.5,-.5,-.5),a.uniforms.cloudMax.value=new A(.5,.5,.5),a.uniforms.cloudMin.value.applyMatrix4(s.matrixWorld),a.uniforms.cloudMax.value.applyMatrix4(s.matrixWorld)}}};wi(t,"CLASS_NAME","CloudController");let e=t;return{CloudController:e}}();var Do=function(e,t){t===void 0&&(console.warn('THREE.PointerLockControls: The second parameter "domElement" is now mandatory.'),t=document.body),this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI;var i=this,n={type:"change"},r={type:"lock"},o={type:"unlock"},s=new Qn(0,0,0,"YXZ"),a=Math.PI/2,l=new A;function c(d){if(i.isLocked!==!1){var f=d.movementX||d.mozMovementX||d.webkitMovementX||0,m=d.movementY||d.mozMovementY||d.webkitMovementY||0;s.setFromQuaternion(e.quaternion),s.y-=f*.002,s.x-=m*.002,s.x=Math.max(a-i.maxPolarAngle,Math.min(a-i.minPolarAngle,s.x)),e.quaternion.setFromEuler(s),i.dispatchEvent(n)}}function h(){i.domElement.ownerDocument.pointerLockElement===i.domElement?(i.dispatchEvent(r),i.isLocked=!0):(i.dispatchEvent(o),i.isLocked=!1)}function u(){console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}this.connect=function(){i.domElement.ownerDocument.addEventListener("mousemove",c),i.domElement.ownerDocument.addEventListener("pointerlockchange",h),i.domElement.ownerDocument.addEventListener("pointerlockerror",u)},this.disconnect=function(){i.domElement.ownerDocument.removeEventListener("mousemove",c),i.domElement.ownerDocument.removeEventListener("pointerlockchange",h),i.domElement.ownerDocument.removeEventListener("pointerlockerror",u)},this.dispose=function(){this.disconnect()},this.getObject=function(){return e},this.getDirection=function(){var d=new A(0,0,-1);return function(f){return f.copy(d).applyQuaternion(e.quaternion)}}(),this.moveForward=function(d){l.setFromMatrixColumn(e.matrix,0),l.crossVectors(e.up,l),e.position.addScaledVector(l,d)},this.moveRight=function(d){l.setFromMatrixColumn(e.matrix,0),e.position.addScaledVector(l,d)},this.lock=function(){this.domElement.requestPointerLock()},this.unlock=function(){i.domElement.ownerDocument.exitPointerLock()},this.connect()};Do.prototype=Object.create(ci.prototype),Do.prototype.constructor=Do;const Hg=(()=>{const t=class t extends Ut.Component{get NAME(){return t.CLASS_NAME}constructor(){super()}InitEntity(){this.radius_=1.5,this.keys_={forward:!1,backward:!1,left:!1,right:!1},this.standing=!0,this.velocity_=new A(0,0,0),this.decceleration_=new A(-10,-9.8*5,-10),this.acceleration_=new A(75,20,75),this.acceleration_=new A(200,25,200);const n=this.FindEntity("renderer").GetComponent("ThreeJSController");this.element_=n.threejs_.domElement,this.camera_=n.camera_,this.SetupPointerLock_(),this.controls_=new Do(this.camera_,document.body),n.scene_.add(this.controls_.getObject()),this.controls_.getObject().position.copy(this.Parent.Position),document.addEventListener("keydown",r=>this.OnKeyDown_(r),!1),document.addEventListener("keyup",r=>this.OnKeyUp_(r),!1)}OnKeyDown_(n){switch(n.keyCode){case 38:case 87:this.keys_.forward=!0;break;case 37:case 65:this.keys_.left=!0;break;case 40:case 83:this.keys_.backward=!0;break;case 39:case 68:this.keys_.right=!0;break;case 32:this.standing&&(this.velocity_.y=this.acceleration_.y,this.standing=!1);break}}OnKeyUp_(n){switch(n.keyCode){case 38:case 87:this.keys_.forward=!1;break;case 37:case 65:this.keys_.left=!1;break;case 40:case 83:this.keys_.backward=!1;break;case 39:case 68:this.keys_.right=!1;break;case 79:break;case 80:break;case 84:this.OnCycleTools_();break;case 219:this.OnCycleTextures_(-1);break;case 221:this.OnCycleTextures_(1);break;case 13:this.keys_.enter=!0;break}}_onMouseUp(n){this.keys_.enter=!0}SetupPointerLock_(){if("pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document){const n=o=>{document.pointerLockElement===document.body||document.mozPointerLockElement===document.body||document.webkitPointerLockElement===document.body?(this.enabled_=!0,this.controls_.enabled=!0):this.controls_.enabled=!1},r=o=>{console.log(o)};document.addEventListener("pointerlockchange",n,!1),document.addEventListener("webkitpointerlockchange",n,!1),document.addEventListener("mozpointerlockchange",n,!1),document.addEventListener("pointerlockerror",r,!1),document.addEventListener("mozpointerlockerror",r,!1),document.addEventListener("webkitpointerlockerror",r,!1),this.element_.addEventListener("click",o=>{if(document.body.requestPointerLock=document.body.requestPointerLock||document.body.mozRequestPointerLock||document.body.webkitRequestPointerLock,/Firefox/i.test(navigator.userAgent)){const s=a=>{(document.fullscreenElement===document.body||document.mozFullscreenElement===document.body||document.mozFullScreenElement===document.body)&&(document.removeEventListener("fullscreenchange",s),document.removeEventListener("mozfullscreenchange",s),document.body.requestPointerLock())};document.addEventListener("fullscreenchange",s,!1),document.addEventListener("mozfullscreenchange",s,!1),document.body.requestFullscreen=document.body.requestFullscreen||document.body.mozRequestFullscreen||document.body.mozRequestFullScreen||document.body.webkitRequestFullscreen,document.body.requestFullscreen()}else document.body.requestPointerLock()},!1)}}_FindIntersections(n,r){const o=new Zt(r,this.radius_);return n.filter(s=>o.intersectsBox(s))}OnCycleTools_(){this.FindEntity("ui").GetComponent("UIController").CycleTool_()}OnCycleTextures_(n){this.FindEntity("ui").GetComponent("UIController").CycleBuildIcon_(n)}Update(n){const r=this.controls_.getObject();this.keys_.enter&&this.Broadcast({topic:"input.pressed",value:"enter"}),this.keys_.enter=!1;const o=this.velocity_,s=new A(this.velocity_.x*this.decceleration_.x,this.decceleration_.y,this.velocity_.z*this.decceleration_.z);s.multiplyScalar(n),s.z=Math.sign(s.z)*Math.min(Math.abs(s.z),Math.abs(o.z)),this.velocity_.add(s),this.velocity_.y=Math.max(this.velocity_.y,-50),this.keys_.forward&&(this.velocity_.z-=this.acceleration_.z*n),this.keys_.backward&&(this.velocity_.z+=this.acceleration_.z*n),this.keys_.left&&(this.velocity_.x-=this.acceleration_.x*n),this.keys_.right&&(this.velocity_.x+=this.acceleration_.x*n);const a=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager").FindVoxelsNear(r.position,3).filter(g=>g.type!="ocean"),l=g=>{const p=new A(g.position[0],g.position[1],g.position[2]),E=new A(.5,.5,.5),S=new A;S.copy(p),S.sub(E);const T=new A;return T.copy(p),T.add(E),new dt(S,T)},c=a.map(g=>l(g)),h=new A;h.copy(r.position);const u=new A(0,0,1);u.applyQuaternion(r.quaternion),u.y=0,u.normalize();const d=new A(1,0,0);d.applyQuaternion(r.quaternion),d.normalize(),d.multiplyScalar(this.velocity_.x*n),u.multiplyScalar(this.velocity_.z*n);const f=this._FindIntersections(c,r.position).length>0;r.position.add(u),r.position.add(d);let m=this._FindIntersections(c,r.position);m.length>0&&!f&&r.position.copy(h),h.copy(r.position);const v=.01;let _=v;for(;_<n;){if(r.position.y+=this.velocity_.y*_,m=this._FindIntersections(c,r.position),m.length>0){r.position.copy(h),this.velocity_.y=Math.max(0,this.velocity_.y),this.standing=!0;break}_=Math.min(_+v,n)}r.position.y<-100&&(this.velocity_.y=0,r.position.y=250,this.standing=!0),this.Parent.SetPosition(r.position),this.Parent.SetQuaternion(r.quaternion)}};wi(t,"CLASS_NAME","PlayerController");let e=t;return{PlayerController:e}})();var Bg=function(){function e(M){Ue.call(this,M),this.dracoLoader=null,this.ddsLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(w){return new s(w)}),this.register(function(w){return new l(w)}),this.register(function(w){return new c(w)}),this.register(function(w){return new a(w)}),this.register(function(w){return new r(w)}),this.register(function(w){return new h(w)})}e.prototype=Object.assign(Object.create(Ue.prototype),{constructor:e,load:function(M,w,O,P){var F=this,R;this.resourcePath!==""?R=this.resourcePath:this.path!==""?R=this.path:R=Yn.extractUrlBase(M),this.manager.itemStart(M);var N=function(V){P?P(V):console.error(V),F.manager.itemError(M),F.manager.itemEnd(M)},I=new Yt(this.manager);I.setPath(this.path),I.setResponseType("arraybuffer"),I.setRequestHeader(this.requestHeader),I.setWithCredentials(this.withCredentials),I.load(M,function(V){try{F.parse(V,R,function(X){w(X),F.manager.itemEnd(M)},N)}catch(X){N(X)}},O,N)},setDRACOLoader:function(M){return this.dracoLoader=M,this},setDDSLoader:function(M){return this.ddsLoader=M,this},setKTX2Loader:function(M){return this.ktx2Loader=M,this},setMeshoptDecoder:function(M){return this.meshoptDecoder=M,this},register:function(M){return this.pluginCallbacks.indexOf(M)===-1&&this.pluginCallbacks.push(M),this},unregister:function(M){return this.pluginCallbacks.indexOf(M)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(M),1),this},parse:function(M,w,O,P){var F,R={},N={};if(typeof M=="string")F=M;else{var I=Yn.decodeText(new Uint8Array(M,0,4));if(I===u){try{R[i.KHR_BINARY_GLTF]=new m(M)}catch(q){P&&P(q);return}F=R[i.KHR_BINARY_GLTF].content}else F=Yn.decodeText(new Uint8Array(M))}var V=JSON.parse(F);if(V.asset===void 0||V.asset.version[0]<2){P&&P(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}var X=new ce(V,{path:w||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});X.fileLoader.setRequestHeader(this.requestHeader);for(var Q=0;Q<this.pluginCallbacks.length;Q++){var b=this.pluginCallbacks[Q](X);N[b.name]=b,R[b.name]=!0}if(V.extensionsUsed)for(var Q=0;Q<V.extensionsUsed.length;++Q){var y=V.extensionsUsed[Q],J=V.extensionsRequired||[];switch(y){case i.KHR_MATERIALS_UNLIT:R[y]=new o;break;case i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:R[y]=new p;break;case i.KHR_DRACO_MESH_COMPRESSION:R[y]=new v(V,this.dracoLoader);break;case i.MSFT_TEXTURE_DDS:R[y]=new n(this.ddsLoader);break;case i.KHR_TEXTURE_TRANSFORM:R[y]=new _;break;case i.KHR_MESH_QUANTIZATION:R[y]=new E;break;default:J.indexOf(y)>=0&&N[y]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+y+'".')}}X.setExtensions(R),X.setPlugins(N),X.parse(O,P)}});function t(){var M={};return{get:function(w){return M[w]},add:function(w,O){M[w]=O},remove:function(w){delete M[w]},removeAll:function(){M={}}}}var i={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};function n(M){if(!M)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=i.MSFT_TEXTURE_DDS,this.ddsLoader=M}function r(M){this.parser=M,this.name=i.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}r.prototype._markDefs=function(){for(var M=this.parser,w=this.parser.json.nodes||[],O=0,P=w.length;O<P;O++){var F=w[O];F.extensions&&F.extensions[this.name]&&F.extensions[this.name].light!==void 0&&M._addNodeRef(this.cache,F.extensions[this.name].light)}},r.prototype._loadLight=function(M){var w=this.parser,O="light:"+M,P=w.cache.get(O);if(P)return P;var F=w.json,R=F.extensions&&F.extensions[this.name]||{},N=R.lights||[],I=N[M],V,X=new he(16777215);I.color!==void 0&&X.fromArray(I.color);var Q=I.range!==void 0?I.range:0;switch(I.type){case"directional":V=new Lo(X),V.target.position.set(0,0,-1),V.add(V.target);break;case"point":V=new Js(X),V.distance=Q;break;case"spot":V=new Qs(X),V.distance=Q,I.spot=I.spot||{},I.spot.innerConeAngle=I.spot.innerConeAngle!==void 0?I.spot.innerConeAngle:0,I.spot.outerConeAngle=I.spot.outerConeAngle!==void 0?I.spot.outerConeAngle:Math.PI/4,V.angle=I.spot.outerConeAngle,V.penumbra=1-I.spot.innerConeAngle/I.spot.outerConeAngle,V.target.position.set(0,0,-1),V.add(V.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+I.type)}return V.position.set(0,0,0),V.decay=2,I.intensity!==void 0&&(V.intensity=I.intensity),V.name=w.createUniqueName(I.name||"light_"+M),P=Promise.resolve(V),w.cache.add(O,P),P},r.prototype.createNodeAttachment=function(M){var w=this,O=this.parser,P=O.json,F=P.nodes[M],R=F.extensions&&F.extensions[this.name]||{},N=R.light;return N===void 0?null:this._loadLight(N).then(function(I){return O._getNodeRef(w.cache,N,I)})};function o(){this.name=i.KHR_MATERIALS_UNLIT}o.prototype.getMaterialType=function(){return vt},o.prototype.extendParams=function(M,w,O){var P=[];M.color=new he(1,1,1),M.opacity=1;var F=w.pbrMetallicRoughness;if(F){if(Array.isArray(F.baseColorFactor)){var R=F.baseColorFactor;M.color.fromArray(R),M.opacity=R[3]}F.baseColorTexture!==void 0&&P.push(O.assignTexture(M,"map",F.baseColorTexture))}return Promise.all(P)};function s(M){this.parser=M,this.name=i.KHR_MATERIALS_CLEARCOAT}s.prototype.getMaterialType=function(M){var w=this.parser,O=w.json.materials[M];return!O.extensions||!O.extensions[this.name]?null:vi},s.prototype.extendMaterialParams=function(M,w){var O=this.parser,P=O.json.materials[M];if(!P.extensions||!P.extensions[this.name])return Promise.resolve();var F=[],R=P.extensions[this.name];if(R.clearcoatFactor!==void 0&&(w.clearcoat=R.clearcoatFactor),R.clearcoatTexture!==void 0&&F.push(O.assignTexture(w,"clearcoatMap",R.clearcoatTexture)),R.clearcoatRoughnessFactor!==void 0&&(w.clearcoatRoughness=R.clearcoatRoughnessFactor),R.clearcoatRoughnessTexture!==void 0&&F.push(O.assignTexture(w,"clearcoatRoughnessMap",R.clearcoatRoughnessTexture)),R.clearcoatNormalTexture!==void 0&&(F.push(O.assignTexture(w,"clearcoatNormalMap",R.clearcoatNormalTexture)),R.clearcoatNormalTexture.scale!==void 0)){var N=R.clearcoatNormalTexture.scale;w.clearcoatNormalScale=new le(N,-N)}return Promise.all(F)};function a(M){this.parser=M,this.name=i.KHR_MATERIALS_TRANSMISSION}a.prototype.getMaterialType=function(M){var w=this.parser,O=w.json.materials[M];return!O.extensions||!O.extensions[this.name]?null:vi},a.prototype.extendMaterialParams=function(M,w){var O=this.parser,P=O.json.materials[M];if(!P.extensions||!P.extensions[this.name])return Promise.resolve();var F=[],R=P.extensions[this.name];return R.transmissionFactor!==void 0&&(w.transmission=R.transmissionFactor),R.transmissionTexture!==void 0&&F.push(O.assignTexture(w,"transmissionMap",R.transmissionTexture)),Promise.all(F)};function l(M){this.parser=M,this.name=i.KHR_TEXTURE_BASISU}l.prototype.loadTexture=function(M){var w=this.parser,O=w.json,P=O.textures[M];if(!P.extensions||!P.extensions[this.name])return null;var F=P.extensions[this.name],R=O.images[F.source],N=w.options.ktx2Loader;if(!N){if(O.extensionsRequired&&O.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return w.loadTextureImage(M,R,N)};function c(M){this.parser=M,this.name=i.EXT_TEXTURE_WEBP,this.isSupported=null}c.prototype.loadTexture=function(M){var w=this.name,O=this.parser,P=O.json,F=P.textures[M];if(!F.extensions||!F.extensions[w])return null;var R=F.extensions[w],N=P.images[R.source],I=N.uri?O.options.manager.getHandler(N.uri):O.textureLoader;return this.detectSupport().then(function(V){if(V)return O.loadTextureImage(M,N,I);if(P.extensionsRequired&&P.extensionsRequired.indexOf(w)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return O.loadTexture(M)})},c.prototype.detectSupport=function(){return this.isSupported||(this.isSupported=new Promise(function(M){var w=new Image;w.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",w.onload=w.onerror=function(){M(w.height===1)}})),this.isSupported};function h(M){this.name=i.EXT_MESHOPT_COMPRESSION,this.parser=M}h.prototype.loadBufferView=function(M){var w=this.parser.json,O=w.bufferViews[M];if(O.extensions&&O.extensions[this.name]){var P=O.extensions[this.name],F=this.parser.getDependency("buffer",P.buffer),R=this.parser.options.meshoptDecoder;if(!R||!R.supported){if(w.extensionsRequired&&w.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([F,R.ready]).then(function(N){var I=P.byteOffset||0,V=P.byteLength||0,X=P.count,Q=P.byteStride,b=new ArrayBuffer(X*Q),y=new Uint8Array(N[0],I,V);return R.decodeGltfBuffer(new Uint8Array(b),X,Q,y,P.mode,P.filter),b})}else return null};var u="glTF",d=12,f={JSON:1313821514,BIN:5130562};function m(M){this.name=i.KHR_BINARY_GLTF,this.content=null,this.body=null;var w=new DataView(M,0,d);if(this.header={magic:Yn.decodeText(new Uint8Array(M.slice(0,4))),version:w.getUint32(4,!0),length:w.getUint32(8,!0)},this.header.magic!==u)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var O=this.header.length-d,P=new DataView(M,d),F=0;F<O;){var R=P.getUint32(F,!0);F+=4;var N=P.getUint32(F,!0);if(F+=4,N===f.JSON){var I=new Uint8Array(M,d+F,R);this.content=Yn.decodeText(I)}else if(N===f.BIN){var V=d+F;this.body=M.slice(V,V+R)}F+=R}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}function v(M,w){if(!w)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=i.KHR_DRACO_MESH_COMPRESSION,this.json=M,this.dracoLoader=w,this.dracoLoader.preload()}v.prototype.decodePrimitive=function(M,w){var O=this.json,P=this.dracoLoader,F=M.extensions[this.name].bufferView,R=M.extensions[this.name].attributes,N={},I={},V={};for(var X in R){var Q=B[X]||X.toLowerCase();N[Q]=R[X]}for(X in M.attributes){var Q=B[X]||X.toLowerCase();if(R[X]!==void 0){var b=O.accessors[M.attributes[X]],y=x[b.componentType];V[Q]=y,I[Q]=b.normalized===!0}}return w.getDependency("bufferView",F).then(function(J){return new Promise(function(q){P.decodeDracoFile(J,function(z){for(var te in z.attributes){var re=z.attributes[te],ue=I[te];ue!==void 0&&(re.normalized=ue)}q(z)},N,V)})})};function _(){this.name=i.KHR_TEXTURE_TRANSFORM}_.prototype.extendTexture=function(M,w){return M=M.clone(),w.offset!==void 0&&M.offset.fromArray(w.offset),w.rotation!==void 0&&(M.rotation=w.rotation),w.scale!==void 0&&M.repeat.fromArray(w.scale),w.texCoord!==void 0&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),M.needsUpdate=!0,M};function g(M){Mt.call(this),this.isGLTFSpecularGlossinessMaterial=!0;var w=["#ifdef USE_SPECULARMAP"," uniform sampler2D specularMap;","#endif"].join(`
  3339. `),O=["#ifdef USE_GLOSSINESSMAP"," uniform sampler2D glossinessMap;","#endif"].join(`
  3340. `),P=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP"," vec4 texelSpecular = texture2D( specularMap, vUv );"," texelSpecular = sRGBToLinear( texelSpecular );"," // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture"," specularFactor *= texelSpecular.rgb;","#endif"].join(`
  3341. `),F=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP"," vec4 texelGlossiness = texture2D( glossinessMap, vUv );"," // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture"," glossinessFactor *= texelGlossiness.a;","#endif"].join(`
  3342. `),R=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularColor = specularFactor;"].join(`
  3343. `),N={specular:{value:new he().setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=N,this.onBeforeCompile=function(I){for(var V in N)I.uniforms[V]=N[V];I.fragmentShader=I.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",w).replace("#include <metalnessmap_pars_fragment>",O).replace("#include <roughnessmap_fragment>",P).replace("#include <metalnessmap_fragment>",F).replace("#include <lights_physical_fragment>",R)},Object.defineProperties(this,{specular:{get:function(){return N.specular.value},set:function(I){N.specular.value=I}},specularMap:{get:function(){return N.specularMap.value},set:function(I){N.specularMap.value=I,I?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return N.glossiness.value},set:function(I){N.glossiness.value=I}},glossinessMap:{get:function(){return N.glossinessMap.value},set:function(I){N.glossinessMap.value=I,I?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(M)}g.prototype=Object.create(Mt.prototype),g.prototype.constructor=g,g.prototype.copy=function(M){return Mt.prototype.copy.call(this,M),this.specularMap=M.specularMap,this.specular.copy(M.specular),this.glossinessMap=M.glossinessMap,this.glossiness=M.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this};function p(){return{name:i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return g},extendParams:function(M,w,O){var P=w.extensions[this.name];M.color=new he(1,1,1),M.opacity=1;var F=[];if(Array.isArray(P.diffuseFactor)){var R=P.diffuseFactor;M.color.fromArray(R),M.opacity=R[3]}if(P.diffuseTexture!==void 0&&F.push(O.assignTexture(M,"map",P.diffuseTexture)),M.emissive=new he(0,0,0),M.glossiness=P.glossinessFactor!==void 0?P.glossinessFactor:1,M.specular=new he(1,1,1),Array.isArray(P.specularFactor)&&M.specular.fromArray(P.specularFactor),P.specularGlossinessTexture!==void 0){var N=P.specularGlossinessTexture;F.push(O.assignTexture(M,"glossinessMap",N)),F.push(O.assignTexture(M,"specularMap",N))}return Promise.all(F)},createMaterial:function(M){var w=new g(M);return w.fog=!0,w.color=M.color,w.map=M.map===void 0?null:M.map,w.lightMap=null,w.lightMapIntensity=1,w.aoMap=M.aoMap===void 0?null:M.aoMap,w.aoMapIntensity=1,w.emissive=M.emissive,w.emissiveIntensity=1,w.emissiveMap=M.emissiveMap===void 0?null:M.emissiveMap,w.bumpMap=M.bumpMap===void 0?null:M.bumpMap,w.bumpScale=1,w.normalMap=M.normalMap===void 0?null:M.normalMap,w.normalMapType=Wi,M.normalScale&&(w.normalScale=M.normalScale),w.displacementMap=null,w.displacementScale=1,w.displacementBias=0,w.specularMap=M.specularMap===void 0?null:M.specularMap,w.specular=M.specular,w.glossinessMap=M.glossinessMap===void 0?null:M.glossinessMap,w.glossiness=M.glossiness,w.alphaMap=null,w.envMap=M.envMap===void 0?null:M.envMap,w.envMapIntensity=1,w.refractionRatio=.98,w}}}function E(){this.name=i.KHR_MESH_QUANTIZATION}function S(M,w,O,P){Tt.call(this,M,w,O,P)}S.prototype=Object.create(Tt.prototype),S.prototype.constructor=S,S.prototype.copySampleValue_=function(M){for(var w=this.resultBuffer,O=this.sampleValues,P=this.valueSize,F=M*P*3+P,R=0;R!==P;R++)w[R]=O[F+R];return w},S.prototype.beforeStart_=S.prototype.copySampleValue_,S.prototype.afterEnd_=S.prototype.copySampleValue_,S.prototype.interpolate_=function(M,w,O,P){for(var F=this.resultBuffer,R=this.sampleValues,N=this.valueSize,I=N*2,V=N*3,X=P-w,Q=(O-w)/X,b=Q*Q,y=b*Q,J=M*V,q=J-V,z=-2*y+3*b,te=y-b,re=1-z,ue=te-b+Q,se=0;se!==N;se++){var ge=R[q+se+N],ve=R[q+se+I]*X,be=R[J+se+N],pe=R[J+se]*X;F[se]=re*ge+ue*ve+z*be+te*pe}return F};var T={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},x={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},L={9728:rt,9729:qe,9984:jo,9985:Ma,9986:Xo,9987:an},W={33071:ut,33648:Dr,10497:Mi},U={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},B={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},j={CUBICSPLINE:void 0,LINEAR:ln,STEP:or},G={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function D(M,w){return typeof M!="string"||M===""?"":(/^https?:\/\//i.test(w)&&/^\//.test(M)&&(w=w.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(M)||/^data:.*,.*$/i.test(M)||/^blob:.*$/i.test(M)?M:w+M)}function k(M){return M.DefaultMaterial===void 0&&(M.DefaultMaterial=new Mt({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Gt})),M.DefaultMaterial}function Y(M,w,O){for(var P in O.extensions)M[P]===void 0&&(w.userData.gltfExtensions=w.userData.gltfExtensions||{},w.userData.gltfExtensions[P]=O.extensions[P])}function Z(M,w){w.extras!==void 0&&(typeof w.extras=="object"?Object.assign(M.userData,w.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+w.extras))}function $(M,w,O){for(var P=!1,F=!1,R=0,N=w.length;R<N;R++){var I=w[R];if(I.POSITION!==void 0&&(P=!0),I.NORMAL!==void 0&&(F=!0),P&&F)break}if(!P&&!F)return Promise.resolve(M);for(var V=[],X=[],R=0,N=w.length;R<N;R++){var I=w[R];if(P){var Q=I.POSITION!==void 0?O.getDependency("accessor",I.POSITION):M.attributes.position;V.push(Q)}if(F){var Q=I.NORMAL!==void 0?O.getDependency("accessor",I.NORMAL):M.attributes.normal;X.push(Q)}}return Promise.all([Promise.all(V),Promise.all(X)]).then(function(b){var y=b[0],J=b[1];return P&&(M.morphAttributes.position=y),F&&(M.morphAttributes.normal=J),M.morphTargetsRelative=!0,M})}function ne(M,w){if(M.updateMorphTargets(),w.weights!==void 0)for(var O=0,P=w.weights.length;O<P;O++)M.morphTargetInfluences[O]=w.weights[O];if(w.extras&&Array.isArray(w.extras.targetNames)){var F=w.extras.targetNames;if(M.morphTargetInfluences.length===F.length){M.morphTargetDictionary={};for(var O=0,P=F.length;O<P;O++)M.morphTargetDictionary[F[O]]=O}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ae(M){var w=M.extensions&&M.extensions[i.KHR_DRACO_MESH_COMPRESSION],O;return w?O="draco:"+w.bufferView+":"+w.indices+":"+de(w.attributes):O=M.indices+":"+de(M.attributes)+":"+M.mode,O}function de(M){for(var w="",O=Object.keys(M).sort(),P=0,F=O.length;P<F;P++)w+=O[P]+":"+M[O[P]]+";";return w}function ce(M,w){this.json=M||{},this.extensions={},this.plugins={},this.options=w||{},this.cache=new t,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.nodeNamesUsed={},typeof createImageBitmap<"u"&&/Firefox/.test(navigator.userAgent)===!1?this.textureLoader=new ea(this.options.manager):this.textureLoader=new Wn(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new Yt(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}ce.prototype.setExtensions=function(M){this.extensions=M},ce.prototype.setPlugins=function(M){this.plugins=M},ce.prototype.parse=function(M,w){var O=this,P=this.json,F=this.extensions;this.cache.removeAll(),this._invokeAll(function(R){return R._markDefs&&R._markDefs()}),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then(function(R){var N={scene:R[0][P.scene||0],scenes:R[0],animations:R[1],cameras:R[2],asset:P.asset,parser:O,userData:{}};Y(F,N,P),Z(N,P),M(N)}).catch(w)},ce.prototype._markDefs=function(){for(var M=this.json.nodes||[],w=this.json.skins||[],O=this.json.meshes||[],P=0,F=w.length;P<F;P++)for(var R=w[P].joints,N=0,I=R.length;N<I;N++)M[R[N]].isBone=!0;for(var V=0,X=M.length;V<X;V++){var Q=M[V];Q.mesh!==void 0&&(this._addNodeRef(this.meshCache,Q.mesh),Q.skin!==void 0&&(O[Q.mesh].isSkinnedMesh=!0)),Q.camera!==void 0&&this._addNodeRef(this.cameraCache,Q.camera)}},ce.prototype._addNodeRef=function(M,w){w!==void 0&&(M.refs[w]===void 0&&(M.refs[w]=M.uses[w]=0),M.refs[w]++)},ce.prototype._getNodeRef=function(M,w,O){if(M.refs[w]<=1)return O;var P=O.clone();return P.name+="_instance_"+M.uses[w]++,P},ce.prototype._invokeOne=function(M){var w=Object.values(this.plugins);w.push(this);for(var O=0;O<w.length;O++){var P=M(w[O]);if(P)return P}},ce.prototype._invokeAll=function(M){var w=Object.values(this.plugins);w.unshift(this);for(var O=[],P=0;P<w.length;P++){var F=M(w[P]);F&&O.push(F)}return O},ce.prototype.getDependency=function(M,w){var O=M+":"+w,P=this.cache.get(O);if(!P){switch(M){case"scene":P=this.loadScene(w);break;case"node":P=this.loadNode(w);break;case"mesh":P=this._invokeOne(function(F){return F.loadMesh&&F.loadMesh(w)});break;case"accessor":P=this.loadAccessor(w);break;case"bufferView":P=this._invokeOne(function(F){return F.loadBufferView&&F.loadBufferView(w)});break;case"buffer":P=this.loadBuffer(w);break;case"material":P=this._invokeOne(function(F){return F.loadMaterial&&F.loadMaterial(w)});break;case"texture":P=this._invokeOne(function(F){return F.loadTexture&&F.loadTexture(w)});break;case"skin":P=this.loadSkin(w);break;case"animation":P=this.loadAnimation(w);break;case"camera":P=this.loadCamera(w);break;default:throw new Error("Unknown type: "+M)}this.cache.add(O,P)}return P},ce.prototype.getDependencies=function(M){var w=this.cache.get(M);if(!w){var O=this,P=this.json[M+(M==="mesh"?"es":"s")]||[];w=Promise.all(P.map(function(F,R){return O.getDependency(M,R)})),this.cache.add(M,w)}return w},ce.prototype.loadBuffer=function(M){var w=this.json.buffers[M],O=this.fileLoader;if(w.type&&w.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+w.type+" buffer type is not supported.");if(w.uri===void 0&&M===0)return Promise.resolve(this.extensions[i.KHR_BINARY_GLTF].body);var P=this.options;return new Promise(function(F,R){O.load(D(w.uri,P.path),F,void 0,function(){R(new Error('THREE.GLTFLoader: Failed to load buffer "'+w.uri+'".'))})})},ce.prototype.loadBufferView=function(M){var w=this.json.bufferViews[M];return this.getDependency("buffer",w.buffer).then(function(O){var P=w.byteLength||0,F=w.byteOffset||0;return O.slice(F,F+P)})},ce.prototype.loadAccessor=function(M){var w=this,O=this.json,P=this.json.accessors[M];if(P.bufferView===void 0&&P.sparse===void 0)return Promise.resolve(null);var F=[];return P.bufferView!==void 0?F.push(this.getDependency("bufferView",P.bufferView)):F.push(null),P.sparse!==void 0&&(F.push(this.getDependency("bufferView",P.sparse.indices.bufferView)),F.push(this.getDependency("bufferView",P.sparse.values.bufferView))),Promise.all(F).then(function(R){var N=R[0],I=U[P.type],V=x[P.componentType],X=V.BYTES_PER_ELEMENT,Q=X*I,b=P.byteOffset||0,y=P.bufferView!==void 0?O.bufferViews[P.bufferView].byteStride:void 0,J=P.normalized===!0,q,z;if(y&&y!==Q){var te=Math.floor(b/y),re="InterleavedBuffer:"+P.bufferView+":"+P.componentType+":"+te+":"+P.count,ue=w.cache.get(re);ue||(q=new V(N,te*y,P.count*y/X),ue=new Pt(q,y/X),w.cache.add(re,ue)),z=new Oi(ue,I,b%y/X,J)}else N===null?q=new V(P.count*I):q=new V(N,b,P.count*I),z=new Le(q,I,J);if(P.sparse!==void 0){var se=U.SCALAR,ge=x[P.sparse.indices.componentType],ve=P.sparse.indices.byteOffset||0,be=P.sparse.values.byteOffset||0,pe=new ge(R[1],ve,P.sparse.count*se),_e=new V(R[2],be,P.sparse.count*I);N!==null&&(z=new Le(z.array.slice(),z.itemSize,z.normalized));for(var Te=0,Ke=pe.length;Te<Ke;Te++){var ct=pe[Te];if(z.setX(ct,_e[Te*I]),I>=2&&z.setY(ct,_e[Te*I+1]),I>=3&&z.setZ(ct,_e[Te*I+2]),I>=4&&z.setW(ct,_e[Te*I+3]),I>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return z})},ce.prototype.loadTexture=function(M){var w=this,O=this.json,P=this.options,F=O.textures[M],R=F.extensions||{},N;R[i.MSFT_TEXTURE_DDS]?N=O.images[R[i.MSFT_TEXTURE_DDS].source]:N=O.images[F.source];var I;return N.uri&&(I=P.manager.getHandler(N.uri)),I||(I=R[i.MSFT_TEXTURE_DDS]?w.extensions[i.MSFT_TEXTURE_DDS].ddsLoader:this.textureLoader),this.loadTextureImage(M,N,I)},ce.prototype.loadTextureImage=function(M,w,O){var P=this,F=this.json,R=this.options,N=F.textures[M],I=self.URL||self.webkitURL,V=w.uri,X=!1,Q=!0;return w.mimeType==="image/jpeg"&&(Q=!1),w.bufferView!==void 0&&(V=P.getDependency("bufferView",w.bufferView).then(function(b){if(w.mimeType==="image/png"){var y=new DataView(b,25,1).getUint8(0,!1);Q=y===6||y===4||y===3}X=!0;var J=new Blob([b],{type:w.mimeType});return V=I.createObjectURL(J),V})),Promise.resolve(V).then(function(b){return new Promise(function(y,J){var q=y;O.isImageBitmapLoader===!0&&(q=function(z){y(new Ar(z))}),O.load(D(b,R.path),q,void 0,J)})}).then(function(b){X===!0&&I.revokeObjectURL(V),b.flipY=!1,N.name&&(b.name=N.name),Q||(b.format=Ti);var y=F.samplers||{},J=y[N.sampler]||{};return b.magFilter=L[J.magFilter]||qe,b.minFilter=L[J.minFilter]||an,b.wrapS=W[J.wrapS]||Mi,b.wrapT=W[J.wrapT]||Mi,P.associations.set(b,{type:"textures",index:M}),b})},ce.prototype.assignTexture=function(M,w,O){var P=this;return this.getDependency("texture",O.index).then(function(F){if(O.texCoord!==void 0&&O.texCoord!=0&&!(w==="aoMap"&&O.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+O.texCoord+" for texture "+w+" not yet supported."),P.extensions[i.KHR_TEXTURE_TRANSFORM]){var R=O.extensions!==void 0?O.extensions[i.KHR_TEXTURE_TRANSFORM]:void 0;if(R){var N=P.associations.get(F);F=P.extensions[i.KHR_TEXTURE_TRANSFORM].extendTexture(F,R),P.associations.set(F,N)}}M[w]=F})},ce.prototype.assignFinalMaterial=function(M){var w=M.geometry,O=M.material,P=w.attributes.tangent!==void 0,F=w.attributes.color!==void 0,R=w.attributes.normal===void 0,N=M.isSkinnedMesh===!0,I=Object.keys(w.morphAttributes).length>0,V=I&&w.morphAttributes.normal!==void 0;if(M.isPoints){var X="PointsMaterial:"+O.uuid,Q=this.cache.get(X);Q||(Q=new Di,Me.prototype.copy.call(Q,O),Q.color.copy(O.color),Q.map=O.map,Q.sizeAttenuation=!1,this.cache.add(X,Q)),O=Q}else if(M.isLine){var X="LineBasicMaterial:"+O.uuid,b=this.cache.get(X);b||(b=new Rt,Me.prototype.copy.call(b,O),b.color.copy(O.color),this.cache.add(X,b)),O=b}if(P||F||R||N||I){var X="ClonedMaterial:"+O.uuid+":";O.isGLTFSpecularGlossinessMaterial&&(X+="specular-glossiness:"),N&&(X+="skinning:"),P&&(X+="vertex-tangents:"),F&&(X+="vertex-colors:"),R&&(X+="flat-shading:"),I&&(X+="morph-targets:"),V&&(X+="morph-normals:");var y=this.cache.get(X);y||(y=O.clone(),N&&(y.skinning=!0),F&&(y.vertexColors=!0),R&&(y.flatShading=!0),I&&(y.morphTargets=!0),V&&(y.morphNormals=!0),P&&(y.vertexTangents=!0,y.normalScale&&(y.normalScale.y*=-1),y.clearcoatNormalScale&&(y.clearcoatNormalScale.y*=-1)),this.cache.add(X,y),this.associations.set(y,this.associations.get(O))),O=y}O.aoMap&&w.attributes.uv2===void 0&&w.attributes.uv!==void 0&&w.setAttribute("uv2",w.attributes.uv),M.material=O},ce.prototype.getMaterialType=function(){return Mt},ce.prototype.loadMaterial=function(M){var w=this,O=this.json,P=this.extensions,F=O.materials[M],R,N={},I=F.extensions||{},V=[];if(I[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var X=P[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];R=X.getMaterialType(),V.push(X.extendParams(N,F,w))}else if(I[i.KHR_MATERIALS_UNLIT]){var Q=P[i.KHR_MATERIALS_UNLIT];R=Q.getMaterialType(),V.push(Q.extendParams(N,F,w))}else{var b=F.pbrMetallicRoughness||{};if(N.color=new he(1,1,1),N.opacity=1,Array.isArray(b.baseColorFactor)){var y=b.baseColorFactor;N.color.fromArray(y),N.opacity=y[3]}b.baseColorTexture!==void 0&&V.push(w.assignTexture(N,"map",b.baseColorTexture)),N.metalness=b.metallicFactor!==void 0?b.metallicFactor:1,N.roughness=b.roughnessFactor!==void 0?b.roughnessFactor:1,b.metallicRoughnessTexture!==void 0&&(V.push(w.assignTexture(N,"metalnessMap",b.metallicRoughnessTexture)),V.push(w.assignTexture(N,"roughnessMap",b.metallicRoughnessTexture))),R=this._invokeOne(function(q){return q.getMaterialType&&q.getMaterialType(M)}),V.push(Promise.all(this._invokeAll(function(q){return q.extendMaterialParams&&q.extendMaterialParams(M,N)})))}F.doubleSided===!0&&(N.side=on);var J=F.alphaMode||G.OPAQUE;return J===G.BLEND?(N.transparent=!0,N.depthWrite=!1):(N.transparent=!1,J===G.MASK&&(N.alphaTest=F.alphaCutoff!==void 0?F.alphaCutoff:.5)),F.normalTexture!==void 0&&R!==vt&&(V.push(w.assignTexture(N,"normalMap",F.normalTexture)),N.normalScale=new le(1,-1),F.normalTexture.scale!==void 0&&N.normalScale.set(F.normalTexture.scale,-F.normalTexture.scale)),F.occlusionTexture!==void 0&&R!==vt&&(V.push(w.assignTexture(N,"aoMap",F.occlusionTexture)),F.occlusionTexture.strength!==void 0&&(N.aoMapIntensity=F.occlusionTexture.strength)),F.emissiveFactor!==void 0&&R!==vt&&(N.emissive=new he().fromArray(F.emissiveFactor)),F.emissiveTexture!==void 0&&R!==vt&&V.push(w.assignTexture(N,"emissiveMap",F.emissiveTexture)),Promise.all(V).then(function(){var q;return R===g?q=P[i.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(N):q=new R(N),F.name&&(q.name=F.name),q.map&&(q.map.encoding=Vi),q.emissiveMap&&(q.emissiveMap.encoding=Vi),Z(q,F),w.associations.set(q,{type:"materials",index:M}),F.extensions&&Y(P,q,F),q})},ce.prototype.createUniqueName=function(M){for(var w=gt.sanitizeNodeName(M||""),O=w,P=1;this.nodeNamesUsed[O];++P)O=w+"_"+P;return this.nodeNamesUsed[O]=!0,O};function ye(M,w,O){var P=w.attributes,F=new dt;if(P.POSITION!==void 0){var R=O.json.accessors[P.POSITION],N=R.min,I=R.max;if(N!==void 0&&I!==void 0)F.set(new A(N[0],N[1],N[2]),new A(I[0],I[1],I[2]));else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;var V=w.targets;if(V!==void 0){for(var X=new A,Q=new A,b=0,y=V.length;b<y;b++){var J=V[b];if(J.POSITION!==void 0){var R=O.json.accessors[J.POSITION],N=R.min,I=R.max;N!==void 0&&I!==void 0?(Q.setX(Math.max(Math.abs(N[0]),Math.abs(I[0]))),Q.setY(Math.max(Math.abs(N[1]),Math.abs(I[1]))),Q.setZ(Math.max(Math.abs(N[2]),Math.abs(I[2]))),X.max(Q)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}F.expandByVector(X)}M.boundingBox=F;var q=new Zt;F.getCenter(q.center),q.radius=F.min.distanceTo(F.max)/2,M.boundingSphere=q}function Ne(M,w,O){var P=w.attributes,F=[];function R(X,Q){return O.getDependency("accessor",X).then(function(b){M.setAttribute(Q,b)})}for(var N in P){var I=B[N]||N.toLowerCase();I in M.attributes||F.push(R(P[N],I))}if(w.indices!==void 0&&!M.index){var V=O.getDependency("accessor",w.indices).then(function(X){M.setIndex(X)});F.push(V)}return Z(M,w),ye(M,w,O),Promise.all(F).then(function(){return w.targets!==void 0?$(M,w.targets,O):M})}function ie(M,w){var O=M.getIndex();if(O===null){var P=[],F=M.getAttribute("position");if(F!==void 0){for(var R=0;R<F.count;R++)P.push(R);M.setIndex(P),O=M.getIndex()}else return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),M}var N=O.count-2,I=[];if(w===Da)for(var R=1;R<=N;R++)I.push(O.getX(0)),I.push(O.getX(R)),I.push(O.getX(R+1));else for(var R=0;R<N;R++)R%2===0?(I.push(O.getX(R)),I.push(O.getX(R+1)),I.push(O.getX(R+2))):(I.push(O.getX(R+2)),I.push(O.getX(R+1)),I.push(O.getX(R)));I.length/3!==N&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var V=M.clone();return V.setIndex(I),V}return ce.prototype.loadGeometries=function(M){var w=this,O=this.extensions,P=this.primitiveCache;function F(y){return O[i.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(y,w).then(function(J){return Ne(J,y,w)})}for(var R=[],N=0,I=M.length;N<I;N++){var V=M[N],X=ae(V),Q=P[X];if(Q)R.push(Q.promise);else{var b;V.extensions&&V.extensions[i.KHR_DRACO_MESH_COMPRESSION]?b=F(V):b=Ne(new De,V,w),P[X]={primitive:V,promise:b},R.push(b)}}return Promise.all(R)},ce.prototype.loadMesh=function(M){for(var w=this,O=this.json,P=this.extensions,F=O.meshes[M],R=F.primitives,N=[],I=0,V=R.length;I<V;I++){var X=R[I].material===void 0?k(this.cache):this.getDependency("material",R[I].material);N.push(X)}return N.push(w.loadGeometries(R)),Promise.all(N).then(function(Q){for(var b=Q.slice(0,Q.length-1),y=Q[Q.length-1],J=[],q=0,z=y.length;q<z;q++){var te=y[q],re=R[q],ue,se=b[q];if(re.mode===T.TRIANGLES||re.mode===T.TRIANGLE_STRIP||re.mode===T.TRIANGLE_FAN||re.mode===void 0)ue=F.isSkinnedMesh===!0?new fo(te,se):new Oe(te,se),se.isMeshStandardMaterial===!0&&se.side===on&&te.getIndex()!==null&&te.hasAttribute("position")===!0&&te.hasAttribute("normal")===!0&&te.hasAttribute("uv")===!0&&te.hasAttribute("tangent")===!1&&(te.computeTangents(),se.vertexTangents=!0),ue.isSkinnedMesh===!0&&!ue.geometry.attributes.skinWeight.normalized&&ue.normalizeSkinWeights(),re.mode===T.TRIANGLE_STRIP?ue.geometry=ie(ue.geometry,Jh):re.mode===T.TRIANGLE_FAN&&(ue.geometry=ie(ue.geometry,Da));else if(re.mode===T.LINES)ue=new Mr(te,se);else if(re.mode===T.LINE_STRIP)ue=new $i(te,se);else if(re.mode===T.LINE_LOOP)ue=new Cs(te,se);else if(re.mode===T.POINTS)ue=new Is(te,se);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+re.mode);Object.keys(ue.geometry.morphAttributes).length>0&&ne(ue,F),ue.name=w.createUniqueName(F.name||"mesh_"+M),Z(ue,F),re.extensions&&Y(P,ue,re),w.assignFinalMaterial(ue),J.push(ue)}if(J.length===1)return J[0];for(var ge=new ft,q=0,z=J.length;q<z;q++)ge.add(J[q]);return ge})},ce.prototype.loadCamera=function(M){var w,O=this.json.cameras[M],P=O[O.type];if(!P){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return O.type==="perspective"?w=new $e(Se.radToDeg(P.yfov),P.aspectRatio||1,P.znear||1,P.zfar||2e6):O.type==="orthographic"&&(w=new Xn(-P.xmag,P.xmag,P.ymag,-P.ymag,P.znear,P.zfar)),O.name&&(w.name=this.createUniqueName(O.name)),Z(w,O),Promise.resolve(w)},ce.prototype.loadSkin=function(M){var w=this.json.skins[M],O={joints:w.joints};return w.inverseBindMatrices===void 0?Promise.resolve(O):this.getDependency("accessor",w.inverseBindMatrices).then(function(P){return O.inverseBindMatrices=P,O})},ce.prototype.loadAnimation=function(M){for(var w=this.json,O=w.animations[M],P=[],F=[],R=[],N=[],I=[],V=0,X=O.channels.length;V<X;V++){var Q=O.channels[V],b=O.samplers[Q.sampler],y=Q.target,J=y.node!==void 0?y.node:y.id,q=O.parameters!==void 0?O.parameters[b.input]:b.input,z=O.parameters!==void 0?O.parameters[b.output]:b.output;P.push(this.getDependency("node",J)),F.push(this.getDependency("accessor",q)),R.push(this.getDependency("accessor",z)),N.push(b),I.push(y)}return Promise.all([Promise.all(P),Promise.all(F),Promise.all(R),Promise.all(N),Promise.all(I)]).then(function(te){for(var re=te[0],ue=te[1],se=te[2],ge=te[3],ve=te[4],be=[],pe=0,_e=re.length;pe<_e;pe++){var Te=re[pe],Ke=ue[pe],ct=se[pe],zt=ge[pe],It=ve[pe];if(Te!==void 0){Te.updateMatrix(),Te.matrixAutoUpdate=!0;var kt;switch(H[It.path]){case H.weights:kt=Bn;break;case H.rotation:kt=tn;break;case H.position:case H.scale:default:kt=Gn;break}var Ht=Te.name?Te.name:Te.uuid,bi=zt.interpolation!==void 0?j[zt.interpolation]:ln,ht=[];H[It.path]===H.weights?Te.traverse(function(C){C.isMesh===!0&&C.morphTargetInfluences&&ht.push(C.name?C.name:C.uuid)}):ht.push(Ht);var st=ct.array;if(ct.normalized){var yt;if(st.constructor===Int8Array)yt=1/127;else if(st.constructor===Uint8Array)yt=1/255;else if(st.constructor==Int16Array)yt=1/32767;else if(st.constructor===Uint16Array)yt=1/65535;else throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");for(var Qt=new Float32Array(st.length),et=0,Bt=st.length;et<Bt;et++)Qt[et]=st[et]*yt;st=Qt}for(var et=0,Bt=ht.length;et<Bt;et++){var Zn=new kt(ht[et]+"."+H[It.path],Ke.array,st,bi);zt.interpolation==="CUBICSPLINE"&&(Zn.createInterpolant=function(K){return new S(this.times,this.values,this.getValueSize()/3,K)},Zn.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),be.push(Zn)}}}var Uo=O.name?O.name:"animation_"+M;return new At(Uo,void 0,be)})},ce.prototype.loadNode=function(M){var w=this.json,O=this.extensions,P=this,F=w.nodes[M],R=F.name?P.createUniqueName(F.name):"";return function(){var N=[];return F.mesh!==void 0&&N.push(P.getDependency("mesh",F.mesh).then(function(I){var V=P._getNodeRef(P.meshCache,F.mesh,I);return F.weights!==void 0&&V.traverse(function(X){if(X.isMesh)for(var Q=0,b=F.weights.length;Q<b;Q++)X.morphTargetInfluences[Q]=F.weights[Q]}),V})),F.camera!==void 0&&N.push(P.getDependency("camera",F.camera).then(function(I){return P._getNodeRef(P.cameraCache,F.camera,I)})),P._invokeAll(function(I){return I.createNodeAttachment&&I.createNodeAttachment(M)}).forEach(function(I){N.push(I)}),Promise.all(N)}().then(function(N){var I;if(F.isBone===!0?I=new mo:N.length>1?I=new ft:N.length===1?I=N[0]:I=new we,I!==N[0])for(var V=0,X=N.length;V<X;V++)I.add(N[V]);if(F.name&&(I.userData.name=F.name,I.name=R),Z(I,F),F.extensions&&Y(O,I,F),F.matrix!==void 0){var Q=new Re;Q.fromArray(F.matrix),I.applyMatrix4(Q)}else F.translation!==void 0&&I.position.fromArray(F.translation),F.rotation!==void 0&&I.quaternion.fromArray(F.rotation),F.scale!==void 0&&I.scale.fromArray(F.scale);return P.associations.set(I,{type:"nodes",index:M}),I})},ce.prototype.loadScene=function(){function M(w,O,P,F){var R=P.nodes[w];return F.getDependency("node",w).then(function(N){if(R.skin===void 0)return N;var I;return F.getDependency("skin",R.skin).then(function(V){I=V;for(var X=[],Q=0,b=I.joints.length;Q<b;Q++)X.push(F.getDependency("node",I.joints[Q]));return Promise.all(X)}).then(function(V){return N.traverse(function(X){if(X.isMesh){for(var Q=[],b=[],y=0,J=V.length;y<J;y++){var q=V[y];if(q){Q.push(q);var z=new Re;I.inverseBindMatrices!==void 0&&z.fromArray(I.inverseBindMatrices.array,y*16),b.push(z)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',I.joints[y])}X.bind(new go(Q,b),X.matrixWorld)}}),N})}).then(function(N){O.add(N);var I=[];if(R.children)for(var V=R.children,X=0,Q=V.length;X<Q;X++){var b=V[X];I.push(M(b,N,P,F))}return Promise.all(I)})}return function(w){var O=this.json,P=this.extensions,F=this.json.scenes[w],R=this,N=new ft;F.name&&(N.name=R.createUniqueName(F.name)),Z(N,F),F.extensions&&Y(P,N,F);for(var I=F.nodes||[],V=[],X=0,Q=I.length;X<Q;X++)V.push(M(I[X],N,O,R));return Promise.all(V).then(function(){return N})}}(),e}();const Sc=(()=>{const i=class i extends Ut.Component{get NAME(){return i.CLASS_NAME}constructor(){super(),this.voxelType_="stone",this.timer_=0,this.active_=!1}InitComponent(){this._RegisterHandler("input.pressed",o=>this.OnInput_(o)),this._RegisterHandler("ui.blockChanged",o=>this.OnBlockIcon_(o)),this._RegisterHandler("ui.toolChanged",o=>this.OnToolChanged_(o))}OnToolChanged_(o){o.value!="build"?this.LoseFocus():this.GainFocus()}LoseFocus(){this.voxelMeshGroup_.visible=!1,this.placementMesh_.visible=!1,this.active_=!1}GainFocus(){this.voxelMeshGroup_.visible=!0,this.placementMesh_.visible=!0,this.active_=!0}OnBlockIcon_(o){this.voxelType_=o.value,this.UpdateVoxelMesh_()}UpdateVoxelMesh_(){const o=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),s=[],a=[];for(let l=0;l<6;++l)for(let c=0;c<4*3;++c)s.push(1,1,1),a.push(o.blockTypes_[this.voxelType_].textures[2]);this.voxelMesh_.geometry.setAttribute("colour",new Fe(s,3)),this.voxelMesh_.geometry.setAttribute("uvSlice",new Fe(a,1))}InitEntity(){const o=this.FindEntity("renderer").GetComponent("ThreeJSController").scene_,s=this.FindEntity("renderer").GetComponent("ThreeJSController").uiCamera_,a=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),l=new gi(1,1,1),c=new Qe({uniforms:{time:{value:0},edgeColour:{value:new he(0)}},vertexShader:si.PLACEMENT.VS,fragmentShader:si.PLACEMENT.PS,side:Gt,blending:Bi,transparent:!0,depthWrite:!1}),h=c.clone();h.side=Ze;const u=new Oe(l,c),d=new Oe(l,h);u.renderOrder=1,this.placementMesh_=new ft,this.placementMesh_.add(u),this.placementMesh_.add(d),this.placementMesh_.scale.setScalar(.999),this.material1_=c,this.material2_=h;const f=new gi(1,1,1);this.voxelMesh_=new Oe(f,a.materialOpaque_.clone()),this.voxelMesh_.position.set(1.25,-1.25,-4),this.voxelMesh_.rotateY(.125*2*Math.PI),this.voxelMesh_.material.depthWrite=!1,this.voxelMesh_.material.depthTest=!1,this.voxelMeshGroup_=new ft,this.voxelMeshGroup_.add(this.voxelMesh_),this.voxelMeshGroup_.position.set(0,0,2),this.voxelMeshRotEnd_=this.voxelMeshGroup_.quaternion.clone(),this.voxelMeshGroup_.rotateX(-.125*2*Math.PI),this.voxelMeshRotStart_=this.voxelMeshGroup_.quaternion.clone(),this.voxelMeshGroup_.quaternion.identity(),s.add(this.voxelMeshGroup_);const m=new tn(".quaternion",[0,1],[...this.voxelMeshRotStart_.toArray(),...this.voxelMeshRotEnd_.toArray()]),v=new At("rot",-1,[m]);this.mixer_=new Co(this.voxelMeshGroup_),this.action_=this.mixer_.clipAction(v),o.add(this.placementMesh_),this.UpdateVoxelMesh_(),this.LoseFocus()}OnInput_(o){this.active_&&o.value=="enter"&&this.PerformAction()}PerformAction(){if(!this.active_||!this.placementMesh_.visible)return;const o=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),s=[this.placementMesh_.position.x,this.placementMesh_.position.y,this.placementMesh_.position.z];o.HasVoxelAt(...s)||(o.InsertVoxelAt(s,this.voxelType_),this.action_.setLoop(Yo,1),this.action_.clampWhenFinished=!0,this.action_.timeScale=3,this.action_.reset(),this.action_.play())}Update(o){if(!this.active_)return;this.mixer_.update(o),this.timer_+=o,this.material1_.uniforms.time.value=this.timer_,this.material2_.uniforms.time.value=this.timer_,this.material1_.needsUpdate=!0,this.material2_.needsUpdate=!0;const s=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager");this.voxelMesh_.material.uniforms.diffuseMap.value=s.materialOpaque_.uniforms.diffuseMap.value,this.placementMesh_.visible=!1;const a=this.FindEntity("player"),l=new A(0,0,-1);l.applyQuaternion(a.Quaternion);const c=new qi(a.Position,l),h=s.FindIntersectionsWithRay(c,5).filter(f=>f.voxel.visible);if(!h.length)return;const u=[...h[0].voxel.position],d=this.FindClosestSide_(u,c);d&&(s.HasVoxelAt(...d)||(this.placementMesh_.position.set(...d),this.placementMesh_.visible=!0))}FindClosestSide_(o,s){const a=[[...o],[...o],[...o],[...o],[...o],[...o]];a[0][0]-=1,a[1][0]+=1,a[2][1]-=1,a[3][1]+=1,a[4][2]-=1,a[5][2]+=1;const l=d=>{const f=new A(...d),m=new A(.5,.5,.5),v=new A;v.copy(f),v.sub(m);const _=new A;return _.copy(f),_.add(m),new dt(v,_)},c=a.map(d=>l(d)),h=new A,u=[];for(let d=0;d<c.length;++d)s.intersectBox(c[d],h)&&u.push({position:a[d],distance:h.distanceTo(s.origin)});return u.sort((d,f)=>d.distance-f.distance),u.length>0?u[0].position:null}};wi(i,"CLASS_NAME","VoxelTools_Insert");let e=i;const n=class n extends Ut.Component{get NAME(){return n.CLASS_NAME}constructor(){super(),this.timer_=0,this.active_=!0}InitEntity(){this.LoadModel_()}InitComponent(){this._RegisterHandler("input.pressed",o=>this.OnInput_(o)),this._RegisterHandler("ui.toolChanged",o=>this.OnToolChanged_(o))}OnToolChanged_(o){o.value!="break"?this.LoseFocus():this.GainFocus()}LoseFocus(){this.balls_.visible=!1,this.placementMesh_.visible=!1,this.active_=!1}GainFocus(){this.balls_.visible=!0,this.placementMesh_.visible=!0,this.active_=!0}LoadModel_(){const o=this.FindEntity("renderer").GetComponent("ThreeJSController").scene_,s=this.FindEntity("renderer").GetComponent("ThreeJSController").uiCamera_;this.balls_=new ft,s.add(this.balls_),new Bg().load("./resources/pickaxe/scene.gltf",d=>{d.scene.traverse(g=>{g.material&&(g.material.depthWrite=!1,g.material.depthTest=!1)}),this.mesh_=d.scene,this.mesh_.position.set(2,2,1),this.mesh_.scale.setScalar(.1),this.mesh_.rotateZ(.25*2*Math.PI),this.mesh_.rotateY(-.1*2*Math.PI),this.group_=new ft,this.group_.add(this.mesh_),this.group_.position.set(0,-3,-4);const f=this.group_.quaternion.clone();this.group_.rotateX(-.25*2*Math.PI);const m=this.group_.quaternion.clone();this.group_.quaternion.identity(),this.balls_.add(this.group_);const v=new tn(".quaternion",[0,1,2],[...f.toArray(),...m.toArray(),...f.toArray()]),_=new At("rot",-1,[v]);this.mixer_=new Co(this.group_),this.action_=this.mixer_.clipAction(_)});const a=new gi(1,1,1),l=new Qe({uniforms:{time:{value:0},edgeColour:{value:new he(16711680)}},vertexShader:si.PLACEMENT.VS,fragmentShader:si.PLACEMENT.PS,side:Gt,blending:Bi,transparent:!0,depthWrite:!1}),c=l.clone();c.side=Ze;const h=new Oe(a,l),u=new Oe(a,c);h.renderOrder=1,this.placementMesh_=new ft,this.placementMesh_.add(h),this.placementMesh_.add(u),this.placementMesh_.scale.setScalar(1.0001),this.material1_=l,this.material2_=c,o.add(this.placementMesh_),this.LoseFocus()}OnInput_(o){this.active_&&o.value=="enter"&&this.PerformAction()}PerformAction(){if(!this.active_||!this.placementMesh_.visible)return;const o=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),s=[this.placementMesh_.position.x,this.placementMesh_.position.y,this.placementMesh_.position.z];o.HasVoxelAt(...s)&&(o.RemoveVoxelAt(s),this.action_&&(this.action_.setLoop(Yo,1),this.action_.clampWhenFinished=!0,this.action_.timeScale=10,this.action_.reset(),this.action_.play()))}Update(o){if(!this.active_)return;this.mixer_&&this.mixer_.update(o),this.timer_+=o,this.material1_.uniforms.time.value=this.timer_,this.material2_.uniforms.time.value=this.timer_,this.material1_.needsUpdate=!0,this.material2_.needsUpdate=!0;const s=this.FindEntity("voxels").GetComponent("SparseVoxelCellManager"),a=this.FindEntity("player"),l=new A(0,0,-1);l.applyQuaternion(a.Quaternion);const c=new qi(a.Position,l),h=s.FindIntersectionsWithRay(c,4);if(!h.length)return;const u=[...h[0].voxel.position];s.HasVoxelAt(...u)&&(this.placementMesh_.position.set(...u),this.placementMesh_.visible=!0)}};wi(n,"CLASS_NAME","VoxelTools_Delete");let t=n;return{VoxelTools_Insert:e,VoxelTools_Delete:t}})(),Gg=(()=>{const t=class t extends Ut.Component{get NAME(){return t.CLASS_NAME}constructor(){super()}InitEntity(){this.iconBar_=document.getElementById("icon-bar"),this.icons_=[];const n=["dirt","stone","sand","grass","snow","moon","tree_bark","tree_leaves"];for(let r of n){const o=document.createElement("DIV");let s=la.DEFS[r].texture;s instanceof Array&&(s=s[2]),o.className="icon-bar-item",o.style="background-image: url('./resources/minecraft/textures/blocks/"+s+"');",o.blockType=r,this.iconBar_.appendChild(o),this.icons_.push(o)}this.toolTypes_=["build","break"],this.toolIndex_=0,this.iconIndex_=0,this.icons_[0].classList.toggle("highlight"),this.UpdateToolBlockType_(),this.UpdateToolType_()}CycleBuildIcon_(n){this.icons_[this.iconIndex_].classList.remove("highlight"),this.iconIndex_=(this.iconIndex_+this.icons_.length+n)%this.icons_.length,this.icons_[this.iconIndex_].classList.toggle("highlight"),this.UpdateToolBlockType_()}CycleTool_(){this.toolIndex_=(this.toolIndex_+1)%this.toolTypes_.length,this.UpdateToolType_()}UpdateToolBlockType_(){this.FindEntity("player").Broadcast({topic:"ui.blockChanged",value:this.icons_[this.iconIndex_].blockType})}UpdateToolType_(){this.FindEntity("player").Broadcast({topic:"ui.toolChanged",value:this.toolTypes_[this.toolIndex_]})}};wi(t,"CLASS_NAME","UIController");let e=t;return{UIController:e}})();class Vg{constructor(){this._Initialize()}_Initialize(){this.entityManager_=new zg.EntityManager,this.LoadControllers_(),this.previousRAF_=null,this.RAF_()}CreateGUI_(){this._guiParams={general:{}},this._gui=new GUI,this._gui.close()}LoadControllers_(){const t=new Ut.Entity;t.AddComponent(new Cg.ThreeJSController),this.entityManager_.Add(t,"renderer"),this.renderer_=t.GetComponent("ThreeJSController"),this.scene_=t.GetComponent("ThreeJSController").scene_,this.camera_=t.GetComponent("ThreeJSController").camera_,this.threejs_=t.GetComponent("ThreeJSController").threejs_;const i=new Ut.Entity;i.AddComponent(new Ug.SparseVoxelCellManager({cellSize:Fr.WORLD_BLOCK_SIZE,worldSize:Fr.WORLD_SIZE})),this.entityManager_.Add(i,"voxels");const n=new Ut.Entity;n.AddComponent(new kg.CloudController),this.entityManager_.Add(n);const r=new Ut.Entity;r.AddComponent(new Hg.PlayerController),r.AddComponent(new Sc.VoxelTools_Insert),r.AddComponent(new Sc.VoxelTools_Delete),r.SetPosition(new A(..._t.PLAYER_POS)),r.SetQuaternion(new tt(..._t.PLAYER_ROT)),this.entityManager_.Add(r,"player");const o=new Ut.Entity;o.AddComponent(new Gg.UIController),this.entityManager_.Add(o,"ui")}RAF_(){requestAnimationFrame(t=>{this.previousRAF_===null&&(this.previousRAF_=t),this.Step_(t-this.previousRAF_),this.renderer_.Render(),this.previousRAF_=t,setTimeout(()=>{this.RAF_()},1)})}Step_(t){const i=Math.min(.03333333333333333,t*.001);this.entityManager_.Update(i)}}window.addEventListener("DOMContentLoaded",()=>{new Vg});