b3dmExample.fa261be3.js 581 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070
  1. (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerpolicy&&(s.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?s.credentials="include":i.crossorigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();/**
  2. * @license
  3. * Copyright 2010-2021 Three.js Authors
  4. * SPDX-License-Identifier: MIT
  5. */const bo="136",Wn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},qn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},jc=0,Qo=1,Xc=2,Pl=1,Il=2,Yi=3,yi=0,it=1,Un=2,Dl=1,mn=0,Ji=1,ea=2,ta=3,na=4,Yc=5,ui=100,Zc=101,Jc=102,ia=103,sa=104,Kc=200,$c=201,Qc=202,eh=203,Nl=204,Fl=205,th=206,nh=207,ih=208,sh=209,rh=210,oh=0,ah=1,lh=2,to=3,ch=4,hh=5,uh=6,dh=7,sr=0,fh=1,ph=2,gn=0,mh=1,gh=2,xh=3,_h=4,yh=5,Ol=300,us=301,ds=302,no=303,io=304,rr=306,wo=307,vi=1e3,yt=1001,er=1002,Qe=1003,so=1004,ro=1005,ht=1006,Bl=1007,Ei=1008,en=1009,vh=1010,Mh=1011,ts=1012,bh=1013,Qs=1014,$t=1015,Fn=1016,wh=1017,Sh=1018,Th=1019,xi=1020,Eh=1021,xn=1022,st=1023,Ah=1024,Lh=1025,On=1026,Mi=1027,Rh=1028,Ch=1029,Ph=1030,Ih=1031,Dh=1032,Nh=1033,ra=33776,oa=33777,aa=33778,la=33779,ca=35840,ha=35841,ua=35842,da=35843,Fh=36196,fa=37492,pa=37496,Oh=37808,Bh=37809,Uh=37810,zh=37811,Hh=37812,kh=37813,Gh=37814,Vh=37815,Wh=37816,qh=37817,jh=37818,Xh=37819,Yh=37820,Zh=37821,Jh=36492,Kh=37840,$h=37841,Qh=37842,eu=37843,tu=37844,nu=37845,iu=37846,su=37847,ru=37848,ou=37849,au=37850,lu=37851,cu=37852,hu=37853,uu=2200,du=2201,fu=2202,ns=2300,bi=2301,_r=2302,di=2400,fi=2401,tr=2402,So=2500,Ul=2501,pu=0,mu=1,zl=2,Dt=3e3,Ht=3001,gu=3200,xu=3201,kn=0,_u=1,yr=7680,yu=519,is=35044,nr=35048,ma="300 es";class Sn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}}const ct=[];for(let r=0;r<256;r++)ct[r]=(r<16?"0":"")+r.toString(16);let _s=1234567;const Ki=Math.PI/180,ss=180/Math.PI;function Tt(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ct[r&255]+ct[r>>8&255]+ct[r>>16&255]+ct[r>>24&255]+"-"+ct[e&255]+ct[e>>8&255]+"-"+ct[e>>16&15|64]+ct[e>>24&255]+"-"+ct[t&63|128]+ct[t>>8&255]+"-"+ct[t>>16&255]+ct[t>>24&255]+ct[n&255]+ct[n>>8&255]+ct[n>>16&255]+ct[n>>24&255]).toUpperCase()}function gt(r,e,t){return Math.max(e,Math.min(t,r))}function To(r,e){return(r%e+e)%e}function vu(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function Mu(r,e,t){return r!==e?(t-r)/(e-r):0}function $i(r,e,t){return(1-t)*r+t*e}function bu(r,e,t,n){return $i(r,e,1-Math.exp(-t*n))}function wu(r,e=1){return e-Math.abs(To(r,e*2)-e)}function Su(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Tu(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function Eu(r,e){return r+Math.floor(Math.random()*(e-r+1))}function Au(r,e){return r+Math.random()*(e-r)}function Lu(r){return r*(.5-Math.random())}function Ru(r){return r!==void 0&&(_s=r%2147483647),_s=_s*16807%2147483647,(_s-1)/2147483646}function Cu(r){return r*Ki}function Pu(r){return r*ss}function oo(r){return(r&r-1)===0&&r!==0}function Hl(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function kl(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Iu(r,e,t,n,i){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),h=o((e+n)/2),u=s((e-n)/2),d=o((e-n)/2),f=s((n-e)/2),g=o((n-e)/2);switch(i){case"XYX":r.set(a*h,l*u,l*d,a*c);break;case"YZY":r.set(l*d,a*h,l*u,a*c);break;case"ZXZ":r.set(l*u,l*d,a*h,a*c);break;case"XZX":r.set(a*h,l*g,l*f,a*c);break;case"YXY":r.set(l*f,a*h,l*g,a*c);break;case"ZYZ":r.set(l*g,l*f,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}var Du=Object.freeze({__proto__:null,DEG2RAD:Ki,RAD2DEG:ss,generateUUID:Tt,clamp:gt,euclideanModulo:To,mapLinear:vu,inverseLerp:Mu,lerp:$i,damp:bu,pingpong:wu,smoothstep:Su,smootherstep:Tu,randInt:Eu,randFloat:Au,randFloatSpread:Lu,seededRandom:Ru,degToRad:Cu,radToDeg:Pu,isPowerOfTwo:oo,ceilPowerOfTwo:Hl,floorPowerOfTwo:kl,setQuaternionFromProperEuler:Iu});class j{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}j.prototype.isVector2=!0;class ut{constructor(){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(e,t,n,i,s,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],x=i[0],_=i[3],p=i[6],m=i[1],R=i[4],y=i[7],E=i[2],C=i[5],P=i[8];return s[0]=o*x+a*m+l*E,s[3]=o*_+a*R+l*C,s[6]=o*p+a*y+l*P,s[1]=c*x+h*m+u*E,s[4]=c*_+h*R+u*C,s[7]=c*p+h*y+u*P,s[2]=d*x+f*m+g*E,s[5]=d*_+f*R+g*C,s[8]=d*p+f*y+g*P,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*s*h+n*a*l+i*s*c-i*o*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=h*o-a*c,d=a*l-h*s,f=c*s-o*l,g=t*u+n*d+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=u*x,e[1]=(i*c-h*n)*x,e[2]=(a*n-i*o)*x,e[3]=d*x,e[4]=(h*t-i*l)*x,e[5]=(i*s-a*t)*x,e[6]=f*x,e[7]=(n*l-c*t)*x,e[8]=(o*t-n*s)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],c=i[4],h=i[7];return i[0]=t*s+n*l,i[3]=t*o+n*c,i[6]=t*a+n*h,i[1]=-n*s+t*l,i[4]=-n*o+t*c,i[7]=-n*a+t*h,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}ut.prototype.isMatrix3=!0;function Gl(r){if(r.length===0)return-1/0;let e=r[0];for(let t=1,n=r.length;t<n;++t)r[t]>e&&(e=r[t]);return e}function or(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}let jn;class Ai{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{jn===void 0&&(jn=or("canvas")),jn.width=e.width,jn.height=e.height;const n=jn.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=jn}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let Nu=0;class tt extends Sn{constructor(e=tt.DEFAULT_IMAGE,t=tt.DEFAULT_MAPPING,n=yt,i=yt,s=ht,o=Ei,a=st,l=en,c=1,h=Dt){super(),Object.defineProperty(this,"id",{value:Nu++}),this.uuid=Tt(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new j(0,0),this.repeat=new j(1,1),this.center=new j(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ut,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.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.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={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 i=this.image;if(i.uuid===void 0&&(i.uuid=Tt()),!t&&e.images[i.uuid]===void 0){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(vr(i[o].image)):s.push(vr(i[o]))}else s=vr(i);e.images[i.uuid]={uuid:i.uuid,url:s}}n.image=i.uuid}return JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ol)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case vi:e.x=e.x-Math.floor(e.x);break;case yt:e.x=e.x<0?0:1;break;case er: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 vi:e.y=e.y-Math.floor(e.y);break;case yt:e.y=e.y<0?0:1;break;case er:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&this.version++}}tt.DEFAULT_IMAGE=void 0;tt.DEFAULT_MAPPING=Ol;tt.prototype.isTexture=!0;function vr(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Ai.getDataURL(r):r.data?{data:Array.prototype.slice.call(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}class qe{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],g=l[9],x=l[2],_=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(g-_)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(g+_)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const R=(c+1)/2,y=(f+1)/2,E=(p+1)/2,C=(h+d)/4,P=(u+x)/4,V=(g+_)/4;return R>y&&R>E?R<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(R),i=C/n,s=P/n):y>E?y<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(y),n=C/i,s=V/i):E<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(E),n=P/s,i=V/s),this.set(n,i,s,t),this}let m=Math.sqrt((_-g)*(_-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(m)<.001&&(m=1),this.x=(_-g)/m,this.y=(u-x)/m,this.z=(d-h)/m,this.w=Math.acos((c+f+p-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}qe.prototype.isVector4=!0;class Et extends Sn{constructor(e,t,n={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new qe(0,0,e,t),this.scissorTest=!1,this.viewport=new qe(0,0,e,t),this.texture=new tt(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:ht,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}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image={...this.texture.image},this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Et.prototype.isWebGLRenderTarget=!0;class Fu extends Et{constructor(e,t,n){super(e,t);const i=this.texture;this.texture=[];for(let s=0;s<n;s++)this.texture[s]=i.clone()}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.texture.length;i<s;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone();return this}}Fu.prototype.isWebGLMultipleRenderTargets=!0;class Eo extends Et{constructor(e,t,n={}){super(e,t,n),this.samples=4,this.ignoreDepthForMultisampleCopy=n.ignoreDepth!==void 0?n.ignoreDepth:!0,this.useRenderToTexture=n.useRenderToTexture!==void 0?n.useRenderToTexture:!1,this.useRenderbuffer=this.useRenderToTexture===!1}copy(e){return super.copy.call(this,e),this.samples=e.samples,this.useRenderToTexture=e.useRenderToTexture,this.useRenderbuffer=e.useRenderbuffer,this}}Eo.prototype.isWebGLMultisampleRenderTarget=!0;class at{constructor(e=0,t=0,n=0,i=1){this._x=e,this._y=t,this._z=n,this._w=i}static slerp(e,t,n,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(e,t,i)}static slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3];const d=s[o+0],f=s[o+1],g=s[o+2],x=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=d,e[t+1]=f,e[t+2]=g,e[t+3]=x;return}if(u!==x||l!==d||c!==f||h!==g){let _=1-a;const p=l*d+c*f+h*g+u*x,m=p>=0?1:-1,R=1-p*p;if(R>Number.EPSILON){const E=Math.sqrt(R),C=Math.atan2(E,p*m);_=Math.sin(_*C)/E,a=Math.sin(a*C)/E}const y=a*m;if(l=l*_+d*y,c=c*_+f*y,h=h*_+g*y,u=u*_+x*y,_===1-a){const E=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=E,c*=E,h*=E,u*=E}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[o],d=s[o+1],f=s[o+2],g=s[o+3];return e[t]=a*g+h*u+l*f-c*d,e[t+1]=l*g+h*d+c*u-a*f,e[t+2]=c*g+h*f+a*d-l*u,e[t+3]=h*g-a*u-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(i/2),u=a(s/2),d=l(n/2),f=l(i/2),g=l(s/2);switch(o){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],u=t[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=(s-c)*f,this._z=(o-i)*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=(i+o)/f,this._z=(s+c)/f}else if(a>u){const f=2*Math.sqrt(1+a-n-u);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(gt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-n*c,this._z=s*h+o*c+n*l-i*a,this._w=o*h-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const f=1-t;return this._w=f*o+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),u=Math.sin((1-t)*h)/c,d=Math.sin(t*h)/c;return this._w=o*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}at.prototype.isQuaternion=!0;class T{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(ga.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ga.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=l*t+o*i-a*n,h=l*n+a*t-s*i,u=l*i+s*n-o*t,d=-s*t-o*n-a*i;return this.x=c*l+d*-s+h*-a-u*-o,this.y=h*l+d*-o+u*-s-c*-a,this.z=u*l+d*-a+c*-o-h*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Mr.copy(this).projectOnVector(e),this.sub(Mr)}reflect(e){return this.sub(Mr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(gt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}T.prototype.isVector3=!0;const Mr=new T,ga=new at;class wt{constructor(e=new T(1/0,1/0,1/0),t=new T(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.length;l<c;l+=3){const h=e[l],u=e[l+1],d=e[l+2];h<t&&(t=h),u<n&&(n=u),d<i&&(i=d),h>s&&(s=h),u>o&&(o=u),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.count;l<c;l++){const h=e.getX(l),u=e.getY(l),d=e.getZ(l);h<t&&(t=h),u<n&&(n=u),d<i&&(i=d),h>s&&(s=h),u>o&&(o=u),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Oi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){e.updateWorldMatrix(!1,!1);const t=e.geometry;t!==void 0&&(t.boundingBox===null&&t.computeBoundingBox(),br.copy(t.boundingBox),br.applyMatrix4(e.matrixWorld),this.union(br));const n=e.children;for(let i=0,s=n.length;i<s;i++)this.expandByObject(n[i]);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Oi),Oi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Bi),ys.subVectors(this.max,Bi),Xn.subVectors(e.a,Bi),Yn.subVectors(e.b,Bi),Zn.subVectors(e.c,Bi),sn.subVectors(Yn,Xn),rn.subVectors(Zn,Yn),Rn.subVectors(Xn,Zn);let t=[0,-sn.z,sn.y,0,-rn.z,rn.y,0,-Rn.z,Rn.y,sn.z,0,-sn.x,rn.z,0,-rn.x,Rn.z,0,-Rn.x,-sn.y,sn.x,0,-rn.y,rn.x,0,-Rn.y,Rn.x,0];return!wr(t,Xn,Yn,Zn,ys)||(t=[1,0,0,0,1,0,0,0,1],!wr(t,Xn,Yn,Zn,ys))?!1:(vs.crossVectors(sn,rn),t=[vs.x,vs.y,vs.z],wr(t,Xn,Yn,Zn,ys))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Oi.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Oi).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Wt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Wt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Wt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Wt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Wt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Wt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Wt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Wt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Wt),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}wt.prototype.isBox3=!0;const Wt=[new T,new T,new T,new T,new T,new T,new T,new T],Oi=new T,br=new wt,Xn=new T,Yn=new T,Zn=new T,sn=new T,rn=new T,Rn=new T,Bi=new T,ys=new T,vs=new T,Cn=new T;function wr(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Cn.fromArray(r,s);const a=i.x*Math.abs(Cn.x)+i.y*Math.abs(Cn.y)+i.z*Math.abs(Cn.z),l=e.dot(Cn),c=t.dot(Cn),h=n.dot(Cn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const Ou=new wt,xa=new T,Ms=new T,Sr=new T;class Tn{constructor(e=new T,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ou.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){Sr.subVectors(e,this.center);const t=Sr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(Sr.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?Ms.set(0,0,1).multiplyScalar(e.radius):Ms.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(xa.copy(e.center).add(Ms)),this.expandByPoint(xa.copy(e.center).sub(Ms)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const qt=new T,Tr=new T,bs=new T,on=new T,Er=new T,ws=new T,Ar=new T;class En{constructor(e=new T,t=new T(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,qt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=qt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(qt.copy(this.direction).multiplyScalar(t).add(this.origin),qt.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Tr.copy(e).add(t).multiplyScalar(.5),bs.copy(t).sub(e).normalize(),on.copy(this.origin).sub(Tr);const s=e.distanceTo(t)*.5,o=-this.direction.dot(bs),a=on.dot(this.direction),l=-on.dot(bs),c=on.lengthSq(),h=Math.abs(1-o*o);let u,d,f,g;if(h>0)if(u=o*l-a,d=o*a-l,g=s*h,u>=0)if(d>=-g)if(d<=g){const x=1/h;u*=x,d*=x,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(bs).multiplyScalar(d).add(Tr),f}intersectSphere(e,t){qt.subVectors(e.center,this.origin);const n=qt.dot(this.direction),i=qt.dot(qt)-n*n,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,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=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),h>=0?(s=(e.min.y-d.y)*h,o=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,o=(e.min.y-d.y)*h),n>o||s>i||((s>n||n!==n)&&(n=s),(o<i||i!==i)&&(i=o),u>=0?(a=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,qt)!==null}intersectTriangle(e,t,n,i,s){Er.subVectors(t,e),ws.subVectors(n,e),Ar.crossVectors(Er,ws);let o=this.direction.dot(Ar),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;on.subVectors(this.origin,e);const l=a*this.direction.dot(ws.crossVectors(on,ws));if(l<0)return null;const c=a*this.direction.dot(Er.cross(on));if(c<0||l+c>o)return null;const h=-a*on.dot(Ar);return h<0?null:this.at(h/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class pe{constructor(){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(e,t,n,i,s,o,a,l,c,h,u,d,f,g,x,_){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=s,p[5]=o,p[9]=a,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=g,p[11]=x,p[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 pe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Jn.setFromMatrixColumn(e,0).length(),s=1/Jn.setFromMatrixColumn(e,1).length(),o=1/Jn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const d=o*h,f=o*u,g=a*h,x=a*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=f+g*c,t[5]=d-x*c,t[9]=-a*l,t[2]=x-d*c,t[6]=g+f*c,t[10]=o*l}else if(e.order==="YXZ"){const d=l*h,f=l*u,g=c*h,x=c*u;t[0]=d+x*a,t[4]=g*a-f,t[8]=o*c,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=f*a-g,t[6]=x+d*a,t[10]=o*l}else if(e.order==="ZXY"){const d=l*h,f=l*u,g=c*h,x=c*u;t[0]=d-x*a,t[4]=-o*u,t[8]=g+f*a,t[1]=f+g*a,t[5]=o*h,t[9]=x-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const d=o*h,f=o*u,g=a*h,x=a*u;t[0]=l*h,t[4]=g*c-f,t[8]=d*c+x,t[1]=l*u,t[5]=x*c+d,t[9]=f*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const d=o*l,f=o*c,g=a*l,x=a*c;t[0]=l*h,t[4]=x-d*u,t[8]=g*u+f,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=f*u+g,t[10]=d-x*u}else if(e.order==="XZY"){const d=o*l,f=o*c,g=a*l,x=a*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+x,t[5]=o*h,t[9]=f*u-g,t[2]=g*u-f,t[6]=a*h,t[10]=x*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Bu,e,Uu)}lookAt(e,t,n){const i=this.elements;return vt.subVectors(e,t),vt.lengthSq()===0&&(vt.z=1),vt.normalize(),an.crossVectors(n,vt),an.lengthSq()===0&&(Math.abs(n.z)===1?vt.x+=1e-4:vt.z+=1e-4,vt.normalize(),an.crossVectors(n,vt)),an.normalize(),Ss.crossVectors(vt,an),i[0]=an.x,i[4]=Ss.x,i[8]=vt.x,i[1]=an.y,i[5]=Ss.y,i[9]=vt.y,i[2]=an.z,i[6]=Ss.z,i[10]=vt.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],x=n[6],_=n[10],p=n[14],m=n[3],R=n[7],y=n[11],E=n[15],C=i[0],P=i[4],V=i[8],ne=i[12],Z=i[1],I=i[5],S=i[9],b=i[13],N=i[2],O=i[6],D=i[10],B=i[14],te=i[3],le=i[7],k=i[11],G=i[15];return s[0]=o*C+a*Z+l*N+c*te,s[4]=o*P+a*I+l*O+c*le,s[8]=o*V+a*S+l*D+c*k,s[12]=o*ne+a*b+l*B+c*G,s[1]=h*C+u*Z+d*N+f*te,s[5]=h*P+u*I+d*O+f*le,s[9]=h*V+u*S+d*D+f*k,s[13]=h*ne+u*b+d*B+f*G,s[2]=g*C+x*Z+_*N+p*te,s[6]=g*P+x*I+_*O+p*le,s[10]=g*V+x*S+_*D+p*k,s[14]=g*ne+x*b+_*B+p*G,s[3]=m*C+R*Z+y*N+E*te,s[7]=m*P+R*I+y*O+E*le,s[11]=m*V+R*S+y*D+E*k,s[15]=m*ne+R*b+y*B+E*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],f=e[14],g=e[3],x=e[7],_=e[11],p=e[15];return g*(+s*l*u-i*c*u-s*a*d+n*c*d+i*a*f-n*l*f)+x*(+t*l*f-t*c*d+s*o*d-i*o*f+i*c*h-s*l*h)+_*(+t*c*u-t*a*f-s*o*u+n*o*f+s*a*h-n*c*h)+p*(-i*a*h-t*l*u+t*a*d+i*o*u-n*o*d+n*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],g=e[12],x=e[13],_=e[14],p=e[15],m=u*_*c-x*d*c+x*l*f-a*_*f-u*l*p+a*d*p,R=g*d*c-h*_*c-g*l*f+o*_*f+h*l*p-o*d*p,y=h*x*c-g*u*c+g*a*f-o*x*f-h*a*p+o*u*p,E=g*u*l-h*x*l-g*a*d+o*x*d+h*a*_-o*u*_,C=t*m+n*R+i*y+s*E;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/C;return e[0]=m*P,e[1]=(x*d*s-u*_*s-x*i*f+n*_*f+u*i*p-n*d*p)*P,e[2]=(a*_*s-x*l*s+x*i*c-n*_*c-a*i*p+n*l*p)*P,e[3]=(u*l*s-a*d*s-u*i*c+n*d*c+a*i*f-n*l*f)*P,e[4]=R*P,e[5]=(h*_*s-g*d*s+g*i*f-t*_*f-h*i*p+t*d*p)*P,e[6]=(g*l*s-o*_*s-g*i*c+t*_*c+o*i*p-t*l*p)*P,e[7]=(o*d*s-h*l*s+h*i*c-t*d*c-o*i*f+t*l*f)*P,e[8]=y*P,e[9]=(g*u*s-h*x*s-g*n*f+t*x*f+h*n*p-t*u*p)*P,e[10]=(o*x*s-g*a*s+g*n*c-t*x*c-o*n*p+t*a*p)*P,e[11]=(h*a*s-o*u*s-h*n*c+t*u*c+o*n*f-t*a*f)*P,e[12]=E*P,e[13]=(h*x*i-g*u*i+g*n*d-t*x*d-h*n*_+t*u*_)*P,e[14]=(g*a*i-o*x*i-g*n*l+t*x*l+o*n*_-t*a*_)*P,e[15]=(o*u*i-h*a*i+h*n*l-t*u*l-o*n*d+t*a*d)*P,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,h=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+n,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,h=o+o,u=a+a,d=s*c,f=s*h,g=s*u,x=o*h,_=o*u,p=a*u,m=l*c,R=l*h,y=l*u,E=n.x,C=n.y,P=n.z;return i[0]=(1-(x+p))*E,i[1]=(f+y)*E,i[2]=(g-R)*E,i[3]=0,i[4]=(f-y)*C,i[5]=(1-(d+p))*C,i[6]=(_+m)*C,i[7]=0,i[8]=(g+R)*P,i[9]=(_-m)*P,i[10]=(1-(d+x))*P,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Jn.set(i[0],i[1],i[2]).length();const o=Jn.set(i[4],i[5],i[6]).length(),a=Jn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Rt.copy(this);const c=1/s,h=1/o,u=1/a;return Rt.elements[0]*=c,Rt.elements[1]*=c,Rt.elements[2]*=c,Rt.elements[4]*=h,Rt.elements[5]*=h,Rt.elements[6]*=h,Rt.elements[8]*=u,Rt.elements[9]*=u,Rt.elements[10]*=u,t.setFromRotationMatrix(Rt),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o){o===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*s/(t-e),c=2*s/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i),d=-(o+s)/(o-s),f=-2*o*s/(o-s);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(e,t,n,i,s,o){const a=this.elements,l=1/(t-e),c=1/(n-i),h=1/(o-s),u=(t+e)*l,d=(n+i)*c,f=(o+s)*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(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}pe.prototype.isMatrix4=!0;const Jn=new T,Rt=new pe,Bu=new T(0,0,0),Uu=new T(1,1,1),an=new T,Ss=new T,vt=new T,_a=new pe,ya=new at;class Li{constructor(e=0,t=0,n=0,i=Li.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-gt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(gt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-gt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(gt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return _a.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_a,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ya.setFromEuler(this),this.setFromQuaternion(ya,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new T(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Li.prototype.isEuler=!0;Li.DefaultOrder="XYZ";Li.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Ao{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let zu=0;const va=new T,Kn=new at,jt=new pe,Ts=new T,Ui=new T,Hu=new T,ku=new at,Ma=new T(1,0,0),ba=new T(0,1,0),wa=new T(0,0,1),Gu={type:"added"},Sa={type:"removed"};class ke extends Sn{constructor(){super(),Object.defineProperty(this,"id",{value:zu++}),this.uuid=Tt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ke.DefaultUp.clone();const e=new T,t=new Li,n=new at,i=new T(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._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:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new pe},normalMatrix:{value:new ut}}),this.matrix=new pe,this.matrixWorld=new pe,this.matrixAutoUpdate=ke.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Ao,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Kn.setFromAxisAngle(e,t),this.quaternion.multiply(Kn),this}rotateOnWorldAxis(e,t){return Kn.setFromAxisAngle(e,t),this.quaternion.premultiply(Kn),this}rotateX(e){return this.rotateOnAxis(Ma,e)}rotateY(e){return this.rotateOnAxis(ba,e)}rotateZ(e){return this.rotateOnAxis(wa,e)}translateOnAxis(e,t){return va.copy(e).applyQuaternion(this.quaternion),this.position.add(va.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ma,e)}translateY(e){return this.translateOnAxis(ba,e)}translateZ(e){return this.translateOnAxis(wa,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(jt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ts.copy(e):Ts.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Ui.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?jt.lookAt(Ui,Ts,this.up):jt.lookAt(Ts,Ui,this.up),this.quaternion.setFromRotationMatrix(jt),i&&(jt.extractRotation(i.matrixWorld),Kn.setFromRotationMatrix(jt),this.quaternion.premultiply(Kn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Gu)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Sa)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(Sa)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),jt.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),jt.multiply(e.parent.matrixWorld)),e.applyMatrix4(jt),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ui,e,Hu),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ui,ku,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),u=o(e.shapes),d=o(e.skeletons),f=o(e.animations);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f)}return n.object=i,n;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.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 n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}ke.DefaultUp=new T(0,1,0);ke.DefaultMatrixAutoUpdate=!0;ke.prototype.isObject3D=!0;const Ct=new T,Xt=new T,Lr=new T,Yt=new T,$n=new T,Qn=new T,Ta=new T,Rr=new T,Cr=new T,Pr=new T;class et{constructor(e=new T,t=new T,n=new T){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Ct.subVectors(e,t),i.cross(Ct);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Ct.subVectors(i,t),Xt.subVectors(n,t),Lr.subVectors(e,t);const o=Ct.dot(Ct),a=Ct.dot(Xt),l=Ct.dot(Lr),c=Xt.dot(Xt),h=Xt.dot(Lr),u=o*c-a*a;if(u===0)return s.set(-2,-1,-1);const d=1/u,f=(c*l-a*h)*d,g=(o*h-a*l)*d;return s.set(1-f-g,g,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Yt),Yt.x>=0&&Yt.y>=0&&Yt.x+Yt.y<=1}static getUV(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,Yt),l.set(0,0),l.addScaledVector(s,Yt.x),l.addScaledVector(o,Yt.y),l.addScaledVector(a,Yt.z),l}static isFrontFacing(e,t,n,i){return Ct.subVectors(n,t),Xt.subVectors(e,t),Ct.cross(Xt).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ct.subVectors(this.c,this.b),Xt.subVectors(this.a,this.b),Ct.cross(Xt).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return et.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return et.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return et.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return et.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return et.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let o,a;$n.subVectors(i,n),Qn.subVectors(s,n),Rr.subVectors(e,n);const l=$n.dot(Rr),c=Qn.dot(Rr);if(l<=0&&c<=0)return t.copy(n);Cr.subVectors(e,i);const h=$n.dot(Cr),u=Qn.dot(Cr);if(h>=0&&u<=h)return t.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector($n,o);Pr.subVectors(e,s);const f=$n.dot(Pr),g=Qn.dot(Pr);if(g>=0&&f<=g)return t.copy(s);const x=f*c-l*g;if(x<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(Qn,a);const _=h*g-f*u;if(_<=0&&u-h>=0&&f-g>=0)return Ta.subVectors(s,i),a=(u-h)/(u-h+(f-g)),t.copy(i).addScaledVector(Ta,a);const p=1/(_+x+d);return o=x*p,a=d*p,t.copy(n).addScaledVector($n,o).addScaledVector(Qn,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Vu=0;class rt extends Sn{constructor(){super(),Object.defineProperty(this,"id",{value:Vu++}),this.uuid=Tt(),this.name="",this.type="Material",this.fog=!0,this.blending=Ji,this.side=yi,this.vertexColors=!1,this.opacity=1,this.format=st,this.transparent=!1,this.blendSrc=Nl,this.blendDst=Fl,this.blendEquation=ui,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=to,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=yr,this.stencilZFail=yr,this.stencilZPass=yr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===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=n===Dl;continue}const i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ji&&(n.blending=this.blending),this.side!==yi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.format!==st&&(n.format=this.format),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.format=e.format,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 n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}rt.prototype.isMaterial=!0;const Vl={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},Pt={h:0,s:0,l:0},Es={h:0,s:0,l:0};function Ir(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}function Dr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Nr(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}class ue{constructor(e,t,n){return t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=To(e,1),t=gt(t,0,1),n=gt(n,0,1),t===0)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,s=2*n-i;this.r=Ir(s,i,e+1/3),this.g=Ir(s,i,e),this.b=Ir(s,i,e-1/3)}return this}setStyle(e){function t(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let i;const s=n[1],o=n[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[4]),this;if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[4]),this;break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const a=parseFloat(i[1])/360,l=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return t(i[4]),this.setHSL(a,l,c)}break}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const i=n[1],s=i.length;if(s===3)return this.r=parseInt(i.charAt(0)+i.charAt(0),16)/255,this.g=parseInt(i.charAt(1)+i.charAt(1),16)/255,this.b=parseInt(i.charAt(2)+i.charAt(2),16)/255,this;if(s===6)return this.r=parseInt(i.charAt(0)+i.charAt(1),16)/255,this.g=parseInt(i.charAt(2)+i.charAt(3),16)/255,this.b=parseInt(i.charAt(4)+i.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=Vl[e.toLowerCase()];return t!==void 0?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Dr(e.r),this.g=Dr(e.g),this.b=Dr(e.b),this}copyLinearToSRGB(e){return this.r=Nr(e.r),this.g=Nr(e.g),this.b=Nr(e.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(e){const t=this.r,n=this.g,i=this.b,s=Math.max(t,n,i),o=Math.min(t,n,i);let a,l;const c=(o+s)/2;if(o===s)a=0,l=0;else{const h=s-o;switch(l=c<=.5?h/(s+o):h/(2-s-o),s){case t:a=(n-i)/h+(n<i?6:0);break;case n:a=(i-t)/h+2;break;case i:a=(t-n)/h+4;break}a/=6}return e.h=a,e.s=l,e.l=c,e}getStyle(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"}offsetHSL(e,t,n){return this.getHSL(Pt),Pt.h+=e,Pt.s+=t,Pt.l+=n,this.setHSL(Pt.h,Pt.s,Pt.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Pt),e.getHSL(Es);const n=$i(Pt.h,Es.h,t),i=$i(Pt.s,Es.s,t),s=$i(Pt.l,Es.l,t);return this.setHSL(n,i,s),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}ue.NAMES=Vl;ue.prototype.isColor=!0;ue.prototype.r=1;ue.prototype.g=1;ue.prototype.b=1;class pn extends rt{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new ue(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=sr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}pn.prototype.isMeshBasicMaterial=!0;const je=new T,As=new j;class $e{constructor(e,t,n){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=n===!0,this.usage=is,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){const t=this.array;let n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),o=new ue),t[n++]=o.r,t[n++]=o.g,t[n++]=o.b}return this}copyVector2sArray(e){const t=this.array;let n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),o=new j),t[n++]=o.x,t[n++]=o.y}return this}copyVector3sArray(e){const t=this.array;let n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new T),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z}return this}copyVector4sArray(e){const t=this.array;let n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),o=new qe),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z,t[n++]=o.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)As.fromBufferAttribute(this,t),As.applyMatrix3(e),this.setXY(t,As.x,As.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)je.fromBufferAttribute(this,t),je.applyMatrix3(e),this.setXYZ(t,je.x,je.y,je.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)je.x=this.getX(t),je.y=this.getY(t),je.z=this.getZ(t),je.applyMatrix4(e),this.setXYZ(t,je.x,je.y,je.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)je.x=this.getX(t),je.y=this.getY(t),je.z=this.getZ(t),je.applyNormalMatrix(e),this.setXYZ(t,je.x,je.y,je.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)je.x=this.getX(t),je.y=this.getY(t),je.z=this.getZ(t),je.transformDirection(e),this.setXYZ(t,je.x,je.y,je.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==is&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}}$e.prototype.isBufferAttribute=!0;class Wl extends $e{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ql extends $e{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Wu extends $e{constructor(e,t,n){super(new Uint16Array(e),t,n)}}Wu.prototype.isFloat16BufferAttribute=!0;class lt extends $e{constructor(e,t,n){super(new Float32Array(e),t,n)}}let qu=0;const St=new pe,Fr=new ke,ei=new T,Mt=new wt,zi=new wt,ot=new T;class Xe extends Sn{constructor(){super(),Object.defineProperty(this,"id",{value:qu++}),this.uuid=Tt(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Gl(e)>65535?ql:Wl)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new ut().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return St.makeRotationFromQuaternion(e),this.applyMatrix4(St),this}rotateX(e){return St.makeRotationX(e),this.applyMatrix4(St),this}rotateY(e){return St.makeRotationY(e),this.applyMatrix4(St),this}rotateZ(e){return St.makeRotationZ(e),this.applyMatrix4(St),this}translate(e,t,n){return St.makeTranslation(e,t,n),this.applyMatrix4(St),this}scale(e,t,n){return St.makeScale(e,t,n),this.applyMatrix4(St),this}lookAt(e){return Fr.lookAt(e),Fr.updateMatrix(),this.applyMatrix4(Fr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ei).negate(),this.translate(ei.x,ei.y,ei.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new lt(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wt);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 T(-1/0,-1/0,-1/0),new T(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];Mt.setFromBufferAttribute(s),this.morphTargetsRelative?(ot.addVectors(this.boundingBox.min,Mt.min),this.boundingBox.expandByPoint(ot),ot.addVectors(this.boundingBox.max,Mt.max),this.boundingBox.expandByPoint(ot)):(this.boundingBox.expandByPoint(Mt.min),this.boundingBox.expandByPoint(Mt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Tn);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 T,1/0);return}if(e){const n=this.boundingSphere.center;if(Mt.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];zi.setFromBufferAttribute(a),this.morphTargetsRelative?(ot.addVectors(Mt.min,zi.min),Mt.expandByPoint(ot),ot.addVectors(Mt.max,zi.max),Mt.expandByPoint(ot)):(Mt.expandByPoint(zi.min),Mt.expandByPoint(zi.max))}Mt.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)ot.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(ot));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)ot.fromBufferAttribute(a,c),l&&(ei.fromBufferAttribute(e,c),ot.add(ei)),i=Math.max(i,n.distanceToSquared(ot))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.array,i=t.position.array,s=t.normal.array,o=t.uv.array,a=i.length/3;t.tangent===void 0&&this.setAttribute("tangent",new $e(new Float32Array(4*a),4));const l=t.tangent.array,c=[],h=[];for(let Z=0;Z<a;Z++)c[Z]=new T,h[Z]=new T;const u=new T,d=new T,f=new T,g=new j,x=new j,_=new j,p=new T,m=new T;function R(Z,I,S){u.fromArray(i,Z*3),d.fromArray(i,I*3),f.fromArray(i,S*3),g.fromArray(o,Z*2),x.fromArray(o,I*2),_.fromArray(o,S*2),d.sub(u),f.sub(u),x.sub(g),_.sub(g);const b=1/(x.x*_.y-_.x*x.y);!isFinite(b)||(p.copy(d).multiplyScalar(_.y).addScaledVector(f,-x.y).multiplyScalar(b),m.copy(f).multiplyScalar(x.x).addScaledVector(d,-_.x).multiplyScalar(b),c[Z].add(p),c[I].add(p),c[S].add(p),h[Z].add(m),h[I].add(m),h[S].add(m))}let y=this.groups;y.length===0&&(y=[{start:0,count:n.length}]);for(let Z=0,I=y.length;Z<I;++Z){const S=y[Z],b=S.start,N=S.count;for(let O=b,D=b+N;O<D;O+=3)R(n[O+0],n[O+1],n[O+2])}const E=new T,C=new T,P=new T,V=new T;function ne(Z){P.fromArray(s,Z*3),V.copy(P);const I=c[Z];E.copy(I),E.sub(P.multiplyScalar(P.dot(I))).normalize(),C.crossVectors(V,I);const b=C.dot(h[Z])<0?-1:1;l[Z*4]=E.x,l[Z*4+1]=E.y,l[Z*4+2]=E.z,l[Z*4+3]=b}for(let Z=0,I=y.length;Z<I;++Z){const S=y[Z],b=S.start,N=S.count;for(let O=b,D=b+N;O<D;O+=3)ne(n[O+0]),ne(n[O+1]),ne(n[O+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new $e(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new T,s=new T,o=new T,a=new T,l=new T,c=new T,h=new T,u=new T;if(e)for(let d=0,f=e.count;d<f;d+=3){const g=e.getX(d+0),x=e.getX(d+1),_=e.getX(d+2);i.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),o.fromBufferAttribute(t,_),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),a.fromBufferAttribute(n,g),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,_),a.add(h),l.add(h),c.add(h),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(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 n=this.attributes;for(const i in n){if(e.attributes[i]===void 0)continue;const o=n[i].array,a=e.attributes[i],l=a.array,c=a.itemSize*t,h=Math.min(l.length,o.length-c);for(let u=0,d=c;u<h;u++,d++)o[d]=l[u]}return this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)ot.fromBufferAttribute(e,t),ot.normalize(),e.setXYZ(t,ot.x,ot.y,ot.z)}toNonIndexed(){function e(a,l){const c=a.array,h=a.itemSize,u=a.normalized,d=new c.constructor(l.length*h);let f=0,g=0;for(let x=0,_=l.length;x<_;x++){a.isInterleavedBufferAttribute?f=l[x]*a.data.stride+a.offset:f=l[x]*h;for(let p=0;p<h;p++)d[g++]=c[f++]}return new $e(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Xe,n=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=e(l,n);t.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=e(d,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.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 l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(e.data))}h.length>0&&(i[l]=h,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,h=o.length;c<h;c++){const u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}Xe.prototype.isBufferGeometry=!0;const Ea=new pe,ti=new En,Or=new Tn,ln=new T,cn=new T,hn=new T,Br=new T,Ur=new T,zr=new T,Ls=new T,Rs=new T,Cs=new T,Ps=new j,Is=new j,Ds=new j,Hr=new T,Ns=new T;class xt extends ke{constructor(e=new Xe,t=new pn){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(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(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}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(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),Or.copy(n.boundingSphere),Or.applyMatrix4(s),e.ray.intersectsSphere(Or)===!1)||(Ea.copy(s).invert(),ti.copy(e.ray).applyMatrix4(Ea),n.boundingBox!==null&&ti.intersectsBox(n.boundingBox)===!1))return;let o;if(n.isBufferGeometry){const a=n.index,l=n.attributes.position,c=n.morphAttributes.position,h=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,f=n.groups,g=n.drawRange;if(a!==null)if(Array.isArray(i))for(let x=0,_=f.length;x<_;x++){const p=f[x],m=i[p.materialIndex],R=Math.max(p.start,g.start),y=Math.min(a.count,Math.min(p.start+p.count,g.start+g.count));for(let E=R,C=y;E<C;E+=3){const P=a.getX(E),V=a.getX(E+1),ne=a.getX(E+2);o=Fs(this,m,e,ti,l,c,h,u,d,P,V,ne),o&&(o.faceIndex=Math.floor(E/3),o.face.materialIndex=p.materialIndex,t.push(o))}}else{const x=Math.max(0,g.start),_=Math.min(a.count,g.start+g.count);for(let p=x,m=_;p<m;p+=3){const R=a.getX(p),y=a.getX(p+1),E=a.getX(p+2);o=Fs(this,i,e,ti,l,c,h,u,d,R,y,E),o&&(o.faceIndex=Math.floor(p/3),t.push(o))}}else if(l!==void 0)if(Array.isArray(i))for(let x=0,_=f.length;x<_;x++){const p=f[x],m=i[p.materialIndex],R=Math.max(p.start,g.start),y=Math.min(l.count,Math.min(p.start+p.count,g.start+g.count));for(let E=R,C=y;E<C;E+=3){const P=E,V=E+1,ne=E+2;o=Fs(this,m,e,ti,l,c,h,u,d,P,V,ne),o&&(o.faceIndex=Math.floor(E/3),o.face.materialIndex=p.materialIndex,t.push(o))}}else{const x=Math.max(0,g.start),_=Math.min(l.count,g.start+g.count);for(let p=x,m=_;p<m;p+=3){const R=p,y=p+1,E=p+2;o=Fs(this,i,e,ti,l,c,h,u,d,R,y,E),o&&(o.faceIndex=Math.floor(p/3),t.push(o))}}}else n.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}xt.prototype.isMesh=!0;function ju(r,e,t,n,i,s,o,a){let l;if(e.side===it?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,e.side!==Un,a),l===null)return null;Ns.copy(a),Ns.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(Ns);return c<t.near||c>t.far?null:{distance:c,point:Ns.clone(),object:r}}function Fs(r,e,t,n,i,s,o,a,l,c,h,u){ln.fromBufferAttribute(i,c),cn.fromBufferAttribute(i,h),hn.fromBufferAttribute(i,u);const d=r.morphTargetInfluences;if(s&&d){Ls.set(0,0,0),Rs.set(0,0,0),Cs.set(0,0,0);for(let g=0,x=s.length;g<x;g++){const _=d[g],p=s[g];_!==0&&(Br.fromBufferAttribute(p,c),Ur.fromBufferAttribute(p,h),zr.fromBufferAttribute(p,u),o?(Ls.addScaledVector(Br,_),Rs.addScaledVector(Ur,_),Cs.addScaledVector(zr,_)):(Ls.addScaledVector(Br.sub(ln),_),Rs.addScaledVector(Ur.sub(cn),_),Cs.addScaledVector(zr.sub(hn),_)))}ln.add(Ls),cn.add(Rs),hn.add(Cs)}r.isSkinnedMesh&&(r.boneTransform(c,ln),r.boneTransform(h,cn),r.boneTransform(u,hn));const f=ju(r,e,t,n,ln,cn,hn,Hr);if(f){a&&(Ps.fromBufferAttribute(a,c),Is.fromBufferAttribute(a,h),Ds.fromBufferAttribute(a,u),f.uv=et.getUV(Hr,ln,cn,hn,Ps,Is,Ds,new j)),l&&(Ps.fromBufferAttribute(l,c),Is.fromBufferAttribute(l,h),Ds.fromBufferAttribute(l,u),f.uv2=et.getUV(Hr,ln,cn,hn,Ps,Is,Ds,new j));const g={a:c,b:h,c:u,normal:new T,materialIndex:0};et.getNormal(ln,cn,hn,g.normal),f.face=g}return f}class fs extends Xe{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],u=[];let d=0,f=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new lt(c,3)),this.setAttribute("normal",new lt(h,3)),this.setAttribute("uv",new lt(u,2));function g(x,_,p,m,R,y,E,C,P,V,ne){const Z=y/P,I=E/V,S=y/2,b=E/2,N=C/2,O=P+1,D=V+1;let B=0,te=0;const le=new T;for(let k=0;k<D;k++){const G=k*I-b;for(let ce=0;ce<O;ce++){const ae=ce*Z-S;le[x]=ae*m,le[_]=G*R,le[p]=N,c.push(le.x,le.y,le.z),le[x]=0,le[_]=0,le[p]=C>0?1:-1,h.push(le.x,le.y,le.z),u.push(ce/P),u.push(1-k/V),B+=1}}for(let k=0;k<V;k++)for(let G=0;G<P;G++){const ce=d+G+O*k,ae=d+G+O*(k+1),fe=d+(G+1)+O*(k+1),Ce=d+(G+1)+O*k;l.push(ce,ae,Ce),l.push(ae,fe,Ce),te+=6}a.addGroup(f,te,ne),f+=te,d+=B}}static fromJSON(e){return new fs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function wi(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function ft(r){const e={};for(let t=0;t<r.length;t++){const n=wi(r[t]);for(const i in n)e[i]=n[i]}return e}const jl={clone:wi,merge:ft};var Xu=`void main() {
  6. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  7. }`,Yu=`void main() {
  8. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  9. }`;class bn extends rt{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=Xu,this.fragmentShader=Yu,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!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))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=wi(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.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}bn.prototype.isShaderMaterial=!0;class Lo extends ke{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new pe,this.projectionMatrix=new pe,this.projectionMatrixInverse=new pe}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}Lo.prototype.isCamera=!0;class pt extends Lo{constructor(e=50,t=1,n=.1,i=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ss*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ki*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ss*2*Math.atan(Math.tan(Ki*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,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=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ki*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}pt.prototype.isPerspectiveCamera=!0;const ni=90,ii=1;class Ro extends ke{constructor(e,t,n){if(super(),this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;const i=new pt(ni,ii,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new T(1,0,0)),this.add(i);const s=new pt(ni,ii,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new T(-1,0,0)),this.add(s);const o=new pt(ni,ii,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new T(0,1,0)),this.add(o);const a=new pt(ni,ii,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new T(0,-1,0)),this.add(a);const l=new pt(ni,ii,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new T(0,0,1)),this.add(l);const c=new pt(ni,ii,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new T(0,0,-1)),this.add(c)}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget,[i,s,o,a,l,c]=this.children,h=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,l),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(u),e.xr.enabled=h}}class ar extends tt{constructor(e,t,n,i,s,o,a,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:us,super(e,t,n,i,s,o,a,l,c,h),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}ar.prototype.isCubeTexture=!0;class Xl extends Et{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),super(e,e,t),t=t||{},this.texture=new ar(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:ht,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=st,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
  10. varying vec3 vWorldDirection;
  11. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  12. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  13. }
  14. void main() {
  15. vWorldDirection = transformDirection( position, modelMatrix );
  16. #include <begin_vertex>
  17. #include <project_vertex>
  18. }
  19. `,fragmentShader:`
  20. uniform sampler2D tEquirect;
  21. varying vec3 vWorldDirection;
  22. #include <common>
  23. void main() {
  24. vec3 direction = normalize( vWorldDirection );
  25. vec2 sampleUV = equirectUv( direction );
  26. gl_FragColor = texture2D( tEquirect, sampleUV );
  27. }
  28. `},i=new fs(5,5,5),s=new bn({name:"CubemapFromEquirect",uniforms:wi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:it,blending:mn});s.uniforms.tEquirect.value=t;const o=new xt(i,s),a=t.minFilter;return t.minFilter===Ei&&(t.minFilter=ht),new Ro(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}}Xl.prototype.isWebGLCubeRenderTarget=!0;const kr=new T,Zu=new T,Ju=new ut;class Kt{constructor(e=new T(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=kr.subVectors(n,t).cross(Zu.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(kr),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Ju.getNormalMatrix(e),i=this.coplanarPoint(kr).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}Kt.prototype.isPlane=!0;const si=new Tn,Os=new T;class lr{constructor(e=new Kt,t=new Kt,n=new Kt,i=new Kt,s=new Kt,o=new Kt){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],s=n[1],o=n[2],a=n[3],l=n[4],c=n[5],h=n[6],u=n[7],d=n[8],f=n[9],g=n[10],x=n[11],_=n[12],p=n[13],m=n[14],R=n[15];return t[0].setComponents(a-i,u-l,x-d,R-_).normalize(),t[1].setComponents(a+i,u+l,x+d,R+_).normalize(),t[2].setComponents(a+s,u+c,x+f,R+p).normalize(),t[3].setComponents(a-s,u-c,x-f,R-p).normalize(),t[4].setComponents(a-o,u-h,x-g,R-m).normalize(),t[5].setComponents(a+o,u+h,x+g,R+m).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),si.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(si)}intersectsSprite(e){return si.center.set(0,0,0),si.radius=.7071067811865476,si.applyMatrix4(e.matrixWorld),this.intersectsSphere(si)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Os.x=i.normal.x>0?e.max.x:e.min.x,Os.y=i.normal.y>0?e.max.y:e.min.y,Os.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Os)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Yl(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function Ku(r,e){const t=e.isWebGL2,n=new WeakMap;function i(c,h){const u=c.array,d=c.usage,f=r.createBuffer();r.bindBuffer(h,f),r.bufferData(h,u,d),c.onUploadCallback();let g=5126;return u instanceof Float32Array?g=5126:u instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):u instanceof Uint16Array?c.isFloat16BufferAttribute?t?g=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):g=5123:u instanceof Int16Array?g=5122:u instanceof Uint32Array?g=5125:u instanceof Int32Array?g=5124:u instanceof Int8Array?g=5120:(u instanceof Uint8Array||u instanceof Uint8ClampedArray)&&(g=5121),{buffer:f,type:g,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function s(c,h,u){const d=h.array,f=h.updateRange;r.bindBuffer(u,c),f.count===-1?r.bufferSubData(u,0,d):(t?r.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):r.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);const h=n.get(c);h&&(r.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,i(c,h)):u.version<c.version&&(s(u.buffer,c,h),u.version=c.version)}return{get:o,remove:a,update:l}}class Co extends Xe{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,o=t/2,a=Math.floor(n),l=Math.floor(i),c=a+1,h=l+1,u=e/a,d=t/l,f=[],g=[],x=[],_=[];for(let p=0;p<h;p++){const m=p*d-o;for(let R=0;R<c;R++){const y=R*u-s;g.push(y,-m,0),x.push(0,0,1),_.push(R/a),_.push(1-p/l)}}for(let p=0;p<l;p++)for(let m=0;m<a;m++){const R=m+c*p,y=m+c*(p+1),E=m+1+c*(p+1),C=m+1+c*p;f.push(R,y,C),f.push(y,E,C)}this.setIndex(f),this.setAttribute("position",new lt(g,3)),this.setAttribute("normal",new lt(x,3)),this.setAttribute("uv",new lt(_,2))}static fromJSON(e){return new Co(e.width,e.height,e.widthSegments,e.heightSegments)}}var $u=`#ifdef USE_ALPHAMAP
  29. diffuseColor.a *= texture2D( alphaMap, vUv ).g;
  30. #endif`,Qu=`#ifdef USE_ALPHAMAP
  31. uniform sampler2D alphaMap;
  32. #endif`,ed=`#ifdef USE_ALPHATEST
  33. if ( diffuseColor.a < alphaTest ) discard;
  34. #endif`,td=`#ifdef USE_ALPHATEST
  35. uniform float alphaTest;
  36. #endif`,nd=`#ifdef USE_AOMAP
  37. float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
  38. reflectedLight.indirectDiffuse *= ambientOcclusion;
  39. #if defined( USE_ENVMAP ) && defined( STANDARD )
  40. float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
  41. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  42. #endif
  43. #endif`,id=`#ifdef USE_AOMAP
  44. uniform sampler2D aoMap;
  45. uniform float aoMapIntensity;
  46. #endif`,sd="vec3 transformed = vec3( position );",rd=`vec3 objectNormal = vec3( normal );
  47. #ifdef USE_TANGENT
  48. vec3 objectTangent = vec3( tangent.xyz );
  49. #endif`,od=`vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  50. return RECIPROCAL_PI * diffuseColor;
  51. }
  52. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  53. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  54. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  55. }
  56. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  57. float a2 = pow2( alpha );
  58. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  59. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  60. return 0.5 / max( gv + gl, EPSILON );
  61. }
  62. float D_GGX( const in float alpha, const in float dotNH ) {
  63. float a2 = pow2( alpha );
  64. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  65. return RECIPROCAL_PI * a2 / pow2( denom );
  66. }
  67. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
  68. float alpha = pow2( roughness );
  69. vec3 halfDir = normalize( lightDir + viewDir );
  70. float dotNL = saturate( dot( normal, lightDir ) );
  71. float dotNV = saturate( dot( normal, viewDir ) );
  72. float dotNH = saturate( dot( normal, halfDir ) );
  73. float dotVH = saturate( dot( viewDir, halfDir ) );
  74. vec3 F = F_Schlick( f0, f90, dotVH );
  75. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  76. float D = D_GGX( alpha, dotNH );
  77. return F * ( V * D );
  78. }
  79. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  80. const float LUT_SIZE = 64.0;
  81. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  82. const float LUT_BIAS = 0.5 / LUT_SIZE;
  83. float dotNV = saturate( dot( N, V ) );
  84. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  85. uv = uv * LUT_SCALE + LUT_BIAS;
  86. return uv;
  87. }
  88. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  89. float l = length( f );
  90. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  91. }
  92. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  93. float x = dot( v1, v2 );
  94. float y = abs( x );
  95. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  96. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  97. float v = a / b;
  98. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  99. return cross( v1, v2 ) * theta_sintheta;
  100. }
  101. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  102. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  103. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  104. vec3 lightNormal = cross( v1, v2 );
  105. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  106. vec3 T1, T2;
  107. T1 = normalize( V - N * dot( V, N ) );
  108. T2 = - cross( N, T1 );
  109. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  110. vec3 coords[ 4 ];
  111. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  112. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  113. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  114. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  115. coords[ 0 ] = normalize( coords[ 0 ] );
  116. coords[ 1 ] = normalize( coords[ 1 ] );
  117. coords[ 2 ] = normalize( coords[ 2 ] );
  118. coords[ 3 ] = normalize( coords[ 3 ] );
  119. vec3 vectorFormFactor = vec3( 0.0 );
  120. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  121. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  122. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  123. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  124. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  125. return vec3( result );
  126. }
  127. float G_BlinnPhong_Implicit( ) {
  128. return 0.25;
  129. }
  130. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  131. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  132. }
  133. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  134. vec3 halfDir = normalize( lightDir + viewDir );
  135. float dotNH = saturate( dot( normal, halfDir ) );
  136. float dotVH = saturate( dot( viewDir, halfDir ) );
  137. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  138. float G = G_BlinnPhong_Implicit( );
  139. float D = D_BlinnPhong( shininess, dotNH );
  140. return F * ( G * D );
  141. }
  142. #if defined( USE_SHEEN )
  143. float D_Charlie( float roughness, float dotNH ) {
  144. float alpha = pow2( roughness );
  145. float invAlpha = 1.0 / alpha;
  146. float cos2h = dotNH * dotNH;
  147. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  148. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  149. }
  150. float V_Neubelt( float dotNV, float dotNL ) {
  151. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  152. }
  153. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  154. vec3 halfDir = normalize( lightDir + viewDir );
  155. float dotNL = saturate( dot( normal, lightDir ) );
  156. float dotNV = saturate( dot( normal, viewDir ) );
  157. float dotNH = saturate( dot( normal, halfDir ) );
  158. float D = D_Charlie( sheenRoughness, dotNH );
  159. float V = V_Neubelt( dotNV, dotNL );
  160. return sheenColor * ( D * V );
  161. }
  162. #endif`,ad=`#ifdef USE_BUMPMAP
  163. uniform sampler2D bumpMap;
  164. uniform float bumpScale;
  165. vec2 dHdxy_fwd() {
  166. vec2 dSTdx = dFdx( vUv );
  167. vec2 dSTdy = dFdy( vUv );
  168. float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
  169. float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
  170. float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
  171. return vec2( dBx, dBy );
  172. }
  173. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  174. vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
  175. vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
  176. vec3 vN = surf_norm;
  177. vec3 R1 = cross( vSigmaY, vN );
  178. vec3 R2 = cross( vN, vSigmaX );
  179. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  180. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  181. return normalize( abs( fDet ) * surf_norm - vGrad );
  182. }
  183. #endif`,ld=`#if NUM_CLIPPING_PLANES > 0
  184. vec4 plane;
  185. #pragma unroll_loop_start
  186. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  187. plane = clippingPlanes[ i ];
  188. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  189. }
  190. #pragma unroll_loop_end
  191. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  192. bool clipped = true;
  193. #pragma unroll_loop_start
  194. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  195. plane = clippingPlanes[ i ];
  196. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  197. }
  198. #pragma unroll_loop_end
  199. if ( clipped ) discard;
  200. #endif
  201. #endif`,cd=`#if NUM_CLIPPING_PLANES > 0
  202. varying vec3 vClipPosition;
  203. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  204. #endif`,hd=`#if NUM_CLIPPING_PLANES > 0
  205. varying vec3 vClipPosition;
  206. #endif`,ud=`#if NUM_CLIPPING_PLANES > 0
  207. vClipPosition = - mvPosition.xyz;
  208. #endif`,dd=`#if defined( USE_COLOR_ALPHA )
  209. diffuseColor *= vColor;
  210. #elif defined( USE_COLOR )
  211. diffuseColor.rgb *= vColor;
  212. #endif`,fd=`#if defined( USE_COLOR_ALPHA )
  213. varying vec4 vColor;
  214. #elif defined( USE_COLOR )
  215. varying vec3 vColor;
  216. #endif`,pd=`#if defined( USE_COLOR_ALPHA )
  217. varying vec4 vColor;
  218. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  219. varying vec3 vColor;
  220. #endif`,md=`#if defined( USE_COLOR_ALPHA )
  221. vColor = vec4( 1.0 );
  222. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  223. vColor = vec3( 1.0 );
  224. #endif
  225. #ifdef USE_COLOR
  226. vColor *= color;
  227. #endif
  228. #ifdef USE_INSTANCING_COLOR
  229. vColor.xyz *= instanceColor.xyz;
  230. #endif`,gd=`#define PI 3.141592653589793
  231. #define PI2 6.283185307179586
  232. #define PI_HALF 1.5707963267948966
  233. #define RECIPROCAL_PI 0.3183098861837907
  234. #define RECIPROCAL_PI2 0.15915494309189535
  235. #define EPSILON 1e-6
  236. #ifndef saturate
  237. #define saturate( a ) clamp( a, 0.0, 1.0 )
  238. #endif
  239. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  240. float pow2( const in float x ) { return x*x; }
  241. float pow3( const in float x ) { return x*x*x; }
  242. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  243. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  244. float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
  245. highp float rand( const in vec2 uv ) {
  246. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  247. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  248. return fract( sin( sn ) * c );
  249. }
  250. #ifdef HIGH_PRECISION
  251. float precisionSafeLength( vec3 v ) { return length( v ); }
  252. #else
  253. float precisionSafeLength( vec3 v ) {
  254. float maxComponent = max3( abs( v ) );
  255. return length( v / maxComponent ) * maxComponent;
  256. }
  257. #endif
  258. struct IncidentLight {
  259. vec3 color;
  260. vec3 direction;
  261. bool visible;
  262. };
  263. struct ReflectedLight {
  264. vec3 directDiffuse;
  265. vec3 directSpecular;
  266. vec3 indirectDiffuse;
  267. vec3 indirectSpecular;
  268. };
  269. struct GeometricContext {
  270. vec3 position;
  271. vec3 normal;
  272. vec3 viewDir;
  273. #ifdef USE_CLEARCOAT
  274. vec3 clearcoatNormal;
  275. #endif
  276. };
  277. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  278. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  279. }
  280. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  281. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  282. }
  283. mat3 transposeMat3( const in mat3 m ) {
  284. mat3 tmp;
  285. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  286. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  287. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  288. return tmp;
  289. }
  290. float linearToRelativeLuminance( const in vec3 color ) {
  291. vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
  292. return dot( weights, color.rgb );
  293. }
  294. bool isPerspectiveMatrix( mat4 m ) {
  295. return m[ 2 ][ 3 ] == - 1.0;
  296. }
  297. vec2 equirectUv( in vec3 dir ) {
  298. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  299. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  300. return vec2( u, v );
  301. }`,xd=`#ifdef ENVMAP_TYPE_CUBE_UV
  302. #define cubeUV_maxMipLevel 8.0
  303. #define cubeUV_minMipLevel 4.0
  304. #define cubeUV_maxTileSize 256.0
  305. #define cubeUV_minTileSize 16.0
  306. float getFace( vec3 direction ) {
  307. vec3 absDirection = abs( direction );
  308. float face = - 1.0;
  309. if ( absDirection.x > absDirection.z ) {
  310. if ( absDirection.x > absDirection.y )
  311. face = direction.x > 0.0 ? 0.0 : 3.0;
  312. else
  313. face = direction.y > 0.0 ? 1.0 : 4.0;
  314. } else {
  315. if ( absDirection.z > absDirection.y )
  316. face = direction.z > 0.0 ? 2.0 : 5.0;
  317. else
  318. face = direction.y > 0.0 ? 1.0 : 4.0;
  319. }
  320. return face;
  321. }
  322. vec2 getUV( vec3 direction, float face ) {
  323. vec2 uv;
  324. if ( face == 0.0 ) {
  325. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  326. } else if ( face == 1.0 ) {
  327. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  328. } else if ( face == 2.0 ) {
  329. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  330. } else if ( face == 3.0 ) {
  331. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  332. } else if ( face == 4.0 ) {
  333. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  334. } else {
  335. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  336. }
  337. return 0.5 * ( uv + 1.0 );
  338. }
  339. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  340. float face = getFace( direction );
  341. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  342. mipInt = max( mipInt, cubeUV_minMipLevel );
  343. float faceSize = exp2( mipInt );
  344. float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );
  345. vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;
  346. if ( face > 2.0 ) {
  347. uv.y += faceSize;
  348. face -= 3.0;
  349. }
  350. uv.x += face * faceSize;
  351. if ( mipInt < cubeUV_maxMipLevel ) {
  352. uv.y += 2.0 * cubeUV_maxTileSize;
  353. }
  354. uv.y += filterInt * 2.0 * cubeUV_minTileSize;
  355. uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );
  356. uv *= texelSize;
  357. return texture2D( envMap, uv ).rgb;
  358. }
  359. #define r0 1.0
  360. #define v0 0.339
  361. #define m0 - 2.0
  362. #define r1 0.8
  363. #define v1 0.276
  364. #define m1 - 1.0
  365. #define r4 0.4
  366. #define v4 0.046
  367. #define m4 2.0
  368. #define r5 0.305
  369. #define v5 0.016
  370. #define m5 3.0
  371. #define r6 0.21
  372. #define v6 0.0038
  373. #define m6 4.0
  374. float roughnessToMip( float roughness ) {
  375. float mip = 0.0;
  376. if ( roughness >= r1 ) {
  377. mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
  378. } else if ( roughness >= r4 ) {
  379. mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
  380. } else if ( roughness >= r5 ) {
  381. mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
  382. } else if ( roughness >= r6 ) {
  383. mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
  384. } else {
  385. mip = - 2.0 * log2( 1.16 * roughness ); }
  386. return mip;
  387. }
  388. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  389. float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );
  390. float mipF = fract( mip );
  391. float mipInt = floor( mip );
  392. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  393. if ( mipF == 0.0 ) {
  394. return vec4( color0, 1.0 );
  395. } else {
  396. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  397. return vec4( mix( color0, color1, mipF ), 1.0 );
  398. }
  399. }
  400. #endif`,_d=`vec3 transformedNormal = objectNormal;
  401. #ifdef USE_INSTANCING
  402. mat3 m = mat3( instanceMatrix );
  403. transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
  404. transformedNormal = m * transformedNormal;
  405. #endif
  406. transformedNormal = normalMatrix * transformedNormal;
  407. #ifdef FLIP_SIDED
  408. transformedNormal = - transformedNormal;
  409. #endif
  410. #ifdef USE_TANGENT
  411. vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  412. #ifdef FLIP_SIDED
  413. transformedTangent = - transformedTangent;
  414. #endif
  415. #endif`,yd=`#ifdef USE_DISPLACEMENTMAP
  416. uniform sampler2D displacementMap;
  417. uniform float displacementScale;
  418. uniform float displacementBias;
  419. #endif`,vd=`#ifdef USE_DISPLACEMENTMAP
  420. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
  421. #endif`,Md=`#ifdef USE_EMISSIVEMAP
  422. vec4 emissiveColor = texture2D( emissiveMap, vUv );
  423. emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;
  424. totalEmissiveRadiance *= emissiveColor.rgb;
  425. #endif`,bd=`#ifdef USE_EMISSIVEMAP
  426. uniform sampler2D emissiveMap;
  427. #endif`,wd="gl_FragColor = linearToOutputTexel( gl_FragColor );",Sd=`vec4 LinearToLinear( in vec4 value ) {
  428. return value;
  429. }
  430. vec4 sRGBToLinear( in vec4 value ) {
  431. 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 );
  432. }
  433. vec4 LinearTosRGB( in vec4 value ) {
  434. 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 );
  435. }`,Td=`#ifdef USE_ENVMAP
  436. #ifdef ENV_WORLDPOS
  437. vec3 cameraToFrag;
  438. if ( isOrthographic ) {
  439. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  440. } else {
  441. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  442. }
  443. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  444. #ifdef ENVMAP_MODE_REFLECTION
  445. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  446. #else
  447. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  448. #endif
  449. #else
  450. vec3 reflectVec = vReflect;
  451. #endif
  452. #ifdef ENVMAP_TYPE_CUBE
  453. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  454. envColor = envMapTexelToLinear( envColor );
  455. #elif defined( ENVMAP_TYPE_CUBE_UV )
  456. vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
  457. #else
  458. vec4 envColor = vec4( 0.0 );
  459. #endif
  460. #ifdef ENVMAP_BLENDING_MULTIPLY
  461. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  462. #elif defined( ENVMAP_BLENDING_MIX )
  463. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  464. #elif defined( ENVMAP_BLENDING_ADD )
  465. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  466. #endif
  467. #endif`,Ed=`#ifdef USE_ENVMAP
  468. uniform float envMapIntensity;
  469. uniform float flipEnvMap;
  470. #ifdef ENVMAP_TYPE_CUBE
  471. uniform samplerCube envMap;
  472. #else
  473. uniform sampler2D envMap;
  474. #endif
  475. #endif`,Ad=`#ifdef USE_ENVMAP
  476. uniform float reflectivity;
  477. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
  478. #define ENV_WORLDPOS
  479. #endif
  480. #ifdef ENV_WORLDPOS
  481. varying vec3 vWorldPosition;
  482. uniform float refractionRatio;
  483. #else
  484. varying vec3 vReflect;
  485. #endif
  486. #endif`,Ld=`#ifdef USE_ENVMAP
  487. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
  488. #define ENV_WORLDPOS
  489. #endif
  490. #ifdef ENV_WORLDPOS
  491. varying vec3 vWorldPosition;
  492. #else
  493. varying vec3 vReflect;
  494. uniform float refractionRatio;
  495. #endif
  496. #endif`,Rd=`#ifdef USE_ENVMAP
  497. #ifdef ENV_WORLDPOS
  498. vWorldPosition = worldPosition.xyz;
  499. #else
  500. vec3 cameraToVertex;
  501. if ( isOrthographic ) {
  502. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  503. } else {
  504. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  505. }
  506. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  507. #ifdef ENVMAP_MODE_REFLECTION
  508. vReflect = reflect( cameraToVertex, worldNormal );
  509. #else
  510. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  511. #endif
  512. #endif
  513. #endif`,Cd=`#ifdef USE_FOG
  514. vFogDepth = - mvPosition.z;
  515. #endif`,Pd=`#ifdef USE_FOG
  516. varying float vFogDepth;
  517. #endif`,Id=`#ifdef USE_FOG
  518. #ifdef FOG_EXP2
  519. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  520. #else
  521. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  522. #endif
  523. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  524. #endif`,Dd=`#ifdef USE_FOG
  525. uniform vec3 fogColor;
  526. varying float vFogDepth;
  527. #ifdef FOG_EXP2
  528. uniform float fogDensity;
  529. #else
  530. uniform float fogNear;
  531. uniform float fogFar;
  532. #endif
  533. #endif`,Nd=`#ifdef USE_GRADIENTMAP
  534. uniform sampler2D gradientMap;
  535. #endif
  536. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  537. float dotNL = dot( normal, lightDirection );
  538. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  539. #ifdef USE_GRADIENTMAP
  540. return vec3( texture2D( gradientMap, coord ).r );
  541. #else
  542. return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
  543. #endif
  544. }`,Fd=`#ifdef USE_LIGHTMAP
  545. vec4 lightMapTexel = texture2D( lightMap, vUv2 );
  546. vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  547. #ifndef PHYSICALLY_CORRECT_LIGHTS
  548. lightMapIrradiance *= PI;
  549. #endif
  550. reflectedLight.indirectDiffuse += lightMapIrradiance;
  551. #endif`,Od=`#ifdef USE_LIGHTMAP
  552. uniform sampler2D lightMap;
  553. uniform float lightMapIntensity;
  554. #endif`,Bd=`vec3 diffuse = vec3( 1.0 );
  555. GeometricContext geometry;
  556. geometry.position = mvPosition.xyz;
  557. geometry.normal = normalize( transformedNormal );
  558. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
  559. GeometricContext backGeometry;
  560. backGeometry.position = geometry.position;
  561. backGeometry.normal = -geometry.normal;
  562. backGeometry.viewDir = geometry.viewDir;
  563. vLightFront = vec3( 0.0 );
  564. vIndirectFront = vec3( 0.0 );
  565. #ifdef DOUBLE_SIDED
  566. vLightBack = vec3( 0.0 );
  567. vIndirectBack = vec3( 0.0 );
  568. #endif
  569. IncidentLight directLight;
  570. float dotNL;
  571. vec3 directLightColor_Diffuse;
  572. vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
  573. vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
  574. #ifdef DOUBLE_SIDED
  575. vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
  576. vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
  577. #endif
  578. #if NUM_POINT_LIGHTS > 0
  579. #pragma unroll_loop_start
  580. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  581. getPointLightInfo( pointLights[ i ], geometry, directLight );
  582. dotNL = dot( geometry.normal, directLight.direction );
  583. directLightColor_Diffuse = directLight.color;
  584. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  585. #ifdef DOUBLE_SIDED
  586. vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
  587. #endif
  588. }
  589. #pragma unroll_loop_end
  590. #endif
  591. #if NUM_SPOT_LIGHTS > 0
  592. #pragma unroll_loop_start
  593. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  594. getSpotLightInfo( spotLights[ i ], geometry, directLight );
  595. dotNL = dot( geometry.normal, directLight.direction );
  596. directLightColor_Diffuse = directLight.color;
  597. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  598. #ifdef DOUBLE_SIDED
  599. vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
  600. #endif
  601. }
  602. #pragma unroll_loop_end
  603. #endif
  604. #if NUM_DIR_LIGHTS > 0
  605. #pragma unroll_loop_start
  606. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  607. getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
  608. dotNL = dot( geometry.normal, directLight.direction );
  609. directLightColor_Diffuse = directLight.color;
  610. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  611. #ifdef DOUBLE_SIDED
  612. vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
  613. #endif
  614. }
  615. #pragma unroll_loop_end
  616. #endif
  617. #if NUM_HEMI_LIGHTS > 0
  618. #pragma unroll_loop_start
  619. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  620. vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
  621. #ifdef DOUBLE_SIDED
  622. vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
  623. #endif
  624. }
  625. #pragma unroll_loop_end
  626. #endif`,Ud=`uniform bool receiveShadow;
  627. uniform vec3 ambientLightColor;
  628. uniform vec3 lightProbe[ 9 ];
  629. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  630. float x = normal.x, y = normal.y, z = normal.z;
  631. vec3 result = shCoefficients[ 0 ] * 0.886227;
  632. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  633. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  634. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  635. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  636. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  637. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  638. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  639. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  640. return result;
  641. }
  642. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  643. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  644. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  645. return irradiance;
  646. }
  647. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  648. vec3 irradiance = ambientLightColor;
  649. return irradiance;
  650. }
  651. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  652. #if defined ( PHYSICALLY_CORRECT_LIGHTS )
  653. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  654. if ( cutoffDistance > 0.0 ) {
  655. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  656. }
  657. return distanceFalloff;
  658. #else
  659. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  660. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  661. }
  662. return 1.0;
  663. #endif
  664. }
  665. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  666. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  667. }
  668. #if NUM_DIR_LIGHTS > 0
  669. struct DirectionalLight {
  670. vec3 direction;
  671. vec3 color;
  672. };
  673. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  674. void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
  675. light.color = directionalLight.color;
  676. light.direction = directionalLight.direction;
  677. light.visible = true;
  678. }
  679. #endif
  680. #if NUM_POINT_LIGHTS > 0
  681. struct PointLight {
  682. vec3 position;
  683. vec3 color;
  684. float distance;
  685. float decay;
  686. };
  687. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  688. void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
  689. vec3 lVector = pointLight.position - geometry.position;
  690. light.direction = normalize( lVector );
  691. float lightDistance = length( lVector );
  692. light.color = pointLight.color;
  693. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  694. light.visible = ( light.color != vec3( 0.0 ) );
  695. }
  696. #endif
  697. #if NUM_SPOT_LIGHTS > 0
  698. struct SpotLight {
  699. vec3 position;
  700. vec3 direction;
  701. vec3 color;
  702. float distance;
  703. float decay;
  704. float coneCos;
  705. float penumbraCos;
  706. };
  707. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  708. void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
  709. vec3 lVector = spotLight.position - geometry.position;
  710. light.direction = normalize( lVector );
  711. float angleCos = dot( light.direction, spotLight.direction );
  712. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  713. if ( spotAttenuation > 0.0 ) {
  714. float lightDistance = length( lVector );
  715. light.color = spotLight.color * spotAttenuation;
  716. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  717. light.visible = ( light.color != vec3( 0.0 ) );
  718. } else {
  719. light.color = vec3( 0.0 );
  720. light.visible = false;
  721. }
  722. }
  723. #endif
  724. #if NUM_RECT_AREA_LIGHTS > 0
  725. struct RectAreaLight {
  726. vec3 color;
  727. vec3 position;
  728. vec3 halfWidth;
  729. vec3 halfHeight;
  730. };
  731. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  732. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  733. #endif
  734. #if NUM_HEMI_LIGHTS > 0
  735. struct HemisphereLight {
  736. vec3 direction;
  737. vec3 skyColor;
  738. vec3 groundColor;
  739. };
  740. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  741. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  742. float dotNL = dot( normal, hemiLight.direction );
  743. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  744. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  745. return irradiance;
  746. }
  747. #endif`,zd=`#if defined( USE_ENVMAP )
  748. #ifdef ENVMAP_MODE_REFRACTION
  749. uniform float refractionRatio;
  750. #endif
  751. vec3 getIBLIrradiance( const in vec3 normal ) {
  752. #if defined( ENVMAP_TYPE_CUBE_UV )
  753. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  754. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  755. return PI * envMapColor.rgb * envMapIntensity;
  756. #else
  757. return vec3( 0.0 );
  758. #endif
  759. }
  760. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  761. #if defined( ENVMAP_TYPE_CUBE_UV )
  762. vec3 reflectVec;
  763. #ifdef ENVMAP_MODE_REFLECTION
  764. reflectVec = reflect( - viewDir, normal );
  765. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  766. #else
  767. reflectVec = refract( - viewDir, normal, refractionRatio );
  768. #endif
  769. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  770. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  771. return envMapColor.rgb * envMapIntensity;
  772. #else
  773. return vec3( 0.0 );
  774. #endif
  775. }
  776. #endif`,Hd=`ToonMaterial material;
  777. material.diffuseColor = diffuseColor.rgb;`,kd=`varying vec3 vViewPosition;
  778. struct ToonMaterial {
  779. vec3 diffuseColor;
  780. };
  781. void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  782. vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
  783. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  784. }
  785. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  786. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  787. }
  788. #define RE_Direct RE_Direct_Toon
  789. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
  790. #define Material_LightProbeLOD( material ) (0)`,Gd=`BlinnPhongMaterial material;
  791. material.diffuseColor = diffuseColor.rgb;
  792. material.specularColor = specular;
  793. material.specularShininess = shininess;
  794. material.specularStrength = specularStrength;`,Vd=`varying vec3 vViewPosition;
  795. struct BlinnPhongMaterial {
  796. vec3 diffuseColor;
  797. vec3 specularColor;
  798. float specularShininess;
  799. float specularStrength;
  800. };
  801. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  802. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  803. vec3 irradiance = dotNL * directLight.color;
  804. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  805. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
  806. }
  807. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  808. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  809. }
  810. #define RE_Direct RE_Direct_BlinnPhong
  811. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
  812. #define Material_LightProbeLOD( material ) (0)`,Wd=`PhysicalMaterial material;
  813. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  814. vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
  815. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  816. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  817. material.roughness = min( material.roughness, 1.0 );
  818. #ifdef IOR
  819. #ifdef SPECULAR
  820. float specularIntensityFactor = specularIntensity;
  821. vec3 specularColorFactor = specularColor;
  822. #ifdef USE_SPECULARINTENSITYMAP
  823. specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
  824. #endif
  825. #ifdef USE_SPECULARCOLORMAP
  826. specularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;
  827. #endif
  828. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  829. #else
  830. float specularIntensityFactor = 1.0;
  831. vec3 specularColorFactor = vec3( 1.0 );
  832. material.specularF90 = 1.0;
  833. #endif
  834. material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  835. #else
  836. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  837. material.specularF90 = 1.0;
  838. #endif
  839. #ifdef USE_CLEARCOAT
  840. material.clearcoat = clearcoat;
  841. material.clearcoatRoughness = clearcoatRoughness;
  842. material.clearcoatF0 = vec3( 0.04 );
  843. material.clearcoatF90 = 1.0;
  844. #ifdef USE_CLEARCOATMAP
  845. material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
  846. #endif
  847. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  848. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
  849. #endif
  850. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  851. material.clearcoatRoughness += geometryRoughness;
  852. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  853. #endif
  854. #ifdef USE_SHEEN
  855. material.sheenColor = sheenColor;
  856. #ifdef USE_SHEENCOLORMAP
  857. material.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;
  858. #endif
  859. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  860. #ifdef USE_SHEENROUGHNESSMAP
  861. material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
  862. #endif
  863. #endif`,qd=`struct PhysicalMaterial {
  864. vec3 diffuseColor;
  865. float roughness;
  866. vec3 specularColor;
  867. float specularF90;
  868. #ifdef USE_CLEARCOAT
  869. float clearcoat;
  870. float clearcoatRoughness;
  871. vec3 clearcoatF0;
  872. float clearcoatF90;
  873. #endif
  874. #ifdef USE_SHEEN
  875. vec3 sheenColor;
  876. float sheenRoughness;
  877. #endif
  878. };
  879. vec3 clearcoatSpecular = vec3( 0.0 );
  880. vec3 sheenSpecular = vec3( 0.0 );
  881. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {
  882. float dotNV = saturate( dot( normal, viewDir ) );
  883. float r2 = roughness * roughness;
  884. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  885. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  886. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  887. return saturate( DG * RECIPROCAL_PI );
  888. }
  889. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  890. float dotNV = saturate( dot( normal, viewDir ) );
  891. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  892. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  893. vec4 r = roughness * c0 + c1;
  894. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  895. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  896. return fab;
  897. }
  898. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  899. vec2 fab = DFGApprox( normal, viewDir, roughness );
  900. return specularColor * fab.x + specularF90 * fab.y;
  901. }
  902. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  903. vec2 fab = DFGApprox( normal, viewDir, roughness );
  904. vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;
  905. float Ess = fab.x + fab.y;
  906. float Ems = 1.0 - Ess;
  907. vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  908. singleScatter += FssEss;
  909. multiScatter += Fms * Ems;
  910. }
  911. #if NUM_RECT_AREA_LIGHTS > 0
  912. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  913. vec3 normal = geometry.normal;
  914. vec3 viewDir = geometry.viewDir;
  915. vec3 position = geometry.position;
  916. vec3 lightPos = rectAreaLight.position;
  917. vec3 halfWidth = rectAreaLight.halfWidth;
  918. vec3 halfHeight = rectAreaLight.halfHeight;
  919. vec3 lightColor = rectAreaLight.color;
  920. float roughness = material.roughness;
  921. vec3 rectCoords[ 4 ];
  922. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  923. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  924. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  925. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  926. vec4 t1 = texture2D( ltc_1, uv );
  927. vec4 t2 = texture2D( ltc_2, uv );
  928. mat3 mInv = mat3(
  929. vec3( t1.x, 0, t1.y ),
  930. vec3( 0, 1, 0 ),
  931. vec3( t1.z, 0, t1.w )
  932. );
  933. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  934. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  935. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  936. }
  937. #endif
  938. void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  939. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  940. vec3 irradiance = dotNL * directLight.color;
  941. #ifdef USE_CLEARCOAT
  942. float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
  943. vec3 ccIrradiance = dotNLcc * directLight.color;
  944. clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  945. #endif
  946. #ifdef USE_SHEEN
  947. sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
  948. #endif
  949. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
  950. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  951. }
  952. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  953. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  954. }
  955. 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) {
  956. #ifdef USE_CLEARCOAT
  957. clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  958. #endif
  959. #ifdef USE_SHEEN
  960. sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
  961. #endif
  962. vec3 singleScattering = vec3( 0.0 );
  963. vec3 multiScattering = vec3( 0.0 );
  964. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  965. computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  966. vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
  967. reflectedLight.indirectSpecular += radiance * singleScattering;
  968. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  969. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  970. }
  971. #define RE_Direct RE_Direct_Physical
  972. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  973. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  974. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  975. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  976. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  977. }`,jd=`
  978. GeometricContext geometry;
  979. geometry.position = - vViewPosition;
  980. geometry.normal = normal;
  981. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  982. #ifdef USE_CLEARCOAT
  983. geometry.clearcoatNormal = clearcoatNormal;
  984. #endif
  985. IncidentLight directLight;
  986. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  987. PointLight pointLight;
  988. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  989. PointLightShadow pointLightShadow;
  990. #endif
  991. #pragma unroll_loop_start
  992. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  993. pointLight = pointLights[ i ];
  994. getPointLightInfo( pointLight, geometry, directLight );
  995. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  996. pointLightShadow = pointLightShadows[ i ];
  997. directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  998. #endif
  999. RE_Direct( directLight, geometry, material, reflectedLight );
  1000. }
  1001. #pragma unroll_loop_end
  1002. #endif
  1003. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1004. SpotLight spotLight;
  1005. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1006. SpotLightShadow spotLightShadow;
  1007. #endif
  1008. #pragma unroll_loop_start
  1009. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1010. spotLight = spotLights[ i ];
  1011. getSpotLightInfo( spotLight, geometry, directLight );
  1012. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1013. spotLightShadow = spotLightShadows[ i ];
  1014. directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
  1015. #endif
  1016. RE_Direct( directLight, geometry, material, reflectedLight );
  1017. }
  1018. #pragma unroll_loop_end
  1019. #endif
  1020. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1021. DirectionalLight directionalLight;
  1022. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1023. DirectionalLightShadow directionalLightShadow;
  1024. #endif
  1025. #pragma unroll_loop_start
  1026. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1027. directionalLight = directionalLights[ i ];
  1028. getDirectionalLightInfo( directionalLight, geometry, directLight );
  1029. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1030. directionalLightShadow = directionalLightShadows[ i ];
  1031. directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1032. #endif
  1033. RE_Direct( directLight, geometry, material, reflectedLight );
  1034. }
  1035. #pragma unroll_loop_end
  1036. #endif
  1037. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1038. RectAreaLight rectAreaLight;
  1039. #pragma unroll_loop_start
  1040. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1041. rectAreaLight = rectAreaLights[ i ];
  1042. RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
  1043. }
  1044. #pragma unroll_loop_end
  1045. #endif
  1046. #if defined( RE_IndirectDiffuse )
  1047. vec3 iblIrradiance = vec3( 0.0 );
  1048. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1049. irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
  1050. #if ( NUM_HEMI_LIGHTS > 0 )
  1051. #pragma unroll_loop_start
  1052. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1053. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
  1054. }
  1055. #pragma unroll_loop_end
  1056. #endif
  1057. #endif
  1058. #if defined( RE_IndirectSpecular )
  1059. vec3 radiance = vec3( 0.0 );
  1060. vec3 clearcoatRadiance = vec3( 0.0 );
  1061. #endif`,Xd=`#if defined( RE_IndirectDiffuse )
  1062. #ifdef USE_LIGHTMAP
  1063. vec4 lightMapTexel = texture2D( lightMap, vUv2 );
  1064. vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  1065. #ifndef PHYSICALLY_CORRECT_LIGHTS
  1066. lightMapIrradiance *= PI;
  1067. #endif
  1068. irradiance += lightMapIrradiance;
  1069. #endif
  1070. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1071. iblIrradiance += getIBLIrradiance( geometry.normal );
  1072. #endif
  1073. #endif
  1074. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1075. radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
  1076. #ifdef USE_CLEARCOAT
  1077. clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
  1078. #endif
  1079. #endif`,Yd=`#if defined( RE_IndirectDiffuse )
  1080. RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
  1081. #endif
  1082. #if defined( RE_IndirectSpecular )
  1083. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
  1084. #endif`,Zd=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  1085. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1086. #endif`,Jd=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  1087. uniform float logDepthBufFC;
  1088. varying float vFragDepth;
  1089. varying float vIsPerspective;
  1090. #endif`,Kd=`#ifdef USE_LOGDEPTHBUF
  1091. #ifdef USE_LOGDEPTHBUF_EXT
  1092. varying float vFragDepth;
  1093. varying float vIsPerspective;
  1094. #else
  1095. uniform float logDepthBufFC;
  1096. #endif
  1097. #endif`,$d=`#ifdef USE_LOGDEPTHBUF
  1098. #ifdef USE_LOGDEPTHBUF_EXT
  1099. vFragDepth = 1.0 + gl_Position.w;
  1100. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1101. #else
  1102. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  1103. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  1104. gl_Position.z *= gl_Position.w;
  1105. }
  1106. #endif
  1107. #endif`,Qd=`#ifdef USE_MAP
  1108. vec4 texelColor = texture2D( map, vUv );
  1109. texelColor = mapTexelToLinear( texelColor );
  1110. diffuseColor *= texelColor;
  1111. #endif`,ef=`#ifdef USE_MAP
  1112. uniform sampler2D map;
  1113. #endif`,tf=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1114. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1115. #endif
  1116. #ifdef USE_MAP
  1117. vec4 mapTexel = texture2D( map, uv );
  1118. diffuseColor *= mapTexelToLinear( mapTexel );
  1119. #endif
  1120. #ifdef USE_ALPHAMAP
  1121. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1122. #endif`,nf=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1123. uniform mat3 uvTransform;
  1124. #endif
  1125. #ifdef USE_MAP
  1126. uniform sampler2D map;
  1127. #endif
  1128. #ifdef USE_ALPHAMAP
  1129. uniform sampler2D alphaMap;
  1130. #endif`,sf=`float metalnessFactor = metalness;
  1131. #ifdef USE_METALNESSMAP
  1132. vec4 texelMetalness = texture2D( metalnessMap, vUv );
  1133. metalnessFactor *= texelMetalness.b;
  1134. #endif`,rf=`#ifdef USE_METALNESSMAP
  1135. uniform sampler2D metalnessMap;
  1136. #endif`,of=`#ifdef USE_MORPHNORMALS
  1137. objectNormal *= morphTargetBaseInfluence;
  1138. #ifdef MORPHTARGETS_TEXTURE
  1139. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1140. if ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];
  1141. }
  1142. #else
  1143. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  1144. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  1145. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  1146. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  1147. #endif
  1148. #endif`,af=`#ifdef USE_MORPHTARGETS
  1149. uniform float morphTargetBaseInfluence;
  1150. #ifdef MORPHTARGETS_TEXTURE
  1151. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1152. uniform sampler2DArray morphTargetsTexture;
  1153. uniform vec2 morphTargetsTextureSize;
  1154. vec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {
  1155. float texelIndex = float( vertexIndex * stride + offset );
  1156. float y = floor( texelIndex / morphTargetsTextureSize.x );
  1157. float x = texelIndex - y * morphTargetsTextureSize.x;
  1158. vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );
  1159. return texture( morphTargetsTexture, morphUV ).xyz;
  1160. }
  1161. #else
  1162. #ifndef USE_MORPHNORMALS
  1163. uniform float morphTargetInfluences[ 8 ];
  1164. #else
  1165. uniform float morphTargetInfluences[ 4 ];
  1166. #endif
  1167. #endif
  1168. #endif`,lf=`#ifdef USE_MORPHTARGETS
  1169. transformed *= morphTargetBaseInfluence;
  1170. #ifdef MORPHTARGETS_TEXTURE
  1171. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1172. #ifndef USE_MORPHNORMALS
  1173. if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];
  1174. #else
  1175. if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];
  1176. #endif
  1177. }
  1178. #else
  1179. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  1180. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  1181. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  1182. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  1183. #ifndef USE_MORPHNORMALS
  1184. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  1185. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  1186. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  1187. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  1188. #endif
  1189. #endif
  1190. #endif`,cf=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1191. #ifdef FLAT_SHADED
  1192. vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
  1193. vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
  1194. vec3 normal = normalize( cross( fdx, fdy ) );
  1195. #else
  1196. vec3 normal = normalize( vNormal );
  1197. #ifdef DOUBLE_SIDED
  1198. normal = normal * faceDirection;
  1199. #endif
  1200. #ifdef USE_TANGENT
  1201. vec3 tangent = normalize( vTangent );
  1202. vec3 bitangent = normalize( vBitangent );
  1203. #ifdef DOUBLE_SIDED
  1204. tangent = tangent * faceDirection;
  1205. bitangent = bitangent * faceDirection;
  1206. #endif
  1207. #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
  1208. mat3 vTBN = mat3( tangent, bitangent, normal );
  1209. #endif
  1210. #endif
  1211. #endif
  1212. vec3 geometryNormal = normal;`,hf=`#ifdef OBJECTSPACE_NORMALMAP
  1213. normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  1214. #ifdef FLIP_SIDED
  1215. normal = - normal;
  1216. #endif
  1217. #ifdef DOUBLE_SIDED
  1218. normal = normal * faceDirection;
  1219. #endif
  1220. normal = normalize( normalMatrix * normal );
  1221. #elif defined( TANGENTSPACE_NORMALMAP )
  1222. vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  1223. mapN.xy *= normalScale;
  1224. #ifdef USE_TANGENT
  1225. normal = normalize( vTBN * mapN );
  1226. #else
  1227. normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
  1228. #endif
  1229. #elif defined( USE_BUMPMAP )
  1230. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1231. #endif`,uf=`#ifndef FLAT_SHADED
  1232. varying vec3 vNormal;
  1233. #ifdef USE_TANGENT
  1234. varying vec3 vTangent;
  1235. varying vec3 vBitangent;
  1236. #endif
  1237. #endif`,df=`#ifndef FLAT_SHADED
  1238. varying vec3 vNormal;
  1239. #ifdef USE_TANGENT
  1240. varying vec3 vTangent;
  1241. varying vec3 vBitangent;
  1242. #endif
  1243. #endif`,ff=`#ifndef FLAT_SHADED
  1244. vNormal = normalize( transformedNormal );
  1245. #ifdef USE_TANGENT
  1246. vTangent = normalize( transformedTangent );
  1247. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1248. #endif
  1249. #endif`,pf=`#ifdef USE_NORMALMAP
  1250. uniform sampler2D normalMap;
  1251. uniform vec2 normalScale;
  1252. #endif
  1253. #ifdef OBJECTSPACE_NORMALMAP
  1254. uniform mat3 normalMatrix;
  1255. #endif
  1256. #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
  1257. vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
  1258. vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
  1259. vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
  1260. vec2 st0 = dFdx( vUv.st );
  1261. vec2 st1 = dFdy( vUv.st );
  1262. vec3 N = surf_norm;
  1263. vec3 q1perp = cross( q1, N );
  1264. vec3 q0perp = cross( N, q0 );
  1265. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1266. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1267. float det = max( dot( T, T ), dot( B, B ) );
  1268. float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
  1269. return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
  1270. }
  1271. #endif`,mf=`#ifdef USE_CLEARCOAT
  1272. vec3 clearcoatNormal = geometryNormal;
  1273. #endif`,gf=`#ifdef USE_CLEARCOAT_NORMALMAP
  1274. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
  1275. clearcoatMapN.xy *= clearcoatNormalScale;
  1276. #ifdef USE_TANGENT
  1277. clearcoatNormal = normalize( vTBN * clearcoatMapN );
  1278. #else
  1279. clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
  1280. #endif
  1281. #endif`,xf=`#ifdef USE_CLEARCOATMAP
  1282. uniform sampler2D clearcoatMap;
  1283. #endif
  1284. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1285. uniform sampler2D clearcoatRoughnessMap;
  1286. #endif
  1287. #ifdef USE_CLEARCOAT_NORMALMAP
  1288. uniform sampler2D clearcoatNormalMap;
  1289. uniform vec2 clearcoatNormalScale;
  1290. #endif`,_f=`#ifdef OPAQUE
  1291. diffuseColor.a = 1.0;
  1292. #endif
  1293. #ifdef USE_TRANSMISSION
  1294. diffuseColor.a *= transmissionAlpha + 0.1;
  1295. #endif
  1296. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,yf=`vec3 packNormalToRGB( const in vec3 normal ) {
  1297. return normalize( normal ) * 0.5 + 0.5;
  1298. }
  1299. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1300. return 2.0 * rgb.xyz - 1.0;
  1301. }
  1302. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  1303. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  1304. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  1305. const float ShiftRight8 = 1. / 256.;
  1306. vec4 packDepthToRGBA( const in float v ) {
  1307. vec4 r = vec4( fract( v * PackFactors ), v );
  1308. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  1309. }
  1310. float unpackRGBAToDepth( const in vec4 v ) {
  1311. return dot( v, UnpackFactors );
  1312. }
  1313. vec4 pack2HalfToRGBA( vec2 v ) {
  1314. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1315. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1316. }
  1317. vec2 unpackRGBATo2Half( vec4 v ) {
  1318. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1319. }
  1320. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1321. return ( viewZ + near ) / ( near - far );
  1322. }
  1323. float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
  1324. return linearClipZ * ( near - far ) - near;
  1325. }
  1326. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1327. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1328. }
  1329. float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
  1330. return ( near * far ) / ( ( far - near ) * invClipZ - far );
  1331. }`,vf=`#ifdef PREMULTIPLIED_ALPHA
  1332. gl_FragColor.rgb *= gl_FragColor.a;
  1333. #endif`,Mf=`vec4 mvPosition = vec4( transformed, 1.0 );
  1334. #ifdef USE_INSTANCING
  1335. mvPosition = instanceMatrix * mvPosition;
  1336. #endif
  1337. mvPosition = modelViewMatrix * mvPosition;
  1338. gl_Position = projectionMatrix * mvPosition;`,bf=`#ifdef DITHERING
  1339. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1340. #endif`,wf=`#ifdef DITHERING
  1341. vec3 dithering( vec3 color ) {
  1342. float grid_position = rand( gl_FragCoord.xy );
  1343. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1344. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1345. return color + dither_shift_RGB;
  1346. }
  1347. #endif`,Sf=`float roughnessFactor = roughness;
  1348. #ifdef USE_ROUGHNESSMAP
  1349. vec4 texelRoughness = texture2D( roughnessMap, vUv );
  1350. roughnessFactor *= texelRoughness.g;
  1351. #endif`,Tf=`#ifdef USE_ROUGHNESSMAP
  1352. uniform sampler2D roughnessMap;
  1353. #endif`,Ef=`#ifdef USE_SHADOWMAP
  1354. #if NUM_DIR_LIGHT_SHADOWS > 0
  1355. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1356. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1357. struct DirectionalLightShadow {
  1358. float shadowBias;
  1359. float shadowNormalBias;
  1360. float shadowRadius;
  1361. vec2 shadowMapSize;
  1362. };
  1363. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1364. #endif
  1365. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1366. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1367. varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
  1368. struct SpotLightShadow {
  1369. float shadowBias;
  1370. float shadowNormalBias;
  1371. float shadowRadius;
  1372. vec2 shadowMapSize;
  1373. };
  1374. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1375. #endif
  1376. #if NUM_POINT_LIGHT_SHADOWS > 0
  1377. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1378. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1379. struct PointLightShadow {
  1380. float shadowBias;
  1381. float shadowNormalBias;
  1382. float shadowRadius;
  1383. vec2 shadowMapSize;
  1384. float shadowCameraNear;
  1385. float shadowCameraFar;
  1386. };
  1387. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1388. #endif
  1389. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1390. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  1391. }
  1392. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1393. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1394. }
  1395. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  1396. float occlusion = 1.0;
  1397. vec2 distribution = texture2DDistribution( shadow, uv );
  1398. float hard_shadow = step( compare , distribution.x );
  1399. if (hard_shadow != 1.0 ) {
  1400. float distance = compare - distribution.x ;
  1401. float variance = max( 0.00000, distribution.y * distribution.y );
  1402. 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 );
  1403. }
  1404. return occlusion;
  1405. }
  1406. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1407. float shadow = 1.0;
  1408. shadowCoord.xyz /= shadowCoord.w;
  1409. shadowCoord.z += shadowBias;
  1410. bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
  1411. bool inFrustum = all( inFrustumVec );
  1412. bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
  1413. bool frustumTest = all( frustumTestVec );
  1414. if ( frustumTest ) {
  1415. #if defined( SHADOWMAP_TYPE_PCF )
  1416. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1417. float dx0 = - texelSize.x * shadowRadius;
  1418. float dy0 = - texelSize.y * shadowRadius;
  1419. float dx1 = + texelSize.x * shadowRadius;
  1420. float dy1 = + texelSize.y * shadowRadius;
  1421. float dx2 = dx0 / 2.0;
  1422. float dy2 = dy0 / 2.0;
  1423. float dx3 = dx1 / 2.0;
  1424. float dy3 = dy1 / 2.0;
  1425. shadow = (
  1426. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1427. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1428. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1429. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1430. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1431. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1432. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1433. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1434. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1435. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1436. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1437. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1438. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1439. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1440. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1441. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1442. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1443. ) * ( 1.0 / 17.0 );
  1444. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1445. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1446. float dx = texelSize.x;
  1447. float dy = texelSize.y;
  1448. vec2 uv = shadowCoord.xy;
  1449. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1450. uv -= f * texelSize;
  1451. shadow = (
  1452. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1453. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1454. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1455. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1456. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1457. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1458. f.x ) +
  1459. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1460. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1461. f.x ) +
  1462. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1463. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1464. f.y ) +
  1465. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1466. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1467. f.y ) +
  1468. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1469. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1470. f.x ),
  1471. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1472. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1473. f.x ),
  1474. f.y )
  1475. ) * ( 1.0 / 9.0 );
  1476. #elif defined( SHADOWMAP_TYPE_VSM )
  1477. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1478. #else
  1479. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1480. #endif
  1481. }
  1482. return shadow;
  1483. }
  1484. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1485. vec3 absV = abs( v );
  1486. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1487. absV *= scaleToCube;
  1488. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1489. vec2 planar = v.xy;
  1490. float almostATexel = 1.5 * texelSizeY;
  1491. float almostOne = 1.0 - almostATexel;
  1492. if ( absV.z >= almostOne ) {
  1493. if ( v.z > 0.0 )
  1494. planar.x = 4.0 - v.x;
  1495. } else if ( absV.x >= almostOne ) {
  1496. float signX = sign( v.x );
  1497. planar.x = v.z * signX + 2.0 * signX;
  1498. } else if ( absV.y >= almostOne ) {
  1499. float signY = sign( v.y );
  1500. planar.x = v.x + 2.0 * signY + 2.0;
  1501. planar.y = v.z * signY - 2.0;
  1502. }
  1503. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1504. }
  1505. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1506. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1507. vec3 lightToPosition = shadowCoord.xyz;
  1508. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1509. vec3 bd3D = normalize( lightToPosition );
  1510. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1511. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1512. return (
  1513. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1514. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1515. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1516. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1517. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1518. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1519. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1520. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1521. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1522. ) * ( 1.0 / 9.0 );
  1523. #else
  1524. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1525. #endif
  1526. }
  1527. #endif`,Af=`#ifdef USE_SHADOWMAP
  1528. #if NUM_DIR_LIGHT_SHADOWS > 0
  1529. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1530. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1531. struct DirectionalLightShadow {
  1532. float shadowBias;
  1533. float shadowNormalBias;
  1534. float shadowRadius;
  1535. vec2 shadowMapSize;
  1536. };
  1537. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1538. #endif
  1539. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1540. uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
  1541. varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
  1542. struct SpotLightShadow {
  1543. float shadowBias;
  1544. float shadowNormalBias;
  1545. float shadowRadius;
  1546. vec2 shadowMapSize;
  1547. };
  1548. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1549. #endif
  1550. #if NUM_POINT_LIGHT_SHADOWS > 0
  1551. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1552. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1553. struct PointLightShadow {
  1554. float shadowBias;
  1555. float shadowNormalBias;
  1556. float shadowRadius;
  1557. vec2 shadowMapSize;
  1558. float shadowCameraNear;
  1559. float shadowCameraFar;
  1560. };
  1561. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1562. #endif
  1563. #endif`,Lf=`#ifdef USE_SHADOWMAP
  1564. #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
  1565. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1566. vec4 shadowWorldPosition;
  1567. #endif
  1568. #if NUM_DIR_LIGHT_SHADOWS > 0
  1569. #pragma unroll_loop_start
  1570. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1571. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1572. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1573. }
  1574. #pragma unroll_loop_end
  1575. #endif
  1576. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1577. #pragma unroll_loop_start
  1578. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1579. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
  1580. vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
  1581. }
  1582. #pragma unroll_loop_end
  1583. #endif
  1584. #if NUM_POINT_LIGHT_SHADOWS > 0
  1585. #pragma unroll_loop_start
  1586. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1587. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1588. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1589. }
  1590. #pragma unroll_loop_end
  1591. #endif
  1592. #endif`,Rf=`float getShadowMask() {
  1593. float shadow = 1.0;
  1594. #ifdef USE_SHADOWMAP
  1595. #if NUM_DIR_LIGHT_SHADOWS > 0
  1596. DirectionalLightShadow directionalLight;
  1597. #pragma unroll_loop_start
  1598. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1599. directionalLight = directionalLightShadows[ i ];
  1600. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1601. }
  1602. #pragma unroll_loop_end
  1603. #endif
  1604. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1605. SpotLightShadow spotLight;
  1606. #pragma unroll_loop_start
  1607. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1608. spotLight = spotLightShadows[ i ];
  1609. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
  1610. }
  1611. #pragma unroll_loop_end
  1612. #endif
  1613. #if NUM_POINT_LIGHT_SHADOWS > 0
  1614. PointLightShadow pointLight;
  1615. #pragma unroll_loop_start
  1616. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1617. pointLight = pointLightShadows[ i ];
  1618. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1619. }
  1620. #pragma unroll_loop_end
  1621. #endif
  1622. #endif
  1623. return shadow;
  1624. }`,Cf=`#ifdef USE_SKINNING
  1625. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1626. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1627. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1628. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1629. #endif`,Pf=`#ifdef USE_SKINNING
  1630. uniform mat4 bindMatrix;
  1631. uniform mat4 bindMatrixInverse;
  1632. #ifdef BONE_TEXTURE
  1633. uniform highp sampler2D boneTexture;
  1634. uniform int boneTextureSize;
  1635. mat4 getBoneMatrix( const in float i ) {
  1636. float j = i * 4.0;
  1637. float x = mod( j, float( boneTextureSize ) );
  1638. float y = floor( j / float( boneTextureSize ) );
  1639. float dx = 1.0 / float( boneTextureSize );
  1640. float dy = 1.0 / float( boneTextureSize );
  1641. y = dy * ( y + 0.5 );
  1642. vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
  1643. vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
  1644. vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
  1645. vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
  1646. mat4 bone = mat4( v1, v2, v3, v4 );
  1647. return bone;
  1648. }
  1649. #else
  1650. uniform mat4 boneMatrices[ MAX_BONES ];
  1651. mat4 getBoneMatrix( const in float i ) {
  1652. mat4 bone = boneMatrices[ int(i) ];
  1653. return bone;
  1654. }
  1655. #endif
  1656. #endif`,If=`#ifdef USE_SKINNING
  1657. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  1658. vec4 skinned = vec4( 0.0 );
  1659. skinned += boneMatX * skinVertex * skinWeight.x;
  1660. skinned += boneMatY * skinVertex * skinWeight.y;
  1661. skinned += boneMatZ * skinVertex * skinWeight.z;
  1662. skinned += boneMatW * skinVertex * skinWeight.w;
  1663. transformed = ( bindMatrixInverse * skinned ).xyz;
  1664. #endif`,Df=`#ifdef USE_SKINNING
  1665. mat4 skinMatrix = mat4( 0.0 );
  1666. skinMatrix += skinWeight.x * boneMatX;
  1667. skinMatrix += skinWeight.y * boneMatY;
  1668. skinMatrix += skinWeight.z * boneMatZ;
  1669. skinMatrix += skinWeight.w * boneMatW;
  1670. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  1671. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  1672. #ifdef USE_TANGENT
  1673. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  1674. #endif
  1675. #endif`,Nf=`float specularStrength;
  1676. #ifdef USE_SPECULARMAP
  1677. vec4 texelSpecular = texture2D( specularMap, vUv );
  1678. specularStrength = texelSpecular.r;
  1679. #else
  1680. specularStrength = 1.0;
  1681. #endif`,Ff=`#ifdef USE_SPECULARMAP
  1682. uniform sampler2D specularMap;
  1683. #endif`,Of=`#if defined( TONE_MAPPING )
  1684. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  1685. #endif`,Bf=`#ifndef saturate
  1686. #define saturate( a ) clamp( a, 0.0, 1.0 )
  1687. #endif
  1688. uniform float toneMappingExposure;
  1689. vec3 LinearToneMapping( vec3 color ) {
  1690. return toneMappingExposure * color;
  1691. }
  1692. vec3 ReinhardToneMapping( vec3 color ) {
  1693. color *= toneMappingExposure;
  1694. return saturate( color / ( vec3( 1.0 ) + color ) );
  1695. }
  1696. vec3 OptimizedCineonToneMapping( vec3 color ) {
  1697. color *= toneMappingExposure;
  1698. color = max( vec3( 0.0 ), color - 0.004 );
  1699. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  1700. }
  1701. vec3 RRTAndODTFit( vec3 v ) {
  1702. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  1703. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  1704. return a / b;
  1705. }
  1706. vec3 ACESFilmicToneMapping( vec3 color ) {
  1707. const mat3 ACESInputMat = mat3(
  1708. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  1709. vec3( 0.04823, 0.01566, 0.83777 )
  1710. );
  1711. const mat3 ACESOutputMat = mat3(
  1712. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  1713. vec3( -0.07367, -0.00605, 1.07602 )
  1714. );
  1715. color *= toneMappingExposure / 0.6;
  1716. color = ACESInputMat * color;
  1717. color = RRTAndODTFit( color );
  1718. color = ACESOutputMat * color;
  1719. return saturate( color );
  1720. }
  1721. vec3 CustomToneMapping( vec3 color ) { return color; }`,Uf=`#ifdef USE_TRANSMISSION
  1722. float transmissionAlpha = 1.0;
  1723. float transmissionFactor = transmission;
  1724. float thicknessFactor = thickness;
  1725. #ifdef USE_TRANSMISSIONMAP
  1726. transmissionFactor *= texture2D( transmissionMap, vUv ).r;
  1727. #endif
  1728. #ifdef USE_THICKNESSMAP
  1729. thicknessFactor *= texture2D( thicknessMap, vUv ).g;
  1730. #endif
  1731. vec3 pos = vWorldPosition;
  1732. vec3 v = normalize( cameraPosition - pos );
  1733. vec3 n = inverseTransformDirection( normal, viewMatrix );
  1734. vec4 transmission = getIBLVolumeRefraction(
  1735. n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,
  1736. pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,
  1737. attenuationColor, attenuationDistance );
  1738. totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );
  1739. transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );
  1740. #endif`,zf=`#ifdef USE_TRANSMISSION
  1741. uniform float transmission;
  1742. uniform float thickness;
  1743. uniform float attenuationDistance;
  1744. uniform vec3 attenuationColor;
  1745. #ifdef USE_TRANSMISSIONMAP
  1746. uniform sampler2D transmissionMap;
  1747. #endif
  1748. #ifdef USE_THICKNESSMAP
  1749. uniform sampler2D thicknessMap;
  1750. #endif
  1751. uniform vec2 transmissionSamplerSize;
  1752. uniform sampler2D transmissionSamplerMap;
  1753. uniform mat4 modelMatrix;
  1754. uniform mat4 projectionMatrix;
  1755. varying vec3 vWorldPosition;
  1756. vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
  1757. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  1758. vec3 modelScale;
  1759. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  1760. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  1761. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  1762. return normalize( refractionVector ) * thickness * modelScale;
  1763. }
  1764. float applyIorToRoughness( float roughness, float ior ) {
  1765. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  1766. }
  1767. vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {
  1768. float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  1769. #ifdef TEXTURE_LOD_EXT
  1770. return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
  1771. #else
  1772. return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
  1773. #endif
  1774. }
  1775. vec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {
  1776. if ( attenuationDistance == 0.0 ) {
  1777. return radiance;
  1778. } else {
  1779. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  1780. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance;
  1781. }
  1782. }
  1783. vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,
  1784. vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,
  1785. vec3 attenuationColor, float attenuationDistance ) {
  1786. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  1787. vec3 refractedRayExit = position + transmissionRay;
  1788. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  1789. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  1790. refractionCoords += 1.0;
  1791. refractionCoords /= 2.0;
  1792. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  1793. vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
  1794. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  1795. return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
  1796. }
  1797. #endif`,Hf=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
  1798. varying vec2 vUv;
  1799. #endif`,kf=`#ifdef USE_UV
  1800. #ifdef UVS_VERTEX_ONLY
  1801. vec2 vUv;
  1802. #else
  1803. varying vec2 vUv;
  1804. #endif
  1805. uniform mat3 uvTransform;
  1806. #endif`,Gf=`#ifdef USE_UV
  1807. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  1808. #endif`,Vf=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1809. varying vec2 vUv2;
  1810. #endif`,Wf=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1811. attribute vec2 uv2;
  1812. varying vec2 vUv2;
  1813. uniform mat3 uv2Transform;
  1814. #endif`,qf=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1815. vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
  1816. #endif`,jf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )
  1817. vec4 worldPosition = vec4( transformed, 1.0 );
  1818. #ifdef USE_INSTANCING
  1819. worldPosition = instanceMatrix * worldPosition;
  1820. #endif
  1821. worldPosition = modelMatrix * worldPosition;
  1822. #endif`;const Xf=`varying vec2 vUv;
  1823. uniform mat3 uvTransform;
  1824. void main() {
  1825. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  1826. gl_Position = vec4( position.xy, 1.0, 1.0 );
  1827. }`,Yf=`uniform sampler2D t2D;
  1828. varying vec2 vUv;
  1829. void main() {
  1830. vec4 texColor = texture2D( t2D, vUv );
  1831. gl_FragColor = mapTexelToLinear( texColor );
  1832. #include <tonemapping_fragment>
  1833. #include <encodings_fragment>
  1834. }`,Zf=`varying vec3 vWorldDirection;
  1835. #include <common>
  1836. void main() {
  1837. vWorldDirection = transformDirection( position, modelMatrix );
  1838. #include <begin_vertex>
  1839. #include <project_vertex>
  1840. gl_Position.z = gl_Position.w;
  1841. }`,Jf=`#include <envmap_common_pars_fragment>
  1842. uniform float opacity;
  1843. varying vec3 vWorldDirection;
  1844. #include <cube_uv_reflection_fragment>
  1845. void main() {
  1846. vec3 vReflect = vWorldDirection;
  1847. #include <envmap_fragment>
  1848. gl_FragColor = envColor;
  1849. gl_FragColor.a *= opacity;
  1850. #include <tonemapping_fragment>
  1851. #include <encodings_fragment>
  1852. }`,Kf=`#include <common>
  1853. #include <uv_pars_vertex>
  1854. #include <displacementmap_pars_vertex>
  1855. #include <morphtarget_pars_vertex>
  1856. #include <skinning_pars_vertex>
  1857. #include <logdepthbuf_pars_vertex>
  1858. #include <clipping_planes_pars_vertex>
  1859. varying vec2 vHighPrecisionZW;
  1860. void main() {
  1861. #include <uv_vertex>
  1862. #include <skinbase_vertex>
  1863. #ifdef USE_DISPLACEMENTMAP
  1864. #include <beginnormal_vertex>
  1865. #include <morphnormal_vertex>
  1866. #include <skinnormal_vertex>
  1867. #endif
  1868. #include <begin_vertex>
  1869. #include <morphtarget_vertex>
  1870. #include <skinning_vertex>
  1871. #include <displacementmap_vertex>
  1872. #include <project_vertex>
  1873. #include <logdepthbuf_vertex>
  1874. #include <clipping_planes_vertex>
  1875. vHighPrecisionZW = gl_Position.zw;
  1876. }`,$f=`#if DEPTH_PACKING == 3200
  1877. uniform float opacity;
  1878. #endif
  1879. #include <common>
  1880. #include <packing>
  1881. #include <uv_pars_fragment>
  1882. #include <map_pars_fragment>
  1883. #include <alphamap_pars_fragment>
  1884. #include <alphatest_pars_fragment>
  1885. #include <logdepthbuf_pars_fragment>
  1886. #include <clipping_planes_pars_fragment>
  1887. varying vec2 vHighPrecisionZW;
  1888. void main() {
  1889. #include <clipping_planes_fragment>
  1890. vec4 diffuseColor = vec4( 1.0 );
  1891. #if DEPTH_PACKING == 3200
  1892. diffuseColor.a = opacity;
  1893. #endif
  1894. #include <map_fragment>
  1895. #include <alphamap_fragment>
  1896. #include <alphatest_fragment>
  1897. #include <logdepthbuf_fragment>
  1898. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  1899. #if DEPTH_PACKING == 3200
  1900. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  1901. #elif DEPTH_PACKING == 3201
  1902. gl_FragColor = packDepthToRGBA( fragCoordZ );
  1903. #endif
  1904. }`,Qf=`#define DISTANCE
  1905. varying vec3 vWorldPosition;
  1906. #include <common>
  1907. #include <uv_pars_vertex>
  1908. #include <displacementmap_pars_vertex>
  1909. #include <morphtarget_pars_vertex>
  1910. #include <skinning_pars_vertex>
  1911. #include <clipping_planes_pars_vertex>
  1912. void main() {
  1913. #include <uv_vertex>
  1914. #include <skinbase_vertex>
  1915. #ifdef USE_DISPLACEMENTMAP
  1916. #include <beginnormal_vertex>
  1917. #include <morphnormal_vertex>
  1918. #include <skinnormal_vertex>
  1919. #endif
  1920. #include <begin_vertex>
  1921. #include <morphtarget_vertex>
  1922. #include <skinning_vertex>
  1923. #include <displacementmap_vertex>
  1924. #include <project_vertex>
  1925. #include <worldpos_vertex>
  1926. #include <clipping_planes_vertex>
  1927. vWorldPosition = worldPosition.xyz;
  1928. }`,ep=`#define DISTANCE
  1929. uniform vec3 referencePosition;
  1930. uniform float nearDistance;
  1931. uniform float farDistance;
  1932. varying vec3 vWorldPosition;
  1933. #include <common>
  1934. #include <packing>
  1935. #include <uv_pars_fragment>
  1936. #include <map_pars_fragment>
  1937. #include <alphamap_pars_fragment>
  1938. #include <alphatest_pars_fragment>
  1939. #include <clipping_planes_pars_fragment>
  1940. void main () {
  1941. #include <clipping_planes_fragment>
  1942. vec4 diffuseColor = vec4( 1.0 );
  1943. #include <map_fragment>
  1944. #include <alphamap_fragment>
  1945. #include <alphatest_fragment>
  1946. float dist = length( vWorldPosition - referencePosition );
  1947. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  1948. dist = saturate( dist );
  1949. gl_FragColor = packDepthToRGBA( dist );
  1950. }`,tp=`varying vec3 vWorldDirection;
  1951. #include <common>
  1952. void main() {
  1953. vWorldDirection = transformDirection( position, modelMatrix );
  1954. #include <begin_vertex>
  1955. #include <project_vertex>
  1956. }`,np=`uniform sampler2D tEquirect;
  1957. varying vec3 vWorldDirection;
  1958. #include <common>
  1959. void main() {
  1960. vec3 direction = normalize( vWorldDirection );
  1961. vec2 sampleUV = equirectUv( direction );
  1962. vec4 texColor = texture2D( tEquirect, sampleUV );
  1963. gl_FragColor = mapTexelToLinear( texColor );
  1964. #include <tonemapping_fragment>
  1965. #include <encodings_fragment>
  1966. }`,ip=`uniform float scale;
  1967. attribute float lineDistance;
  1968. varying float vLineDistance;
  1969. #include <common>
  1970. #include <color_pars_vertex>
  1971. #include <fog_pars_vertex>
  1972. #include <morphtarget_pars_vertex>
  1973. #include <logdepthbuf_pars_vertex>
  1974. #include <clipping_planes_pars_vertex>
  1975. void main() {
  1976. vLineDistance = scale * lineDistance;
  1977. #include <color_vertex>
  1978. #include <begin_vertex>
  1979. #include <morphtarget_vertex>
  1980. #include <project_vertex>
  1981. #include <logdepthbuf_vertex>
  1982. #include <clipping_planes_vertex>
  1983. #include <fog_vertex>
  1984. }`,sp=`uniform vec3 diffuse;
  1985. uniform float opacity;
  1986. uniform float dashSize;
  1987. uniform float totalSize;
  1988. varying float vLineDistance;
  1989. #include <common>
  1990. #include <color_pars_fragment>
  1991. #include <fog_pars_fragment>
  1992. #include <logdepthbuf_pars_fragment>
  1993. #include <clipping_planes_pars_fragment>
  1994. void main() {
  1995. #include <clipping_planes_fragment>
  1996. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  1997. discard;
  1998. }
  1999. vec3 outgoingLight = vec3( 0.0 );
  2000. vec4 diffuseColor = vec4( diffuse, opacity );
  2001. #include <logdepthbuf_fragment>
  2002. #include <color_fragment>
  2003. outgoingLight = diffuseColor.rgb;
  2004. #include <output_fragment>
  2005. #include <tonemapping_fragment>
  2006. #include <encodings_fragment>
  2007. #include <fog_fragment>
  2008. #include <premultiplied_alpha_fragment>
  2009. }`,rp=`#include <common>
  2010. #include <uv_pars_vertex>
  2011. #include <uv2_pars_vertex>
  2012. #include <envmap_pars_vertex>
  2013. #include <color_pars_vertex>
  2014. #include <fog_pars_vertex>
  2015. #include <morphtarget_pars_vertex>
  2016. #include <skinning_pars_vertex>
  2017. #include <logdepthbuf_pars_vertex>
  2018. #include <clipping_planes_pars_vertex>
  2019. void main() {
  2020. #include <uv_vertex>
  2021. #include <uv2_vertex>
  2022. #include <color_vertex>
  2023. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2024. #include <beginnormal_vertex>
  2025. #include <morphnormal_vertex>
  2026. #include <skinbase_vertex>
  2027. #include <skinnormal_vertex>
  2028. #include <defaultnormal_vertex>
  2029. #endif
  2030. #include <begin_vertex>
  2031. #include <morphtarget_vertex>
  2032. #include <skinning_vertex>
  2033. #include <project_vertex>
  2034. #include <logdepthbuf_vertex>
  2035. #include <clipping_planes_vertex>
  2036. #include <worldpos_vertex>
  2037. #include <envmap_vertex>
  2038. #include <fog_vertex>
  2039. }`,op=`uniform vec3 diffuse;
  2040. uniform float opacity;
  2041. #ifndef FLAT_SHADED
  2042. varying vec3 vNormal;
  2043. #endif
  2044. #include <common>
  2045. #include <dithering_pars_fragment>
  2046. #include <color_pars_fragment>
  2047. #include <uv_pars_fragment>
  2048. #include <uv2_pars_fragment>
  2049. #include <map_pars_fragment>
  2050. #include <alphamap_pars_fragment>
  2051. #include <alphatest_pars_fragment>
  2052. #include <aomap_pars_fragment>
  2053. #include <lightmap_pars_fragment>
  2054. #include <envmap_common_pars_fragment>
  2055. #include <envmap_pars_fragment>
  2056. #include <cube_uv_reflection_fragment>
  2057. #include <fog_pars_fragment>
  2058. #include <specularmap_pars_fragment>
  2059. #include <logdepthbuf_pars_fragment>
  2060. #include <clipping_planes_pars_fragment>
  2061. void main() {
  2062. #include <clipping_planes_fragment>
  2063. vec4 diffuseColor = vec4( diffuse, opacity );
  2064. #include <logdepthbuf_fragment>
  2065. #include <map_fragment>
  2066. #include <color_fragment>
  2067. #include <alphamap_fragment>
  2068. #include <alphatest_fragment>
  2069. #include <specularmap_fragment>
  2070. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2071. #ifdef USE_LIGHTMAP
  2072. vec4 lightMapTexel= texture2D( lightMap, vUv2 );
  2073. reflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;
  2074. #else
  2075. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2076. #endif
  2077. #include <aomap_fragment>
  2078. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2079. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2080. #include <envmap_fragment>
  2081. #include <output_fragment>
  2082. #include <tonemapping_fragment>
  2083. #include <encodings_fragment>
  2084. #include <fog_fragment>
  2085. #include <premultiplied_alpha_fragment>
  2086. #include <dithering_fragment>
  2087. }`,ap=`#define LAMBERT
  2088. varying vec3 vLightFront;
  2089. varying vec3 vIndirectFront;
  2090. #ifdef DOUBLE_SIDED
  2091. varying vec3 vLightBack;
  2092. varying vec3 vIndirectBack;
  2093. #endif
  2094. #include <common>
  2095. #include <uv_pars_vertex>
  2096. #include <uv2_pars_vertex>
  2097. #include <envmap_pars_vertex>
  2098. #include <bsdfs>
  2099. #include <lights_pars_begin>
  2100. #include <color_pars_vertex>
  2101. #include <fog_pars_vertex>
  2102. #include <morphtarget_pars_vertex>
  2103. #include <skinning_pars_vertex>
  2104. #include <shadowmap_pars_vertex>
  2105. #include <logdepthbuf_pars_vertex>
  2106. #include <clipping_planes_pars_vertex>
  2107. void main() {
  2108. #include <uv_vertex>
  2109. #include <uv2_vertex>
  2110. #include <color_vertex>
  2111. #include <beginnormal_vertex>
  2112. #include <morphnormal_vertex>
  2113. #include <skinbase_vertex>
  2114. #include <skinnormal_vertex>
  2115. #include <defaultnormal_vertex>
  2116. #include <begin_vertex>
  2117. #include <morphtarget_vertex>
  2118. #include <skinning_vertex>
  2119. #include <project_vertex>
  2120. #include <logdepthbuf_vertex>
  2121. #include <clipping_planes_vertex>
  2122. #include <worldpos_vertex>
  2123. #include <envmap_vertex>
  2124. #include <lights_lambert_vertex>
  2125. #include <shadowmap_vertex>
  2126. #include <fog_vertex>
  2127. }`,lp=`uniform vec3 diffuse;
  2128. uniform vec3 emissive;
  2129. uniform float opacity;
  2130. varying vec3 vLightFront;
  2131. varying vec3 vIndirectFront;
  2132. #ifdef DOUBLE_SIDED
  2133. varying vec3 vLightBack;
  2134. varying vec3 vIndirectBack;
  2135. #endif
  2136. #include <common>
  2137. #include <packing>
  2138. #include <dithering_pars_fragment>
  2139. #include <color_pars_fragment>
  2140. #include <uv_pars_fragment>
  2141. #include <uv2_pars_fragment>
  2142. #include <map_pars_fragment>
  2143. #include <alphamap_pars_fragment>
  2144. #include <alphatest_pars_fragment>
  2145. #include <aomap_pars_fragment>
  2146. #include <lightmap_pars_fragment>
  2147. #include <emissivemap_pars_fragment>
  2148. #include <envmap_common_pars_fragment>
  2149. #include <envmap_pars_fragment>
  2150. #include <cube_uv_reflection_fragment>
  2151. #include <bsdfs>
  2152. #include <lights_pars_begin>
  2153. #include <fog_pars_fragment>
  2154. #include <shadowmap_pars_fragment>
  2155. #include <shadowmask_pars_fragment>
  2156. #include <specularmap_pars_fragment>
  2157. #include <logdepthbuf_pars_fragment>
  2158. #include <clipping_planes_pars_fragment>
  2159. void main() {
  2160. #include <clipping_planes_fragment>
  2161. vec4 diffuseColor = vec4( diffuse, opacity );
  2162. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2163. vec3 totalEmissiveRadiance = emissive;
  2164. #include <logdepthbuf_fragment>
  2165. #include <map_fragment>
  2166. #include <color_fragment>
  2167. #include <alphamap_fragment>
  2168. #include <alphatest_fragment>
  2169. #include <specularmap_fragment>
  2170. #include <emissivemap_fragment>
  2171. #ifdef DOUBLE_SIDED
  2172. reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
  2173. #else
  2174. reflectedLight.indirectDiffuse += vIndirectFront;
  2175. #endif
  2176. #include <lightmap_fragment>
  2177. reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );
  2178. #ifdef DOUBLE_SIDED
  2179. reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
  2180. #else
  2181. reflectedLight.directDiffuse = vLightFront;
  2182. #endif
  2183. reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();
  2184. #include <aomap_fragment>
  2185. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2186. #include <envmap_fragment>
  2187. #include <output_fragment>
  2188. #include <tonemapping_fragment>
  2189. #include <encodings_fragment>
  2190. #include <fog_fragment>
  2191. #include <premultiplied_alpha_fragment>
  2192. #include <dithering_fragment>
  2193. }`,cp=`#define MATCAP
  2194. varying vec3 vViewPosition;
  2195. #include <common>
  2196. #include <uv_pars_vertex>
  2197. #include <color_pars_vertex>
  2198. #include <displacementmap_pars_vertex>
  2199. #include <fog_pars_vertex>
  2200. #include <normal_pars_vertex>
  2201. #include <morphtarget_pars_vertex>
  2202. #include <skinning_pars_vertex>
  2203. #include <logdepthbuf_pars_vertex>
  2204. #include <clipping_planes_pars_vertex>
  2205. void main() {
  2206. #include <uv_vertex>
  2207. #include <color_vertex>
  2208. #include <beginnormal_vertex>
  2209. #include <morphnormal_vertex>
  2210. #include <skinbase_vertex>
  2211. #include <skinnormal_vertex>
  2212. #include <defaultnormal_vertex>
  2213. #include <normal_vertex>
  2214. #include <begin_vertex>
  2215. #include <morphtarget_vertex>
  2216. #include <skinning_vertex>
  2217. #include <displacementmap_vertex>
  2218. #include <project_vertex>
  2219. #include <logdepthbuf_vertex>
  2220. #include <clipping_planes_vertex>
  2221. #include <fog_vertex>
  2222. vViewPosition = - mvPosition.xyz;
  2223. }`,hp=`#define MATCAP
  2224. uniform vec3 diffuse;
  2225. uniform float opacity;
  2226. uniform sampler2D matcap;
  2227. varying vec3 vViewPosition;
  2228. #include <common>
  2229. #include <dithering_pars_fragment>
  2230. #include <color_pars_fragment>
  2231. #include <uv_pars_fragment>
  2232. #include <map_pars_fragment>
  2233. #include <alphamap_pars_fragment>
  2234. #include <alphatest_pars_fragment>
  2235. #include <fog_pars_fragment>
  2236. #include <normal_pars_fragment>
  2237. #include <bumpmap_pars_fragment>
  2238. #include <normalmap_pars_fragment>
  2239. #include <logdepthbuf_pars_fragment>
  2240. #include <clipping_planes_pars_fragment>
  2241. void main() {
  2242. #include <clipping_planes_fragment>
  2243. vec4 diffuseColor = vec4( diffuse, opacity );
  2244. #include <logdepthbuf_fragment>
  2245. #include <map_fragment>
  2246. #include <color_fragment>
  2247. #include <alphamap_fragment>
  2248. #include <alphatest_fragment>
  2249. #include <normal_fragment_begin>
  2250. #include <normal_fragment_maps>
  2251. vec3 viewDir = normalize( vViewPosition );
  2252. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  2253. vec3 y = cross( viewDir, x );
  2254. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  2255. #ifdef USE_MATCAP
  2256. vec4 matcapColor = texture2D( matcap, uv );
  2257. matcapColor = matcapTexelToLinear( matcapColor );
  2258. #else
  2259. vec4 matcapColor = vec4( 1.0 );
  2260. #endif
  2261. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  2262. #include <output_fragment>
  2263. #include <tonemapping_fragment>
  2264. #include <encodings_fragment>
  2265. #include <fog_fragment>
  2266. #include <premultiplied_alpha_fragment>
  2267. #include <dithering_fragment>
  2268. }`,up=`#define NORMAL
  2269. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2270. varying vec3 vViewPosition;
  2271. #endif
  2272. #include <common>
  2273. #include <uv_pars_vertex>
  2274. #include <displacementmap_pars_vertex>
  2275. #include <normal_pars_vertex>
  2276. #include <morphtarget_pars_vertex>
  2277. #include <skinning_pars_vertex>
  2278. #include <logdepthbuf_pars_vertex>
  2279. #include <clipping_planes_pars_vertex>
  2280. void main() {
  2281. #include <uv_vertex>
  2282. #include <beginnormal_vertex>
  2283. #include <morphnormal_vertex>
  2284. #include <skinbase_vertex>
  2285. #include <skinnormal_vertex>
  2286. #include <defaultnormal_vertex>
  2287. #include <normal_vertex>
  2288. #include <begin_vertex>
  2289. #include <morphtarget_vertex>
  2290. #include <skinning_vertex>
  2291. #include <displacementmap_vertex>
  2292. #include <project_vertex>
  2293. #include <logdepthbuf_vertex>
  2294. #include <clipping_planes_vertex>
  2295. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2296. vViewPosition = - mvPosition.xyz;
  2297. #endif
  2298. }`,dp=`#define NORMAL
  2299. uniform float opacity;
  2300. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2301. varying vec3 vViewPosition;
  2302. #endif
  2303. #include <packing>
  2304. #include <uv_pars_fragment>
  2305. #include <normal_pars_fragment>
  2306. #include <bumpmap_pars_fragment>
  2307. #include <normalmap_pars_fragment>
  2308. #include <logdepthbuf_pars_fragment>
  2309. #include <clipping_planes_pars_fragment>
  2310. void main() {
  2311. #include <clipping_planes_fragment>
  2312. #include <logdepthbuf_fragment>
  2313. #include <normal_fragment_begin>
  2314. #include <normal_fragment_maps>
  2315. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  2316. }`,fp=`#define PHONG
  2317. varying vec3 vViewPosition;
  2318. #include <common>
  2319. #include <uv_pars_vertex>
  2320. #include <uv2_pars_vertex>
  2321. #include <displacementmap_pars_vertex>
  2322. #include <envmap_pars_vertex>
  2323. #include <color_pars_vertex>
  2324. #include <fog_pars_vertex>
  2325. #include <normal_pars_vertex>
  2326. #include <morphtarget_pars_vertex>
  2327. #include <skinning_pars_vertex>
  2328. #include <shadowmap_pars_vertex>
  2329. #include <logdepthbuf_pars_vertex>
  2330. #include <clipping_planes_pars_vertex>
  2331. void main() {
  2332. #include <uv_vertex>
  2333. #include <uv2_vertex>
  2334. #include <color_vertex>
  2335. #include <beginnormal_vertex>
  2336. #include <morphnormal_vertex>
  2337. #include <skinbase_vertex>
  2338. #include <skinnormal_vertex>
  2339. #include <defaultnormal_vertex>
  2340. #include <normal_vertex>
  2341. #include <begin_vertex>
  2342. #include <morphtarget_vertex>
  2343. #include <skinning_vertex>
  2344. #include <displacementmap_vertex>
  2345. #include <project_vertex>
  2346. #include <logdepthbuf_vertex>
  2347. #include <clipping_planes_vertex>
  2348. vViewPosition = - mvPosition.xyz;
  2349. #include <worldpos_vertex>
  2350. #include <envmap_vertex>
  2351. #include <shadowmap_vertex>
  2352. #include <fog_vertex>
  2353. }`,pp=`#define PHONG
  2354. uniform vec3 diffuse;
  2355. uniform vec3 emissive;
  2356. uniform vec3 specular;
  2357. uniform float shininess;
  2358. uniform float opacity;
  2359. #include <common>
  2360. #include <packing>
  2361. #include <dithering_pars_fragment>
  2362. #include <color_pars_fragment>
  2363. #include <uv_pars_fragment>
  2364. #include <uv2_pars_fragment>
  2365. #include <map_pars_fragment>
  2366. #include <alphamap_pars_fragment>
  2367. #include <alphatest_pars_fragment>
  2368. #include <aomap_pars_fragment>
  2369. #include <lightmap_pars_fragment>
  2370. #include <emissivemap_pars_fragment>
  2371. #include <envmap_common_pars_fragment>
  2372. #include <envmap_pars_fragment>
  2373. #include <cube_uv_reflection_fragment>
  2374. #include <fog_pars_fragment>
  2375. #include <bsdfs>
  2376. #include <lights_pars_begin>
  2377. #include <normal_pars_fragment>
  2378. #include <lights_phong_pars_fragment>
  2379. #include <shadowmap_pars_fragment>
  2380. #include <bumpmap_pars_fragment>
  2381. #include <normalmap_pars_fragment>
  2382. #include <specularmap_pars_fragment>
  2383. #include <logdepthbuf_pars_fragment>
  2384. #include <clipping_planes_pars_fragment>
  2385. void main() {
  2386. #include <clipping_planes_fragment>
  2387. vec4 diffuseColor = vec4( diffuse, opacity );
  2388. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2389. vec3 totalEmissiveRadiance = emissive;
  2390. #include <logdepthbuf_fragment>
  2391. #include <map_fragment>
  2392. #include <color_fragment>
  2393. #include <alphamap_fragment>
  2394. #include <alphatest_fragment>
  2395. #include <specularmap_fragment>
  2396. #include <normal_fragment_begin>
  2397. #include <normal_fragment_maps>
  2398. #include <emissivemap_fragment>
  2399. #include <lights_phong_fragment>
  2400. #include <lights_fragment_begin>
  2401. #include <lights_fragment_maps>
  2402. #include <lights_fragment_end>
  2403. #include <aomap_fragment>
  2404. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  2405. #include <envmap_fragment>
  2406. #include <output_fragment>
  2407. #include <tonemapping_fragment>
  2408. #include <encodings_fragment>
  2409. #include <fog_fragment>
  2410. #include <premultiplied_alpha_fragment>
  2411. #include <dithering_fragment>
  2412. }`,mp=`#define STANDARD
  2413. varying vec3 vViewPosition;
  2414. #ifdef USE_TRANSMISSION
  2415. varying vec3 vWorldPosition;
  2416. #endif
  2417. #include <common>
  2418. #include <uv_pars_vertex>
  2419. #include <uv2_pars_vertex>
  2420. #include <displacementmap_pars_vertex>
  2421. #include <color_pars_vertex>
  2422. #include <fog_pars_vertex>
  2423. #include <normal_pars_vertex>
  2424. #include <morphtarget_pars_vertex>
  2425. #include <skinning_pars_vertex>
  2426. #include <shadowmap_pars_vertex>
  2427. #include <logdepthbuf_pars_vertex>
  2428. #include <clipping_planes_pars_vertex>
  2429. void main() {
  2430. #include <uv_vertex>
  2431. #include <uv2_vertex>
  2432. #include <color_vertex>
  2433. #include <beginnormal_vertex>
  2434. #include <morphnormal_vertex>
  2435. #include <skinbase_vertex>
  2436. #include <skinnormal_vertex>
  2437. #include <defaultnormal_vertex>
  2438. #include <normal_vertex>
  2439. #include <begin_vertex>
  2440. #include <morphtarget_vertex>
  2441. #include <skinning_vertex>
  2442. #include <displacementmap_vertex>
  2443. #include <project_vertex>
  2444. #include <logdepthbuf_vertex>
  2445. #include <clipping_planes_vertex>
  2446. vViewPosition = - mvPosition.xyz;
  2447. #include <worldpos_vertex>
  2448. #include <shadowmap_vertex>
  2449. #include <fog_vertex>
  2450. #ifdef USE_TRANSMISSION
  2451. vWorldPosition = worldPosition.xyz;
  2452. #endif
  2453. }`,gp=`#define STANDARD
  2454. #ifdef PHYSICAL
  2455. #define IOR
  2456. #define SPECULAR
  2457. #endif
  2458. uniform vec3 diffuse;
  2459. uniform vec3 emissive;
  2460. uniform float roughness;
  2461. uniform float metalness;
  2462. uniform float opacity;
  2463. #ifdef IOR
  2464. uniform float ior;
  2465. #endif
  2466. #ifdef SPECULAR
  2467. uniform float specularIntensity;
  2468. uniform vec3 specularColor;
  2469. #ifdef USE_SPECULARINTENSITYMAP
  2470. uniform sampler2D specularIntensityMap;
  2471. #endif
  2472. #ifdef USE_SPECULARCOLORMAP
  2473. uniform sampler2D specularColorMap;
  2474. #endif
  2475. #endif
  2476. #ifdef USE_CLEARCOAT
  2477. uniform float clearcoat;
  2478. uniform float clearcoatRoughness;
  2479. #endif
  2480. #ifdef USE_SHEEN
  2481. uniform vec3 sheenColor;
  2482. uniform float sheenRoughness;
  2483. #ifdef USE_SHEENCOLORMAP
  2484. uniform sampler2D sheenColorMap;
  2485. #endif
  2486. #ifdef USE_SHEENROUGHNESSMAP
  2487. uniform sampler2D sheenRoughnessMap;
  2488. #endif
  2489. #endif
  2490. varying vec3 vViewPosition;
  2491. #include <common>
  2492. #include <packing>
  2493. #include <dithering_pars_fragment>
  2494. #include <color_pars_fragment>
  2495. #include <uv_pars_fragment>
  2496. #include <uv2_pars_fragment>
  2497. #include <map_pars_fragment>
  2498. #include <alphamap_pars_fragment>
  2499. #include <alphatest_pars_fragment>
  2500. #include <aomap_pars_fragment>
  2501. #include <lightmap_pars_fragment>
  2502. #include <emissivemap_pars_fragment>
  2503. #include <bsdfs>
  2504. #include <cube_uv_reflection_fragment>
  2505. #include <envmap_common_pars_fragment>
  2506. #include <envmap_physical_pars_fragment>
  2507. #include <fog_pars_fragment>
  2508. #include <lights_pars_begin>
  2509. #include <normal_pars_fragment>
  2510. #include <lights_physical_pars_fragment>
  2511. #include <transmission_pars_fragment>
  2512. #include <shadowmap_pars_fragment>
  2513. #include <bumpmap_pars_fragment>
  2514. #include <normalmap_pars_fragment>
  2515. #include <clearcoat_pars_fragment>
  2516. #include <roughnessmap_pars_fragment>
  2517. #include <metalnessmap_pars_fragment>
  2518. #include <logdepthbuf_pars_fragment>
  2519. #include <clipping_planes_pars_fragment>
  2520. void main() {
  2521. #include <clipping_planes_fragment>
  2522. vec4 diffuseColor = vec4( diffuse, opacity );
  2523. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2524. vec3 totalEmissiveRadiance = emissive;
  2525. #include <logdepthbuf_fragment>
  2526. #include <map_fragment>
  2527. #include <color_fragment>
  2528. #include <alphamap_fragment>
  2529. #include <alphatest_fragment>
  2530. #include <roughnessmap_fragment>
  2531. #include <metalnessmap_fragment>
  2532. #include <normal_fragment_begin>
  2533. #include <normal_fragment_maps>
  2534. #include <clearcoat_normal_fragment_begin>
  2535. #include <clearcoat_normal_fragment_maps>
  2536. #include <emissivemap_fragment>
  2537. #include <lights_physical_fragment>
  2538. #include <lights_fragment_begin>
  2539. #include <lights_fragment_maps>
  2540. #include <lights_fragment_end>
  2541. #include <aomap_fragment>
  2542. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  2543. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  2544. #include <transmission_fragment>
  2545. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  2546. #ifdef USE_SHEEN
  2547. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  2548. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
  2549. #endif
  2550. #ifdef USE_CLEARCOAT
  2551. float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
  2552. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  2553. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
  2554. #endif
  2555. #include <output_fragment>
  2556. #include <tonemapping_fragment>
  2557. #include <encodings_fragment>
  2558. #include <fog_fragment>
  2559. #include <premultiplied_alpha_fragment>
  2560. #include <dithering_fragment>
  2561. }`,xp=`#define TOON
  2562. varying vec3 vViewPosition;
  2563. #include <common>
  2564. #include <uv_pars_vertex>
  2565. #include <uv2_pars_vertex>
  2566. #include <displacementmap_pars_vertex>
  2567. #include <color_pars_vertex>
  2568. #include <fog_pars_vertex>
  2569. #include <normal_pars_vertex>
  2570. #include <morphtarget_pars_vertex>
  2571. #include <skinning_pars_vertex>
  2572. #include <shadowmap_pars_vertex>
  2573. #include <logdepthbuf_pars_vertex>
  2574. #include <clipping_planes_pars_vertex>
  2575. void main() {
  2576. #include <uv_vertex>
  2577. #include <uv2_vertex>
  2578. #include <color_vertex>
  2579. #include <beginnormal_vertex>
  2580. #include <morphnormal_vertex>
  2581. #include <skinbase_vertex>
  2582. #include <skinnormal_vertex>
  2583. #include <defaultnormal_vertex>
  2584. #include <normal_vertex>
  2585. #include <begin_vertex>
  2586. #include <morphtarget_vertex>
  2587. #include <skinning_vertex>
  2588. #include <displacementmap_vertex>
  2589. #include <project_vertex>
  2590. #include <logdepthbuf_vertex>
  2591. #include <clipping_planes_vertex>
  2592. vViewPosition = - mvPosition.xyz;
  2593. #include <worldpos_vertex>
  2594. #include <shadowmap_vertex>
  2595. #include <fog_vertex>
  2596. }`,_p=`#define TOON
  2597. uniform vec3 diffuse;
  2598. uniform vec3 emissive;
  2599. uniform float opacity;
  2600. #include <common>
  2601. #include <packing>
  2602. #include <dithering_pars_fragment>
  2603. #include <color_pars_fragment>
  2604. #include <uv_pars_fragment>
  2605. #include <uv2_pars_fragment>
  2606. #include <map_pars_fragment>
  2607. #include <alphamap_pars_fragment>
  2608. #include <alphatest_pars_fragment>
  2609. #include <aomap_pars_fragment>
  2610. #include <lightmap_pars_fragment>
  2611. #include <emissivemap_pars_fragment>
  2612. #include <gradientmap_pars_fragment>
  2613. #include <fog_pars_fragment>
  2614. #include <bsdfs>
  2615. #include <lights_pars_begin>
  2616. #include <normal_pars_fragment>
  2617. #include <lights_toon_pars_fragment>
  2618. #include <shadowmap_pars_fragment>
  2619. #include <bumpmap_pars_fragment>
  2620. #include <normalmap_pars_fragment>
  2621. #include <logdepthbuf_pars_fragment>
  2622. #include <clipping_planes_pars_fragment>
  2623. void main() {
  2624. #include <clipping_planes_fragment>
  2625. vec4 diffuseColor = vec4( diffuse, opacity );
  2626. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2627. vec3 totalEmissiveRadiance = emissive;
  2628. #include <logdepthbuf_fragment>
  2629. #include <map_fragment>
  2630. #include <color_fragment>
  2631. #include <alphamap_fragment>
  2632. #include <alphatest_fragment>
  2633. #include <normal_fragment_begin>
  2634. #include <normal_fragment_maps>
  2635. #include <emissivemap_fragment>
  2636. #include <lights_toon_fragment>
  2637. #include <lights_fragment_begin>
  2638. #include <lights_fragment_maps>
  2639. #include <lights_fragment_end>
  2640. #include <aomap_fragment>
  2641. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2642. #include <output_fragment>
  2643. #include <tonemapping_fragment>
  2644. #include <encodings_fragment>
  2645. #include <fog_fragment>
  2646. #include <premultiplied_alpha_fragment>
  2647. #include <dithering_fragment>
  2648. }`,yp=`uniform float size;
  2649. uniform float scale;
  2650. #include <common>
  2651. #include <color_pars_vertex>
  2652. #include <fog_pars_vertex>
  2653. #include <morphtarget_pars_vertex>
  2654. #include <logdepthbuf_pars_vertex>
  2655. #include <clipping_planes_pars_vertex>
  2656. void main() {
  2657. #include <color_vertex>
  2658. #include <begin_vertex>
  2659. #include <morphtarget_vertex>
  2660. #include <project_vertex>
  2661. gl_PointSize = size;
  2662. #ifdef USE_SIZEATTENUATION
  2663. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  2664. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  2665. #endif
  2666. #include <logdepthbuf_vertex>
  2667. #include <clipping_planes_vertex>
  2668. #include <worldpos_vertex>
  2669. #include <fog_vertex>
  2670. }`,vp=`uniform vec3 diffuse;
  2671. uniform float opacity;
  2672. #include <common>
  2673. #include <color_pars_fragment>
  2674. #include <map_particle_pars_fragment>
  2675. #include <alphatest_pars_fragment>
  2676. #include <fog_pars_fragment>
  2677. #include <logdepthbuf_pars_fragment>
  2678. #include <clipping_planes_pars_fragment>
  2679. void main() {
  2680. #include <clipping_planes_fragment>
  2681. vec3 outgoingLight = vec3( 0.0 );
  2682. vec4 diffuseColor = vec4( diffuse, opacity );
  2683. #include <logdepthbuf_fragment>
  2684. #include <map_particle_fragment>
  2685. #include <color_fragment>
  2686. #include <alphatest_fragment>
  2687. outgoingLight = diffuseColor.rgb;
  2688. #include <output_fragment>
  2689. #include <tonemapping_fragment>
  2690. #include <encodings_fragment>
  2691. #include <fog_fragment>
  2692. #include <premultiplied_alpha_fragment>
  2693. }`,Mp=`#include <common>
  2694. #include <fog_pars_vertex>
  2695. #include <morphtarget_pars_vertex>
  2696. #include <skinning_pars_vertex>
  2697. #include <shadowmap_pars_vertex>
  2698. void main() {
  2699. #include <beginnormal_vertex>
  2700. #include <morphnormal_vertex>
  2701. #include <skinbase_vertex>
  2702. #include <skinnormal_vertex>
  2703. #include <defaultnormal_vertex>
  2704. #include <begin_vertex>
  2705. #include <morphtarget_vertex>
  2706. #include <skinning_vertex>
  2707. #include <project_vertex>
  2708. #include <worldpos_vertex>
  2709. #include <shadowmap_vertex>
  2710. #include <fog_vertex>
  2711. }`,bp=`uniform vec3 color;
  2712. uniform float opacity;
  2713. #include <common>
  2714. #include <packing>
  2715. #include <fog_pars_fragment>
  2716. #include <bsdfs>
  2717. #include <lights_pars_begin>
  2718. #include <shadowmap_pars_fragment>
  2719. #include <shadowmask_pars_fragment>
  2720. void main() {
  2721. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  2722. #include <tonemapping_fragment>
  2723. #include <encodings_fragment>
  2724. #include <fog_fragment>
  2725. }`,wp=`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. }`,Sp=`uniform vec3 diffuse;
  2752. uniform float opacity;
  2753. #include <common>
  2754. #include <uv_pars_fragment>
  2755. #include <map_pars_fragment>
  2756. #include <alphamap_pars_fragment>
  2757. #include <alphatest_pars_fragment>
  2758. #include <fog_pars_fragment>
  2759. #include <logdepthbuf_pars_fragment>
  2760. #include <clipping_planes_pars_fragment>
  2761. void main() {
  2762. #include <clipping_planes_fragment>
  2763. vec3 outgoingLight = vec3( 0.0 );
  2764. vec4 diffuseColor = vec4( diffuse, opacity );
  2765. #include <logdepthbuf_fragment>
  2766. #include <map_fragment>
  2767. #include <alphamap_fragment>
  2768. #include <alphatest_fragment>
  2769. outgoingLight = diffuseColor.rgb;
  2770. #include <output_fragment>
  2771. #include <tonemapping_fragment>
  2772. #include <encodings_fragment>
  2773. #include <fog_fragment>
  2774. }`,De={alphamap_fragment:$u,alphamap_pars_fragment:Qu,alphatest_fragment:ed,alphatest_pars_fragment:td,aomap_fragment:nd,aomap_pars_fragment:id,begin_vertex:sd,beginnormal_vertex:rd,bsdfs:od,bumpmap_pars_fragment:ad,clipping_planes_fragment:ld,clipping_planes_pars_fragment:cd,clipping_planes_pars_vertex:hd,clipping_planes_vertex:ud,color_fragment:dd,color_pars_fragment:fd,color_pars_vertex:pd,color_vertex:md,common:gd,cube_uv_reflection_fragment:xd,defaultnormal_vertex:_d,displacementmap_pars_vertex:yd,displacementmap_vertex:vd,emissivemap_fragment:Md,emissivemap_pars_fragment:bd,encodings_fragment:wd,encodings_pars_fragment:Sd,envmap_fragment:Td,envmap_common_pars_fragment:Ed,envmap_pars_fragment:Ad,envmap_pars_vertex:Ld,envmap_physical_pars_fragment:zd,envmap_vertex:Rd,fog_vertex:Cd,fog_pars_vertex:Pd,fog_fragment:Id,fog_pars_fragment:Dd,gradientmap_pars_fragment:Nd,lightmap_fragment:Fd,lightmap_pars_fragment:Od,lights_lambert_vertex:Bd,lights_pars_begin:Ud,lights_toon_fragment:Hd,lights_toon_pars_fragment:kd,lights_phong_fragment:Gd,lights_phong_pars_fragment:Vd,lights_physical_fragment:Wd,lights_physical_pars_fragment:qd,lights_fragment_begin:jd,lights_fragment_maps:Xd,lights_fragment_end:Yd,logdepthbuf_fragment:Zd,logdepthbuf_pars_fragment:Jd,logdepthbuf_pars_vertex:Kd,logdepthbuf_vertex:$d,map_fragment:Qd,map_pars_fragment:ef,map_particle_fragment:tf,map_particle_pars_fragment:nf,metalnessmap_fragment:sf,metalnessmap_pars_fragment:rf,morphnormal_vertex:of,morphtarget_pars_vertex:af,morphtarget_vertex:lf,normal_fragment_begin:cf,normal_fragment_maps:hf,normal_pars_fragment:uf,normal_pars_vertex:df,normal_vertex:ff,normalmap_pars_fragment:pf,clearcoat_normal_fragment_begin:mf,clearcoat_normal_fragment_maps:gf,clearcoat_pars_fragment:xf,output_fragment:_f,packing:yf,premultiplied_alpha_fragment:vf,project_vertex:Mf,dithering_fragment:bf,dithering_pars_fragment:wf,roughnessmap_fragment:Sf,roughnessmap_pars_fragment:Tf,shadowmap_pars_fragment:Ef,shadowmap_pars_vertex:Af,shadowmap_vertex:Lf,shadowmask_pars_fragment:Rf,skinbase_vertex:Cf,skinning_pars_vertex:Pf,skinning_vertex:If,skinnormal_vertex:Df,specularmap_fragment:Nf,specularmap_pars_fragment:Ff,tonemapping_fragment:Of,tonemapping_pars_fragment:Bf,transmission_fragment:Uf,transmission_pars_fragment:zf,uv_pars_fragment:Hf,uv_pars_vertex:kf,uv_vertex:Gf,uv2_pars_fragment:Vf,uv2_pars_vertex:Wf,uv2_vertex:qf,worldpos_vertex:jf,background_vert:Xf,background_frag:Yf,cube_vert:Zf,cube_frag:Jf,depth_vert:Kf,depth_frag:$f,distanceRGBA_vert:Qf,distanceRGBA_frag:ep,equirect_vert:tp,equirect_frag:np,linedashed_vert:ip,linedashed_frag:sp,meshbasic_vert:rp,meshbasic_frag:op,meshlambert_vert:ap,meshlambert_frag:lp,meshmatcap_vert:cp,meshmatcap_frag:hp,meshnormal_vert:up,meshnormal_frag:dp,meshphong_vert:fp,meshphong_frag:pp,meshphysical_vert:mp,meshphysical_frag:gp,meshtoon_vert:xp,meshtoon_frag:_p,points_vert:yp,points_frag:vp,shadow_vert:Mp,shadow_frag:bp,sprite_vert:wp,sprite_frag:Sp},oe={common:{diffuse:{value:new ue(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new ut},uv2Transform:{value:new ut},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new j(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ue(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 ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new ut}},sprite:{diffuse:{value:new ue(16777215)},opacity:{value:1},center:{value:new j(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new ut}}},It={basic:{uniforms:ft([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.fog]),vertexShader:De.meshbasic_vert,fragmentShader:De.meshbasic_frag},lambert:{uniforms:ft([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.fog,oe.lights,{emissive:{value:new ue(0)}}]),vertexShader:De.meshlambert_vert,fragmentShader:De.meshlambert_frag},phong:{uniforms:ft([oe.common,oe.specularmap,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.fog,oe.lights,{emissive:{value:new ue(0)},specular:{value:new ue(1118481)},shininess:{value:30}}]),vertexShader:De.meshphong_vert,fragmentShader:De.meshphong_frag},standard:{uniforms:ft([oe.common,oe.envmap,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.roughnessmap,oe.metalnessmap,oe.fog,oe.lights,{emissive:{value:new ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:De.meshphysical_vert,fragmentShader:De.meshphysical_frag},toon:{uniforms:ft([oe.common,oe.aomap,oe.lightmap,oe.emissivemap,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.gradientmap,oe.fog,oe.lights,{emissive:{value:new ue(0)}}]),vertexShader:De.meshtoon_vert,fragmentShader:De.meshtoon_frag},matcap:{uniforms:ft([oe.common,oe.bumpmap,oe.normalmap,oe.displacementmap,oe.fog,{matcap:{value:null}}]),vertexShader:De.meshmatcap_vert,fragmentShader:De.meshmatcap_frag},points:{uniforms:ft([oe.points,oe.fog]),vertexShader:De.points_vert,fragmentShader:De.points_frag},dashed:{uniforms:ft([oe.common,oe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:De.linedashed_vert,fragmentShader:De.linedashed_frag},depth:{uniforms:ft([oe.common,oe.displacementmap]),vertexShader:De.depth_vert,fragmentShader:De.depth_frag},normal:{uniforms:ft([oe.common,oe.bumpmap,oe.normalmap,oe.displacementmap,{opacity:{value:1}}]),vertexShader:De.meshnormal_vert,fragmentShader:De.meshnormal_frag},sprite:{uniforms:ft([oe.sprite,oe.fog]),vertexShader:De.sprite_vert,fragmentShader:De.sprite_frag},background:{uniforms:{uvTransform:{value:new ut},t2D:{value:null}},vertexShader:De.background_vert,fragmentShader:De.background_frag},cube:{uniforms:ft([oe.envmap,{opacity:{value:1}}]),vertexShader:De.cube_vert,fragmentShader:De.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:De.equirect_vert,fragmentShader:De.equirect_frag},distanceRGBA:{uniforms:ft([oe.common,oe.displacementmap,{referencePosition:{value:new T},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:De.distanceRGBA_vert,fragmentShader:De.distanceRGBA_frag},shadow:{uniforms:ft([oe.lights,oe.fog,{color:{value:new ue(0)},opacity:{value:1}}]),vertexShader:De.shadow_vert,fragmentShader:De.shadow_frag}};It.physical={uniforms:ft([It.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new j(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new ue(0)},sheenColorMap:{value:null},sheenRoughness:{value:0},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new j},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new ue(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularColor:{value:new ue(1,1,1)},specularColorMap:{value:null}}]),vertexShader:De.meshphysical_vert,fragmentShader:De.meshphysical_frag};function Tp(r,e,t,n,i){const s=new ue(0);let o=0,a,l,c=null,h=0,u=null;function d(g,x){let _=!1,p=x.isScene===!0?x.background:null;p&&p.isTexture&&(p=e.get(p));const m=r.xr,R=m.getSession&&m.getSession();R&&R.environmentBlendMode==="additive"&&(p=null),p===null?f(s,o):p&&p.isColor&&(f(p,1),_=!0),(r.autoClear||_)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),p&&(p.isCubeTexture||p.mapping===rr)?(l===void 0&&(l=new xt(new fs(1,1,1),new bn({name:"BackgroundCubeMaterial",uniforms:wi(It.cube.uniforms),vertexShader:It.cube.vertexShader,fragmentShader:It.cube.fragmentShader,side:it,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(y,E,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=p,l.material.uniforms.flipEnvMap.value=p.isCubeTexture&&p.isRenderTargetTexture===!1?-1:1,(c!==p||h!==p.version||u!==r.toneMapping)&&(l.material.needsUpdate=!0,c=p,h=p.version,u=r.toneMapping),g.unshift(l,l.geometry,l.material,0,0,null)):p&&p.isTexture&&(a===void 0&&(a=new xt(new Co(2,2),new bn({name:"BackgroundMaterial",uniforms:wi(It.background.uniforms),vertexShader:It.background.vertexShader,fragmentShader:It.background.fragmentShader,side:yi,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!==r.toneMapping)&&(a.material.needsUpdate=!0,c=p,h=p.version,u=r.toneMapping),g.unshift(a,a.geometry,a.material,0,0,null))}function f(g,x){t.buffers.color.setClear(g.r,g.g,g.b,x,i)}return{getClearColor:function(){return s},setClearColor:function(g,x=1){s.set(g),o=x,f(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(g){o=g,f(s,o)},render:d}}function Ep(r,e,t,n){const i=r.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=x(null);let c=l;function h(b,N,O,D,B){let te=!1;if(o){const le=g(D,O,N);c!==le&&(c=le,d(c.object)),te=_(D,B),te&&p(D,B)}else{const le=N.wireframe===!0;(c.geometry!==D.id||c.program!==O.id||c.wireframe!==le)&&(c.geometry=D.id,c.program=O.id,c.wireframe=le,te=!0)}b.isInstancedMesh===!0&&(te=!0),B!==null&&t.update(B,34963),te&&(P(b,N,O,D),B!==null&&r.bindBuffer(34963,t.get(B).buffer))}function u(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function d(b){return n.isWebGL2?r.bindVertexArray(b):s.bindVertexArrayOES(b)}function f(b){return n.isWebGL2?r.deleteVertexArray(b):s.deleteVertexArrayOES(b)}function g(b,N,O){const D=O.wireframe===!0;let B=a[b.id];B===void 0&&(B={},a[b.id]=B);let te=B[N.id];te===void 0&&(te={},B[N.id]=te);let le=te[D];return le===void 0&&(le=x(u()),te[D]=le),le}function x(b){const N=[],O=[],D=[];for(let B=0;B<i;B++)N[B]=0,O[B]=0,D[B]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:O,attributeDivisors:D,object:b,attributes:{},index:null}}function _(b,N){const O=c.attributes,D=b.attributes;let B=0;for(const te in D){const le=O[te],k=D[te];if(le===void 0||le.attribute!==k||le.data!==k.data)return!0;B++}return c.attributesNum!==B||c.index!==N}function p(b,N){const O={},D=b.attributes;let B=0;for(const te in D){const le=D[te],k={};k.attribute=le,le.data&&(k.data=le.data),O[te]=k,B++}c.attributes=O,c.attributesNum=B,c.index=N}function m(){const b=c.newAttributes;for(let N=0,O=b.length;N<O;N++)b[N]=0}function R(b){y(b,0)}function y(b,N){const O=c.newAttributes,D=c.enabledAttributes,B=c.attributeDivisors;O[b]=1,D[b]===0&&(r.enableVertexAttribArray(b),D[b]=1),B[b]!==N&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](b,N),B[b]=N)}function E(){const b=c.newAttributes,N=c.enabledAttributes;for(let O=0,D=N.length;O<D;O++)N[O]!==b[O]&&(r.disableVertexAttribArray(O),N[O]=0)}function C(b,N,O,D,B,te){n.isWebGL2===!0&&(O===5124||O===5125)?r.vertexAttribIPointer(b,N,O,B,te):r.vertexAttribPointer(b,N,O,D,B,te)}function P(b,N,O,D){if(n.isWebGL2===!1&&(b.isInstancedMesh||D.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;m();const B=D.attributes,te=O.getAttributes(),le=N.defaultAttributeValues;for(const k in te){const G=te[k];if(G.location>=0){let ce=B[k];if(ce===void 0&&(k==="instanceMatrix"&&b.instanceMatrix&&(ce=b.instanceMatrix),k==="instanceColor"&&b.instanceColor&&(ce=b.instanceColor)),ce!==void 0){const ae=ce.normalized,fe=ce.itemSize,Ce=t.get(ce);if(Ce===void 0)continue;const X=Ce.buffer,Ae=Ce.type,ye=Ce.bytesPerElement;if(ce.isInterleavedBufferAttribute){const me=ce.data,ge=me.stride,Ne=ce.offset;if(me&&me.isInstancedInterleavedBuffer){for(let H=0;H<G.locationSize;H++)y(G.location+H,me.meshPerAttribute);b.isInstancedMesh!==!0&&D._maxInstanceCount===void 0&&(D._maxInstanceCount=me.meshPerAttribute*me.count)}else for(let H=0;H<G.locationSize;H++)R(G.location+H);r.bindBuffer(34962,X);for(let H=0;H<G.locationSize;H++)C(G.location+H,fe/G.locationSize,Ae,ae,ge*ye,(Ne+fe/G.locationSize*H)*ye)}else{if(ce.isInstancedBufferAttribute){for(let me=0;me<G.locationSize;me++)y(G.location+me,ce.meshPerAttribute);b.isInstancedMesh!==!0&&D._maxInstanceCount===void 0&&(D._maxInstanceCount=ce.meshPerAttribute*ce.count)}else for(let me=0;me<G.locationSize;me++)R(G.location+me);r.bindBuffer(34962,X);for(let me=0;me<G.locationSize;me++)C(G.location+me,fe/G.locationSize,Ae,ae,fe*ye,fe/G.locationSize*me*ye)}}else if(le!==void 0){const ae=le[k];if(ae!==void 0)switch(ae.length){case 2:r.vertexAttrib2fv(G.location,ae);break;case 3:r.vertexAttrib3fv(G.location,ae);break;case 4:r.vertexAttrib4fv(G.location,ae);break;default:r.vertexAttrib1fv(G.location,ae)}}}}E()}function V(){I();for(const b in a){const N=a[b];for(const O in N){const D=N[O];for(const B in D)f(D[B].object),delete D[B];delete N[O]}delete a[b]}}function ne(b){if(a[b.id]===void 0)return;const N=a[b.id];for(const O in N){const D=N[O];for(const B in D)f(D[B].object),delete D[B];delete N[O]}delete a[b.id]}function Z(b){for(const N in a){const O=a[N];if(O[b.id]===void 0)continue;const D=O[b.id];for(const B in D)f(D[B].object),delete D[B];delete O[b.id]}}function I(){S(),c!==l&&(c=l,d(c.object))}function S(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:I,resetDefaultState:S,dispose:V,releaseStatesOfGeometry:ne,releaseStatesOfProgram:Z,initAttributes:m,enableAttribute:R,disableUnusedAttributes:E}}function Ap(r,e,t,n){const i=n.isWebGL2;let s;function o(c){s=c}function a(c,h){r.drawArrays(s,c,h),t.update(h,s,1)}function l(c,h,u){if(u===0)return;let d,f;if(i)d=r,f="drawArraysInstanced";else if(d=e.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](s,c,h,u),t.update(h,s,u)}this.setMode=o,this.render=a,this.renderInstances=l}function Lp(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const P=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(P.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(P){if(P==="highp"){if(r.getShaderPrecisionFormat(35633,36338).precision>0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";P="mediump"}return P==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&r instanceof WebGL2ComputeRenderingContext;let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=r.getParameter(34930),d=r.getParameter(35660),f=r.getParameter(3379),g=r.getParameter(34076),x=r.getParameter(34921),_=r.getParameter(36347),p=r.getParameter(36348),m=r.getParameter(36349),R=d>0,y=o||e.has("OES_texture_float"),E=R&&y,C=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:g,maxAttributes:x,maxVertexUniforms:_,maxVaryings:p,maxFragmentUniforms:m,vertexTextures:R,floatFragmentTextures:y,floatVertexTextures:E,maxSamples:C}}function Rp(r){const e=this;let t=null,n=0,i=!1,s=!1;const o=new Kt,a=new ut,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d,f){const g=u.length!==0||d||n!==0||i;return i=d,t=h(u,f,0),n=u.length,g},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1,c()},this.setState=function(u,d,f){const g=u.clippingPlanes,x=u.clipIntersection,_=u.clipShadows,p=r.get(u);if(!i||g===null||g.length===0||s&&!_)s?h(null):c();else{const m=s?0:n,R=m*4;let y=p.clippingState||null;l.value=y,y=h(g,d,R,f);for(let E=0;E!==R;++E)y[E]=t[E];p.clippingState=y,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=m}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,g){const x=u!==null?u.length:0;let _=null;if(x!==0){if(_=l.value,g!==!0||_===null){const p=f+x*4,m=d.matrixWorldInverse;a.getNormalMatrix(m),(_===null||_.length<p)&&(_=new Float32Array(p));for(let R=0,y=f;R!==x;++R,y+=4)o.copy(u[R]).applyMatrix4(m,a),o.normal.toArray(_,y),_[y+3]=o.constant}l.value=_,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,_}}function Cp(r){let e=new WeakMap;function t(o,a){return a===no?o.mapping=us:a===io&&(o.mapping=ds),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){const a=o.mapping;if(a===no||a===io)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=r.getRenderTarget(),h=new Xl(l.height/2);return h.fromEquirectangularTexture(r,o),e.set(o,h),r.setRenderTarget(c),o.addEventListener("dispose",i),t(h.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class cr extends Lo{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,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=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}cr.prototype.isOrthographicCamera=!0;class hr extends bn{constructor(e){super(e),this.type="RawShaderMaterial"}}hr.prototype.isRawShaderMaterial=!0;const _i=4,_n=8,zt=Math.pow(2,_n),Zl=[.125,.215,.35,.446,.526,.582],Jl=_n-_i+1+Zl.length,ri=20,ir={[Dt]:0,[Ht]:1},Gr=new cr,{_lodPlanes:Hi,_sizeLods:Aa,_sigmas:Bs}=Ip(),La=new ue;let Vr=null;const Dn=(1+Math.sqrt(5))/2,oi=1/Dn,Ra=[new T(1,1,1),new T(-1,1,1),new T(1,1,-1),new T(-1,1,-1),new T(0,Dn,oi),new T(0,Dn,-oi),new T(oi,0,Dn),new T(-oi,0,Dn),new T(Dn,oi,0),new T(-Dn,oi,0)];class Pp{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=Dp(ri),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Vr=this._renderer.getRenderTarget();const s=this._allocateTargets();return this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=Ia(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=Pa(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),this._cubemapShader!==null&&this._cubemapShader.dispose(),this._equirectShader!==null&&this._equirectShader.dispose();for(let e=0;e<Hi.length;e++)Hi[e].dispose()}_cleanup(e){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(Vr),e.scissorTest=!1,Us(e,0,0,e.width,e.height)}_fromTexture(e){Vr=this._renderer.getRenderTarget();const t=this._allocateTargets(e);return this._textureToCubeUV(e,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(e){const t={magFilter:ht,minFilter:ht,generateMipmaps:!1,type:Fn,format:st,encoding:Dt,depthBuffer:!1},n=Ca(t);return n.depthBuffer=!e,this._pingPongRenderTarget=Ca(t),n}_compileMaterial(e){const t=new xt(Hi[0],e);this._renderer.compile(t,Gr)}_sceneToCubeUV(e,t,n,i){const a=new pt(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(La),h.toneMapping=gn,h.autoClear=!1;const f=new pn({name:"PMREM.Background",side:it,depthWrite:!1,depthTest:!1}),g=new xt(new fs,f);let x=!1;const _=e.background;_?_.isColor&&(f.color.copy(_),e.background=null,x=!0):(f.color.copy(La),x=!0);for(let p=0;p<6;p++){const m=p%3;m==0?(a.up.set(0,l[p],0),a.lookAt(c[p],0,0)):m==1?(a.up.set(0,0,l[p]),a.lookAt(0,c[p],0)):(a.up.set(0,l[p],0),a.lookAt(0,0,c[p])),Us(i,m*zt,p>2?zt:0,zt,zt),h.setRenderTarget(i),x&&h.render(g,a),h.render(e,a)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,e.background=_}_setEncoding(e,t){this._renderer.capabilities.isWebGL2===!0&&t.format===st&&t.type===en&&t.encoding===Ht?e.value=ir[Dt]:e.value=ir[t.encoding]}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===us||e.mapping===ds;i?this._cubemapShader==null&&(this._cubemapShader=Ia()):this._equirectShader==null&&(this._equirectShader=Pa());const s=i?this._cubemapShader:this._equirectShader,o=new xt(Hi[0],s),a=s.uniforms;a.envMap.value=e,i||a.texelSize.value.set(1/e.image.width,1/e.image.height),this._setEncoding(a.inputEncoding,e),Us(t,0,0,3*zt,2*zt),n.setRenderTarget(t),n.render(o,Gr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<Jl;i++){const s=Math.sqrt(Bs[i]*Bs[i]-Bs[i-1]*Bs[i-1]),o=Ra[(i-1)%Ra.length];this._blur(e,i-1,i,s,o)}t.autoClear=n}_blur(e,t,n,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new xt(Hi[i],c),d=c.uniforms,f=Aa[n]-1,g=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*ri-1),x=s/g,_=isFinite(s)?1+Math.floor(h*x):ri;_>ri&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${ri}`);const p=[];let m=0;for(let C=0;C<ri;++C){const P=C/x,V=Math.exp(-P*P/2);p.push(V),C==0?m+=V:C<_&&(m+=2*V)}for(let C=0;C<p.length;C++)p[C]=p[C]/m;d.envMap.value=e.texture,d.samples.value=_,d.weights.value=p,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a),d.dTheta.value=g,d.mipInt.value=_n-n;const R=Aa[i],y=3*Math.max(0,zt-2*R),E=(i===0?0:2*zt)+2*R*(i>_n-_i?i-_n+_i:0);Us(t,y,E,3*R,2*R),l.setRenderTarget(t),l.render(u,Gr)}}function Ip(){const r=[],e=[],t=[];let n=_n;for(let i=0;i<Jl;i++){const s=Math.pow(2,n);e.push(s);let o=1/s;i>_n-_i?o=Zl[i-_n+_i-1]:i==0&&(o=0),t.push(o);const a=1/(s-1),l=-a/2,c=1+a/2,h=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,d=6,f=3,g=2,x=1,_=new Float32Array(f*d*u),p=new Float32Array(g*d*u),m=new Float32Array(x*d*u);for(let y=0;y<u;y++){const E=y%3*2/3-1,C=y>2?0:-1,P=[E,C,0,E+2/3,C,0,E+2/3,C+1,0,E,C,0,E+2/3,C+1,0,E,C+1,0];_.set(P,f*d*y),p.set(h,g*d*y);const V=[y,y,y,y,y,y];m.set(V,x*d*y)}const R=new Xe;R.setAttribute("position",new $e(_,f)),R.setAttribute("uv",new $e(p,g)),R.setAttribute("faceIndex",new $e(m,x)),r.push(R),n>_i&&n--}return{_lodPlanes:r,_sizeLods:e,_sigmas:t}}function Ca(r){const e=new Et(3*zt,3*zt,r);return e.texture.mapping=rr,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Us(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function Dp(r){const e=new Float32Array(r),t=new T(0,1,0);return new hr({name:"SphericalGaussianBlur",defines:{n:r},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t}},vertexShader:Po(),fragmentShader:`
  2775. precision mediump float;
  2776. precision mediump int;
  2777. varying vec3 vOutputDirection;
  2778. uniform sampler2D envMap;
  2779. uniform int samples;
  2780. uniform float weights[ n ];
  2781. uniform bool latitudinal;
  2782. uniform float dTheta;
  2783. uniform float mipInt;
  2784. uniform vec3 poleAxis;
  2785. ${Io()}
  2786. #define ENVMAP_TYPE_CUBE_UV
  2787. #include <cube_uv_reflection_fragment>
  2788. vec3 getSample( float theta, vec3 axis ) {
  2789. float cosTheta = cos( theta );
  2790. // Rodrigues' axis-angle rotation
  2791. vec3 sampleDirection = vOutputDirection * cosTheta
  2792. + cross( axis, vOutputDirection ) * sin( theta )
  2793. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  2794. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  2795. }
  2796. void main() {
  2797. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  2798. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  2799. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  2800. }
  2801. axis = normalize( axis );
  2802. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2803. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  2804. for ( int i = 1; i < n; i++ ) {
  2805. if ( i >= samples ) {
  2806. break;
  2807. }
  2808. float theta = dTheta * float( i );
  2809. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  2810. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  2811. }
  2812. }
  2813. `,blending:mn,depthTest:!1,depthWrite:!1})}function Pa(){const r=new j(1,1);return new hr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:r},inputEncoding:{value:ir[Dt]}},vertexShader:Po(),fragmentShader:`
  2814. precision mediump float;
  2815. precision mediump int;
  2816. varying vec3 vOutputDirection;
  2817. uniform sampler2D envMap;
  2818. uniform vec2 texelSize;
  2819. ${Io()}
  2820. #include <common>
  2821. void main() {
  2822. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2823. vec3 outputDirection = normalize( vOutputDirection );
  2824. vec2 uv = equirectUv( outputDirection );
  2825. vec2 f = fract( uv / texelSize - 0.5 );
  2826. uv -= f * texelSize;
  2827. vec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
  2828. uv.x += texelSize.x;
  2829. vec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
  2830. uv.y += texelSize.y;
  2831. vec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
  2832. uv.x -= texelSize.x;
  2833. vec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;
  2834. vec3 tm = mix( tl, tr, f.x );
  2835. vec3 bm = mix( bl, br, f.x );
  2836. gl_FragColor.rgb = mix( tm, bm, f.y );
  2837. }
  2838. `,blending:mn,depthTest:!1,depthWrite:!1})}function Ia(){return new hr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:ir[Dt]}},vertexShader:Po(),fragmentShader:`
  2839. precision mediump float;
  2840. precision mediump int;
  2841. varying vec3 vOutputDirection;
  2842. uniform samplerCube envMap;
  2843. ${Io()}
  2844. void main() {
  2845. gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) );
  2846. }
  2847. `,blending:mn,depthTest:!1,depthWrite:!1})}function Po(){return`
  2848. precision mediump float;
  2849. precision mediump int;
  2850. attribute vec3 position;
  2851. attribute vec2 uv;
  2852. attribute float faceIndex;
  2853. varying vec3 vOutputDirection;
  2854. // RH coordinate system; PMREM face-indexing convention
  2855. vec3 getDirection( vec2 uv, float face ) {
  2856. uv = 2.0 * uv - 1.0;
  2857. vec3 direction = vec3( uv, 1.0 );
  2858. if ( face == 0.0 ) {
  2859. direction = direction.zyx; // ( 1, v, u ) pos x
  2860. } else if ( face == 1.0 ) {
  2861. direction = direction.xzy;
  2862. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  2863. } else if ( face == 2.0 ) {
  2864. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  2865. } else if ( face == 3.0 ) {
  2866. direction = direction.zyx;
  2867. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  2868. } else if ( face == 4.0 ) {
  2869. direction = direction.xzy;
  2870. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  2871. } else if ( face == 5.0 ) {
  2872. direction.z *= -1.0; // ( u, v, -1 ) neg z
  2873. }
  2874. return direction;
  2875. }
  2876. void main() {
  2877. vOutputDirection = getDirection( uv, faceIndex );
  2878. gl_Position = vec4( position, 1.0 );
  2879. }
  2880. `}function Io(){return`
  2881. uniform int inputEncoding;
  2882. #include <encodings_pars_fragment>
  2883. vec4 inputTexelToLinear( vec4 value ) {
  2884. if ( inputEncoding == 0 ) {
  2885. return value;
  2886. } else {
  2887. return sRGBToLinear( value );
  2888. }
  2889. }
  2890. vec4 envMapTexelToLinear( vec4 color ) {
  2891. return inputTexelToLinear( color );
  2892. }
  2893. `}function Np(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture&&a.isRenderTargetTexture===!1){const l=a.mapping,c=l===no||l===io,h=l===us||l===ds;if(c||h){if(e.has(a))return e.get(a).texture;{const u=a.image;if(c&&u&&u.height>0||h&&u&&i(u)){const d=r.getRenderTarget();t===null&&(t=new Pp(r));const f=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,f),r.setRenderTarget(d),a.addEventListener("dispose",s),f.texture}else return null}}}return a}function i(a){let l=0;const c=6;for(let h=0;h<c;h++)a[h]!==void 0&&l++;return l===c}function s(a){const l=a.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function Fp(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){const i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function Op(r,e,t,n){const i={},s=new WeakMap;function o(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",o),delete i[d.id];const f=s.get(d);f&&(e.remove(f),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(u,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function l(u){const d=u.attributes;for(const g in d)e.update(d[g],34962);const f=u.morphAttributes;for(const g in f){const x=f[g];for(let _=0,p=x.length;_<p;_++)e.update(x[_],34962)}}function c(u){const d=[],f=u.index,g=u.attributes.position;let x=0;if(f!==null){const m=f.array;x=f.version;for(let R=0,y=m.length;R<y;R+=3){const E=m[R+0],C=m[R+1],P=m[R+2];d.push(E,C,C,P,P,E)}}else{const m=g.array;x=g.version;for(let R=0,y=m.length/3-1;R<y;R+=3){const E=R+0,C=R+1,P=R+2;d.push(E,C,C,P,P,E)}}const _=new(Gl(d)>65535?ql:Wl)(d,1);_.version=x;const p=s.get(u);p&&e.remove(p),s.set(u,_)}function h(u){const d=s.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return s.get(u)}return{get:a,update:l,getWireframeAttribute:h}}function Bp(r,e,t,n){const i=n.isWebGL2;let s;function o(d){s=d}let a,l;function c(d){a=d.type,l=d.bytesPerElement}function h(d,f){r.drawElements(s,f,a,d*l),t.update(f,s,1)}function u(d,f,g){if(g===0)return;let x,_;if(i)x=r,_="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),_="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[_](s,f,a,d*l,g),t.update(f,s,g)}this.setMode=o,this.setIndex=c,this.render=h,this.renderInstances=u}function Up(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case 4:t.triangles+=a*(s/3);break;case 1:t.lines+=a*(s/2);break;case 3:t.lines+=a*(s-1);break;case 2:t.lines+=a*s;break;case 0:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}class Do extends tt{constructor(e=null,t=1,n=1,i=1){super(null),this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qe,this.minFilter=Qe,this.wrapR=yt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}Do.prototype.isDataTexture2DArray=!0;function zp(r,e){return r[0]-e[0]}function Hp(r,e){return Math.abs(e[1])-Math.abs(r[1])}function Da(r,e){let t=1;const n=e.isInterleavedBufferAttribute?e.data.array:e.array;n instanceof Int8Array?t=127:n instanceof Int16Array?t=32767:n instanceof Int32Array?t=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",n),r.divideScalar(t)}function kp(r,e,t){const n={},i=new Float32Array(8),s=new WeakMap,o=new T,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,h,u,d){const f=c.morphTargetInfluences;if(e.isWebGL2===!0){const g=h.morphAttributes.position.length;let x=s.get(h);if(x===void 0||x.count!==g){x!==void 0&&x.texture.dispose();const m=h.morphAttributes.normal!==void 0,R=h.morphAttributes.position,y=h.morphAttributes.normal||[],E=h.attributes.position.count,C=m===!0?2:1;let P=E*C,V=1;P>e.maxTextureSize&&(V=Math.ceil(P/e.maxTextureSize),P=e.maxTextureSize);const ne=new Float32Array(P*V*4*g),Z=new Do(ne,P,V,g);Z.format=st,Z.type=$t,Z.needsUpdate=!0;const I=C*4;for(let S=0;S<g;S++){const b=R[S],N=y[S],O=P*V*4*S;for(let D=0;D<b.count;D++){o.fromBufferAttribute(b,D),b.normalized===!0&&Da(o,b);const B=D*I;ne[O+B+0]=o.x,ne[O+B+1]=o.y,ne[O+B+2]=o.z,ne[O+B+3]=0,m===!0&&(o.fromBufferAttribute(N,D),N.normalized===!0&&Da(o,N),ne[O+B+4]=o.x,ne[O+B+5]=o.y,ne[O+B+6]=o.z,ne[O+B+7]=0)}}x={count:g,texture:Z,size:new j(P,V)},s.set(h,x)}let _=0;for(let m=0;m<f.length;m++)_+=f[m];const p=h.morphTargetsRelative?1:1-_;d.getUniforms().setValue(r,"morphTargetBaseInfluence",p),d.getUniforms().setValue(r,"morphTargetInfluences",f),d.getUniforms().setValue(r,"morphTargetsTexture",x.texture,t),d.getUniforms().setValue(r,"morphTargetsTextureSize",x.size)}else{const g=f===void 0?0:f.length;let x=n[h.id];if(x===void 0||x.length!==g){x=[];for(let y=0;y<g;y++)x[y]=[y,0];n[h.id]=x}for(let y=0;y<g;y++){const E=x[y];E[0]=y,E[1]=f[y]}x.sort(Hp);for(let y=0;y<8;y++)y<g&&x[y][1]?(a[y][0]=x[y][0],a[y][1]=x[y][1]):(a[y][0]=Number.MAX_SAFE_INTEGER,a[y][1]=0);a.sort(zp);const _=h.morphAttributes.position,p=h.morphAttributes.normal;let m=0;for(let y=0;y<8;y++){const E=a[y],C=E[0],P=E[1];C!==Number.MAX_SAFE_INTEGER&&P?(_&&h.getAttribute("morphTarget"+y)!==_[C]&&h.setAttribute("morphTarget"+y,_[C]),p&&h.getAttribute("morphNormal"+y)!==p[C]&&h.setAttribute("morphNormal"+y,p[C]),i[y]=P,m+=P):(_&&h.hasAttribute("morphTarget"+y)===!0&&h.deleteAttribute("morphTarget"+y),p&&h.hasAttribute("morphNormal"+y)===!0&&h.deleteAttribute("morphNormal"+y),i[y]=0)}const R=h.morphTargetsRelative?1:1-m;d.getUniforms().setValue(r,"morphTargetBaseInfluence",R),d.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:l}}function Gp(r,e,t,n){let i=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,u=e.get(l,h);return i.get(u)!==c&&(e.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),t.update(l.instanceMatrix,34962),l.instanceColor!==null&&t.update(l.instanceColor,34962)),u}function o(){i=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}class Kl extends tt{constructor(e=null,t=1,n=1,i=1){super(null),this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qe,this.minFilter=Qe,this.wrapR=yt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}Kl.prototype.isDataTexture3D=!0;const $l=new tt,Ql=new Do,ec=new Kl,tc=new ar,Na=[],Fa=[],Oa=new Float32Array(16),Ba=new Float32Array(9),Ua=new Float32Array(4);function Ri(r,e,t){const n=r[0];if(n<=0||n>0)return r;const i=e*t;let s=Na[i];if(s===void 0&&(s=new Float32Array(i),Na[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function _t(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function mt(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function ur(r,e){let t=Fa[e];t===void 0&&(t=new Int32Array(e),Fa[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function Vp(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function Wp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(_t(t,e))return;r.uniform2fv(this.addr,e),mt(t,e)}}function qp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(_t(t,e))return;r.uniform3fv(this.addr,e),mt(t,e)}}function jp(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(_t(t,e))return;r.uniform4fv(this.addr,e),mt(t,e)}}function Xp(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(_t(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),mt(t,e)}else{if(_t(t,n))return;Ua.set(n),r.uniformMatrix2fv(this.addr,!1,Ua),mt(t,n)}}function Yp(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(_t(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),mt(t,e)}else{if(_t(t,n))return;Ba.set(n),r.uniformMatrix3fv(this.addr,!1,Ba),mt(t,n)}}function Zp(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(_t(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),mt(t,e)}else{if(_t(t,n))return;Oa.set(n),r.uniformMatrix4fv(this.addr,!1,Oa),mt(t,n)}}function Jp(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function Kp(r,e){const t=this.cache;_t(t,e)||(r.uniform2iv(this.addr,e),mt(t,e))}function $p(r,e){const t=this.cache;_t(t,e)||(r.uniform3iv(this.addr,e),mt(t,e))}function Qp(r,e){const t=this.cache;_t(t,e)||(r.uniform4iv(this.addr,e),mt(t,e))}function em(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function tm(r,e){const t=this.cache;_t(t,e)||(r.uniform2uiv(this.addr,e),mt(t,e))}function nm(r,e){const t=this.cache;_t(t,e)||(r.uniform3uiv(this.addr,e),mt(t,e))}function im(r,e){const t=this.cache;_t(t,e)||(r.uniform4uiv(this.addr,e),mt(t,e))}function sm(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.safeSetTexture2D(e||$l,i)}function rm(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||ec,i)}function om(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.safeSetTextureCube(e||tc,i)}function am(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Ql,i)}function lm(r){switch(r){case 5126:return Vp;case 35664:return Wp;case 35665:return qp;case 35666:return jp;case 35674:return Xp;case 35675:return Yp;case 35676:return Zp;case 5124:case 35670:return Jp;case 35667:case 35671:return Kp;case 35668:case 35672:return $p;case 35669:case 35673:return Qp;case 5125:return em;case 36294:return tm;case 36295:return nm;case 36296:return im;case 35678:case 36198:case 36298:case 36306:case 35682:return sm;case 35679:case 36299:case 36307:return rm;case 35680:case 36300:case 36308:case 36293:return om;case 36289:case 36303:case 36311:case 36292:return am}}function cm(r,e){r.uniform1fv(this.addr,e)}function hm(r,e){const t=Ri(e,this.size,2);r.uniform2fv(this.addr,t)}function um(r,e){const t=Ri(e,this.size,3);r.uniform3fv(this.addr,t)}function dm(r,e){const t=Ri(e,this.size,4);r.uniform4fv(this.addr,t)}function fm(r,e){const t=Ri(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function pm(r,e){const t=Ri(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function mm(r,e){const t=Ri(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function gm(r,e){r.uniform1iv(this.addr,e)}function xm(r,e){r.uniform2iv(this.addr,e)}function _m(r,e){r.uniform3iv(this.addr,e)}function ym(r,e){r.uniform4iv(this.addr,e)}function vm(r,e){r.uniform1uiv(this.addr,e)}function Mm(r,e){r.uniform2uiv(this.addr,e)}function bm(r,e){r.uniform3uiv(this.addr,e)}function wm(r,e){r.uniform4uiv(this.addr,e)}function Sm(r,e,t){const n=e.length,i=ur(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.safeSetTexture2D(e[s]||$l,i[s])}function Tm(r,e,t){const n=e.length,i=ur(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture3D(e[s]||ec,i[s])}function Em(r,e,t){const n=e.length,i=ur(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.safeSetTextureCube(e[s]||tc,i[s])}function Am(r,e,t){const n=e.length,i=ur(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2DArray(e[s]||Ql,i[s])}function Lm(r){switch(r){case 5126:return cm;case 35664:return hm;case 35665:return um;case 35666:return dm;case 35674:return fm;case 35675:return pm;case 35676:return mm;case 5124:case 35670:return gm;case 35667:case 35671:return xm;case 35668:case 35672:return _m;case 35669:case 35673:return ym;case 5125:return vm;case 36294:return Mm;case 36295:return bm;case 36296:return wm;case 35678:case 36198:case 36298:case 36306:case 35682:return Sm;case 35679:case 36299:case 36307:return Tm;case 35680:case 36300:case 36308:case 36293:return Em;case 36289:case 36303:case 36311:case 36292:return Am}}function Rm(r,e,t){this.id=r,this.addr=t,this.cache=[],this.setValue=lm(e.type)}function nc(r,e,t){this.id=r,this.addr=t,this.cache=[],this.size=e.size,this.setValue=Lm(e.type)}nc.prototype.updateCache=function(r){const e=this.cache;r instanceof Float32Array&&e.length!==r.length&&(this.cache=new Float32Array(r.length)),mt(e,r)};function ic(r){this.id=r,this.seq=[],this.map={}}ic.prototype.setValue=function(r,e,t){const n=this.seq;for(let i=0,s=n.length;i!==s;++i){const o=n[i];o.setValue(r,e[o.id],t)}};const Wr=/(\w+)(\])?(\[|\.)?/g;function za(r,e){r.seq.push(e),r.map[e.id]=e}function Cm(r,e,t){const n=r.name,i=n.length;for(Wr.lastIndex=0;;){const s=Wr.exec(n),o=Wr.lastIndex;let a=s[1];const l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){za(t,c===void 0?new Rm(a,r,e):new nc(a,r,e));break}else{let u=t.map[a];u===void 0&&(u=new ic(a),za(t,u)),t=u}}}function yn(r,e){this.seq=[],this.map={};const t=r.getProgramParameter(e,35718);for(let n=0;n<t;++n){const i=r.getActiveUniform(e,n),s=r.getUniformLocation(e,i.name);Cm(i,s,this)}}yn.prototype.setValue=function(r,e,t,n){const i=this.map[e];i!==void 0&&i.setValue(r,t,n)};yn.prototype.setOptional=function(r,e,t){const n=e[t];n!==void 0&&this.setValue(r,t,n)};yn.upload=function(r,e,t,n){for(let i=0,s=e.length;i!==s;++i){const o=e[i],a=t[o.id];a.needsUpdate!==!1&&o.setValue(r,a.value,n)}};yn.seqWithValue=function(r,e){const t=[];for(let n=0,i=r.length;n!==i;++n){const s=r[n];s.id in e&&t.push(s)}return t};function Ha(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}let Pm=0;function Im(r){const e=r.split(`
  2894. `);for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join(`
  2895. `)}function sc(r){switch(r){case Dt:return["Linear","( value )"];case Ht:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",r),["Linear","( value )"]}}function ka(r,e,t){const n=r.getShaderParameter(e,35713),i=r.getShaderInfoLog(e).trim();return n&&i===""?"":t.toUpperCase()+`
  2896. `+i+`
  2897. `+Im(r.getShaderSource(e))}function Pn(r,e){const t=sc(e);return"vec4 "+r+"( vec4 value ) { return "+t[0]+"ToLinear"+t[1]+"; }"}function Dm(r,e){const t=sc(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function Nm(r,e){let t;switch(e){case mh:t="Linear";break;case gh:t="Reinhard";break;case xh:t="OptimizedCineon";break;case _h:t="ACESFilmic";break;case yh:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Fm(r){return[r.extensionDerivatives||r.envMapCubeUV||r.bumpMap||r.tangentSpaceNormalMap||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Zi).join(`
  2898. `)}function Om(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
  2899. `)}function Bm(r,e){const t={},n=r.getProgramParameter(e,35721);for(let i=0;i<n;i++){const s=r.getActiveAttrib(e,i),o=s.name;let a=1;s.type===35674&&(a=2),s.type===35675&&(a=3),s.type===35676&&(a=4),t[o]={type:s.type,location:r.getAttribLocation(e,o),locationSize:a}}return t}function Zi(r){return r!==""}function Ga(r,e){return r.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Va(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Um=/^[ \t]*#include +<([\w\d./]+)>/gm;function ao(r){return r.replace(Um,zm)}function zm(r,e){const t=De[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return ao(t)}const Hm=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,km=/#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 Wa(r){return r.replace(km,rc).replace(Hm,Gm)}function Gm(r,e,t,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),rc(r,e,t,n)}function rc(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function qa(r){let e="precision "+r.precision+` float;
  2900. precision `+r.precision+" int;";return r.precision==="highp"?e+=`
  2901. #define HIGH_PRECISION`:r.precision==="mediump"?e+=`
  2902. #define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
  2903. #define LOW_PRECISION`),e}function Vm(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===Pl?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===Il?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Yi&&(e="SHADOWMAP_TYPE_VSM"),e}function Wm(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case us:case ds:e="ENVMAP_TYPE_CUBE";break;case rr:case wo:e="ENVMAP_TYPE_CUBE_UV";break}return e}function qm(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case ds:case wo:e="ENVMAP_MODE_REFRACTION";break}return e}function jm(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case sr:e="ENVMAP_BLENDING_MULTIPLY";break;case fh:e="ENVMAP_BLENDING_MIX";break;case ph:e="ENVMAP_BLENDING_ADD";break}return e}function Xm(r,e,t,n){const i=r.getContext(),s=t.defines;let o=t.vertexShader,a=t.fragmentShader;const l=Vm(t),c=Wm(t),h=qm(t),u=jm(t),d=t.isWebGL2?"":Fm(t),f=Om(s),g=i.createProgram();let x,_,p=t.glslVersion?"#version "+t.glslVersion+`
  2904. `:"";t.isRawShaderMaterial?(x=[f].filter(Zi).join(`
  2905. `),x.length>0&&(x+=`
  2906. `),_=[d,f].filter(Zi).join(`
  2907. `),_.length>0&&(_+=`
  2908. `)):(x=[qa(t),"#define SHADER_NAME "+t.shaderName,f,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+t.maxBones,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.useVertexTexture?"#define BONE_TEXTURE":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphTargets&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargets&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  2909. `].filter(Zi).join(`
  2910. `),_=[d,qa(t),"#define SHADER_NAME "+t.shaderName,f,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==gn?"#define TONE_MAPPING":"",t.toneMapping!==gn?De.tonemapping_pars_fragment:"",t.toneMapping!==gn?Nm("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.format===xn?"#define OPAQUE":"",De.encodings_pars_fragment,t.map?Pn("mapTexelToLinear",t.mapEncoding):"",t.matcap?Pn("matcapTexelToLinear",t.matcapEncoding):"",t.envMap?Pn("envMapTexelToLinear",t.envMapEncoding):"",t.emissiveMap?Pn("emissiveMapTexelToLinear",t.emissiveMapEncoding):"",t.specularColorMap?Pn("specularColorMapTexelToLinear",t.specularColorMapEncoding):"",t.sheenColorMap?Pn("sheenColorMapTexelToLinear",t.sheenColorMapEncoding):"",t.lightMap?Pn("lightMapTexelToLinear",t.lightMapEncoding):"",Dm("linearToOutputTexel",t.outputEncoding),t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
  2911. `].filter(Zi).join(`
  2912. `)),o=ao(o),o=Ga(o,t),o=Va(o,t),a=ao(a),a=Ga(a,t),a=Va(a,t),o=Wa(o),a=Wa(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(p=`#version 300 es
  2913. `,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  2914. `)+`
  2915. `+x,_=["#define varying in",t.glslVersion===ma?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ma?"":"#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(`
  2916. `)+`
  2917. `+_);const m=p+x+o,R=p+_+a,y=Ha(i,35633,m),E=Ha(i,35632,R);if(i.attachShader(g,y),i.attachShader(g,E),t.index0AttributeName!==void 0?i.bindAttribLocation(g,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(g,0,"position"),i.linkProgram(g),r.debug.checkShaderErrors){const V=i.getProgramInfoLog(g).trim(),ne=i.getShaderInfoLog(y).trim(),Z=i.getShaderInfoLog(E).trim();let I=!0,S=!0;if(i.getProgramParameter(g,35714)===!1){I=!1;const b=ka(i,y,"vertex"),N=ka(i,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(g,35715)+`
  2918. Program Info Log: `+V+`
  2919. `+b+`
  2920. `+N)}else V!==""?console.warn("THREE.WebGLProgram: Program Info Log:",V):(ne===""||Z==="")&&(S=!1);S&&(this.diagnostics={runnable:I,programLog:V,vertexShader:{log:ne,prefix:x},fragmentShader:{log:Z,prefix:_}})}i.deleteShader(y),i.deleteShader(E);let C;this.getUniforms=function(){return C===void 0&&(C=new yn(i,g)),C};let P;return this.getAttributes=function(){return P===void 0&&(P=Bm(i,g)),P},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(g),this.program=void 0},this.name=t.shaderName,this.id=Pm++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=y,this.fragmentShader=E,this}let Ym=0;class Zm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(t.has(e)===!1){const n=new Jm;t.set(e,n)}return t.get(e)}}class Jm{constructor(){this.id=Ym++,this.usedTimes=0}}function Km(r,e,t,n,i,s,o){const a=new Ao,l=new Zm,c=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,d=i.floatVertexTextures,f=i.maxVertexUniforms,g=i.vertexTextures;let x=i.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(S){const N=S.skeleton.bones;if(d)return 1024;{const D=Math.floor((f-20)/4),B=Math.min(D,N.length);return B<N.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+N.length+" bones. This GPU supports "+B+"."),0):B}}function m(S){let b;return S&&S.isTexture?b=S.encoding:S&&S.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),b=S.texture.encoding):b=Dt,h&&S&&S.isTexture&&S.format===st&&S.type===en&&S.encoding===Ht&&(b=Dt),b}function R(S,b,N,O,D){const B=O.fog,te=S.isMeshStandardMaterial?O.environment:null,le=(S.isMeshStandardMaterial?t:e).get(S.envMap||te),k=_[S.type],G=D.isSkinnedMesh?p(D):0;S.precision!==null&&(x=i.getMaxPrecision(S.precision),x!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",x,"instead."));let ce,ae,fe,Ce;if(k){const ge=It[k];ce=ge.vertexShader,ae=ge.fragmentShader}else ce=S.vertexShader,ae=S.fragmentShader,l.update(S),fe=l.getVertexShaderID(S),Ce=l.getFragmentShaderID(S);const X=r.getRenderTarget(),Ae=S.alphaTest>0,ye=S.clearcoat>0;return{isWebGL2:h,shaderID:k,shaderName:S.type,vertexShader:ce,fragmentShader:ae,defines:S.defines,customVertexShaderID:fe,customFragmentShaderID:Ce,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:x,instancing:D.isInstancedMesh===!0,instancingColor:D.isInstancedMesh===!0&&D.instanceColor!==null,supportsVertexTextures:g,outputEncoding:X!==null?m(X.texture):r.outputEncoding,map:!!S.map,mapEncoding:m(S.map),matcap:!!S.matcap,matcapEncoding:m(S.matcap),envMap:!!le,envMapMode:le&&le.mapping,envMapEncoding:m(le),envMapCubeUV:!!le&&(le.mapping===rr||le.mapping===wo),lightMap:!!S.lightMap,lightMapEncoding:m(S.lightMap),aoMap:!!S.aoMap,emissiveMap:!!S.emissiveMap,emissiveMapEncoding:m(S.emissiveMap),bumpMap:!!S.bumpMap,normalMap:!!S.normalMap,objectSpaceNormalMap:S.normalMapType===_u,tangentSpaceNormalMap:S.normalMapType===kn,clearcoat:ye,clearcoatMap:ye&&!!S.clearcoatMap,clearcoatRoughnessMap:ye&&!!S.clearcoatRoughnessMap,clearcoatNormalMap:ye&&!!S.clearcoatNormalMap,displacementMap:!!S.displacementMap,roughnessMap:!!S.roughnessMap,metalnessMap:!!S.metalnessMap,specularMap:!!S.specularMap,specularIntensityMap:!!S.specularIntensityMap,specularColorMap:!!S.specularColorMap,specularColorMapEncoding:m(S.specularColorMap),alphaMap:!!S.alphaMap,alphaTest:Ae,gradientMap:!!S.gradientMap,sheen:S.sheen>0,sheenColorMap:!!S.sheenColorMap,sheenColorMapEncoding:m(S.sheenColorMap),sheenRoughnessMap:!!S.sheenRoughnessMap,transmission:S.transmission>0,transmissionMap:!!S.transmissionMap,thicknessMap:!!S.thicknessMap,combine:S.combine,vertexTangents:!!S.normalMap&&!!D.geometry&&!!D.geometry.attributes.tangent,vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!D.geometry&&!!D.geometry.attributes.color&&D.geometry.attributes.color.itemSize===4,vertexUvs:!!S.map||!!S.bumpMap||!!S.normalMap||!!S.specularMap||!!S.alphaMap||!!S.emissiveMap||!!S.roughnessMap||!!S.metalnessMap||!!S.clearcoatMap||!!S.clearcoatRoughnessMap||!!S.clearcoatNormalMap||!!S.displacementMap||!!S.transmissionMap||!!S.thicknessMap||!!S.specularIntensityMap||!!S.specularColorMap||!!S.sheenColorMap||!!S.sheenRoughnessMap,uvsVertexOnly:!(!!S.map||!!S.bumpMap||!!S.normalMap||!!S.specularMap||!!S.alphaMap||!!S.emissiveMap||!!S.roughnessMap||!!S.metalnessMap||!!S.clearcoatNormalMap||S.transmission>0||!!S.transmissionMap||!!S.thicknessMap||!!S.specularIntensityMap||!!S.specularColorMap||S.sheen>0||!!S.sheenColorMap||!!S.sheenRoughnessMap)&&!!S.displacementMap,fog:!!B,useFog:S.fog,fogExp2:B&&B.isFogExp2,flatShading:!!S.flatShading,sizeAttenuation:S.sizeAttenuation,logarithmicDepthBuffer:u,skinning:D.isSkinnedMesh===!0&&G>0,maxBones:G,useVertexTexture:d,morphTargets:!!D.geometry&&!!D.geometry.morphAttributes.position,morphNormals:!!D.geometry&&!!D.geometry.morphAttributes.normal,morphTargetsCount:!!D.geometry&&!!D.geometry.morphAttributes.position?D.geometry.morphAttributes.position.length:0,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,format:S.format,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&N.length>0,shadowMapType:r.shadowMap.type,toneMapping:S.toneMapped?r.toneMapping:gn,physicallyCorrectLights:r.physicallyCorrectLights,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Un,flipSided:S.side===it,depthPacking:S.depthPacking!==void 0?S.depthPacking:!1,index0AttributeName:S.index0AttributeName,extensionDerivatives:S.extensions&&S.extensions.derivatives,extensionFragDepth:S.extensions&&S.extensions.fragDepth,extensionDrawBuffers:S.extensions&&S.extensions.drawBuffers,extensionShaderTextureLOD:S.extensions&&S.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:S.customProgramCacheKey()}}function y(S){const b=[];if(S.shaderID?b.push(S.shaderID):(b.push(S.customVertexShaderID),b.push(S.customFragmentShaderID)),S.defines!==void 0)for(const N in S.defines)b.push(N),b.push(S.defines[N]);return S.isRawShaderMaterial===!1&&(E(b,S),C(b,S),b.push(r.outputEncoding)),b.push(S.customProgramCacheKey),b.join()}function E(S,b){S.push(b.precision),S.push(b.outputEncoding),S.push(b.mapEncoding),S.push(b.matcapEncoding),S.push(b.envMapMode),S.push(b.envMapEncoding),S.push(b.lightMapEncoding),S.push(b.emissiveMapEncoding),S.push(b.combine),S.push(b.vertexUvs),S.push(b.fogExp2),S.push(b.sizeAttenuation),S.push(b.maxBones),S.push(b.morphTargetsCount),S.push(b.numDirLights),S.push(b.numPointLights),S.push(b.numSpotLights),S.push(b.numHemiLights),S.push(b.numRectAreaLights),S.push(b.numDirLightShadows),S.push(b.numPointLightShadows),S.push(b.numSpotLightShadows),S.push(b.shadowMapType),S.push(b.toneMapping),S.push(b.numClippingPlanes),S.push(b.numClipIntersection),S.push(b.format),S.push(b.specularColorMapEncoding),S.push(b.sheenColorMapEncoding)}function C(S,b){a.disableAll(),b.isWebGL2&&a.enable(0),b.supportsVertexTextures&&a.enable(1),b.instancing&&a.enable(2),b.instancingColor&&a.enable(3),b.map&&a.enable(4),b.matcap&&a.enable(5),b.envMap&&a.enable(6),b.envMapCubeUV&&a.enable(7),b.lightMap&&a.enable(8),b.aoMap&&a.enable(9),b.emissiveMap&&a.enable(10),b.bumpMap&&a.enable(11),b.normalMap&&a.enable(12),b.objectSpaceNormalMap&&a.enable(13),b.tangentSpaceNormalMap&&a.enable(14),b.clearcoat&&a.enable(15),b.clearcoatMap&&a.enable(16),b.clearcoatRoughnessMap&&a.enable(17),b.clearcoatNormalMap&&a.enable(18),b.displacementMap&&a.enable(19),b.specularMap&&a.enable(20),b.roughnessMap&&a.enable(21),b.metalnessMap&&a.enable(22),b.gradientMap&&a.enable(23),b.alphaMap&&a.enable(24),b.alphaTest&&a.enable(25),b.vertexColors&&a.enable(26),b.vertexAlphas&&a.enable(27),b.vertexUvs&&a.enable(28),b.vertexTangents&&a.enable(29),b.uvsVertexOnly&&a.enable(30),b.fog&&a.enable(31),S.push(a.mask),a.disableAll(),b.useFog&&a.enable(0),b.flatShading&&a.enable(1),b.logarithmicDepthBuffer&&a.enable(2),b.skinning&&a.enable(3),b.useVertexTexture&&a.enable(4),b.morphTargets&&a.enable(5),b.morphNormals&&a.enable(6),b.premultipliedAlpha&&a.enable(7),b.shadowMapEnabled&&a.enable(8),b.physicallyCorrectLights&&a.enable(9),b.doubleSided&&a.enable(10),b.flipSided&&a.enable(11),b.depthPacking&&a.enable(12),b.dithering&&a.enable(13),b.specularIntensityMap&&a.enable(14),b.specularColorMap&&a.enable(15),b.transmission&&a.enable(16),b.transmissionMap&&a.enable(17),b.thicknessMap&&a.enable(18),b.sheen&&a.enable(19),b.sheenColorMap&&a.enable(20),b.sheenRoughnessMap&&a.enable(21),S.push(a.mask)}function P(S){const b=_[S.type];let N;if(b){const O=It[b];N=jl.clone(O.uniforms)}else N=S.uniforms;return N}function V(S,b){let N;for(let O=0,D=c.length;O<D;O++){const B=c[O];if(B.cacheKey===b){N=B,++N.usedTimes;break}}return N===void 0&&(N=new Xm(r,b,S,s),c.push(N)),N}function ne(S){if(--S.usedTimes===0){const b=c.indexOf(S);c[b]=c[c.length-1],c.pop(),S.destroy()}}function Z(S){l.remove(S)}function I(){l.dispose()}return{getParameters:R,getProgramCacheKey:y,getUniforms:P,acquireProgram:V,releaseProgram:ne,releaseShaderCache:Z,programs:c,dispose:I}}function $m(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function n(s,o,a){r.get(s)[o]=a}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function Qm(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function ja(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function Xa(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(u,d,f,g,x,_){let p=r[e];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:g,renderOrder:u.renderOrder,z:x,group:_},r[e]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=g,p.renderOrder=u.renderOrder,p.z=x,p.group=_),e++,p}function a(u,d,f,g,x,_){const p=o(u,d,f,g,x,_);f.transmission>0?n.push(p):f.transparent===!0?i.push(p):t.push(p)}function l(u,d,f,g,x,_){const p=o(u,d,f,g,x,_);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):t.unshift(p)}function c(u,d){t.length>1&&t.sort(u||Qm),n.length>1&&n.sort(d||ja),i.length>1&&i.sort(d||ja)}function h(){for(let u=e,d=r.length;u<d;u++){const f=r[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:l,finish:h,sort:c}}function eg(){let r=new WeakMap;function e(n,i){let s;return r.has(n)===!1?(s=new Xa,r.set(n,[s])):i>=r.get(n).length?(s=new Xa,r.get(n).push(s)):s=r.get(n)[i],s}function t(){r=new WeakMap}return{get:e,dispose:t}}function tg(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new T,color:new ue};break;case"SpotLight":t={position:new T,direction:new T,color:new ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new T,color:new ue,distance:0,decay:0};break;case"HemisphereLight":t={direction:new T,skyColor:new ue,groundColor:new ue};break;case"RectAreaLight":t={color:new ue,position:new T,halfWidth:new T,halfHeight:new T};break}return r[e.id]=t,t}}}function ng(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let ig=0;function sg(r,e){return(e.castShadow?1:0)-(r.castShadow?1:0)}function rg(r,e){const t=new tg,n=ng(),i={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++)i.probe.push(new T);const s=new T,o=new pe,a=new pe;function l(h,u){let d=0,f=0,g=0;for(let ne=0;ne<9;ne++)i.probe[ne].set(0,0,0);let x=0,_=0,p=0,m=0,R=0,y=0,E=0,C=0;h.sort(sg);const P=u!==!0?Math.PI:1;for(let ne=0,Z=h.length;ne<Z;ne++){const I=h[ne],S=I.color,b=I.intensity,N=I.distance,O=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)d+=S.r*b*P,f+=S.g*b*P,g+=S.b*b*P;else if(I.isLightProbe)for(let D=0;D<9;D++)i.probe[D].addScaledVector(I.sh.coefficients[D],b);else if(I.isDirectionalLight){const D=t.get(I);if(D.color.copy(I.color).multiplyScalar(I.intensity*P),I.castShadow){const B=I.shadow,te=n.get(I);te.shadowBias=B.bias,te.shadowNormalBias=B.normalBias,te.shadowRadius=B.radius,te.shadowMapSize=B.mapSize,i.directionalShadow[x]=te,i.directionalShadowMap[x]=O,i.directionalShadowMatrix[x]=I.shadow.matrix,y++}i.directional[x]=D,x++}else if(I.isSpotLight){const D=t.get(I);if(D.position.setFromMatrixPosition(I.matrixWorld),D.color.copy(S).multiplyScalar(b*P),D.distance=N,D.coneCos=Math.cos(I.angle),D.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),D.decay=I.decay,I.castShadow){const B=I.shadow,te=n.get(I);te.shadowBias=B.bias,te.shadowNormalBias=B.normalBias,te.shadowRadius=B.radius,te.shadowMapSize=B.mapSize,i.spotShadow[p]=te,i.spotShadowMap[p]=O,i.spotShadowMatrix[p]=I.shadow.matrix,C++}i.spot[p]=D,p++}else if(I.isRectAreaLight){const D=t.get(I);D.color.copy(S).multiplyScalar(b),D.halfWidth.set(I.width*.5,0,0),D.halfHeight.set(0,I.height*.5,0),i.rectArea[m]=D,m++}else if(I.isPointLight){const D=t.get(I);if(D.color.copy(I.color).multiplyScalar(I.intensity*P),D.distance=I.distance,D.decay=I.decay,I.castShadow){const B=I.shadow,te=n.get(I);te.shadowBias=B.bias,te.shadowNormalBias=B.normalBias,te.shadowRadius=B.radius,te.shadowMapSize=B.mapSize,te.shadowCameraNear=B.camera.near,te.shadowCameraFar=B.camera.far,i.pointShadow[_]=te,i.pointShadowMap[_]=O,i.pointShadowMatrix[_]=I.shadow.matrix,E++}i.point[_]=D,_++}else if(I.isHemisphereLight){const D=t.get(I);D.skyColor.copy(I.color).multiplyScalar(b*P),D.groundColor.copy(I.groundColor).multiplyScalar(b*P),i.hemi[R]=D,R++}}m>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=oe.LTC_FLOAT_1,i.rectAreaLTC2=oe.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=oe.LTC_HALF_1,i.rectAreaLTC2=oe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=g;const V=i.hash;(V.directionalLength!==x||V.pointLength!==_||V.spotLength!==p||V.rectAreaLength!==m||V.hemiLength!==R||V.numDirectionalShadows!==y||V.numPointShadows!==E||V.numSpotShadows!==C)&&(i.directional.length=x,i.spot.length=p,i.rectArea.length=m,i.point.length=_,i.hemi.length=R,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=E,i.spotShadowMatrix.length=C,V.directionalLength=x,V.pointLength=_,V.spotLength=p,V.rectAreaLength=m,V.hemiLength=R,V.numDirectionalShadows=y,V.numPointShadows=E,V.numSpotShadows=C,i.version=ig++)}function c(h,u){let d=0,f=0,g=0,x=0,_=0;const p=u.matrixWorldInverse;for(let m=0,R=h.length;m<R;m++){const y=h[m];if(y.isDirectionalLight){const E=i.directional[d];E.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),d++}else if(y.isSpotLight){const E=i.spot[g];E.position.setFromMatrixPosition(y.matrixWorld),E.position.applyMatrix4(p),E.direction.setFromMatrixPosition(y.matrixWorld),s.setFromMatrixPosition(y.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),g++}else if(y.isRectAreaLight){const E=i.rectArea[x];E.position.setFromMatrixPosition(y.matrixWorld),E.position.applyMatrix4(p),a.identity(),o.copy(y.matrixWorld),o.premultiply(p),a.extractRotation(o),E.halfWidth.set(y.width*.5,0,0),E.halfHeight.set(0,y.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),x++}else if(y.isPointLight){const E=i.point[f];E.position.setFromMatrixPosition(y.matrixWorld),E.position.applyMatrix4(p),f++}else if(y.isHemisphereLight){const E=i.hemi[_];E.direction.setFromMatrixPosition(y.matrixWorld),E.direction.transformDirection(p),E.direction.normalize(),_++}}}return{setup:l,setupView:c,state:i}}function Ya(r,e){const t=new rg(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function o(u){n.push(u)}function a(u){i.push(u)}function l(u){t.setup(n,u)}function c(u){t.setupView(n,u)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function og(r,e){let t=new WeakMap;function n(s,o=0){let a;return t.has(s)===!1?(a=new Ya(r,e),t.set(s,[a])):o>=t.get(s).length?(a=new Ya(r,e),t.get(s).push(a)):a=t.get(s)[o],a}function i(){t=new WeakMap}return{get:n,dispose:i}}class oc extends rt{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=gu,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)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}oc.prototype.isMeshDepthMaterial=!0;class ac extends rt{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new T,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}ac.prototype.isMeshDistanceMaterial=!0;const ag=`void main() {
  2921. gl_Position = vec4( position, 1.0 );
  2922. }`,lg=`uniform sampler2D shadow_pass;
  2923. uniform vec2 resolution;
  2924. uniform float radius;
  2925. #include <packing>
  2926. void main() {
  2927. const float samples = float( VSM_SAMPLES );
  2928. float mean = 0.0;
  2929. float squared_mean = 0.0;
  2930. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  2931. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  2932. for ( float i = 0.0; i < samples; i ++ ) {
  2933. float uvOffset = uvStart + i * uvStride;
  2934. #ifdef HORIZONTAL_PASS
  2935. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  2936. mean += distribution.x;
  2937. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  2938. #else
  2939. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  2940. mean += depth;
  2941. squared_mean += depth * depth;
  2942. #endif
  2943. }
  2944. mean = mean / samples;
  2945. squared_mean = squared_mean / samples;
  2946. float std_dev = sqrt( squared_mean - mean * mean );
  2947. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  2948. }`;function lc(r,e,t){let n=new lr;const i=new j,s=new j,o=new qe,a=new oc({depthPacking:xu}),l=new ac,c={},h=t.maxTextureSize,u={0:it,1:yi,2:Un},d=new bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new j},radius:{value:4}},vertexShader:ag,fragmentShader:lg}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new Xe;g.setAttribute("position",new $e(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new xt(g,d),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Pl,this.render=function(y,E,C){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||y.length===0)return;const P=r.getRenderTarget(),V=r.getActiveCubeFace(),ne=r.getActiveMipmapLevel(),Z=r.state;Z.setBlending(mn),Z.buffers.color.setClear(1,1,1,1),Z.buffers.depth.setTest(!0),Z.setScissorTest(!1);for(let I=0,S=y.length;I<S;I++){const b=y[I],N=b.shadow;if(N===void 0){console.warn("THREE.WebGLShadowMap:",b,"has no shadow.");continue}if(N.autoUpdate===!1&&N.needsUpdate===!1)continue;i.copy(N.mapSize);const O=N.getFrameExtents();if(i.multiply(O),s.copy(N.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/O.x),i.x=s.x*O.x,N.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/O.y),i.y=s.y*O.y,N.mapSize.y=s.y)),N.map===null&&!N.isPointLightShadow&&this.type===Yi){const B={minFilter:ht,magFilter:ht,format:st};N.map=new Et(i.x,i.y,B),N.map.texture.name=b.name+".shadowMap",N.mapPass=new Et(i.x,i.y,B),N.camera.updateProjectionMatrix()}if(N.map===null){const B={minFilter:Qe,magFilter:Qe,format:st};N.map=new Et(i.x,i.y,B),N.map.texture.name=b.name+".shadowMap",N.camera.updateProjectionMatrix()}r.setRenderTarget(N.map),r.clear();const D=N.getViewportCount();for(let B=0;B<D;B++){const te=N.getViewport(B);o.set(s.x*te.x,s.y*te.y,s.x*te.z,s.y*te.w),Z.viewport(o),N.updateMatrices(b,B),n=N.getFrustum(),R(E,C,N.camera,b,this.type)}!N.isPointLightShadow&&this.type===Yi&&p(N,C),N.needsUpdate=!1}_.needsUpdate=!1,r.setRenderTarget(P,V,ne)};function p(y,E){const C=e.update(x);d.defines.VSM_SAMPLES!==y.blurSamples&&(d.defines.VSM_SAMPLES=y.blurSamples,f.defines.VSM_SAMPLES=y.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),d.uniforms.shadow_pass.value=y.map.texture,d.uniforms.resolution.value=y.mapSize,d.uniforms.radius.value=y.radius,r.setRenderTarget(y.mapPass),r.clear(),r.renderBufferDirect(E,null,C,d,x,null),f.uniforms.shadow_pass.value=y.mapPass.texture,f.uniforms.resolution.value=y.mapSize,f.uniforms.radius.value=y.radius,r.setRenderTarget(y.map),r.clear(),r.renderBufferDirect(E,null,C,f,x,null)}function m(y,E,C,P,V,ne,Z){let I=null;const S=P.isPointLight===!0?y.customDistanceMaterial:y.customDepthMaterial;if(S!==void 0?I=S:I=P.isPointLight===!0?l:a,r.localClippingEnabled&&C.clipShadows===!0&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0){const b=I.uuid,N=C.uuid;let O=c[b];O===void 0&&(O={},c[b]=O);let D=O[N];D===void 0&&(D=I.clone(),O[N]=D),I=D}return I.visible=C.visible,I.wireframe=C.wireframe,Z===Yi?I.side=C.shadowSide!==null?C.shadowSide:C.side:I.side=C.shadowSide!==null?C.shadowSide:u[C.side],I.alphaMap=C.alphaMap,I.alphaTest=C.alphaTest,I.clipShadows=C.clipShadows,I.clippingPlanes=C.clippingPlanes,I.clipIntersection=C.clipIntersection,I.displacementMap=C.displacementMap,I.displacementScale=C.displacementScale,I.displacementBias=C.displacementBias,I.wireframeLinewidth=C.wireframeLinewidth,I.linewidth=C.linewidth,P.isPointLight===!0&&I.isMeshDistanceMaterial===!0&&(I.referencePosition.setFromMatrixPosition(P.matrixWorld),I.nearDistance=V,I.farDistance=ne),I}function R(y,E,C,P,V){if(y.visible===!1)return;if(y.layers.test(E.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&V===Yi)&&(!y.frustumCulled||n.intersectsObject(y))){y.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,y.matrixWorld);const I=e.update(y),S=y.material;if(Array.isArray(S)){const b=I.groups;for(let N=0,O=b.length;N<O;N++){const D=b[N],B=S[D.materialIndex];if(B&&B.visible){const te=m(y,I,B,P,C.near,C.far,V);r.renderBufferDirect(C,null,I,te,y,D)}}}else if(S.visible){const b=m(y,I,S,P,C.near,C.far,V);r.renderBufferDirect(C,null,I,b,y,null)}}const Z=y.children;for(let I=0,S=Z.length;I<S;I++)R(Z[I],E,C,P,V)}}function cg(r,e,t){const n=t.isWebGL2;function i(){let w=!1;const J=new qe;let Y=null;const _e=new qe(0,0,0,0);return{setMask:function(de){Y!==de&&!w&&(r.colorMask(de,de,de,de),Y=de)},setLocked:function(de){w=de},setClear:function(de,Se,re,ve,Fe){Fe===!0&&(de*=ve,Se*=ve,re*=ve),J.set(de,Se,re,ve),_e.equals(J)===!1&&(r.clearColor(de,Se,re,ve),_e.copy(J))},reset:function(){w=!1,Y=null,_e.set(-1,0,0,0)}}}function s(){let w=!1,J=null,Y=null,_e=null;return{setTest:function(de){de?ae(2929):fe(2929)},setMask:function(de){J!==de&&!w&&(r.depthMask(de),J=de)},setFunc:function(de){if(Y!==de){if(de)switch(de){case oh:r.depthFunc(512);break;case ah:r.depthFunc(519);break;case lh:r.depthFunc(513);break;case to:r.depthFunc(515);break;case ch:r.depthFunc(514);break;case hh:r.depthFunc(518);break;case uh:r.depthFunc(516);break;case dh:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);Y=de}},setLocked:function(de){w=de},setClear:function(de){_e!==de&&(r.clearDepth(de),_e=de)},reset:function(){w=!1,J=null,Y=null,_e=null}}}function o(){let w=!1,J=null,Y=null,_e=null,de=null,Se=null,re=null,ve=null,Fe=null;return{setTest:function(We){w||(We?ae(2960):fe(2960))},setMask:function(We){J!==We&&!w&&(r.stencilMask(We),J=We)},setFunc:function(We,Nt,Ft){(Y!==We||_e!==Nt||de!==Ft)&&(r.stencilFunc(We,Nt,Ft),Y=We,_e=Nt,de=Ft)},setOp:function(We,Nt,Ft){(Se!==We||re!==Nt||ve!==Ft)&&(r.stencilOp(We,Nt,Ft),Se=We,re=Nt,ve=Ft)},setLocked:function(We){w=We},setClear:function(We){Fe!==We&&(r.clearStencil(We),Fe=We)},reset:function(){w=!1,J=null,Y=null,_e=null,de=null,Se=null,re=null,ve=null,Fe=null}}}const a=new i,l=new s,c=new o;let h={},u={},d=null,f=!1,g=null,x=null,_=null,p=null,m=null,R=null,y=null,E=!1,C=null,P=null,V=null,ne=null,Z=null;const I=r.getParameter(35661);let S=!1,b=0;const N=r.getParameter(7938);N.indexOf("WebGL")!==-1?(b=parseFloat(/^WebGL (\d)/.exec(N)[1]),S=b>=1):N.indexOf("OpenGL ES")!==-1&&(b=parseFloat(/^OpenGL ES (\d)/.exec(N)[1]),S=b>=2);let O=null,D={};const B=r.getParameter(3088),te=r.getParameter(2978),le=new qe().fromArray(B),k=new qe().fromArray(te);function G(w,J,Y){const _e=new Uint8Array(4),de=r.createTexture();r.bindTexture(w,de),r.texParameteri(w,10241,9728),r.texParameteri(w,10240,9728);for(let Se=0;Se<Y;Se++)r.texImage2D(J+Se,0,6408,1,1,0,6408,5121,_e);return de}const ce={};ce[3553]=G(3553,3553,1),ce[34067]=G(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),ae(2929),l.setFunc(to),Ne(!1),H(Qo),ae(2884),me(mn);function ae(w){h[w]!==!0&&(r.enable(w),h[w]=!0)}function fe(w){h[w]!==!1&&(r.disable(w),h[w]=!1)}function Ce(w,J){return u[w]!==J?(r.bindFramebuffer(w,J),u[w]=J,n&&(w===36009&&(u[36160]=J),w===36160&&(u[36009]=J)),!0):!1}function X(w){return d!==w?(r.useProgram(w),d=w,!0):!1}const Ae={[ui]:32774,[Zc]:32778,[Jc]:32779};if(n)Ae[ia]=32775,Ae[sa]=32776;else{const w=e.get("EXT_blend_minmax");w!==null&&(Ae[ia]=w.MIN_EXT,Ae[sa]=w.MAX_EXT)}const ye={[Kc]:0,[$c]:1,[Qc]:768,[Nl]:770,[rh]:776,[ih]:774,[th]:772,[eh]:769,[Fl]:771,[sh]:775,[nh]:773};function me(w,J,Y,_e,de,Se,re,ve){if(w===mn){f===!0&&(fe(3042),f=!1);return}if(f===!1&&(ae(3042),f=!0),w!==Yc){if(w!==g||ve!==E){if((x!==ui||m!==ui)&&(r.blendEquation(32774),x=ui,m=ui),ve)switch(w){case Ji:r.blendFuncSeparate(1,771,1,771);break;case ea:r.blendFunc(1,1);break;case ta:r.blendFuncSeparate(0,0,769,771);break;case na:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",w);break}else switch(w){case Ji:r.blendFuncSeparate(770,771,1,771);break;case ea:r.blendFunc(770,1);break;case ta:r.blendFunc(0,769);break;case na:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",w);break}_=null,p=null,R=null,y=null,g=w,E=ve}return}de=de||J,Se=Se||Y,re=re||_e,(J!==x||de!==m)&&(r.blendEquationSeparate(Ae[J],Ae[de]),x=J,m=de),(Y!==_||_e!==p||Se!==R||re!==y)&&(r.blendFuncSeparate(ye[Y],ye[_e],ye[Se],ye[re]),_=Y,p=_e,R=Se,y=re),g=w,E=null}function ge(w,J){w.side===Un?fe(2884):ae(2884);let Y=w.side===it;J&&(Y=!Y),Ne(Y),w.blending===Ji&&w.transparent===!1?me(mn):me(w.blending,w.blendEquation,w.blendSrc,w.blendDst,w.blendEquationAlpha,w.blendSrcAlpha,w.blendDstAlpha,w.premultipliedAlpha),l.setFunc(w.depthFunc),l.setTest(w.depthTest),l.setMask(w.depthWrite),a.setMask(w.colorWrite);const _e=w.stencilWrite;c.setTest(_e),_e&&(c.setMask(w.stencilWriteMask),c.setFunc(w.stencilFunc,w.stencilRef,w.stencilFuncMask),c.setOp(w.stencilFail,w.stencilZFail,w.stencilZPass)),ee(w.polygonOffset,w.polygonOffsetFactor,w.polygonOffsetUnits),w.alphaToCoverage===!0?ae(32926):fe(32926)}function Ne(w){C!==w&&(w?r.frontFace(2304):r.frontFace(2305),C=w)}function H(w){w!==jc?(ae(2884),w!==P&&(w===Qo?r.cullFace(1029):w===Xc?r.cullFace(1028):r.cullFace(1032))):fe(2884),P=w}function Q(w){w!==V&&(S&&r.lineWidth(w),V=w)}function ee(w,J,Y){w?(ae(32823),(ne!==J||Z!==Y)&&(r.polygonOffset(J,Y),ne=J,Z=Y)):fe(32823)}function he(w){w?ae(3089):fe(3089)}function ie(w){w===void 0&&(w=33984+I-1),O!==w&&(r.activeTexture(w),O=w)}function be(w,J){O===null&&ie();let Y=D[O];Y===void 0&&(Y={type:void 0,texture:void 0},D[O]=Y),(Y.type!==w||Y.texture!==J)&&(r.bindTexture(w,J||ce[w]),Y.type=w,Y.texture=J)}function we(){const w=D[O];w!==void 0&&w.type!==void 0&&(r.bindTexture(w.type,null),w.type=void 0,w.texture=void 0)}function Re(){try{r.compressedTexImage2D.apply(r,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Ve(){try{r.texSubImage2D.apply(r,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function A(){try{r.texSubImage3D.apply(r,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function v(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function q(){try{r.texStorage2D.apply(r,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function $(){try{r.texStorage3D.apply(r,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function se(){try{r.texImage2D.apply(r,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function K(){try{r.texImage3D.apply(r,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Me(w){le.equals(w)===!1&&(r.scissor(w.x,w.y,w.z,w.w),le.copy(w))}function xe(w){k.equals(w)===!1&&(r.viewport(w.x,w.y,w.z,w.w),k.copy(w))}function L(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},O=null,D={},u={},d=null,f=!1,g=null,x=null,_=null,p=null,m=null,R=null,y=null,E=!1,C=null,P=null,V=null,ne=null,Z=null,le.set(0,0,r.canvas.width,r.canvas.height),k.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:ae,disable:fe,bindFramebuffer:Ce,useProgram:X,setBlending:me,setMaterial:ge,setFlipSided:Ne,setCullFace:H,setLineWidth:Q,setPolygonOffset:ee,setScissorTest:he,activeTexture:ie,bindTexture:be,unbindTexture:we,compressedTexImage2D:Re,texImage2D:se,texImage3D:K,texStorage2D:q,texStorage3D:$,texSubImage2D:Ve,texSubImage3D:A,compressedTexSubImage2D:v,scissor:Me,viewport:xe,reset:L}}function hg(r,e,t,n,i,s,o){const a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,f=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):void 0,g=new WeakMap;let x,_=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(A,v){return _?new OffscreenCanvas(A,v):or("canvas")}function m(A,v,q,$){let se=1;if((A.width>$||A.height>$)&&(se=$/Math.max(A.width,A.height)),se<1||v===!0)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap){const K=v?kl:Math.floor,Me=K(se*A.width),xe=K(se*A.height);x===void 0&&(x=p(Me,xe));const L=q?p(Me,xe):x;return L.width=Me,L.height=xe,L.getContext("2d").drawImage(A,0,0,Me,xe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+A.width+"x"+A.height+") to ("+Me+"x"+xe+")."),L}else return"data"in A&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+A.width+"x"+A.height+")."),A;return A}function R(A){return oo(A.width)&&oo(A.height)}function y(A){return a?!1:A.wrapS!==yt||A.wrapT!==yt||A.minFilter!==Qe&&A.minFilter!==ht}function E(A,v){return A.generateMipmaps&&v&&A.minFilter!==Qe&&A.minFilter!==ht}function C(A){r.generateMipmap(A)}function P(A,v,q,$){if(a===!1)return v;if(A!==null){if(r[A]!==void 0)return r[A];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let se=v;return v===6403&&(q===5126&&(se=33326),q===5131&&(se=33325),q===5121&&(se=33321)),v===6407&&(q===5126&&(se=34837),q===5131&&(se=34843),q===5121&&(se=32849)),v===6408&&(q===5126&&(se=34836),q===5131&&(se=34842),q===5121&&(se=$===Ht?35907:32856)),(se===33325||se===33326||se===34842||se===34836)&&e.get("EXT_color_buffer_float"),se}function V(A,v,q){return E(A,q)===!0||A.isFramebufferTexture&&A.minFilter!==Qe&&A.minFilter!==ht?Math.log2(Math.max(v.width,v.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?v.mipmaps.length:1}function ne(A){return A===Qe||A===so||A===ro?9728:9729}function Z(A){const v=A.target;v.removeEventListener("dispose",Z),S(v),v.isVideoTexture&&g.delete(v),o.memory.textures--}function I(A){const v=A.target;v.removeEventListener("dispose",I),b(v)}function S(A){const v=n.get(A);v.__webglInit!==void 0&&(r.deleteTexture(v.__webglTexture),n.remove(A))}function b(A){const v=A.texture,q=n.get(A),$=n.get(v);if(!!A){if($.__webglTexture!==void 0&&(r.deleteTexture($.__webglTexture),o.memory.textures--),A.depthTexture&&A.depthTexture.dispose(),A.isWebGLCubeRenderTarget)for(let se=0;se<6;se++)r.deleteFramebuffer(q.__webglFramebuffer[se]),q.__webglDepthbuffer&&r.deleteRenderbuffer(q.__webglDepthbuffer[se]);else r.deleteFramebuffer(q.__webglFramebuffer),q.__webglDepthbuffer&&r.deleteRenderbuffer(q.__webglDepthbuffer),q.__webglMultisampledFramebuffer&&r.deleteFramebuffer(q.__webglMultisampledFramebuffer),q.__webglColorRenderbuffer&&r.deleteRenderbuffer(q.__webglColorRenderbuffer),q.__webglDepthRenderbuffer&&r.deleteRenderbuffer(q.__webglDepthRenderbuffer);if(A.isWebGLMultipleRenderTargets)for(let se=0,K=v.length;se<K;se++){const Me=n.get(v[se]);Me.__webglTexture&&(r.deleteTexture(Me.__webglTexture),o.memory.textures--),n.remove(v[se])}n.remove(v),n.remove(A)}}let N=0;function O(){N=0}function D(){const A=N;return A>=l&&console.warn("THREE.WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+l),N+=1,A}function B(A,v){const q=n.get(A);if(A.isVideoTexture&&ie(A),A.version>0&&q.__version!==A.version){const $=A.image;if($===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if($.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(q,A,v);return}}t.activeTexture(33984+v),t.bindTexture(3553,q.__webglTexture)}function te(A,v){const q=n.get(A);if(A.version>0&&q.__version!==A.version){Ce(q,A,v);return}t.activeTexture(33984+v),t.bindTexture(35866,q.__webglTexture)}function le(A,v){const q=n.get(A);if(A.version>0&&q.__version!==A.version){Ce(q,A,v);return}t.activeTexture(33984+v),t.bindTexture(32879,q.__webglTexture)}function k(A,v){const q=n.get(A);if(A.version>0&&q.__version!==A.version){X(q,A,v);return}t.activeTexture(33984+v),t.bindTexture(34067,q.__webglTexture)}const G={[vi]:10497,[yt]:33071,[er]:33648},ce={[Qe]:9728,[so]:9984,[ro]:9986,[ht]:9729,[Bl]:9985,[Ei]:9987};function ae(A,v,q){if(q?(r.texParameteri(A,10242,G[v.wrapS]),r.texParameteri(A,10243,G[v.wrapT]),(A===32879||A===35866)&&r.texParameteri(A,32882,G[v.wrapR]),r.texParameteri(A,10240,ce[v.magFilter]),r.texParameteri(A,10241,ce[v.minFilter])):(r.texParameteri(A,10242,33071),r.texParameteri(A,10243,33071),(A===32879||A===35866)&&r.texParameteri(A,32882,33071),(v.wrapS!==yt||v.wrapT!==yt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(A,10240,ne(v.magFilter)),r.texParameteri(A,10241,ne(v.minFilter)),v.minFilter!==Qe&&v.minFilter!==ht&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const $=e.get("EXT_texture_filter_anisotropic");if(v.type===$t&&e.has("OES_texture_float_linear")===!1||a===!1&&v.type===Fn&&e.has("OES_texture_half_float_linear")===!1)return;(v.anisotropy>1||n.get(v).__currentAnisotropy)&&(r.texParameterf(A,$.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,i.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy)}}function fe(A,v){A.__webglInit===void 0&&(A.__webglInit=!0,v.addEventListener("dispose",Z),A.__webglTexture=r.createTexture(),o.memory.textures++)}function Ce(A,v,q){let $=3553;v.isDataTexture2DArray&&($=35866),v.isDataTexture3D&&($=32879),fe(A,v),t.activeTexture(33984+q),t.bindTexture($,A.__webglTexture),r.pixelStorei(37440,v.flipY),r.pixelStorei(37441,v.premultiplyAlpha),r.pixelStorei(3317,v.unpackAlignment),r.pixelStorei(37443,0);const se=y(v)&&R(v.image)===!1,K=m(v.image,se,!1,h),Me=R(K)||a,xe=s.convert(v.format);let L=s.convert(v.type),w=P(v.internalFormat,xe,L,v.encoding);ae($,v,Me);let J;const Y=v.mipmaps,_e=a&&v.isVideoTexture!==!0,de=A.__version===void 0,Se=V(v,K,Me);if(v.isDepthTexture)w=6402,a?v.type===$t?w=36012:v.type===Qs?w=33190:v.type===xi?w=35056:w=33189:v.type===$t&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),v.format===On&&w===6402&&v.type!==ts&&v.type!==Qs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),v.type=ts,L=s.convert(v.type)),v.format===Mi&&w===6402&&(w=34041,v.type!==xi&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),v.type=xi,L=s.convert(v.type))),_e&&de?t.texStorage2D(3553,1,w,K.width,K.height):t.texImage2D(3553,0,w,K.width,K.height,0,xe,L,null);else if(v.isDataTexture)if(Y.length>0&&Me){_e&&de&&t.texStorage2D(3553,Se,w,Y[0].width,Y[0].height);for(let re=0,ve=Y.length;re<ve;re++)J=Y[re],_e?t.texSubImage2D(3553,0,0,0,J.width,J.height,xe,L,J.data):t.texImage2D(3553,re,w,J.width,J.height,0,xe,L,J.data);v.generateMipmaps=!1}else _e?(de&&t.texStorage2D(3553,Se,w,K.width,K.height),t.texSubImage2D(3553,0,0,0,K.width,K.height,xe,L,K.data)):t.texImage2D(3553,0,w,K.width,K.height,0,xe,L,K.data);else if(v.isCompressedTexture){_e&&de&&t.texStorage2D(3553,Se,w,Y[0].width,Y[0].height);for(let re=0,ve=Y.length;re<ve;re++)J=Y[re],v.format!==st&&v.format!==xn?xe!==null?_e?t.compressedTexSubImage2D(3553,re,0,0,J.width,J.height,xe,J.data):t.compressedTexImage2D(3553,re,w,J.width,J.height,0,J.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):_e?t.texSubImage2D(3553,re,0,0,J.width,J.height,xe,L,J.data):t.texImage2D(3553,re,w,J.width,J.height,0,xe,L,J.data)}else if(v.isDataTexture2DArray)_e?(de&&t.texStorage3D(35866,Se,w,K.width,K.height,K.depth),t.texSubImage3D(35866,0,0,0,0,K.width,K.height,K.depth,xe,L,K.data)):t.texImage3D(35866,0,w,K.width,K.height,K.depth,0,xe,L,K.data);else if(v.isDataTexture3D)_e?(de&&t.texStorage3D(32879,Se,w,K.width,K.height,K.depth),t.texSubImage3D(32879,0,0,0,0,K.width,K.height,K.depth,xe,L,K.data)):t.texImage3D(32879,0,w,K.width,K.height,K.depth,0,xe,L,K.data);else if(v.isFramebufferTexture)_e&&de?t.texStorage2D(3553,Se,w,K.width,K.height):t.texImage2D(3553,0,w,K.width,K.height,0,xe,L,null);else if(Y.length>0&&Me){_e&&de&&t.texStorage2D(3553,Se,w,Y[0].width,Y[0].height);for(let re=0,ve=Y.length;re<ve;re++)J=Y[re],_e?t.texSubImage2D(3553,re,0,0,xe,L,J):t.texImage2D(3553,re,w,xe,L,J);v.generateMipmaps=!1}else _e?(de&&t.texStorage2D(3553,Se,w,K.width,K.height),t.texSubImage2D(3553,0,0,0,xe,L,K)):t.texImage2D(3553,0,w,xe,L,K);E(v,Me)&&C($),A.__version=v.version,v.onUpdate&&v.onUpdate(v)}function X(A,v,q){if(v.image.length!==6)return;fe(A,v),t.activeTexture(33984+q),t.bindTexture(34067,A.__webglTexture),r.pixelStorei(37440,v.flipY),r.pixelStorei(37441,v.premultiplyAlpha),r.pixelStorei(3317,v.unpackAlignment),r.pixelStorei(37443,0);const $=v&&(v.isCompressedTexture||v.image[0].isCompressedTexture),se=v.image[0]&&v.image[0].isDataTexture,K=[];for(let re=0;re<6;re++)!$&&!se?K[re]=m(v.image[re],!1,!0,c):K[re]=se?v.image[re].image:v.image[re];const Me=K[0],xe=R(Me)||a,L=s.convert(v.format),w=s.convert(v.type),J=P(v.internalFormat,L,w,v.encoding),Y=a&&v.isVideoTexture!==!0,_e=A.__version===void 0;let de=V(v,Me,xe);ae(34067,v,xe);let Se;if($){Y&&_e&&t.texStorage2D(34067,de,J,Me.width,Me.height);for(let re=0;re<6;re++){Se=K[re].mipmaps;for(let ve=0;ve<Se.length;ve++){const Fe=Se[ve];v.format!==st&&v.format!==xn?L!==null?Y?t.compressedTexSubImage2D(34069+re,ve,0,0,Fe.width,Fe.height,L,Fe.data):t.compressedTexImage2D(34069+re,ve,J,Fe.width,Fe.height,0,Fe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Y?t.texSubImage2D(34069+re,ve,0,0,Fe.width,Fe.height,L,w,Fe.data):t.texImage2D(34069+re,ve,J,Fe.width,Fe.height,0,L,w,Fe.data)}}}else{Se=v.mipmaps,Y&&_e&&(Se.length>0&&de++,t.texStorage2D(34067,de,J,K[0].width,K[0].height));for(let re=0;re<6;re++)if(se){Y?t.texSubImage2D(34069+re,0,0,0,K[re].width,K[re].height,L,w,K[re].data):t.texImage2D(34069+re,0,J,K[re].width,K[re].height,0,L,w,K[re].data);for(let ve=0;ve<Se.length;ve++){const We=Se[ve].image[re].image;Y?t.texSubImage2D(34069+re,ve+1,0,0,We.width,We.height,L,w,We.data):t.texImage2D(34069+re,ve+1,J,We.width,We.height,0,L,w,We.data)}}else{Y?t.texSubImage2D(34069+re,0,0,0,L,w,K[re]):t.texImage2D(34069+re,0,J,L,w,K[re]);for(let ve=0;ve<Se.length;ve++){const Fe=Se[ve];Y?t.texSubImage2D(34069+re,ve+1,0,0,L,w,Fe.image[re]):t.texImage2D(34069+re,ve+1,J,L,w,Fe.image[re])}}}E(v,xe)&&C(34067),A.__version=v.version,v.onUpdate&&v.onUpdate(v)}function Ae(A,v,q,$,se){const K=s.convert(q.format),Me=s.convert(q.type),xe=P(q.internalFormat,K,Me,q.encoding);n.get(v).__hasExternalTextures||(se===32879||se===35866?t.texImage3D(se,0,xe,v.width,v.height,v.depth,0,K,Me,null):t.texImage2D(se,0,xe,v.width,v.height,0,K,Me,null)),t.bindFramebuffer(36160,A),v.useRenderToTexture?f.framebufferTexture2DMultisampleEXT(36160,$,se,n.get(q).__webglTexture,0,he(v)):r.framebufferTexture2D(36160,$,se,n.get(q).__webglTexture,0),t.bindFramebuffer(36160,null)}function ye(A,v,q){if(r.bindRenderbuffer(36161,A),v.depthBuffer&&!v.stencilBuffer){let $=33189;if(q||v.useRenderToTexture){const se=v.depthTexture;se&&se.isDepthTexture&&(se.type===$t?$=36012:se.type===Qs&&($=33190));const K=he(v);v.useRenderToTexture?f.renderbufferStorageMultisampleEXT(36161,K,$,v.width,v.height):r.renderbufferStorageMultisample(36161,K,$,v.width,v.height)}else r.renderbufferStorage(36161,$,v.width,v.height);r.framebufferRenderbuffer(36160,36096,36161,A)}else if(v.depthBuffer&&v.stencilBuffer){const $=he(v);q&&v.useRenderbuffer?r.renderbufferStorageMultisample(36161,$,35056,v.width,v.height):v.useRenderToTexture?f.renderbufferStorageMultisampleEXT(36161,$,35056,v.width,v.height):r.renderbufferStorage(36161,34041,v.width,v.height),r.framebufferRenderbuffer(36160,33306,36161,A)}else{const $=v.isWebGLMultipleRenderTargets===!0?v.texture[0]:v.texture,se=s.convert($.format),K=s.convert($.type),Me=P($.internalFormat,se,K,$.encoding),xe=he(v);q&&v.useRenderbuffer?r.renderbufferStorageMultisample(36161,xe,Me,v.width,v.height):v.useRenderToTexture?f.renderbufferStorageMultisampleEXT(36161,xe,Me,v.width,v.height):r.renderbufferStorage(36161,Me,v.width,v.height)}r.bindRenderbuffer(36161,null)}function me(A,v){if(v&&v.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,A),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(v.depthTexture).__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),B(v.depthTexture,0);const $=n.get(v.depthTexture).__webglTexture,se=he(v);if(v.depthTexture.format===On)v.useRenderToTexture?f.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,se):r.framebufferTexture2D(36160,36096,3553,$,0);else if(v.depthTexture.format===Mi)v.useRenderToTexture?f.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,se):r.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function ge(A){const v=n.get(A),q=A.isWebGLCubeRenderTarget===!0;if(A.depthTexture&&!v.__autoAllocateDepthBuffer){if(q)throw new Error("target.depthTexture not supported in Cube render targets");me(v.__webglFramebuffer,A)}else if(q){v.__webglDepthbuffer=[];for(let $=0;$<6;$++)t.bindFramebuffer(36160,v.__webglFramebuffer[$]),v.__webglDepthbuffer[$]=r.createRenderbuffer(),ye(v.__webglDepthbuffer[$],A,!1)}else t.bindFramebuffer(36160,v.__webglFramebuffer),v.__webglDepthbuffer=r.createRenderbuffer(),ye(v.__webglDepthbuffer,A,!1);t.bindFramebuffer(36160,null)}function Ne(A,v,q){const $=n.get(A);v!==void 0&&Ae($.__webglFramebuffer,A,A.texture,36064,3553),q!==void 0&&ge(A)}function H(A){const v=A.texture,q=n.get(A),$=n.get(v);A.addEventListener("dispose",I),A.isWebGLMultipleRenderTargets!==!0&&($.__webglTexture===void 0&&($.__webglTexture=r.createTexture()),$.__version=v.version,o.memory.textures++);const se=A.isWebGLCubeRenderTarget===!0,K=A.isWebGLMultipleRenderTargets===!0,Me=v.isDataTexture3D||v.isDataTexture2DArray,xe=R(A)||a;if(a&&v.format===xn&&(v.type===$t||v.type===Fn)&&(v.format=st,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),se){q.__webglFramebuffer=[];for(let L=0;L<6;L++)q.__webglFramebuffer[L]=r.createFramebuffer()}else if(q.__webglFramebuffer=r.createFramebuffer(),K)if(i.drawBuffers){const L=A.texture;for(let w=0,J=L.length;w<J;w++){const Y=n.get(L[w]);Y.__webglTexture===void 0&&(Y.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(A.useRenderbuffer)if(a){q.__webglMultisampledFramebuffer=r.createFramebuffer(),q.__webglColorRenderbuffer=r.createRenderbuffer(),r.bindRenderbuffer(36161,q.__webglColorRenderbuffer);const L=s.convert(v.format),w=s.convert(v.type),J=P(v.internalFormat,L,w,v.encoding),Y=he(A);r.renderbufferStorageMultisample(36161,Y,J,A.width,A.height),t.bindFramebuffer(36160,q.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064,36161,q.__webglColorRenderbuffer),r.bindRenderbuffer(36161,null),A.depthBuffer&&(q.__webglDepthRenderbuffer=r.createRenderbuffer(),ye(q.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(se){t.bindTexture(34067,$.__webglTexture),ae(34067,v,xe);for(let L=0;L<6;L++)Ae(q.__webglFramebuffer[L],A,v,36064,34069+L);E(v,xe)&&C(34067),t.unbindTexture()}else if(K){const L=A.texture;for(let w=0,J=L.length;w<J;w++){const Y=L[w],_e=n.get(Y);t.bindTexture(3553,_e.__webglTexture),ae(3553,Y,xe),Ae(q.__webglFramebuffer,A,Y,36064+w,3553),E(Y,xe)&&C(3553)}t.unbindTexture()}else{let L=3553;Me&&(a?L=v.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),t.bindTexture(L,$.__webglTexture),ae(L,v,xe),Ae(q.__webglFramebuffer,A,v,36064,L),E(v,xe)&&C(L),t.unbindTexture()}A.depthBuffer&&ge(A)}function Q(A){const v=R(A)||a,q=A.isWebGLMultipleRenderTargets===!0?A.texture:[A.texture];for(let $=0,se=q.length;$<se;$++){const K=q[$];if(E(K,v)){const Me=A.isWebGLCubeRenderTarget?34067:3553,xe=n.get(K).__webglTexture;t.bindTexture(Me,xe),C(Me),t.unbindTexture()}}}function ee(A){if(A.useRenderbuffer)if(a){const v=A.width,q=A.height;let $=16384;const se=[36064],K=A.stencilBuffer?33306:36096;A.depthBuffer&&se.push(K),A.ignoreDepthForMultisampleCopy||(A.depthBuffer&&($|=256),A.stencilBuffer&&($|=1024));const Me=n.get(A);t.bindFramebuffer(36008,Me.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,Me.__webglFramebuffer),A.ignoreDepthForMultisampleCopy&&(r.invalidateFramebuffer(36008,[K]),r.invalidateFramebuffer(36009,[K])),r.blitFramebuffer(0,0,v,q,0,0,v,q,$,9728),r.invalidateFramebuffer(36008,se),t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,Me.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function he(A){return a&&(A.useRenderbuffer||A.useRenderToTexture)?Math.min(u,A.samples):0}function ie(A){const v=o.render.frame;g.get(A)!==v&&(g.set(A,v),A.update())}let be=!1,we=!1;function Re(A,v){A&&A.isWebGLRenderTarget&&(be===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),be=!0),A=A.texture),B(A,v)}function Ve(A,v){A&&A.isWebGLCubeRenderTarget&&(we===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),we=!0),A=A.texture),k(A,v)}this.allocateTextureUnit=D,this.resetTextureUnits=O,this.setTexture2D=B,this.setTexture2DArray=te,this.setTexture3D=le,this.setTextureCube=k,this.rebindTextures=Ne,this.setupRenderTarget=H,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=ee,this.setupDepthRenderbuffer=ge,this.setupFrameBufferTexture=Ae,this.safeSetTexture2D=Re,this.safeSetTextureCube=Ve}function ug(r,e,t){const n=t.isWebGL2;function i(s){let o;if(s===en)return 5121;if(s===wh)return 32819;if(s===Sh)return 32820;if(s===Th)return 33635;if(s===vh)return 5120;if(s===Mh)return 5122;if(s===ts)return 5123;if(s===bh)return 5124;if(s===Qs)return 5125;if(s===$t)return 5126;if(s===Fn)return n?5131:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===Eh)return 6406;if(s===xn)return 6407;if(s===st)return 6408;if(s===Ah)return 6409;if(s===Lh)return 6410;if(s===On)return 6402;if(s===Mi)return 34041;if(s===Rh)return 6403;if(s===Ch)return 36244;if(s===Ph)return 33319;if(s===Ih)return 33320;if(s===Dh)return 36248;if(s===Nh)return 36249;if(s===ra||s===oa||s===aa||s===la)if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===ra)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===oa)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===aa)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===la)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===ca||s===ha||s===ua||s===da)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===ca)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===ha)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===ua)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===da)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Fh)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if((s===fa||s===pa)&&(o=e.get("WEBGL_compressed_texture_etc"),o!==null)){if(s===fa)return o.COMPRESSED_RGB8_ETC2;if(s===pa)return o.COMPRESSED_RGBA8_ETC2_EAC}if(s===Oh||s===Bh||s===Uh||s===zh||s===Hh||s===kh||s===Gh||s===Vh||s===Wh||s===qh||s===jh||s===Xh||s===Yh||s===Zh||s===Kh||s===$h||s===Qh||s===eu||s===tu||s===nu||s===iu||s===su||s===ru||s===ou||s===au||s===lu||s===cu||s===hu)return o=e.get("WEBGL_compressed_texture_astc"),o!==null?s:null;if(s===Jh)return o=e.get("EXT_texture_compression_bptc"),o!==null?s:null;if(s===xi)return n?34042:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:i}}class cc extends pt{constructor(e=[]){super(),this.cameras=e}}cc.prototype.isArrayCamera=!0;class Qt extends ke{constructor(){super(),this.type="Group"}}Qt.prototype.isGroup=!0;const dg={type:"move"};class qr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qt,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Qt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new T,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new T),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new T,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new T),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(a!==null&&(i=t.getPose(e.targetRaySpace,n),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(dg))),c&&e.hand){o=!0;for(const x of e.hand.values()){const _=t.getJointPose(x,n);if(c.joints[x.jointName]===void 0){const m=new Qt;m.matrixAutoUpdate=!1,m.visible=!1,c.joints[x.jointName]=m,c.add(m)}const p=c.joints[x.jointName];_!==null&&(p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.jointRadius=_.radius),p.visible=_!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}}class lo extends tt{constructor(e,t,n,i,s,o,a,l,c,h){if(h=h!==void 0?h:On,h!==On&&h!==Mi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===On&&(n=ts),n===void 0&&h===Mi&&(n=xi),super(null,i,s,o,a,l,h,n,c),this.image={width:e,height:t},this.magFilter=a!==void 0?a:Qe,this.minFilter=l!==void 0?l:Qe,this.flipY=!1,this.generateMipmaps=!1}}lo.prototype.isDepthTexture=!0;class fg extends Sn{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor";const l=e.extensions.has("WEBGL_multisampled_render_to_texture");let c=null,h=null,u=null,d=null,f=!1,g=null;const x=t.getContextAttributes();let _=null,p=null;const m=[],R=new Map,y=new pt;y.layers.enable(1),y.viewport=new qe;const E=new pt;E.layers.enable(2),E.viewport=new qe;const C=[y,E],P=new cc;P.layers.enable(1),P.layers.enable(2);let V=null,ne=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(k){let G=m[k];return G===void 0&&(G=new qr,m[k]=G),G.getTargetRaySpace()},this.getControllerGrip=function(k){let G=m[k];return G===void 0&&(G=new qr,m[k]=G),G.getGripSpace()},this.getHand=function(k){let G=m[k];return G===void 0&&(G=new qr,m[k]=G),G.getHandSpace()};function Z(k){const G=R.get(k.inputSource);G&&G.dispatchEvent({type:k.type,data:k.inputSource})}function I(){R.forEach(function(k,G){k.disconnect(G)}),R.clear(),V=null,ne=null,e.setRenderTarget(_),d=null,u=null,h=null,i=null,p=null,le.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(k){s=k,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(k){a=k,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(k){if(i=k,i!==null){if(_=e.getRenderTarget(),i.addEventListener("select",Z),i.addEventListener("selectstart",Z),i.addEventListener("selectend",Z),i.addEventListener("squeeze",Z),i.addEventListener("squeezestart",Z),i.addEventListener("squeezeend",Z),i.addEventListener("end",I),i.addEventListener("inputsourceschange",S),x.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const G={antialias:i.renderState.layers===void 0?x.antialias:!0,alpha:x.alpha,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,G),i.updateRenderState({baseLayer:d}),p=new Et(d.framebufferWidth,d.framebufferHeight,{format:st,type:en,encoding:e.outputEncoding})}else{f=x.antialias;let G=null,ce=null,ae=null;x.depth&&(ae=x.stencil?35056:33190,G=x.stencil?Mi:On,ce=x.stencil?xi:ts);const fe={colorFormat:x.alpha||f?32856:32849,depthFormat:ae,scaleFactor:s};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(fe),i.updateRenderState({layers:[u]}),f?p=new Eo(u.textureWidth,u.textureHeight,{format:st,type:en,depthTexture:new lo(u.textureWidth,u.textureHeight,ce,void 0,void 0,void 0,void 0,void 0,void 0,G),stencilBuffer:x.stencil,ignoreDepth:u.ignoreDepthValues,useRenderToTexture:l,encoding:e.outputEncoding}):p=new Et(u.textureWidth,u.textureHeight,{format:x.alpha?st:xn,type:en,depthTexture:new lo(u.textureWidth,u.textureHeight,ce,void 0,void 0,void 0,void 0,void 0,void 0,G),stencilBuffer:x.stencil,ignoreDepth:u.ignoreDepthValues,encoding:e.outputEncoding})}this.setFoveation(1),o=await i.requestReferenceSpace(a),le.setContext(i),le.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function S(k){const G=i.inputSources;for(let ce=0;ce<m.length;ce++)R.set(G[ce],m[ce]);for(let ce=0;ce<k.removed.length;ce++){const ae=k.removed[ce],fe=R.get(ae);fe&&(fe.dispatchEvent({type:"disconnected",data:ae}),R.delete(ae))}for(let ce=0;ce<k.added.length;ce++){const ae=k.added[ce],fe=R.get(ae);fe&&fe.dispatchEvent({type:"connected",data:ae})}}const b=new T,N=new T;function O(k,G,ce){b.setFromMatrixPosition(G.matrixWorld),N.setFromMatrixPosition(ce.matrixWorld);const ae=b.distanceTo(N),fe=G.projectionMatrix.elements,Ce=ce.projectionMatrix.elements,X=fe[14]/(fe[10]-1),Ae=fe[14]/(fe[10]+1),ye=(fe[9]+1)/fe[5],me=(fe[9]-1)/fe[5],ge=(fe[8]-1)/fe[0],Ne=(Ce[8]+1)/Ce[0],H=X*ge,Q=X*Ne,ee=ae/(-ge+Ne),he=ee*-ge;G.matrixWorld.decompose(k.position,k.quaternion,k.scale),k.translateX(he),k.translateZ(ee),k.matrixWorld.compose(k.position,k.quaternion,k.scale),k.matrixWorldInverse.copy(k.matrixWorld).invert();const ie=X+ee,be=Ae+ee,we=H-he,Re=Q+(ae-he),Ve=ye*Ae/be*ie,A=me*Ae/be*ie;k.projectionMatrix.makePerspective(we,Re,Ve,A,ie,be)}function D(k,G){G===null?k.matrixWorld.copy(k.matrix):k.matrixWorld.multiplyMatrices(G.matrixWorld,k.matrix),k.matrixWorldInverse.copy(k.matrixWorld).invert()}this.updateCamera=function(k){if(i===null)return;P.near=E.near=y.near=k.near,P.far=E.far=y.far=k.far,(V!==P.near||ne!==P.far)&&(i.updateRenderState({depthNear:P.near,depthFar:P.far}),V=P.near,ne=P.far);const G=k.parent,ce=P.cameras;D(P,G);for(let fe=0;fe<ce.length;fe++)D(ce[fe],G);P.matrixWorld.decompose(P.position,P.quaternion,P.scale),k.position.copy(P.position),k.quaternion.copy(P.quaternion),k.scale.copy(P.scale),k.matrix.copy(P.matrix),k.matrixWorld.copy(P.matrixWorld);const ae=k.children;for(let fe=0,Ce=ae.length;fe<Ce;fe++)ae[fe].updateMatrixWorld(!0);ce.length===2?O(P,y,E):P.projectionMatrix.copy(y.projectionMatrix)},this.getCamera=function(){return P},this.getFoveation=function(){if(u!==null)return u.fixedFoveation;if(d!==null)return d.fixedFoveation},this.setFoveation=function(k){u!==null&&(u.fixedFoveation=k),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=k)};let B=null;function te(k,G){if(c=G.getViewerPose(o),g=G,c!==null){const ae=c.views;d!==null&&(e.setRenderTargetFramebuffer(p,d.framebuffer),e.setRenderTarget(p));let fe=!1;ae.length!==P.cameras.length&&(P.cameras.length=0,fe=!0);for(let Ce=0;Ce<ae.length;Ce++){const X=ae[Ce];let Ae=null;if(d!==null)Ae=d.getViewport(X);else{const me=h.getViewSubImage(u,X);Ae=me.viewport,Ce===0&&(e.setRenderTargetTextures(p,me.colorTexture,u.ignoreDepthValues?void 0:me.depthStencilTexture),e.setRenderTarget(p))}const ye=C[Ce];ye.matrix.fromArray(X.transform.matrix),ye.projectionMatrix.fromArray(X.projectionMatrix),ye.viewport.set(Ae.x,Ae.y,Ae.width,Ae.height),Ce===0&&P.matrix.copy(ye.matrix),fe===!0&&P.cameras.push(ye)}}const ce=i.inputSources;for(let ae=0;ae<m.length;ae++){const fe=m[ae],Ce=ce[ae];fe.update(Ce,G,o)}B&&B(k,G),g=null}const le=new Yl;le.setAnimationLoop(te),this.setAnimationLoop=function(k){B=k},this.dispose=function(){}}}function pg(r){function e(p,m){p.fogColor.value.copy(m.color),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function t(p,m,R,y,E){m.isMeshBasicMaterial?n(p,m):m.isMeshLambertMaterial?(n(p,m),l(p,m)):m.isMeshToonMaterial?(n(p,m),h(p,m)):m.isMeshPhongMaterial?(n(p,m),c(p,m)):m.isMeshStandardMaterial?(n(p,m),m.isMeshPhysicalMaterial?d(p,m,E):u(p,m)):m.isMeshMatcapMaterial?(n(p,m),f(p,m)):m.isMeshDepthMaterial?(n(p,m),g(p,m)):m.isMeshDistanceMaterial?(n(p,m),x(p,m)):m.isMeshNormalMaterial?(n(p,m),_(p,m)):m.isLineBasicMaterial?(i(p,m),m.isLineDashedMaterial&&s(p,m)):m.isPointsMaterial?o(p,m,R,y):m.isSpriteMaterial?a(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function n(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.specularMap&&(p.specularMap.value=m.specularMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);const R=r.get(m).envMap;R&&(p.envMap.value=R,p.flipEnvMap.value=R.isCubeTexture&&R.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix));let E;m.aoMap?E=m.aoMap:m.lightMap&&(E=m.lightMap),E!==void 0&&(E.isWebGLRenderTarget&&(E=E.texture),E.matrixAutoUpdate===!0&&E.updateMatrix(),p.uv2Transform.value.copy(E.matrix))}function i(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity}function s(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function o(p,m,R,y){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*R,p.scale.value=y*.5,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let E;m.map?E=m.map:m.alphaMap&&(E=m.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),p.uvTransform.value.copy(E.matrix))}function a(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map),m.alphaMap&&(p.alphaMap.value=m.alphaMap),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);let R;m.map?R=m.map:m.alphaMap&&(R=m.alphaMap),R!==void 0&&(R.matrixAutoUpdate===!0&&R.updateMatrix(),p.uvTransform.value.copy(R.matrix))}function l(p,m){m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap)}function c(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap),m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===it&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===it&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias)}function h(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap),m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===it&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===it&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias)}function u(p,m){p.roughness.value=m.roughness,p.metalness.value=m.metalness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap),m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===it&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===it&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),r.get(m).envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function d(p,m,R){u(p,m),p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),p.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===it&&p.clearcoatNormalScale.value.negate())),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=R.texture,p.transmissionSamplerSize.value.set(R.width,R.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap)}function f(p,m){m.matcap&&(p.matcap.value=m.matcap),m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===it&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===it&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias)}function g(p,m){m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias)}function x(p,m){m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),p.referencePosition.value.copy(m.referencePosition),p.nearDistance.value=m.nearDistance,p.farDistance.value=m.farDistance}function _(p,m){m.bumpMap&&(p.bumpMap.value=m.bumpMap,p.bumpScale.value=m.bumpScale,m.side===it&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,p.normalScale.value.copy(m.normalScale),m.side===it&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function mg(){const r=or("canvas");return r.style.display="block",r}function Ge(r={}){const e=r.canvas!==void 0?r.canvas:mg(),t=r.context!==void 0?r.context:null,n=r.alpha!==void 0?r.alpha:!1,i=r.depth!==void 0?r.depth:!0,s=r.stencil!==void 0?r.stencil:!0,o=r.antialias!==void 0?r.antialias:!1,a=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,l=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,c=r.powerPreference!==void 0?r.powerPreference:"default",h=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1;let u=null,d=null;const f=[],g=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Dt,this.physicallyCorrectLights=!1,this.toneMapping=gn,this.toneMappingExposure=1;const x=this;let _=!1,p=0,m=0,R=null,y=-1,E=null;const C=new qe,P=new qe;let V=null,ne=e.width,Z=e.height,I=1,S=null,b=null;const N=new qe(0,0,ne,Z),O=new qe(0,0,ne,Z);let D=!1;const B=[],te=new lr;let le=!1,k=!1,G=null;const ce=new pe,ae=new T,fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ce(){return R===null?I:1}let X=t;function Ae(M,F){for(let z=0;z<M.length;z++){const U=M[z],W=e.getContext(U,F);if(W!==null)return W}return null}try{const M={alpha:n,depth:i,stencil:s,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${bo}`),e.addEventListener("webglcontextlost",_e,!1),e.addEventListener("webglcontextrestored",de,!1),X===null){const F=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&F.shift(),X=Ae(F,M),X===null)throw Ae(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}X.getShaderPrecisionFormat===void 0&&(X.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(M){throw console.error("THREE.WebGLRenderer: "+M.message),M}let ye,me,ge,Ne,H,Q,ee,he,ie,be,we,Re,Ve,A,v,q,$,se,K,Me,xe,L,w;function J(){ye=new Fp(X),me=new Lp(X,ye,r),ye.init(me),L=new ug(X,ye,me),ge=new cg(X,ye,me),B[0]=1029,Ne=new Up,H=new $m,Q=new hg(X,ye,ge,H,me,L,Ne),ee=new Cp(x),he=new Np(x),ie=new Ku(X,me),w=new Ep(X,ye,ie,me),be=new Op(X,ie,Ne,w),we=new Gp(X,be,ie,Ne),K=new kp(X,me,Q),q=new Rp(H),Re=new Km(x,ee,he,ye,me,w,q),Ve=new pg(H),A=new eg,v=new og(ye,me),se=new Tp(x,ee,ge,we,a),$=new lc(x,we,me),Me=new Ap(X,ye,Ne,me),xe=new Bp(X,ye,Ne,me),Ne.programs=Re.programs,x.capabilities=me,x.extensions=ye,x.properties=H,x.renderLists=A,x.shadowMap=$,x.state=ge,x.info=Ne}J();const Y=new fg(x,X);this.xr=Y,this.getContext=function(){return X},this.getContextAttributes=function(){return X.getContextAttributes()},this.forceContextLoss=function(){const M=ye.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=ye.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(M){M!==void 0&&(I=M,this.setSize(ne,Z,!1))},this.getSize=function(M){return M.set(ne,Z)},this.setSize=function(M,F,z){if(Y.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ne=M,Z=F,e.width=Math.floor(M*I),e.height=Math.floor(F*I),z!==!1&&(e.style.width=M+"px",e.style.height=F+"px"),this.setViewport(0,0,M,F)},this.getDrawingBufferSize=function(M){return M.set(ne*I,Z*I).floor()},this.setDrawingBufferSize=function(M,F,z){ne=M,Z=F,I=z,e.width=Math.floor(M*z),e.height=Math.floor(F*z),this.setViewport(0,0,M,F)},this.getCurrentViewport=function(M){return M.copy(C)},this.getViewport=function(M){return M.copy(N)},this.setViewport=function(M,F,z,U){M.isVector4?N.set(M.x,M.y,M.z,M.w):N.set(M,F,z,U),ge.viewport(C.copy(N).multiplyScalar(I).floor())},this.getScissor=function(M){return M.copy(O)},this.setScissor=function(M,F,z,U){M.isVector4?O.set(M.x,M.y,M.z,M.w):O.set(M,F,z,U),ge.scissor(P.copy(O).multiplyScalar(I).floor())},this.getScissorTest=function(){return D},this.setScissorTest=function(M){ge.setScissorTest(D=M)},this.setOpaqueSort=function(M){S=M},this.setTransparentSort=function(M){b=M},this.getClearColor=function(M){return M.copy(se.getClearColor())},this.setClearColor=function(){se.setClearColor.apply(se,arguments)},this.getClearAlpha=function(){return se.getClearAlpha()},this.setClearAlpha=function(){se.setClearAlpha.apply(se,arguments)},this.clear=function(M,F,z){let U=0;(M===void 0||M)&&(U|=16384),(F===void 0||F)&&(U|=256),(z===void 0||z)&&(U|=1024),X.clear(U)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",_e,!1),e.removeEventListener("webglcontextrestored",de,!1),A.dispose(),v.dispose(),H.dispose(),ee.dispose(),he.dispose(),we.dispose(),w.dispose(),Re.dispose(),Y.dispose(),Y.removeEventListener("sessionstart",Nt),Y.removeEventListener("sessionend",Ft),G&&(G.dispose(),G=null),An.stop()};function _e(M){M.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function de(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const M=Ne.autoReset,F=$.enabled,z=$.autoUpdate,U=$.needsUpdate,W=$.type;J(),Ne.autoReset=M,$.enabled=F,$.autoUpdate=z,$.needsUpdate=U,$.type=W}function Se(M){const F=M.target;F.removeEventListener("dispose",Se),re(F)}function re(M){ve(M),H.remove(M)}function ve(M){const F=H.get(M).programs;F!==void 0&&(F.forEach(function(z){Re.releaseProgram(z)}),M.isShaderMaterial&&Re.releaseShaderCache(M))}this.renderBufferDirect=function(M,F,z,U,W,Te){F===null&&(F=fe);const Le=W.isMesh&&W.matrixWorld.determinant()<0,Pe=Vc(M,F,z,U,W);ge.setMaterial(U,Le);let Ee=z.index;const Ue=z.attributes.position;if(Ee===null){if(Ue===void 0||Ue.count===0)return}else if(Ee.count===0)return;let Ie=1;U.wireframe===!0&&(Ee=be.getWireframeAttribute(z),Ie=2),w.setup(W,U,Pe,z,Ee);let Be,Je=Me;Ee!==null&&(Be=ie.get(Ee),Je=xe,Je.setIndex(Be));const Ln=Ee!==null?Ee.count:Ue.count,Vn=z.drawRange.start*Ie,ze=z.drawRange.count*Ie,Ot=Te!==null?Te.start*Ie:0,nt=Te!==null?Te.count*Ie:1/0,Bt=Math.max(Vn,Ot),xs=Math.min(Ln,Vn+ze,Ot+nt)-1,Ut=Math.max(0,xs-Bt+1);if(Ut!==0){if(W.isMesh)U.wireframe===!0?(ge.setLineWidth(U.wireframeLinewidth*Ce()),Je.setMode(1)):Je.setMode(4);else if(W.isLine){let Vt=U.linewidth;Vt===void 0&&(Vt=1),ge.setLineWidth(Vt*Ce()),W.isLineSegments?Je.setMode(1):W.isLineLoop?Je.setMode(2):Je.setMode(3)}else W.isPoints?Je.setMode(0):W.isSprite&&Je.setMode(4);if(W.isInstancedMesh)Je.renderInstances(Bt,Ut,W.count);else if(z.isInstancedBufferGeometry){const Vt=Math.min(z.instanceCount,z._maxInstanceCount);Je.renderInstances(Bt,Ut,Vt)}else Je.render(Bt,Ut)}},this.compile=function(M,F){d=v.get(M),d.init(),g.push(d),M.traverseVisible(function(z){z.isLight&&z.layers.test(F.layers)&&(d.pushLight(z),z.castShadow&&d.pushShadow(z))}),d.setupLights(x.physicallyCorrectLights),M.traverse(function(z){const U=z.material;if(U)if(Array.isArray(U))for(let W=0;W<U.length;W++){const Te=U[W];xr(Te,M,z)}else xr(U,M,z)}),g.pop(),d=null};let Fe=null;function We(M){Fe&&Fe(M)}function Nt(){An.stop()}function Ft(){An.start()}const An=new Yl;An.setAnimationLoop(We),typeof window<"u"&&An.setContext(window),this.setAnimationLoop=function(M){Fe=M,Y.setAnimationLoop(M),M===null?An.stop():An.start()},Y.addEventListener("sessionstart",Nt),Y.addEventListener("sessionend",Ft),this.render=function(M,F){if(F!==void 0&&F.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;M.autoUpdate===!0&&M.updateMatrixWorld(),F.parent===null&&F.updateMatrixWorld(),Y.enabled===!0&&Y.isPresenting===!0&&(Y.cameraAutoUpdate===!0&&Y.updateCamera(F),F=Y.getCamera()),M.isScene===!0&&M.onBeforeRender(x,M,F,R),d=v.get(M,g.length),d.init(),g.push(d),ce.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),te.setFromProjectionMatrix(ce),k=this.localClippingEnabled,le=q.init(this.clippingPlanes,k,F),u=A.get(M,f.length),u.init(),f.push(u),Jo(M,F,0,x.sortObjects),u.finish(),x.sortObjects===!0&&u.sort(S,b),le===!0&&q.beginShadows();const z=d.state.shadowsArray;if($.render(z,M,F),le===!0&&q.endShadows(),this.info.autoReset===!0&&this.info.reset(),se.render(u,M),d.setupLights(x.physicallyCorrectLights),F.isArrayCamera){const U=F.cameras;for(let W=0,Te=U.length;W<Te;W++){const Le=U[W];Ko(u,M,Le,Le.viewport)}}else Ko(u,M,F);R!==null&&(Q.updateMultisampleRenderTarget(R),Q.updateRenderTargetMipmap(R)),M.isScene===!0&&M.onAfterRender(x,M,F),ge.buffers.depth.setTest(!0),ge.buffers.depth.setMask(!0),ge.buffers.color.setMask(!0),ge.setPolygonOffset(!1),w.resetDefaultState(),y=-1,E=null,g.pop(),g.length>0?d=g[g.length-1]:d=null,f.pop(),f.length>0?u=f[f.length-1]:u=null};function Jo(M,F,z,U){if(M.visible===!1)return;if(M.layers.test(F.layers)){if(M.isGroup)z=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(F);else if(M.isLight)d.pushLight(M),M.castShadow&&d.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||te.intersectsSprite(M)){U&&ae.setFromMatrixPosition(M.matrixWorld).applyMatrix4(ce);const Le=we.update(M),Pe=M.material;Pe.visible&&u.push(M,Le,Pe,z,ae.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(M.isSkinnedMesh&&M.skeleton.frame!==Ne.render.frame&&(M.skeleton.update(),M.skeleton.frame=Ne.render.frame),!M.frustumCulled||te.intersectsObject(M))){U&&ae.setFromMatrixPosition(M.matrixWorld).applyMatrix4(ce);const Le=we.update(M),Pe=M.material;if(Array.isArray(Pe)){const Ee=Le.groups;for(let Ue=0,Ie=Ee.length;Ue<Ie;Ue++){const Be=Ee[Ue],Je=Pe[Be.materialIndex];Je&&Je.visible&&u.push(M,Le,Je,z,ae.z,Be)}}else Pe.visible&&u.push(M,Le,Pe,z,ae.z,null)}}const Te=M.children;for(let Le=0,Pe=Te.length;Le<Pe;Le++)Jo(Te[Le],F,z,U)}function Ko(M,F,z,U){const W=M.opaque,Te=M.transmissive,Le=M.transparent;d.setupLightsView(z),Te.length>0&&kc(W,F,z),U&&ge.viewport(C.copy(U)),W.length>0&&gs(W,F,z),Te.length>0&&gs(Te,F,z),Le.length>0&&gs(Le,F,z)}function kc(M,F,z){if(G===null){const Le=o===!0&&me.isWebGL2===!0?Eo:Et;G=new Le(1024,1024,{generateMipmaps:!0,type:L.convert(Fn)!==null?Fn:en,minFilter:Ei,magFilter:Qe,wrapS:yt,wrapT:yt,useRenderToTexture:ye.has("WEBGL_multisampled_render_to_texture")})}const U=x.getRenderTarget();x.setRenderTarget(G),x.clear();const W=x.toneMapping;x.toneMapping=gn,gs(M,F,z),x.toneMapping=W,Q.updateMultisampleRenderTarget(G),Q.updateRenderTargetMipmap(G),x.setRenderTarget(U)}function gs(M,F,z){const U=F.isScene===!0?F.overrideMaterial:null;for(let W=0,Te=M.length;W<Te;W++){const Le=M[W],Pe=Le.object,Ee=Le.geometry,Ue=U===null?Le.material:U,Ie=Le.group;Pe.layers.test(z.layers)&&Gc(Pe,F,z,Ee,Ue,Ie)}}function Gc(M,F,z,U,W,Te){M.onBeforeRender(x,F,z,U,W,Te),M.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),W.onBeforeRender(x,F,z,U,M,Te),W.transparent===!0&&W.side===Un?(W.side=it,W.needsUpdate=!0,x.renderBufferDirect(z,F,U,W,M,Te),W.side=yi,W.needsUpdate=!0,x.renderBufferDirect(z,F,U,W,M,Te),W.side=Un):x.renderBufferDirect(z,F,U,W,M,Te),M.onAfterRender(x,F,z,U,W,Te)}function xr(M,F,z){F.isScene!==!0&&(F=fe);const U=H.get(M),W=d.state.lights,Te=d.state.shadowsArray,Le=W.state.version,Pe=Re.getParameters(M,W.state,Te,F,z),Ee=Re.getProgramCacheKey(Pe);let Ue=U.programs;U.environment=M.isMeshStandardMaterial?F.environment:null,U.fog=F.fog,U.envMap=(M.isMeshStandardMaterial?he:ee).get(M.envMap||U.environment),Ue===void 0&&(M.addEventListener("dispose",Se),Ue=new Map,U.programs=Ue);let Ie=Ue.get(Ee);if(Ie!==void 0){if(U.currentProgram===Ie&&U.lightsStateVersion===Le)return $o(M,Pe),Ie}else Pe.uniforms=Re.getUniforms(M),M.onBuild(z,Pe,x),M.onBeforeCompile(Pe,x),Ie=Re.acquireProgram(Pe,Ee),Ue.set(Ee,Ie),U.uniforms=Pe.uniforms;const Be=U.uniforms;(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(Be.clippingPlanes=q.uniform),$o(M,Pe),U.needsLights=qc(M),U.lightsStateVersion=Le,U.needsLights&&(Be.ambientLightColor.value=W.state.ambient,Be.lightProbe.value=W.state.probe,Be.directionalLights.value=W.state.directional,Be.directionalLightShadows.value=W.state.directionalShadow,Be.spotLights.value=W.state.spot,Be.spotLightShadows.value=W.state.spotShadow,Be.rectAreaLights.value=W.state.rectArea,Be.ltc_1.value=W.state.rectAreaLTC1,Be.ltc_2.value=W.state.rectAreaLTC2,Be.pointLights.value=W.state.point,Be.pointLightShadows.value=W.state.pointShadow,Be.hemisphereLights.value=W.state.hemi,Be.directionalShadowMap.value=W.state.directionalShadowMap,Be.directionalShadowMatrix.value=W.state.directionalShadowMatrix,Be.spotShadowMap.value=W.state.spotShadowMap,Be.spotShadowMatrix.value=W.state.spotShadowMatrix,Be.pointShadowMap.value=W.state.pointShadowMap,Be.pointShadowMatrix.value=W.state.pointShadowMatrix);const Je=Ie.getUniforms(),Ln=yn.seqWithValue(Je.seq,Be);return U.currentProgram=Ie,U.uniformsList=Ln,Ie}function $o(M,F){const z=H.get(M);z.outputEncoding=F.outputEncoding,z.instancing=F.instancing,z.skinning=F.skinning,z.morphTargets=F.morphTargets,z.morphNormals=F.morphNormals,z.morphTargetsCount=F.morphTargetsCount,z.numClippingPlanes=F.numClippingPlanes,z.numIntersection=F.numClipIntersection,z.vertexAlphas=F.vertexAlphas,z.vertexTangents=F.vertexTangents,z.toneMapping=F.toneMapping}function Vc(M,F,z,U,W){F.isScene!==!0&&(F=fe),Q.resetTextureUnits();const Te=F.fog,Le=U.isMeshStandardMaterial?F.environment:null,Pe=R===null?x.outputEncoding:R.texture.encoding,Ee=(U.isMeshStandardMaterial?he:ee).get(U.envMap||Le),Ue=U.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,Ie=!!U.normalMap&&!!z.attributes.tangent,Be=!!z.morphAttributes.position,Je=!!z.morphAttributes.normal,Ln=z.morphAttributes.position?z.morphAttributes.position.length:0,Vn=U.toneMapped?x.toneMapping:gn,ze=H.get(U),Ot=d.state.lights;if(le===!0&&(k===!0||M!==E)){const Lt=M===E&&U.id===y;q.setState(U,M,Lt)}let nt=!1;U.version===ze.__version?(ze.needsLights&&ze.lightsStateVersion!==Ot.state.version||ze.outputEncoding!==Pe||W.isInstancedMesh&&ze.instancing===!1||!W.isInstancedMesh&&ze.instancing===!0||W.isSkinnedMesh&&ze.skinning===!1||!W.isSkinnedMesh&&ze.skinning===!0||ze.envMap!==Ee||U.fog&&ze.fog!==Te||ze.numClippingPlanes!==void 0&&(ze.numClippingPlanes!==q.numPlanes||ze.numIntersection!==q.numIntersection)||ze.vertexAlphas!==Ue||ze.vertexTangents!==Ie||ze.morphTargets!==Be||ze.morphNormals!==Je||ze.toneMapping!==Vn||me.isWebGL2===!0&&ze.morphTargetsCount!==Ln)&&(nt=!0):(nt=!0,ze.__version=U.version);let Bt=ze.currentProgram;nt===!0&&(Bt=xr(U,F,W));let xs=!1,Ut=!1,Vt=!1;const dt=Bt.getUniforms(),Fi=ze.uniforms;if(ge.useProgram(Bt.program)&&(xs=!0,Ut=!0,Vt=!0),U.id!==y&&(y=U.id,Ut=!0),xs||E!==M){if(dt.setValue(X,"projectionMatrix",M.projectionMatrix),me.logarithmicDepthBuffer&&dt.setValue(X,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),E!==M&&(E=M,Ut=!0,Vt=!0),U.isShaderMaterial||U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshStandardMaterial||U.envMap){const Lt=dt.map.cameraPosition;Lt!==void 0&&Lt.setValue(X,ae.setFromMatrixPosition(M.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&dt.setValue(X,"isOrthographic",M.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||W.isSkinnedMesh)&&dt.setValue(X,"viewMatrix",M.matrixWorldInverse)}if(W.isSkinnedMesh){dt.setOptional(X,W,"bindMatrix"),dt.setOptional(X,W,"bindMatrixInverse");const Lt=W.skeleton;Lt&&(me.floatVertexTextures?(Lt.boneTexture===null&&Lt.computeBoneTexture(),dt.setValue(X,"boneTexture",Lt.boneTexture,Q),dt.setValue(X,"boneTextureSize",Lt.boneTextureSize)):dt.setOptional(X,Lt,"boneMatrices"))}return!!z&&(z.morphAttributes.position!==void 0||z.morphAttributes.normal!==void 0)&&K.update(W,z,U,Bt),(Ut||ze.receiveShadow!==W.receiveShadow)&&(ze.receiveShadow=W.receiveShadow,dt.setValue(X,"receiveShadow",W.receiveShadow)),Ut&&(dt.setValue(X,"toneMappingExposure",x.toneMappingExposure),ze.needsLights&&Wc(Fi,Vt),Te&&U.fog&&Ve.refreshFogUniforms(Fi,Te),Ve.refreshMaterialUniforms(Fi,U,I,Z,G),yn.upload(X,ze.uniformsList,Fi,Q)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(yn.upload(X,ze.uniformsList,Fi,Q),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&dt.setValue(X,"center",W.center),dt.setValue(X,"modelViewMatrix",W.modelViewMatrix),dt.setValue(X,"normalMatrix",W.normalMatrix),dt.setValue(X,"modelMatrix",W.matrixWorld),Bt}function Wc(M,F){M.ambientLightColor.needsUpdate=F,M.lightProbe.needsUpdate=F,M.directionalLights.needsUpdate=F,M.directionalLightShadows.needsUpdate=F,M.pointLights.needsUpdate=F,M.pointLightShadows.needsUpdate=F,M.spotLights.needsUpdate=F,M.spotLightShadows.needsUpdate=F,M.rectAreaLights.needsUpdate=F,M.hemisphereLights.needsUpdate=F}function qc(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return p},this.getActiveMipmapLevel=function(){return m},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(M,F,z){H.get(M.texture).__webglTexture=F,H.get(M.depthTexture).__webglTexture=z;const U=H.get(M);U.__hasExternalTextures=!0,U.__hasExternalTextures&&(U.__autoAllocateDepthBuffer=z===void 0,U.__autoAllocateDepthBuffer||M.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),M.useRenderToTexture=!1,M.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(M,F){const z=H.get(M);z.__webglFramebuffer=F,z.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(M,F=0,z=0){R=M,p=F,m=z;let U=!0;if(M){const Ee=H.get(M);Ee.__useDefaultFramebuffer!==void 0?(ge.bindFramebuffer(36160,null),U=!1):Ee.__webglFramebuffer===void 0?Q.setupRenderTarget(M):Ee.__hasExternalTextures&&Q.rebindTextures(M,H.get(M.texture).__webglTexture,H.get(M.depthTexture).__webglTexture)}let W=null,Te=!1,Le=!1;if(M){const Ee=M.texture;(Ee.isDataTexture3D||Ee.isDataTexture2DArray)&&(Le=!0);const Ue=H.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(W=Ue[F],Te=!0):M.useRenderbuffer?W=H.get(M).__webglMultisampledFramebuffer:W=Ue,C.copy(M.viewport),P.copy(M.scissor),V=M.scissorTest}else C.copy(N).multiplyScalar(I).floor(),P.copy(O).multiplyScalar(I).floor(),V=D;if(ge.bindFramebuffer(36160,W)&&me.drawBuffers&&U){let Ee=!1;if(M)if(M.isWebGLMultipleRenderTargets){const Ue=M.texture;if(B.length!==Ue.length||B[0]!==36064){for(let Ie=0,Be=Ue.length;Ie<Be;Ie++)B[Ie]=36064+Ie;B.length=Ue.length,Ee=!0}}else(B.length!==1||B[0]!==36064)&&(B[0]=36064,B.length=1,Ee=!0);else(B.length!==1||B[0]!==1029)&&(B[0]=1029,B.length=1,Ee=!0);Ee&&(me.isWebGL2?X.drawBuffers(B):ye.get("WEBGL_draw_buffers").drawBuffersWEBGL(B))}if(ge.viewport(C),ge.scissor(P),ge.setScissorTest(V),Te){const Ee=H.get(M.texture);X.framebufferTexture2D(36160,36064,34069+F,Ee.__webglTexture,z)}else if(Le){const Ee=H.get(M.texture),Ue=F||0;X.framebufferTextureLayer(36160,36064,Ee.__webglTexture,z||0,Ue)}y=-1},this.readRenderTargetPixels=function(M,F,z,U,W,Te,Le){if(!(M&&M.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=H.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&Le!==void 0&&(Pe=Pe[Le]),Pe){ge.bindFramebuffer(36160,Pe);try{const Ee=M.texture,Ue=Ee.format,Ie=Ee.type;if(Ue!==st&&L.convert(Ue)!==X.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Be=Ie===Fn&&(ye.has("EXT_color_buffer_half_float")||me.isWebGL2&&ye.has("EXT_color_buffer_float"));if(Ie!==en&&L.convert(Ie)!==X.getParameter(35738)&&!(Ie===$t&&(me.isWebGL2||ye.has("OES_texture_float")||ye.has("WEBGL_color_buffer_float")))&&!Be){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}X.checkFramebufferStatus(36160)===36053?F>=0&&F<=M.width-U&&z>=0&&z<=M.height-W&&X.readPixels(F,z,U,W,L.convert(Ue),L.convert(Ie),Te):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const Ee=R!==null?H.get(R).__webglFramebuffer:null;ge.bindFramebuffer(36160,Ee)}}},this.copyFramebufferToTexture=function(M,F,z=0){if(F.isFramebufferTexture!==!0){console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");return}const U=Math.pow(2,-z),W=Math.floor(F.image.width*U),Te=Math.floor(F.image.height*U);Q.setTexture2D(F,0),X.copyTexSubImage2D(3553,z,0,0,M.x,M.y,W,Te),ge.unbindTexture()},this.copyTextureToTexture=function(M,F,z,U=0){const W=F.image.width,Te=F.image.height,Le=L.convert(z.format),Pe=L.convert(z.type);Q.setTexture2D(z,0),X.pixelStorei(37440,z.flipY),X.pixelStorei(37441,z.premultiplyAlpha),X.pixelStorei(3317,z.unpackAlignment),F.isDataTexture?X.texSubImage2D(3553,U,M.x,M.y,W,Te,Le,Pe,F.image.data):F.isCompressedTexture?X.compressedTexSubImage2D(3553,U,M.x,M.y,F.mipmaps[0].width,F.mipmaps[0].height,Le,F.mipmaps[0].data):X.texSubImage2D(3553,U,M.x,M.y,Le,Pe,F.image),U===0&&z.generateMipmaps&&X.generateMipmap(3553),ge.unbindTexture()},this.copyTextureToTexture3D=function(M,F,z,U,W=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Te=M.max.x-M.min.x+1,Le=M.max.y-M.min.y+1,Pe=M.max.z-M.min.z+1,Ee=L.convert(U.format),Ue=L.convert(U.type);let Ie;if(U.isDataTexture3D)Q.setTexture3D(U,0),Ie=32879;else if(U.isDataTexture2DArray)Q.setTexture2DArray(U,0),Ie=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}X.pixelStorei(37440,U.flipY),X.pixelStorei(37441,U.premultiplyAlpha),X.pixelStorei(3317,U.unpackAlignment);const Be=X.getParameter(3314),Je=X.getParameter(32878),Ln=X.getParameter(3316),Vn=X.getParameter(3315),ze=X.getParameter(32877),Ot=z.isCompressedTexture?z.mipmaps[0]:z.image;X.pixelStorei(3314,Ot.width),X.pixelStorei(32878,Ot.height),X.pixelStorei(3316,M.min.x),X.pixelStorei(3315,M.min.y),X.pixelStorei(32877,M.min.z),z.isDataTexture||z.isDataTexture3D?X.texSubImage3D(Ie,W,F.x,F.y,F.z,Te,Le,Pe,Ee,Ue,Ot.data):z.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),X.compressedTexSubImage3D(Ie,W,F.x,F.y,F.z,Te,Le,Pe,Ee,Ot.data)):X.texSubImage3D(Ie,W,F.x,F.y,F.z,Te,Le,Pe,Ee,Ue,Ot),X.pixelStorei(3314,Be),X.pixelStorei(32878,Je),X.pixelStorei(3316,Ln),X.pixelStorei(3315,Vn),X.pixelStorei(32877,ze),W===0&&U.generateMipmaps&&X.generateMipmap(Ie),ge.unbindTexture()},this.initTexture=function(M){Q.setTexture2D(M,0),ge.unbindTexture()},this.resetState=function(){p=0,m=0,R=null,ge.reset(),w.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Ge.prototype.isWebGLRenderer=!0;class gg extends Ge{}gg.prototype.isWebGL1Renderer=!0;class No extends ke{constructor(){super(),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(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}}No.prototype.isScene=!0;class Ci{constructor(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=is,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Tt()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Tt()),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]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Tt()),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}}}Ci.prototype.isInterleavedBuffer=!0;const Ke=new T;class Si{constructor(e,t,n,i=!1){this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Ke.x=this.getX(t),Ke.y=this.getY(t),Ke.z=this.getZ(t),Ke.applyMatrix4(e),this.setXYZ(t,Ke.x,Ke.y,Ke.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ke.x=this.getX(t),Ke.y=this.getY(t),Ke.z=this.getZ(t),Ke.applyNormalMatrix(e),this.setXYZ(t,Ke.x,Ke.y,Ke.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ke.x=this.getX(t),Ke.y=this.getY(t),Ke.z=this.getZ(t),Ke.transformDirection(e),this.setXYZ(t,Ke.x,Ke.y,Ke.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new $e(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 Si(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}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}}}Si.prototype.isInterleavedBufferAttribute=!0;class hc extends rt{constructor(e){super(),this.type="SpriteMaterial",this.color=new ue(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}}hc.prototype.isSpriteMaterial=!0;let ai;const ki=new T,li=new T,ci=new T,hi=new j,Gi=new j,uc=new pe,zs=new T,Vi=new T,Hs=new T,Za=new j,jr=new j,Ja=new j;class xg extends ke{constructor(e){if(super(),this.type="Sprite",ai===void 0){ai=new Xe;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Ci(t,5);ai.setIndex([0,1,2,0,2,3]),ai.setAttribute("position",new Si(n,3,0,!1)),ai.setAttribute("uv",new Si(n,2,3,!1))}this.geometry=ai,this.material=e!==void 0?e:new hc,this.center=new j(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),li.setFromMatrixScale(this.matrixWorld),uc.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ci.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&li.multiplyScalar(-ci.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const o=this.center;ks(zs.set(-.5,-.5,0),ci,o,li,i,s),ks(Vi.set(.5,-.5,0),ci,o,li,i,s),ks(Hs.set(.5,.5,0),ci,o,li,i,s),Za.set(0,0),jr.set(1,0),Ja.set(1,1);let a=e.ray.intersectTriangle(zs,Vi,Hs,!1,ki);if(a===null&&(ks(Vi.set(-.5,.5,0),ci,o,li,i,s),jr.set(0,1),a=e.ray.intersectTriangle(zs,Hs,Vi,!1,ki),a===null))return;const l=e.ray.origin.distanceTo(ki);l<e.near||l>e.far||t.push({distance:l,point:ki.clone(),uv:et.getUV(ki,zs,Vi,Hs,Za,jr,Ja,new j),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}xg.prototype.isSprite=!0;function ks(r,e,t,n,i,s){hi.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Gi.x=s*hi.x-i*hi.y,Gi.y=i*hi.x+s*hi.y):Gi.copy(hi),r.copy(e),r.x+=Gi.x,r.y+=Gi.y,r.applyMatrix4(uc)}const Ka=new T,$a=new qe,Qa=new qe,_g=new T,el=new pe;class Fo extends xt{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new pe,this.bindMatrixInverse=new pe}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(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(){this.skeleton.pose()}normalizeSkinWeights(){const e=new qe,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.x=t.getX(n),e.y=t.getY(n),e.z=t.getZ(n),e.w=t.getW(n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(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(e,t){const n=this.skeleton,i=this.geometry;$a.fromBufferAttribute(i.attributes.skinIndex,e),Qa.fromBufferAttribute(i.attributes.skinWeight,e),Ka.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=Qa.getComponent(s);if(o!==0){const a=$a.getComponent(s);el.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(_g.copy(Ka).applyMatrix4(el),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}Fo.prototype.isSkinnedMesh=!0;class Oo extends ke{constructor(){super(),this.type="Bone"}}Oo.prototype.isBone=!0;class dc extends tt{constructor(e=null,t=1,n=1,i,s,o,a,l,c=Qe,h=Qe,u,d){super(null,o,a,l,c,h,i,s,u,d),this.image={data:e,width:t,height:n},this.magFilter=c,this.minFilter=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}dc.prototype.isDataTexture=!0;const tl=new pe,yg=new pe;class Bo{constructor(e=[],t=[]){this.uuid=Tt(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){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 n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new pe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new pe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const a=e[s]?e[s].matrixWorld:yg;tl.multiplyMatrices(a,t[s]),tl.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Bo(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Hl(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new dc(t,e,e,st,$t);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Oo),this.bones.push(o),this.boneInverses.push(new pe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}}class co extends $e{constructor(e,t,n,i=1){typeof n=="number"&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}co.prototype.isInstancedBufferAttribute=!0;const nl=new pe,il=new pe,Gs=[],Wi=new xt;class vg extends xt{constructor(e,t,n){super(e,t),this.instanceMatrix=new co(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Wi.geometry=this.geometry,Wi.material=this.material,Wi.material!==void 0)for(let s=0;s<i;s++){this.getMatrixAt(s,nl),il.multiplyMatrices(n,nl),Wi.matrixWorld=il,Wi.raycast(e,Gs);for(let o=0,a=Gs.length;o<a;o++){const l=Gs[o];l.instanceId=s,l.object=this,t.push(l)}Gs.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new co(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}vg.prototype.isInstancedMesh=!0;class Pi extends rt{constructor(e){super(),this.type="LineBasicMaterial",this.color=new ue(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}}Pi.prototype.isLineBasicMaterial=!0;const sl=new T,rl=new T,ol=new pe,Xr=new En,Vs=new Tn;class dr extends ke{constructor(e=new Xe,t=new Pi){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)sl.fromBufferAttribute(t,i-1),rl.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=sl.distanceTo(rl);e.setAttribute("lineDistance",new lt(n,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(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Vs.copy(n.boundingSphere),Vs.applyMatrix4(i),Vs.radius+=s,e.ray.intersectsSphere(Vs)===!1)return;ol.copy(i).invert(),Xr.copy(e.ray).applyMatrix4(ol);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new T,h=new T,u=new T,d=new T,f=this.isLineSegments?2:1;if(n.isBufferGeometry){const g=n.index,_=n.attributes.position;if(g!==null){const p=Math.max(0,o.start),m=Math.min(g.count,o.start+o.count);for(let R=p,y=m-1;R<y;R+=f){const E=g.getX(R),C=g.getX(R+1);if(c.fromBufferAttribute(_,E),h.fromBufferAttribute(_,C),Xr.distanceSqToSegment(c,h,d,u)>l)continue;d.applyMatrix4(this.matrixWorld);const V=e.ray.origin.distanceTo(d);V<e.near||V>e.far||t.push({distance:V,point:u.clone().applyMatrix4(this.matrixWorld),index:R,face:null,faceIndex:null,object:this})}}else{const p=Math.max(0,o.start),m=Math.min(_.count,o.start+o.count);for(let R=p,y=m-1;R<y;R+=f){if(c.fromBufferAttribute(_,R),h.fromBufferAttribute(_,R+1),Xr.distanceSqToSegment(c,h,d,u)>l)continue;d.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(d);C<e.near||C>e.far||t.push({distance:C,point:u.clone().applyMatrix4(this.matrixWorld),index:R,face:null,faceIndex:null,object:this})}}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}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.")}}}dr.prototype.isLine=!0;const al=new T,ll=new T;class fr extends dr{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)al.fromBufferAttribute(t,i),ll.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+al.distanceTo(ll);e.setAttribute("lineDistance",new lt(n,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}}fr.prototype.isLineSegments=!0;class fc extends dr{constructor(e,t){super(e,t),this.type="LineLoop"}}fc.prototype.isLineLoop=!0;class Uo extends rt{constructor(e){super(),this.type="PointsMaterial",this.color=new ue(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this}}Uo.prototype.isPointsMaterial=!0;const cl=new pe,ho=new En,Ws=new Tn,qs=new T;class pc extends ke{constructor(e=new Xe,t=new Uo){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ws.copy(n.boundingSphere),Ws.applyMatrix4(i),Ws.radius+=s,e.ray.intersectsSphere(Ws)===!1)return;cl.copy(i).invert(),ho.copy(e.ray).applyMatrix4(cl);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a;if(n.isBufferGeometry){const c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,o.start),f=Math.min(c.count,o.start+o.count);for(let g=d,x=f;g<x;g++){const _=c.getX(g);qs.fromBufferAttribute(u,_),hl(qs,_,l,i,e,t,this)}}else{const d=Math.max(0,o.start),f=Math.min(u.count,o.start+o.count);for(let g=d,x=f;g<x;g++)qs.fromBufferAttribute(u,g),hl(qs,g,l,i,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}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.")}}}pc.prototype.isPoints=!0;function hl(r,e,t,n,i,s,o){const a=ho.distanceSqToPoint(r);if(a<t){const l=new T;ho.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class Mg extends tt{constructor(e,t,n,i,s,o,a,l,c){super(e,t,n,i,s,o,a,l,c),this.format=a!==void 0?a:xn,this.minFilter=o!==void 0?o:ht,this.magFilter=s!==void 0?s:ht,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Mg.prototype.isVideoTexture=!0;class bg extends tt{constructor(e,t,n){super({width:e,height:t}),this.format=n,this.magFilter=Qe,this.minFilter=Qe,this.generateMipmaps=!1,this.needsUpdate=!0}}bg.prototype.isFramebufferTexture=!0;class wg extends tt{constructor(e,t,n,i,s,o,a,l,c,h,u,d){super(null,o,a,l,c,h,i,s,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}wg.prototype.isCompressedTexture=!0;class Sg extends tt{constructor(e,t,n,i,s,o,a,l,c){super(e,t,n,i,s,o,a,l,c),this.needsUpdate=!0}}Sg.prototype.isCanvasTexture=!0;new T;new T;new T;new et;class At{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let o;t?o=t:o=e*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);const h=n[i],d=n[i+1]-h,f=(o-h)/d;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new j:new T);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new T,i=[],s=[],o=[],a=new T,l=new pe;for(let f=0;f<=e;f++){const g=f/e;i[f]=this.getTangentAt(g,new T)}s[0]=new T,o[0]=new T;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();const g=Math.acos(gt(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,g))}o[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(gt(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let g=1;g<=e;g++)s[g].applyMatrix4(l.makeRotationAxis(i[g],f*g)),o[g].crossVectors(i[g],s[g])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class pr extends At{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){const n=t||new j,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(e){return super.copy(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}toJSON(){const e=super.toJSON();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}fromJSON(e){return super.fromJSON(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}}pr.prototype.isEllipseCurve=!0;class mc extends pr{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.type="ArcCurve"}}mc.prototype.isArcCurve=!0;function zo(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,u){let d=(o-s)/c-(a-s)/(c+h)+(a-o)/h,f=(a-o)/h-(l-o)/(h+u)+(l-a)/u;d*=h,f*=h,i(o,a,d,f)},calc:function(s){const o=s*s,a=o*s;return r+e*s+t*o+n*a}}}const js=new T,Yr=new zo,Zr=new zo,Jr=new zo;class gc extends At{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new T){const n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(js.subVectors(i[0],i[1]).add(i[0]),c=js);const u=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(js.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=js),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),f),x=Math.pow(u.distanceToSquared(d),f),_=Math.pow(d.distanceToSquared(h),f);x<1e-4&&(x=1),g<1e-4&&(g=x),_<1e-4&&(_=x),Yr.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,g,x,_),Zr.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,g,x,_),Jr.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,g,x,_)}else this.curveType==="catmullrom"&&(Yr.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),Zr.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Jr.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Yr.calc(l),Zr.calc(l),Jr.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new T().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}gc.prototype.isCatmullRomCurve3=!0;function ul(r,e,t,n,i){const s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function Tg(r,e){const t=1-r;return t*t*e}function Eg(r,e){return 2*(1-r)*r*e}function Ag(r,e){return r*r*e}function Qi(r,e,t,n){return Tg(r,e)+Eg(r,t)+Ag(r,n)}function Lg(r,e){const t=1-r;return t*t*t*e}function Rg(r,e){const t=1-r;return 3*t*t*r*e}function Cg(r,e){return 3*(1-r)*r*r*e}function Pg(r,e){return r*r*r*e}function es(r,e,t,n,i){return Lg(r,e)+Rg(r,t)+Cg(r,n)+Pg(r,i)}class Ho extends At{constructor(e=new j,t=new j,n=new j,i=new j){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new j){const n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(es(e,i.x,s.x,o.x,a.x),es(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}Ho.prototype.isCubicBezierCurve=!0;class xc extends At{constructor(e=new T,t=new T,n=new T,i=new T){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new T){const n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(es(e,i.x,s.x,o.x,a.x),es(e,i.y,s.y,o.y,a.y),es(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}xc.prototype.isCubicBezierCurve3=!0;class mr extends At{constructor(e=new j,t=new j){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new j){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const n=t||new j;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}mr.prototype.isLineCurve=!0;class Ig extends At{constructor(e=new T,t=new T){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new T){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ko extends At{constructor(e=new j,t=new j,n=new j){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new j){const n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Qi(e,i.x,s.x,o.x),Qi(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}ko.prototype.isQuadraticBezierCurve=!0;class _c extends At{constructor(e=new T,t=new T,n=new T){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new T){const n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Qi(e,i.x,s.x,o.x),Qi(e,i.y,s.y,o.y),Qi(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}_c.prototype.isQuadraticBezierCurve3=!0;class Go extends At{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new j){const n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(ul(a,l.x,c.x,h.x,u.x),ul(a,l.y,c.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new j().fromArray(i))}return this}}Go.prototype.isSplineCurve=!0;var yc=Object.freeze({__proto__:null,ArcCurve:mc,CatmullRomCurve3:gc,CubicBezierCurve:Ho,CubicBezierCurve3:xc,EllipseCurve:pr,LineCurve:mr,LineCurve3:Ig,QuadraticBezierCurve:ko,QuadraticBezierCurve3:_c,SplineCurve:Go});class Dg extends At{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new mr(t,e))}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o&&o.isEllipseCurve?e*2:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new yc[i.type]().fromJSON(i))}return this}}class uo extends Dg{constructor(e){super(),this.type="Path",this.currentPoint=new j,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new mr(this.currentPoint.clone(),new j(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new ko(this.currentPoint.clone(),new j(e,t),new j(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){const a=new Ho(this.currentPoint.clone(),new j(e,t),new j(n,i),new j(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Go(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){const c=new pr(e,t,n,i,s,o,a,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class ps extends uo{constructor(e){super(e),this.uuid=Tt(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new uo().fromJSON(i))}return this}}const Ng={triangulate:function(r,e,t=2){const n=e&&e.length,i=n?e[0]*t:r.length;let s=vc(r,0,i,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c,h,u,d,f;if(n&&(s=zg(r,e,s,t)),r.length>80*t){a=c=r[0],l=h=r[1];for(let g=t;g<i;g+=t)u=r[g],d=r[g+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 rs(s,o,t,a,l,f),o}};function vc(r,e,t,n,i){let s,o;if(i===Jg(r,e,t,n)>0)for(s=e;s<t;s+=n)o=dl(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=dl(s,r[s],r[s+1],o);return o&&gr(o,o.next)&&(as(o),o=o.next),o}function wn(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(gr(t,t.next)||Ze(t.prev,t,t.next)===0)){if(as(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function rs(r,e,t,n,i,s,o){if(!r)return;!o&&s&&Wg(r,n,i,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?Og(r,n,i,s):Fg(r)){e.push(l.i/t),e.push(r.i/t),e.push(c.i/t),as(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=Bg(wn(r),e,t),rs(r,e,t,n,i,s,2)):o===2&&Ug(r,e,t,n,i,s):rs(wn(r),e,t,n,i,s,1);break}}}function Fg(r){const e=r.prev,t=r,n=r.next;if(Ze(e,t,n)>=0)return!1;let i=r.next.next;for(;i!==r.prev;){if(pi(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&Ze(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Og(r,e,t,n){const i=r.prev,s=r,o=r.next;if(Ze(i,s,o)>=0)return!1;const a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,c=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,h=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,u=fo(a,l,e,t,n),d=fo(c,h,e,t,n);let f=r.prevZ,g=r.nextZ;for(;f&&f.z>=u&&g&&g.z<=d;){if(f!==r.prev&&f!==r.next&&pi(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Ze(f.prev,f,f.next)>=0||(f=f.prevZ,g!==r.prev&&g!==r.next&&pi(i.x,i.y,s.x,s.y,o.x,o.y,g.x,g.y)&&Ze(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;f&&f.z>=u;){if(f!==r.prev&&f!==r.next&&pi(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Ze(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;g&&g.z<=d;){if(g!==r.prev&&g!==r.next&&pi(i.x,i.y,s.x,s.y,o.x,o.y,g.x,g.y)&&Ze(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function Bg(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!gr(i,s)&&Mc(i,n,n.next,s)&&os(i,s)&&os(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),as(n),as(n.next),n=r=s),n=n.next}while(n!==r);return wn(n)}function Ug(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Xg(o,a)){let l=bc(o,a);o=wn(o,o.next),l=wn(l,l.next),rs(o,e,t,n,i,s),rs(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function zg(r,e,t,n){const i=[];let s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,c=vc(r,a,l,n,!1),c===c.next&&(c.steiner=!0),i.push(jg(c));for(i.sort(Hg),s=0;s<i.length;s++)kg(i[s],t),t=wn(t,t.next);return t}function Hg(r,e){return r.x-e.x}function kg(r,e){if(e=Gg(r,e),e){const t=bc(e,r);wn(e,e.next),wn(t,t.next)}}function Gg(r,e){let t=e;const n=r.x,i=r.y;let s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s){if(s=d,d===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(n===s)return o;const a=o,l=o.x,c=o.y;let h=1/0,u;t=o;do n>=t.x&&t.x>=l&&n!==t.x&&pi(i<c?n:s,i,l,c,i<c?s:n,i,t.x,t.y)&&(u=Math.abs(i-t.y)/(n-t.x),os(t,r)&&(u<h||u===h&&(t.x>o.x||t.x===o.x&&Vg(o,t)))&&(o=t,h=u)),t=t.next;while(t!==a);return o}function Vg(r,e){return Ze(r.prev,r,e.prev)<0&&Ze(e.next,r,r.next)<0}function Wg(r,e,t,n){let i=r;do i.z===null&&(i.z=fo(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,qg(i)}function qg(r){let e,t,n,i,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<c&&(a++,n=n.nextZ,!!n);e++);for(l=c;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(o>1);return r}function fo(r,e,t,n,i){return r=32767*(r-t)*i,e=32767*(e-n)*i,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function jg(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function pi(r,e,t,n,i,s,o,a){return(i-o)*(e-a)-(r-o)*(s-a)>=0&&(r-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(n-a)>=0}function Xg(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!Yg(r,e)&&(os(r,e)&&os(e,r)&&Zg(r,e)&&(Ze(r.prev,r,e.prev)||Ze(r,e.prev,e))||gr(r,e)&&Ze(r.prev,r,r.next)>0&&Ze(e.prev,e,e.next)>0)}function Ze(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function gr(r,e){return r.x===e.x&&r.y===e.y}function Mc(r,e,t,n){const i=Ys(Ze(r,e,t)),s=Ys(Ze(r,e,n)),o=Ys(Ze(t,n,r)),a=Ys(Ze(t,n,e));return!!(i!==s&&o!==a||i===0&&Xs(r,t,e)||s===0&&Xs(r,n,e)||o===0&&Xs(t,r,n)||a===0&&Xs(t,e,n))}function Xs(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Ys(r){return r>0?1:r<0?-1:0}function Yg(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Mc(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function os(r,e){return Ze(r.prev,r,r.next)<0?Ze(r,e,r.next)>=0&&Ze(r,r.prev,e)>=0:Ze(r,e,r.prev)<0||Ze(r,r.next,e)<0}function Zg(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function bc(r,e){const t=new po(r.i,r.x,r.y),n=new po(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function dl(r,e,t,n){const i=new po(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function as(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function po(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Jg(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}class vn{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return vn.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];fl(e),pl(n,e);let o=e.length;t.forEach(fl);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,pl(n,t[l]);const a=Ng.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function fl(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function pl(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}class Ii extends Xe{constructor(e=new ps([new j(.5,.5),new j(-.5,.5),new j(-.5,-.5),new j(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let a=0,l=e.length;a<l;a++){const c=e[a];o(c)}this.setAttribute("position",new lt(i,3)),this.setAttribute("uv",new lt(s,2)),this.computeVertexNormals();function o(a){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1;let u=t.depth!==void 0?t.depth:1,d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:f-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,_=t.bevelSegments!==void 0?t.bevelSegments:3;const p=t.extrudePath,m=t.UVGenerator!==void 0?t.UVGenerator:Kg;t.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),u=t.amount);let R,y=!1,E,C,P,V;p&&(R=p.getSpacedPoints(h),y=!0,d=!1,E=p.computeFrenetFrames(h,!1),C=new T,P=new T,V=new T),d||(_=0,f=0,g=0,x=0);const ne=a.extractPoints(c);let Z=ne.shape;const I=ne.holes;if(!vn.isClockWise(Z)){Z=Z.reverse();for(let H=0,Q=I.length;H<Q;H++){const ee=I[H];vn.isClockWise(ee)&&(I[H]=ee.reverse())}}const b=vn.triangulateShape(Z,I),N=Z;for(let H=0,Q=I.length;H<Q;H++){const ee=I[H];Z=Z.concat(ee)}function O(H,Q,ee){return Q||console.error("THREE.ExtrudeGeometry: vec does not exist"),Q.clone().multiplyScalar(ee).add(H)}const D=Z.length,B=b.length;function te(H,Q,ee){let he,ie,be;const we=H.x-Q.x,Re=H.y-Q.y,Ve=ee.x-H.x,A=ee.y-H.y,v=we*we+Re*Re,q=we*A-Re*Ve;if(Math.abs(q)>Number.EPSILON){const $=Math.sqrt(v),se=Math.sqrt(Ve*Ve+A*A),K=Q.x-Re/$,Me=Q.y+we/$,xe=ee.x-A/se,L=ee.y+Ve/se,w=((xe-K)*A-(L-Me)*Ve)/(we*A-Re*Ve);he=K+we*w-H.x,ie=Me+Re*w-H.y;const J=he*he+ie*ie;if(J<=2)return new j(he,ie);be=Math.sqrt(J/2)}else{let $=!1;we>Number.EPSILON?Ve>Number.EPSILON&&($=!0):we<-Number.EPSILON?Ve<-Number.EPSILON&&($=!0):Math.sign(Re)===Math.sign(A)&&($=!0),$?(he=-Re,ie=we,be=Math.sqrt(v)):(he=we,ie=Re,be=Math.sqrt(v/2))}return new j(he/be,ie/be)}const le=[];for(let H=0,Q=N.length,ee=Q-1,he=H+1;H<Q;H++,ee++,he++)ee===Q&&(ee=0),he===Q&&(he=0),le[H]=te(N[H],N[ee],N[he]);const k=[];let G,ce=le.concat();for(let H=0,Q=I.length;H<Q;H++){const ee=I[H];G=[];for(let he=0,ie=ee.length,be=ie-1,we=he+1;he<ie;he++,be++,we++)be===ie&&(be=0),we===ie&&(we=0),G[he]=te(ee[he],ee[be],ee[we]);k.push(G),ce=ce.concat(G)}for(let H=0;H<_;H++){const Q=H/_,ee=f*Math.cos(Q*Math.PI/2),he=g*Math.sin(Q*Math.PI/2)+x;for(let ie=0,be=N.length;ie<be;ie++){const we=O(N[ie],le[ie],he);Ae(we.x,we.y,-ee)}for(let ie=0,be=I.length;ie<be;ie++){const we=I[ie];G=k[ie];for(let Re=0,Ve=we.length;Re<Ve;Re++){const A=O(we[Re],G[Re],he);Ae(A.x,A.y,-ee)}}}const ae=g+x;for(let H=0;H<D;H++){const Q=d?O(Z[H],ce[H],ae):Z[H];y?(P.copy(E.normals[0]).multiplyScalar(Q.x),C.copy(E.binormals[0]).multiplyScalar(Q.y),V.copy(R[0]).add(P).add(C),Ae(V.x,V.y,V.z)):Ae(Q.x,Q.y,0)}for(let H=1;H<=h;H++)for(let Q=0;Q<D;Q++){const ee=d?O(Z[Q],ce[Q],ae):Z[Q];y?(P.copy(E.normals[H]).multiplyScalar(ee.x),C.copy(E.binormals[H]).multiplyScalar(ee.y),V.copy(R[H]).add(P).add(C),Ae(V.x,V.y,V.z)):Ae(ee.x,ee.y,u/h*H)}for(let H=_-1;H>=0;H--){const Q=H/_,ee=f*Math.cos(Q*Math.PI/2),he=g*Math.sin(Q*Math.PI/2)+x;for(let ie=0,be=N.length;ie<be;ie++){const we=O(N[ie],le[ie],he);Ae(we.x,we.y,u+ee)}for(let ie=0,be=I.length;ie<be;ie++){const we=I[ie];G=k[ie];for(let Re=0,Ve=we.length;Re<Ve;Re++){const A=O(we[Re],G[Re],he);y?Ae(A.x,A.y+R[h-1].y,R[h-1].x+ee):Ae(A.x,A.y,u+ee)}}}fe(),Ce();function fe(){const H=i.length/3;if(d){let Q=0,ee=D*Q;for(let he=0;he<B;he++){const ie=b[he];ye(ie[2]+ee,ie[1]+ee,ie[0]+ee)}Q=h+_*2,ee=D*Q;for(let he=0;he<B;he++){const ie=b[he];ye(ie[0]+ee,ie[1]+ee,ie[2]+ee)}}else{for(let Q=0;Q<B;Q++){const ee=b[Q];ye(ee[2],ee[1],ee[0])}for(let Q=0;Q<B;Q++){const ee=b[Q];ye(ee[0]+D*h,ee[1]+D*h,ee[2]+D*h)}}n.addGroup(H,i.length/3-H,0)}function Ce(){const H=i.length/3;let Q=0;X(N,Q),Q+=N.length;for(let ee=0,he=I.length;ee<he;ee++){const ie=I[ee];X(ie,Q),Q+=ie.length}n.addGroup(H,i.length/3-H,1)}function X(H,Q){let ee=H.length;for(;--ee>=0;){const he=ee;let ie=ee-1;ie<0&&(ie=H.length-1);for(let be=0,we=h+_*2;be<we;be++){const Re=D*be,Ve=D*(be+1),A=Q+he+Re,v=Q+ie+Re,q=Q+ie+Ve,$=Q+he+Ve;me(A,v,q,$)}}}function Ae(H,Q,ee){l.push(H),l.push(Q),l.push(ee)}function ye(H,Q,ee){ge(H),ge(Q),ge(ee);const he=i.length/3,ie=m.generateTopUV(n,i,he-3,he-2,he-1);Ne(ie[0]),Ne(ie[1]),Ne(ie[2])}function me(H,Q,ee,he){ge(H),ge(Q),ge(he),ge(Q),ge(ee),ge(he);const ie=i.length/3,be=m.generateSideWallUV(n,i,ie-6,ie-3,ie-2,ie-1);Ne(be[0]),Ne(be[1]),Ne(be[3]),Ne(be[1]),Ne(be[2]),Ne(be[3])}function ge(H){i.push(l[H*3+0]),i.push(l[H*3+1]),i.push(l[H*3+2])}function Ne(H){s.push(H.x),s.push(H.y)}}}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return $g(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,o=e.shapes.length;s<o;s++){const a=t[e.shapes[s]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new yc[i.type]().fromJSON(i)),new Ii(n,e.options)}}const Kg={generateTopUV:function(r,e,t,n,i){const s=e[t*3],o=e[t*3+1],a=e[n*3],l=e[n*3+1],c=e[i*3],h=e[i*3+1];return[new j(s,o),new j(a,l),new j(c,h)]},generateSideWallUV:function(r,e,t,n,i,s){const o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],u=e[n*3+2],d=e[i*3],f=e[i*3+1],g=e[i*3+2],x=e[s*3],_=e[s*3+1],p=e[s*3+2];return Math.abs(a-h)<Math.abs(o-c)?[new j(o,1-l),new j(c,1-u),new j(d,1-g),new j(x,1-p)]:[new j(a,1-l),new j(h,1-u),new j(f,1-g),new j(_,1-p)]}};function $g(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Vo extends Xe{constructor(e=new ps([new j(0,.5),new j(-.5,-.5),new j(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(n),this.setAttribute("position",new lt(i,3)),this.setAttribute("normal",new lt(s,3)),this.setAttribute("uv",new lt(o,2));function c(h){const u=i.length/3,d=h.extractPoints(t);let f=d.shape;const g=d.holes;vn.isClockWise(f)===!1&&(f=f.reverse());for(let _=0,p=g.length;_<p;_++){const m=g[_];vn.isClockWise(m)===!0&&(g[_]=m.reverse())}const x=vn.triangulateShape(f,g);for(let _=0,p=g.length;_<p;_++){const m=g[_];f=f.concat(m)}for(let _=0,p=f.length;_<p;_++){const m=f[_];i.push(m.x,m.y,0),s.push(0,0,1),o.push(m.x,m.y)}for(let _=0,p=x.length;_<p;_++){const m=x[_],R=m[0]+u,y=m[1]+u,E=m[2]+u;n.push(R,y,E),l+=3}}}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Qg(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const o=t[e.shapes[i]];n.push(o)}return new Vo(n,e.curveSegments)}}function Qg(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}class ex extends rt{constructor(e){super(),this.type="ShadowMaterial",this.color=new ue(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}ex.prototype.isShadowMaterial=!0;class ms extends rt{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ue(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 ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kn,this.normalScale=new j(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.flatShading=!1,this.setValues(e)}copy(e){return super.copy(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.flatShading=e.flatShading,this}}ms.prototype.isMeshStandardMaterial=!0;class Gn extends ms{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new j(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.sheenColor=new ue(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new ue(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ue(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(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.ior=e.ior,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}Gn.prototype.isMeshPhysicalMaterial=!0;class tx extends rt{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new ue(16777215),this.specular=new ue(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kn,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=sr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}tx.prototype.isMeshPhongMaterial=!0;class nx extends rt{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ue(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kn,this.normalScale=new j(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.setValues(e)}copy(e){return super.copy(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}}nx.prototype.isMeshToonMaterial=!0;class ix extends rt{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kn,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(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.flatShading=e.flatShading,this}}ix.prototype.isMeshNormalMaterial=!0;class sx extends rt{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=sr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.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}}sx.prototype.isMeshLambertMaterial=!0;class rx extends rt{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ue(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kn,this.normalScale=new j(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(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.flatShading=e.flatShading,this}}rx.prototype.isMeshMatcapMaterial=!0;class ox extends Pi{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}ox.prototype.isLineDashedMaterial=!0;const Ye={arraySlice:function(r,e,t){return Ye.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n},sortedArray:function(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i},flattenJSON:function(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)},subclip:function(r,e,t,n,i=30){const s=r.clone();s.name=e;const o=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],h=c.getValueSize(),u=[],d=[];for(let f=0;f<c.times.length;++f){const g=c.times[f]*i;if(!(g<t||g>=n)){u.push(c.times[f]);for(let x=0;x<h;++x)d.push(c.values[f*h+x])}}u.length!==0&&(c.times=Ye.convertArray(u,c.times.constructor),c.values=Ye.convertArray(d,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(r,e=0,t=r,n=30){n<=0&&(n=30);const i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){const a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(p){return p.name===a.name&&p.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 g=a.times.length-1;let x;if(s<=a.times[0]){const p=h,m=u-h;x=Ye.arraySlice(a.values,p,m)}else if(s>=a.times[g]){const p=g*u+h,m=p+u-h;x=Ye.arraySlice(a.values,p,m)}else{const p=a.createInterpolant(),m=h,R=u-h;p.evaluate(s),x=Ye.arraySlice(p.resultBuffer,m,R)}l==="quaternion"&&new at().fromArray(x).normalize().conjugate().toArray(x);const _=c.times.length;for(let p=0;p<_;++p){const m=p*f+d;if(l==="quaternion")at.multiplyQuaternionsFlat(c.values,m,x,0,c.values,m);else{const R=f-d*2;for(let y=0;y<R;++y)c.values[m+y]-=x[y]}}}return r.blendMode=Ul,r}};class tn{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,e,s)}if(n===a)break;if(s=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=s)){const a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,i);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break t}o=n,n=0;break n}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,i);if(i===void 0)return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,s,e)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}tn.prototype.beforeStart_=tn.prototype.copySampleValue_;tn.prototype.afterEnd_=tn.prototype.copySampleValue_;class ax extends tn{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:di,endingEnd:di}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case fi:s=e,a=2*t-n;break;case tr:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case fi:o=e,l=2*n-t;break;case tr:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=o*h}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),x=g*g,_=x*g,p=-d*_+2*d*x-d*g,m=(1+d)*_+(-1.5-2*d)*x+(-.5+d)*g+1,R=(-1-f)*_+(1.5+f)*x+.5*g,y=f*_-f*x;for(let E=0;E!==a;++E)s[E]=p*o[h+E]+m*o[c+E]+R*o[l+E]+y*o[u+E];return s}}class wc extends tn{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(n-t)/(i-t),u=1-h;for(let d=0;d!==a;++d)s[d]=o[c+d]*u+o[l+d]*h;return s}}class lx extends tn{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Gt{constructor(e,t,n,i){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=Ye.convertArray(t,this.TimeBufferType),this.values=Ye.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ye.convertArray(e.times,Array),values:Ye.convertArray(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new lx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new wc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ax(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ns:t=this.InterpolantFactoryMethodDiscrete;break;case bi:t=this.InterpolantFactoryMethodLinear;break;case _r:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="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(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ns;case this.InterpolantFactoryMethodLinear:return bi;case this.InterpolantFactoryMethodSmooth:return _r}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=Ye.arraySlice(n,s,o),this.values=Ye.arraySlice(this.values,s*a,o*a)}return this}validate(){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 n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&Ye.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=Ye.arraySlice(this.times),t=Ye.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===_r,s=e.length-1;let o=1;for(let a=1;a<s;++a){let l=!1;const c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(i)l=!0;else{const u=a*n,d=u-n,f=u+n;for(let g=0;g!==n;++g){const x=t[u+g];if(x!==t[d+g]||x!==t[f+g]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const u=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=Ye.arraySlice(e,0,o),this.values=Ye.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=Ye.arraySlice(this.times,0),t=Ye.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Gt.prototype.TimeBufferType=Float32Array;Gt.prototype.ValueBufferType=Float32Array;Gt.prototype.DefaultInterpolation=bi;class Di extends Gt{}Di.prototype.ValueTypeName="bool";Di.prototype.ValueBufferType=Array;Di.prototype.DefaultInterpolation=ns;Di.prototype.InterpolantFactoryMethodLinear=void 0;Di.prototype.InterpolantFactoryMethodSmooth=void 0;class Sc extends Gt{}Sc.prototype.ValueTypeName="color";class ls extends Gt{}ls.prototype.ValueTypeName="number";class cx extends tn{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let h=c+a;c!==h;c+=4)at.slerpFlat(s,0,o,c-a,o,c,l);return s}}class zn extends Gt{InterpolantFactoryMethodLinear(e){return new cx(this.times,this.values,this.getValueSize(),e)}}zn.prototype.ValueTypeName="quaternion";zn.prototype.DefaultInterpolation=bi;zn.prototype.InterpolantFactoryMethodSmooth=void 0;class Ni extends Gt{}Ni.prototype.ValueTypeName="string";Ni.prototype.ValueBufferType=Array;Ni.prototype.DefaultInterpolation=ns;Ni.prototype.InterpolantFactoryMethodLinear=void 0;Ni.prototype.InterpolantFactoryMethodSmooth=void 0;class cs extends Gt{}cs.prototype.ValueTypeName="vector";class mo{constructor(e,t=-1,n,i=So){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Tt(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(ux(n[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(Gt.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);const h=Ye.getKeyframeOrder(l);l=Ye.sortedArray(l,1,h),c=Ye.sortedArray(c,1,h),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new ls(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,g,x){if(f.length!==0){const _=[],p=[];Ye.flattenJSON(f,_,p,g),_.length!==0&&x.push(new u(d,_,p))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const d=c[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let x=0;x<d[g].morphTargets.length;x++)f[d[g].morphTargets[x]]=-1;for(const x in f){const _=[],p=[];for(let m=0;m!==d[g].morphTargets.length;++m){const R=d[g];_.push(R.time),p.push(R.morphTarget===x?1:0)}i.push(new ls(".morphTargetInfluence["+x+"]",_,p))}l=f.length*(o||1)}else{const f=".bones["+t[u].name+"]";n(cs,f+".position",d,"pos",i),n(zn,f+".quaternion",d,"rot",i),n(cs,f+".scale",d,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function hx(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ls;case"vector":case"vector2":case"vector3":case"vector4":return cs;case"color":return Sc;case"quaternion":return zn;case"bool":case"boolean":return Di;case"string":return Ni}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function ux(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=hx(r.type);if(r.times===void 0){const t=[],n=[];Ye.flattenJSON(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const Ti={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class dx{constructor(e,t,n){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){const f=c[u],g=c[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}return null}}}const Tc=new dx;class nn{constructor(e){this.manager=e!==void 0?e:Tc,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const Zt={};class Wo extends nn{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Ti.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Zt[e]!==void 0){Zt[e].push({onLoad:t,onProgress:n,onError:i});return}Zt[e]=[],Zt[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"});fetch(o).then(a=>{if(a.status===200||a.status===0){if(a.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||a.body.getReader===void 0)return a;const l=Zt[e],c=a.body.getReader(),h=a.headers.get("Content-Length"),u=h?parseInt(h):0,d=u!==0;let f=0;const g=new ReadableStream({start(x){_();function _(){c.read().then(({done:p,value:m})=>{if(p)x.close();else{f+=m.byteLength;const R=new ProgressEvent("progress",{lengthComputable:d,loaded:f,total:u});for(let y=0,E=l.length;y<E;y++){const C=l[y];C.onProgress&&C.onProgress(R)}x.enqueue(m),_()}})}}});return new Response(g)}else throw Error(`fetch for "${a.url}" responded with ${a.status}: ${a.statusText}`)}).then(a=>{switch(this.responseType){case"arraybuffer":return a.arrayBuffer();case"blob":return a.blob();case"document":return a.text().then(l=>new DOMParser().parseFromString(l,this.mimeType));case"json":return a.json();default:return a.text()}}).then(a=>{Ti.add(e,a);const l=Zt[e];delete Zt[e];for(let c=0,h=l.length;c<h;c++){const u=l[c];u.onLoad&&u.onLoad(a)}}).catch(a=>{const l=Zt[e];if(l===void 0)throw this.manager.itemError(e),a;delete Zt[e];for(let c=0,h=l.length;c<h;c++){const u=l[c];u.onError&&u.onError(a)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Ec extends nn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ti.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=or("img");function l(){h(),Ti.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(u){h(),i&&i(u),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class fx extends nn{constructor(e){super(e)}load(e,t,n,i){const s=new ar,o=new Ec(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(h){s.images[c]=h,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,i)}for(let c=0;c<e.length;++c)l(c);return s}}class Ac extends nn{constructor(e){super(e)}load(e,t,n,i){const s=new tt,o=new Ec(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class kt extends ke{constructor(e,t=1){super(),this.type="Light",this.color=new ue(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}kt.prototype.isLight=!0;class px extends kt{constructor(e,t,n){super(e,n),this.type="HemisphereLight",this.position.copy(ke.DefaultUp),this.updateMatrix(),this.groundColor=new ue(t)}copy(e){return kt.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}px.prototype.isHemisphereLight=!0;const ml=new pe,gl=new T,xl=new T;class qo{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new j(512,512),this.map=null,this.mapPass=null,this.matrix=new pe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new lr,this._frameExtents=new j(1,1),this._viewportCount=1,this._viewports=[new qe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;gl.setFromMatrixPosition(e.matrixWorld),t.position.copy(gl),xl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(xl),t.updateMatrixWorld(),ml.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ml),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){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}}class Lc extends qo{constructor(){super(new pt(50,1,.5,500)),this.focus=1}updateMatrices(e){const t=this.camera,n=ss*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}Lc.prototype.isSpotLightShadow=!0;class Rc extends kt{constructor(e,t,n=0,i=Math.PI/3,s=0,o=1){super(e,t),this.type="SpotLight",this.position.copy(ke.DefaultUp),this.updateMatrix(),this.target=new ke,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Lc}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(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}}Rc.prototype.isSpotLight=!0;const _l=new pe,qi=new T,Kr=new T;class Cc extends qo{constructor(){super(new pt(90,1,.5,500)),this._frameExtents=new j(4,2),this._viewportCount=6,this._viewports=[new qe(2,1,1,1),new qe(0,1,1,1),new qe(3,1,1,1),new qe(1,1,1,1),new qe(3,0,1,1),new qe(1,0,1,1)],this._cubeDirections=[new T(1,0,0),new T(-1,0,0),new T(0,0,1),new T(0,0,-1),new T(0,1,0),new T(0,-1,0)],this._cubeUps=[new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,0,1),new T(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),qi.setFromMatrixPosition(e.matrixWorld),n.position.copy(qi),Kr.copy(n.position),Kr.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Kr),n.updateMatrixWorld(),i.makeTranslation(-qi.x,-qi.y,-qi.z),_l.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_l)}}Cc.prototype.isPointLightShadow=!0;class Pc extends kt{constructor(e,t,n=0,i=1){super(e,t),this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Cc}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}Pc.prototype.isPointLight=!0;class Ic extends qo{constructor(){super(new cr(-5,5,5,-5,.5,500))}}Ic.prototype.isDirectionalLightShadow=!0;class jo extends kt{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(ke.DefaultUp),this.updateMatrix(),this.target=new ke,this.shadow=new Ic}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}jo.prototype.isDirectionalLight=!0;class Dc extends kt{constructor(e,t){super(e,t),this.type="AmbientLight"}}Dc.prototype.isAmbientLight=!0;class mx extends kt{constructor(e,t,n=10,i=10){super(e,t),this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}mx.prototype.isRectAreaLight=!0;class Nc{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new T)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*i)),t.addScaledVector(o[5],1.092548*(i*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(n*s)),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*i),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*i),t.addScaledVector(o[5],2*.429043*i*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*n*s),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,s=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-i*i)}}Nc.prototype.isSphericalHarmonics3=!0;class Xo extends kt{constructor(e=new Nc,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}Xo.prototype.isLightProbe=!0;class Mn{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substr(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class gx extends Xe{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}gx.prototype.isInstancedBufferGeometry=!0;class Fc extends nn{constructor(e){super(e),typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ti.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){Ti.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}Fc.prototype.isImageBitmapLoader=!0;let Zs;const xx={getContext:function(){return Zs===void 0&&(Zs=new(window.AudioContext||window.webkitAudioContext)),Zs},setContext:function(r){Zs=r}};class _x extends nn{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new Wo(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{const l=a.slice(0);xx.getContext().decodeAudioData(l,function(h){t(h)})}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}}class yx extends Xo{constructor(e,t,n=1){super(void 0,n);const i=new ue().set(e),s=new ue().set(t),o=new T(i.r,i.g,i.b),a=new T(s.r,s.g,s.b),l=Math.sqrt(Math.PI),c=l*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(l),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(c)}}yx.prototype.isHemisphereLightProbe=!0;class vx extends Xo{constructor(e,t=1){super(void 0,t);const n=new ue().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}vx.prototype.isAmbientLightProbe=!0;class Mx extends ke{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}class bx{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,s,o;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,s=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[s+a]=n[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(n,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(n,i,l,1-s,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,o=i;s!==o;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,s){if(i>=.5)for(let o=0;o!==s;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){at.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const o=this._workIndex*s;at.multiplyQuaternionsFlat(e,o,e,t,e,n),at.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,s){const o=1-i;for(let a=0;a!==s;++a){const l=t+a;e[l]=e[l]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const Yo="\\[\\]\\.:\\/",wx=new RegExp("["+Yo+"]","g"),Zo="[^"+Yo+"]",Sx="[^"+Yo.replace("\\.","")+"]",Tx=/((?:WC+[\/:])*)/.source.replace("WC",Zo),Ex=/(WCOD+)?/.source.replace("WCOD",Sx),Ax=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zo),Lx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zo),Rx=new RegExp("^"+Tx+Ex+Ax+Lx+"$"),Cx=["material","materials","bones"];class Px{constructor(e,t,n){const i=n||He.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class He{constructor(e,t,n){this.path=t,this.parsedPath=n||He.parseTrackName(t),this.node=He.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new He.Composite(e,t,n):new He(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(wx,"")}static parseTrackName(e){const t=Rx.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);Cx.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(!t||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let o=0;o<s.length;o++){const a=s[o];if(a.name===t||a.uuid===t)return a;const l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=He.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(n){let c=t.objectIndex;switch(n){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 h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[i];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="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[s]!==void 0&&(s=e.morphTargetDictionary[s])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}He.Composite=Px;He.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};He.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};He.prototype.GetterByBindingType=[He.prototype._getValue_direct,He.prototype._getValue_array,He.prototype._getValue_arrayElement,He.prototype._getValue_toArray];He.prototype.SetterByBindingTypeAndVersioning=[[He.prototype._setValue_direct,He.prototype._setValue_direct_setNeedsUpdate,He.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[He.prototype._setValue_array,He.prototype._setValue_array_setNeedsUpdate,He.prototype._setValue_array_setMatrixWorldNeedsUpdate],[He.prototype._setValue_arrayElement,He.prototype._setValue_arrayElement_setNeedsUpdate,He.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[He.prototype._setValue_fromArray,He.prototype._setValue_fromArray_setNeedsUpdate,He.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ix{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,o=s.length,a=new Array(o),l={endingStart:di,endingEnd:di};for(let c=0;c!==o;++c){const h=s[c].createInterpolant(null);a[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=du,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(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,o=s/i,a=i/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;if(l<0||n===0)return;this._startTime=null,t=n*l}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Ul:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(o),c[h].accumulateAdditive(a);break;case So:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(o),c[h].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;n!==null&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const o=n===fu;if(e===0)return s===-1?i:o&&(s&1)===1?t-i:i;if(n===uu){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=fi,i.endingEnd=fi):(e?i.endingStart=this.zeroSlopeAtStart?fi:di:i.endingStart=tr,t?i.endingEnd=this.zeroSlopeAtEnd?fi:di:i.endingEnd=tr)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=n,this}}class Dx extends Sn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,o=e._propertyBindings,a=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=i[u],f=d.name;let g=h[f];if(g!==void 0)o[u]=g;else{if(g=o[u],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,l,f));continue}const x=t&&t._propertyBindings[u].binding.parsedPath;g=new bx(He.create(n,f,x),d.ValueTypeName,d.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,l,f),o[u]=g}a[u].resultBuffer=g.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;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(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,s=this._actionsByClip;let o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],h=e._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),e._byClipCacheIndex=null;const u=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,s=this._bindings;let o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[i],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new wc(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,s=t[i];e.__cacheIndex=i,t[i]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const i=t||this._root,s=i.uuid;let o=typeof e=="string"?mo.findByName(i,e):e;const a=o!==null?o.uuid:e,l=this._actionsByClip[a];let c=null;if(n===void 0&&(o!==null?n=o.blendMode:n=So),l!==void 0){const u=l.actionByRoot[s];if(u!==void 0&&u.blendMode===n)return u;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const h=new Ix(this,o,t,n);return this._bindAction(h,c),this._addInactiveAction(h,a,s),h}existingAction(e,t){const n=t||this._root,i=n.uuid,s=typeof e=="string"?mo.findByName(n,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const h=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,s=i[t];if(s!==void 0)for(const o in s){const a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}Dx.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class Nx extends Ci{constructor(e,t,n=1){super(e,t),this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}Nx.prototype.isInstancedInterleavedBuffer=!0;class Fx{constructor(e,t,n=0,i=1/0){this.ray=new En(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Ao,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(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(e,t=!0,n=[]){return go(e,this,n,t),n.sort(yl),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)go(e[i],this,n,t);return n.sort(yl),n}}function yl(r,e){return r.distance-e.distance}function go(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){const i=r.children;for(let s=0,o=i.length;s<o;s++)go(i[s],e,t,!0)}}class vl{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(gt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const un=new T,Js=new pe,$r=new pe;class Ox extends fr{constructor(e){const t=Oc(e),n=new Xe,i=[],s=[],o=new ue(0,0,1),a=new ue(0,1,0);for(let c=0;c<t.length;c++){const h=t[c];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}n.setAttribute("position",new lt(i,3)),n.setAttribute("color",new lt(s,3));const l=new Pi({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");$r.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){const a=t[s];a.parent&&a.parent.isBone&&(Js.multiplyMatrices($r,a.matrixWorld),un.setFromMatrixPosition(Js),i.setXYZ(o,un.x,un.y,un.z),Js.multiplyMatrices($r,a.parent.matrixWorld),un.setFromMatrixPosition(Js),i.setXYZ(o+1,un.x,un.y,un.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function Oc(r){const e=[];r&&r.isBone&&e.push(r);for(let t=0;t<r.children.length;t++)e.push.apply(e,Oc(r.children[t]));return e}class Bx extends fr{constructor(e=10,t=10,n=4473924,i=8947848){n=new ue(n),i=new ue(i);const s=t/2,o=e/t,a=e/2,l=[],c=[];for(let d=0,f=0,g=-a;d<=t;d++,g+=o){l.push(-a,0,g,a,0,g),l.push(g,0,-a,g,0,a);const x=d===s?n:i;x.toArray(c,f),f+=3,x.toArray(c,f),f+=3,x.toArray(c,f),f+=3,x.toArray(c,f),f+=3}const h=new Xe;h.setAttribute("position",new lt(l,3)),h.setAttribute("color",new lt(c,3));const u=new Pi({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}}const Ux=new Float32Array(1);new Int32Array(Ux.buffer);At.create=function(r,e){return console.log("THREE.Curve.create() has been deprecated"),r.prototype=Object.create(At.prototype),r.prototype.constructor=r,r.prototype.getPoint=e,r};uo.prototype.fromPoints=function(r){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(r)};Bx.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};Ox.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};nn.prototype.extractUrlBase=function(r){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Mn.extractUrlBase(r)};nn.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.")}};wt.prototype.center=function(r){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(r)};wt.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()};wt.prototype.isIntersectionBox=function(r){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(r)};wt.prototype.isIntersectionSphere=function(r){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(r)};wt.prototype.size=function(r){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(r)};Tn.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()};lr.prototype.setFromMatrix=function(r){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(r)};ut.prototype.flattenToArrayOffset=function(r,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(r,e)};ut.prototype.multiplyVector3=function(r){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),r.applyMatrix3(this)};ut.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")};ut.prototype.applyToBufferAttribute=function(r){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),r.applyMatrix3(this)};ut.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")};ut.prototype.getInverse=function(r){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(r).invert()};pe.prototype.extractPosition=function(r){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(r)};pe.prototype.flattenToArrayOffset=function(r,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(r,e)};pe.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new T().setFromMatrixColumn(this,3)};pe.prototype.setRotationFromQuaternion=function(r){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(r)};pe.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")};pe.prototype.multiplyVector3=function(r){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),r.applyMatrix4(this)};pe.prototype.multiplyVector4=function(r){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),r.applyMatrix4(this)};pe.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")};pe.prototype.rotateAxis=function(r){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),r.transformDirection(this)};pe.prototype.crossVector=function(r){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),r.applyMatrix4(this)};pe.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")};pe.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")};pe.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")};pe.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")};pe.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")};pe.prototype.applyToBufferAttribute=function(r){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),r.applyMatrix4(this)};pe.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")};pe.prototype.makeFrustum=function(r,e,t,n,i,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(r,e,n,t,i,s)};pe.prototype.getInverse=function(r){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(r).invert()};Kt.prototype.isIntersectionLine=function(r){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(r)};at.prototype.multiplyVector3=function(r){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),r.applyQuaternion(this)};at.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()};En.prototype.isIntersectionBox=function(r){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(r)};En.prototype.isIntersectionPlane=function(r){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(r)};En.prototype.isIntersectionSphere=function(r){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(r)};et.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()};et.prototype.barycoordFromPoint=function(r,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(r,e)};et.prototype.midpoint=function(r){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(r)};et.prototypenormal=function(r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(r)};et.prototype.plane=function(r){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(r)};et.barycoordFromPoint=function(r,e,t,n,i){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),et.getBarycoord(r,e,t,n,i)};et.normal=function(r,e,t,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),et.getNormal(r,e,t,n)};ps.prototype.extractAllPoints=function(r){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(r)};ps.prototype.extrude=function(r){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Ii(this,r)};ps.prototype.makeGeometry=function(r){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Vo(this,r)};j.prototype.fromAttribute=function(r,e,t){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(r,e,t)};j.prototype.distanceToManhattan=function(r){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(r)};j.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};T.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")};T.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")};T.prototype.getPositionFromMatrix=function(r){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(r)};T.prototype.getScaleFromMatrix=function(r){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(r)};T.prototype.getColumnFromMatrix=function(r,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,r)};T.prototype.applyProjection=function(r){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(r)};T.prototype.fromAttribute=function(r,e,t){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(r,e,t)};T.prototype.distanceToManhattan=function(r){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(r)};T.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};qe.prototype.fromAttribute=function(r,e,t){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(r,e,t)};qe.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};ke.prototype.getChildByName=function(r){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(r)};ke.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")};ke.prototype.translate=function(r,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,r)};ke.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")};ke.prototype.applyMatrix=function(r){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)};Object.defineProperties(ke.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(r){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=r}},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.")}}});xt.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(xt.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),pu},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.")}}});Fo.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")};pt.prototype.setLens=function(r,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),e!==void 0&&(this.filmGauge=e),this.setFocalLength(r)};Object.defineProperties(kt.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(r){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=r}},shadowCameraLeft:{set:function(r){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=r}},shadowCameraRight:{set:function(r){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=r}},shadowCameraTop:{set:function(r){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=r}},shadowCameraBottom:{set:function(r){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=r}},shadowCameraNear:{set:function(r){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=r}},shadowCameraFar:{set:function(r){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=r}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(r){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=r}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(r){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=r}},shadowMapHeight:{set:function(r){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=r}}});Object.defineProperties($e.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===nr},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(nr)}}});$e.prototype.setDynamic=function(r){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(r===!0?nr:is),this};$e.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},$e.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")};Xe.prototype.addIndex=function(r){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(r)};Xe.prototype.addAttribute=function(r,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(e&&e.isBufferAttribute)&&!(e&&e.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(r,new $e(arguments[1],arguments[2]))):r==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(r,e)};Xe.prototype.addDrawCall=function(r,e,t){t!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(r,e)};Xe.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()};Xe.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")};Xe.prototype.removeAttribute=function(r){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(r)};Xe.prototype.applyMatrix=function(r){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)};Object.defineProperties(Xe.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}}});Ci.prototype.setDynamic=function(r){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(r===!0?nr:is),this};Ci.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")};Ii.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")};Ii.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")};Ii.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")};No.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")};Object.defineProperties(rt.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 ue}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(r){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=r===Dl}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(r){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=r}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}});Object.defineProperties(bn.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(r){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=r}}});Ge.prototype.clearTarget=function(r,e,t,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(r),this.clear(e,t,n)};Ge.prototype.animate=function(r){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(r)};Ge.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()};Ge.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()};Ge.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision};Ge.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()};Ge.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")};Ge.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")};Ge.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")};Ge.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")};Ge.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")};Ge.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")};Ge.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures};Ge.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")};Ge.prototype.enableScissorTest=function(r){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(r)};Ge.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")};Ge.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")};Ge.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")};Ge.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")};Ge.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")};Ge.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")};Ge.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")};Ge.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")};Ge.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")};Ge.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()};Object.defineProperties(Ge.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(r){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=r}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(r){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=r}},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(r){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=r===!0?Ht:Dt}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}},gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});Object.defineProperties(lc.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(Et.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(r){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=r}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(r){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=r}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(r){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=r}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(r){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=r}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(r){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=r}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(r){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=r}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(r){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=r}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(r){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=r}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(r){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=r}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(r){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=r}}});Mx.prototype.load=function(r){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const e=this;return new _x().load(r,function(n){e.setBuffer(n)}),this};Ro.prototype.updateCubeMap=function(r,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(r,e)};Ro.prototype.clear=function(r,e,t,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(r,e,t,n)};Ai.crossOrigin=void 0;Ai.loadTexture=function(r,e,t,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const i=new Ac;i.setCrossOrigin(this.crossOrigin);const s=i.load(r,t,void 0,n);return e&&(s.mapping=e),s};Ai.loadTextureCube=function(r,e,t,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const i=new fx;i.setCrossOrigin(this.crossOrigin);const s=i.load(r,t,void 0,n);return e&&(s.mapping=e),s};Ai.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};Ai.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:bo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=bo);function zx(r){return new TextDecoder().decode(r)}class Bc{constructor(e,t,n,i){this.buffer=e,this.binOffset=t+n,this.binLength=i;let s=null;if(n!==0){const o=new Uint8Array(e,t,n);s=JSON.parse(zx(o))}else s={};this.header=s}getKeys(){return Object.keys(this.header)}getData(e,t,n=null,i=null){const s=this.header;if(!(e in s))return null;const o=s[e];if(o instanceof Object){if(Array.isArray(o))return o;{const{buffer:a,binOffset:l,binLength:c}=this,h=o.byteOffset||0,u=o.type||i,d=o.componentType||n;if("type"in o&&i&&o.type!==i)throw new Error("FeatureTable: Specified type does not match expected type.");let f;switch(u){case"SCALAR":f=1;break;case"VEC2":f=2;break;case"VEC3":f=3;break;case"VEC4":f=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${e}".`)}let g;const x=l+h,_=t*f;switch(d){case"BYTE":g=new Int8Array(a,x,_);break;case"UNSIGNED_BYTE":g=new Uint8Array(a,x,_);break;case"SHORT":g=new Int16Array(a,x,_);break;case"UNSIGNED_SHORT":g=new Uint16Array(a,x,_);break;case"INT":g=new Int32Array(a,x,_);break;case"UNSIGNED_INT":g=new Uint32Array(a,x,_);break;case"FLOAT":g=new Float32Array(a,x,_);break;case"DOUBLE":g=new Float64Array(a,x,_);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${e}".`)}if(x+_*g.BYTES_PER_ELEMENT>l+c)throw new Error("FeatureTable: Feature data read outside binary body length.");return g}}else return o}}class Hx extends Bc{constructor(e,t,n,i,s){super(e,n,i,s),this.batchSize=t}getData(e,t=null,n=null){return super.getData(e,this.batchSize,t,n)}}class kx{constructor(){this.fetchOptions={},this.workingPath=""}load(e){return fetch(e,this.fetchOptions).then(t=>{if(!t.ok)throw new Error(`Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()}).then(t=>(this.workingPath===""&&(this.workingPath=this.workingPathForURL(e)),this.parse(t)))}resolveExternalURL(e){return/^[^\\/]/.test(e)?this.workingPath+"/"+e:e}workingPathForURL(e){const t=e.split(/[\\/]/g);return t.pop(),t.join("/")+"/"}parse(e){throw new Error("LoaderBase: Parse not implemented.")}}function Gx(r){let e;if(r instanceof DataView?e=r:e=new DataView(r),String.fromCharCode(e.getUint8(0))==="{")return null;let t="";for(let n=0;n<4;n++)t+=String.fromCharCode(e.getUint8(n));return t}class Vx extends kx{parse(e){const t=new DataView(e),n=Gx(t);console.assert(n==="b3dm");const i=t.getUint32(4,!0);console.assert(i===1);const s=t.getUint32(8,!0);console.assert(s===e.byteLength);const o=t.getUint32(12,!0),a=t.getUint32(16,!0),l=t.getUint32(20,!0),c=t.getUint32(24,!0),h=28,u=e.slice(h,h+o+a),d=new Bc(u,0,o,a),f=h+o+a,g=e.slice(f,f+l+c),x=new Hx(g,d.getData("BATCH_LENGTH"),0,l,c),_=f+l+c,p=new Uint8Array(e,_,s-_);return{version:i,featureTable:d,batchTable:x,glbBytes:p}}}class Wx extends nn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Yx(t)}),this.register(function(t){return new e_(t)}),this.register(function(t){return new t_(t)}),this.register(function(t){return new Zx(t)}),this.register(function(t){return new Jx(t)}),this.register(function(t){return new Kx(t)}),this.register(function(t){return new $x(t)}),this.register(function(t){return new Qx(t)}),this.register(function(t){return new jx(t)}),this.register(function(t){return new n_(t)})}load(e,t,n,i){const s=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=Mn.extractUrlBase(e),this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new Wo(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,o,function(h){t(h),s.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const o={},a={};if(typeof e=="string")s=e;else if(Mn.decodeText(new Uint8Array(e,0,4))===Uc){try{o[Oe.KHR_BINARY_GLTF]=new i_(e)}catch(u){i&&i(u);return}s=o[Oe.KHR_BINARY_GLTF].content}else s=Mn.decodeText(new Uint8Array(e));const l=JSON.parse(s);if(l.asset===void 0||l.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new m_(l,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](c);a[u.name]=u,o[u.name]=!0}if(l.extensionsUsed)for(let h=0;h<l.extensionsUsed.length;++h){const u=l.extensionsUsed[h],d=l.extensionsRequired||[];switch(u){case Oe.KHR_MATERIALS_UNLIT:o[u]=new Xx;break;case Oe.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[u]=new o_;break;case Oe.KHR_DRACO_MESH_COMPRESSION:o[u]=new s_(l,this.dracoLoader);break;case Oe.KHR_TEXTURE_TRANSFORM:o[u]=new r_;break;case Oe.KHR_MESH_QUANTIZATION:o[u]=new a_;break;default:d.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function qx(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const Oe={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_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",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"};class jx{constructor(e){this.parser=e,this.name=Oe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const h=new ue(16777215);l.color!==void 0&&h.fromArray(l.color);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new jo(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Pc(h),c.distance=u;break;case"spot":c=new Rc(h),c.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),c.decay=2,l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Xx{constructor(){this.name=Oe.KHR_MATERIALS_UNLIT}getMaterialType(){return pn}extendParams(e,t,n){const i=[];e.color=new ue(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const o=s.baseColorFactor;e.color.fromArray(o),e.opacity=o[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture))}return Promise.all(i)}}class Yx{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Gn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new j(a,a)}return Promise.all(s)}}class Zx{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Gn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new ue(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.extensions[this.name];return o.sheenColorFactor!==void 0&&t.sheenColor.fromArray(o.sheenColorFactor),o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture)),o.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class Jx{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Gn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}}class Kx{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Gn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new ue(a[0],a[1],a[2]),Promise.all(s)}}class $x{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Gn}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class Qx{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Gn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new ue(a[0],a[1],a[2]),o.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture).then(function(l){l.encoding=Ht})),Promise.all(s)}}class e_{constructor(e){this.parser=e,this.name=Oe.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],o=n.images[s.source],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o,a)}}class t_{constructor(e){this.parser=e,this.name=Oe.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,a,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class n_{constructor(e){this.name=Oe.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([s,o.ready]).then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,h=i.count,u=i.byteStride,d=new ArrayBuffer(h*u),f=new Uint8Array(a[0],l,c);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,i.mode,i.filter),d})}else return null}}const Uc="glTF",ji=12,Ml={JSON:1313821514,BIN:5130562};class i_{constructor(e){this.name=Oe.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ji);if(this.header={magic:Mn.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Uc)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-ji,i=new DataView(e,ji);let s=0;for(;s<n;){const o=i.getUint32(s,!0);s+=4;const a=i.getUint32(s,!0);if(s+=4,a===Ml.JSON){const l=new Uint8Array(e,ji+s,o);this.content=Mn.decodeText(l)}else if(a===Ml.BIN){const l=ji+s;this.body=e.slice(l,l+o)}s+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class s_{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Oe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const h in o){const u=_o[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=_o[h]||h.toLowerCase();if(o[h]!==void 0){const d=n.accessors[e.attributes[h]],f=hs[d.componentType];c[u]=f,l[u]=d.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(u){i.decodeDracoFile(h,function(d){for(const f in d.attributes){const g=d.attributes[f],x=l[f];x!==void 0&&(g.normalized=x)}u(d)},a,c)})})}}class r_{constructor(){this.name=Oe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return t.texCoord!==void 0&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class xo extends ms{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP"," uniform sampler2D specularMap;","#endif"].join(`
  2949. `),n=["#ifdef USE_GLOSSINESSMAP"," uniform sampler2D glossinessMap;","#endif"].join(`
  2950. `),i=["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(`
  2951. `),s=["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(`
  2952. `),o=["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.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join(`
  2953. `),a={specular:{value:new ue().setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(l){for(const c in a)l.uniforms[c]=a[c];l.fragmentShader=l.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",i).replace("#include <metalnessmap_fragment>",s).replace("#include <lights_physical_fragment>",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(l){a.specular.value=l}},specularMap:{get:function(){return a.specularMap.value},set:function(l){a.specularMap.value=l,l?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(l){a.glossiness.value=l}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(l){a.glossinessMap.value=l,l?(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(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class o_{constructor(){this.name=Oe.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.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(){return xo}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new ue(1,1,1),e.opacity=1;const s=[];if(Array.isArray(i.diffuseFactor)){const o=i.diffuseFactor;e.color.fromArray(o),e.opacity=o[3]}if(i.diffuseTexture!==void 0&&s.push(n.assignTexture(e,"map",i.diffuseTexture)),e.emissive=new ue(0,0,0),e.glossiness=i.glossinessFactor!==void 0?i.glossinessFactor:1,e.specular=new ue(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),i.specularGlossinessTexture!==void 0){const o=i.specularGlossinessTexture;s.push(n.assignTexture(e,"glossinessMap",o)),s.push(n.assignTexture(e,"specularMap",o))}return Promise.all(s)}createMaterial(e){const t=new xo(e);return t.fog=!0,t.color=e.color,t.map=e.map===void 0?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=e.aoMap===void 0?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=e.emissiveMap===void 0?null:e.emissiveMap,t.bumpMap=e.bumpMap===void 0?null:e.bumpMap,t.bumpScale=1,t.normalMap=e.normalMap===void 0?null:e.normalMap,t.normalMapType=kn,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=e.specularMap===void 0?null:e.specularMap,t.specular=e.specular,t.glossinessMap=e.glossinessMap===void 0?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=e.envMap===void 0?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}class a_{constructor(){this.name=Oe.KHR_MESH_QUANTIZATION}}class Hn extends tn{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[s+o];return t}}Hn.prototype.beforeStart_=Hn.prototype.copySampleValue_;Hn.prototype.afterEnd_=Hn.prototype.copySampleValue_;Hn.prototype.interpolate_=function(r,e,t,n){const i=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,l=o*3,c=n-e,h=(t-e)/c,u=h*h,d=u*h,f=r*l,g=f-l,x=-2*d+3*u,_=d-u,p=1-x,m=_-u+h;for(let R=0;R!==o;R++){const y=s[g+R+o],E=s[g+R+a]*c,C=s[f+R+o],P=s[f+R]*c;i[R]=p*y+m*E+x*C+_*P}return i};const l_=new at;class c_ extends Hn{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return l_.fromArray(s).normalize().toArray(s),s}}const Jt={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},hs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bl={9728:Qe,9729:ht,9984:so,9985:Bl,9986:ro,9987:Ei},wl={33071:yt,33648:er,10497:vi},Sl={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},_o={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},dn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},h_={CUBICSPLINE:void 0,LINEAR:bi,STEP:ns},Qr={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function u_(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new ms({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:yi})),r.DefaultMaterial}function Xi(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Nn(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function d_(r,e,t){let n=!1,i=!1;for(let a=0,l=e.length;a<l;a++){const c=e[a];if(c.POSITION!==void 0&&(n=!0),c.NORMAL!==void 0&&(i=!0),n&&i)break}if(!n&&!i)return Promise.resolve(r);const s=[],o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a];if(n){const h=c.POSITION!==void 0?t.getDependency("accessor",c.POSITION):r.attributes.position;s.push(h)}if(i){const h=c.NORMAL!==void 0?t.getDependency("accessor",c.NORMAL):r.attributes.normal;o.push(h)}}return Promise.all([Promise.all(s),Promise.all(o)]).then(function(a){const l=a[0],c=a[1];return n&&(r.morphAttributes.position=l),i&&(r.morphAttributes.normal=c),r.morphTargetsRelative=!0,r})}function f_(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function p_(r){const e=r.extensions&&r.extensions[Oe.KHR_DRACO_MESH_COMPRESSION];let t;return e?t="draco:"+e.bufferView+":"+e.indices+":"+Tl(e.attributes):t=r.indices+":"+Tl(r.attributes)+":"+r.mode,t}function Tl(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function yo(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class m_{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new qx,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.textureCache={},this.nodeNamesUsed={},typeof createImageBitmap<"u"&&/Firefox|Safari/.test(navigator.userAgent)===!1?this.textureLoader=new Fc(this.options.manager):this.textureLoader=new Ac(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Wo(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};Xi(s,a,i),Nn(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const o=t[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,h]of o.children.entries())s(h,a.children[c])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this.loadAnimation(t);break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Oe.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,o){n.load(Mn.resolveURL(t.uri,i.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0)return Promise.resolve(null);const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(o){const a=o[0],l=Sl[i.type],c=hs[i.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let x,_;if(f&&f!==u){const p=Math.floor(d/f),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let R=t.cache.get(m);R||(x=new c(a,p*f,i.count*f/h),R=new Ci(x,f/h),t.cache.add(m,R)),_=new Si(R,l,d%f/h,g)}else a===null?x=new c(i.count*l):x=new c(a,d,i.count*l),_=new $e(x,l,g);if(i.sparse!==void 0){const p=Sl.SCALAR,m=hs[i.sparse.indices.componentType],R=i.sparse.indices.byteOffset||0,y=i.sparse.values.byteOffset||0,E=new m(o[1],R,i.sparse.count*p),C=new c(o[2],y,i.sparse.count*l);a!==null&&(_=new $e(_.array.slice(),_.itemSize,_.normalized));for(let P=0,V=E.length;P<V;P++){const ne=E[P];if(_.setX(ne,C[P*l]),l>=2&&_.setY(ne,C[P*l+1]),l>=3&&_.setZ(ne,C[P*l+2]),l>=4&&_.setW(ne,C[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e],s=t.images[i.source];let o=this.textureLoader;if(s.uri){const a=n.manager.getHandler(s.uri);a!==null&&(o=a)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,o=this.options,a=s.textures[e],l=(t.uri||t.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=self.URL||self.webkitURL;let h=t.uri||"",u=!1;if(t.bufferView!==void 0)h=i.getDependency("bufferView",t.bufferView).then(function(f){u=!0;const g=new Blob([f],{type:t.mimeType});return h=c.createObjectURL(g),h});else if(t.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(h).then(function(f){return new Promise(function(g,x){let _=g;n.isImageBitmapLoader===!0&&(_=function(p){const m=new tt(p);m.needsUpdate=!0,g(m)}),n.load(Mn.resolveURL(f,o.path),_,void 0,x)})}).then(function(f){u===!0&&c.revokeObjectURL(h),f.flipY=!1,a.name&&(f.name=a.name);const x=(s.samplers||{})[a.sampler]||{};return f.magFilter=bl[x.magFilter]||ht,f.minFilter=bl[x.minFilter]||Ei,f.wrapS=wl[x.wrapS]||vi,f.wrapT=wl[x.wrapT]||vi,i.associations.set(f,{textures:e}),f}).catch(function(){return console.error("THREE.GLTFLoader: Couldn't load texture",h),null});return this.textureCache[l]=d,d}assignTexture(e,t,n){const i=this;return this.getDependency("texture",n.index).then(function(s){if(n.texCoord!==void 0&&n.texCoord!=0&&!(t==="aoMap"&&n.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[Oe.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[Oe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const a=i.associations.get(s);s=i.extensions[Oe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),i.associations.set(s,a)}}return e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new Uo,rt.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new Pi,rt.prototype.copy.call(l,n),l.color.copy(n.color),this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(a+="specular-glossiness:"),i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}n.aoMap&&t.attributes.uv2===void 0&&t.attributes.uv!==void 0&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return ms}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[Oe.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const u=i[Oe.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else if(l[Oe.KHR_MATERIALS_UNLIT]){const u=i[Oe.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new ue(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.fromArray(d),a.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Un);const h=s.alphaMode||Qr.OPAQUE;if(h===Qr.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.format=xn,a.transparent=!1,h===Qr.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==pn&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new j(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}return s.occlusionTexture!==void 0&&o!==pn&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==pn&&(a.emissive=new ue().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&o!==pn&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture)),Promise.all(c).then(function(){let u;return o===xo?u=i[Oe.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):u=new o(a),s.name&&(u.name=s.name),u.map&&(u.map.encoding=Ht),u.emissiveMap&&(u.emissiveMap.encoding=Ht),Nn(u,s),t.associations.set(u,{materials:e}),s.extensions&&Xi(i,u,s),u})}createUniqueName(e){const t=He.sanitizeNodeName(e||"");let n=t;for(let i=1;this.nodeNamesUsed[n];++i)n=t+"_"+i;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[Oe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return El(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=p_(c),u=i[h];if(u)o.push(u.promise);else{let d;c.extensions&&c.extensions[Oe.KHR_DRACO_MESH_COMPRESSION]?d=s(c):d=El(new Xe,c,t),i[h]={primitive:c,promise:d},o.push(d)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const h=o[l].material===void 0?u_(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],u=[];for(let f=0,g=h.length;f<g;f++){const x=h[f],_=o[f];let p;const m=c[f];if(_.mode===Jt.TRIANGLES||_.mode===Jt.TRIANGLE_STRIP||_.mode===Jt.TRIANGLE_FAN||_.mode===void 0)p=s.isSkinnedMesh===!0?new Fo(x,m):new xt(x,m),p.isSkinnedMesh===!0&&!p.geometry.attributes.skinWeight.normalized&&p.normalizeSkinWeights(),_.mode===Jt.TRIANGLE_STRIP?p.geometry=Al(p.geometry,mu):_.mode===Jt.TRIANGLE_FAN&&(p.geometry=Al(p.geometry,zl));else if(_.mode===Jt.LINES)p=new fr(x,m);else if(_.mode===Jt.LINE_STRIP)p=new dr(x,m);else if(_.mode===Jt.LINE_LOOP)p=new fc(x,m);else if(_.mode===Jt.POINTS)p=new pc(x,m);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(p.geometry.morphAttributes).length>0&&f_(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),Nn(p,s),_.extensions&&Xi(i,p,_),t.assignFinalMaterial(p),u.push(p)}for(let f=0,g=u.length;f<g;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return u[0];const d=new Qt;t.associations.set(d,{meshes:e});for(let f=0,g=u.length;f<g;f++)d.add(u[f]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new pt(Du.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new cr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Nn(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return t.inverseBindMatrices===void 0?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then(function(i){return n.inverseBindMatrices=i,n})}loadAnimation(e){const n=this.json.animations[e],i=[],s=[],o=[],a=[],l=[];for(let c=0,h=n.channels.length;c<h;c++){const u=n.channels[c],d=n.samplers[u.sampler],f=u.target,g=f.node!==void 0?f.node:f.id,x=n.parameters!==void 0?n.parameters[d.input]:d.input,_=n.parameters!==void 0?n.parameters[d.output]:d.output;i.push(this.getDependency("node",g)),s.push(this.getDependency("accessor",x)),o.push(this.getDependency("accessor",_)),a.push(d),l.push(f)}return Promise.all([Promise.all(i),Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],u=c[1],d=c[2],f=c[3],g=c[4],x=[];for(let p=0,m=h.length;p<m;p++){const R=h[p],y=u[p],E=d[p],C=f[p],P=g[p];if(R===void 0)continue;R.updateMatrix(),R.matrixAutoUpdate=!0;let V;switch(dn[P.path]){case dn.weights:V=ls;break;case dn.rotation:V=zn;break;case dn.position:case dn.scale:default:V=cs;break}const ne=R.name?R.name:R.uuid,Z=C.interpolation!==void 0?h_[C.interpolation]:bi,I=[];dn[P.path]===dn.weights?R.traverse(function(b){b.morphTargetInfluences&&I.push(b.name?b.name:b.uuid)}):I.push(ne);let S=E.array;if(E.normalized){const b=yo(S.constructor),N=new Float32Array(S.length);for(let O=0,D=S.length;O<D;O++)N[O]=S[O]*b;S=N}for(let b=0,N=I.length;b<N;b++){const O=new V(I[b]+"."+dn[P.path],y.array,S,Z);C.interpolation==="CUBICSPLINE"&&(O.createInterpolant=function(B){const te=this instanceof zn?c_:Hn;return new te(this.times,this.values,this.getValueSize()/3,B)},O.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),x.push(O)}}const _=n.name?n.name:"animation_"+e;return new mo(_,void 0,x)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const o=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&o.traverse(function(a){if(!!a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const t=this.json,n=this.extensions,i=this,s=t.nodes[e],o=s.name?i.createUniqueName(s.name):"";return function(){const a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(c){return i._getNodeRef(i.cameraCache,s.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),Promise.all(a)}().then(function(a){let l;if(s.isBone===!0?l=new Oo:a.length>1?l=new Qt:a.length===1?l=a[0]:l=new ke,l!==a[0])for(let c=0,h=a.length;c<h;c++)l.add(a[c]);if(s.name&&(l.userData.name=s.name,l.name=o),Nn(l,s),s.extensions&&Xi(n,l,s),s.matrix!==void 0){const c=new pe;c.fromArray(s.matrix),l.applyMatrix4(c)}else s.translation!==void 0&&l.position.fromArray(s.translation),s.rotation!==void 0&&l.quaternion.fromArray(s.rotation),s.scale!==void 0&&l.scale.fromArray(s.scale);return i.associations.has(l)||i.associations.set(l,{}),i.associations.get(l).nodes=e,l})}loadScene(e){const t=this.json,n=this.extensions,i=this.json.scenes[e],s=this,o=new Qt;i.name&&(o.name=s.createUniqueName(i.name)),Nn(o,i),i.extensions&&Xi(n,o,i);const a=i.nodes||[],l=[];for(let c=0,h=a.length;c<h;c++)l.push(zc(a[c],o,t,s));return Promise.all(l).then(function(){const c=h=>{const u=new Map;for(const[d,f]of s.associations)(d instanceof rt||d instanceof tt)&&u.set(d,f);return h.traverse(d=>{const f=s.associations.get(d);f!=null&&u.set(d,f)}),u};return s.associations=c(o),o})}}function zc(r,e,t,n){const i=t.nodes[r];return n.getDependency("node",r).then(function(s){if(i.skin===void 0)return s;let o;return n.getDependency("skin",i.skin).then(function(a){o=a;const l=[];for(let c=0,h=o.joints.length;c<h;c++)l.push(n.getDependency("node",o.joints[c]));return Promise.all(l)}).then(function(a){return s.traverse(function(l){if(!l.isMesh)return;const c=[],h=[];for(let u=0,d=a.length;u<d;u++){const f=a[u];if(f){c.push(f);const g=new pe;o.inverseBindMatrices!==void 0&&g.fromArray(o.inverseBindMatrices.array,u*16),h.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',o.joints[u])}l.bind(new Bo(c,h),l.matrixWorld)}),s})}).then(function(s){e.add(s);const o=[];if(i.children){const a=i.children;for(let l=0,c=a.length;l<c;l++){const h=a[l];o.push(zc(h,s,t,n))}}return Promise.all(o)})}function g_(r,e,t){const n=e.attributes,i=new wt;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new T(l[0],l[1],l[2]),new T(c[0],c[1],c[2])),a.normalized){const h=yo(hs[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new T,l=new T;for(let c=0,h=s.length;c<h;c++){const u=s[c];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],f=d.min,g=d.max;if(f!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(g[2]))),d.normalized){const x=yo(hs[d.componentType]);l.multiplyScalar(x)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}r.boundingBox=i;const o=new Tn;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=o}function El(r,e,t){const n=e.attributes,i=[];function s(o,a){return t.getDependency("accessor",o).then(function(l){r.setAttribute(a,l)})}for(const o in n){const a=_o[o]||o.toLowerCase();a in r.attributes||i.push(s(n[o],a))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(a){r.setIndex(a)});i.push(o)}return Nn(r,e),g_(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?d_(r,e.targets,t):r})}function Al(r,e){let t=r.getIndex();if(t===null){const o=[],a=r.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===zl)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(i),s}class x_ extends Vx{constructor(e=Tc){super(),this.manager=e,this.adjustmentTransform=new pe}parse(e){const t=super.parse(e),n=t.glbBytes.slice().buffer;return new Promise((i,s)=>{const o=this.manager,a=this.fetchOptions,l=o.getHandler("path.gltf")||new Wx(o);a.credentials==="include"&&a.mode==="cors"&&l.setCrossOrigin("use-credentials"),"credentials"in a&&l.setWithCredentials(a.credentials==="include"),a.headers&&l.setRequestHeader(a.headers);let c=this.workingPath;!/[\\/]$/.test(c)&&c.length&&(c+="/");const h=this.adjustmentTransform;l.parse(n,c,u=>{const{batchTable:d,featureTable:f}=t,{scene:g}=u,x=f.getData("RTC_CENTER");x&&(g.position.x+=x[0],g.position.y+=x[1],g.position.z+=x[2]),u.scene.updateMatrix(),u.scene.matrix.multiply(h),u.scene.matrix.decompose(u.scene.position,u.scene.quaternion,u.scene.scale),u.batchTable=d,u.featureTable=f,g.batchTable=d,g.featureTable=f,i(u)},s)})}}new T;new T;new T;new T;new at;new T;new pe;const w_=new pe;new Tn;new pe;new T;new T;new En;new pe;new pe;new T;new T;new T;new T;new T(1,0,0);new T(0,1,0);const S_=new T;const Ll={type:"change"},eo={type:"start"},Rl={type:"end"};class __ extends Sn{constructor(e,t){super(),t===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new T,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Wn.ROTATE,MIDDLE:Wn.DOLLY,RIGHT:Wn.PAN},this.touches={ONE:qn.ROTATE,TWO:qn.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(L){L.addEventListener("keydown",A),this._domElementKeyEvents=L},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(Ll),n.update(),s=i.NONE},this.update=function(){const L=new T,w=new at().setFromUnitVectors(e.up,new T(0,1,0)),J=w.clone().invert(),Y=new T,_e=new at,de=2*Math.PI;return function(){const re=n.object.position;L.copy(re).sub(n.target),L.applyQuaternion(w),a.setFromVector3(L),n.autoRotate&&s===i.NONE&&ne(P()),n.enableDamping?(a.theta+=l.theta*n.dampingFactor,a.phi+=l.phi*n.dampingFactor):(a.theta+=l.theta,a.phi+=l.phi);let ve=n.minAzimuthAngle,Fe=n.maxAzimuthAngle;return isFinite(ve)&&isFinite(Fe)&&(ve<-Math.PI?ve+=de:ve>Math.PI&&(ve-=de),Fe<-Math.PI?Fe+=de:Fe>Math.PI&&(Fe-=de),ve<=Fe?a.theta=Math.max(ve,Math.min(Fe,a.theta)):a.theta=a.theta>(ve+Fe)/2?Math.max(ve,a.theta):Math.min(Fe,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),a.radius*=c,a.radius=Math.max(n.minDistance,Math.min(n.maxDistance,a.radius)),n.enableDamping===!0?n.target.addScaledVector(h,n.dampingFactor):n.target.add(h),L.setFromSpherical(a),L.applyQuaternion(J),re.copy(n.target).add(L),n.object.lookAt(n.target),n.enableDamping===!0?(l.theta*=1-n.dampingFactor,l.phi*=1-n.dampingFactor,h.multiplyScalar(1-n.dampingFactor)):(l.set(0,0,0),h.set(0,0,0)),c=1,u||Y.distanceToSquared(n.object.position)>o||8*(1-_e.dot(n.object.quaternion))>o?(n.dispatchEvent(Ll),Y.copy(n.object.position),_e.copy(n.object.quaternion),u=!1,!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",$),n.domElement.removeEventListener("pointerdown",ee),n.domElement.removeEventListener("pointercancel",be),n.domElement.removeEventListener("wheel",Ve),n.domElement.removeEventListener("pointermove",he),n.domElement.removeEventListener("pointerup",ie),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",A)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,a=new vl,l=new vl;let c=1;const h=new T;let u=!1;const d=new j,f=new j,g=new j,x=new j,_=new j,p=new j,m=new j,R=new j,y=new j,E=[],C={};function P(){return 2*Math.PI/60/60*n.autoRotateSpeed}function V(){return Math.pow(.95,n.zoomSpeed)}function ne(L){l.theta-=L}function Z(L){l.phi-=L}const I=function(){const L=new T;return function(J,Y){L.setFromMatrixColumn(Y,0),L.multiplyScalar(-J),h.add(L)}}(),S=function(){const L=new T;return function(J,Y){n.screenSpacePanning===!0?L.setFromMatrixColumn(Y,1):(L.setFromMatrixColumn(Y,0),L.crossVectors(n.object.up,L)),L.multiplyScalar(J),h.add(L)}}(),b=function(){const L=new T;return function(J,Y){const _e=n.domElement;if(n.object.isPerspectiveCamera){const de=n.object.position;L.copy(de).sub(n.target);let Se=L.length();Se*=Math.tan(n.object.fov/2*Math.PI/180),I(2*J*Se/_e.clientHeight,n.object.matrix),S(2*Y*Se/_e.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(I(J*(n.object.right-n.object.left)/n.object.zoom/_e.clientWidth,n.object.matrix),S(Y*(n.object.top-n.object.bottom)/n.object.zoom/_e.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function N(L){n.object.isPerspectiveCamera?c/=L:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*L)),n.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function O(L){n.object.isPerspectiveCamera?c*=L:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/L)),n.object.updateProjectionMatrix(),u=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function D(L){d.set(L.clientX,L.clientY)}function B(L){m.set(L.clientX,L.clientY)}function te(L){x.set(L.clientX,L.clientY)}function le(L){f.set(L.clientX,L.clientY),g.subVectors(f,d).multiplyScalar(n.rotateSpeed);const w=n.domElement;ne(2*Math.PI*g.x/w.clientHeight),Z(2*Math.PI*g.y/w.clientHeight),d.copy(f),n.update()}function k(L){R.set(L.clientX,L.clientY),y.subVectors(R,m),y.y>0?N(V()):y.y<0&&O(V()),m.copy(R),n.update()}function G(L){_.set(L.clientX,L.clientY),p.subVectors(_,x).multiplyScalar(n.panSpeed),b(p.x,p.y),x.copy(_),n.update()}function ce(L){L.deltaY<0?O(V()):L.deltaY>0&&N(V()),n.update()}function ae(L){let w=!1;switch(L.code){case n.keys.UP:b(0,n.keyPanSpeed),w=!0;break;case n.keys.BOTTOM:b(0,-n.keyPanSpeed),w=!0;break;case n.keys.LEFT:b(n.keyPanSpeed,0),w=!0;break;case n.keys.RIGHT:b(-n.keyPanSpeed,0),w=!0;break}w&&(L.preventDefault(),n.update())}function fe(){if(E.length===1)d.set(E[0].pageX,E[0].pageY);else{const L=.5*(E[0].pageX+E[1].pageX),w=.5*(E[0].pageY+E[1].pageY);d.set(L,w)}}function Ce(){if(E.length===1)x.set(E[0].pageX,E[0].pageY);else{const L=.5*(E[0].pageX+E[1].pageX),w=.5*(E[0].pageY+E[1].pageY);x.set(L,w)}}function X(){const L=E[0].pageX-E[1].pageX,w=E[0].pageY-E[1].pageY,J=Math.sqrt(L*L+w*w);m.set(0,J)}function Ae(){n.enableZoom&&X(),n.enablePan&&Ce()}function ye(){n.enableZoom&&X(),n.enableRotate&&fe()}function me(L){if(E.length==1)f.set(L.pageX,L.pageY);else{const J=xe(L),Y=.5*(L.pageX+J.x),_e=.5*(L.pageY+J.y);f.set(Y,_e)}g.subVectors(f,d).multiplyScalar(n.rotateSpeed);const w=n.domElement;ne(2*Math.PI*g.x/w.clientHeight),Z(2*Math.PI*g.y/w.clientHeight),d.copy(f)}function ge(L){if(E.length===1)_.set(L.pageX,L.pageY);else{const w=xe(L),J=.5*(L.pageX+w.x),Y=.5*(L.pageY+w.y);_.set(J,Y)}p.subVectors(_,x).multiplyScalar(n.panSpeed),b(p.x,p.y),x.copy(_)}function Ne(L){const w=xe(L),J=L.pageX-w.x,Y=L.pageY-w.y,_e=Math.sqrt(J*J+Y*Y);R.set(0,_e),y.set(0,Math.pow(R.y/m.y,n.zoomSpeed)),N(y.y),m.copy(R)}function H(L){n.enableZoom&&Ne(L),n.enablePan&&ge(L)}function Q(L){n.enableZoom&&Ne(L),n.enableRotate&&me(L)}function ee(L){n.enabled!==!1&&(E.length===0&&(n.domElement.setPointerCapture(L.pointerId),n.domElement.addEventListener("pointermove",he),n.domElement.addEventListener("pointerup",ie)),se(L),L.pointerType==="touch"?v(L):we(L))}function he(L){n.enabled!==!1&&(L.pointerType==="touch"?q(L):Re(L))}function ie(L){K(L),E.length===0&&(n.domElement.releasePointerCapture(L.pointerId),n.domElement.removeEventListener("pointermove",he),n.domElement.removeEventListener("pointerup",ie)),n.dispatchEvent(Rl),s=i.NONE}function be(L){K(L)}function we(L){let w;switch(L.button){case 0:w=n.mouseButtons.LEFT;break;case 1:w=n.mouseButtons.MIDDLE;break;case 2:w=n.mouseButtons.RIGHT;break;default:w=-1}switch(w){case Wn.DOLLY:if(n.enableZoom===!1)return;B(L),s=i.DOLLY;break;case Wn.ROTATE:if(L.ctrlKey||L.metaKey||L.shiftKey){if(n.enablePan===!1)return;te(L),s=i.PAN}else{if(n.enableRotate===!1)return;D(L),s=i.ROTATE}break;case Wn.PAN:if(L.ctrlKey||L.metaKey||L.shiftKey){if(n.enableRotate===!1)return;D(L),s=i.ROTATE}else{if(n.enablePan===!1)return;te(L),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(eo)}function Re(L){if(n.enabled!==!1)switch(s){case i.ROTATE:if(n.enableRotate===!1)return;le(L);break;case i.DOLLY:if(n.enableZoom===!1)return;k(L);break;case i.PAN:if(n.enablePan===!1)return;G(L);break}}function Ve(L){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(L.preventDefault(),n.dispatchEvent(eo),ce(L),n.dispatchEvent(Rl))}function A(L){n.enabled===!1||n.enablePan===!1||ae(L)}function v(L){switch(Me(L),E.length){case 1:switch(n.touches.ONE){case qn.ROTATE:if(n.enableRotate===!1)return;fe(),s=i.TOUCH_ROTATE;break;case qn.PAN:if(n.enablePan===!1)return;Ce(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case qn.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ae(),s=i.TOUCH_DOLLY_PAN;break;case qn.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ye(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(eo)}function q(L){switch(Me(L),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;me(L),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;ge(L),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;H(L),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Q(L),n.update();break;default:s=i.NONE}}function $(L){n.enabled!==!1&&L.preventDefault()}function se(L){E.push(L)}function K(L){delete C[L.pointerId];for(let w=0;w<E.length;w++)if(E[w].pointerId==L.pointerId){E.splice(w,1);return}}function Me(L){let w=C[L.pointerId];w===void 0&&(w=new j,C[L.pointerId]=w),w.set(L.pageX,L.pageY)}function xe(L){const w=L.pointerId===E[0].pointerId?E[1]:E[0];return C[w.pointerId]}n.domElement.addEventListener("contextmenu",$),n.domElement.addEventListener("pointerdown",ee),n.domElement.addEventListener("pointercancel",be),n.domElement.addEventListener("wheel",Ve,{passive:!1}),this.update()}}let Bn,Ks,mi,bt,$s,In,vo,fn,gi,Mo;v_();Hc();console.log("a?");function y_(r){const e={...r};return e.uniforms={highlightedBatchId:{value:-1},highlightColor:{value:new ue(16761095).convertSRGBToLinear()},...jl.clone(r.uniforms)},e.extensions={derivatives:!0},e.lights=!0,e.vertexShader=`
  2954. attribute float _batchid;
  2955. varying float batchid;
  2956. `+e.vertexShader.replace(/#include <uv_vertex>/,`
  2957. #include <uv_vertex>
  2958. batchid = _batchid;
  2959. `),e.fragmentShader=`
  2960. varying float batchid;
  2961. uniform float highlightedBatchId;
  2962. uniform vec3 highlightColor;
  2963. `+e.fragmentShader.replace(/vec4 diffuseColor = vec4\( diffuse, opacity \);/,`
  2964. vec4 diffuseColor =
  2965. abs( batchid - highlightedBatchId ) < 0.5 ?
  2966. vec4( highlightColor, opacity ) :
  2967. vec4( diffuse, opacity );
  2968. `),e}function v_(){Mo=document.getElementById("info"),mi=new No,bt=new Ge({antialias:!0}),bt.setPixelRatio(window.devicePixelRatio),bt.setSize(window.innerWidth,window.innerHeight),bt.setClearColor(1383455),bt.shadowMap.enabled=!0,bt.shadowMap.type=Il,bt.outputEncoding=Ht,document.body.appendChild(bt.domElement),Bn=new pt(60,window.innerWidth/window.innerHeight,1,4e3),Bn.position.set(400,400,400),Ks=new __(Bn,bt.domElement),Ks.screenSpacePanning=!1,Ks.minDistance=1,Ks.maxDistance=2e3,In=new jo(16777215,1.25),In.position.set(1,2,3).multiplyScalar(40),In.castShadow=!0,In.shadow.bias=-.01,In.shadow.mapSize.setScalar(2048);const r=In.shadow.camera;r.left=-200,r.bottom=-200,r.right=200,r.top=200,r.updateProjectionMatrix(),mi.add(In);const e=new Dc(16777215,.05);mi.add(e),$s=new Qt,mi.add($s),new x_().load("https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/main/1.0/TilesetWithRequestVolume/city/lr.b3dm").then(t=>{console.log(t),gi=t.scene,$s.add(gi);const n=new wt;n.setFromObject(gi),n.getCenter($s.position).multiplyScalar(-1),gi.traverse(i=>{i.isMesh&&(i.material=new bn(y_(It.standard)))})}),vo=new Fx,fn=new j,Cl(),window.addEventListener("resize",Cl,!1),bt.domElement.addEventListener("mousemove",M_,!1)}function M_(r){const e=this.getBoundingClientRect();fn.x=r.clientX-e.x,fn.y=r.clientY-e.y,fn.x=fn.x/e.width*2-1,fn.y=-(fn.y/e.height)*2+1,vo.setFromCamera(fn,Bn);const t=vo.intersectObject(mi,!0);let n=-1;if(t.length){const{face:i,object:s}=t[0],o=s.geometry.getAttribute("_batchid");if(o){let a=s;for(;!a.batchTable;)a=a.parent;const l=a.batchTable;n=o.getX(i.a),Mo.innerText=`_batchid : ${n}
  2969. Latitude : ${l.getData("Latitude")[n].toFixed(3)}
  2970. Longitude : ${l.getData("Longitude")[n].toFixed(3)}
  2971. Height : ${l.getData("Height")[n].toFixed(3)}
  2972. `}}else Mo.innerText="";gi&&gi.traverse(i=>{i.isMesh&&(i.material.uniforms.highlightedBatchId.value=n)})}function Cl(){Bn.aspect=window.innerWidth/window.innerHeight,bt.setPixelRatio(window.devicePixelRatio),bt.setSize(window.innerWidth,window.innerHeight),Bn.updateProjectionMatrix()}function Hc(){requestAnimationFrame(Hc),b_()}function b_(){bt.render(mi,Bn)}