1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641 |
- !function (e, t) {
- "object" == typeof exports && "object" == typeof module ? module.exports = t(require("echarts")) : "function" == typeof define && define.amd ? define(["echarts"], t) : "object" == typeof exports ? exports["echarts-gl"] = t(require("echarts")) : e["echarts-gl"] = t(e.echarts)
- }(self, (function (e) {
- return (() => {
- "use strict";
- var t = {
- 468: (e, t, r) => {
- r.r(t);
- var i = r(83);
- function n(e, t, r) {
- "object" == typeof t && (r = t,
- t = null);
- var i, n = this;
- if (!(e instanceof Function))
- for (var s in i = [],
- e)
- e.hasOwnProperty(s) && i.push(s);
- var l = function (t) {
- if (n.apply(this, arguments),
- e instanceof Function ? a(this, e.call(this, t)) : o(this, e, i),
- this.constructor === l)
- for (var r = l.__initializers__, s = 0; s < r.length; s++)
- r[s].apply(this, arguments)
- };
- l.__super__ = n,
- n.__initializers__ ? l.__initializers__ = n.__initializers__.slice() : l.__initializers__ = [],
- t && l.__initializers__.push(t);
- var h = function () { };
- return h.prototype = n.prototype,
- l.prototype = new h,
- l.prototype.constructor = l,
- a(l.prototype, r),
- l.extend = n.extend,
- l.derive = n.extend,
- l
- }
- function a(e, t) {
- if (t)
- for (var r in t)
- t.hasOwnProperty(r) && (e[r] = t[r])
- }
- function o(e, t, r) {
- for (var i = 0; i < r.length; i++) {
- var n = r[i];
- e[n] = t[n]
- }
- }
- const s = {
- extend: n,
- derive: n
- };
- function l(e, t) {
- this.action = e,
- this.context = t
- }
- const h = {
- trigger: function (e) {
- if (this.hasOwnProperty("__handlers__") && this.__handlers__.hasOwnProperty(e)) {
- var t = this.__handlers__[e]
- , r = t.length
- , i = -1
- , n = arguments;
- switch (n.length) {
- case 1:
- for (; ++i < r;)
- t[i].action.call(t[i].context);
- return;
- case 2:
- for (; ++i < r;)
- t[i].action.call(t[i].context, n[1]);
- return;
- case 3:
- for (; ++i < r;)
- t[i].action.call(t[i].context, n[1], n[2]);
- return;
- case 4:
- for (; ++i < r;)
- t[i].action.call(t[i].context, n[1], n[2], n[3]);
- return;
- case 5:
- for (; ++i < r;)
- t[i].action.call(t[i].context, n[1], n[2], n[3], n[4]);
- return;
- default:
- for (; ++i < r;)
- t[i].action.apply(t[i].context, Array.prototype.slice.call(n, 1));
- return
- }
- }
- },
- on: function (e, t, r) {
- if (e && t) {
- var i = this.__handlers__ || (this.__handlers__ = {});
- if (i[e]) {
- if (this.has(e, t))
- return
- } else
- i[e] = [];
- var n = new l(t, r || this);
- return i[e].push(n),
- this
- }
- },
- once: function (e, t, r) {
- if (e && t) {
- var i = this;
- return this.on(e, (function r() {
- i.off(e, r),
- t.apply(this, arguments)
- }
- ), r)
- }
- },
- before: function (e, t, r) {
- if (e && t)
- return e = "before" + e,
- this.on(e, t, r)
- },
- after: function (e, t, r) {
- if (e && t)
- return e = "after" + e,
- this.on(e, t, r)
- },
- success: function (e, t) {
- return this.once("success", e, t)
- },
- error: function (e, t) {
- return this.once("error", e, t)
- },
- off: function (e, t) {
- var r = this.__handlers__ || (this.__handlers__ = {});
- if (t) {
- if (r[e]) {
- for (var i = r[e], n = [], a = 0; a < i.length; a++)
- t && i[a].action !== t && n.push(i[a]);
- r[e] = n
- }
- return this
- }
- r[e] = []
- },
- has: function (e, t) {
- var r = this.__handlers__;
- if (!r || !r[e])
- return !1;
- for (var i = r[e], n = 0; n < i.length; n++)
- if (i[n].action === t)
- return !0
- }
- };
- var u = 0
- , c = Array.prototype.forEach
- , d = {
- genGUID: function () {
- return ++u
- },
- relative2absolute: function (e, t) {
- if (!t || e.match(/^\//))
- return e;
- for (var r = e.split("/"), i = t.split("/"), n = r[0]; "." === n || ".." === n;)
- ".." === n && i.pop(),
- r.shift(),
- n = r[0];
- return i.join("/") + "/" + r.join("/")
- },
- extend: function (e, t) {
- if (t)
- for (var r in t)
- t.hasOwnProperty(r) && (e[r] = t[r]);
- return e
- },
- defaults: function (e, t) {
- if (t)
- for (var r in t)
- void 0 === e[r] && (e[r] = t[r]);
- return e
- },
- extendWithPropList: function (e, t, r) {
- if (t)
- for (var i = 0; i < r.length; i++) {
- var n = r[i];
- e[n] = t[n]
- }
- return e
- },
- defaultsWithPropList: function (e, t, r) {
- if (t)
- for (var i = 0; i < r.length; i++) {
- var n = r[i];
- null == e[n] && (e[n] = t[n])
- }
- return e
- },
- each: function (e, t, r) {
- if (e && t)
- if (e.forEach && e.forEach === c)
- e.forEach(t, r);
- else if (e.length === +e.length)
- for (var i = 0, n = e.length; i < n; i++)
- t.call(r, e[i], i, e);
- else
- for (var a in e)
- e.hasOwnProperty(a) && t.call(r, e[a], a, e)
- },
- isObject: function (e) {
- return e === Object(e)
- },
- isArray: function (e) {
- return Array.isArray(e)
- },
- isArrayLike: function (e) {
- return !!e && e.length === +e.length
- },
- clone: function (e) {
- if (d.isObject(e)) {
- if (d.isArray(e))
- return e.slice();
- if (d.isArrayLike(e)) {
- for (var t = new e.constructor(e.length), r = 0; r < e.length; r++)
- t[r] = e[r];
- return t
- }
- return d.extend({}, e)
- }
- return e
- }
- };
- const f = d;
- var p = function () {
- this.__uid__ = f.genGUID()
- };
- p.__initializers__ = [function (e) {
- f.extend(this, e)
- }
- ],
- f.extend(p, s),
- f.extend(p.prototype, h);
- const m = p;
- var g = ["OES_texture_float", "OES_texture_half_float", "OES_texture_float_linear", "OES_texture_half_float_linear", "OES_standard_derivatives", "OES_vertex_array_object", "OES_element_index_uint", "WEBGL_compressed_texture_s3tc", "WEBGL_depth_texture", "EXT_texture_filter_anisotropic", "EXT_shader_texture_lod", "WEBGL_draw_buffers", "EXT_frag_depth", "EXT_sRGB", "ANGLE_instanced_arrays"]
- , _ = ["MAX_TEXTURE_SIZE", "MAX_CUBE_MAP_TEXTURE_SIZE"];
- const v = function (e) {
- for (var t = {}, r = {}, i = 0; i < g.length; i++)
- a(g[i]);
- for (i = 0; i < _.length; i++) {
- var n = _[i];
- r[n] = e.getParameter(e[n])
- }
- function a(r) {
- if (e.getExtension) {
- var i = e.getExtension(r);
- i || (i = e.getExtension("MOZ_" + r)),
- i || (i = e.getExtension("WEBKIT_" + r)),
- t[r] = i
- }
- }
- this.getExtension = function (e) {
- return e in t || a(e),
- t[e]
- }
- ,
- this.getParameter = function (e) {
- return r[e]
- }
- }
- , y = 1028
- , x = 1029
- , b = 2304
- , w = 2305
- , T = 5121
- , S = 5126
- , M = 6402
- , A = 6408
- , E = 9728
- , C = 9729
- , D = 9984
- , L = 9985
- , P = 9986
- , O = 9987
- , N = 10497
- , I = 33071
- , R = 33306
- , B = {
- get: function (e) {
- var t = new XMLHttpRequest;
- t.open("get", e.url),
- t.responseType = e.responseType || "text",
- e.onprogress && (t.onprogress = function (t) {
- if (t.lengthComputable) {
- var r = t.loaded / t.total;
- e.onprogress(r, t.loaded, t.total)
- } else
- e.onprogress(null)
- }
- ),
- t.onload = function (r) {
- t.status >= 400 ? e.onerror && e.onerror() : e.onload && e.onload(t.response)
- }
- ,
- e.onerror && (t.onerror = e.onerror),
- t.send(null)
- }
- };
- var F, z = {
- supportWebGL: function () {
- if (null == F)
- try {
- var e = document.createElement("canvas");
- if (!e.getContext("webgl") && !e.getContext("experimental-webgl"))
- throw new Error
- } catch (e) {
- F = !1
- }
- return F
- }
- };
- z.Int8Array = "undefined" == typeof Int8Array ? Array : Int8Array,
- z.Uint8Array = "undefined" == typeof Uint8Array ? Array : Uint8Array,
- z.Uint16Array = "undefined" == typeof Uint16Array ? Array : Uint16Array,
- z.Uint32Array = "undefined" == typeof Uint32Array ? Array : Uint32Array,
- z.Int16Array = "undefined" == typeof Int16Array ? Array : Int16Array,
- z.Float32Array = "undefined" == typeof Float32Array ? Array : Float32Array,
- z.Float64Array = "undefined" == typeof Float64Array ? Array : Float64Array;
- var G = {};
- "undefined" != typeof window ? G = window : void 0 !== r.g && (G = r.g),
- z.requestAnimationFrame = G.requestAnimationFrame || G.msRequestAnimationFrame || G.mozRequestAnimationFrame || G.webkitRequestAnimationFrame || function (e) {
- setTimeout(e, 16)
- }
- ,
- z.createCanvas = function () {
- return document.createElement("canvas")
- }
- ,
- z.createImage = function () {
- return new G.Image
- }
- ,
- z.request = {
- get: B.get
- },
- z.addEventListener = function (e, t, r, i) {
- e.addEventListener(t, r, i)
- }
- ,
- z.removeEventListener = function (e, t, r) {
- e.removeEventListener(t, r)
- }
- ;
- const U = z;
- var k = function () {
- this.head = null,
- this.tail = null,
- this._length = 0
- };
- k.prototype.insert = function (e) {
- var t = new k.Entry(e);
- return this.insertEntry(t),
- t
- }
- ,
- k.prototype.insertAt = function (e, t) {
- if (!(e < 0)) {
- for (var r = this.head, i = 0; r && i != e;)
- r = r.next,
- i++;
- if (r) {
- var n = new k.Entry(t)
- , a = r.prev;
- a ? (a.next = n,
- n.prev = a) : this.head = n,
- n.next = r,
- r.prev = n
- } else
- this.insert(t)
- }
- }
- ,
- k.prototype.insertBeforeEntry = function (e, t) {
- var r = new k.Entry(e)
- , i = t.prev;
- i ? (i.next = r,
- r.prev = i) : this.head = r,
- r.next = t,
- t.prev = r,
- this._length++
- }
- ,
- k.prototype.insertEntry = function (e) {
- this.head ? (this.tail.next = e,
- e.prev = this.tail,
- this.tail = e) : this.head = this.tail = e,
- this._length++
- }
- ,
- k.prototype.remove = function (e) {
- var t = e.prev
- , r = e.next;
- t ? t.next = r : this.head = r,
- r ? r.prev = t : this.tail = t,
- e.next = e.prev = null,
- this._length--
- }
- ,
- k.prototype.removeAt = function (e) {
- if (!(e < 0)) {
- for (var t = this.head, r = 0; t && r != e;)
- t = t.next,
- r++;
- return t ? (this.remove(t),
- t.value) : void 0
- }
- }
- ,
- k.prototype.getHead = function () {
- if (this.head)
- return this.head.value
- }
- ,
- k.prototype.getTail = function () {
- if (this.tail)
- return this.tail.value
- }
- ,
- k.prototype.getAt = function (e) {
- if (!(e < 0)) {
- for (var t = this.head, r = 0; t && r != e;)
- t = t.next,
- r++;
- return t.value
- }
- }
- ,
- k.prototype.indexOf = function (e) {
- for (var t = this.head, r = 0; t;) {
- if (t.value === e)
- return r;
- t = t.next,
- r++
- }
- }
- ,
- k.prototype.length = function () {
- return this._length
- }
- ,
- k.prototype.isEmpty = function () {
- return 0 === this._length
- }
- ,
- k.prototype.forEach = function (e, t) {
- for (var r = this.head, i = 0, n = void 0 !== t; r;)
- n ? e.call(t, r.value, i) : e(r.value, i),
- r = r.next,
- i++
- }
- ,
- k.prototype.clear = function () {
- this.tail = this.head = null,
- this._length = 0
- }
- ,
- k.Entry = function (e) {
- this.value = e,
- this.next = null,
- this.prev = null
- }
- ;
- const V = k;
- var H = function (e) {
- this._list = new V,
- this._map = {},
- this._maxSize = e || 10
- };
- H.prototype.setMaxSize = function (e) {
- this._maxSize = e
- }
- ,
- H.prototype.put = function (e, t) {
- if (!this._map.hasOwnProperty(e)) {
- var r = this._list.length();
- if (r >= this._maxSize && r > 0) {
- var i = this._list.head;
- this._list.remove(i),
- delete this._map[i.key]
- }
- var n = this._list.insert(t);
- n.key = e,
- this._map[e] = n
- }
- }
- ,
- H.prototype.get = function (e) {
- var t = this._map[e];
- if (this._map.hasOwnProperty(e))
- return t !== this._list.tail && (this._list.remove(t),
- this._list.insertEntry(t)),
- t.value
- }
- ,
- H.prototype.remove = function (e) {
- var t = this._map[e];
- void 0 !== t && (delete this._map[e],
- this._list.remove(t))
- }
- ,
- H.prototype.clear = function () {
- this._list.clear(),
- this._map = {}
- }
- ;
- const W = H;
- var j = {}
- , X = {
- transparent: [0, 0, 0, 0],
- aliceblue: [240, 248, 255, 1],
- antiquewhite: [250, 235, 215, 1],
- aqua: [0, 255, 255, 1],
- aquamarine: [127, 255, 212, 1],
- azure: [240, 255, 255, 1],
- beige: [245, 245, 220, 1],
- bisque: [255, 228, 196, 1],
- black: [0, 0, 0, 1],
- blanchedalmond: [255, 235, 205, 1],
- blue: [0, 0, 255, 1],
- blueviolet: [138, 43, 226, 1],
- brown: [165, 42, 42, 1],
- burlywood: [222, 184, 135, 1],
- cadetblue: [95, 158, 160, 1],
- chartreuse: [127, 255, 0, 1],
- chocolate: [210, 105, 30, 1],
- coral: [255, 127, 80, 1],
- cornflowerblue: [100, 149, 237, 1],
- cornsilk: [255, 248, 220, 1],
- crimson: [220, 20, 60, 1],
- cyan: [0, 255, 255, 1],
- darkblue: [0, 0, 139, 1],
- darkcyan: [0, 139, 139, 1],
- darkgoldenrod: [184, 134, 11, 1],
- darkgray: [169, 169, 169, 1],
- darkgreen: [0, 100, 0, 1],
- darkgrey: [169, 169, 169, 1],
- darkkhaki: [189, 183, 107, 1],
- darkmagenta: [139, 0, 139, 1],
- darkolivegreen: [85, 107, 47, 1],
- darkorange: [255, 140, 0, 1],
- darkorchid: [153, 50, 204, 1],
- darkred: [139, 0, 0, 1],
- darksalmon: [233, 150, 122, 1],
- darkseagreen: [143, 188, 143, 1],
- darkslateblue: [72, 61, 139, 1],
- darkslategray: [47, 79, 79, 1],
- darkslategrey: [47, 79, 79, 1],
- darkturquoise: [0, 206, 209, 1],
- darkviolet: [148, 0, 211, 1],
- deeppink: [255, 20, 147, 1],
- deepskyblue: [0, 191, 255, 1],
- dimgray: [105, 105, 105, 1],
- dimgrey: [105, 105, 105, 1],
- dodgerblue: [30, 144, 255, 1],
- firebrick: [178, 34, 34, 1],
- floralwhite: [255, 250, 240, 1],
- forestgreen: [34, 139, 34, 1],
- fuchsia: [255, 0, 255, 1],
- gainsboro: [220, 220, 220, 1],
- ghostwhite: [248, 248, 255, 1],
- gold: [255, 215, 0, 1],
- goldenrod: [218, 165, 32, 1],
- gray: [128, 128, 128, 1],
- green: [0, 128, 0, 1],
- greenyellow: [173, 255, 47, 1],
- grey: [128, 128, 128, 1],
- honeydew: [240, 255, 240, 1],
- hotpink: [255, 105, 180, 1],
- indianred: [205, 92, 92, 1],
- indigo: [75, 0, 130, 1],
- ivory: [255, 255, 240, 1],
- khaki: [240, 230, 140, 1],
- lavender: [230, 230, 250, 1],
- lavenderblush: [255, 240, 245, 1],
- lawngreen: [124, 252, 0, 1],
- lemonchiffon: [255, 250, 205, 1],
- lightblue: [173, 216, 230, 1],
- lightcoral: [240, 128, 128, 1],
- lightcyan: [224, 255, 255, 1],
- lightgoldenrodyellow: [250, 250, 210, 1],
- lightgray: [211, 211, 211, 1],
- lightgreen: [144, 238, 144, 1],
- lightgrey: [211, 211, 211, 1],
- lightpink: [255, 182, 193, 1],
- lightsalmon: [255, 160, 122, 1],
- lightseagreen: [32, 178, 170, 1],
- lightskyblue: [135, 206, 250, 1],
- lightslategray: [119, 136, 153, 1],
- lightslategrey: [119, 136, 153, 1],
- lightsteelblue: [176, 196, 222, 1],
- lightyellow: [255, 255, 224, 1],
- lime: [0, 255, 0, 1],
- limegreen: [50, 205, 50, 1],
- linen: [250, 240, 230, 1],
- magenta: [255, 0, 255, 1],
- maroon: [128, 0, 0, 1],
- mediumaquamarine: [102, 205, 170, 1],
- mediumblue: [0, 0, 205, 1],
- mediumorchid: [186, 85, 211, 1],
- mediumpurple: [147, 112, 219, 1],
- mediumseagreen: [60, 179, 113, 1],
- mediumslateblue: [123, 104, 238, 1],
- mediumspringgreen: [0, 250, 154, 1],
- mediumturquoise: [72, 209, 204, 1],
- mediumvioletred: [199, 21, 133, 1],
- midnightblue: [25, 25, 112, 1],
- mintcream: [245, 255, 250, 1],
- mistyrose: [255, 228, 225, 1],
- moccasin: [255, 228, 181, 1],
- navajowhite: [255, 222, 173, 1],
- navy: [0, 0, 128, 1],
- oldlace: [253, 245, 230, 1],
- olive: [128, 128, 0, 1],
- olivedrab: [107, 142, 35, 1],
- orange: [255, 165, 0, 1],
- orangered: [255, 69, 0, 1],
- orchid: [218, 112, 214, 1],
- palegoldenrod: [238, 232, 170, 1],
- palegreen: [152, 251, 152, 1],
- paleturquoise: [175, 238, 238, 1],
- palevioletred: [219, 112, 147, 1],
- papayawhip: [255, 239, 213, 1],
- peachpuff: [255, 218, 185, 1],
- peru: [205, 133, 63, 1],
- pink: [255, 192, 203, 1],
- plum: [221, 160, 221, 1],
- powderblue: [176, 224, 230, 1],
- purple: [128, 0, 128, 1],
- red: [255, 0, 0, 1],
- rosybrown: [188, 143, 143, 1],
- royalblue: [65, 105, 225, 1],
- saddlebrown: [139, 69, 19, 1],
- salmon: [250, 128, 114, 1],
- sandybrown: [244, 164, 96, 1],
- seagreen: [46, 139, 87, 1],
- seashell: [255, 245, 238, 1],
- sienna: [160, 82, 45, 1],
- silver: [192, 192, 192, 1],
- skyblue: [135, 206, 235, 1],
- slateblue: [106, 90, 205, 1],
- slategray: [112, 128, 144, 1],
- slategrey: [112, 128, 144, 1],
- snow: [255, 250, 250, 1],
- springgreen: [0, 255, 127, 1],
- steelblue: [70, 130, 180, 1],
- tan: [210, 180, 140, 1],
- teal: [0, 128, 128, 1],
- thistle: [216, 191, 216, 1],
- tomato: [255, 99, 71, 1],
- turquoise: [64, 224, 208, 1],
- violet: [238, 130, 238, 1],
- wheat: [245, 222, 179, 1],
- white: [255, 255, 255, 1],
- whitesmoke: [245, 245, 245, 1],
- yellow: [255, 255, 0, 1],
- yellowgreen: [154, 205, 50, 1]
- };
- function q(e) {
- return (e = Math.round(e)) < 0 ? 0 : e > 255 ? 255 : e
- }
- function Z(e) {
- return e < 0 ? 0 : e > 1 ? 1 : e
- }
- function Y(e) {
- return e.length && "%" === e.charAt(e.length - 1) ? q(parseFloat(e) / 100 * 255) : q(parseInt(e, 10))
- }
- function K(e) {
- return e.length && "%" === e.charAt(e.length - 1) ? Z(parseFloat(e) / 100) : Z(parseFloat(e))
- }
- function Q(e, t, r) {
- return r < 0 ? r += 1 : r > 1 && (r -= 1),
- 6 * r < 1 ? e + (t - e) * r * 6 : 2 * r < 1 ? t : 3 * r < 2 ? e + (t - e) * (2 / 3 - r) * 6 : e
- }
- function J(e, t, r) {
- return e + (t - e) * r
- }
- function $(e, t, r, i, n) {
- return e[0] = t,
- e[1] = r,
- e[2] = i,
- e[3] = n,
- e
- }
- function ee(e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e
- }
- var te = new W(20)
- , re = null;
- function ie(e, t) {
- re && ee(re, t),
- re = te.put(e, re || t.slice())
- }
- function ne(e, t) {
- var r = (parseFloat(e[0]) % 360 + 360) % 360 / 360
- , i = K(e[1])
- , n = K(e[2])
- , a = n <= .5 ? n * (i + 1) : n + i - n * i
- , o = 2 * n - a;
- return $(t = t || [], q(255 * Q(o, a, r + 1 / 3)), q(255 * Q(o, a, r)), q(255 * Q(o, a, r - 1 / 3)), 1),
- 4 === e.length && (t[3] = e[3]),
- t
- }
- j.parse = function (e, t) {
- if (e) {
- t = t || [];
- var r = te.get(e);
- if (r)
- return ee(t, r);
- var i, n = (e += "").replace(/ /g, "").toLowerCase();
- if (n in X)
- return ee(t, X[n]),
- ie(e, t),
- t;
- if ("#" === n.charAt(0))
- return 4 === n.length ? (i = parseInt(n.substr(1), 16)) >= 0 && i <= 4095 ? ($(t, (3840 & i) >> 4 | (3840 & i) >> 8, 240 & i | (240 & i) >> 4, 15 & i | (15 & i) << 4, 1),
- ie(e, t),
- t) : void $(t, 0, 0, 0, 1) : 7 === n.length ? (i = parseInt(n.substr(1), 16)) >= 0 && i <= 16777215 ? ($(t, (16711680 & i) >> 16, (65280 & i) >> 8, 255 & i, 1),
- ie(e, t),
- t) : void $(t, 0, 0, 0, 1) : void 0;
- var a = n.indexOf("(")
- , o = n.indexOf(")");
- if (-1 !== a && o + 1 === n.length) {
- var s = n.substr(0, a)
- , l = n.substr(a + 1, o - (a + 1)).split(",")
- , h = 1;
- switch (s) {
- case "rgba":
- if (4 !== l.length)
- return void $(t, 0, 0, 0, 1);
- h = K(l.pop());
- case "rgb":
- return 3 !== l.length ? void $(t, 0, 0, 0, 1) : ($(t, Y(l[0]), Y(l[1]), Y(l[2]), h),
- ie(e, t),
- t);
- case "hsla":
- return 4 !== l.length ? void $(t, 0, 0, 0, 1) : (l[3] = K(l[3]),
- ne(l, t),
- ie(e, t),
- t);
- case "hsl":
- return 3 !== l.length ? void $(t, 0, 0, 0, 1) : (ne(l, t),
- ie(e, t),
- t);
- default:
- return
- }
- }
- $(t, 0, 0, 0, 1)
- }
- }
- ,
- j.parseToFloat = function (e, t) {
- if (t = j.parse(e, t))
- return t[0] /= 255,
- t[1] /= 255,
- t[2] /= 255,
- t
- }
- ,
- j.lift = function (e, t) {
- var r = j.parse(e);
- if (r) {
- for (var i = 0; i < 3; i++)
- r[i] = t < 0 ? r[i] * (1 - t) | 0 : (255 - r[i]) * t + r[i] | 0;
- return j.stringify(r, 4 === r.length ? "rgba" : "rgb")
- }
- }
- ,
- j.toHex = function (e) {
- var t = j.parse(e);
- if (t)
- return ((1 << 24) + (t[0] << 16) + (t[1] << 8) + +t[2]).toString(16).slice(1)
- }
- ,
- j.fastLerp = function (e, t, r) {
- if (t && t.length && e >= 0 && e <= 1) {
- r = r || [];
- var i = e * (t.length - 1)
- , n = Math.floor(i)
- , a = Math.ceil(i)
- , o = t[n]
- , s = t[a]
- , l = i - n;
- return r[0] = q(J(o[0], s[0], l)),
- r[1] = q(J(o[1], s[1], l)),
- r[2] = q(J(o[2], s[2], l)),
- r[3] = Z(J(o[3], s[3], l)),
- r
- }
- }
- ,
- j.fastMapToColor = j.fastLerp,
- j.lerp = function (e, t, r) {
- if (t && t.length && e >= 0 && e <= 1) {
- var i = e * (t.length - 1)
- , n = Math.floor(i)
- , a = Math.ceil(i)
- , o = j.parse(t[n])
- , s = j.parse(t[a])
- , l = i - n
- , h = j.stringify([q(J(o[0], s[0], l)), q(J(o[1], s[1], l)), q(J(o[2], s[2], l)), Z(J(o[3], s[3], l))], "rgba");
- return r ? {
- color: h,
- leftIndex: n,
- rightIndex: a,
- value: i
- } : h
- }
- }
- ,
- j.mapToColor = j.lerp,
- j.modifyHSL = function (e, t, r, i) {
- if (e = j.parse(e))
- return e = function (e) {
- if (e) {
- var t, r, i = e[0] / 255, n = e[1] / 255, a = e[2] / 255, o = Math.min(i, n, a), s = Math.max(i, n, a), l = s - o, h = (s + o) / 2;
- if (0 === l)
- t = 0,
- r = 0;
- else {
- r = h < .5 ? l / (s + o) : l / (2 - s - o);
- var u = ((s - i) / 6 + l / 2) / l
- , c = ((s - n) / 6 + l / 2) / l
- , d = ((s - a) / 6 + l / 2) / l;
- i === s ? t = d - c : n === s ? t = 1 / 3 + u - d : a === s && (t = 2 / 3 + c - u),
- t < 0 && (t += 1),
- t > 1 && (t -= 1)
- }
- var f = [360 * t, r, h];
- return null != e[3] && f.push(e[3]),
- f
- }
- }(e),
- null != t && (e[0] = (n = t,
- (n = Math.round(n)) < 0 ? 0 : n > 360 ? 360 : n)),
- null != r && (e[1] = K(r)),
- null != i && (e[2] = K(i)),
- j.stringify(ne(e), "rgba");
- var n
- }
- ,
- j.modifyAlpha = function (e, t) {
- if ((e = j.parse(e)) && null != t)
- return e[3] = Z(t),
- j.stringify(e, "rgba")
- }
- ,
- j.stringify = function (e, t) {
- if (e && e.length) {
- var r = e[0] + "," + e[1] + "," + e[2];
- return "rgba" !== t && "hsva" !== t && "hsla" !== t || (r += "," + e[3]),
- t + "(" + r + ")"
- }
- }
- ;
- var ae = j.parseToFloat
- , oe = {};
- function se(e) {
- var t = Object.keys(e);
- t.sort();
- for (var r = [], i = 0; i < t.length; i++) {
- var n = t[i]
- , a = e[n];
- null === a ? r.push(n) : r.push(n + " " + a.toString())
- }
- return r.join("\n")
- }
- const le = m.extend((function () {
- return {
- name: "",
- depthTest: !0,
- depthMask: !0,
- transparent: !1,
- blend: null,
- autoUpdateTextureStatus: !0,
- uniforms: {},
- vertexDefines: {},
- fragmentDefines: {},
- _textureStatus: {},
- _enabledUniforms: null
- }
- }
- ), (function () {
- this.name || (this.name = "MATERIAL_" + this.__uid__),
- this.shader && this.attachShader(this.shader, !0)
- }
- ), {
- precision: "highp",
- setUniform: function (e, t) {
- void 0 === t && console.warn('Uniform value "' + e + '" is undefined');
- var r = this.uniforms[e];
- r && ("string" == typeof t && (t = ae(t) || t),
- r.value = t,
- this.autoUpdateTextureStatus && "t" === r.type && (t ? this.enableTexture(e) : this.disableTexture(e)))
- },
- setUniforms: function (e) {
- for (var t in e) {
- var r = e[t];
- this.setUniform(t, r)
- }
- },
- isUniformEnabled: function (e) {
- return this._enabledUniforms.indexOf(e) >= 0
- },
- getEnabledUniforms: function () {
- return this._enabledUniforms
- },
- getTextureUniforms: function () {
- return this._textureUniforms
- },
- set: function (e, t) {
- if ("object" == typeof e)
- for (var r in e) {
- var i = e[r];
- this.setUniform(r, i)
- }
- else
- this.setUniform(e, t)
- },
- get: function (e) {
- var t = this.uniforms[e];
- if (t)
- return t.value
- },
- attachShader: function (e, t) {
- var r = this.uniforms;
- this.uniforms = e.createUniforms(),
- this.shader = e;
- var i = this.uniforms;
- this._enabledUniforms = Object.keys(i),
- this._enabledUniforms.sort(),
- this._textureUniforms = this._enabledUniforms.filter((function (e) {
- var t = this.uniforms[e].type;
- return "t" === t || "tv" === t
- }
- ), this);
- var n = this.vertexDefines
- , a = this.fragmentDefines;
- if (this.vertexDefines = f.clone(e.vertexDefines),
- this.fragmentDefines = f.clone(e.fragmentDefines),
- t) {
- for (var o in r)
- i[o] && (i[o].value = r[o].value);
- f.defaults(this.vertexDefines, n),
- f.defaults(this.fragmentDefines, a)
- }
- var s = {};
- for (var l in e.textures)
- s[l] = {
- shaderType: e.textures[l].shaderType,
- type: e.textures[l].type,
- enabled: !(!t || !this._textureStatus[l]) && this._textureStatus[l].enabled
- };
- this._textureStatus = s,
- this._programKey = ""
- },
- clone: function () {
- var e = new this.constructor({
- name: this.name,
- shader: this.shader
- });
- for (var t in this.uniforms)
- e.uniforms[t].value = this.uniforms[t].value;
- return e.depthTest = this.depthTest,
- e.depthMask = this.depthMask,
- e.transparent = this.transparent,
- e.blend = this.blend,
- e.vertexDefines = f.clone(this.vertexDefines),
- e.fragmentDefines = f.clone(this.fragmentDefines),
- e.enableTexture(this.getEnabledTextures()),
- e.precision = this.precision,
- e
- },
- define: function (e, t, r) {
- var i = this.vertexDefines
- , n = this.fragmentDefines;
- "vertex" !== e && "fragment" !== e && "both" !== e && arguments.length < 3 && (r = t,
- t = e,
- e = "both"),
- r = null != r ? r : null,
- "vertex" !== e && "both" !== e || i[t] !== r && (i[t] = r,
- this._programKey = ""),
- "fragment" !== e && "both" !== e || n[t] !== r && (n[t] = r,
- "both" !== e && (this._programKey = ""))
- },
- undefine: function (e, t) {
- "vertex" !== e && "fragment" !== e && "both" !== e && arguments.length < 2 && (t = e,
- e = "both"),
- "vertex" !== e && "both" !== e || this.isDefined("vertex", t) && (delete this.vertexDefines[t],
- this._programKey = ""),
- "fragment" !== e && "both" !== e || this.isDefined("fragment", t) && (delete this.fragmentDefines[t],
- "both" !== e && (this._programKey = ""))
- },
- isDefined: function (e, t) {
- switch (e) {
- case "vertex":
- return void 0 !== this.vertexDefines[t];
- case "fragment":
- return void 0 !== this.fragmentDefines[t]
- }
- },
- getDefine: function (e, t) {
- switch (e) {
- case "vertex":
- return this.vertexDefines[t];
- case "fragment":
- return this.fragmentDefines[t]
- }
- },
- enableTexture: function (e) {
- if (Array.isArray(e))
- for (var t = 0; t < e.length; t++)
- this.enableTexture(e[t]);
- else {
- var r = this._textureStatus[e];
- r && (r.enabled || (r.enabled = !0,
- this._programKey = ""))
- }
- },
- enableTexturesAll: function () {
- var e = this._textureStatus;
- for (var t in e)
- e[t].enabled = !0;
- this._programKey = ""
- },
- disableTexture: function (e) {
- if (Array.isArray(e))
- for (var t = 0; t < e.length; t++)
- this.disableTexture(e[t]);
- else {
- var r = this._textureStatus[e];
- r && (!r.enabled || (r.enabled = !1,
- this._programKey = ""))
- }
- },
- disableTexturesAll: function () {
- var e = this._textureStatus;
- for (var t in e)
- e[t].enabled = !1;
- this._programKey = ""
- },
- isTextureEnabled: function (e) {
- var t = this._textureStatus;
- return !!t[e] && t[e].enabled
- },
- getEnabledTextures: function () {
- var e = []
- , t = this._textureStatus;
- for (var r in t)
- t[r].enabled && e.push(r);
- return e
- },
- dirtyDefines: function () {
- this._programKey = ""
- },
- getProgramKey: function () {
- return this._programKey || (this._programKey = function (e, t, r) {
- r.sort();
- for (var i = [], n = 0; n < r.length; n++) {
- var a = r[n];
- i.push(a)
- }
- var o = se(e) + "\n" + se(t) + "\n" + i.join("\n");
- if (oe[o])
- return oe[o];
- var s = f.genGUID();
- return oe[o] = s,
- s
- }(this.vertexDefines, this.fragmentDefines, this.getEnabledTextures())),
- this._programKey
- }
- });
- var he, ue = 1e-6, ce = Array, de = Math.random, fe = {
- create: function () {
- var e = new ce(2);
- return e[0] = 0,
- e[1] = 0,
- e
- },
- clone: function (e) {
- var t = new ce(2);
- return t[0] = e[0],
- t[1] = e[1],
- t
- },
- fromValues: function (e, t) {
- var r = new ce(2);
- return r[0] = e,
- r[1] = t,
- r
- },
- copy: function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e
- },
- set: function (e, t, r) {
- return e[0] = t,
- e[1] = r,
- e
- },
- add: function (e, t, r) {
- return e[0] = t[0] + r[0],
- e[1] = t[1] + r[1],
- e
- },
- subtract: function (e, t, r) {
- return e[0] = t[0] - r[0],
- e[1] = t[1] - r[1],
- e
- }
- };
- fe.sub = fe.subtract,
- fe.multiply = function (e, t, r) {
- return e[0] = t[0] * r[0],
- e[1] = t[1] * r[1],
- e
- }
- ,
- fe.mul = fe.multiply,
- fe.divide = function (e, t, r) {
- return e[0] = t[0] / r[0],
- e[1] = t[1] / r[1],
- e
- }
- ,
- fe.div = fe.divide,
- fe.min = function (e, t, r) {
- return e[0] = Math.min(t[0], r[0]),
- e[1] = Math.min(t[1], r[1]),
- e
- }
- ,
- fe.max = function (e, t, r) {
- return e[0] = Math.max(t[0], r[0]),
- e[1] = Math.max(t[1], r[1]),
- e
- }
- ,
- fe.scale = function (e, t, r) {
- return e[0] = t[0] * r,
- e[1] = t[1] * r,
- e
- }
- ,
- fe.scaleAndAdd = function (e, t, r, i) {
- return e[0] = t[0] + r[0] * i,
- e[1] = t[1] + r[1] * i,
- e
- }
- ,
- fe.distance = function (e, t) {
- var r = t[0] - e[0]
- , i = t[1] - e[1];
- return Math.sqrt(r * r + i * i)
- }
- ,
- fe.dist = fe.distance,
- fe.squaredDistance = function (e, t) {
- var r = t[0] - e[0]
- , i = t[1] - e[1];
- return r * r + i * i
- }
- ,
- fe.sqrDist = fe.squaredDistance,
- fe.length = function (e) {
- var t = e[0]
- , r = e[1];
- return Math.sqrt(t * t + r * r)
- }
- ,
- fe.len = fe.length,
- fe.squaredLength = function (e) {
- var t = e[0]
- , r = e[1];
- return t * t + r * r
- }
- ,
- fe.sqrLen = fe.squaredLength,
- fe.negate = function (e, t) {
- return e[0] = -t[0],
- e[1] = -t[1],
- e
- }
- ,
- fe.inverse = function (e, t) {
- return e[0] = 1 / t[0],
- e[1] = 1 / t[1],
- e
- }
- ,
- fe.normalize = function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = r * r + i * i;
- return n > 0 && (n = 1 / Math.sqrt(n),
- e[0] = t[0] * n,
- e[1] = t[1] * n),
- e
- }
- ,
- fe.dot = function (e, t) {
- return e[0] * t[0] + e[1] * t[1]
- }
- ,
- fe.cross = function (e, t, r) {
- var i = t[0] * r[1] - t[1] * r[0];
- return e[0] = e[1] = 0,
- e[2] = i,
- e
- }
- ,
- fe.lerp = function (e, t, r, i) {
- var n = t[0]
- , a = t[1];
- return e[0] = n + i * (r[0] - n),
- e[1] = a + i * (r[1] - a),
- e
- }
- ,
- fe.random = function (e, t) {
- t = t || 1;
- var r = 2 * GLMAT_RANDOM() * Math.PI;
- return e[0] = Math.cos(r) * t,
- e[1] = Math.sin(r) * t,
- e
- }
- ,
- fe.transformMat2 = function (e, t, r) {
- var i = t[0]
- , n = t[1];
- return e[0] = r[0] * i + r[2] * n,
- e[1] = r[1] * i + r[3] * n,
- e
- }
- ,
- fe.transformMat2d = function (e, t, r) {
- var i = t[0]
- , n = t[1];
- return e[0] = r[0] * i + r[2] * n + r[4],
- e[1] = r[1] * i + r[3] * n + r[5],
- e
- }
- ,
- fe.transformMat3 = function (e, t, r) {
- var i = t[0]
- , n = t[1];
- return e[0] = r[0] * i + r[3] * n + r[6],
- e[1] = r[1] * i + r[4] * n + r[7],
- e
- }
- ,
- fe.transformMat4 = function (e, t, r) {
- var i = t[0]
- , n = t[1];
- return e[0] = r[0] * i + r[4] * n + r[12],
- e[1] = r[1] * i + r[5] * n + r[13],
- e
- }
- ,
- fe.forEach = (he = fe.create(),
- function (e, t, r, i, n, a) {
- var o, s;
- for (t || (t = 2),
- r || (r = 0),
- s = i ? Math.min(i * t + r, e.length) : e.length,
- o = r; o < s; o += t)
- he[0] = e[o],
- he[1] = e[o + 1],
- n(he, he, a),
- e[o] = he[0],
- e[o + 1] = he[1];
- return e
- }
- );
- const pe = fe;
- var me = function (e, t) {
- e = e || 0,
- t = t || 0,
- this.array = pe.fromValues(e, t),
- this._dirty = !0
- };
- if (me.prototype = {
- constructor: me,
- add: function (e) {
- return pe.add(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- set: function (e, t) {
- return this.array[0] = e,
- this.array[1] = t,
- this._dirty = !0,
- this
- },
- setArray: function (e) {
- return this.array[0] = e[0],
- this.array[1] = e[1],
- this._dirty = !0,
- this
- },
- clone: function () {
- return new me(this.x, this.y)
- },
- copy: function (e) {
- return pe.copy(this.array, e.array),
- this._dirty = !0,
- this
- },
- cross: function (e, t) {
- return pe.cross(e.array, this.array, t.array),
- e._dirty = !0,
- this
- },
- dist: function (e) {
- return pe.dist(this.array, e.array)
- },
- distance: function (e) {
- return pe.distance(this.array, e.array)
- },
- div: function (e) {
- return pe.div(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- divide: function (e) {
- return pe.divide(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- dot: function (e) {
- return pe.dot(this.array, e.array)
- },
- len: function () {
- return pe.len(this.array)
- },
- length: function () {
- return pe.length(this.array)
- },
- lerp: function (e, t, r) {
- return pe.lerp(this.array, e.array, t.array, r),
- this._dirty = !0,
- this
- },
- min: function (e) {
- return pe.min(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- max: function (e) {
- return pe.max(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- mul: function (e) {
- return pe.mul(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- multiply: function (e) {
- return pe.multiply(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- negate: function () {
- return pe.negate(this.array, this.array),
- this._dirty = !0,
- this
- },
- normalize: function () {
- return pe.normalize(this.array, this.array),
- this._dirty = !0,
- this
- },
- random: function (e) {
- return pe.random(this.array, e),
- this._dirty = !0,
- this
- },
- scale: function (e) {
- return pe.scale(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- scaleAndAdd: function (e, t) {
- return pe.scaleAndAdd(this.array, this.array, e.array, t),
- this._dirty = !0,
- this
- },
- sqrDist: function (e) {
- return pe.sqrDist(this.array, e.array)
- },
- squaredDistance: function (e) {
- return pe.squaredDistance(this.array, e.array)
- },
- sqrLen: function () {
- return pe.sqrLen(this.array)
- },
- squaredLength: function () {
- return pe.squaredLength(this.array)
- },
- sub: function (e) {
- return pe.sub(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- subtract: function (e) {
- return pe.subtract(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformMat2: function (e) {
- return pe.transformMat2(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformMat2d: function (e) {
- return pe.transformMat2d(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformMat3: function (e) {
- return pe.transformMat3(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformMat4: function (e) {
- return pe.transformMat4(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- toString: function () {
- return "[" + Array.prototype.join.call(this.array, ",") + "]"
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array)
- }
- },
- Object.defineProperty) {
- var ge = me.prototype;
- Object.defineProperty(ge, "x", {
- get: function () {
- return this.array[0]
- },
- set: function (e) {
- this.array[0] = e,
- this._dirty = !0
- }
- }),
- Object.defineProperty(ge, "y", {
- get: function () {
- return this.array[1]
- },
- set: function (e) {
- this.array[1] = e,
- this._dirty = !0
- }
- })
- }
- me.add = function (e, t, r) {
- return pe.add(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.set = function (e, t, r) {
- return pe.set(e.array, t, r),
- e._dirty = !0,
- e
- }
- ,
- me.copy = function (e, t) {
- return pe.copy(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- me.cross = function (e, t, r) {
- return pe.cross(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.distance = me.dist = function (e, t) {
- return pe.distance(e.array, t.array)
- }
- ,
- me.divide = me.div = function (e, t, r) {
- return pe.divide(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.dot = function (e, t) {
- return pe.dot(e.array, t.array)
- }
- ,
- me.len = function (e) {
- return pe.length(e.array)
- }
- ,
- me.lerp = function (e, t, r, i) {
- return pe.lerp(e.array, t.array, r.array, i),
- e._dirty = !0,
- e
- }
- ,
- me.min = function (e, t, r) {
- return pe.min(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.max = function (e, t, r) {
- return pe.max(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.multiply = me.mul = function (e, t, r) {
- return pe.multiply(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.negate = function (e, t) {
- return pe.negate(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- me.normalize = function (e, t) {
- return pe.normalize(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- me.random = function (e, t) {
- return pe.random(e.array, t),
- e._dirty = !0,
- e
- }
- ,
- me.scale = function (e, t, r) {
- return pe.scale(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- me.scaleAndAdd = function (e, t, r, i) {
- return pe.scaleAndAdd(e.array, t.array, r.array, i),
- e._dirty = !0,
- e
- }
- ,
- me.squaredDistance = me.sqrDist = function (e, t) {
- return pe.sqrDist(e.array, t.array)
- }
- ,
- me.squaredLength = me.sqrLen = function (e) {
- return pe.sqrLen(e.array)
- }
- ,
- me.subtract = me.sub = function (e, t, r) {
- return pe.subtract(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.transformMat2 = function (e, t, r) {
- return pe.transformMat2(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.transformMat2d = function (e, t, r) {
- return pe.transformMat2d(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.transformMat3 = function (e, t, r) {
- return pe.transformMat3(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- me.transformMat4 = function (e, t, r) {
- return pe.transformMat4(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ;
- const _e = me;
- var ve = {};
- function ye(e) {
- for (var t = e.split("\n"), r = 0, i = t.length; r < i; r++)
- t[r] = r + 1 + ": " + t[r];
- return t.join("\n")
- }
- function xe(e, t, r) {
- if (!e.getShaderParameter(t, e.COMPILE_STATUS))
- return [e.getShaderInfoLog(t), ye(r)].join("\n")
- }
- var be = new U.Float32Array(16);
- const we = m.extend({
- uniformSemantics: {},
- attributes: {}
- }, (function () {
- this._locations = {},
- this._textureSlot = 0,
- this._program = null
- }
- ), {
- bind: function (e) {
- this._textureSlot = 0,
- e.gl.useProgram(this._program)
- },
- hasUniform: function (e) {
- return null != this._locations[e]
- },
- useTextureSlot: function (e, t, r) {
- t && (e.gl.activeTexture(e.gl.TEXTURE0 + r),
- t.isRenderable() ? t.bind(e) : t.unbind(e))
- },
- currentTextureSlot: function () {
- return this._textureSlot
- },
- resetTextureSlot: function (e) {
- this._textureSlot = e || 0
- },
- takeCurrentTextureSlot: function (e, t) {
- var r = this._textureSlot;
- return this.useTextureSlot(e, t, r),
- this._textureSlot++,
- r
- },
- setUniform: function (e, t, r, i) {
- var n = this._locations[r];
- if (null == n)
- return !1;
- switch (t) {
- case "m4":
- if (!(i instanceof Float32Array)) {
- for (var a = 0; a < i.length; a++)
- be[a] = i[a];
- i = be
- }
- e.uniformMatrix4fv(n, !1, i);
- break;
- case "2i":
- e.uniform2i(n, i[0], i[1]);
- break;
- case "2f":
- e.uniform2f(n, i[0], i[1]);
- break;
- case "3i":
- e.uniform3i(n, i[0], i[1], i[2]);
- break;
- case "3f":
- e.uniform3f(n, i[0], i[1], i[2]);
- break;
- case "4i":
- e.uniform4i(n, i[0], i[1], i[2], i[3]);
- break;
- case "4f":
- e.uniform4f(n, i[0], i[1], i[2], i[3]);
- break;
- case "1i":
- e.uniform1i(n, i);
- break;
- case "1f":
- e.uniform1f(n, i);
- break;
- case "1fv":
- e.uniform1fv(n, i);
- break;
- case "1iv":
- e.uniform1iv(n, i);
- break;
- case "2iv":
- e.uniform2iv(n, i);
- break;
- case "2fv":
- e.uniform2fv(n, i);
- break;
- case "3iv":
- e.uniform3iv(n, i);
- break;
- case "3fv":
- e.uniform3fv(n, i);
- break;
- case "4iv":
- e.uniform4iv(n, i);
- break;
- case "4fv":
- e.uniform4fv(n, i);
- break;
- case "m2":
- case "m2v":
- e.uniformMatrix2fv(n, !1, i);
- break;
- case "m3":
- case "m3v":
- e.uniformMatrix3fv(n, !1, i);
- break;
- case "m4v":
- if (Array.isArray(i) && Array.isArray(i[0])) {
- var o = new U.Float32Array(16 * i.length)
- , s = 0;
- for (a = 0; a < i.length; a++)
- for (var l = i[a], h = 0; h < 16; h++)
- o[s++] = l[h];
- e.uniformMatrix4fv(n, !1, o)
- } else
- e.uniformMatrix4fv(n, !1, i)
- }
- return !0
- },
- setUniformOfSemantic: function (e, t, r) {
- var i = this.uniformSemantics[t];
- return !!i && this.setUniform(e, i.type, i.symbol, r)
- },
- enableAttributes: function (e, t, r) {
- var i, n = e.gl, a = this._program, o = this._locations;
- (i = r ? r.__enabledAttributeList : ve[e.__uid__]) || (i = r ? r.__enabledAttributeList = [] : ve[e.__uid__] = []);
- for (var s = [], l = 0; l < t.length; l++) {
- var h = t[l];
- if (this.attributes[h]) {
- var u = o[h];
- if (null == u) {
- if (-1 === (u = n.getAttribLocation(a, h))) {
- s[l] = -1;
- continue
- }
- o[h] = u
- }
- s[l] = u,
- i[u] ? i[u] = 2 : i[u] = 1
- } else
- s[l] = -1
- }
- for (l = 0; l < i.length; l++)
- switch (i[l]) {
- case 1:
- n.enableVertexAttribArray(l),
- i[l] = 3;
- break;
- case 2:
- i[l] = 3;
- break;
- case 3:
- n.disableVertexAttribArray(l),
- i[l] = 0
- }
- return s
- },
- getAttribLocation: function (e, t) {
- var r = this._locations
- , i = r[t];
- return null == i && (i = e.getAttribLocation(this._program, t),
- r[t] = i),
- i
- },
- buildProgram: function (e, t, r, i) {
- var n = e.createShader(e.VERTEX_SHADER)
- , a = e.createProgram();
- e.shaderSource(n, r),
- e.compileShader(n);
- var o = e.createShader(e.FRAGMENT_SHADER);
- e.shaderSource(o, i),
- e.compileShader(o);
- var s = xe(e, n, r);
- if (s)
- return s;
- if (s = xe(e, o, i))
- return s;
- if (e.attachShader(a, n),
- e.attachShader(a, o),
- t.attributeSemantics.POSITION)
- e.bindAttribLocation(a, 0, t.attributeSemantics.POSITION.symbol);
- else {
- var l = Object.keys(this.attributes);
- e.bindAttribLocation(a, 0, l[0])
- }
- if (e.linkProgram(a),
- e.deleteShader(n),
- e.deleteShader(o),
- this._program = a,
- this.vertexCode = r,
- this.fragmentCode = i,
- !e.getProgramParameter(a, e.LINK_STATUS))
- return "Could not link program\n" + e.getProgramInfoLog(a);
- for (var h = 0; h < t.uniforms.length; h++) {
- var u = t.uniforms[h];
- this._locations[u] = e.getUniformLocation(a, u)
- }
- }
- });
- var Te = /for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;
- function Se(e, t, r) {
- var i = {};
- for (var n in r)
- i[n + "_COUNT"] = r[n];
- return e.replace(Te, (function (e, r, n, a) {
- var o = "";
- isNaN(r) && (r = r in t ? t[r] : i[r]),
- isNaN(n) && (n = n in t ? t[n] : i[n]);
- for (var s = parseInt(r); s < parseInt(n); s++)
- o += "{" + a.replace(/float\s*\(\s*_idx_\s*\)/g, s.toFixed(1)).replace(/_idx_/g, s) + "}";
- return o
- }
- ))
- }
- function Me(e, t, r) {
- var i = [];
- if (t)
- for (var n in t) {
- var a = t[n];
- a > 0 && i.push("#define " + n.toUpperCase() + "_COUNT " + a)
- }
- if (r)
- for (var o = 0; o < r.length; o++) {
- var s = r[o];
- i.push("#define " + s.toUpperCase() + "_ENABLED")
- }
- for (var s in e) {
- var l = e[s];
- null === l ? i.push("#define " + s) : i.push("#define " + s + " " + l.toString())
- }
- return i.join("\n")
- }
- function Ae(e) {
- this._renderer = e,
- this._cache = {}
- }
- Ae.prototype.getProgram = function (e, t, r) {
- var i = this._cache
- , n = e.isSkinnedMesh && e.isSkinnedMesh()
- , a = e.isInstancedMesh && e.isInstancedMesh()
- , o = "s" + t.shader.shaderID + "m" + t.getProgramKey();
- if (r && (o += "se" + r.getProgramKey(e.lightGroup)),
- n && (o += ",sk" + e.joints.length),
- a && (o += ",is"),
- v = i[o])
- return v;
- var s = r ? r.getLightsNumbers(e.lightGroup) : {}
- , l = this._renderer
- , h = l.gl
- , u = t.getEnabledTextures()
- , c = "";
- if (n) {
- var d = {
- SKINNING: null,
- JOINT_COUNT: e.joints.length
- };
- e.joints.length > l.getMaxJointNumber() && (d.USE_SKIN_MATRICES_TEXTURE = null),
- c += "\n" + Me(d) + "\n"
- }
- a && (c += "\n#define INSTANCING\n");
- var f = c + Me(t.vertexDefines, s, u)
- , p = c + Me(t.fragmentDefines, s, u)
- , m = f + "\n" + t.shader.vertex
- , g = ["OES_standard_derivatives", "EXT_shader_texture_lod"].filter((function (e) {
- return null != l.getGLExtension(e)
- }
- ));
- g.indexOf("EXT_shader_texture_lod") >= 0 && (p += "\n#define SUPPORT_TEXTURE_LOD"),
- g.indexOf("OES_standard_derivatives") >= 0 && (p += "\n#define SUPPORT_STANDARD_DERIVATIVES");
- var _, v, y = function (e) {
- for (var t = [], r = 0; r < e.length; r++)
- t.push("#extension GL_" + e[r] + " : enable");
- return t.join("\n")
- }(g) + "\n" + ["precision", _ = t.precision, "float"].join(" ") + ";\n" + ["precision", _, "int"].join(" ") + ";\n" + ["precision", _, "sampler2D"].join(" ") + ";\n\n" + p + "\n" + t.shader.fragment, x = Se(m, t.vertexDefines, s), b = Se(y, t.fragmentDefines, s);
- (v = new we).uniformSemantics = t.shader.uniformSemantics,
- v.attributes = t.shader.attributes;
- var w = v.buildProgram(h, t.shader, x, b);
- return v.__error = w,
- i[o] = v,
- v
- }
- ;
- const Ee = Ae;
- var Ce = /uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g
- , De = /attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g
- , Le = /#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g
- , Pe = {
- bool: "1i",
- int: "1i",
- sampler2D: "t",
- samplerCube: "t",
- float: "1f",
- vec2: "2f",
- vec3: "3f",
- vec4: "4f",
- ivec2: "2i",
- ivec3: "3i",
- ivec4: "4i",
- mat2: "m2",
- mat3: "m3",
- mat4: "m4"
- };
- function Oe(e) {
- for (var t = [], r = 0; r < e; r++)
- t[r] = 0;
- return t
- }
- var Ne = {
- bool: function () {
- return !0
- },
- int: function () {
- return 0
- },
- float: function () {
- return 0
- },
- sampler2D: function () {
- return null
- },
- samplerCube: function () {
- return null
- },
- vec2: function () {
- return Oe(2)
- },
- vec3: function () {
- return Oe(3)
- },
- vec4: function () {
- return Oe(4)
- },
- ivec2: function () {
- return Oe(2)
- },
- ivec3: function () {
- return Oe(3)
- },
- ivec4: function () {
- return Oe(4)
- },
- mat2: function () {
- return Oe(4)
- },
- mat3: function () {
- return Oe(9)
- },
- mat4: function () {
- return Oe(16)
- },
- array: function () {
- return []
- }
- }
- , Ie = ["POSITION", "NORMAL", "BINORMAL", "TANGENT", "TEXCOORD", "TEXCOORD_0", "TEXCOORD_1", "COLOR", "JOINT", "WEIGHT"]
- , Re = ["SKIN_MATRIX", "VIEWPORT_SIZE", "VIEWPORT", "DEVICEPIXELRATIO", "WINDOW_SIZE", "NEAR", "FAR", "TIME"]
- , Be = ["WORLD", "VIEW", "PROJECTION", "WORLDVIEW", "VIEWPROJECTION", "WORLDVIEWPROJECTION", "WORLDINVERSE", "VIEWINVERSE", "PROJECTIONINVERSE", "WORLDVIEWINVERSE", "VIEWPROJECTIONINVERSE", "WORLDVIEWPROJECTIONINVERSE", "WORLDTRANSPOSE", "VIEWTRANSPOSE", "PROJECTIONTRANSPOSE", "WORLDVIEWTRANSPOSE", "VIEWPROJECTIONTRANSPOSE", "WORLDVIEWPROJECTIONTRANSPOSE", "WORLDINVERSETRANSPOSE", "VIEWINVERSETRANSPOSE", "PROJECTIONINVERSETRANSPOSE", "WORLDVIEWINVERSETRANSPOSE", "VIEWPROJECTIONINVERSETRANSPOSE", "WORLDVIEWPROJECTIONINVERSETRANSPOSE"]
- , Fe = {
- vec4: 4,
- vec3: 3,
- vec2: 2,
- float: 1
- }
- , ze = {}
- , Ge = {};
- function Ue(e) {
- return e.replace(/[ \t]*\/\/.*\n/g, "").replace(/[ \t]*\/\*[\s\S]*?\*\//g, "")
- }
- function ke() {
- console.error("Wrong uniform/attributes syntax")
- }
- function Ve(e, t) {
- for (var r = /[,=\(\):]/, i = t.replace(/:\s*\[\s*(.*)\s*\]/g, "=" + e + "($1)").replace(/\s+/g, "").split(/(?=[,=\(\):])/g), n = [], a = 0; a < i.length; a++)
- i[a].match(r) ? n.push(i[a].charAt(0), i[a].slice(1)) : n.push(i[a]);
- var o, s = 0, l = {}, h = null;
- function u(e) {
- e || ke();
- var t = e.match(/\[(.*?)\]/);
- o = e.replace(/\[(.*?)\]/, ""),
- l[o] = {},
- t && (l[o].isArray = !0,
- l[o].arraySize = t[1])
- }
- for (u((i = n)[0]),
- a = 1; a < i.length; a++) {
- var c = i[a];
- if (c)
- if ("=" !== c)
- if (":" !== c)
- if ("," !== c)
- if (")" !== c)
- if ("(" !== c)
- if (c.indexOf("vec") >= 0) {
- if (1 !== s && 4 !== s) {
- ke();
- break
- }
- s = 2,
- h = []
- } else if (1 !== s)
- if (4 !== s)
- u(c),
- s = 0;
- else {
- var d = c;
- Ie.indexOf(d) >= 0 || Re.indexOf(d) >= 0 || Be.indexOf(d) >= 0 ? l[o].semantic = d : "ignore" === d || "unconfigurable" === d ? l[o].ignore = !0 : l[o].value = "bool" === e ? "true" === d : parseFloat(d)
- }
- else
- l[o].value = "bool" === e ? "true" === c : parseFloat(c),
- h = null;
- else {
- if (2 !== s) {
- ke();
- break
- }
- if (!(h instanceof Array)) {
- ke();
- break
- }
- h.push(+i[++a])
- }
- else
- l[o].value = new U.Float32Array(h),
- h = null,
- s = 5;
- else if (2 === s) {
- if (!(h instanceof Array)) {
- ke();
- break
- }
- h.push(+i[++a])
- } else
- s = 5;
- else
- s = 4;
- else {
- if (0 !== s && 3 !== s) {
- ke();
- break
- }
- s = 1
- }
- }
- return l
- }
- function He(e, t) {
- "object" == typeof e && (t = e.fragment,
- e = e.vertex),
- e = Ue(e),
- t = Ue(t),
- this._shaderID = function (e, t) {
- var r = "vertex:" + e + "fragment:" + t;
- if (ze[r])
- return ze[r];
- var i = f.genGUID();
- return ze[r] = i,
- Ge[i] = {
- vertex: e,
- fragment: t
- },
- i
- }(e, t),
- this._vertexCode = He.parseImport(e),
- this._fragmentCode = He.parseImport(t),
- this.attributeSemantics = {},
- this.matrixSemantics = {},
- this.uniformSemantics = {},
- this.matrixSemanticKeys = [],
- this.uniformTemplates = {},
- this.attributes = {},
- this.textures = {},
- this.vertexDefines = {},
- this.fragmentDefines = {},
- this._parseAttributes(),
- this._parseUniforms(),
- this._parseDefines()
- }
- He.prototype = {
- constructor: He,
- createUniforms: function () {
- var e = {};
- for (var t in this.uniformTemplates) {
- var r = this.uniformTemplates[t];
- e[t] = {
- type: r.type,
- value: r.value()
- }
- }
- return e
- },
- _parseImport: function () {
- this._vertexCode = He.parseImport(this.vertex),
- this._fragmentCode = He.parseImport(this.fragment)
- },
- _addSemanticUniform: function (e, t, r) {
- if (Ie.indexOf(r) >= 0)
- this.attributeSemantics[r] = {
- symbol: e,
- type: t
- };
- else if (Be.indexOf(r) >= 0) {
- var i = !1
- , n = r;
- r.match(/TRANSPOSE$/) && (i = !0,
- n = r.slice(0, -9)),
- this.matrixSemantics[r] = {
- symbol: e,
- type: t,
- isTranspose: i,
- semanticNoTranspose: n
- }
- } else
- Re.indexOf(r) >= 0 && (this.uniformSemantics[r] = {
- symbol: e,
- type: t
- })
- },
- _addMaterialUniform: function (e, t, r, i, n, a) {
- a[e] = {
- type: r,
- value: n ? Ne.array : i || Ne[t],
- semantic: null
- }
- },
- _parseUniforms: function () {
- var e = {}
- , t = this;
- function r(e) {
- return null != e ? function () {
- return e
- }
- : null
- }
- function i(i, n, a) {
- var o = Ve(n, a)
- , s = [];
- for (var l in o) {
- var h = o[l]
- , u = h.semantic
- , c = l
- , d = Pe[n]
- , f = r(o[l].value);
- o[l].isArray && (c += "[" + o[l].arraySize + "]",
- d += "v"),
- s.push(c),
- t._uniformList.push(l),
- h.ignore || ("sampler2D" !== n && "samplerCube" !== n || (t.textures[l] = {
- shaderType: "fragment",
- type: n
- }),
- u ? t._addSemanticUniform(l, d, u) : t._addMaterialUniform(l, n, d, f, o[l].isArray, e))
- }
- return s.length > 0 ? "uniform " + n + " " + s.join(",") + ";\n" : ""
- }
- this._uniformList = [],
- this._vertexCode = this._vertexCode.replace(Ce, i),
- this._fragmentCode = this._fragmentCode.replace(Ce, i),
- t.matrixSemanticKeys = Object.keys(this.matrixSemantics),
- this.uniformTemplates = e
- },
- _parseAttributes: function () {
- var e = {}
- , t = this;
- this._vertexCode = this._vertexCode.replace(De, (function (r, i, n) {
- var a = Ve(i, n)
- , o = Fe[i] || 1
- , s = [];
- for (var l in a) {
- var h = a[l].semantic;
- if (e[l] = {
- type: "float",
- size: o,
- semantic: h || null
- },
- h) {
- if (Ie.indexOf(h) < 0)
- throw new Error('Unkown semantic "' + h + '"');
- t.attributeSemantics[h] = {
- symbol: l,
- type: i
- }
- }
- s.push(l)
- }
- return "attribute " + i + " " + s.join(",") + ";\n"
- }
- )),
- this.attributes = e
- },
- _parseDefines: function () {
- var e = this;
- function t(t, r, i) {
- var n = e.fragmentDefines;
- return n[r] || (n[r] = "false" !== i && ("true" === i || (i ? isNaN(parseFloat(i)) ? i.trim() : parseFloat(i) : null))),
- ""
- }
- this._vertexCode = this._vertexCode.replace(Le, t),
- this._fragmentCode = this._fragmentCode.replace(Le, t)
- },
- clone: function () {
- var e = Ge[this._shaderID];
- return new He(e.vertex, e.fragment)
- }
- },
- Object.defineProperty && (Object.defineProperty(He.prototype, "shaderID", {
- get: function () {
- return this._shaderID
- }
- }),
- Object.defineProperty(He.prototype, "vertex", {
- get: function () {
- return this._vertexCode
- }
- }),
- Object.defineProperty(He.prototype, "fragment", {
- get: function () {
- return this._fragmentCode
- }
- }),
- Object.defineProperty(He.prototype, "uniforms", {
- get: function () {
- return this._uniformList
- }
- }));
- var We = /(@import)\s*([0-9a-zA-Z_\-\.]*)/g;
- He.parseImport = function (e) {
- return e.replace(We, (function (e, t, r) {
- return (e = He.source(r)) ? He.parseImport(e) : (console.error('Shader chunk "' + r + '" not existed in library'),
- "")
- }
- ))
- }
- ;
- var je = /(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;
- He.import = function (e) {
- e.replace(je, (function (e, t, r, i) {
- if (i = i.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g, "")) {
- for (var n, a = r.split("."), o = He.codes, s = 0; s < a.length - 1;)
- o[n = a[s++]] || (o[n] = {}),
- o = o[n];
- o[n = a[s]] = i
- }
- return i
- }
- ))
- }
- ,
- He.codes = {},
- He.source = function (e) {
- for (var t = e.split("."), r = He.codes, i = 0; r && i < t.length;)
- r = r[t[i++]];
- return "string" != typeof r ? (console.error('Shader "' + e + '" not existed in library'),
- "") : r
- }
- ;
- const Xe = He
- , qe = "@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end";
- var Ze = {
- create: function () {
- var e = new ce(16);
- return e[0] = 1,
- e[1] = 0,
- e[2] = 0,
- e[3] = 0,
- e[4] = 0,
- e[5] = 1,
- e[6] = 0,
- e[7] = 0,
- e[8] = 0,
- e[9] = 0,
- e[10] = 1,
- e[11] = 0,
- e[12] = 0,
- e[13] = 0,
- e[14] = 0,
- e[15] = 1,
- e
- },
- clone: function (e) {
- var t = new ce(16);
- return t[0] = e[0],
- t[1] = e[1],
- t[2] = e[2],
- t[3] = e[3],
- t[4] = e[4],
- t[5] = e[5],
- t[6] = e[6],
- t[7] = e[7],
- t[8] = e[8],
- t[9] = e[9],
- t[10] = e[10],
- t[11] = e[11],
- t[12] = e[12],
- t[13] = e[13],
- t[14] = e[14],
- t[15] = e[15],
- t
- },
- copy: function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e[4] = t[4],
- e[5] = t[5],
- e[6] = t[6],
- e[7] = t[7],
- e[8] = t[8],
- e[9] = t[9],
- e[10] = t[10],
- e[11] = t[11],
- e[12] = t[12],
- e[13] = t[13],
- e[14] = t[14],
- e[15] = t[15],
- e
- },
- identity: function (e) {
- return e[0] = 1,
- e[1] = 0,
- e[2] = 0,
- e[3] = 0,
- e[4] = 0,
- e[5] = 1,
- e[6] = 0,
- e[7] = 0,
- e[8] = 0,
- e[9] = 0,
- e[10] = 1,
- e[11] = 0,
- e[12] = 0,
- e[13] = 0,
- e[14] = 0,
- e[15] = 1,
- e
- },
- transpose: function (e, t) {
- if (e === t) {
- var r = t[1]
- , i = t[2]
- , n = t[3]
- , a = t[6]
- , o = t[7]
- , s = t[11];
- e[1] = t[4],
- e[2] = t[8],
- e[3] = t[12],
- e[4] = r,
- e[6] = t[9],
- e[7] = t[13],
- e[8] = i,
- e[9] = a,
- e[11] = t[14],
- e[12] = n,
- e[13] = o,
- e[14] = s
- } else
- e[0] = t[0],
- e[1] = t[4],
- e[2] = t[8],
- e[3] = t[12],
- e[4] = t[1],
- e[5] = t[5],
- e[6] = t[9],
- e[7] = t[13],
- e[8] = t[2],
- e[9] = t[6],
- e[10] = t[10],
- e[11] = t[14],
- e[12] = t[3],
- e[13] = t[7],
- e[14] = t[11],
- e[15] = t[15];
- return e
- },
- invert: function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = t[4]
- , s = t[5]
- , l = t[6]
- , h = t[7]
- , u = t[8]
- , c = t[9]
- , d = t[10]
- , f = t[11]
- , p = t[12]
- , m = t[13]
- , g = t[14]
- , _ = t[15]
- , v = r * s - i * o
- , y = r * l - n * o
- , x = r * h - a * o
- , b = i * l - n * s
- , w = i * h - a * s
- , T = n * h - a * l
- , S = u * m - c * p
- , M = u * g - d * p
- , A = u * _ - f * p
- , E = c * g - d * m
- , C = c * _ - f * m
- , D = d * _ - f * g
- , L = v * D - y * C + x * E + b * A - w * M + T * S;
- return L ? (L = 1 / L,
- e[0] = (s * D - l * C + h * E) * L,
- e[1] = (n * C - i * D - a * E) * L,
- e[2] = (m * T - g * w + _ * b) * L,
- e[3] = (d * w - c * T - f * b) * L,
- e[4] = (l * A - o * D - h * M) * L,
- e[5] = (r * D - n * A + a * M) * L,
- e[6] = (g * x - p * T - _ * y) * L,
- e[7] = (u * T - d * x + f * y) * L,
- e[8] = (o * C - s * A + h * S) * L,
- e[9] = (i * A - r * C - a * S) * L,
- e[10] = (p * w - m * x + _ * v) * L,
- e[11] = (c * x - u * w - f * v) * L,
- e[12] = (s * M - o * E - l * S) * L,
- e[13] = (r * E - i * M + n * S) * L,
- e[14] = (m * y - p * b - g * v) * L,
- e[15] = (u * b - c * y + d * v) * L,
- e) : null
- },
- adjoint: function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = t[4]
- , s = t[5]
- , l = t[6]
- , h = t[7]
- , u = t[8]
- , c = t[9]
- , d = t[10]
- , f = t[11]
- , p = t[12]
- , m = t[13]
- , g = t[14]
- , _ = t[15];
- return e[0] = s * (d * _ - f * g) - c * (l * _ - h * g) + m * (l * f - h * d),
- e[1] = -(i * (d * _ - f * g) - c * (n * _ - a * g) + m * (n * f - a * d)),
- e[2] = i * (l * _ - h * g) - s * (n * _ - a * g) + m * (n * h - a * l),
- e[3] = -(i * (l * f - h * d) - s * (n * f - a * d) + c * (n * h - a * l)),
- e[4] = -(o * (d * _ - f * g) - u * (l * _ - h * g) + p * (l * f - h * d)),
- e[5] = r * (d * _ - f * g) - u * (n * _ - a * g) + p * (n * f - a * d),
- e[6] = -(r * (l * _ - h * g) - o * (n * _ - a * g) + p * (n * h - a * l)),
- e[7] = r * (l * f - h * d) - o * (n * f - a * d) + u * (n * h - a * l),
- e[8] = o * (c * _ - f * m) - u * (s * _ - h * m) + p * (s * f - h * c),
- e[9] = -(r * (c * _ - f * m) - u * (i * _ - a * m) + p * (i * f - a * c)),
- e[10] = r * (s * _ - h * m) - o * (i * _ - a * m) + p * (i * h - a * s),
- e[11] = -(r * (s * f - h * c) - o * (i * f - a * c) + u * (i * h - a * s)),
- e[12] = -(o * (c * g - d * m) - u * (s * g - l * m) + p * (s * d - l * c)),
- e[13] = r * (c * g - d * m) - u * (i * g - n * m) + p * (i * d - n * c),
- e[14] = -(r * (s * g - l * m) - o * (i * g - n * m) + p * (i * l - n * s)),
- e[15] = r * (s * d - l * c) - o * (i * d - n * c) + u * (i * l - n * s),
- e
- },
- determinant: function (e) {
- var t = e[0]
- , r = e[1]
- , i = e[2]
- , n = e[3]
- , a = e[4]
- , o = e[5]
- , s = e[6]
- , l = e[7]
- , h = e[8]
- , u = e[9]
- , c = e[10]
- , d = e[11]
- , f = e[12]
- , p = e[13]
- , m = e[14]
- , g = e[15];
- return (t * o - r * a) * (c * g - d * m) - (t * s - i * a) * (u * g - d * p) + (t * l - n * a) * (u * m - c * p) + (r * s - i * o) * (h * g - d * f) - (r * l - n * o) * (h * m - c * f) + (i * l - n * s) * (h * p - u * f)
- },
- multiply: function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = t[4]
- , l = t[5]
- , h = t[6]
- , u = t[7]
- , c = t[8]
- , d = t[9]
- , f = t[10]
- , p = t[11]
- , m = t[12]
- , g = t[13]
- , _ = t[14]
- , v = t[15]
- , y = r[0]
- , x = r[1]
- , b = r[2]
- , w = r[3];
- return e[0] = y * i + x * s + b * c + w * m,
- e[1] = y * n + x * l + b * d + w * g,
- e[2] = y * a + x * h + b * f + w * _,
- e[3] = y * o + x * u + b * p + w * v,
- y = r[4],
- x = r[5],
- b = r[6],
- w = r[7],
- e[4] = y * i + x * s + b * c + w * m,
- e[5] = y * n + x * l + b * d + w * g,
- e[6] = y * a + x * h + b * f + w * _,
- e[7] = y * o + x * u + b * p + w * v,
- y = r[8],
- x = r[9],
- b = r[10],
- w = r[11],
- e[8] = y * i + x * s + b * c + w * m,
- e[9] = y * n + x * l + b * d + w * g,
- e[10] = y * a + x * h + b * f + w * _,
- e[11] = y * o + x * u + b * p + w * v,
- y = r[12],
- x = r[13],
- b = r[14],
- w = r[15],
- e[12] = y * i + x * s + b * c + w * m,
- e[13] = y * n + x * l + b * d + w * g,
- e[14] = y * a + x * h + b * f + w * _,
- e[15] = y * o + x * u + b * p + w * v,
- e
- },
- multiplyAffine: function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[4]
- , s = t[5]
- , l = t[6]
- , h = t[8]
- , u = t[9]
- , c = t[10]
- , d = t[12]
- , f = t[13]
- , p = t[14]
- , m = r[0]
- , g = r[1]
- , _ = r[2];
- return e[0] = m * i + g * o + _ * h,
- e[1] = m * n + g * s + _ * u,
- e[2] = m * a + g * l + _ * c,
- m = r[4],
- g = r[5],
- _ = r[6],
- e[4] = m * i + g * o + _ * h,
- e[5] = m * n + g * s + _ * u,
- e[6] = m * a + g * l + _ * c,
- m = r[8],
- g = r[9],
- _ = r[10],
- e[8] = m * i + g * o + _ * h,
- e[9] = m * n + g * s + _ * u,
- e[10] = m * a + g * l + _ * c,
- m = r[12],
- g = r[13],
- _ = r[14],
- e[12] = m * i + g * o + _ * h + d,
- e[13] = m * n + g * s + _ * u + f,
- e[14] = m * a + g * l + _ * c + p,
- e
- }
- };
- Ze.mul = Ze.multiply,
- Ze.mulAffine = Ze.multiplyAffine,
- Ze.translate = function (e, t, r) {
- var i, n, a, o, s, l, h, u, c, d, f, p, m = r[0], g = r[1], _ = r[2];
- return t === e ? (e[12] = t[0] * m + t[4] * g + t[8] * _ + t[12],
- e[13] = t[1] * m + t[5] * g + t[9] * _ + t[13],
- e[14] = t[2] * m + t[6] * g + t[10] * _ + t[14],
- e[15] = t[3] * m + t[7] * g + t[11] * _ + t[15]) : (i = t[0],
- n = t[1],
- a = t[2],
- o = t[3],
- s = t[4],
- l = t[5],
- h = t[6],
- u = t[7],
- c = t[8],
- d = t[9],
- f = t[10],
- p = t[11],
- e[0] = i,
- e[1] = n,
- e[2] = a,
- e[3] = o,
- e[4] = s,
- e[5] = l,
- e[6] = h,
- e[7] = u,
- e[8] = c,
- e[9] = d,
- e[10] = f,
- e[11] = p,
- e[12] = i * m + s * g + c * _ + t[12],
- e[13] = n * m + l * g + d * _ + t[13],
- e[14] = a * m + h * g + f * _ + t[14],
- e[15] = o * m + u * g + p * _ + t[15]),
- e
- }
- ,
- Ze.scale = function (e, t, r) {
- var i = r[0]
- , n = r[1]
- , a = r[2];
- return e[0] = t[0] * i,
- e[1] = t[1] * i,
- e[2] = t[2] * i,
- e[3] = t[3] * i,
- e[4] = t[4] * n,
- e[5] = t[5] * n,
- e[6] = t[6] * n,
- e[7] = t[7] * n,
- e[8] = t[8] * a,
- e[9] = t[9] * a,
- e[10] = t[10] * a,
- e[11] = t[11] * a,
- e[12] = t[12],
- e[13] = t[13],
- e[14] = t[14],
- e[15] = t[15],
- e
- }
- ,
- Ze.rotate = function (e, t, r, i) {
- var n, a, o, s, l, h, u, c, d, f, p, m, g, _, v, y, x, b, w, T, S, M, A, E, C = i[0], D = i[1], L = i[2], P = Math.sqrt(C * C + D * D + L * L);
- return Math.abs(P) < ue ? null : (C *= P = 1 / P,
- D *= P,
- L *= P,
- n = Math.sin(r),
- o = 1 - (a = Math.cos(r)),
- s = t[0],
- l = t[1],
- h = t[2],
- u = t[3],
- c = t[4],
- d = t[5],
- f = t[6],
- p = t[7],
- m = t[8],
- g = t[9],
- _ = t[10],
- v = t[11],
- y = C * C * o + a,
- x = D * C * o + L * n,
- b = L * C * o - D * n,
- w = C * D * o - L * n,
- T = D * D * o + a,
- S = L * D * o + C * n,
- M = C * L * o + D * n,
- A = D * L * o - C * n,
- E = L * L * o + a,
- e[0] = s * y + c * x + m * b,
- e[1] = l * y + d * x + g * b,
- e[2] = h * y + f * x + _ * b,
- e[3] = u * y + p * x + v * b,
- e[4] = s * w + c * T + m * S,
- e[5] = l * w + d * T + g * S,
- e[6] = h * w + f * T + _ * S,
- e[7] = u * w + p * T + v * S,
- e[8] = s * M + c * A + m * E,
- e[9] = l * M + d * A + g * E,
- e[10] = h * M + f * A + _ * E,
- e[11] = u * M + p * A + v * E,
- t !== e && (e[12] = t[12],
- e[13] = t[13],
- e[14] = t[14],
- e[15] = t[15]),
- e)
- }
- ,
- Ze.rotateX = function (e, t, r) {
- var i = Math.sin(r)
- , n = Math.cos(r)
- , a = t[4]
- , o = t[5]
- , s = t[6]
- , l = t[7]
- , h = t[8]
- , u = t[9]
- , c = t[10]
- , d = t[11];
- return t !== e && (e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e[12] = t[12],
- e[13] = t[13],
- e[14] = t[14],
- e[15] = t[15]),
- e[4] = a * n + h * i,
- e[5] = o * n + u * i,
- e[6] = s * n + c * i,
- e[7] = l * n + d * i,
- e[8] = h * n - a * i,
- e[9] = u * n - o * i,
- e[10] = c * n - s * i,
- e[11] = d * n - l * i,
- e
- }
- ,
- Ze.rotateY = function (e, t, r) {
- var i = Math.sin(r)
- , n = Math.cos(r)
- , a = t[0]
- , o = t[1]
- , s = t[2]
- , l = t[3]
- , h = t[8]
- , u = t[9]
- , c = t[10]
- , d = t[11];
- return t !== e && (e[4] = t[4],
- e[5] = t[5],
- e[6] = t[6],
- e[7] = t[7],
- e[12] = t[12],
- e[13] = t[13],
- e[14] = t[14],
- e[15] = t[15]),
- e[0] = a * n - h * i,
- e[1] = o * n - u * i,
- e[2] = s * n - c * i,
- e[3] = l * n - d * i,
- e[8] = a * i + h * n,
- e[9] = o * i + u * n,
- e[10] = s * i + c * n,
- e[11] = l * i + d * n,
- e
- }
- ,
- Ze.rotateZ = function (e, t, r) {
- var i = Math.sin(r)
- , n = Math.cos(r)
- , a = t[0]
- , o = t[1]
- , s = t[2]
- , l = t[3]
- , h = t[4]
- , u = t[5]
- , c = t[6]
- , d = t[7];
- return t !== e && (e[8] = t[8],
- e[9] = t[9],
- e[10] = t[10],
- e[11] = t[11],
- e[12] = t[12],
- e[13] = t[13],
- e[14] = t[14],
- e[15] = t[15]),
- e[0] = a * n + h * i,
- e[1] = o * n + u * i,
- e[2] = s * n + c * i,
- e[3] = l * n + d * i,
- e[4] = h * n - a * i,
- e[5] = u * n - o * i,
- e[6] = c * n - s * i,
- e[7] = d * n - l * i,
- e
- }
- ,
- Ze.fromRotationTranslation = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = i + i
- , l = n + n
- , h = a + a
- , u = i * s
- , c = i * l
- , d = i * h
- , f = n * l
- , p = n * h
- , m = a * h
- , g = o * s
- , _ = o * l
- , v = o * h;
- return e[0] = 1 - (f + m),
- e[1] = c + v,
- e[2] = d - _,
- e[3] = 0,
- e[4] = c - v,
- e[5] = 1 - (u + m),
- e[6] = p + g,
- e[7] = 0,
- e[8] = d + _,
- e[9] = p - g,
- e[10] = 1 - (u + f),
- e[11] = 0,
- e[12] = r[0],
- e[13] = r[1],
- e[14] = r[2],
- e[15] = 1,
- e
- }
- ,
- Ze.fromQuat = function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = r + r
- , s = i + i
- , l = n + n
- , h = r * o
- , u = i * o
- , c = i * s
- , d = n * o
- , f = n * s
- , p = n * l
- , m = a * o
- , g = a * s
- , _ = a * l;
- return e[0] = 1 - c - p,
- e[1] = u + _,
- e[2] = d - g,
- e[3] = 0,
- e[4] = u - _,
- e[5] = 1 - h - p,
- e[6] = f + m,
- e[7] = 0,
- e[8] = d + g,
- e[9] = f - m,
- e[10] = 1 - h - c,
- e[11] = 0,
- e[12] = 0,
- e[13] = 0,
- e[14] = 0,
- e[15] = 1,
- e
- }
- ,
- Ze.frustum = function (e, t, r, i, n, a, o) {
- var s = 1 / (r - t)
- , l = 1 / (n - i)
- , h = 1 / (a - o);
- return e[0] = 2 * a * s,
- e[1] = 0,
- e[2] = 0,
- e[3] = 0,
- e[4] = 0,
- e[5] = 2 * a * l,
- e[6] = 0,
- e[7] = 0,
- e[8] = (r + t) * s,
- e[9] = (n + i) * l,
- e[10] = (o + a) * h,
- e[11] = -1,
- e[12] = 0,
- e[13] = 0,
- e[14] = o * a * 2 * h,
- e[15] = 0,
- e
- }
- ,
- Ze.perspective = function (e, t, r, i, n) {
- var a = 1 / Math.tan(t / 2)
- , o = 1 / (i - n);
- return e[0] = a / r,
- e[1] = 0,
- e[2] = 0,
- e[3] = 0,
- e[4] = 0,
- e[5] = a,
- e[6] = 0,
- e[7] = 0,
- e[8] = 0,
- e[9] = 0,
- e[10] = (n + i) * o,
- e[11] = -1,
- e[12] = 0,
- e[13] = 0,
- e[14] = 2 * n * i * o,
- e[15] = 0,
- e
- }
- ,
- Ze.ortho = function (e, t, r, i, n, a, o) {
- var s = 1 / (t - r)
- , l = 1 / (i - n)
- , h = 1 / (a - o);
- return e[0] = -2 * s,
- e[1] = 0,
- e[2] = 0,
- e[3] = 0,
- e[4] = 0,
- e[5] = -2 * l,
- e[6] = 0,
- e[7] = 0,
- e[8] = 0,
- e[9] = 0,
- e[10] = 2 * h,
- e[11] = 0,
- e[12] = (t + r) * s,
- e[13] = (n + i) * l,
- e[14] = (o + a) * h,
- e[15] = 1,
- e
- }
- ,
- Ze.lookAt = function (e, t, r, i) {
- var n, a, o, s, l, h, u, c, d, f, p = t[0], m = t[1], g = t[2], _ = i[0], v = i[1], y = i[2], x = r[0], b = r[1], w = r[2];
- return Math.abs(p - x) < ue && Math.abs(m - b) < ue && Math.abs(g - w) < ue ? Ze.identity(e) : (u = p - x,
- c = m - b,
- d = g - w,
- n = v * (d *= f = 1 / Math.sqrt(u * u + c * c + d * d)) - y * (c *= f),
- a = y * (u *= f) - _ * d,
- o = _ * c - v * u,
- (f = Math.sqrt(n * n + a * a + o * o)) ? (n *= f = 1 / f,
- a *= f,
- o *= f) : (n = 0,
- a = 0,
- o = 0),
- s = c * o - d * a,
- l = d * n - u * o,
- h = u * a - c * n,
- (f = Math.sqrt(s * s + l * l + h * h)) ? (s *= f = 1 / f,
- l *= f,
- h *= f) : (s = 0,
- l = 0,
- h = 0),
- e[0] = n,
- e[1] = s,
- e[2] = u,
- e[3] = 0,
- e[4] = a,
- e[5] = l,
- e[6] = c,
- e[7] = 0,
- e[8] = o,
- e[9] = h,
- e[10] = d,
- e[11] = 0,
- e[12] = -(n * p + a * m + o * g),
- e[13] = -(s * p + l * m + h * g),
- e[14] = -(u * p + c * m + d * g),
- e[15] = 1,
- e)
- }
- ,
- Ze.frob = function (e) {
- return Math.sqrt(Math.pow(e[0], 2) + Math.pow(e[1], 2) + Math.pow(e[2], 2) + Math.pow(e[3], 2) + Math.pow(e[4], 2) + Math.pow(e[5], 2) + Math.pow(e[6], 2) + Math.pow(e[7], 2) + Math.pow(e[8], 2) + Math.pow(e[9], 2) + Math.pow(e[10], 2) + Math.pow(e[11], 2) + Math.pow(e[12], 2) + Math.pow(e[13], 2) + Math.pow(e[14], 2) + Math.pow(e[15], 2))
- }
- ;
- const Ye = Ze;
- var Ke = {
- create: function () {
- var e = new ce(3);
- return e[0] = 0,
- e[1] = 0,
- e[2] = 0,
- e
- },
- clone: function (e) {
- var t = new ce(3);
- return t[0] = e[0],
- t[1] = e[1],
- t[2] = e[2],
- t
- },
- fromValues: function (e, t, r) {
- var i = new ce(3);
- return i[0] = e,
- i[1] = t,
- i[2] = r,
- i
- },
- copy: function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e
- },
- set: function (e, t, r, i) {
- return e[0] = t,
- e[1] = r,
- e[2] = i,
- e
- },
- add: function (e, t, r) {
- return e[0] = t[0] + r[0],
- e[1] = t[1] + r[1],
- e[2] = t[2] + r[2],
- e
- },
- subtract: function (e, t, r) {
- return e[0] = t[0] - r[0],
- e[1] = t[1] - r[1],
- e[2] = t[2] - r[2],
- e
- }
- };
- Ke.sub = Ke.subtract,
- Ke.multiply = function (e, t, r) {
- return e[0] = t[0] * r[0],
- e[1] = t[1] * r[1],
- e[2] = t[2] * r[2],
- e
- }
- ,
- Ke.mul = Ke.multiply,
- Ke.divide = function (e, t, r) {
- return e[0] = t[0] / r[0],
- e[1] = t[1] / r[1],
- e[2] = t[2] / r[2],
- e
- }
- ,
- Ke.div = Ke.divide,
- Ke.min = function (e, t, r) {
- return e[0] = Math.min(t[0], r[0]),
- e[1] = Math.min(t[1], r[1]),
- e[2] = Math.min(t[2], r[2]),
- e
- }
- ,
- Ke.max = function (e, t, r) {
- return e[0] = Math.max(t[0], r[0]),
- e[1] = Math.max(t[1], r[1]),
- e[2] = Math.max(t[2], r[2]),
- e
- }
- ,
- Ke.scale = function (e, t, r) {
- return e[0] = t[0] * r,
- e[1] = t[1] * r,
- e[2] = t[2] * r,
- e
- }
- ,
- Ke.scaleAndAdd = function (e, t, r, i) {
- return e[0] = t[0] + r[0] * i,
- e[1] = t[1] + r[1] * i,
- e[2] = t[2] + r[2] * i,
- e
- }
- ,
- Ke.distance = function (e, t) {
- var r = t[0] - e[0]
- , i = t[1] - e[1]
- , n = t[2] - e[2];
- return Math.sqrt(r * r + i * i + n * n)
- }
- ,
- Ke.dist = Ke.distance,
- Ke.squaredDistance = function (e, t) {
- var r = t[0] - e[0]
- , i = t[1] - e[1]
- , n = t[2] - e[2];
- return r * r + i * i + n * n
- }
- ,
- Ke.sqrDist = Ke.squaredDistance,
- Ke.length = function (e) {
- var t = e[0]
- , r = e[1]
- , i = e[2];
- return Math.sqrt(t * t + r * r + i * i)
- }
- ,
- Ke.len = Ke.length,
- Ke.squaredLength = function (e) {
- var t = e[0]
- , r = e[1]
- , i = e[2];
- return t * t + r * r + i * i
- }
- ,
- Ke.sqrLen = Ke.squaredLength,
- Ke.negate = function (e, t) {
- return e[0] = -t[0],
- e[1] = -t[1],
- e[2] = -t[2],
- e
- }
- ,
- Ke.inverse = function (e, t) {
- return e[0] = 1 / t[0],
- e[1] = 1 / t[1],
- e[2] = 1 / t[2],
- e
- }
- ,
- Ke.normalize = function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = r * r + i * i + n * n;
- return a > 0 && (a = 1 / Math.sqrt(a),
- e[0] = t[0] * a,
- e[1] = t[1] * a,
- e[2] = t[2] * a),
- e
- }
- ,
- Ke.dot = function (e, t) {
- return e[0] * t[0] + e[1] * t[1] + e[2] * t[2]
- }
- ,
- Ke.cross = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = r[0]
- , s = r[1]
- , l = r[2];
- return e[0] = n * l - a * s,
- e[1] = a * o - i * l,
- e[2] = i * s - n * o,
- e
- }
- ,
- Ke.lerp = function (e, t, r, i) {
- var n = t[0]
- , a = t[1]
- , o = t[2];
- return e[0] = n + i * (r[0] - n),
- e[1] = a + i * (r[1] - a),
- e[2] = o + i * (r[2] - o),
- e
- }
- ,
- Ke.random = function (e, t) {
- t = t || 1;
- var r = 2 * de() * Math.PI
- , i = 2 * de() - 1
- , n = Math.sqrt(1 - i * i) * t;
- return e[0] = Math.cos(r) * n,
- e[1] = Math.sin(r) * n,
- e[2] = i * t,
- e
- }
- ,
- Ke.transformMat4 = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = r[3] * i + r[7] * n + r[11] * a + r[15];
- return o = o || 1,
- e[0] = (r[0] * i + r[4] * n + r[8] * a + r[12]) / o,
- e[1] = (r[1] * i + r[5] * n + r[9] * a + r[13]) / o,
- e[2] = (r[2] * i + r[6] * n + r[10] * a + r[14]) / o,
- e
- }
- ,
- Ke.transformMat3 = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2];
- return e[0] = i * r[0] + n * r[3] + a * r[6],
- e[1] = i * r[1] + n * r[4] + a * r[7],
- e[2] = i * r[2] + n * r[5] + a * r[8],
- e
- }
- ,
- Ke.transformQuat = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = r[0]
- , s = r[1]
- , l = r[2]
- , h = r[3]
- , u = h * i + s * a - l * n
- , c = h * n + l * i - o * a
- , d = h * a + o * n - s * i
- , f = -o * i - s * n - l * a;
- return e[0] = u * h + f * -o + c * -l - d * -s,
- e[1] = c * h + f * -s + d * -o - u * -l,
- e[2] = d * h + f * -l + u * -s - c * -o,
- e
- }
- ,
- Ke.rotateX = function (e, t, r, i) {
- var n = []
- , a = [];
- return n[0] = t[0] - r[0],
- n[1] = t[1] - r[1],
- n[2] = t[2] - r[2],
- a[0] = n[0],
- a[1] = n[1] * Math.cos(i) - n[2] * Math.sin(i),
- a[2] = n[1] * Math.sin(i) + n[2] * Math.cos(i),
- e[0] = a[0] + r[0],
- e[1] = a[1] + r[1],
- e[2] = a[2] + r[2],
- e
- }
- ,
- Ke.rotateY = function (e, t, r, i) {
- var n = []
- , a = [];
- return n[0] = t[0] - r[0],
- n[1] = t[1] - r[1],
- n[2] = t[2] - r[2],
- a[0] = n[2] * Math.sin(i) + n[0] * Math.cos(i),
- a[1] = n[1],
- a[2] = n[2] * Math.cos(i) - n[0] * Math.sin(i),
- e[0] = a[0] + r[0],
- e[1] = a[1] + r[1],
- e[2] = a[2] + r[2],
- e
- }
- ,
- Ke.rotateZ = function (e, t, r, i) {
- var n = []
- , a = [];
- return n[0] = t[0] - r[0],
- n[1] = t[1] - r[1],
- n[2] = t[2] - r[2],
- a[0] = n[0] * Math.cos(i) - n[1] * Math.sin(i),
- a[1] = n[0] * Math.sin(i) + n[1] * Math.cos(i),
- a[2] = n[2],
- e[0] = a[0] + r[0],
- e[1] = a[1] + r[1],
- e[2] = a[2] + r[2],
- e
- }
- ,
- Ke.forEach = function () {
- var e = Ke.create();
- return function (t, r, i, n, a, o) {
- var s, l;
- for (r || (r = 3),
- i || (i = 0),
- l = n ? Math.min(n * r + i, t.length) : t.length,
- s = i; s < l; s += r)
- e[0] = t[s],
- e[1] = t[s + 1],
- e[2] = t[s + 2],
- a(e, e, o),
- t[s] = e[0],
- t[s + 1] = e[1],
- t[s + 2] = e[2];
- return t
- }
- }(),
- Ke.angle = function (e, t) {
- var r = Ke.fromValues(e[0], e[1], e[2])
- , i = Ke.fromValues(t[0], t[1], t[2]);
- Ke.normalize(r, r),
- Ke.normalize(i, i);
- var n = Ke.dot(r, i);
- return n > 1 ? 0 : Math.acos(n)
- }
- ;
- const Qe = Ke;
- Xe.import(qe);
- var Je = Ye.create
- , $e = {};
- function et(e) {
- return e.material
- }
- function tt(e, t, r) {
- return t.uniforms[r].value
- }
- function rt(e, t, r, i) {
- return r !== i
- }
- function it(e) {
- return !0
- }
- function nt() { }
- var at = {
- float: S,
- byte: 5120,
- ubyte: T,
- short: 5122,
- ushort: 5123
- };
- function ot(e, t, r) {
- this.availableAttributes = e,
- this.availableAttributeSymbols = t,
- this.indicesBuffer = r,
- this.vao = null
- }
- function st(e) {
- var t, r;
- this.bind = function (e) {
- t || ((t = U.createCanvas()).width = t.height = 1,
- t.getContext("2d"));
- var i = e.gl
- , n = !r;
- n && (r = i.createTexture()),
- i.bindTexture(i.TEXTURE_2D, r),
- n && i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, t)
- }
- ,
- this.unbind = function (e) {
- e.gl.bindTexture(e.gl.TEXTURE_2D, null)
- }
- ,
- this.isRenderable = function () {
- return !0
- }
- }
- var lt = m.extend((function () {
- return {
- canvas: null,
- _width: 100,
- _height: 100,
- devicePixelRatio: "undefined" != typeof window && window.devicePixelRatio || 1,
- clearColor: [0, 0, 0, 0],
- clearBit: 17664,
- alpha: !0,
- depth: !0,
- stencil: !1,
- antialias: !0,
- premultipliedAlpha: !0,
- preserveDrawingBuffer: !1,
- throwError: !0,
- gl: null,
- viewport: {},
- maxJointNumber: 20,
- __currentFrameBuffer: null,
- _viewportStack: [],
- _clearStack: [],
- _sceneRendering: null
- }
- }
- ), (function () {
- this.canvas || (this.canvas = U.createCanvas());
- var e = this.canvas;
- try {
- var t = {
- alpha: this.alpha,
- depth: this.depth,
- stencil: this.stencil,
- antialias: this.antialias,
- premultipliedAlpha: this.premultipliedAlpha,
- preserveDrawingBuffer: this.preserveDrawingBuffer
- };
- if (this.gl = e.getContext("webgl", t) || e.getContext("experimental-webgl", t),
- !this.gl)
- throw new Error;
- this._glinfo = new v(this.gl),
- this.gl.targetRenderer && console.error("Already created a renderer"),
- this.gl.targetRenderer = this,
- this.resize()
- } catch (e) {
- throw "Error creating WebGL Context " + e
- }
- this._programMgr = new Ee(this),
- this._placeholderTexture = new st(this)
- }
- ), {
- resize: function (e, t) {
- var r = this.canvas
- , i = this.devicePixelRatio;
- null != e ? (r.style && (r.style.width = e + "px",
- r.style.height = t + "px"),
- r.width = e * i,
- r.height = t * i,
- this._width = e,
- this._height = t) : (this._width = r.width / i,
- this._height = r.height / i),
- this.setViewport(0, 0, this._width, this._height)
- },
- getWidth: function () {
- return this._width
- },
- getHeight: function () {
- return this._height
- },
- getViewportAspect: function () {
- var e = this.viewport;
- return e.width / e.height
- },
- setDevicePixelRatio: function (e) {
- this.devicePixelRatio = e,
- this.resize(this._width, this._height)
- },
- getDevicePixelRatio: function () {
- return this.devicePixelRatio
- },
- getGLExtension: function (e) {
- return this._glinfo.getExtension(e)
- },
- getGLParameter: function (e) {
- return this._glinfo.getParameter(e)
- },
- setViewport: function (e, t, r, i, n) {
- if ("object" == typeof e) {
- var a = e;
- e = a.x,
- t = a.y,
- r = a.width,
- i = a.height,
- n = a.devicePixelRatio
- }
- n = n || this.devicePixelRatio,
- this.gl.viewport(e * n, t * n, r * n, i * n),
- this.viewport = {
- x: e,
- y: t,
- width: r,
- height: i,
- devicePixelRatio: n
- }
- },
- saveViewport: function () {
- this._viewportStack.push(this.viewport)
- },
- restoreViewport: function () {
- this._viewportStack.length > 0 && this.setViewport(this._viewportStack.pop())
- },
- saveClear: function () {
- this._clearStack.push({
- clearBit: this.clearBit,
- clearColor: this.clearColor
- })
- },
- restoreClear: function () {
- if (this._clearStack.length > 0) {
- var e = this._clearStack.pop();
- this.clearColor = e.clearColor,
- this.clearBit = e.clearBit
- }
- },
- bindSceneRendering: function (e) {
- this._sceneRendering = e
- },
- render: function (e, t, r, i) {
- var n = this.gl
- , a = this.clearColor;
- if (this.clearBit) {
- n.colorMask(!0, !0, !0, !0),
- n.depthMask(!0);
- var o = this.viewport
- , s = !1
- , l = o.devicePixelRatio;
- (o.width !== this._width || o.height !== this._height || l && l !== this.devicePixelRatio || o.x || o.y) && (s = !0,
- n.enable(n.SCISSOR_TEST),
- n.scissor(o.x * l, o.y * l, o.width * l, o.height * l)),
- n.clearColor(a[0], a[1], a[2], a[3]),
- n.clear(this.clearBit),
- s && n.disable(n.SCISSOR_TEST)
- }
- if (r || e.update(!1),
- e.updateLights(),
- t = t || e.getMainCamera()) {
- t.update();
- var h = e.updateRenderList(t, !0);
- this._sceneRendering = e;
- var u = h.opaque
- , c = h.transparent
- , d = e.material;
- e.trigger("beforerender", this, e, t, h),
- i ? (this.renderPreZ(u, e, t),
- n.depthFunc(n.LEQUAL)) : n.depthFunc(n.LESS);
- for (var f = Je(), p = Qe.create(), m = 0; m < c.length; m++) {
- var g = c[m];
- Ye.multiplyAffine(f, t.viewMatrix.array, g.worldTransform.array),
- Qe.transformMat4(p, g.position.array, f),
- g.__depth = p[2]
- }
- this.renderPass(u, t, {
- getMaterial: function (e) {
- return d || e.material
- },
- sortCompare: this.opaqueSortCompare
- }),
- this.renderPass(c, t, {
- getMaterial: function (e) {
- return d || e.material
- },
- sortCompare: this.transparentSortCompare
- }),
- e.trigger("afterrender", this, e, t, h),
- this._sceneRendering = null
- } else
- console.error("Can't find camera in the scene.")
- },
- getProgram: function (e, t, r) {
- return t = t || e.material,
- this._programMgr.getProgram(e, t, r)
- },
- validateProgram: function (e) {
- if (e.__error) {
- var t = e.__error;
- if ($e[e.__uid__])
- return;
- if ($e[e.__uid__] = !0,
- this.throwError)
- throw new Error(t);
- this.trigger("error", t)
- }
- },
- updatePrograms: function (e, t, r) {
- var i = r && r.getMaterial || et;
- t = t || null;
- for (var n = 0; n < e.length; n++) {
- var a = e[n]
- , o = i.call(this, a);
- if (n > 0) {
- var s = e[n - 1]
- , l = s.joints ? s.joints.length : 0;
- if ((a.joints ? a.joints.length : 0) === l && a.material === s.material && a.lightGroup === s.lightGroup) {
- a.__program = s.__program;
- continue
- }
- }
- var h = this._programMgr.getProgram(a, o, t);
- this.validateProgram(h),
- a.__program = h
- }
- },
- renderPass: function (e, t, r) {
- this.trigger("beforerenderpass", this, e, t, r),
- (r = r || {}).getMaterial = r.getMaterial || et,
- r.getUniform = r.getUniform || tt,
- r.isMaterialChanged = r.isMaterialChanged || rt,
- r.beforeRender = r.beforeRender || nt,
- r.afterRender = r.afterRender || nt;
- var i = r.ifRender || it;
- this.updatePrograms(e, this._sceneRendering, r),
- r.sortCompare && e.sort(r.sortCompare);
- var n = this.viewport
- , a = n.devicePixelRatio
- , o = [n.x * a, n.y * a, n.width * a, n.height * a]
- , s = this.devicePixelRatio
- , l = this.__currentFrameBuffer ? [this.__currentFrameBuffer.getTextureWidth(), this.__currentFrameBuffer.getTextureHeight()] : [this._width * s, this._height * s]
- , h = [o[2], o[3]]
- , u = Date.now();
- t ? (Ye.copy(ht.VIEW, t.viewMatrix.array),
- Ye.copy(ht.PROJECTION, t.projectionMatrix.array),
- Ye.copy(ht.VIEWINVERSE, t.worldTransform.array)) : (Ye.identity(ht.VIEW),
- Ye.identity(ht.PROJECTION),
- Ye.identity(ht.VIEWINVERSE)),
- Ye.multiply(ht.VIEWPROJECTION, ht.PROJECTION, ht.VIEW),
- Ye.invert(ht.PROJECTIONINVERSE, ht.PROJECTION),
- Ye.invert(ht.VIEWPROJECTIONINVERSE, ht.VIEWPROJECTION);
- for (var c, d, f, p, m, g, _, v, y, x, b, w, T = this.gl, S = this._sceneRendering, M = 0; M < e.length; M++) {
- var A, E = e[M], C = null != E.worldTransform;
- if (i(E)) {
- C && (A = E.isSkinnedMesh && E.isSkinnedMesh() ? E.offsetMatrix ? E.offsetMatrix.array : ht.IDENTITY : E.worldTransform.array);
- var D = E.geometry
- , L = r.getMaterial.call(this, E)
- , P = E.__program
- , O = L.shader
- , N = D.__uid__ + "-" + P.__uid__
- , I = N !== x;
- x = N,
- C && (Ye.copy(ht.WORLD, A),
- Ye.multiply(ht.WORLDVIEWPROJECTION, ht.VIEWPROJECTION, A),
- Ye.multiplyAffine(ht.WORLDVIEW, ht.VIEW, A),
- (O.matrixSemantics.WORLDINVERSE || O.matrixSemantics.WORLDINVERSETRANSPOSE) && Ye.invert(ht.WORLDINVERSE, A),
- (O.matrixSemantics.WORLDVIEWINVERSE || O.matrixSemantics.WORLDVIEWINVERSETRANSPOSE) && Ye.invert(ht.WORLDVIEWINVERSE, ht.WORLDVIEW),
- (O.matrixSemantics.WORLDVIEWPROJECTIONINVERSE || O.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE) && Ye.invert(ht.WORLDVIEWPROJECTIONINVERSE, ht.WORLDVIEWPROJECTION)),
- E.beforeRender && E.beforeRender(this),
- r.beforeRender.call(this, E, L, c);
- var R = P !== d;
- R ? (P.bind(this),
- P.setUniformOfSemantic(T, "VIEWPORT", o),
- P.setUniformOfSemantic(T, "WINDOW_SIZE", l),
- t && (P.setUniformOfSemantic(T, "NEAR", t.near),
- P.setUniformOfSemantic(T, "FAR", t.far)),
- P.setUniformOfSemantic(T, "DEVICEPIXELRATIO", a),
- P.setUniformOfSemantic(T, "TIME", u),
- P.setUniformOfSemantic(T, "VIEWPORT_SIZE", h),
- S && S.setLightUniforms(P, E.lightGroup, this)) : P = d,
- (R || r.isMaterialChanged(E, f, L, c)) && (L.depthTest !== p && (L.depthTest ? T.enable(T.DEPTH_TEST) : T.disable(T.DEPTH_TEST),
- p = L.depthTest),
- L.depthMask !== m && (T.depthMask(L.depthMask),
- m = L.depthMask),
- L.transparent !== y && (L.transparent ? T.enable(T.BLEND) : T.disable(T.BLEND),
- y = L.transparent),
- L.transparent && (L.blend ? L.blend(T) : (T.blendEquationSeparate(T.FUNC_ADD, T.FUNC_ADD),
- T.blendFuncSeparate(T.SRC_ALPHA, T.ONE_MINUS_SRC_ALPHA, T.ONE, T.ONE_MINUS_SRC_ALPHA))),
- w = this._bindMaterial(E, L, P, f || null, c || null, d || null, r.getUniform),
- c = L);
- var B = O.matrixSemanticKeys;
- if (C)
- for (var F = 0; F < B.length; F++) {
- var z = B[F]
- , G = O.matrixSemantics[z]
- , U = ht[z];
- if (G.isTranspose) {
- var k = ht[G.semanticNoTranspose];
- Ye.transpose(U, k)
- }
- P.setUniform(T, G.type, G.symbol, U)
- }
- E.cullFace !== _ && (_ = E.cullFace,
- T.cullFace(_)),
- E.frontFace !== v && (v = E.frontFace,
- T.frontFace(v)),
- E.culling !== g && ((g = E.culling) ? T.enable(T.CULL_FACE) : T.disable(T.CULL_FACE)),
- this._updateSkeleton(E, P, w),
- I && (b = this._bindVAO(null, O, D, P)),
- this._renderObject(E, b, P),
- r.afterRender(this, E),
- E.afterRender && E.afterRender(this),
- d = P,
- f = E
- }
- }
- this.trigger("afterrenderpass", this, e, t, r)
- },
- getMaxJointNumber: function () {
- return this.maxJointNumber
- },
- _updateSkeleton: function (e, t, r) {
- var i = this.gl
- , n = e.skeleton;
- if (n)
- if (n.update(),
- e.joints.length > this.getMaxJointNumber()) {
- var a = n.getSubSkinMatricesTexture(e.__uid__, e.joints);
- t.useTextureSlot(this, a, r),
- t.setUniform(i, "1i", "skinMatricesTexture", r),
- t.setUniform(i, "1f", "skinMatricesTextureSize", a.width)
- } else {
- var o = n.getSubSkinMatrices(e.__uid__, e.joints);
- t.setUniformOfSemantic(i, "SKIN_MATRIX", o)
- }
- },
- _renderObject: function (e, t, r) {
- var i = this.gl
- , n = e.geometry
- , a = e.mode;
- null == a && (a = 4);
- var o = null
- , s = e.isInstancedMesh && e.isInstancedMesh();
- if (!s || (o = this.getGLExtension("ANGLE_instanced_arrays"))) {
- var l;
- if (s && (l = this._bindInstancedAttributes(e, r, o)),
- t.indicesBuffer) {
- var h = this.getGLExtension("OES_element_index_uint") && n.indices instanceof Uint32Array ? i.UNSIGNED_INT : i.UNSIGNED_SHORT;
- s ? o.drawElementsInstancedANGLE(a, t.indicesBuffer.count, h, 0, e.getInstanceCount()) : i.drawElements(a, t.indicesBuffer.count, h, 0)
- } else
- s ? o.drawArraysInstancedANGLE(a, 0, n.vertexCount, e.getInstanceCount()) : i.drawArrays(a, 0, n.vertexCount);
- if (s)
- for (var u = 0; u < l.length; u++)
- i.disableVertexAttribArray(l[u])
- } else
- console.warn("Device not support ANGLE_instanced_arrays extension")
- },
- _bindInstancedAttributes: function (e, t, r) {
- for (var i = this.gl, n = e.getInstancedAttributesBuffers(this), a = [], o = 0; o < n.length; o++) {
- var s = n[o]
- , l = t.getAttribLocation(i, s.symbol);
- if (!(l < 0)) {
- var h = at[s.type] || i.FLOAT;
- i.enableVertexAttribArray(l),
- i.bindBuffer(i.ARRAY_BUFFER, s.buffer),
- i.vertexAttribPointer(l, s.size, h, !1, 0, 0),
- r.vertexAttribDivisorANGLE(l, s.divisor),
- a.push(l)
- }
- }
- return a
- },
- _bindMaterial: function (e, t, r, i, n, a, o) {
- for (var s = this.gl, l = a === r, h = r.currentTextureSlot(), u = t.getEnabledUniforms(), c = t.getTextureUniforms(), d = this._placeholderTexture, f = 0; f < c.length; f++) {
- var p = o(e, t, _ = c[f]);
- if ("t" === (g = t.uniforms[_].type) && p)
- p.__slot = -1;
- else if ("tv" === g)
- for (var m = 0; m < p.length; m++)
- p[m] && (p[m].__slot = -1)
- }
- for (d.__slot = -1,
- f = 0; f < u.length; f++) {
- var g, _ = u[f], v = t.uniforms[_], y = (p = o(e, t, _),
- "t" === (g = v.type));
- if (y && (p && p.isRenderable() || (p = d)),
- n && l) {
- var x = o(i, n, _);
- if (y && (x && x.isRenderable() || (x = d)),
- x === p) {
- if (y)
- r.takeCurrentTextureSlot(this, null);
- else if ("tv" === g && p)
- for (m = 0; m < p.length; m++)
- r.takeCurrentTextureSlot(this, null);
- continue
- }
- }
- if (null != p)
- if (y)
- if (p.__slot < 0) {
- var b = r.currentTextureSlot();
- r.setUniform(s, "1i", _, b) && (r.takeCurrentTextureSlot(this, p),
- p.__slot = b)
- } else
- r.setUniform(s, "1i", _, p.__slot);
- else if (Array.isArray(p)) {
- if (0 === p.length)
- continue;
- if ("tv" === g) {
- if (!r.hasUniform(_))
- continue;
- var w = [];
- for (m = 0; m < p.length; m++) {
- var T = p[m];
- T.__slot < 0 ? (b = r.currentTextureSlot(),
- w.push(b),
- r.takeCurrentTextureSlot(this, T),
- T.__slot = b) : w.push(T.__slot)
- }
- r.setUniform(s, "1iv", _, w)
- } else
- r.setUniform(s, v.type, _, p)
- } else
- r.setUniform(s, v.type, _, p)
- }
- var S = r.currentTextureSlot();
- return r.resetTextureSlot(h),
- S
- },
- _bindVAO: function (e, t, r, i) {
- var n = !r.dynamic
- , a = this.gl
- , o = this.__uid__ + "-" + i.__uid__
- , s = r.__vaoCache[o];
- if (!s) {
- var l = r.getBufferChunks(this);
- if (!l || !l.length)
- return;
- for (var h = l[0], u = h.attributeBuffers, c = h.indicesBuffer, d = [], f = [], p = 0; p < u.length; p++) {
- var m, g = (w = u[p]).name, _ = w.semantic;
- if (_) {
- var v = t.attributeSemantics[_];
- m = v && v.symbol
- } else
- m = g;
- m && i.attributes[m] && (d.push(w),
- f.push(m))
- }
- s = new ot(d, f, c),
- n && (r.__vaoCache[o] = s)
- }
- var y = !0;
- if (e && n && (null == s.vao ? s.vao = e.createVertexArrayOES() : y = !1,
- e.bindVertexArrayOES(s.vao)),
- d = s.availableAttributes,
- c = s.indicesBuffer,
- y) {
- var x = i.enableAttributes(this, s.availableAttributeSymbols, e && n && s);
- for (p = 0; p < d.length; p++) {
- var b = x[p];
- if (-1 !== b) {
- var w, T = (w = d[p]).buffer, S = w.size, M = at[w.type] || a.FLOAT;
- a.bindBuffer(a.ARRAY_BUFFER, T),
- a.vertexAttribPointer(b, S, M, !1, 0, 0)
- }
- }
- r.isUseIndices() && a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, c.buffer)
- }
- return s
- },
- renderPreZ: function (e, t, r) {
- var i = this.gl
- , n = this._prezMaterial || new le({
- shader: new Xe(Xe.source("clay.prez.vertex"), Xe.source("clay.prez.fragment"))
- });
- this._prezMaterial = n,
- i.colorMask(!1, !1, !1, !1),
- i.depthMask(!0),
- this.renderPass(e, r, {
- ifRender: function (e) {
- return !e.ignorePreZ
- },
- isMaterialChanged: function (e, t) {
- var r = e.material
- , i = t.material;
- return r.get("diffuseMap") !== i.get("diffuseMap") || (r.get("alphaCutoff") || 0) !== (i.get("alphaCutoff") || 0)
- },
- getUniform: function (e, t, r) {
- return "alphaMap" === r ? e.material.get("diffuseMap") : "alphaCutoff" === r ? e.material.isDefined("fragment", "ALPHA_TEST") && e.material.get("diffuseMap") && e.material.get("alphaCutoff") || 0 : "uvRepeat" === r ? e.material.get("uvRepeat") : "uvOffset" === r ? e.material.get("uvOffset") : t.get(r)
- },
- getMaterial: function () {
- return n
- },
- sort: this.opaqueSortCompare
- }),
- i.colorMask(!0, !0, !0, !0),
- i.depthMask(!0)
- },
- disposeScene: function (e) {
- this.disposeNode(e, !0, !0),
- e.dispose()
- },
- disposeNode: function (e, t, r) {
- e.getParent() && e.getParent().remove(e);
- var i = {};
- e.traverse((function (e) {
- var n = e.material;
- if (e.geometry && t && e.geometry.dispose(this),
- r && n && !i[n.__uid__]) {
- for (var a = n.getTextureUniforms(), o = 0; o < a.length; o++) {
- var s = a[o]
- , l = n.uniforms[s].value
- , h = n.uniforms[s].type;
- if (l)
- if ("t" === h)
- l.dispose && l.dispose(this);
- else if ("tv" === h)
- for (var u = 0; u < l.length; u++)
- l[u] && l[u].dispose && l[u].dispose(this)
- }
- i[n.__uid__] = !0
- }
- e.dispose && e.dispose(this)
- }
- ), this)
- },
- disposeGeometry: function (e) {
- e.dispose(this)
- },
- disposeTexture: function (e) {
- e.dispose(this)
- },
- disposeFrameBuffer: function (e) {
- e.dispose(this)
- },
- dispose: function () { },
- screenToNDC: function (e, t, r) {
- r || (r = new _e),
- t = this._height - t;
- var i = this.viewport
- , n = r.array;
- return n[0] = (e - i.x) / i.width,
- n[0] = 2 * n[0] - 1,
- n[1] = (t - i.y) / i.height,
- n[1] = 2 * n[1] - 1,
- r
- }
- });
- lt.opaqueSortCompare = lt.prototype.opaqueSortCompare = function (e, t) {
- return e.renderOrder === t.renderOrder ? e.__program === t.__program ? e.material === t.material ? e.geometry.__uid__ - t.geometry.__uid__ : e.material.__uid__ - t.material.__uid__ : e.__program && t.__program ? e.__program.__uid__ - t.__program.__uid__ : 0 : e.renderOrder - t.renderOrder
- }
- ,
- lt.transparentSortCompare = lt.prototype.transparentSortCompare = function (e, t) {
- return e.renderOrder === t.renderOrder ? e.__depth === t.__depth ? e.__program === t.__program ? e.material === t.material ? e.geometry.__uid__ - t.geometry.__uid__ : e.material.__uid__ - t.material.__uid__ : e.__program && t.__program ? e.__program.__uid__ - t.__program.__uid__ : 0 : e.__depth - t.__depth : e.renderOrder - t.renderOrder
- }
- ;
- var ht = {
- IDENTITY: Je(),
- WORLD: Je(),
- VIEW: Je(),
- PROJECTION: Je(),
- WORLDVIEW: Je(),
- VIEWPROJECTION: Je(),
- WORLDVIEWPROJECTION: Je(),
- WORLDINVERSE: Je(),
- VIEWINVERSE: Je(),
- PROJECTIONINVERSE: Je(),
- WORLDVIEWINVERSE: Je(),
- VIEWPROJECTIONINVERSE: Je(),
- WORLDVIEWPROJECTIONINVERSE: Je(),
- WORLDTRANSPOSE: Je(),
- VIEWTRANSPOSE: Je(),
- PROJECTIONTRANSPOSE: Je(),
- WORLDVIEWTRANSPOSE: Je(),
- VIEWPROJECTIONTRANSPOSE: Je(),
- WORLDVIEWPROJECTIONTRANSPOSE: Je(),
- WORLDINVERSETRANSPOSE: Je(),
- VIEWINVERSETRANSPOSE: Je(),
- PROJECTIONINVERSETRANSPOSE: Je(),
- WORLDVIEWINVERSETRANSPOSE: Je(),
- VIEWPROJECTIONINVERSETRANSPOSE: Je(),
- WORLDVIEWPROJECTIONINVERSETRANSPOSE: Je()
- };
- lt.COLOR_BUFFER_BIT = 16384,
- lt.DEPTH_BUFFER_BIT = 256,
- lt.STENCIL_BUFFER_BIT = 1024;
- const ut = lt;
- var ct = function (e, t, r) {
- e = e || 0,
- t = t || 0,
- r = r || 0,
- this.array = Qe.fromValues(e, t, r),
- this._dirty = !0
- };
- ct.prototype = {
- constructor: ct,
- add: function (e) {
- return Qe.add(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- set: function (e, t, r) {
- return this.array[0] = e,
- this.array[1] = t,
- this.array[2] = r,
- this._dirty = !0,
- this
- },
- setArray: function (e) {
- return this.array[0] = e[0],
- this.array[1] = e[1],
- this.array[2] = e[2],
- this._dirty = !0,
- this
- },
- clone: function () {
- return new ct(this.x, this.y, this.z)
- },
- copy: function (e) {
- return Qe.copy(this.array, e.array),
- this._dirty = !0,
- this
- },
- cross: function (e, t) {
- return Qe.cross(this.array, e.array, t.array),
- this._dirty = !0,
- this
- },
- dist: function (e) {
- return Qe.dist(this.array, e.array)
- },
- distance: function (e) {
- return Qe.distance(this.array, e.array)
- },
- div: function (e) {
- return Qe.div(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- divide: function (e) {
- return Qe.divide(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- dot: function (e) {
- return Qe.dot(this.array, e.array)
- },
- len: function () {
- return Qe.len(this.array)
- },
- length: function () {
- return Qe.length(this.array)
- },
- lerp: function (e, t, r) {
- return Qe.lerp(this.array, e.array, t.array, r),
- this._dirty = !0,
- this
- },
- min: function (e) {
- return Qe.min(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- max: function (e) {
- return Qe.max(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- mul: function (e) {
- return Qe.mul(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- multiply: function (e) {
- return Qe.multiply(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- negate: function () {
- return Qe.negate(this.array, this.array),
- this._dirty = !0,
- this
- },
- normalize: function () {
- return Qe.normalize(this.array, this.array),
- this._dirty = !0,
- this
- },
- random: function (e) {
- return Qe.random(this.array, e),
- this._dirty = !0,
- this
- },
- scale: function (e) {
- return Qe.scale(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- scaleAndAdd: function (e, t) {
- return Qe.scaleAndAdd(this.array, this.array, e.array, t),
- this._dirty = !0,
- this
- },
- sqrDist: function (e) {
- return Qe.sqrDist(this.array, e.array)
- },
- squaredDistance: function (e) {
- return Qe.squaredDistance(this.array, e.array)
- },
- sqrLen: function () {
- return Qe.sqrLen(this.array)
- },
- squaredLength: function () {
- return Qe.squaredLength(this.array)
- },
- sub: function (e) {
- return Qe.sub(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- subtract: function (e) {
- return Qe.subtract(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformMat3: function (e) {
- return Qe.transformMat3(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformMat4: function (e) {
- return Qe.transformMat4(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformQuat: function (e) {
- return Qe.transformQuat(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- applyProjection: function (e) {
- var t = this.array;
- if (0 === (e = e.array)[15]) {
- var r = -1 / t[2];
- t[0] = e[0] * t[0] * r,
- t[1] = e[5] * t[1] * r,
- t[2] = (e[10] * t[2] + e[14]) * r
- } else
- t[0] = e[0] * t[0] + e[12],
- t[1] = e[5] * t[1] + e[13],
- t[2] = e[10] * t[2] + e[14];
- return this._dirty = !0,
- this
- },
- eulerFromQuat: function (e, t) {
- ct.eulerFromQuat(this, e, t)
- },
- eulerFromMat3: function (e, t) {
- ct.eulerFromMat3(this, e, t)
- },
- toString: function () {
- return "[" + Array.prototype.join.call(this.array, ",") + "]"
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array)
- }
- };
- var dt = Object.defineProperty;
- if (dt) {
- var ft = ct.prototype;
- dt(ft, "x", {
- get: function () {
- return this.array[0]
- },
- set: function (e) {
- this.array[0] = e,
- this._dirty = !0
- }
- }),
- dt(ft, "y", {
- get: function () {
- return this.array[1]
- },
- set: function (e) {
- this.array[1] = e,
- this._dirty = !0
- }
- }),
- dt(ft, "z", {
- get: function () {
- return this.array[2]
- },
- set: function (e) {
- this.array[2] = e,
- this._dirty = !0
- }
- })
- }
- function pt(e, t, r) {
- return e < t ? t : e > r ? r : e
- }
- ct.add = function (e, t, r) {
- return Qe.add(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.set = function (e, t, r, i) {
- Qe.set(e.array, t, r, i),
- e._dirty = !0
- }
- ,
- ct.copy = function (e, t) {
- return Qe.copy(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- ct.cross = function (e, t, r) {
- return Qe.cross(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.distance = ct.dist = function (e, t) {
- return Qe.distance(e.array, t.array)
- }
- ,
- ct.divide = ct.div = function (e, t, r) {
- return Qe.divide(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.dot = function (e, t) {
- return Qe.dot(e.array, t.array)
- }
- ,
- ct.len = function (e) {
- return Qe.length(e.array)
- }
- ,
- ct.lerp = function (e, t, r, i) {
- return Qe.lerp(e.array, t.array, r.array, i),
- e._dirty = !0,
- e
- }
- ,
- ct.min = function (e, t, r) {
- return Qe.min(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.max = function (e, t, r) {
- return Qe.max(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.multiply = ct.mul = function (e, t, r) {
- return Qe.multiply(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.negate = function (e, t) {
- return Qe.negate(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- ct.normalize = function (e, t) {
- return Qe.normalize(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- ct.random = function (e, t) {
- return Qe.random(e.array, t),
- e._dirty = !0,
- e
- }
- ,
- ct.scale = function (e, t, r) {
- return Qe.scale(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- ct.scaleAndAdd = function (e, t, r, i) {
- return Qe.scaleAndAdd(e.array, t.array, r.array, i),
- e._dirty = !0,
- e
- }
- ,
- ct.squaredDistance = ct.sqrDist = function (e, t) {
- return Qe.sqrDist(e.array, t.array)
- }
- ,
- ct.squaredLength = ct.sqrLen = function (e) {
- return Qe.sqrLen(e.array)
- }
- ,
- ct.subtract = ct.sub = function (e, t, r) {
- return Qe.subtract(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.transformMat3 = function (e, t, r) {
- return Qe.transformMat3(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.transformMat4 = function (e, t, r) {
- return Qe.transformMat4(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- ct.transformQuat = function (e, t, r) {
- return Qe.transformQuat(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ;
- var mt = Math.atan2
- , gt = Math.asin
- , _t = Math.abs;
- ct.eulerFromQuat = function (e, t, r) {
- e._dirty = !0,
- t = t.array;
- var i = e.array
- , n = t[0]
- , a = t[1]
- , o = t[2]
- , s = t[3]
- , l = n * n
- , h = a * a
- , u = o * o
- , c = s * s;
- switch (r = (r || "XYZ").toUpperCase()) {
- case "XYZ":
- i[0] = mt(2 * (n * s - a * o), c - l - h + u),
- i[1] = gt(pt(2 * (n * o + a * s), -1, 1)),
- i[2] = mt(2 * (o * s - n * a), c + l - h - u);
- break;
- case "YXZ":
- i[0] = gt(pt(2 * (n * s - a * o), -1, 1)),
- i[1] = mt(2 * (n * o + a * s), c - l - h + u),
- i[2] = mt(2 * (n * a + o * s), c - l + h - u);
- break;
- case "ZXY":
- i[0] = gt(pt(2 * (n * s + a * o), -1, 1)),
- i[1] = mt(2 * (a * s - o * n), c - l - h + u),
- i[2] = mt(2 * (o * s - n * a), c - l + h - u);
- break;
- case "ZYX":
- i[0] = mt(2 * (n * s + o * a), c - l - h + u),
- i[1] = gt(pt(2 * (a * s - n * o), -1, 1)),
- i[2] = mt(2 * (n * a + o * s), c + l - h - u);
- break;
- case "YZX":
- i[0] = mt(2 * (n * s - o * a), c - l + h - u),
- i[1] = mt(2 * (a * s - n * o), c + l - h - u),
- i[2] = gt(pt(2 * (n * a + o * s), -1, 1));
- break;
- case "XZY":
- i[0] = mt(2 * (n * s + a * o), c - l + h - u),
- i[1] = mt(2 * (n * o + a * s), c + l - h - u),
- i[2] = gt(pt(2 * (o * s - n * a), -1, 1));
- break;
- default:
- console.warn("Unkown order: " + r)
- }
- return e
- }
- ,
- ct.eulerFromMat3 = function (e, t, r) {
- var i = t.array
- , n = i[0]
- , a = i[3]
- , o = i[6]
- , s = i[1]
- , l = i[4]
- , h = i[7]
- , u = i[2]
- , c = i[5]
- , d = i[8]
- , f = e.array;
- switch (r = (r || "XYZ").toUpperCase()) {
- case "XYZ":
- f[1] = gt(pt(o, -1, 1)),
- _t(o) < .99999 ? (f[0] = mt(-h, d),
- f[2] = mt(-a, n)) : (f[0] = mt(c, l),
- f[2] = 0);
- break;
- case "YXZ":
- f[0] = gt(-pt(h, -1, 1)),
- _t(h) < .99999 ? (f[1] = mt(o, d),
- f[2] = mt(s, l)) : (f[1] = mt(-u, n),
- f[2] = 0);
- break;
- case "ZXY":
- f[0] = gt(pt(c, -1, 1)),
- _t(c) < .99999 ? (f[1] = mt(-u, d),
- f[2] = mt(-a, l)) : (f[1] = 0,
- f[2] = mt(s, n));
- break;
- case "ZYX":
- f[1] = gt(-pt(u, -1, 1)),
- _t(u) < .99999 ? (f[0] = mt(c, d),
- f[2] = mt(s, n)) : (f[0] = 0,
- f[2] = mt(-a, l));
- break;
- case "YZX":
- f[2] = gt(pt(s, -1, 1)),
- _t(s) < .99999 ? (f[0] = mt(-h, l),
- f[1] = mt(-u, n)) : (f[0] = 0,
- f[1] = mt(o, d));
- break;
- case "XZY":
- f[2] = gt(-pt(a, -1, 1)),
- _t(a) < .99999 ? (f[0] = mt(c, l),
- f[1] = mt(o, n)) : (f[0] = mt(-h, d),
- f[1] = 0);
- break;
- default:
- console.warn("Unkown order: " + r)
- }
- return e._dirty = !0,
- e
- }
- ,
- Object.defineProperties(ct, {
- POSITIVE_X: {
- get: function () {
- return new ct(1, 0, 0)
- }
- },
- NEGATIVE_X: {
- get: function () {
- return new ct(-1, 0, 0)
- }
- },
- POSITIVE_Y: {
- get: function () {
- return new ct(0, 1, 0)
- }
- },
- NEGATIVE_Y: {
- get: function () {
- return new ct(0, -1, 0)
- }
- },
- POSITIVE_Z: {
- get: function () {
- return new ct(0, 0, 1)
- }
- },
- NEGATIVE_Z: {
- get: function () {
- return new ct(0, 0, -1)
- }
- },
- UP: {
- get: function () {
- return new ct(0, 1, 0)
- }
- },
- ZERO: {
- get: function () {
- return new ct
- }
- }
- });
- const vt = ct;
- var yt, xt, bt, wt, Tt, St = function (e, t) {
- this.origin = e || new vt,
- this.direction = t || new vt
- };
- St.prototype = {
- constructor: St,
- intersectPlane: function (e, t) {
- var r = e.normal.array
- , i = e.distance
- , n = this.origin.array
- , a = this.direction.array
- , o = Qe.dot(r, a);
- if (0 === o)
- return null;
- t || (t = new vt);
- var s = (Qe.dot(r, n) - i) / o;
- return Qe.scaleAndAdd(t.array, n, a, -s),
- t._dirty = !0,
- t
- },
- mirrorAgainstPlane: function (e) {
- var t = Qe.dot(e.normal.array, this.direction.array);
- Qe.scaleAndAdd(this.direction.array, this.direction.array, e.normal.array, 2 * -t),
- this.direction._dirty = !0
- },
- distanceToPoint: (Tt = Qe.create(),
- function (e) {
- Qe.sub(Tt, e, this.origin.array);
- var t = Qe.dot(Tt, this.direction.array);
- if (t < 0)
- return Qe.distance(this.origin.array, e);
- var r = Qe.lenSquared(Tt);
- return Math.sqrt(r - t * t)
- }
- ),
- intersectSphere: function () {
- var e = Qe.create();
- return function (t, r, i) {
- var n = this.origin.array
- , a = this.direction.array;
- t = t.array,
- Qe.sub(e, t, n);
- var o = Qe.dot(e, a)
- , s = Qe.squaredLength(e) - o * o
- , l = r * r;
- if (!(s > l)) {
- var h = Math.sqrt(l - s)
- , u = o - h
- , c = o + h;
- return i || (i = new vt),
- u < 0 ? c < 0 ? null : (Qe.scaleAndAdd(i.array, n, a, c),
- i) : (Qe.scaleAndAdd(i.array, n, a, u),
- i)
- }
- }
- }(),
- intersectBoundingBox: function (e, t) {
- var r, i, n, a, o, s, l = this.direction.array, h = this.origin.array, u = e.min.array, c = e.max.array, d = 1 / l[0], f = 1 / l[1], p = 1 / l[2];
- if (d >= 0 ? (r = (u[0] - h[0]) * d,
- i = (c[0] - h[0]) * d) : (i = (u[0] - h[0]) * d,
- r = (c[0] - h[0]) * d),
- f >= 0 ? (n = (u[1] - h[1]) * f,
- a = (c[1] - h[1]) * f) : (a = (u[1] - h[1]) * f,
- n = (c[1] - h[1]) * f),
- r > a || n > i)
- return null;
- if ((n > r || r != r) && (r = n),
- (a < i || i != i) && (i = a),
- p >= 0 ? (o = (u[2] - h[2]) * p,
- s = (c[2] - h[2]) * p) : (s = (u[2] - h[2]) * p,
- o = (c[2] - h[2]) * p),
- r > s || o > i)
- return null;
- if ((o > r || r != r) && (r = o),
- (s < i || i != i) && (i = s),
- i < 0)
- return null;
- var m = r >= 0 ? r : i;
- return t || (t = new vt),
- Qe.scaleAndAdd(t.array, h, l, m),
- t
- },
- intersectTriangle: (yt = Qe.create(),
- xt = Qe.create(),
- bt = Qe.create(),
- wt = Qe.create(),
- function (e, t, r, i, n, a) {
- var o = this.direction.array
- , s = this.origin.array;
- e = e.array,
- t = t.array,
- r = r.array,
- Qe.sub(yt, t, e),
- Qe.sub(xt, r, e),
- Qe.cross(wt, xt, o);
- var l = Qe.dot(yt, wt);
- if (i) {
- if (l > -1e-5)
- return null
- } else if (l > -1e-5 && l < 1e-5)
- return null;
- Qe.sub(bt, s, e);
- var h = Qe.dot(wt, bt) / l;
- if (h < 0 || h > 1)
- return null;
- Qe.cross(wt, yt, bt);
- var u = Qe.dot(o, wt) / l;
- if (u < 0 || u > 1 || h + u > 1)
- return null;
- Qe.cross(wt, yt, xt);
- var c = -Qe.dot(bt, wt) / l;
- return c < 0 ? null : (n || (n = new vt),
- a && vt.set(a, 1 - h - u, h, u),
- Qe.scaleAndAdd(n.array, s, o, c),
- n)
- }
- ),
- applyTransform: function (e) {
- vt.add(this.direction, this.direction, this.origin),
- vt.transformMat4(this.origin, this.origin, e),
- vt.transformMat4(this.direction, this.direction, e),
- vt.sub(this.direction, this.direction, this.origin),
- vt.normalize(this.direction, this.direction)
- },
- copy: function (e) {
- vt.copy(this.origin, e.origin),
- vt.copy(this.direction, e.direction)
- },
- clone: function () {
- var e = new St;
- return e.copy(this),
- e
- }
- };
- const Mt = St;
- var At = {
- create: function () {
- var e = new ce(4);
- return e[0] = 0,
- e[1] = 0,
- e[2] = 0,
- e[3] = 0,
- e
- },
- clone: function (e) {
- var t = new ce(4);
- return t[0] = e[0],
- t[1] = e[1],
- t[2] = e[2],
- t[3] = e[3],
- t
- },
- fromValues: function (e, t, r, i) {
- var n = new ce(4);
- return n[0] = e,
- n[1] = t,
- n[2] = r,
- n[3] = i,
- n
- },
- copy: function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e
- },
- set: function (e, t, r, i, n) {
- return e[0] = t,
- e[1] = r,
- e[2] = i,
- e[3] = n,
- e
- },
- add: function (e, t, r) {
- return e[0] = t[0] + r[0],
- e[1] = t[1] + r[1],
- e[2] = t[2] + r[2],
- e[3] = t[3] + r[3],
- e
- },
- subtract: function (e, t, r) {
- return e[0] = t[0] - r[0],
- e[1] = t[1] - r[1],
- e[2] = t[2] - r[2],
- e[3] = t[3] - r[3],
- e
- }
- };
- At.sub = At.subtract,
- At.multiply = function (e, t, r) {
- return e[0] = t[0] * r[0],
- e[1] = t[1] * r[1],
- e[2] = t[2] * r[2],
- e[3] = t[3] * r[3],
- e
- }
- ,
- At.mul = At.multiply,
- At.divide = function (e, t, r) {
- return e[0] = t[0] / r[0],
- e[1] = t[1] / r[1],
- e[2] = t[2] / r[2],
- e[3] = t[3] / r[3],
- e
- }
- ,
- At.div = At.divide,
- At.min = function (e, t, r) {
- return e[0] = Math.min(t[0], r[0]),
- e[1] = Math.min(t[1], r[1]),
- e[2] = Math.min(t[2], r[2]),
- e[3] = Math.min(t[3], r[3]),
- e
- }
- ,
- At.max = function (e, t, r) {
- return e[0] = Math.max(t[0], r[0]),
- e[1] = Math.max(t[1], r[1]),
- e[2] = Math.max(t[2], r[2]),
- e[3] = Math.max(t[3], r[3]),
- e
- }
- ,
- At.scale = function (e, t, r) {
- return e[0] = t[0] * r,
- e[1] = t[1] * r,
- e[2] = t[2] * r,
- e[3] = t[3] * r,
- e
- }
- ,
- At.scaleAndAdd = function (e, t, r, i) {
- return e[0] = t[0] + r[0] * i,
- e[1] = t[1] + r[1] * i,
- e[2] = t[2] + r[2] * i,
- e[3] = t[3] + r[3] * i,
- e
- }
- ,
- At.distance = function (e, t) {
- var r = t[0] - e[0]
- , i = t[1] - e[1]
- , n = t[2] - e[2]
- , a = t[3] - e[3];
- return Math.sqrt(r * r + i * i + n * n + a * a)
- }
- ,
- At.dist = At.distance,
- At.squaredDistance = function (e, t) {
- var r = t[0] - e[0]
- , i = t[1] - e[1]
- , n = t[2] - e[2]
- , a = t[3] - e[3];
- return r * r + i * i + n * n + a * a
- }
- ,
- At.sqrDist = At.squaredDistance,
- At.length = function (e) {
- var t = e[0]
- , r = e[1]
- , i = e[2]
- , n = e[3];
- return Math.sqrt(t * t + r * r + i * i + n * n)
- }
- ,
- At.len = At.length,
- At.squaredLength = function (e) {
- var t = e[0]
- , r = e[1]
- , i = e[2]
- , n = e[3];
- return t * t + r * r + i * i + n * n
- }
- ,
- At.sqrLen = At.squaredLength,
- At.negate = function (e, t) {
- return e[0] = -t[0],
- e[1] = -t[1],
- e[2] = -t[2],
- e[3] = -t[3],
- e
- }
- ,
- At.inverse = function (e, t) {
- return e[0] = 1 / t[0],
- e[1] = 1 / t[1],
- e[2] = 1 / t[2],
- e[3] = 1 / t[3],
- e
- }
- ,
- At.normalize = function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = r * r + i * i + n * n + a * a;
- return o > 0 && (o = 1 / Math.sqrt(o),
- e[0] = t[0] * o,
- e[1] = t[1] * o,
- e[2] = t[2] * o,
- e[3] = t[3] * o),
- e
- }
- ,
- At.dot = function (e, t) {
- return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3]
- }
- ,
- At.lerp = function (e, t, r, i) {
- var n = t[0]
- , a = t[1]
- , o = t[2]
- , s = t[3];
- return e[0] = n + i * (r[0] - n),
- e[1] = a + i * (r[1] - a),
- e[2] = o + i * (r[2] - o),
- e[3] = s + i * (r[3] - s),
- e
- }
- ,
- At.random = function (e, t) {
- return t = t || 1,
- e[0] = de(),
- e[1] = de(),
- e[2] = de(),
- e[3] = de(),
- At.normalize(e, e),
- At.scale(e, e, t),
- e
- }
- ,
- At.transformMat4 = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3];
- return e[0] = r[0] * i + r[4] * n + r[8] * a + r[12] * o,
- e[1] = r[1] * i + r[5] * n + r[9] * a + r[13] * o,
- e[2] = r[2] * i + r[6] * n + r[10] * a + r[14] * o,
- e[3] = r[3] * i + r[7] * n + r[11] * a + r[15] * o,
- e
- }
- ,
- At.transformQuat = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = r[0]
- , s = r[1]
- , l = r[2]
- , h = r[3]
- , u = h * i + s * a - l * n
- , c = h * n + l * i - o * a
- , d = h * a + o * n - s * i
- , f = -o * i - s * n - l * a;
- return e[0] = u * h + f * -o + c * -l - d * -s,
- e[1] = c * h + f * -s + d * -o - u * -l,
- e[2] = d * h + f * -l + u * -s - c * -o,
- e
- }
- ,
- At.forEach = function () {
- var e = At.create();
- return function (t, r, i, n, a, o) {
- var s, l;
- for (r || (r = 4),
- i || (i = 0),
- l = n ? Math.min(n * r + i, t.length) : t.length,
- s = i; s < l; s += r)
- e[0] = t[s],
- e[1] = t[s + 1],
- e[2] = t[s + 2],
- e[3] = t[s + 3],
- a(e, e, o),
- t[s] = e[0],
- t[s + 1] = e[1],
- t[s + 2] = e[2],
- t[s + 3] = e[3];
- return t
- }
- }();
- const Et = At;
- var Ct = {
- create: function () {
- var e = new ce(9);
- return e[0] = 1,
- e[1] = 0,
- e[2] = 0,
- e[3] = 0,
- e[4] = 1,
- e[5] = 0,
- e[6] = 0,
- e[7] = 0,
- e[8] = 1,
- e
- },
- fromMat4: function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[4],
- e[4] = t[5],
- e[5] = t[6],
- e[6] = t[8],
- e[7] = t[9],
- e[8] = t[10],
- e
- },
- clone: function (e) {
- var t = new ce(9);
- return t[0] = e[0],
- t[1] = e[1],
- t[2] = e[2],
- t[3] = e[3],
- t[4] = e[4],
- t[5] = e[5],
- t[6] = e[6],
- t[7] = e[7],
- t[8] = e[8],
- t
- },
- copy: function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e[4] = t[4],
- e[5] = t[5],
- e[6] = t[6],
- e[7] = t[7],
- e[8] = t[8],
- e
- },
- identity: function (e) {
- return e[0] = 1,
- e[1] = 0,
- e[2] = 0,
- e[3] = 0,
- e[4] = 1,
- e[5] = 0,
- e[6] = 0,
- e[7] = 0,
- e[8] = 1,
- e
- },
- transpose: function (e, t) {
- if (e === t) {
- var r = t[1]
- , i = t[2]
- , n = t[5];
- e[1] = t[3],
- e[2] = t[6],
- e[3] = r,
- e[5] = t[7],
- e[6] = i,
- e[7] = n
- } else
- 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];
- return e
- },
- invert: function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = t[4]
- , s = t[5]
- , l = t[6]
- , h = t[7]
- , u = t[8]
- , c = u * o - s * h
- , d = -u * a + s * l
- , f = h * a - o * l
- , p = r * c + i * d + n * f;
- return p ? (p = 1 / p,
- e[0] = c * p,
- e[1] = (-u * i + n * h) * p,
- e[2] = (s * i - n * o) * p,
- e[3] = d * p,
- e[4] = (u * r - n * l) * p,
- e[5] = (-s * r + n * a) * p,
- e[6] = f * p,
- e[7] = (-h * r + i * l) * p,
- e[8] = (o * r - i * a) * p,
- e) : null
- },
- adjoint: function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = t[4]
- , s = t[5]
- , l = t[6]
- , h = t[7]
- , u = t[8];
- return e[0] = o * u - s * h,
- e[1] = n * h - i * u,
- e[2] = i * s - n * o,
- e[3] = s * l - a * u,
- e[4] = r * u - n * l,
- e[5] = n * a - r * s,
- e[6] = a * h - o * l,
- e[7] = i * l - r * h,
- e[8] = r * o - i * a,
- e
- },
- determinant: function (e) {
- var t = e[0]
- , r = e[1]
- , i = e[2]
- , n = e[3]
- , a = e[4]
- , o = e[5]
- , s = e[6]
- , l = e[7]
- , h = e[8];
- return t * (h * a - o * l) + r * (-h * n + o * s) + i * (l * n - a * s)
- },
- multiply: function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = t[4]
- , l = t[5]
- , h = t[6]
- , u = t[7]
- , c = t[8]
- , d = r[0]
- , f = r[1]
- , p = r[2]
- , m = r[3]
- , g = r[4]
- , _ = r[5]
- , v = r[6]
- , y = r[7]
- , x = r[8];
- return e[0] = d * i + f * o + p * h,
- e[1] = d * n + f * s + p * u,
- e[2] = d * a + f * l + p * c,
- e[3] = m * i + g * o + _ * h,
- e[4] = m * n + g * s + _ * u,
- e[5] = m * a + g * l + _ * c,
- e[6] = v * i + y * o + x * h,
- e[7] = v * n + y * s + x * u,
- e[8] = v * a + y * l + x * c,
- e
- }
- };
- Ct.mul = Ct.multiply,
- Ct.translate = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = t[4]
- , l = t[5]
- , h = t[6]
- , u = t[7]
- , c = t[8]
- , d = r[0]
- , f = r[1];
- return e[0] = i,
- e[1] = n,
- e[2] = a,
- e[3] = o,
- e[4] = s,
- e[5] = l,
- e[6] = d * i + f * o + h,
- e[7] = d * n + f * s + u,
- e[8] = d * a + f * l + c,
- e
- }
- ,
- Ct.rotate = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = t[4]
- , l = t[5]
- , h = t[6]
- , u = t[7]
- , c = t[8]
- , d = Math.sin(r)
- , f = Math.cos(r);
- return e[0] = f * i + d * o,
- e[1] = f * n + d * s,
- e[2] = f * a + d * l,
- e[3] = f * o - d * i,
- e[4] = f * s - d * n,
- e[5] = f * l - d * a,
- e[6] = h,
- e[7] = u,
- e[8] = c,
- e
- }
- ,
- Ct.scale = function (e, t, r) {
- var i = r[0]
- , n = r[1];
- return e[0] = i * t[0],
- e[1] = i * t[1],
- e[2] = i * t[2],
- e[3] = n * t[3],
- e[4] = n * t[4],
- e[5] = n * t[5],
- e[6] = t[6],
- e[7] = t[7],
- e[8] = t[8],
- e
- }
- ,
- Ct.fromMat2d = function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = 0,
- e[3] = t[2],
- e[4] = t[3],
- e[5] = 0,
- e[6] = t[4],
- e[7] = t[5],
- e[8] = 1,
- e
- }
- ,
- Ct.fromQuat = function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = r + r
- , s = i + i
- , l = n + n
- , h = r * o
- , u = i * o
- , c = i * s
- , d = n * o
- , f = n * s
- , p = n * l
- , m = a * o
- , g = a * s
- , _ = a * l;
- return e[0] = 1 - c - p,
- e[3] = u - _,
- e[6] = d + g,
- e[1] = u + _,
- e[4] = 1 - h - p,
- e[7] = f - m,
- e[2] = d - g,
- e[5] = f + m,
- e[8] = 1 - h - c,
- e
- }
- ,
- Ct.normalFromMat4 = function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = t[4]
- , s = t[5]
- , l = t[6]
- , h = t[7]
- , u = t[8]
- , c = t[9]
- , d = t[10]
- , f = t[11]
- , p = t[12]
- , m = t[13]
- , g = t[14]
- , _ = t[15]
- , v = r * s - i * o
- , y = r * l - n * o
- , x = r * h - a * o
- , b = i * l - n * s
- , w = i * h - a * s
- , T = n * h - a * l
- , S = u * m - c * p
- , M = u * g - d * p
- , A = u * _ - f * p
- , E = c * g - d * m
- , C = c * _ - f * m
- , D = d * _ - f * g
- , L = v * D - y * C + x * E + b * A - w * M + T * S;
- return L ? (L = 1 / L,
- e[0] = (s * D - l * C + h * E) * L,
- e[1] = (l * A - o * D - h * M) * L,
- e[2] = (o * C - s * A + h * S) * L,
- e[3] = (n * C - i * D - a * E) * L,
- e[4] = (r * D - n * A + a * M) * L,
- e[5] = (i * A - r * C - a * S) * L,
- e[6] = (m * T - g * w + _ * b) * L,
- e[7] = (g * x - p * T - _ * y) * L,
- e[8] = (p * w - m * x + _ * v) * L,
- e) : null
- }
- ,
- Ct.frob = function (e) {
- return Math.sqrt(Math.pow(e[0], 2) + Math.pow(e[1], 2) + Math.pow(e[2], 2) + Math.pow(e[3], 2) + Math.pow(e[4], 2) + Math.pow(e[5], 2) + Math.pow(e[6], 2) + Math.pow(e[7], 2) + Math.pow(e[8], 2))
- }
- ;
- const Dt = Ct;
- var Lt, Pt, Ot, Nt, It = {
- create: function () {
- var e = new ce(4);
- return e[0] = 0,
- e[1] = 0,
- e[2] = 0,
- e[3] = 1,
- e
- }
- };
- It.rotationTo = (Lt = Qe.create(),
- Pt = Qe.fromValues(1, 0, 0),
- Ot = Qe.fromValues(0, 1, 0),
- function (e, t, r) {
- var i = Qe.dot(t, r);
- return i < -.999999 ? (Qe.cross(Lt, Pt, t),
- Qe.length(Lt) < 1e-6 && Qe.cross(Lt, Ot, t),
- Qe.normalize(Lt, Lt),
- It.setAxisAngle(e, Lt, Math.PI),
- e) : i > .999999 ? (e[0] = 0,
- e[1] = 0,
- e[2] = 0,
- e[3] = 1,
- e) : (Qe.cross(Lt, t, r),
- e[0] = Lt[0],
- e[1] = Lt[1],
- e[2] = Lt[2],
- e[3] = 1 + i,
- It.normalize(e, e))
- }
- ),
- It.setAxes = (Nt = Dt.create(),
- function (e, t, r, i) {
- return Nt[0] = r[0],
- Nt[3] = r[1],
- Nt[6] = r[2],
- Nt[1] = i[0],
- Nt[4] = i[1],
- Nt[7] = i[2],
- Nt[2] = -t[0],
- Nt[5] = -t[1],
- Nt[8] = -t[2],
- It.normalize(e, It.fromMat3(e, Nt))
- }
- ),
- It.clone = Et.clone,
- It.fromValues = Et.fromValues,
- It.copy = Et.copy,
- It.set = Et.set,
- It.identity = function (e) {
- return e[0] = 0,
- e[1] = 0,
- e[2] = 0,
- e[3] = 1,
- e
- }
- ,
- It.setAxisAngle = function (e, t, r) {
- r *= .5;
- var i = Math.sin(r);
- return e[0] = i * t[0],
- e[1] = i * t[1],
- e[2] = i * t[2],
- e[3] = Math.cos(r),
- e
- }
- ,
- It.add = Et.add,
- It.multiply = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = r[0]
- , l = r[1]
- , h = r[2]
- , u = r[3];
- return e[0] = i * u + o * s + n * h - a * l,
- e[1] = n * u + o * l + a * s - i * h,
- e[2] = a * u + o * h + i * l - n * s,
- e[3] = o * u - i * s - n * l - a * h,
- e
- }
- ,
- It.mul = It.multiply,
- It.scale = Et.scale,
- It.rotateX = function (e, t, r) {
- r *= .5;
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = Math.sin(r)
- , l = Math.cos(r);
- return e[0] = i * l + o * s,
- e[1] = n * l + a * s,
- e[2] = a * l - n * s,
- e[3] = o * l - i * s,
- e
- }
- ,
- It.rotateY = function (e, t, r) {
- r *= .5;
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = Math.sin(r)
- , l = Math.cos(r);
- return e[0] = i * l - a * s,
- e[1] = n * l + o * s,
- e[2] = a * l + i * s,
- e[3] = o * l - n * s,
- e
- }
- ,
- It.rotateZ = function (e, t, r) {
- r *= .5;
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = Math.sin(r)
- , l = Math.cos(r);
- return e[0] = i * l + n * s,
- e[1] = n * l - i * s,
- e[2] = a * l + o * s,
- e[3] = o * l - a * s,
- e
- }
- ,
- It.calculateW = function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2];
- return e[0] = r,
- e[1] = i,
- e[2] = n,
- e[3] = Math.sqrt(Math.abs(1 - r * r - i * i - n * n)),
- e
- }
- ,
- It.dot = Et.dot,
- It.lerp = Et.lerp,
- It.slerp = function (e, t, r, i) {
- var n, a, o, s, l, h = t[0], u = t[1], c = t[2], d = t[3], f = r[0], p = r[1], m = r[2], g = r[3];
- return (a = h * f + u * p + c * m + d * g) < 0 && (a = -a,
- f = -f,
- p = -p,
- m = -m,
- g = -g),
- 1 - a > 1e-6 ? (n = Math.acos(a),
- o = Math.sin(n),
- s = Math.sin((1 - i) * n) / o,
- l = Math.sin(i * n) / o) : (s = 1 - i,
- l = i),
- e[0] = s * h + l * f,
- e[1] = s * u + l * p,
- e[2] = s * c + l * m,
- e[3] = s * d + l * g,
- e
- }
- ,
- It.invert = function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = r * r + i * i + n * n + a * a
- , s = o ? 1 / o : 0;
- return e[0] = -r * s,
- e[1] = -i * s,
- e[2] = -n * s,
- e[3] = a * s,
- e
- }
- ,
- It.conjugate = function (e, t) {
- return e[0] = -t[0],
- e[1] = -t[1],
- e[2] = -t[2],
- e[3] = t[3],
- e
- }
- ,
- It.length = Et.length,
- It.len = It.length,
- It.squaredLength = Et.squaredLength,
- It.sqrLen = It.squaredLength,
- It.normalize = Et.normalize,
- It.fromMat3 = function (e, t) {
- var r, i = t[0] + t[4] + t[8];
- if (i > 0)
- r = Math.sqrt(i + 1),
- e[3] = .5 * r,
- r = .5 / r,
- e[0] = (t[5] - t[7]) * r,
- e[1] = (t[6] - t[2]) * r,
- e[2] = (t[1] - t[3]) * r;
- else {
- var n = 0;
- t[4] > t[0] && (n = 1),
- t[8] > t[3 * n + n] && (n = 2);
- var a = (n + 1) % 3
- , o = (n + 2) % 3;
- r = Math.sqrt(t[3 * n + n] - t[3 * a + a] - t[3 * o + o] + 1),
- e[n] = .5 * r,
- r = .5 / r,
- e[3] = (t[3 * a + o] - t[3 * o + a]) * r,
- e[a] = (t[3 * a + n] + t[3 * n + a]) * r,
- e[o] = (t[3 * o + n] + t[3 * n + o]) * r
- }
- return e
- }
- ;
- const Rt = It;
- var Bt, Ft, zt, Gt, Ut = function () {
- this._axisX = new vt,
- this._axisY = new vt,
- this._axisZ = new vt,
- this.array = Ye.create(),
- this._dirty = !0
- };
- Ut.prototype = {
- constructor: Ut,
- setArray: function (e) {
- for (var t = 0; t < this.array.length; t++)
- this.array[t] = e[t];
- return this._dirty = !0,
- this
- },
- adjoint: function () {
- return Ye.adjoint(this.array, this.array),
- this._dirty = !0,
- this
- },
- clone: function () {
- return (new Ut).copy(this)
- },
- copy: function (e) {
- return Ye.copy(this.array, e.array),
- this._dirty = !0,
- this
- },
- determinant: function () {
- return Ye.determinant(this.array)
- },
- fromQuat: function (e) {
- return Ye.fromQuat(this.array, e.array),
- this._dirty = !0,
- this
- },
- fromRotationTranslation: function (e, t) {
- return Ye.fromRotationTranslation(this.array, e.array, t.array),
- this._dirty = !0,
- this
- },
- fromMat2d: function (e) {
- return Ut.fromMat2d(this, e),
- this
- },
- frustum: function (e, t, r, i, n, a) {
- return Ye.frustum(this.array, e, t, r, i, n, a),
- this._dirty = !0,
- this
- },
- identity: function () {
- return Ye.identity(this.array),
- this._dirty = !0,
- this
- },
- invert: function () {
- return Ye.invert(this.array, this.array),
- this._dirty = !0,
- this
- },
- lookAt: function (e, t, r) {
- return Ye.lookAt(this.array, e.array, t.array, r.array),
- this._dirty = !0,
- this
- },
- mul: function (e) {
- return Ye.mul(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- mulLeft: function (e) {
- return Ye.mul(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- multiply: function (e) {
- return Ye.multiply(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- multiplyLeft: function (e) {
- return Ye.multiply(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- ortho: function (e, t, r, i, n, a) {
- return Ye.ortho(this.array, e, t, r, i, n, a),
- this._dirty = !0,
- this
- },
- perspective: function (e, t, r, i) {
- return Ye.perspective(this.array, e, t, r, i),
- this._dirty = !0,
- this
- },
- rotate: function (e, t) {
- return Ye.rotate(this.array, this.array, e, t.array),
- this._dirty = !0,
- this
- },
- rotateX: function (e) {
- return Ye.rotateX(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- rotateY: function (e) {
- return Ye.rotateY(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- rotateZ: function (e) {
- return Ye.rotateZ(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- scale: function (e) {
- return Ye.scale(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- translate: function (e) {
- return Ye.translate(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transpose: function () {
- return Ye.transpose(this.array, this.array),
- this._dirty = !0,
- this
- },
- decomposeMatrix: (Bt = Qe.create(),
- Ft = Qe.create(),
- zt = Qe.create(),
- Gt = Dt.create(),
- function (e, t, r) {
- var i = this.array;
- Qe.set(Bt, i[0], i[1], i[2]),
- Qe.set(Ft, i[4], i[5], i[6]),
- Qe.set(zt, i[8], i[9], i[10]);
- var n = Qe.length(Bt)
- , a = Qe.length(Ft)
- , o = Qe.length(zt);
- this.determinant() < 0 && (n = -n),
- e && e.set(n, a, o),
- r.set(i[12], i[13], i[14]),
- Dt.fromMat4(Gt, i),
- Gt[0] /= n,
- Gt[1] /= n,
- Gt[2] /= n,
- Gt[3] /= a,
- Gt[4] /= a,
- Gt[5] /= a,
- Gt[6] /= o,
- Gt[7] /= o,
- Gt[8] /= o,
- Rt.fromMat3(t.array, Gt),
- Rt.normalize(t.array, t.array),
- t._dirty = !0,
- r._dirty = !0
- }
- ),
- toString: function () {
- return "[" + Array.prototype.join.call(this.array, ",") + "]"
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array)
- }
- };
- var kt = Object.defineProperty;
- if (kt) {
- var Vt = Ut.prototype;
- kt(Vt, "z", {
- get: function () {
- var e = this.array;
- return this._axisZ.set(e[8], e[9], e[10]),
- this._axisZ
- },
- set: function (e) {
- var t = this.array;
- e = e.array,
- t[8] = e[0],
- t[9] = e[1],
- t[10] = e[2],
- this._dirty = !0
- }
- }),
- kt(Vt, "y", {
- get: function () {
- var e = this.array;
- return this._axisY.set(e[4], e[5], e[6]),
- this._axisY
- },
- set: function (e) {
- var t = this.array;
- e = e.array,
- t[4] = e[0],
- t[5] = e[1],
- t[6] = e[2],
- this._dirty = !0
- }
- }),
- kt(Vt, "x", {
- get: function () {
- var e = this.array;
- return this._axisX.set(e[0], e[1], e[2]),
- this._axisX
- },
- set: function (e) {
- var t = this.array;
- e = e.array,
- t[0] = e[0],
- t[1] = e[1],
- t[2] = e[2],
- this._dirty = !0
- }
- })
- }
- Ut.adjoint = function (e, t) {
- return Ye.adjoint(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.copy = function (e, t) {
- return Ye.copy(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.determinant = function (e) {
- return Ye.determinant(e.array)
- }
- ,
- Ut.identity = function (e) {
- return Ye.identity(e.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.ortho = function (e, t, r, i, n, a, o) {
- return Ye.ortho(e.array, t, r, i, n, a, o),
- e._dirty = !0,
- e
- }
- ,
- Ut.perspective = function (e, t, r, i, n) {
- return Ye.perspective(e.array, t, r, i, n),
- e._dirty = !0,
- e
- }
- ,
- Ut.lookAt = function (e, t, r, i) {
- return Ye.lookAt(e.array, t.array, r.array, i.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.invert = function (e, t) {
- return Ye.invert(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.multiply = Ut.mul = function (e, t, r) {
- return Ye.mul(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.fromQuat = function (e, t) {
- return Ye.fromQuat(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.fromRotationTranslation = function (e, t, r) {
- return Ye.fromRotationTranslation(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.fromMat2d = function (e, t) {
- return e._dirty = !0,
- t = t.array,
- (e = e.array)[0] = t[0],
- e[4] = t[2],
- e[12] = t[4],
- e[1] = t[1],
- e[5] = t[3],
- e[13] = t[5],
- e
- }
- ,
- Ut.rotate = function (e, t, r, i) {
- return Ye.rotate(e.array, t.array, r, i.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.rotateX = function (e, t, r) {
- return Ye.rotateX(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Ut.rotateY = function (e, t, r) {
- return Ye.rotateY(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Ut.rotateZ = function (e, t, r) {
- return Ye.rotateZ(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Ut.scale = function (e, t, r) {
- return Ye.scale(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.transpose = function (e, t) {
- return Ye.transpose(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Ut.translate = function (e, t, r) {
- return Ye.translate(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ;
- const Ht = Ut;
- var Wt = function (e, t, r, i) {
- e = e || 0,
- t = t || 0,
- r = r || 0,
- i = void 0 === i ? 1 : i,
- this.array = Rt.fromValues(e, t, r, i),
- this._dirty = !0
- };
- Wt.prototype = {
- constructor: Wt,
- add: function (e) {
- return Rt.add(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- calculateW: function () {
- return Rt.calculateW(this.array, this.array),
- this._dirty = !0,
- this
- },
- set: function (e, t, r, i) {
- return this.array[0] = e,
- this.array[1] = t,
- this.array[2] = r,
- this.array[3] = i,
- this._dirty = !0,
- this
- },
- setArray: function (e) {
- return this.array[0] = e[0],
- this.array[1] = e[1],
- this.array[2] = e[2],
- this.array[3] = e[3],
- this._dirty = !0,
- this
- },
- clone: function () {
- return new Wt(this.x, this.y, this.z, this.w)
- },
- conjugate: function () {
- return Rt.conjugate(this.array, this.array),
- this._dirty = !0,
- this
- },
- copy: function (e) {
- return Rt.copy(this.array, e.array),
- this._dirty = !0,
- this
- },
- dot: function (e) {
- return Rt.dot(this.array, e.array)
- },
- fromMat3: function (e) {
- return Rt.fromMat3(this.array, e.array),
- this._dirty = !0,
- this
- },
- fromMat4: function () {
- var e = Dt.create();
- return function (t) {
- return Dt.fromMat4(e, t.array),
- Dt.transpose(e, e),
- Rt.fromMat3(this.array, e),
- this._dirty = !0,
- this
- }
- }(),
- identity: function () {
- return Rt.identity(this.array),
- this._dirty = !0,
- this
- },
- invert: function () {
- return Rt.invert(this.array, this.array),
- this._dirty = !0,
- this
- },
- len: function () {
- return Rt.len(this.array)
- },
- length: function () {
- return Rt.length(this.array)
- },
- lerp: function (e, t, r) {
- return Rt.lerp(this.array, e.array, t.array, r),
- this._dirty = !0,
- this
- },
- mul: function (e) {
- return Rt.mul(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- mulLeft: function (e) {
- return Rt.multiply(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- multiply: function (e) {
- return Rt.multiply(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- multiplyLeft: function (e) {
- return Rt.multiply(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- normalize: function () {
- return Rt.normalize(this.array, this.array),
- this._dirty = !0,
- this
- },
- rotateX: function (e) {
- return Rt.rotateX(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- rotateY: function (e) {
- return Rt.rotateY(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- rotateZ: function (e) {
- return Rt.rotateZ(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- rotationTo: function (e, t) {
- return Rt.rotationTo(this.array, e.array, t.array),
- this._dirty = !0,
- this
- },
- setAxes: function (e, t, r) {
- return Rt.setAxes(this.array, e.array, t.array, r.array),
- this._dirty = !0,
- this
- },
- setAxisAngle: function (e, t) {
- return Rt.setAxisAngle(this.array, e.array, t),
- this._dirty = !0,
- this
- },
- slerp: function (e, t, r) {
- return Rt.slerp(this.array, e.array, t.array, r),
- this._dirty = !0,
- this
- },
- sqrLen: function () {
- return Rt.sqrLen(this.array)
- },
- squaredLength: function () {
- return Rt.squaredLength(this.array)
- },
- fromEuler: function (e, t) {
- return Wt.fromEuler(this, e, t)
- },
- toString: function () {
- return "[" + Array.prototype.join.call(this.array, ",") + "]"
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array)
- }
- };
- var jt = Object.defineProperty;
- if (jt) {
- var Xt = Wt.prototype;
- jt(Xt, "x", {
- get: function () {
- return this.array[0]
- },
- set: function (e) {
- this.array[0] = e,
- this._dirty = !0
- }
- }),
- jt(Xt, "y", {
- get: function () {
- return this.array[1]
- },
- set: function (e) {
- this.array[1] = e,
- this._dirty = !0
- }
- }),
- jt(Xt, "z", {
- get: function () {
- return this.array[2]
- },
- set: function (e) {
- this.array[2] = e,
- this._dirty = !0
- }
- }),
- jt(Xt, "w", {
- get: function () {
- return this.array[3]
- },
- set: function (e) {
- this.array[3] = e,
- this._dirty = !0
- }
- })
- }
- Wt.add = function (e, t, r) {
- return Rt.add(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.set = function (e, t, r, i, n) {
- Rt.set(e.array, t, r, i, n),
- e._dirty = !0
- }
- ,
- Wt.copy = function (e, t) {
- return Rt.copy(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.calculateW = function (e, t) {
- return Rt.calculateW(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.conjugate = function (e, t) {
- return Rt.conjugate(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.identity = function (e) {
- return Rt.identity(e.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.invert = function (e, t) {
- return Rt.invert(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.dot = function (e, t) {
- return Rt.dot(e.array, t.array)
- }
- ,
- Wt.len = function (e) {
- return Rt.length(e.array)
- }
- ,
- Wt.lerp = function (e, t, r, i) {
- return Rt.lerp(e.array, t.array, r.array, i),
- e._dirty = !0,
- e
- }
- ,
- Wt.slerp = function (e, t, r, i) {
- return Rt.slerp(e.array, t.array, r.array, i),
- e._dirty = !0,
- e
- }
- ,
- Wt.multiply = Wt.mul = function (e, t, r) {
- return Rt.multiply(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.rotateX = function (e, t, r) {
- return Rt.rotateX(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Wt.rotateY = function (e, t, r) {
- return Rt.rotateY(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Wt.rotateZ = function (e, t, r) {
- return Rt.rotateZ(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Wt.setAxisAngle = function (e, t, r) {
- return Rt.setAxisAngle(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Wt.normalize = function (e, t) {
- return Rt.normalize(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.squaredLength = Wt.sqrLen = function (e) {
- return Rt.sqrLen(e.array)
- }
- ,
- Wt.fromMat3 = function (e, t) {
- return Rt.fromMat3(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.setAxes = function (e, t, r, i) {
- return Rt.setAxes(e.array, t.array, r.array, i.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.rotationTo = function (e, t, r) {
- return Rt.rotationTo(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Wt.fromEuler = function (e, t, r) {
- e._dirty = !0,
- t = t.array;
- var i = e.array
- , n = Math.cos(t[0] / 2)
- , a = Math.cos(t[1] / 2)
- , o = Math.cos(t[2] / 2)
- , s = Math.sin(t[0] / 2)
- , l = Math.sin(t[1] / 2)
- , h = Math.sin(t[2] / 2);
- switch (r = (r || "XYZ").toUpperCase()) {
- case "XYZ":
- i[0] = s * a * o + n * l * h,
- i[1] = n * l * o - s * a * h,
- i[2] = n * a * h + s * l * o,
- i[3] = n * a * o - s * l * h;
- break;
- case "YXZ":
- i[0] = s * a * o + n * l * h,
- i[1] = n * l * o - s * a * h,
- i[2] = n * a * h - s * l * o,
- i[3] = n * a * o + s * l * h;
- break;
- case "ZXY":
- i[0] = s * a * o - n * l * h,
- i[1] = n * l * o + s * a * h,
- i[2] = n * a * h + s * l * o,
- i[3] = n * a * o - s * l * h;
- break;
- case "ZYX":
- i[0] = s * a * o - n * l * h,
- i[1] = n * l * o + s * a * h,
- i[2] = n * a * h - s * l * o,
- i[3] = n * a * o + s * l * h;
- break;
- case "YZX":
- i[0] = s * a * o + n * l * h,
- i[1] = n * l * o + s * a * h,
- i[2] = n * a * h - s * l * o,
- i[3] = n * a * o - s * l * h;
- break;
- case "XZY":
- i[0] = s * a * o - n * l * h,
- i[1] = n * l * o - s * a * h,
- i[2] = n * a * h + s * l * o,
- i[3] = n * a * o + s * l * h
- }
- }
- ;
- const qt = Wt;
- var Zt, Yt, Kt, Qt, Jt, $t, er = Qe.set, tr = Qe.copy, rr = function (e, t) {
- this.min = e || new vt(1 / 0, 1 / 0, 1 / 0),
- this.max = t || new vt(-1 / 0, -1 / 0, -1 / 0),
- this.vertices = null
- };
- rr.prototype = {
- constructor: rr,
- updateFromVertices: function (e) {
- if (e.length > 0) {
- var t = this.min
- , r = this.max
- , i = t.array
- , n = r.array;
- tr(i, e[0]),
- tr(n, e[0]);
- for (var a = 1; a < e.length; a++) {
- var o = e[a];
- o[0] < i[0] && (i[0] = o[0]),
- o[1] < i[1] && (i[1] = o[1]),
- o[2] < i[2] && (i[2] = o[2]),
- o[0] > n[0] && (n[0] = o[0]),
- o[1] > n[1] && (n[1] = o[1]),
- o[2] > n[2] && (n[2] = o[2])
- }
- t._dirty = !0,
- r._dirty = !0
- }
- },
- union: function (e) {
- var t = this.min
- , r = this.max;
- return Qe.min(t.array, t.array, e.min.array),
- Qe.max(r.array, r.array, e.max.array),
- t._dirty = !0,
- r._dirty = !0,
- this
- },
- intersection: function (e) {
- var t = this.min
- , r = this.max;
- return Qe.max(t.array, t.array, e.min.array),
- Qe.min(r.array, r.array, e.max.array),
- t._dirty = !0,
- r._dirty = !0,
- this
- },
- intersectBoundingBox: function (e) {
- var t = this.min.array
- , r = this.max.array
- , i = e.min.array
- , n = e.max.array;
- return !(t[0] > n[0] || t[1] > n[1] || t[2] > n[2] || r[0] < i[0] || r[1] < i[1] || r[2] < i[2])
- },
- containBoundingBox: function (e) {
- var t = this.min.array
- , r = this.max.array
- , i = e.min.array
- , n = e.max.array;
- return t[0] <= i[0] && t[1] <= i[1] && t[2] <= i[2] && r[0] >= n[0] && r[1] >= n[1] && r[2] >= n[2]
- },
- containPoint: function (e) {
- var t = this.min.array
- , r = this.max.array
- , i = e.array;
- return t[0] <= i[0] && t[1] <= i[1] && t[2] <= i[2] && r[0] >= i[0] && r[1] >= i[1] && r[2] >= i[2]
- },
- isFinite: function () {
- var e = this.min.array
- , t = this.max.array;
- return isFinite(e[0]) && isFinite(e[1]) && isFinite(e[2]) && isFinite(t[0]) && isFinite(t[1]) && isFinite(t[2])
- },
- applyTransform: function (e) {
- this.transformFrom(this, e)
- },
- transformFrom: (Zt = Qe.create(),
- Yt = Qe.create(),
- Kt = Qe.create(),
- Qt = Qe.create(),
- Jt = Qe.create(),
- $t = Qe.create(),
- function (e, t) {
- var r = e.min.array
- , i = e.max.array
- , n = t.array;
- return Zt[0] = n[0] * r[0],
- Zt[1] = n[1] * r[0],
- Zt[2] = n[2] * r[0],
- Yt[0] = n[0] * i[0],
- Yt[1] = n[1] * i[0],
- Yt[2] = n[2] * i[0],
- Kt[0] = n[4] * r[1],
- Kt[1] = n[5] * r[1],
- Kt[2] = n[6] * r[1],
- Qt[0] = n[4] * i[1],
- Qt[1] = n[5] * i[1],
- Qt[2] = n[6] * i[1],
- Jt[0] = n[8] * r[2],
- Jt[1] = n[9] * r[2],
- Jt[2] = n[10] * r[2],
- $t[0] = n[8] * i[2],
- $t[1] = n[9] * i[2],
- $t[2] = n[10] * i[2],
- r = this.min.array,
- i = this.max.array,
- r[0] = Math.min(Zt[0], Yt[0]) + Math.min(Kt[0], Qt[0]) + Math.min(Jt[0], $t[0]) + n[12],
- r[1] = Math.min(Zt[1], Yt[1]) + Math.min(Kt[1], Qt[1]) + Math.min(Jt[1], $t[1]) + n[13],
- r[2] = Math.min(Zt[2], Yt[2]) + Math.min(Kt[2], Qt[2]) + Math.min(Jt[2], $t[2]) + n[14],
- i[0] = Math.max(Zt[0], Yt[0]) + Math.max(Kt[0], Qt[0]) + Math.max(Jt[0], $t[0]) + n[12],
- i[1] = Math.max(Zt[1], Yt[1]) + Math.max(Kt[1], Qt[1]) + Math.max(Jt[1], $t[1]) + n[13],
- i[2] = Math.max(Zt[2], Yt[2]) + Math.max(Kt[2], Qt[2]) + Math.max(Jt[2], $t[2]) + n[14],
- this.min._dirty = !0,
- this.max._dirty = !0,
- this
- }
- ),
- applyProjection: function (e) {
- var t = this.min.array
- , r = this.max.array
- , i = e.array
- , n = t[0]
- , a = t[1]
- , o = t[2]
- , s = r[0]
- , l = r[1]
- , h = t[2]
- , u = r[0]
- , c = r[1]
- , d = r[2];
- if (1 === i[15])
- t[0] = i[0] * n + i[12],
- t[1] = i[5] * a + i[13],
- r[2] = i[10] * o + i[14],
- r[0] = i[0] * u + i[12],
- r[1] = i[5] * c + i[13],
- t[2] = i[10] * d + i[14];
- else {
- var f = -1 / o;
- t[0] = i[0] * n * f,
- t[1] = i[5] * a * f,
- r[2] = (i[10] * o + i[14]) * f,
- f = -1 / h,
- r[0] = i[0] * s * f,
- r[1] = i[5] * l * f,
- f = -1 / d,
- t[2] = (i[10] * d + i[14]) * f
- }
- return this.min._dirty = !0,
- this.max._dirty = !0,
- this
- },
- updateVertices: function () {
- var e = this.vertices;
- if (!e) {
- e = [];
- for (var t = 0; t < 8; t++)
- e[t] = Qe.fromValues(0, 0, 0);
- this.vertices = e
- }
- var r = this.min.array
- , i = this.max.array;
- return er(e[0], r[0], r[1], r[2]),
- er(e[1], r[0], i[1], r[2]),
- er(e[2], i[0], r[1], r[2]),
- er(e[3], i[0], i[1], r[2]),
- er(e[4], r[0], r[1], i[2]),
- er(e[5], r[0], i[1], i[2]),
- er(e[6], i[0], r[1], i[2]),
- er(e[7], i[0], i[1], i[2]),
- this
- },
- copy: function (e) {
- var t = this.min
- , r = this.max;
- return tr(t.array, e.min.array),
- tr(r.array, e.max.array),
- t._dirty = !0,
- r._dirty = !0,
- this
- },
- clone: function () {
- var e = new rr;
- return e.copy(this),
- e
- }
- };
- const ir = rr;
- var nr, ar, or = 0;
- const sr = m.extend({
- name: "",
- position: null,
- rotation: null,
- scale: null,
- worldTransform: null,
- localTransform: null,
- autoUpdateLocalTransform: !0,
- _parent: null,
- _scene: null,
- _needsUpdateWorldTransform: !0,
- _inIterating: !1,
- __depth: 0
- }, (function () {
- this.name || (this.name = (this.type || "NODE") + "_" + or++),
- this.position || (this.position = new vt),
- this.rotation || (this.rotation = new qt),
- this.scale || (this.scale = new vt(1, 1, 1)),
- this.worldTransform = new Ht,
- this.localTransform = new Ht,
- this._children = []
- }
- ), {
- target: null,
- invisible: !1,
- isSkinnedMesh: function () {
- return !1
- },
- isRenderable: function () {
- return !1
- },
- setName: function (e) {
- var t = this._scene;
- if (t) {
- var r = t._nodeRepository;
- delete r[this.name],
- r[e] = this
- }
- this.name = e
- },
- add: function (e) {
- var t = e._parent;
- if (t !== this) {
- t && t.remove(e),
- e._parent = this,
- this._children.push(e);
- var r = this._scene;
- r && r !== e.scene && e.traverse(this._addSelfToScene, this),
- e._needsUpdateWorldTransform = !0
- }
- },
- remove: function (e) {
- var t = this._children
- , r = t.indexOf(e);
- r < 0 || (t.splice(r, 1),
- e._parent = null,
- this._scene && e.traverse(this._removeSelfFromScene, this))
- },
- removeAll: function () {
- for (var e = this._children, t = 0; t < e.length; t++)
- e[t]._parent = null,
- this._scene && e[t].traverse(this._removeSelfFromScene, this);
- this._children = []
- },
- getScene: function () {
- return this._scene
- },
- getParent: function () {
- return this._parent
- },
- _removeSelfFromScene: function (e) {
- e._scene.removeFromScene(e),
- e._scene = null
- },
- _addSelfToScene: function (e) {
- this._scene.addToScene(e),
- e._scene = this._scene
- },
- isAncestor: function (e) {
- for (var t = e._parent; t;) {
- if (t === this)
- return !0;
- t = t._parent
- }
- return !1
- },
- children: function () {
- return this._children.slice()
- },
- childAt: function (e) {
- return this._children[e]
- },
- getChildByName: function (e) {
- for (var t = this._children, r = 0; r < t.length; r++)
- if (t[r].name === e)
- return t[r]
- },
- getDescendantByName: function (e) {
- for (var t = this._children, r = 0; r < t.length; r++) {
- var i = t[r];
- if (i.name === e)
- return i;
- var n = i.getDescendantByName(e);
- if (n)
- return n
- }
- },
- queryNode: function (e) {
- if (e) {
- for (var t = e.split("/"), r = this, i = 0; i < t.length; i++) {
- var n = t[i];
- if (n) {
- for (var a = !1, o = r._children, s = 0; s < o.length; s++) {
- var l = o[s];
- if (l.name === n) {
- r = l,
- a = !0;
- break
- }
- }
- if (!a)
- return
- }
- }
- return r
- }
- },
- getPath: function (e) {
- if (!this._parent)
- return "/";
- for (var t = this._parent, r = this.name; t._parent && (r = t.name + "/" + r,
- t._parent != e);)
- t = t._parent;
- return !t._parent && e ? null : r
- },
- traverse: function (e, t) {
- e.call(t, this);
- for (var r = this._children, i = 0, n = r.length; i < n; i++)
- r[i].traverse(e, t)
- },
- eachChild: function (e, t) {
- for (var r = this._children, i = 0, n = r.length; i < n; i++) {
- var a = r[i];
- e.call(t, a, i)
- }
- },
- setLocalTransform: function (e) {
- Ye.copy(this.localTransform.array, e.array),
- this.decomposeLocalTransform()
- },
- decomposeLocalTransform: function (e) {
- var t = e ? null : this.scale;
- this.localTransform.decomposeMatrix(t, this.rotation, this.position)
- },
- setWorldTransform: function (e) {
- Ye.copy(this.worldTransform.array, e.array),
- this.decomposeWorldTransform()
- },
- decomposeWorldTransform: (ar = Ye.create(),
- function (e) {
- var t = this.localTransform
- , r = this.worldTransform;
- this._parent ? (Ye.invert(ar, this._parent.worldTransform.array),
- Ye.multiply(t.array, ar, r.array)) : Ye.copy(t.array, r.array);
- var i = e ? null : this.scale;
- t.decomposeMatrix(i, this.rotation, this.position)
- }
- ),
- transformNeedsUpdate: function () {
- return this.position._dirty || this.rotation._dirty || this.scale._dirty
- },
- updateLocalTransform: function () {
- var e = this.position
- , t = this.rotation
- , r = this.scale;
- if (this.transformNeedsUpdate()) {
- var i = this.localTransform.array;
- Ye.fromRotationTranslation(i, t.array, e.array),
- Ye.scale(i, i, r.array),
- t._dirty = !1,
- r._dirty = !1,
- e._dirty = !1,
- this._needsUpdateWorldTransform = !0
- }
- },
- _updateWorldTransformTopDown: function () {
- var e = this.localTransform.array
- , t = this.worldTransform.array;
- this._parent ? Ye.multiplyAffine(t, this._parent.worldTransform.array, e) : Ye.copy(t, e)
- },
- updateWorldTransform: function () {
- for (var e = this; e && e.getParent() && e.getParent().transformNeedsUpdate();)
- e = e.getParent();
- e.update()
- },
- update: function (e) {
- this.autoUpdateLocalTransform ? this.updateLocalTransform() : e = !0,
- (e || this._needsUpdateWorldTransform) && (this._updateWorldTransformTopDown(),
- e = !0,
- this._needsUpdateWorldTransform = !1);
- for (var t = this._children, r = 0, i = t.length; r < i; r++)
- t[r].update(e)
- },
- getBoundingBox: function () {
- function e(e) {
- return !e.invisible && e.geometry
- }
- var t = new ir
- , r = new Ht
- , i = new Ht;
- return function (n, a) {
- return a = a || new ir,
- n = n || e,
- this._parent ? Ht.invert(i, this._parent.worldTransform) : Ht.identity(i),
- this.traverse((function (e) {
- e.geometry && e.geometry.boundingBox && (t.copy(e.geometry.boundingBox),
- Ht.multiply(r, i, e.worldTransform),
- t.applyTransform(r),
- a.union(t))
- }
- ), this, e),
- a
- }
- }(),
- getWorldPosition: function (e) {
- this.transformNeedsUpdate() && this.updateWorldTransform();
- var t = this.worldTransform.array;
- if (e) {
- var r = e.array;
- return r[0] = t[12],
- r[1] = t[13],
- r[2] = t[14],
- e
- }
- return new vt(t[12], t[13], t[14])
- },
- clone: function () {
- var e = new this.constructor
- , t = this._children;
- e.setName(this.name),
- e.position.copy(this.position),
- e.rotation.copy(this.rotation),
- e.scale.copy(this.scale);
- for (var r = 0; r < t.length; r++)
- e.add(t[r].clone());
- return e
- },
- rotateAround: function () {
- var e = new vt
- , t = new Ht;
- return function (r, i, n) {
- e.copy(this.position).subtract(r);
- var a = this.localTransform;
- a.identity(),
- a.translate(r),
- a.rotate(n, i),
- t.fromRotationTranslation(this.rotation, e),
- a.multiply(t),
- a.scale(this.scale),
- this.decomposeLocalTransform(),
- this._needsUpdateWorldTransform = !0
- }
- }(),
- lookAt: (nr = new Ht,
- function (e, t) {
- nr.lookAt(this.position, e, t || this.localTransform.y).invert(),
- this.setLocalTransform(nr),
- this.target = e
- }
- )
- });
- var lr, hr = sr.extend({
- material: null,
- geometry: null,
- mode: 4,
- _renderInfo: null
- }, {
- __program: null,
- lightGroup: 0,
- renderOrder: 0,
- culling: !0,
- cullFace: x,
- frontFace: w,
- frustumCulling: !0,
- receiveShadow: !0,
- castShadow: !0,
- ignorePicking: !1,
- ignorePreZ: !1,
- ignoreGBuffer: !1,
- isRenderable: function () {
- return this.geometry && this.material && this.material.shader && !this.invisible && this.geometry.vertexCount > 0
- },
- beforeRender: function (e) { },
- afterRender: function (e, t) { },
- getBoundingBox: function (e, t) {
- return t = sr.prototype.getBoundingBox.call(this, e, t),
- this.geometry && this.geometry.boundingBox && t.union(this.geometry.boundingBox),
- t
- },
- clone: (lr = ["castShadow", "receiveShadow", "mode", "culling", "cullFace", "frontFace", "frustumCulling", "renderOrder", "lineWidth", "ignorePicking", "ignorePreZ", "ignoreGBuffer"],
- function () {
- var e = sr.prototype.clone.call(this);
- e.geometry = this.geometry,
- e.material = this.material;
- for (var t = 0; t < lr.length; t++) {
- var r = lr[t];
- e[r] !== this[r] && (e[r] = this[r])
- }
- return e
- }
- )
- });
- hr.POINTS = 0,
- hr.LINES = 1,
- hr.LINE_LOOP = 2,
- hr.LINE_STRIP = 3,
- hr.TRIANGLES = 4,
- hr.TRIANGLE_STRIP = 5,
- hr.TRIANGLE_FAN = 6,
- hr.BACK = x,
- hr.FRONT = y,
- hr.FRONT_AND_BACK = 1032,
- hr.CW = b,
- hr.CCW = w;
- const ur = hr;
- var cr, dr, fr, pr, mr, gr = m.extend({
- scene: null,
- camera: null,
- renderer: null
- }, (function () {
- this._ray = new Mt,
- this._ndc = new _e
- }
- ), {
- pick: function (e, t, r) {
- return this.pickAll(e, t, [], r)[0] || null
- },
- pickAll: function (e, t, r, i) {
- return this.renderer.screenToNDC(e, t, this._ndc),
- this.camera.castRay(this._ndc, this._ray),
- r = r || [],
- this._intersectNode(this.scene, r, i || !1),
- r.sort(this._intersectionCompareFunc),
- r
- },
- _intersectNode: function (e, t, r) {
- e instanceof ur && e.isRenderable() && (e.ignorePicking && !r || !(4 === e.mode && e.geometry.isUseIndices() || e.geometry.pickByRay || e.geometry.pick) || this._intersectRenderable(e, t));
- for (var i = 0; i < e._children.length; i++)
- this._intersectNode(e._children[i], t, r)
- },
- _intersectRenderable: (cr = new vt,
- dr = new vt,
- fr = new vt,
- pr = new Mt,
- mr = new Ht,
- function (e, t) {
- var r = e.isSkinnedMesh();
- pr.copy(this._ray),
- Ht.invert(mr, e.worldTransform),
- r || pr.applyTransform(mr);
- var i = e.geometry
- , n = r ? e.skeleton.boundingBox : i.boundingBox;
- if (!n || pr.intersectBoundingBox(n))
- if (i.pick)
- i.pick(this._ndc.x, this._ndc.y, this.renderer, this.camera, e, t);
- else if (i.pickByRay)
- i.pickByRay(pr, e, t);
- else {
- var a, o, s = e.cullFace === x && e.frontFace === w || e.cullFace === y && e.frontFace === b, l = i.indices, h = i.attributes.position, u = i.attributes.weight, c = i.attributes.joint, d = [];
- if (h && h.value && l) {
- if (r) {
- o = e.skeleton.getSubSkinMatrices(e.__uid__, e.joints);
- for (var f = 0; f < e.joints.length; f++) {
- d[f] = d[f] || [];
- for (var p = 0; p < 16; p++)
- d[f][p] = o[16 * f + p]
- }
- var m = []
- , g = []
- , _ = []
- , v = []
- , T = []
- , S = i.attributes.skinnedPosition;
- for (S && S.value || (i.createAttribute("skinnedPosition", "f", 3),
- (S = i.attributes.skinnedPosition).init(i.vertexCount)),
- f = 0; f < i.vertexCount; f++) {
- for (h.get(f, m),
- u.get(f, g),
- c.get(f, _),
- g[3] = 1 - g[0] - g[1] - g[2],
- Qe.set(v, 0, 0, 0),
- p = 0; p < 4; p++)
- _[p] >= 0 && g[p] > 1e-4 && (Qe.transformMat4(T, m, d[_[p]]),
- Qe.scaleAndAdd(v, v, T, g[p]));
- S.set(f, v)
- }
- }
- for (f = 0; f < l.length; f += 3) {
- var M = l[f]
- , A = l[f + 1]
- , E = l[f + 2]
- , C = r ? i.attributes.skinnedPosition : h;
- if (C.get(M, cr.array),
- C.get(A, dr.array),
- C.get(E, fr.array),
- a = s ? pr.intersectTriangle(cr, dr, fr, e.culling) : pr.intersectTriangle(cr, fr, dr, e.culling)) {
- var D = new vt;
- r ? vt.copy(D, a) : vt.transformMat4(D, a, e.worldTransform),
- t.push(new gr.Intersection(a, D, e, [M, A, E], f / 3, vt.dist(D, this._ray.origin)))
- }
- }
- }
- }
- }
- ),
- _intersectionCompareFunc: function (e, t) {
- return e.distance - t.distance
- }
- });
- gr.Intersection = function (e, t, r, i, n, a) {
- this.point = e,
- this.pointWorld = t,
- this.target = r,
- this.triangle = i,
- this.triangleIndex = n,
- this.distance = a
- }
- ;
- const _r = gr;
- var vr = "__dt__"
- , yr = function () {
- this._contextId = 0,
- this._caches = [],
- this._context = {}
- };
- (yr.prototype = {
- use: function (e, t) {
- var r = this._caches;
- r[e] || (r[e] = {},
- t && (r[e] = t())),
- this._contextId = e,
- this._context = r[e]
- },
- put: function (e, t) {
- this._context[e] = t
- },
- get: function (e) {
- return this._context[e]
- },
- dirty: function (e) {
- var t = vr + (e = e || "");
- this.put(t, !0)
- },
- dirtyAll: function (e) {
- for (var t = vr + (e = e || ""), r = this._caches, i = 0; i < r.length; i++)
- r[i] && (r[i][t] = !0)
- },
- fresh: function (e) {
- var t = vr + (e = e || "");
- this.put(t, !1)
- },
- freshAll: function (e) {
- for (var t = vr + (e = e || ""), r = this._caches, i = 0; i < r.length; i++)
- r[i] && (r[i][t] = !1)
- },
- isDirty: function (e) {
- var t = vr + (e = e || "")
- , r = this._context;
- return !r.hasOwnProperty(t) || !0 === r[t]
- },
- deleteContext: function (e) {
- delete this._caches[e],
- this._context = {}
- },
- delete: function (e) {
- delete this._context[e]
- },
- clearAll: function () {
- this._caches = {}
- },
- getContext: function () {
- return this._context
- },
- eachContext: function (e, t) {
- Object.keys(this._caches).forEach((function (r) {
- e && e.call(t, r)
- }
- ))
- },
- miss: function (e) {
- return !this._context.hasOwnProperty(e)
- }
- }).constructor = yr;
- const xr = yr;
- var br = m.extend({
- width: 512,
- height: 512,
- type: T,
- format: A,
- wrapS: N,
- wrapT: N,
- minFilter: O,
- magFilter: C,
- useMipmap: !0,
- anisotropic: 1,
- flipY: !0,
- sRGB: !0,
- unpackAlignment: 4,
- premultiplyAlpha: !1,
- dynamic: !1,
- NPOT: !1,
- __used: 0
- }, (function () {
- this._cache = new xr
- }
- ), {
- getWebGLTexture: function (e) {
- var t = e.gl
- , r = this._cache;
- return r.use(e.__uid__),
- r.miss("webgl_texture") && r.put("webgl_texture", t.createTexture()),
- this.dynamic ? this.update(e) : r.isDirty() && (this.update(e),
- r.fresh()),
- r.get("webgl_texture")
- },
- bind: function () { },
- unbind: function () { },
- dirty: function () {
- this._cache && this._cache.dirtyAll()
- },
- update: function (e) { },
- updateCommon: function (e) {
- var t = e.gl;
- t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, this.flipY),
- t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha),
- t.pixelStorei(t.UNPACK_ALIGNMENT, this.unpackAlignment),
- this.format === M && (this.useMipmap = !1);
- var r = e.getGLExtension("EXT_sRGB");
- this.format !== br.SRGB || r || (this.format = br.RGB),
- this.format !== br.SRGB_ALPHA || r || (this.format = br.RGBA),
- this.NPOT = !this.isPowerOfTwo()
- },
- getAvailableWrapS: function () {
- return this.NPOT ? I : this.wrapS
- },
- getAvailableWrapT: function () {
- return this.NPOT ? I : this.wrapT
- },
- getAvailableMinFilter: function () {
- var e = this.minFilter;
- return this.NPOT || !this.useMipmap ? e === D || e === P ? E : e === O || e === L ? C : e : e
- },
- getAvailableMagFilter: function () {
- return this.magFilter
- },
- nextHighestPowerOfTwo: function (e) {
- --e;
- for (var t = 1; t < 32; t <<= 1)
- e |= e >> t;
- return e + 1
- },
- dispose: function (e) {
- var t = this._cache;
- t.use(e.__uid__);
- var r = t.get("webgl_texture");
- r && e.gl.deleteTexture(r),
- t.deleteContext(e.__uid__)
- },
- isRenderable: function () { },
- isPowerOfTwo: function () { }
- });
- Object.defineProperty(br.prototype, "width", {
- get: function () {
- return this._width
- },
- set: function (e) {
- this._width = e
- }
- }),
- Object.defineProperty(br.prototype, "height", {
- get: function () {
- return this._height
- },
- set: function (e) {
- this._height = e
- }
- }),
- br.BYTE = 5120,
- br.UNSIGNED_BYTE = T,
- br.SHORT = 5122,
- br.UNSIGNED_SHORT = 5123,
- br.INT = 5124,
- br.UNSIGNED_INT = 5125,
- br.FLOAT = S,
- br.HALF_FLOAT = 36193,
- br.UNSIGNED_INT_24_8_WEBGL = 34042,
- br.DEPTH_COMPONENT = M,
- br.DEPTH_STENCIL = 34041,
- br.ALPHA = 6406,
- br.RGB = 6407,
- br.RGBA = A,
- br.LUMINANCE = 6409,
- br.LUMINANCE_ALPHA = 6410,
- br.SRGB = 35904,
- br.SRGB_ALPHA = 35906,
- br.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776,
- br.COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777,
- br.COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778,
- br.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779,
- br.NEAREST = E,
- br.LINEAR = C,
- br.NEAREST_MIPMAP_NEAREST = D,
- br.LINEAR_MIPMAP_NEAREST = L,
- br.NEAREST_MIPMAP_LINEAR = P,
- br.LINEAR_MIPMAP_LINEAR = O,
- br.REPEAT = N,
- br.CLAMP_TO_EDGE = I,
- br.MIRRORED_REPEAT = 33648;
- const wr = br;
- var Tr = ur.extend({
- skeleton: null,
- joints: null
- }, (function () {
- this.joints || (this.joints = [])
- }
- ), {
- offsetMatrix: null,
- isInstancedMesh: function () {
- return !1
- },
- isSkinnedMesh: function () {
- return !!(this.skeleton && this.joints && this.joints.length > 0)
- },
- clone: function () {
- var e = ur.prototype.clone.call(this);
- return e.skeleton = this.skeleton,
- this.joints && (e.joints = this.joints.slice()),
- e
- }
- });
- Tr.POINTS = 0,
- Tr.LINES = 1,
- Tr.LINE_LOOP = 2,
- Tr.LINE_STRIP = 3,
- Tr.TRIANGLES = 4,
- Tr.TRIANGLE_STRIP = 5,
- Tr.TRIANGLE_FAN = 6,
- Tr.BACK = x,
- Tr.FRONT = y,
- Tr.FRONT_AND_BACK = 1032,
- Tr.CW = b,
- Tr.CCW = w;
- const Sr = Tr;
- const Mr = {
- isPowerOfTwo: function (e) {
- return 0 == (e & e - 1)
- },
- nextPowerOfTwo: function (e) {
- return e--,
- e |= e >> 1,
- e |= e >> 2,
- e |= e >> 4,
- e |= e >> 8,
- e |= e >> 16,
- ++e
- },
- nearestPowerOfTwo: function (e) {
- return Math.pow(2, Math.round(Math.log(e) / Math.LN2))
- }
- };
- var Ar = Mr.isPowerOfTwo;
- function Er(e) {
- return Math.pow(2, Math.round(Math.log(e) / Math.LN2))
- }
- var Cr = wr.extend((function () {
- return {
- image: null,
- pixels: null,
- mipmaps: [],
- convertToPOT: !1
- }
- }
- ), {
- textureType: "texture2D",
- update: function (e) {
- var t = e.gl;
- t.bindTexture(t.TEXTURE_2D, this._cache.get("webgl_texture")),
- this.updateCommon(e);
- var r = this.format
- , i = this.type
- , n = !(!this.convertToPOT || this.mipmaps.length || !this.image || this.wrapS !== wr.REPEAT && this.wrapT !== wr.REPEAT || !this.NPOT);
- t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, n ? this.wrapS : this.getAvailableWrapS()),
- t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, n ? this.wrapT : this.getAvailableWrapT()),
- t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, n ? this.magFilter : this.getAvailableMagFilter()),
- t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, n ? this.minFilter : this.getAvailableMinFilter());
- var a = e.getGLExtension("EXT_texture_filter_anisotropic");
- if (a && this.anisotropic > 1 && t.texParameterf(t.TEXTURE_2D, a.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic),
- 36193 === i && (e.getGLExtension("OES_texture_half_float") || (i = S)),
- this.mipmaps.length)
- for (var o = this.width, s = this.height, l = 0; l < this.mipmaps.length; l++) {
- var h = this.mipmaps[l];
- this._updateTextureData(t, h, l, o, s, r, i, !1),
- o /= 2,
- s /= 2
- }
- else
- this._updateTextureData(t, this, 0, this.width, this.height, r, i, n),
- !this.useMipmap || this.NPOT && !n || t.generateMipmap(t.TEXTURE_2D);
- t.bindTexture(t.TEXTURE_2D, null)
- },
- _updateTextureData: function (e, t, r, i, n, a, o, s) {
- if (t.image) {
- var l = t.image;
- s && (this._potCanvas = function (e, t) {
- var r = Er(e.width)
- , i = Er(e.height);
- return (t = t || document.createElement("canvas")).width = r,
- t.height = i,
- t.getContext("2d").drawImage(e.image, 0, 0, r, i),
- t
- }(this, this._potCanvas),
- l = this._potCanvas),
- e.texImage2D(e.TEXTURE_2D, r, a, a, o, l)
- } else
- a <= wr.COMPRESSED_RGBA_S3TC_DXT5_EXT && a >= wr.COMPRESSED_RGB_S3TC_DXT1_EXT ? e.compressedTexImage2D(e.TEXTURE_2D, r, a, i, n, 0, t.pixels) : e.texImage2D(e.TEXTURE_2D, r, a, i, n, 0, a, o, t.pixels)
- },
- generateMipmap: function (e) {
- var t = e.gl;
- this.useMipmap && !this.NPOT && (t.bindTexture(t.TEXTURE_2D, this._cache.get("webgl_texture")),
- t.generateMipmap(t.TEXTURE_2D))
- },
- isPowerOfTwo: function () {
- return Ar(this.width) && Ar(this.height)
- },
- isRenderable: function () {
- return this.image ? this.image.width > 0 && this.image.height > 0 : !(!this.width || !this.height)
- },
- bind: function (e) {
- e.gl.bindTexture(e.gl.TEXTURE_2D, this.getWebGLTexture(e))
- },
- unbind: function (e) {
- e.gl.bindTexture(e.gl.TEXTURE_2D, null)
- },
- load: function (e, t) {
- var r = U.createImage();
- t && (r.crossOrigin = t);
- var i = this;
- return r.onload = function () {
- i.dirty(),
- i.trigger("success", i)
- }
- ,
- r.onerror = function () {
- i.trigger("error", i)
- }
- ,
- r.src = e,
- this.image = r,
- this
- }
- });
- Object.defineProperty(Cr.prototype, "width", {
- get: function () {
- return this.image ? this.image.width : this._width
- },
- set: function (e) {
- this.image ? console.warn("Texture from image can't set width") : (this._width !== e && this.dirty(),
- this._width = e)
- }
- }),
- Object.defineProperty(Cr.prototype, "height", {
- get: function () {
- return this.image ? this.image.height : this._height
- },
- set: function (e) {
- this.image ? console.warn("Texture from image can't set height") : (this._height !== e && this.dirty(),
- this._height = e)
- }
- });
- const Dr = Cr;
- function Lr(e) {
- return {
- byte: U.Int8Array,
- ubyte: U.Uint8Array,
- short: U.Int16Array,
- ushort: U.Uint16Array
- }[e] || U.Float32Array
- }
- function Pr(e) {
- return "attr_" + e
- }
- function Or(e, t, r, i) {
- switch (this.name = e,
- this.type = t,
- this.size = r,
- this.semantic = i || "",
- this.value = null,
- r) {
- case 1:
- this.get = function (e) {
- return this.value[e]
- }
- ,
- this.set = function (e, t) {
- this.value[e] = t
- }
- ,
- this.copy = function (e, t) {
- this.value[e] = this.value[e]
- }
- ;
- break;
- case 2:
- this.get = function (e, t) {
- var r = this.value;
- return t[0] = r[2 * e],
- t[1] = r[2 * e + 1],
- t
- }
- ,
- this.set = function (e, t) {
- var r = this.value;
- r[2 * e] = t[0],
- r[2 * e + 1] = t[1]
- }
- ,
- this.copy = function (e, t) {
- var r = this.value;
- t *= 2,
- r[e *= 2] = r[t],
- r[e + 1] = r[t + 1]
- }
- ;
- break;
- case 3:
- this.get = function (e, t) {
- var r = 3 * e
- , i = this.value;
- return t[0] = i[r],
- t[1] = i[r + 1],
- t[2] = i[r + 2],
- t
- }
- ,
- this.set = function (e, t) {
- var r = 3 * e
- , i = this.value;
- i[r] = t[0],
- i[r + 1] = t[1],
- i[r + 2] = t[2]
- }
- ,
- this.copy = function (e, t) {
- var r = this.value;
- t *= 3,
- r[e *= 3] = r[t],
- r[e + 1] = r[t + 1],
- r[e + 2] = r[t + 2]
- }
- ;
- break;
- case 4:
- this.get = function (e, t) {
- var r = this.value
- , i = 4 * e;
- return t[0] = r[i],
- t[1] = r[i + 1],
- t[2] = r[i + 2],
- t[3] = r[i + 3],
- t
- }
- ,
- this.set = function (e, t) {
- var r = this.value
- , i = 4 * e;
- r[i] = t[0],
- r[i + 1] = t[1],
- r[i + 2] = t[2],
- r[i + 3] = t[3]
- }
- ,
- this.copy = function (e, t) {
- var r = this.value;
- t *= 4,
- r[e *= 4] = r[t],
- r[e + 1] = r[t + 1],
- r[e + 2] = r[t + 2],
- r[e + 3] = r[t + 3]
- }
- }
- }
- function Nr(e, t, r, i, n) {
- this.name = e,
- this.type = t,
- this.buffer = r,
- this.size = i,
- this.semantic = n,
- this.symbol = "",
- this.needsRemove = !1
- }
- function Ir(e) {
- this.buffer = e,
- this.count = 0
- }
- Or.prototype.init = function (e) {
- if (!this.value || this.value.length !== e * this.size) {
- var t = Lr(this.type);
- this.value = new t(e * this.size)
- }
- }
- ,
- Or.prototype.fromArray = function (e) {
- var t, r = Lr(this.type);
- if (e[0] && e[0].length) {
- var i = 0
- , n = this.size;
- t = new r(e.length * n);
- for (var a = 0; a < e.length; a++)
- for (var o = 0; o < n; o++)
- t[i++] = e[a][o]
- } else
- t = new r(e);
- this.value = t
- }
- ,
- Or.prototype.clone = function (e) {
- var t = new Or(this.name, this.type, this.size, this.semantic);
- return e && console.warn("todo"),
- t
- }
- ;
- var Rr = m.extend((function () {
- return {
- attributes: {},
- indices: null,
- dynamic: !0,
- _enabledAttributes: null,
- __used: 0
- }
- }
- ), (function () {
- this._cache = new xr,
- this._attributeList = Object.keys(this.attributes),
- this.__vaoCache = {}
- }
- ), {
- mainAttribute: "",
- pick: null,
- pickByRay: null,
- dirty: function () {
- for (var e = this.getEnabledAttributes(), t = 0; t < e.length; t++)
- this.dirtyAttribute(e[t]);
- this.dirtyIndices(),
- this._enabledAttributes = null,
- this._cache.dirty("any")
- },
- dirtyIndices: function () {
- this._cache.dirtyAll("indices")
- },
- dirtyAttribute: function (e) {
- this._cache.dirtyAll(Pr(e)),
- this._cache.dirtyAll("attributes")
- },
- getTriangleIndices: function (e, t) {
- if (e < this.triangleCount && e >= 0) {
- t || (t = []);
- var r = this.indices;
- return t[0] = r[3 * e],
- t[1] = r[3 * e + 1],
- t[2] = r[3 * e + 2],
- t
- }
- },
- setTriangleIndices: function (e, t) {
- var r = this.indices;
- r[3 * e] = t[0],
- r[3 * e + 1] = t[1],
- r[3 * e + 2] = t[2]
- },
- isUseIndices: function () {
- return !!this.indices
- },
- initIndicesFromArray: function (e) {
- var t, r = this.vertexCount > 65535 ? U.Uint32Array : U.Uint16Array;
- if (e[0] && e[0].length) {
- var i = 0;
- t = new r(3 * e.length);
- for (var n = 0; n < e.length; n++)
- for (var a = 0; a < 3; a++)
- t[i++] = e[n][a]
- } else
- t = new r(e);
- this.indices = t
- },
- createAttribute: function (e, t, r, i) {
- var n = new Or(e, t, r, i);
- return this.attributes[e] && this.removeAttribute(e),
- this.attributes[e] = n,
- this._attributeList.push(e),
- n
- },
- removeAttribute: function (e) {
- var t = this._attributeList
- , r = t.indexOf(e);
- return r >= 0 && (t.splice(r, 1),
- delete this.attributes[e],
- !0)
- },
- getAttribute: function (e) {
- return this.attributes[e]
- },
- getEnabledAttributes: function () {
- var e = this._enabledAttributes
- , t = this._attributeList;
- if (e)
- return e;
- for (var r = [], i = this.vertexCount, n = 0; n < t.length; n++) {
- var a = t[n]
- , o = this.attributes[a];
- o.value && o.value.length === i * o.size && r.push(a)
- }
- return this._enabledAttributes = r,
- r
- },
- getBufferChunks: function (e) {
- var t = this._cache;
- t.use(e.__uid__);
- var r = t.isDirty("attributes")
- , i = t.isDirty("indices");
- if (r || i) {
- this._updateBuffer(e.gl, r, i);
- for (var n = this.getEnabledAttributes(), a = 0; a < n.length; a++)
- t.fresh(Pr(n[a]));
- t.fresh("attributes"),
- t.fresh("indices")
- }
- return t.fresh("any"),
- t.get("chunks")
- },
- _updateBuffer: function (e, t, r) {
- var i = this._cache
- , n = i.get("chunks")
- , a = !1;
- n || ((n = [])[0] = {
- attributeBuffers: [],
- indicesBuffer: null
- },
- i.put("chunks", n),
- a = !0);
- var o = n[0]
- , s = o.attributeBuffers
- , l = o.indicesBuffer;
- if (t || a) {
- var h = this.getEnabledAttributes()
- , u = {};
- if (!a)
- for (var c = 0; c < s.length; c++)
- u[s[c].name] = s[c];
- for (var d = 0; d < h.length; d++) {
- var f, p, m = h[d], g = this.attributes[m];
- a || (f = u[m]),
- p = f ? f.buffer : e.createBuffer(),
- i.isDirty(Pr(m)) && (e.bindBuffer(e.ARRAY_BUFFER, p),
- e.bufferData(e.ARRAY_BUFFER, g.value, this.dynamic ? e.DYNAMIC_DRAW : e.STATIC_DRAW)),
- s[d] = new Nr(m, g.type, p, g.size, g.semantic)
- }
- for (c = d; c < s.length; c++)
- e.deleteBuffer(s[c].buffer);
- s.length = d
- }
- this.isUseIndices() && (r || a) && (l || (l = new Ir(e.createBuffer()),
- o.indicesBuffer = l),
- l.count = this.indices.length,
- e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, l.buffer),
- e.bufferData(e.ELEMENT_ARRAY_BUFFER, this.indices, this.dynamic ? e.DYNAMIC_DRAW : e.STATIC_DRAW))
- },
- dispose: function (e) {
- var t = this._cache;
- t.use(e.__uid__);
- var r = t.get("chunks");
- if (r)
- for (var i = 0; i < r.length; i++) {
- for (var n = r[i], a = 0; a < n.attributeBuffers.length; a++) {
- var o = n.attributeBuffers[a];
- e.gl.deleteBuffer(o.buffer)
- }
- n.indicesBuffer && e.gl.deleteBuffer(n.indicesBuffer.buffer)
- }
- if (this.__vaoCache) {
- var s = e.getGLExtension("OES_vertex_array_object");
- for (var l in this.__vaoCache) {
- var h = this.__vaoCache[l].vao;
- h && s.deleteVertexArrayOES(h)
- }
- }
- this.__vaoCache = {},
- t.deleteContext(e.__uid__)
- }
- });
- Object.defineProperty && (Object.defineProperty(Rr.prototype, "vertexCount", {
- enumerable: !1,
- get: function () {
- var e = this.attributes[this.mainAttribute];
- return e || (e = this.attributes[this._attributeList[0]]),
- e && e.value ? e.value.length / e.size : 0
- }
- }),
- Object.defineProperty(Rr.prototype, "triangleCount", {
- enumerable: !1,
- get: function () {
- var e = this.indices;
- return e ? e.length / 3 : 0
- }
- })),
- Rr.STATIC_DRAW = 35044,
- Rr.DYNAMIC_DRAW = 35048,
- Rr.STREAM_DRAW = 35040,
- Rr.AttributeBuffer = Nr,
- Rr.IndicesBuffer = Ir,
- Rr.Attribute = Or;
- const Br = Rr;
- var Fr = Qe.create
- , zr = Qe.add
- , Gr = Qe.set
- , Ur = Br.Attribute
- , kr = Br.extend((function () {
- return {
- attributes: {
- position: new Ur("position", "float", 3, "POSITION"),
- texcoord0: new Ur("texcoord0", "float", 2, "TEXCOORD_0"),
- texcoord1: new Ur("texcoord1", "float", 2, "TEXCOORD_1"),
- normal: new Ur("normal", "float", 3, "NORMAL"),
- tangent: new Ur("tangent", "float", 4, "TANGENT"),
- color: new Ur("color", "float", 4, "COLOR"),
- weight: new Ur("weight", "float", 3, "WEIGHT"),
- joint: new Ur("joint", "float", 4, "JOINT"),
- barycentric: new Ur("barycentric", "float", 3, null)
- },
- boundingBox: null
- }
- }
- ), {
- mainAttribute: "position",
- updateBoundingBox: function () {
- var e = this.boundingBox;
- e || (e = this.boundingBox = new ir);
- var t = this.attributes.position.value;
- if (t && t.length) {
- var r = e.min
- , i = e.max
- , n = r.array
- , a = i.array;
- Qe.set(n, t[0], t[1], t[2]),
- Qe.set(a, t[0], t[1], t[2]);
- for (var o = 3; o < t.length;) {
- var s = t[o++]
- , l = t[o++]
- , h = t[o++];
- s < n[0] && (n[0] = s),
- l < n[1] && (n[1] = l),
- h < n[2] && (n[2] = h),
- s > a[0] && (a[0] = s),
- l > a[1] && (a[1] = l),
- h > a[2] && (a[2] = h)
- }
- r._dirty = !0,
- i._dirty = !0
- }
- },
- generateVertexNormals: function () {
- if (this.vertexCount) {
- var e = this.indices
- , t = this.attributes
- , r = t.position.value
- , i = t.normal.value;
- if (i && i.length === r.length)
- for (var n = 0; n < i.length; n++)
- i[n] = 0;
- else
- i = t.normal.value = new U.Float32Array(r.length);
- for (var a, o, s, l = Fr(), h = Fr(), u = Fr(), c = Fr(), d = Fr(), f = Fr(), p = e ? e.length : this.vertexCount, m = 0; m < p;)
- for (e ? (a = e[m++],
- o = e[m++],
- s = e[m++]) : (a = m++,
- o = m++,
- s = m++),
- Gr(l, r[3 * a], r[3 * a + 1], r[3 * a + 2]),
- Gr(h, r[3 * o], r[3 * o + 1], r[3 * o + 2]),
- Gr(u, r[3 * s], r[3 * s + 1], r[3 * s + 2]),
- Qe.sub(c, l, h),
- Qe.sub(d, h, u),
- Qe.cross(f, c, d),
- n = 0; n < 3; n++)
- i[3 * a + n] = i[3 * a + n] + f[n],
- i[3 * o + n] = i[3 * o + n] + f[n],
- i[3 * s + n] = i[3 * s + n] + f[n];
- for (n = 0; n < i.length;)
- Gr(f, i[n], i[n + 1], i[n + 2]),
- Qe.normalize(f, f),
- i[n++] = f[0],
- i[n++] = f[1],
- i[n++] = f[2];
- this.dirty()
- }
- },
- generateFaceNormals: function () {
- if (this.vertexCount) {
- this.isUniqueVertex() || this.generateUniqueVertex();
- var e = this.indices
- , t = this.attributes
- , r = t.position.value
- , i = t.normal.value
- , n = Fr()
- , a = Fr()
- , o = Fr()
- , s = Fr()
- , l = Fr()
- , h = Fr();
- i || (i = t.normal.value = new Float32Array(r.length));
- for (var u, c, d, f = e ? e.length : this.vertexCount, p = 0; p < f;) {
- e ? (u = e[p++],
- c = e[p++],
- d = e[p++]) : (u = p++,
- c = p++,
- d = p++),
- Gr(n, r[3 * u], r[3 * u + 1], r[3 * u + 2]),
- Gr(a, r[3 * c], r[3 * c + 1], r[3 * c + 2]),
- Gr(o, r[3 * d], r[3 * d + 1], r[3 * d + 2]),
- Qe.sub(s, n, a),
- Qe.sub(l, a, o),
- Qe.cross(h, s, l),
- Qe.normalize(h, h);
- for (var m = 0; m < 3; m++)
- i[3 * u + m] = h[m],
- i[3 * c + m] = h[m],
- i[3 * d + m] = h[m]
- }
- this.dirty()
- }
- },
- generateTangents: function () {
- if (this.vertexCount) {
- var e = this.vertexCount
- , t = this.attributes;
- t.tangent.value || (t.tangent.value = new Float32Array(4 * e));
- var r = t.texcoord0.value
- , i = t.position.value
- , n = t.tangent.value
- , a = t.normal.value;
- if (r) {
- for (var o = [], s = [], l = 0; l < e; l++)
- o[l] = [0, 0, 0],
- s[l] = [0, 0, 0];
- var h, u, c, d = [0, 0, 0], f = [0, 0, 0], p = this.indices, m = p ? p.length : this.vertexCount;
- for (l = 0; l < m;) {
- p ? (h = p[l++],
- u = p[l++],
- c = p[l++]) : (h = l++,
- u = l++,
- c = l++);
- var g = r[2 * h]
- , _ = r[2 * u]
- , v = r[2 * c]
- , y = r[2 * h + 1]
- , x = r[2 * u + 1]
- , b = r[2 * c + 1]
- , w = i[3 * h]
- , T = i[3 * u]
- , S = i[3 * c]
- , M = i[3 * h + 1]
- , A = i[3 * u + 1]
- , E = i[3 * c + 1]
- , C = i[3 * h + 2]
- , D = T - w
- , L = S - w
- , P = A - M
- , O = E - M
- , N = i[3 * u + 2] - C
- , I = i[3 * c + 2] - C
- , R = _ - g
- , B = v - g
- , F = x - y
- , z = b - y
- , G = 1 / (R * z - F * B);
- d[0] = (z * D - F * L) * G,
- d[1] = (z * P - F * O) * G,
- d[2] = (z * N - F * I) * G,
- f[0] = (R * L - B * D) * G,
- f[1] = (R * O - B * P) * G,
- f[2] = (R * I - B * N) * G,
- zr(o[h], o[h], d),
- zr(o[u], o[u], d),
- zr(o[c], o[c], d),
- zr(s[h], s[h], f),
- zr(s[u], s[u], f),
- zr(s[c], s[c], f)
- }
- var U = Fr()
- , k = Fr()
- , V = Fr();
- for (l = 0; l < e; l++) {
- V[0] = a[3 * l],
- V[1] = a[3 * l + 1],
- V[2] = a[3 * l + 2];
- var H = o[l];
- Qe.scale(U, V, Qe.dot(V, H)),
- Qe.sub(U, H, U),
- Qe.normalize(U, U),
- Qe.cross(k, V, H),
- n[4 * l] = U[0],
- n[4 * l + 1] = U[1],
- n[4 * l + 2] = U[2],
- n[4 * l + 3] = Qe.dot(k, s[l]) < 0 ? -1 : 1
- }
- this.dirty()
- } else
- console.warn("Geometry without texcoords can't generate tangents.")
- }
- },
- isUniqueVertex: function () {
- return !this.isUseIndices() || this.vertexCount === this.indices.length
- },
- generateUniqueVertex: function () {
- if (this.vertexCount && this.indices) {
- this.indices.length > 65535 && (this.indices = new U.Uint32Array(this.indices));
- for (var e = this.attributes, t = this.indices, r = this.getEnabledAttributes(), i = {}, n = 0; n < r.length; n++)
- i[l = r[n]] = e[l].value,
- e[l].init(this.indices.length);
- for (var a = 0, o = 0; o < t.length; o++) {
- var s = t[o];
- for (n = 0; n < r.length; n++)
- for (var l, h = e[l = r[n]].value, u = e[l].size, c = 0; c < u; c++)
- h[a * u + c] = i[l][s * u + c];
- t[o] = a,
- a++
- }
- this.dirty()
- }
- },
- generateBarycentric: function () {
- if (this.vertexCount) {
- this.isUniqueVertex() || this.generateUniqueVertex();
- var e = this.attributes
- , t = e.barycentric.value
- , r = this.indices;
- if (!t || t.length !== 3 * r.length) {
- t = e.barycentric.value = new Float32Array(3 * r.length);
- for (var i = 0; i < (r ? r.length : this.vertexCount / 3);)
- for (var n = 0; n < 3; n++)
- t[3 * (r ? r[i++] : 3 * i + n) + n] = 1;
- this.dirty()
- }
- }
- },
- applyTransform: function (e) {
- var t = this.attributes
- , r = t.position.value
- , i = t.normal.value
- , n = t.tangent.value;
- e = e.array;
- var a = Ye.create();
- Ye.invert(a, e),
- Ye.transpose(a, a);
- var o = Qe.transformMat4
- , s = Qe.forEach;
- s(r, 3, 0, null, o, e),
- i && s(i, 3, 0, null, o, a),
- n && s(n, 4, 0, null, o, a),
- this.boundingBox && this.updateBoundingBox()
- },
- dispose: function (e) {
- var t = this._cache;
- t.use(e.__uid__);
- var r = t.get("chunks");
- if (r)
- for (var i = 0; i < r.length; i++) {
- for (var n = r[i], a = 0; a < n.attributeBuffers.length; a++) {
- var o = n.attributeBuffers[a];
- e.gl.deleteBuffer(o.buffer)
- }
- n.indicesBuffer && e.gl.deleteBuffer(n.indicesBuffer.buffer)
- }
- if (this.__vaoCache) {
- var s = e.getGLExtension("OES_vertex_array_object");
- for (var l in this.__vaoCache) {
- var h = this.__vaoCache[l].vao;
- h && s.deleteVertexArrayOES(h)
- }
- }
- this.__vaoCache = {},
- t.deleteContext(e.__uid__)
- }
- });
- kr.STATIC_DRAW = Br.STATIC_DRAW,
- kr.DYNAMIC_DRAW = Br.DYNAMIC_DRAW,
- kr.STREAM_DRAW = Br.STREAM_DRAW,
- kr.AttributeBuffer = Br.AttributeBuffer,
- kr.IndicesBuffer = Br.IndicesBuffer,
- kr.Attribute = Ur;
- const Vr = kr;
- var Hr = "@export clay.header."
- , Wr = "@end"
- , jr = ":unconfigurable;";
- const Xr = [Hr + "directional_light", "uniform vec3 directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]" + jr, "uniform vec3 directionalLightColor[DIRECTIONAL_LIGHT_COUNT]" + jr, Wr, Hr + "ambient_light", "uniform vec3 ambientLightColor[AMBIENT_LIGHT_COUNT]" + jr, Wr, Hr + "ambient_sh_light", "uniform vec3 ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]" + jr, "uniform vec3 ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]" + jr, "vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}", Wr, Hr + "ambient_cubemap_light", "uniform vec3 ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]" + jr, "uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]" + jr, "uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]" + jr, Wr, Hr + "point_light", "uniform vec3 pointLightPosition[POINT_LIGHT_COUNT]" + jr, "uniform float pointLightRange[POINT_LIGHT_COUNT]" + jr, "uniform vec3 pointLightColor[POINT_LIGHT_COUNT]" + jr, Wr, Hr + "spot_light", "uniform vec3 spotLightPosition[SPOT_LIGHT_COUNT]" + jr, "uniform vec3 spotLightDirection[SPOT_LIGHT_COUNT]" + jr, "uniform float spotLightRange[SPOT_LIGHT_COUNT]" + jr, "uniform float spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]" + jr, "uniform float spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]" + jr, "uniform float spotLightFalloffFactor[SPOT_LIGHT_COUNT]" + jr, "uniform vec3 spotLightColor[SPOT_LIGHT_COUNT]" + jr, Wr].join("\n");
- Xe.import(Xr);
- const qr = sr.extend((function () {
- return {
- color: [1, 1, 1],
- intensity: 1,
- castShadow: !0,
- shadowResolution: 512,
- group: 0
- }
- }
- ), {
- type: "",
- clone: function () {
- var e = sr.prototype.clone.call(this);
- return e.color = Array.prototype.slice.call(this.color),
- e.intensity = this.intensity,
- e.castShadow = this.castShadow,
- e.shadowResolution = this.shadowResolution,
- e
- }
- });
- var Zr, Yr, Kr, Qr, Jr = function (e, t) {
- this.normal = e || new vt(0, 1, 0),
- this.distance = t || 0
- };
- Jr.prototype = {
- constructor: Jr,
- distanceToPoint: function (e) {
- return Qe.dot(e.array, this.normal.array) - this.distance
- },
- projectPoint: function (e, t) {
- t || (t = new vt);
- var r = this.distanceToPoint(e);
- return Qe.scaleAndAdd(t.array, e.array, this.normal.array, -r),
- t._dirty = !0,
- t
- },
- normalize: function () {
- var e = 1 / Qe.len(this.normal.array);
- Qe.scale(this.normal.array, e),
- this.distance *= e
- },
- intersectFrustum: function (e) {
- for (var t = e.vertices, r = this.normal.array, i = Qe.dot(t[0].array, r) > this.distance, n = 1; n < 8; n++)
- if (Qe.dot(t[n].array, r) > this.distance != i)
- return !0
- },
- intersectLine: (Qr = Qe.create(),
- function (e, t, r) {
- var i = this.distanceToPoint(e)
- , n = this.distanceToPoint(t);
- if (i > 0 && n > 0 || i < 0 && n < 0)
- return null;
- var a = this.normal.array
- , o = this.distance
- , s = e.array;
- Qe.sub(Qr, t.array, e.array),
- Qe.normalize(Qr, Qr);
- var l = Qe.dot(a, Qr);
- if (0 === l)
- return null;
- r || (r = new vt);
- var h = (Qe.dot(a, s) - o) / l;
- return Qe.scaleAndAdd(r.array, s, Qr, -h),
- r._dirty = !0,
- r
- }
- ),
- applyTransform: (Zr = Ye.create(),
- Yr = Et.create(),
- Kr = Et.create(),
- Kr[3] = 1,
- function (e) {
- e = e.array,
- Qe.scale(Kr, this.normal.array, this.distance),
- Et.transformMat4(Kr, Kr, e),
- this.distance = Qe.dot(Kr, this.normal.array),
- Ye.invert(Zr, e),
- Ye.transpose(Zr, Zr),
- Yr[3] = 0,
- Qe.copy(Yr, this.normal.array),
- Et.transformMat4(Yr, Yr, Zr),
- Qe.copy(this.normal.array, Yr)
- }
- ),
- copy: function (e) {
- Qe.copy(this.normal.array, e.normal.array),
- this.normal._dirty = !0,
- this.distance = e.distance
- },
- clone: function () {
- var e = new Jr;
- return e.copy(this),
- e
- }
- };
- const $r = Jr;
- var ei, ti = Qe.set, ri = Qe.copy, ii = Qe.transformMat4, ni = Math.min, ai = Math.max, oi = function () {
- this.planes = [];
- for (var e = 0; e < 6; e++)
- this.planes.push(new $r);
- for (this.boundingBox = new ir,
- this.vertices = [],
- e = 0; e < 8; e++)
- this.vertices[e] = Qe.fromValues(0, 0, 0)
- };
- oi.prototype = {
- setFromProjection: function (e) {
- var t = this.planes
- , r = e.array
- , i = r[0]
- , n = r[1]
- , a = r[2]
- , o = r[3]
- , s = r[4]
- , l = r[5]
- , h = r[6]
- , u = r[7]
- , c = r[8]
- , d = r[9]
- , f = r[10]
- , p = r[11]
- , m = r[12]
- , g = r[13]
- , _ = r[14]
- , v = r[15];
- ti(t[0].normal.array, o - i, u - s, p - c),
- t[0].distance = -(v - m),
- t[0].normalize(),
- ti(t[1].normal.array, o + i, u + s, p + c),
- t[1].distance = -(v + m),
- t[1].normalize(),
- ti(t[2].normal.array, o + n, u + l, p + d),
- t[2].distance = -(v + g),
- t[2].normalize(),
- ti(t[3].normal.array, o - n, u - l, p - d),
- t[3].distance = -(v - g),
- t[3].normalize(),
- ti(t[4].normal.array, o - a, u - h, p - f),
- t[4].distance = -(v - _),
- t[4].normalize(),
- ti(t[5].normal.array, o + a, u + h, p + f),
- t[5].distance = -(v + _),
- t[5].normalize();
- var y = this.boundingBox
- , x = this.vertices;
- if (0 === v) {
- var b = l / i
- , w = -_ / (f - 1)
- , T = -_ / (f + 1)
- , S = -T / l
- , M = -w / l;
- y.min.set(-S * b, -S, T),
- y.max.set(S * b, S, w),
- ti(x[0], -S * b, -S, T),
- ti(x[1], -S * b, S, T),
- ti(x[2], S * b, -S, T),
- ti(x[3], S * b, S, T),
- ti(x[4], -M * b, -M, w),
- ti(x[5], -M * b, M, w),
- ti(x[6], M * b, -M, w),
- ti(x[7], M * b, M, w)
- } else {
- var A = (-1 - m) / i
- , E = (1 - m) / i
- , C = (1 - g) / l
- , D = (-1 - g) / l
- , L = (-1 - _) / f
- , P = (1 - _) / f;
- y.min.set(Math.min(A, E), Math.min(D, C), Math.min(P, L)),
- y.max.set(Math.max(E, A), Math.max(C, D), Math.max(L, P));
- var O = y.min.array
- , N = y.max.array;
- ti(x[0], O[0], O[1], O[2]),
- ti(x[1], O[0], N[1], O[2]),
- ti(x[2], N[0], O[1], O[2]),
- ti(x[3], N[0], N[1], O[2]),
- ti(x[4], O[0], O[1], N[2]),
- ti(x[5], O[0], N[1], N[2]),
- ti(x[6], N[0], O[1], N[2]),
- ti(x[7], N[0], N[1], N[2])
- }
- },
- getTransformedBoundingBox: (ei = Qe.create(),
- function (e, t) {
- var r = this.vertices
- , i = t.array
- , n = e.min
- , a = e.max
- , o = n.array
- , s = a.array
- , l = r[0];
- ii(ei, l, i),
- ri(o, ei),
- ri(s, ei);
- for (var h = 1; h < 8; h++)
- l = r[h],
- ii(ei, l, i),
- o[0] = ni(ei[0], o[0]),
- o[1] = ni(ei[1], o[1]),
- o[2] = ni(ei[2], o[2]),
- s[0] = ai(ei[0], s[0]),
- s[1] = ai(ei[1], s[1]),
- s[2] = ai(ei[2], s[2]);
- return n._dirty = !0,
- a._dirty = !0,
- e
- }
- )
- };
- const si = oi;
- var li;
- const hi = sr.extend((function () {
- return {
- projectionMatrix: new Ht,
- invProjectionMatrix: new Ht,
- viewMatrix: new Ht,
- frustum: new si
- }
- }
- ), (function () {
- this.update(!0)
- }
- ), {
- update: function (e) {
- sr.prototype.update.call(this, e),
- Ht.invert(this.viewMatrix, this.worldTransform),
- this.updateProjectionMatrix(),
- Ht.invert(this.invProjectionMatrix, this.projectionMatrix),
- this.frustum.setFromProjection(this.projectionMatrix)
- },
- setViewMatrix: function (e) {
- Ht.copy(this.viewMatrix, e),
- Ht.invert(this.worldTransform, e),
- this.decomposeWorldTransform()
- },
- decomposeProjectionMatrix: function () { },
- setProjectionMatrix: function (e) {
- Ht.copy(this.projectionMatrix, e),
- Ht.invert(this.invProjectionMatrix, e),
- this.decomposeProjectionMatrix()
- },
- updateProjectionMatrix: function () { },
- castRay: (li = Et.create(),
- function (e, t) {
- var r = void 0 !== t ? t : new Mt
- , i = e.array[0]
- , n = e.array[1];
- return Et.set(li, i, n, -1, 1),
- Et.transformMat4(li, li, this.invProjectionMatrix.array),
- Et.transformMat4(li, li, this.worldTransform.array),
- Qe.scale(r.origin.array, li, 1 / li[3]),
- Et.set(li, i, n, 1, 1),
- Et.transformMat4(li, li, this.invProjectionMatrix.array),
- Et.transformMat4(li, li, this.worldTransform.array),
- Qe.scale(li, li, 1 / li[3]),
- Qe.sub(r.direction.array, li, r.origin.array),
- Qe.normalize(r.direction.array, r.direction.array),
- r.direction._dirty = !0,
- r.origin._dirty = !0,
- r
- }
- )
- });
- var ui, ci, di = Ye.create(), fi = Ye.create(), pi = {};
- function mi(e) {
- var t = []
- , r = Object.keys(e);
- r.sort();
- for (var i = 0; i < r.length; i++) {
- var n = r[i];
- t.push(n + " " + e[n])
- }
- var a = t.join("\n");
- if (pi[a])
- return pi[a];
- var o = f.genGUID();
- return pi[a] = o,
- o
- }
- function gi() {
- this.opaque = [],
- this.transparent = [],
- this._opaqueCount = 0,
- this._transparentCount = 0
- }
- function _i(e, t) {
- if (t.castShadow && !e.castShadow)
- return !0
- }
- gi.prototype.startCount = function () {
- this._opaqueCount = 0,
- this._transparentCount = 0
- }
- ,
- gi.prototype.add = function (e, t) {
- t ? this.transparent[this._transparentCount++] = e : this.opaque[this._opaqueCount++] = e
- }
- ,
- gi.prototype.endCount = function () {
- this.transparent.length = this._transparentCount,
- this.opaque.length = this._opaqueCount
- }
- ;
- const vi = sr.extend((function () {
- return {
- material: null,
- lights: [],
- viewBoundingBoxLastFrame: new ir,
- shadowUniforms: {},
- _cameraList: [],
- _lightUniforms: {},
- _previousLightNumber: {},
- _lightNumber: {},
- _lightProgramKeys: {},
- _nodeRepository: {},
- _renderLists: new W(20)
- }
- }
- ), (function () {
- this._scene = this
- }
- ), {
- addToScene: function (e) {
- e instanceof hi ? (this._cameraList.length > 0 && console.warn("Found multiple camera in one scene. Use the fist one."),
- this._cameraList.push(e)) : e instanceof qr && this.lights.push(e),
- e.name && (this._nodeRepository[e.name] = e)
- },
- removeFromScene: function (e) {
- var t;
- e instanceof hi ? (t = this._cameraList.indexOf(e)) >= 0 && this._cameraList.splice(t, 1) : e instanceof qr && (t = this.lights.indexOf(e)) >= 0 && this.lights.splice(t, 1),
- e.name && delete this._nodeRepository[e.name]
- },
- getNode: function (e) {
- return this._nodeRepository[e]
- },
- setMainCamera: function (e) {
- var t = this._cameraList.indexOf(e);
- t >= 0 && this._cameraList.splice(t, 1),
- this._cameraList.unshift(e)
- },
- getMainCamera: function () {
- return this._cameraList[0]
- },
- getLights: function () {
- return this.lights
- },
- updateLights: function () {
- var e = this.lights;
- this._previousLightNumber = this._lightNumber;
- for (var t = {}, r = 0; r < e.length; r++) {
- var i = e[r];
- if (!i.invisible) {
- var n = i.group;
- t[n] || (t[n] = {}),
- t[n][i.type] = t[n][i.type] || 0,
- t[n][i.type]++
- }
- }
- for (var a in this._lightNumber = t,
- t)
- this._lightProgramKeys[a] = mi(t[a]);
- this._updateLightUniforms()
- },
- cloneNode: function (e) {
- var t = e.clone()
- , r = {};
- return function e(t, i) {
- r[t.__uid__] = i;
- for (var n = 0; n < t._children.length; n++)
- e(t._children[n], i._children[n])
- }(e, t),
- t.traverse((function (e) {
- e.skeleton && (e.skeleton = e.skeleton.clone(r)),
- e.material && (e.material = e.material.clone())
- }
- )),
- t
- },
- updateRenderList: function (e, t) {
- var r = e.__uid__
- , i = this._renderLists.get(r);
- i || (i = new gi,
- this._renderLists.put(r, i)),
- i.startCount(),
- t && (this.viewBoundingBoxLastFrame.min.set(1 / 0, 1 / 0, 1 / 0),
- this.viewBoundingBoxLastFrame.max.set(-1 / 0, -1 / 0, -1 / 0));
- var n = this.material && this.material.transparent || !1;
- return this._doUpdateRenderList(this, e, n, i, t),
- i.endCount(),
- i
- },
- getRenderList: function (e) {
- return this._renderLists.get(e.__uid__)
- },
- _doUpdateRenderList: function (e, t, r, i, n) {
- if (!e.invisible)
- for (var a = 0; a < e._children.length; a++) {
- var o = e._children[a];
- if (o.isRenderable()) {
- var s = o.isSkinnedMesh() ? di : o.worldTransform.array
- , l = o.geometry;
- Ye.multiplyAffine(fi, t.viewMatrix.array, s),
- (n && !l.boundingBox || !this.isFrustumCulled(o, t, fi)) && i.add(o, o.material.transparent || r)
- }
- o._children.length > 0 && this._doUpdateRenderList(o, t, r, i, n)
- }
- },
- isFrustumCulled: (ui = new ir,
- ci = new Ht,
- function (e, t, r) {
- var i = e.boundingBox;
- if (i || (i = e.skeleton && e.skeleton.boundingBox ? e.skeleton.boundingBox : e.geometry.boundingBox),
- !i)
- return !1;
- if (ci.array = r,
- ui.transformFrom(i, ci),
- e.castShadow && this.viewBoundingBoxLastFrame.union(ui),
- e.frustumCulling) {
- if (!ui.intersectBoundingBox(t.frustum.boundingBox))
- return !0;
- ci.array = t.projectionMatrix.array,
- ui.max.array[2] > 0 && ui.min.array[2] < 0 && (ui.max.array[2] = -1e-20),
- ui.applyProjection(ci);
- var n = ui.min.array
- , a = ui.max.array;
- if (a[0] < -1 || n[0] > 1 || a[1] < -1 || n[1] > 1 || a[2] < -1 || n[2] > 1)
- return !0
- }
- return !1
- }
- ),
- _updateLightUniforms: function () {
- var e = this.lights;
- e.sort(_i);
- var t = this._lightUniforms;
- for (var r in t)
- for (var i in t[r])
- t[r][i].value.length = 0;
- for (var n = 0; n < e.length; n++) {
- var a = e[n];
- if (!a.invisible)
- for (var i in r = a.group,
- a.uniformTemplates) {
- var o = a.uniformTemplates[i]
- , s = o.value(a);
- if (null != s) {
- t[r] || (t[r] = {}),
- t[r][i] || (t[r][i] = {
- type: "",
- value: []
- });
- var l = t[r][i];
- switch (l.type = o.type + "v",
- o.type) {
- case "1i":
- case "1f":
- case "t":
- l.value.push(s);
- break;
- case "2f":
- case "3f":
- case "4f":
- for (var h = 0; h < s.length; h++)
- l.value.push(s[h]);
- break;
- default:
- console.error("Unkown light uniform type " + o.type)
- }
- }
- }
- }
- },
- getLightGroups: function () {
- var e = [];
- for (var t in this._lightNumber)
- e.push(t);
- return e
- },
- getNumberChangedLightGroups: function () {
- var e = [];
- for (var t in this._lightNumber)
- this.isLightNumberChanged(t) && e.push(t);
- return e
- },
- isLightNumberChanged: function (e) {
- var t = this._previousLightNumber
- , r = this._lightNumber;
- for (var i in r[e]) {
- if (!t[e])
- return !0;
- if (r[e][i] !== t[e][i])
- return !0
- }
- for (var i in t[e]) {
- if (!r[e])
- return !0;
- if (r[e][i] !== t[e][i])
- return !0
- }
- return !1
- },
- getLightsNumbers: function (e) {
- return this._lightNumber[e]
- },
- getProgramKey: function (e) {
- return this._lightProgramKeys[e]
- },
- setLightUniforms: function () {
- function e(e, t, r) {
- for (var i in e) {
- var n = e[i];
- if ("tv" === n.type) {
- if (!t.hasUniform(i))
- continue;
- for (var a = [], o = 0; o < n.value.length; o++) {
- var s = n.value[o]
- , l = t.takeCurrentTextureSlot(r, s);
- a.push(l)
- }
- t.setUniform(r.gl, "1iv", i, a)
- } else
- t.setUniform(r.gl, n.type, i, n.value)
- }
- }
- return function (t, r, i) {
- e(this._lightUniforms[r], t, i),
- e(this.shadowUniforms, t, i)
- }
- }(),
- dispose: function () {
- this.material = null,
- this._opaqueList = [],
- this._transparentList = [],
- this.lights = [],
- this._lightUniforms = {},
- this._lightNumber = {},
- this._nodeRepository = {}
- }
- });
- var yi = function (e) {
- this.value = e
- }
- , xi = function () {
- function e() {
- this._len = 0
- }
- return e.prototype.insert = function (e) {
- var t = new yi(e);
- return this.insertEntry(t),
- t
- }
- ,
- e.prototype.insertEntry = function (e) {
- this.head ? (this.tail.next = e,
- e.prev = this.tail,
- e.next = null,
- this.tail = e) : this.head = this.tail = e,
- this._len++
- }
- ,
- e.prototype.remove = function (e) {
- var t = e.prev
- , r = e.next;
- t ? t.next = r : this.head = r,
- r ? r.prev = t : this.tail = t,
- e.next = e.prev = null,
- this._len--
- }
- ,
- e.prototype.len = function () {
- return this._len
- }
- ,
- e.prototype.clear = function () {
- this.head = this.tail = null,
- this._len = 0
- }
- ,
- e
- }();
- const bi = function () {
- function e(e) {
- this._list = new xi,
- this._maxSize = 10,
- this._map = {},
- this._maxSize = e
- }
- return e.prototype.put = function (e, t) {
- var r = this._list
- , i = this._map
- , n = null;
- if (null == i[e]) {
- var a = r.len()
- , o = this._lastRemovedEntry;
- if (a >= this._maxSize && a > 0) {
- var s = r.head;
- r.remove(s),
- delete i[s.key],
- n = s.value,
- this._lastRemovedEntry = s
- }
- o ? o.value = t : o = new yi(t),
- o.key = e,
- r.insertEntry(o),
- i[e] = o
- }
- return n
- }
- ,
- e.prototype.get = function (e) {
- var t = this._map[e]
- , r = this._list;
- if (null != t)
- return t !== r.tail && (r.remove(t),
- r.insertEntry(t)),
- t.value
- }
- ,
- e.prototype.clear = function () {
- this._list.clear(),
- this._map = {}
- }
- ,
- e.prototype.len = function () {
- return this._list.len()
- }
- ,
- e
- }();
- var wi = Mr.isPowerOfTwo
- , Ti = ["px", "nx", "py", "ny", "pz", "nz"]
- , Si = wr.extend((function () {
- return {
- image: {
- px: null,
- nx: null,
- py: null,
- ny: null,
- pz: null,
- nz: null
- },
- pixels: {
- px: null,
- nx: null,
- py: null,
- ny: null,
- pz: null,
- nz: null
- },
- mipmaps: []
- }
- }
- ), {
- textureType: "textureCube",
- update: function (e) {
- var t = e.gl;
- t.bindTexture(t.TEXTURE_CUBE_MAP, this._cache.get("webgl_texture")),
- this.updateCommon(e);
- var r = this.format
- , i = this.type;
- t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_WRAP_S, this.getAvailableWrapS()),
- t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_WRAP_T, this.getAvailableWrapT()),
- t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_MAG_FILTER, this.getAvailableMagFilter()),
- t.texParameteri(t.TEXTURE_CUBE_MAP, t.TEXTURE_MIN_FILTER, this.getAvailableMinFilter());
- var n = e.getGLExtension("EXT_texture_filter_anisotropic");
- if (n && this.anisotropic > 1 && t.texParameterf(t.TEXTURE_CUBE_MAP, n.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic),
- 36193 === i && (e.getGLExtension("OES_texture_half_float") || (i = S)),
- this.mipmaps.length)
- for (var a = this.width, o = this.height, s = 0; s < this.mipmaps.length; s++) {
- var l = this.mipmaps[s];
- this._updateTextureData(t, l, s, a, o, r, i),
- a /= 2,
- o /= 2
- }
- else
- this._updateTextureData(t, this, 0, this.width, this.height, r, i),
- !this.NPOT && this.useMipmap && t.generateMipmap(t.TEXTURE_CUBE_MAP);
- t.bindTexture(t.TEXTURE_CUBE_MAP, null)
- },
- _updateTextureData: function (e, t, r, i, n, a, o) {
- for (var s = 0; s < 6; s++) {
- var l = Ti[s]
- , h = t.image && t.image[l];
- h ? e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + s, r, a, a, o, h) : e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + s, r, a, i, n, 0, a, o, t.pixels && t.pixels[l])
- }
- },
- generateMipmap: function (e) {
- var t = e.gl;
- this.useMipmap && !this.NPOT && (t.bindTexture(t.TEXTURE_CUBE_MAP, this._cache.get("webgl_texture")),
- t.generateMipmap(t.TEXTURE_CUBE_MAP))
- },
- bind: function (e) {
- e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP, this.getWebGLTexture(e))
- },
- unbind: function (e) {
- e.gl.bindTexture(e.gl.TEXTURE_CUBE_MAP, null)
- },
- isPowerOfTwo: function () {
- return this.image.px ? wi(this.image.px.width) && wi(this.image.px.height) : wi(this.width) && wi(this.height)
- },
- isRenderable: function () {
- return this.image.px ? Mi(this.image.px) && Mi(this.image.nx) && Mi(this.image.py) && Mi(this.image.ny) && Mi(this.image.pz) && Mi(this.image.nz) : !(!this.width || !this.height)
- },
- load: function (e, t) {
- var r = 0
- , i = this;
- return f.each(e, (function (e, n) {
- var a = U.createImage();
- t && (a.crossOrigin = t),
- a.onload = function () {
- 0 == --r && (i.dirty(),
- i.trigger("success", i))
- }
- ,
- a.onerror = function () {
- r--
- }
- ,
- r++,
- a.src = e,
- i.image[n] = a
- }
- )),
- this
- }
- });
- function Mi(e) {
- return e.width > 0 && e.height > 0
- }
- Object.defineProperty(Si.prototype, "width", {
- get: function () {
- return this.image && this.image.px ? this.image.px.width : this._width
- },
- set: function (e) {
- this.image && this.image.px ? console.warn("Texture from image can't set width") : (this._width !== e && this.dirty(),
- this._width = e)
- }
- }),
- Object.defineProperty(Si.prototype, "height", {
- get: function () {
- return this.image && this.image.px ? this.image.px.height : this._height
- },
- set: function (e) {
- this.image && this.image.px ? console.warn("Texture from image can't set height") : (this._height !== e && this.dirty(),
- this._height = e)
- }
- });
- const Ai = Si
- , Ei = hi.extend({
- fov: 50,
- aspect: 1,
- near: .1,
- far: 2e3
- }, {
- updateProjectionMatrix: function () {
- var e = this.fov / 180 * Math.PI;
- this.projectionMatrix.perspective(e, this.aspect, this.near, this.far)
- },
- decomposeProjectionMatrix: function () {
- var e = this.projectionMatrix.array
- , t = 2 * Math.atan(1 / e[5]);
- this.fov = t / Math.PI * 180,
- this.aspect = e[5] / e[0],
- this.near = e[14] / (e[10] - 1),
- this.far = e[14] / (e[10] + 1)
- },
- clone: function () {
- var e = hi.prototype.clone.call(this);
- return e.fov = this.fov,
- e.aspect = this.aspect,
- e.near = this.near,
- e.far = this.far,
- e
- }
- });
- var Ci = "framebuffer"
- , Di = "renderbuffer"
- , Li = "renderbuffer_width"
- , Pi = "renderbuffer_height"
- , Oi = "renderbuffer_attached"
- , Ni = "depthtexture_attached"
- , Ii = 36160
- , Ri = 36161
- , Bi = 36096
- , Fi = m.extend({
- depthBuffer: !0,
- viewport: null,
- _width: 0,
- _height: 0,
- _textures: null,
- _boundRenderer: null
- }, (function () {
- this._cache = new xr,
- this._textures = {}
- }
- ), {
- getTextureWidth: function () {
- return this._width
- },
- getTextureHeight: function () {
- return this._height
- },
- bind: function (e) {
- if (e.__currentFrameBuffer) {
- if (e.__currentFrameBuffer === this)
- return;
- console.warn("Renderer already bound with another framebuffer. Unbind it first")
- }
- e.__currentFrameBuffer = this;
- var t = e.gl;
- t.bindFramebuffer(Ii, this._getFrameBufferGL(e)),
- this._boundRenderer = e;
- var r = this._cache;
- r.put("viewport", e.viewport);
- var i, n, a = !1;
- for (var o in this._textures) {
- a = !0;
- var s = this._textures[o];
- s && (i = s.texture.width,
- n = s.texture.height,
- this._doAttach(e, s.texture, o, s.target))
- }
- this._width = i,
- this._height = n,
- !a && this.depthBuffer && console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),
- this.viewport ? e.setViewport(this.viewport) : e.setViewport(0, 0, i, n, 1);
- var l = r.get("attached_textures");
- if (l)
- for (var o in l)
- if (!this._textures[o]) {
- var h = l[o];
- this._doDetach(t, o, h)
- }
- if (!r.get(Ni) && this.depthBuffer) {
- r.miss(Di) && r.put(Di, t.createRenderbuffer());
- var u = r.get(Di);
- i === r.get(Li) && n === r.get(Pi) || (t.bindRenderbuffer(Ri, u),
- t.renderbufferStorage(Ri, t.DEPTH_COMPONENT16, i, n),
- r.put(Li, i),
- r.put(Pi, n),
- t.bindRenderbuffer(Ri, null)),
- r.get(Oi) || (t.framebufferRenderbuffer(Ii, Bi, Ri, u),
- r.put(Oi, !0))
- }
- },
- unbind: function (e) {
- e.__currentFrameBuffer = null,
- e.gl.bindFramebuffer(Ii, null),
- this._boundRenderer = null,
- this._cache.use(e.__uid__);
- var t = this._cache.get("viewport");
- t && e.setViewport(t),
- this.updateMipmap(e)
- },
- updateMipmap: function (e) {
- var t = e.gl;
- for (var r in this._textures) {
- var i = this._textures[r];
- if (i) {
- var n = i.texture;
- if (!n.NPOT && n.useMipmap && n.minFilter === wr.LINEAR_MIPMAP_LINEAR) {
- var a = "textureCube" === n.textureType ? 34067 : 3553;
- t.bindTexture(a, n.getWebGLTexture(e)),
- t.generateMipmap(a),
- t.bindTexture(a, null)
- }
- }
- }
- },
- checkStatus: function (e) {
- return e.checkFramebufferStatus(Ii)
- },
- _getFrameBufferGL: function (e) {
- var t = this._cache;
- return t.use(e.__uid__),
- t.miss(Ci) && t.put(Ci, e.gl.createFramebuffer()),
- t.get(Ci)
- },
- attach: function (e, t, r) {
- if (!e.width)
- throw new Error("The texture attached to color buffer is not a valid.");
- t = t || 36064,
- r = r || 3553;
- var i, n = this._boundRenderer;
- if (n && n.gl) {
- var a = this._cache;
- a.use(n.__uid__),
- i = a.get("attached_textures")
- }
- var o = this._textures[t];
- if (!o || o.target !== r || o.texture !== e || !i || null == i[t]) {
- var s = !0;
- n && (s = this._doAttach(n, e, t, r),
- this.viewport || n.setViewport(0, 0, e.width, e.height, 1)),
- s && (this._textures[t] = this._textures[t] || {},
- this._textures[t].texture = e,
- this._textures[t].target = r)
- }
- },
- _doAttach: function (e, t, r, i) {
- var n = e.gl
- , a = t.getWebGLTexture(e)
- , o = this._cache.get("attached_textures");
- if (o && o[r]) {
- var s = o[r];
- if (s.texture === t && s.target === i)
- return
- }
- var l = !0;
- if (((r = +r) === Bi || r === R) && (e.getGLExtension("WEBGL_depth_texture") || (console.error("Depth texture is not supported by the browser"),
- l = !1),
- t.format !== M && 34041 !== t.format && (console.error("The texture attached to depth buffer is not a valid."),
- l = !1),
- l)) {
- var h = this._cache.get(Di);
- h && (n.framebufferRenderbuffer(Ii, Bi, Ri, null),
- n.deleteRenderbuffer(h),
- this._cache.put(Di, !1)),
- this._cache.put(Oi, !1),
- this._cache.put(Ni, !0)
- }
- return n.framebufferTexture2D(Ii, r, i, a, 0),
- o || (o = {},
- this._cache.put("attached_textures", o)),
- o[r] = o[r] || {},
- o[r].texture = t,
- o[r].target = i,
- l
- },
- _doDetach: function (e, t, r) {
- e.framebufferTexture2D(Ii, t, r, null, 0);
- var i = this._cache.get("attached_textures");
- i && i[t] && (i[t] = null),
- t !== Bi && t !== R || this._cache.put(Ni, !1)
- },
- detach: function (e, t) {
- this._textures[e] = null,
- this._boundRenderer && (this._cache.use(this._boundRenderer.__uid__),
- this._doDetach(this._boundRenderer.gl, e, t))
- },
- dispose: function (e) {
- var t = e.gl
- , r = this._cache;
- r.use(e.__uid__);
- var i = r.get(Di);
- i && t.deleteRenderbuffer(i);
- var n = r.get(Ci);
- n && t.deleteFramebuffer(n),
- r.deleteContext(e.__uid__),
- this._textures = {}
- }
- });
- Fi.DEPTH_ATTACHMENT = Bi,
- Fi.COLOR_ATTACHMENT0 = 36064,
- Fi.STENCIL_ATTACHMENT = 36128,
- Fi.DEPTH_STENCIL_ATTACHMENT = R;
- const zi = Fi;
- var Gi = ["px", "nx", "py", "ny", "pz", "nz"];
- const Ui = m.extend((function () {
- var e = {
- position: new vt,
- far: 1e3,
- near: .1,
- texture: null,
- shadowMapPass: null
- }
- , t = e._cameras = {
- px: new Ei({
- fov: 90
- }),
- nx: new Ei({
- fov: 90
- }),
- py: new Ei({
- fov: 90
- }),
- ny: new Ei({
- fov: 90
- }),
- pz: new Ei({
- fov: 90
- }),
- nz: new Ei({
- fov: 90
- })
- };
- return t.px.lookAt(vt.POSITIVE_X, vt.NEGATIVE_Y),
- t.nx.lookAt(vt.NEGATIVE_X, vt.NEGATIVE_Y),
- t.py.lookAt(vt.POSITIVE_Y, vt.POSITIVE_Z),
- t.ny.lookAt(vt.NEGATIVE_Y, vt.NEGATIVE_Z),
- t.pz.lookAt(vt.POSITIVE_Z, vt.NEGATIVE_Y),
- t.nz.lookAt(vt.NEGATIVE_Z, vt.NEGATIVE_Y),
- e._frameBuffer = new zi,
- e
- }
- ), {
- getCamera: function (e) {
- return this._cameras[e]
- },
- render: function (e, t, r) {
- var i = e.gl;
- r || t.update();
- for (var n = this.texture.width, a = 2 * Math.atan(n / (n - .5)) / Math.PI * 180, o = 0; o < 6; o++) {
- var s = Gi[o]
- , l = this._cameras[s];
- if (vt.copy(l.position, this.position),
- l.far = this.far,
- l.near = this.near,
- l.fov = a,
- this.shadowMapPass) {
- l.update();
- var h = t.getBoundingBox();
- h.applyTransform(l.viewMatrix),
- t.viewBoundingBoxLastFrame.copy(h),
- this.shadowMapPass.render(e, t, l, !0)
- }
- this._frameBuffer.attach(this.texture, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + o),
- this._frameBuffer.bind(e),
- e.render(t, l, !0),
- this._frameBuffer.unbind(e)
- }
- },
- dispose: function (e) {
- this._frameBuffer.dispose(e)
- }
- })
- , ki = Vr.extend({
- dynamic: !1,
- widthSegments: 1,
- heightSegments: 1
- }, (function () {
- this.build()
- }
- ), {
- build: function () {
- for (var e = this.heightSegments, t = this.widthSegments, r = this.attributes, i = [], n = [], a = [], o = [], s = 0; s <= e; s++)
- for (var l = s / e, h = 0; h <= t; h++) {
- var u = h / t;
- if (i.push([2 * u - 1, 2 * l - 1, 0]),
- n && n.push([u, l]),
- a && a.push([0, 0, 1]),
- h < t && s < e) {
- var c = h + s * (t + 1);
- o.push([c, c + 1, c + t + 1]),
- o.push([c + t + 1, c + 1, c + t + 2])
- }
- }
- r.position.fromArray(i),
- r.texcoord0.fromArray(n),
- r.normal.fromArray(a),
- this.initIndicesFromArray(o),
- this.boundingBox = new ir,
- this.boundingBox.min.set(-1, -1, 0),
- this.boundingBox.max.set(1, 1, 0)
- }
- });
- var Vi = new Ht;
- function Hi(e, t, r) {
- Vi.identity();
- var i = new ki({
- widthSegments: t,
- heightSegments: r
- });
- switch (e) {
- case "px":
- Ht.translate(Vi, Vi, vt.POSITIVE_X),
- Ht.rotateY(Vi, Vi, Math.PI / 2);
- break;
- case "nx":
- Ht.translate(Vi, Vi, vt.NEGATIVE_X),
- Ht.rotateY(Vi, Vi, -Math.PI / 2);
- break;
- case "py":
- Ht.translate(Vi, Vi, vt.POSITIVE_Y),
- Ht.rotateX(Vi, Vi, -Math.PI / 2);
- break;
- case "ny":
- Ht.translate(Vi, Vi, vt.NEGATIVE_Y),
- Ht.rotateX(Vi, Vi, Math.PI / 2);
- break;
- case "pz":
- Ht.translate(Vi, Vi, vt.POSITIVE_Z);
- break;
- case "nz":
- Ht.translate(Vi, Vi, vt.NEGATIVE_Z),
- Ht.rotateY(Vi, Vi, Math.PI)
- }
- return i.applyTransform(Vi),
- i
- }
- const Wi = Vr.extend({
- dynamic: !1,
- widthSegments: 1,
- heightSegments: 1,
- depthSegments: 1,
- inside: !1
- }, (function () {
- this.build()
- }
- ), {
- build: function () {
- var e = {
- px: Hi("px", this.depthSegments, this.heightSegments),
- nx: Hi("nx", this.depthSegments, this.heightSegments),
- py: Hi("py", this.widthSegments, this.depthSegments),
- ny: Hi("ny", this.widthSegments, this.depthSegments),
- pz: Hi("pz", this.widthSegments, this.heightSegments),
- nz: Hi("nz", this.widthSegments, this.heightSegments)
- }
- , t = ["position", "texcoord0", "normal"]
- , r = 0
- , i = 0;
- for (var n in e)
- r += e[n].vertexCount,
- i += e[n].indices.length;
- for (var a = 0; a < t.length; a++)
- this.attributes[t[a]].init(r);
- this.indices = new U.Uint16Array(i);
- var o = 0
- , s = 0;
- for (var n in e) {
- var l = e[n];
- for (a = 0; a < t.length; a++)
- for (var h = t[a], u = l.attributes[h].value, c = l.attributes[h].size, d = "normal" === h, f = 0; f < u.length; f++) {
- var p = u[f];
- this.inside && d && (p = -p),
- this.attributes[h].value[f + c * s] = p
- }
- var m = l.indices.length;
- for (f = 0; f < l.indices.length; f++)
- this.indices[f + o] = s + l.indices[this.inside ? m - f - 1 : f];
- o += l.indices.length,
- s += l.vertexCount
- }
- this.boundingBox = new ir,
- this.boundingBox.max.set(1, 1, 1),
- this.boundingBox.min.set(-1, -1, -1)
- }
- });
- Xe.import("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");
- const ji = Sr.extend((function () {
- var e = new Xe({
- vertex: Xe.source("clay.skybox.vertex"),
- fragment: Xe.source("clay.skybox.fragment")
- })
- , t = new le({
- shader: e,
- depthMask: !1
- });
- return {
- scene: null,
- geometry: new Wi,
- material: t,
- environmentMap: null,
- culling: !1,
- _dummyCamera: new Ei
- }
- }
- ), (function () {
- var e = this.scene;
- e && this.attachScene(e),
- this.environmentMap && this.setEnvironmentMap(this.environmentMap)
- }
- ), {
- attachScene: function (e) {
- this.scene && this.detachScene(),
- e.skybox = this,
- this.scene = e,
- e.on("beforerender", this._beforeRenderScene, this)
- },
- detachScene: function () {
- this.scene && (this.scene.off("beforerender", this._beforeRenderScene),
- this.scene.skybox = null),
- this.scene = null
- },
- dispose: function (e) {
- this.detachScene(),
- this.geometry.dispose(e)
- },
- setEnvironmentMap: function (e) {
- "texture2D" === e.textureType ? (this.material.define("EQUIRECTANGULAR"),
- e.minFilter = wr.LINEAR) : this.material.undefine("EQUIRECTANGULAR"),
- this.material.set("environmentMap", e)
- },
- getEnvironmentMap: function () {
- return this.material.get("environmentMap")
- },
- _beforeRenderScene: function (e, t, r) {
- this.renderSkybox(e, r)
- },
- renderSkybox: function (e, t) {
- var r = this._dummyCamera;
- r.aspect = e.getViewportAspect(),
- r.fov = t.fov || 50,
- r.updateProjectionMatrix(),
- Ht.invert(r.invProjectionMatrix, r.projectionMatrix),
- r.worldTransform.copy(t.worldTransform),
- r.viewMatrix.copy(t.viewMatrix),
- this.position.copy(t.getWorldPosition()),
- this.update(),
- e.gl.disable(e.gl.BLEND),
- this.material.get("lod") > 0 ? this.material.define("fragment", "LOD") : this.material.undefine("fragment", "LOD"),
- e.renderPass([this], r)
- }
- })
- , Xi = ji;
- function qi(e) {
- return e.charCodeAt(0) + (e.charCodeAt(1) << 8) + (e.charCodeAt(2) << 16) + (e.charCodeAt(3) << 24)
- }
- var Zi = qi("DXT1")
- , Yi = qi("DXT3")
- , Ki = qi("DXT5");
- const Qi = function (e, t) {
- var r = new Int32Array(e, 0, 31);
- if (542327876 !== r[0])
- return null;
- if (4 & !r(20))
- return null;
- var i, n, a = r(21), o = r[4], s = r[3], l = 512 & r[28], h = 131072 & r[2];
- switch (a) {
- case Zi:
- i = 8,
- n = wr.COMPRESSED_RGB_S3TC_DXT1_EXT;
- break;
- case Yi:
- i = 16,
- n = wr.COMPRESSED_RGBA_S3TC_DXT3_EXT;
- break;
- case Ki:
- i = 16,
- n = wr.COMPRESSED_RGBA_S3TC_DXT5_EXT;
- break;
- default:
- return null
- }
- var u = r[1] + 4
- , c = l ? 6 : 1
- , d = 1;
- h && (d = Math.max(1, r[7]));
- for (var f = [], p = 0; p < c; p++) {
- var m = o
- , g = s;
- f[p] = new Dr({
- width: m,
- height: g,
- format: n
- });
- for (var _ = [], v = 0; v < d; v++) {
- var y = Math.max(4, m) / 4 * Math.max(4, g) / 4 * i
- , x = new Uint8Array(e, u, y);
- u += y,
- m *= .5,
- g *= .5,
- _[v] = x
- }
- f[p].pixels = _[0],
- h && (f[p].mipmaps = _)
- }
- if (!t)
- return f[0];
- t.width = f[0].width,
- t.height = f[0].height,
- t.format = f[0].format,
- t.pixels = f[0].pixels,
- t.mipmaps = f[0].mipmaps
- };
- var Ji = String.fromCharCode;
- function $i(e, t, r, i) {
- if (e[3] > 0) {
- var n = Math.pow(2, e[3] - 128 - 8 + i);
- t[r + 0] = e[0] * n,
- t[r + 1] = e[1] * n,
- t[r + 2] = e[2] * n
- } else
- t[r + 0] = 0,
- t[r + 1] = 0,
- t[r + 2] = 0;
- return t[r + 3] = 1,
- t
- }
- function en(e, t, r, i) {
- for (var n, a, o = 0, s = 0, l = i; l > 0;)
- if (e[s][0] = t[r++],
- e[s][1] = t[r++],
- e[s][2] = t[r++],
- e[s][3] = t[r++],
- 1 === e[s][0] && 1 === e[s][1] && 1 === e[s][2]) {
- for (var h = e[s][3] << o >>> 0; h > 0; h--)
- n = e[s - 1],
- (a = e[s])[0] = n[0],
- a[1] = n[1],
- a[2] = n[2],
- a[3] = n[3],
- s++,
- l--;
- o += 8
- } else
- s++,
- l--,
- o = 0;
- return r
- }
- function tn(e, t, r, i) {
- if (i < 8 | i > 32767)
- return en(e, t, r, i);
- if (2 != (n = t[r++]))
- return en(e, t, r - 1, i);
- if (e[0][1] = t[r++],
- e[0][2] = t[r++],
- n = t[r++],
- (e[0][2] << 8 >>> 0 | n) >>> 0 !== i)
- return null;
- for (var n = 0; n < 4; n++)
- for (var a = 0; a < i;) {
- var o = t[r++];
- if (o > 128) {
- o = (127 & o) >>> 0;
- for (var s = t[r++]; o--;)
- e[a++][n] = s
- } else
- for (; o--;)
- e[a++][n] = t[r++]
- }
- return r
- }
- const rn = function (e, t, r) {
- null == r && (r = 0);
- var i = new Uint8Array(e)
- , n = i.length;
- if ("#?" === function (e, t, r) {
- for (var i = "", n = 0; n < 2; n++)
- i += Ji(e[n]);
- return i
- }(i)) {
- for (var a = 2; a < n && ("\n" !== Ji(i[a]) || "\n" !== Ji(i[a + 1])); a++)
- ;
- if (!(a >= n)) {
- a += 2;
- for (var o = ""; a < n; a++) {
- var s = Ji(i[a]);
- if ("\n" === s)
- break;
- o += s
- }
- var l = o.split(" ")
- , h = parseInt(l[1])
- , u = parseInt(l[3]);
- if (u && h) {
- for (var c = a + 1, d = [], f = 0; f < u; f++) {
- d[f] = [];
- for (var p = 0; p < 4; p++)
- d[f][p] = 0
- }
- for (var m = new Float32Array(u * h * 4), g = 0, _ = 0; _ < h; _++) {
- if (!(c = tn(d, i, c, u)))
- return null;
- for (f = 0; f < u; f++)
- $i(d[f], m, g, r),
- g += 4
- }
- return t || (t = new Dr),
- t.width = u,
- t.height = h,
- t.pixels = m,
- t.type = wr.FLOAT,
- t
- }
- }
- }
- };
- var nn = {
- loadTexture: function (e, t, r, i) {
- var n;
- if ("function" == typeof t ? (i = r = t,
- t = {}) : t = t || {},
- "string" == typeof e) {
- if (e.match(/.hdr$/) || "hdr" === t.fileType)
- return n = new Dr({
- width: 0,
- height: 0,
- sRGB: !1
- }),
- nn._fetchTexture(e, (function (e) {
- rn(e, n, t.exposure),
- n.dirty(),
- r && r(n)
- }
- ), i),
- n;
- e.match(/.dds$/) || "dds" === t.fileType ? (n = new Dr({
- width: 0,
- height: 0
- }),
- nn._fetchTexture(e, (function (e) {
- Qi(e, n),
- n.dirty(),
- r && r(n)
- }
- ), i)) : ((n = new Dr).load(e),
- n.success(r),
- n.error(i))
- } else
- "object" == typeof e && void 0 !== e.px && ((n = new Ai).load(e),
- n.success(r),
- n.error(i));
- return n
- },
- loadPanorama: function (e, t, r, i, n, a) {
- var o = this;
- "function" == typeof i ? (a = n = i,
- i = {}) : i = i || {},
- nn.loadTexture(t, i, (function (t) {
- t.flipY = i.flipY || !1,
- o.panoramaToCubeMap(e, t, r, i),
- t.dispose(e),
- n && n(r)
- }
- ), a)
- },
- panoramaToCubeMap: function (e, t, r, i) {
- var n = new Ui
- , a = new Xi({
- scene: new vi
- });
- return a.setEnvironmentMap(t),
- (i = i || {}).encodeRGBM && a.material.define("fragment", "RGBM_ENCODE"),
- r.sRGB = t.sRGB,
- n.texture = r,
- n.render(e, a.scene),
- n.texture = null,
- n.dispose(e),
- r
- },
- heightToNormal: function (e, t) {
- var r = document.createElement("canvas")
- , i = r.width = e.width
- , n = r.height = e.height
- , a = r.getContext("2d");
- a.drawImage(e, 0, 0, i, n),
- t = t || !1;
- for (var o = a.getImageData(0, 0, i, n), s = a.createImageData(i, n), l = 0; l < o.data.length; l += 4) {
- if (t) {
- var h = o.data[l]
- , u = o.data[l + 1]
- , c = o.data[l + 2];
- if (Math.abs(h - u) + Math.abs(u - c) > 20)
- return console.warn("Given image is not a height map"),
- e
- }
- var d, f, p, m;
- l % (4 * i) == 0 ? (d = o.data[l],
- p = o.data[l + 4]) : l % (4 * i) == 4 * (i - 1) ? (d = o.data[l - 4],
- p = o.data[l]) : (d = o.data[l - 4],
- p = o.data[l + 4]),
- l < 4 * i ? (f = o.data[l],
- m = o.data[l + 4 * i]) : l > i * (n - 1) * 4 ? (f = o.data[l - 4 * i],
- m = o.data[l]) : (f = o.data[l - 4 * i],
- m = o.data[l + 4 * i]),
- s.data[l] = d - p + 127,
- s.data[l + 1] = f - m + 127,
- s.data[l + 2] = 255,
- s.data[l + 3] = 255
- }
- return a.putImageData(s, 0, 0),
- r
- },
- isHeightImage: function (e, t, r) {
- if (!e || !e.width || !e.height)
- return !1;
- var i = document.createElement("canvas")
- , n = i.getContext("2d")
- , a = t || 32;
- r = r || 20,
- i.width = i.height = a,
- n.drawImage(e, 0, 0, a, a);
- for (var o = n.getImageData(0, 0, a, a), s = 0; s < o.data.length; s += 4) {
- var l = o.data[s]
- , h = o.data[s + 1]
- , u = o.data[s + 2];
- if (Math.abs(l - h) + Math.abs(h - u) > r)
- return !1
- }
- return !0
- },
- _fetchTexture: function (e, t, r) {
- U.request.get({
- url: e,
- responseType: "arraybuffer",
- onload: t,
- onerror: r
- })
- },
- createChessboard: function (e, t, r, i) {
- e = e || 512,
- t = t || 64,
- r = r || "black",
- i = i || "white";
- var n = Math.ceil(e / t)
- , a = document.createElement("canvas");
- a.width = e,
- a.height = e;
- var o = a.getContext("2d");
- o.fillStyle = i,
- o.fillRect(0, 0, e, e),
- o.fillStyle = r;
- for (var s = 0; s < n; s++)
- for (var l = 0; l < n; l++)
- (l % 2 ? s % 2 : s % 2 - 1) && o.fillRect(s * t, l * t, t, t);
- return new Dr({
- image: a,
- anisotropic: 8
- })
- },
- createBlank: function (e) {
- var t = document.createElement("canvas");
- t.width = 1,
- t.height = 1;
- var r = t.getContext("2d");
- return r.fillStyle = e,
- r.fillRect(0, 0, 1, 1),
- new Dr({
- image: t
- })
- }
- };
- const an = nn;
- var on = ["mousedown", "mouseup", "mousemove", "mouseover", "mouseout", "click", "dblclick", "contextmenu"];
- function sn(e) {
- return "_on" + e
- }
- var ln = function (e) {
- var t = this;
- this._texture = new Dr({
- anisotropic: 32,
- flipY: !1,
- surface: this,
- dispose: function (e) {
- t.dispose(),
- Dr.prototype.dispose.call(this, e)
- }
- }),
- on.forEach((function (e) {
- this[sn(e)] = function (t) {
- t.triangle && this._meshes.forEach((function (r) {
- this.dispatchEvent(e, r, t.triangle, t.point)
- }
- ), this)
- }
- }
- ), this),
- this._meshes = [],
- e && this.setECharts(e),
- this.onupdate = null
- };
- ln.prototype = {
- constructor: ln,
- getTexture: function () {
- return this._texture
- },
- setECharts: function (e) {
- this._chart = e;
- var t = e.getDom();
- if (t instanceof HTMLCanvasElement) {
- var r = this
- , i = e.getZr()
- , n = i.__oldRefreshImmediately || i.refreshImmediately;
- i.refreshImmediately = function () {
- n.call(this),
- r._texture.dirty(),
- r.onupdate && r.onupdate()
- }
- ,
- i.__oldRefreshImmediately = n
- } else
- console.error("ECharts must init on canvas if it is used as texture."),
- t = document.createElement("canvas");
- this._texture.image = t,
- this._texture.dirty(),
- this.onupdate && this.onupdate()
- },
- dispatchEvent: function () {
- var e = new vt
- , t = new vt
- , r = new vt
- , i = new _e
- , n = new _e
- , a = new _e
- , o = new _e
- , s = new vt;
- return function (l, h, u, c) {
- var d = h.geometry
- , f = d.attributes.position
- , p = d.attributes.texcoord0
- , m = vt.dot
- , g = vt.cross;
- f.get(u[0], e.array),
- f.get(u[1], t.array),
- f.get(u[2], r.array),
- p.get(u[0], i.array),
- p.get(u[1], n.array),
- p.get(u[2], a.array),
- g(s, t, r);
- var _ = m(e, s)
- , v = m(c, s) / _;
- g(s, r, e);
- var y = m(c, s) / _;
- g(s, e, t);
- var x = m(c, s) / _;
- _e.scale(o, i, v),
- _e.scaleAndAdd(o, o, n, y),
- _e.scaleAndAdd(o, o, a, x);
- var b = o.x * this._chart.getWidth()
- , w = o.y * this._chart.getHeight();
- this._chart.getZr().handler.dispatch(l, {
- zrX: b,
- zrY: w
- })
- }
- }(),
- attachToMesh: function (e) {
- this._meshes.indexOf(e) >= 0 || (on.forEach((function (t) {
- e.on(t, this[sn(t)], this)
- }
- ), this),
- this._meshes.push(e))
- },
- detachFromMesh: function (e) {
- var t = this._meshes.indexOf(e);
- t >= 0 && this._meshes.splice(t, 1),
- on.forEach((function (t) {
- e.off(t, this[sn(t)])
- }
- ), this)
- },
- dispose: function () {
- this._meshes.forEach((function (e) {
- this.detachFromMesh(e)
- }
- ), this)
- }
- };
- const hn = ln
- , un = hi.extend({
- left: -1,
- right: 1,
- near: -1,
- far: 1,
- top: 1,
- bottom: -1
- }, {
- updateProjectionMatrix: function () {
- this.projectionMatrix.ortho(this.left, this.right, this.bottom, this.top, this.near, this.far)
- },
- decomposeProjectionMatrix: function () {
- var e = this.projectionMatrix.array;
- this.left = (-1 - e[12]) / e[0],
- this.right = (1 - e[12]) / e[0],
- this.top = (1 - e[13]) / e[5],
- this.bottom = (-1 - e[13]) / e[5],
- this.near = -(-1 - e[14]) / e[10],
- this.far = -(1 - e[14]) / e[10]
- },
- clone: function () {
- var e = hi.prototype.clone.call(this);
- return e.left = this.left,
- e.right = this.right,
- e.near = this.near,
- e.far = this.far,
- e.top = this.top,
- e.bottom = this.bottom,
- e
- }
- });
- Xe.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");
- var cn = new ki
- , dn = new Sr({
- geometry: cn,
- frustumCulling: !1
- })
- , fn = new un;
- const pn = m.extend((function () {
- return {
- fragment: "",
- outputs: null,
- material: null,
- blendWithPrevious: !1,
- clearColor: !1,
- clearDepth: !0
- }
- }
- ), (function () {
- var e = new Xe(Xe.source("clay.compositor.vertex"), this.fragment)
- , t = new le({
- shader: e
- });
- t.enableTexturesAll(),
- this.material = t
- }
- ), {
- setUniform: function (e, t) {
- this.material.setUniform(e, t)
- },
- getUniform: function (e) {
- var t = this.material.uniforms[e];
- if (t)
- return t.value
- },
- attachOutput: function (e, t) {
- this.outputs || (this.outputs = {}),
- t = t || 36064,
- this.outputs[t] = e
- },
- detachOutput: function (e) {
- for (var t in this.outputs)
- this.outputs[t] === e && (this.outputs[t] = null)
- },
- bind: function (e, t) {
- if (this.outputs)
- for (var r in this.outputs) {
- var i = this.outputs[r];
- i && t.attach(i, r)
- }
- t && t.bind(e)
- },
- unbind: function (e, t) {
- t.unbind(e)
- },
- render: function (e, t) {
- var r = e.gl;
- if (t) {
- this.bind(e, t);
- var i = e.getGLExtension("EXT_draw_buffers");
- if (i && this.outputs) {
- var n = [];
- for (var a in this.outputs)
- (a = +a) >= r.COLOR_ATTACHMENT0 && a <= r.COLOR_ATTACHMENT0 + 8 && n.push(a);
- i.drawBuffersEXT(n)
- }
- }
- this.trigger("beforerender", this, e);
- var o = this.clearDepth ? r.DEPTH_BUFFER_BIT : 0;
- if (r.depthMask(!0),
- this.clearColor) {
- o |= r.COLOR_BUFFER_BIT,
- r.colorMask(!0, !0, !0, !0);
- var s = this.clearColor;
- Array.isArray(s) && r.clearColor(s[0], s[1], s[2], s[3])
- }
- r.clear(o),
- this.blendWithPrevious ? (r.enable(r.BLEND),
- this.material.transparent = !0) : (r.disable(r.BLEND),
- this.material.transparent = !1),
- this.renderQuad(e),
- this.trigger("afterrender", this, e),
- t && this.unbind(e, t)
- },
- renderQuad: function (e) {
- dn.material = this.material,
- e.renderPass([dn], fn)
- },
- dispose: function (e) { }
- });
- var mn = {}
- , gn = ["px", "nx", "py", "ny", "pz", "nz"];
- mn.prefilterEnvironmentMap = function (e, t, r, i, n) {
- n && i || (i = mn.generateNormalDistribution(),
- n = mn.integrateBRDF(e, i));
- var a = (r = r || {}).width || 64
- , o = r.height || 64
- , s = r.type || t.type
- , l = new Ai({
- width: a,
- height: o,
- type: s,
- flipY: !1,
- mipmaps: []
- });
- l.isPowerOfTwo() || console.warn("Width and height must be power of two to enable mipmap.");
- var h = Math.min(a, o)
- , u = Math.log(h) / Math.log(2) + 1
- , c = new le({
- shader: new Xe({
- vertex: Xe.source("clay.skybox.vertex"),
- fragment: "#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"
- })
- });
- c.set("normalDistribution", i),
- r.encodeRGBM && c.define("fragment", "RGBM_ENCODE"),
- r.decodeRGBM && c.define("fragment", "RGBM_DECODE");
- var d, f = new vi;
- if ("texture2D" === t.textureType) {
- var p = new Ai({
- width: a,
- height: o,
- type: s === wr.FLOAT ? wr.HALF_FLOAT : s
- });
- an.panoramaToCubeMap(e, t, p, {
- encodeRGBM: r.decodeRGBM
- }),
- t = p
- }
- (d = new ji({
- scene: f,
- material: c
- })).material.set("environmentMap", t);
- var m = new Ui({
- texture: l
- });
- r.encodeRGBM && (s = l.type = wr.UNSIGNED_BYTE);
- for (var g = new Dr({
- width: a,
- height: o,
- type: s
- }), _ = new zi({
- depthBuffer: !1
- }), v = U[s === wr.UNSIGNED_BYTE ? "Uint8Array" : "Float32Array"], y = 0; y < u; y++) {
- l.mipmaps[y] = {
- pixels: {}
- },
- d.material.set("roughness", y / (u - 1));
- for (var x = g.width, b = 2 * Math.atan(x / (x - .5)) / Math.PI * 180, w = 0; w < gn.length; w++) {
- var T = new v(g.width * g.height * 4);
- _.attach(g),
- _.bind(e);
- var S = m.getCamera(gn[w]);
- S.fov = b,
- e.render(f, S),
- e.gl.readPixels(0, 0, g.width, g.height, wr.RGBA, s, T),
- _.unbind(e),
- l.mipmaps[y].pixels[gn[w]] = T
- }
- g.width /= 2,
- g.height /= 2,
- g.dirty()
- }
- return _.dispose(e),
- g.dispose(e),
- d.dispose(e),
- i.dispose(e),
- {
- environmentMap: l,
- brdfLookup: n,
- normalDistribution: i,
- maxMipmapLevel: u
- }
- }
- ,
- mn.integrateBRDF = function (e, t) {
- t = t || mn.generateNormalDistribution();
- var r = new zi({
- depthBuffer: !1
- })
- , i = new pn({
- fragment: "#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"
- })
- , n = new Dr({
- width: 512,
- height: 256,
- type: wr.HALF_FLOAT,
- wrapS: wr.CLAMP_TO_EDGE,
- wrapT: wr.CLAMP_TO_EDGE,
- minFilter: wr.NEAREST,
- magFilter: wr.NEAREST,
- useMipmap: !1
- });
- return i.setUniform("normalDistribution", t),
- i.setUniform("viewportSize", [512, 256]),
- i.attachOutput(n),
- i.render(e, r),
- r.dispose(e),
- n
- }
- ,
- mn.generateNormalDistribution = function (e, t) {
- for (var r = new Dr({
- width: e = e || 256,
- height: t = t || 1024,
- type: wr.FLOAT,
- minFilter: wr.NEAREST,
- magFilter: wr.NEAREST,
- wrapS: wr.CLAMP_TO_EDGE,
- wrapT: wr.CLAMP_TO_EDGE,
- useMipmap: !1
- }), i = new Float32Array(t * e * 4), n = [], a = 0; a < e; a++) {
- for (var o = a / e, s = o * o, l = 0; l < t; l++) {
- var h = (l << 16 | l >>> 16) >>> 0;
- h = (((16711935 & (h = ((252645135 & (h = ((858993459 & (h = ((1431655765 & h) << 1 | (2863311530 & h) >>> 1) >>> 0)) << 2 | (3435973836 & h) >>> 2) >>> 0)) << 4 | (4042322160 & h) >>> 4) >>> 0)) << 8 | (4278255360 & h) >>> 8) >>> 0) / 4294967296;
- var u = Math.sqrt((1 - h) / (1 + (s * s - 1) * h));
- n[l] = u
- }
- for (l = 0; l < t; l++) {
- var c = 4 * (l * e + a)
- , d = (u = n[l],
- Math.sqrt(1 - u * u))
- , f = l / t
- , p = 2 * Math.PI * f;
- i[c] = d * Math.cos(p),
- i[c + 1] = u,
- i[c + 2] = d * Math.sin(p),
- i[c + 3] = 1
- }
- }
- return r.pixels = i,
- r
- }
- ;
- const _n = mn
- , vn = qr.extend({
- cubemap: null,
- castShadow: !1,
- _normalDistribution: null,
- _brdfLookup: null
- }, {
- type: "AMBIENT_CUBEMAP_LIGHT",
- prefilter: function (e, t) {
- if (e.getGLExtension("EXT_shader_texture_lod")) {
- this._brdfLookup || (this._normalDistribution = _n.generateNormalDistribution(),
- this._brdfLookup = _n.integrateBRDF(e, this._normalDistribution));
- var r = this.cubemap;
- if (!r.__prefiltered) {
- var i = _n.prefilterEnvironmentMap(e, r, {
- encodeRGBM: !0,
- width: t,
- height: t
- }, this._normalDistribution, this._brdfLookup);
- this.cubemap = i.environmentMap,
- this.cubemap.__prefiltered = !0,
- r.dispose(e)
- }
- } else
- console.warn("Device not support textureCubeLodEXT")
- },
- getBRDFLookup: function () {
- return this._brdfLookup
- },
- uniformTemplates: {
- ambientCubemapLightColor: {
- type: "3f",
- value: function (e) {
- var t = e.color
- , r = e.intensity;
- return [t[0] * r, t[1] * r, t[2] * r]
- }
- },
- ambientCubemapLightCubemap: {
- type: "t",
- value: function (e) {
- return e.cubemap
- }
- },
- ambientCubemapLightBRDFLookup: {
- type: "t",
- value: function (e) {
- return e._brdfLookup
- }
- }
- }
- })
- , yn = qr.extend({
- castShadow: !1,
- coefficients: []
- }, (function () {
- this._coefficientsTmpArr = new U.Float32Array(27)
- }
- ), {
- type: "AMBIENT_SH_LIGHT",
- uniformTemplates: {
- ambientSHLightColor: {
- type: "3f",
- value: function (e) {
- var t = e.color
- , r = e.intensity;
- return [t[0] * r, t[1] * r, t[2] * r]
- }
- },
- ambientSHLightCoefficients: {
- type: "3f",
- value: function (e) {
- for (var t = e._coefficientsTmpArr, r = 0; r < e.coefficients.length; r++)
- t[r] = e.coefficients[r];
- return t
- }
- }
- }
- });
- var xn = {}
- , bn = ["px", "nx", "py", "ny", "pz", "nz"];
- function wn(e, t) {
- var r = e[0]
- , i = e[1]
- , n = e[2];
- return 0 === t ? 1 : 1 === t ? r : 2 === t ? i : 3 === t ? n : 4 === t ? r * n : 5 === t ? i * n : 6 === t ? r * i : 7 === t ? 3 * n * n - 1 : r * r - i * i
- }
- var Tn = {
- px: [2, 1, 0, -1, -1, 1],
- nx: [2, 1, 0, 1, -1, -1],
- py: [0, 2, 1, 1, -1, -1],
- ny: [0, 2, 1, 1, 1, 1],
- pz: [0, 1, 2, -1, -1, -1],
- nz: [0, 1, 2, 1, -1, 1]
- };
- xn.projectEnvironmentMap = function (e, t, r) {
- var i;
- (r = r || {}).lod = r.lod || 0;
- var n = new vi
- , a = 64;
- "texture2D" === t.textureType ? i = new Xi({
- scene: n,
- environmentMap: t
- }) : (a = t.image && t.image.px ? t.image.px.width : t.width,
- i = new ji({
- scene: n,
- environmentMap: t
- }));
- var o = Math.ceil(a / Math.pow(2, r.lod))
- , s = Math.ceil(a / Math.pow(2, r.lod))
- , l = new Dr({
- width: o,
- height: s
- })
- , h = new zi;
- i.material.define("fragment", "RGBM_ENCODE"),
- r.decodeRGBM && i.material.define("fragment", "RGBM_DECODE"),
- i.material.set("lod", r.lod);
- for (var u = new Ui({
- texture: l
- }), c = {}, d = 0; d < bn.length; d++) {
- c[bn[d]] = new Uint8Array(o * s * 4);
- var f = u.getCamera(bn[d]);
- f.fov = 90,
- h.attach(l),
- h.bind(e),
- e.render(n, f),
- e.gl.readPixels(0, 0, o, s, wr.RGBA, wr.UNSIGNED_BYTE, c[bn[d]]),
- h.unbind(e)
- }
- return i.dispose(e),
- h.dispose(e),
- l.dispose(e),
- function (e, t, r, i) {
- for (var n = new U.Float32Array(27), a = Qe.create(), o = Qe.create(), s = Qe.create(), l = 0; l < 9; l++) {
- for (var h = Qe.create(), u = 0; u < bn.length; u++) {
- for (var c = t[bn[u]], d = Qe.create(), f = 0, p = 0, m = Tn[bn[u]], g = 0; g < i; g++)
- for (var _ = 0; _ < r; _++) {
- a[0] = _ / (r - 1) * 2 - 1,
- a[1] = g / (i - 1) * 2 - 1,
- a[2] = -1,
- Qe.normalize(a, a),
- s[0] = a[m[0]] * m[3],
- s[1] = a[m[1]] * m[4],
- s[2] = a[m[2]] * m[5],
- o[0] = c[p++] / 255,
- o[1] = c[p++] / 255,
- o[2] = c[p++] / 255;
- var v = c[p++] / 255 * 8.12;
- o[0] *= v,
- o[1] *= v,
- o[2] *= v,
- Qe.scaleAndAdd(d, d, o, wn(s, l) * -a[2]),
- f += -a[2]
- }
- Qe.scaleAndAdd(h, h, d, 1 / f)
- }
- n[3 * l] = h[0] / 6,
- n[3 * l + 1] = h[1] / 6,
- n[3 * l + 2] = h[2] / 6
- }
- return n
- }(0, c, o, s)
- }
- ;
- const Sn = xn
- , Mn = function () {
- for (var e = 0, t = arguments.length; e < t; e++)
- if (null != arguments[e])
- return arguments[e]
- }
- , An = function (e, t) {
- return null != t.dataIndexInside ? t.dataIndexInside : null != t.dataIndex ? i.util.isArray(t.dataIndex) ? i.util.map(t.dataIndex, (function (t) {
- return e.indexOfRawIndex(t)
- }
- )) : e.indexOfRawIndex(t.dataIndex) : null != t.name ? i.util.isArray(t.name) ? i.util.map(t.name, (function (t) {
- return e.indexOfName(t)
- }
- )) : e.indexOfName(t.name) : void 0
- }
- , En = Vr.extend({
- dynamic: !1,
- widthSegments: 40,
- heightSegments: 20,
- phiStart: 0,
- phiLength: 2 * Math.PI,
- thetaStart: 0,
- thetaLength: Math.PI,
- radius: 1
- }, (function () {
- this.build()
- }
- ), {
- build: function () {
- var e = this.heightSegments
- , t = this.widthSegments
- , r = this.attributes.position
- , i = this.attributes.texcoord0
- , n = this.attributes.normal
- , a = (t + 1) * (e + 1);
- r.init(a),
- i.init(a),
- n.init(a);
- var o, s, l, h, u, c, d, f, p, m, g, _ = a > 65535 ? Uint32Array : Uint16Array, v = this.indices = new _(t * e * 6), y = this.radius, x = this.phiStart, b = this.phiLength, w = this.thetaStart, T = this.thetaLength, S = [], M = [], A = 0, E = 1 / (y = this.radius);
- for (d = 0; d <= e; d++)
- for (c = 0; c <= t; c++)
- h = c / t,
- u = d / e,
- o = -y * Math.cos(x + h * b) * Math.sin(w + u * T),
- s = y * Math.cos(w + u * T),
- l = y * Math.sin(x + h * b) * Math.sin(w + u * T),
- S[0] = o,
- S[1] = s,
- S[2] = l,
- M[0] = h,
- M[1] = u,
- r.set(A, S),
- i.set(A, M),
- S[0] *= E,
- S[1] *= E,
- S[2] *= E,
- n.set(A, S),
- A++;
- var C = t + 1
- , D = 0;
- for (d = 0; d < e; d++)
- for (c = 0; c < t; c++)
- p = d * C + c,
- f = d * C + c + 1,
- g = (d + 1) * C + c + 1,
- m = (d + 1) * C + c,
- v[D++] = f,
- v[D++] = p,
- v[D++] = g,
- v[D++] = p,
- v[D++] = m,
- v[D++] = g;
- this.boundingBox = new ir,
- this.boundingBox.max.set(y, y, y),
- this.boundingBox.min.set(-y, -y, -y)
- }
- })
- , Cn = qr.extend({
- castShadow: !1
- }, {
- type: "AMBIENT_LIGHT",
- uniformTemplates: {
- ambientLightColor: {
- type: "3f",
- value: function (e) {
- var t = e.color
- , r = e.intensity;
- return [t[0] * r, t[1] * r, t[2] * r]
- }
- }
- }
- })
- , Dn = qr.extend({
- shadowBias: .001,
- shadowSlopeScale: 2,
- shadowCascade: 1,
- cascadeSplitLogFactor: .2
- }, {
- type: "DIRECTIONAL_LIGHT",
- uniformTemplates: {
- directionalLightDirection: {
- type: "3f",
- value: function (e) {
- return e.__dir = e.__dir || new vt,
- e.__dir.copy(e.worldTransform.z).normalize().negate().array
- }
- },
- directionalLightColor: {
- type: "3f",
- value: function (e) {
- var t = e.color
- , r = e.intensity;
- return [t[0] * r, t[1] * r, t[2] * r]
- }
- }
- },
- clone: function () {
- var e = qr.prototype.clone.call(this);
- return e.shadowBias = this.shadowBias,
- e.shadowSlopeScale = this.shadowSlopeScale,
- e
- }
- })
- , Ln = qr.extend({
- range: 100,
- castShadow: !1
- }, {
- type: "POINT_LIGHT",
- uniformTemplates: {
- pointLightPosition: {
- type: "3f",
- value: function (e) {
- return e.getWorldPosition().array
- }
- },
- pointLightRange: {
- type: "1f",
- value: function (e) {
- return e.range
- }
- },
- pointLightColor: {
- type: "3f",
- value: function (e) {
- var t = e.color
- , r = e.intensity;
- return [t[0] * r, t[1] * r, t[2] * r]
- }
- }
- },
- clone: function () {
- var e = qr.prototype.clone.call(this);
- return e.range = this.range,
- e
- }
- })
- , Pn = qr.extend({
- range: 20,
- umbraAngle: 30,
- penumbraAngle: 45,
- falloffFactor: 2,
- shadowBias: .001,
- shadowSlopeScale: 2
- }, {
- type: "SPOT_LIGHT",
- uniformTemplates: {
- spotLightPosition: {
- type: "3f",
- value: function (e) {
- return e.getWorldPosition().array
- }
- },
- spotLightRange: {
- type: "1f",
- value: function (e) {
- return e.range
- }
- },
- spotLightUmbraAngleCosine: {
- type: "1f",
- value: function (e) {
- return Math.cos(e.umbraAngle * Math.PI / 180)
- }
- },
- spotLightPenumbraAngleCosine: {
- type: "1f",
- value: function (e) {
- return Math.cos(e.penumbraAngle * Math.PI / 180)
- }
- },
- spotLightFalloffFactor: {
- type: "1f",
- value: function (e) {
- return e.falloffFactor
- }
- },
- spotLightDirection: {
- type: "3f",
- value: function (e) {
- return e.__dir = e.__dir || new vt,
- e.__dir.copy(e.worldTransform.z).negate().array
- }
- },
- spotLightColor: {
- type: "3f",
- value: function (e) {
- var t = e.color
- , r = e.intensity;
- return [t[0] * r, t[1] * r, t[2] * r]
- }
- }
- },
- clone: function () {
- var e = qr.prototype.clone.call(this);
- return e.range = this.range,
- e.umbraAngle = this.umbraAngle,
- e.penumbraAngle = this.penumbraAngle,
- e.falloffFactor = this.falloffFactor,
- e.shadowBias = this.shadowBias,
- e.shadowSlopeScale = this.shadowSlopeScale,
- e
- }
- });
- var On = function (e, t, r, i) {
- e = e || 0,
- t = t || 0,
- r = r || 0,
- i = i || 0,
- this.array = Et.fromValues(e, t, r, i),
- this._dirty = !0
- };
- On.prototype = {
- constructor: On,
- add: function (e) {
- return Et.add(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- set: function (e, t, r, i) {
- return this.array[0] = e,
- this.array[1] = t,
- this.array[2] = r,
- this.array[3] = i,
- this._dirty = !0,
- this
- },
- setArray: function (e) {
- return this.array[0] = e[0],
- this.array[1] = e[1],
- this.array[2] = e[2],
- this.array[3] = e[3],
- this._dirty = !0,
- this
- },
- clone: function () {
- return new On(this.x, this.y, this.z, this.w)
- },
- copy: function (e) {
- return Et.copy(this.array, e.array),
- this._dirty = !0,
- this
- },
- dist: function (e) {
- return Et.dist(this.array, e.array)
- },
- distance: function (e) {
- return Et.distance(this.array, e.array)
- },
- div: function (e) {
- return Et.div(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- divide: function (e) {
- return Et.divide(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- dot: function (e) {
- return Et.dot(this.array, e.array)
- },
- len: function () {
- return Et.len(this.array)
- },
- length: function () {
- return Et.length(this.array)
- },
- lerp: function (e, t, r) {
- return Et.lerp(this.array, e.array, t.array, r),
- this._dirty = !0,
- this
- },
- min: function (e) {
- return Et.min(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- max: function (e) {
- return Et.max(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- mul: function (e) {
- return Et.mul(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- multiply: function (e) {
- return Et.multiply(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- negate: function () {
- return Et.negate(this.array, this.array),
- this._dirty = !0,
- this
- },
- normalize: function () {
- return Et.normalize(this.array, this.array),
- this._dirty = !0,
- this
- },
- random: function (e) {
- return Et.random(this.array, e),
- this._dirty = !0,
- this
- },
- scale: function (e) {
- return Et.scale(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- scaleAndAdd: function (e, t) {
- return Et.scaleAndAdd(this.array, this.array, e.array, t),
- this._dirty = !0,
- this
- },
- sqrDist: function (e) {
- return Et.sqrDist(this.array, e.array)
- },
- squaredDistance: function (e) {
- return Et.squaredDistance(this.array, e.array)
- },
- sqrLen: function () {
- return Et.sqrLen(this.array)
- },
- squaredLength: function () {
- return Et.squaredLength(this.array)
- },
- sub: function (e) {
- return Et.sub(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- subtract: function (e) {
- return Et.subtract(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformMat4: function (e) {
- return Et.transformMat4(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transformQuat: function (e) {
- return Et.transformQuat(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- toString: function () {
- return "[" + Array.prototype.join.call(this.array, ",") + "]"
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array)
- }
- };
- var Nn = Object.defineProperty;
- if (Nn) {
- var In = On.prototype;
- Nn(In, "x", {
- get: function () {
- return this.array[0]
- },
- set: function (e) {
- this.array[0] = e,
- this._dirty = !0
- }
- }),
- Nn(In, "y", {
- get: function () {
- return this.array[1]
- },
- set: function (e) {
- this.array[1] = e,
- this._dirty = !0
- }
- }),
- Nn(In, "z", {
- get: function () {
- return this.array[2]
- },
- set: function (e) {
- this.array[2] = e,
- this._dirty = !0
- }
- }),
- Nn(In, "w", {
- get: function () {
- return this.array[3]
- },
- set: function (e) {
- this.array[3] = e,
- this._dirty = !0
- }
- })
- }
- On.add = function (e, t, r) {
- return Et.add(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- On.set = function (e, t, r, i, n) {
- Et.set(e.array, t, r, i, n),
- e._dirty = !0
- }
- ,
- On.copy = function (e, t) {
- return Et.copy(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- On.distance = On.dist = function (e, t) {
- return Et.distance(e.array, t.array)
- }
- ,
- On.divide = On.div = function (e, t, r) {
- return Et.divide(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- On.dot = function (e, t) {
- return Et.dot(e.array, t.array)
- }
- ,
- On.len = function (e) {
- return Et.length(e.array)
- }
- ,
- On.lerp = function (e, t, r, i) {
- return Et.lerp(e.array, t.array, r.array, i),
- e._dirty = !0,
- e
- }
- ,
- On.min = function (e, t, r) {
- return Et.min(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- On.max = function (e, t, r) {
- return Et.max(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- On.multiply = On.mul = function (e, t, r) {
- return Et.multiply(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- On.negate = function (e, t) {
- return Et.negate(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- On.normalize = function (e, t) {
- return Et.normalize(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- On.random = function (e, t) {
- return Et.random(e.array, t),
- e._dirty = !0,
- e
- }
- ,
- On.scale = function (e, t, r) {
- return Et.scale(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- On.scaleAndAdd = function (e, t, r, i) {
- return Et.scaleAndAdd(e.array, t.array, r.array, i),
- e._dirty = !0,
- e
- }
- ,
- On.squaredDistance = On.sqrDist = function (e, t) {
- return Et.sqrDist(e.array, t.array)
- }
- ,
- On.squaredLength = On.sqrLen = function (e) {
- return Et.sqrLen(e.array)
- }
- ,
- On.subtract = On.sub = function (e, t, r) {
- return Et.subtract(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- On.transformMat4 = function (e, t, r) {
- return Et.transformMat4(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- On.transformQuat = function (e, t, r) {
- return Et.transformQuat(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ;
- const Rn = On;
- var Bn = {
- create: function () {
- var e = new ce(4);
- return e[0] = 1,
- e[1] = 0,
- e[2] = 0,
- e[3] = 1,
- e
- },
- clone: function (e) {
- var t = new ce(4);
- return t[0] = e[0],
- t[1] = e[1],
- t[2] = e[2],
- t[3] = e[3],
- t
- },
- copy: function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e
- },
- identity: function (e) {
- return e[0] = 1,
- e[1] = 0,
- e[2] = 0,
- e[3] = 1,
- e
- },
- transpose: function (e, t) {
- if (e === t) {
- var r = t[1];
- e[1] = t[2],
- e[2] = r
- } else
- e[0] = t[0],
- e[1] = t[2],
- e[2] = t[1],
- e[3] = t[3];
- return e
- },
- invert: function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = r * a - n * i;
- return o ? (o = 1 / o,
- e[0] = a * o,
- e[1] = -i * o,
- e[2] = -n * o,
- e[3] = r * o,
- e) : null
- },
- adjoint: function (e, t) {
- var r = t[0];
- return e[0] = t[3],
- e[1] = -t[1],
- e[2] = -t[2],
- e[3] = r,
- e
- },
- determinant: function (e) {
- return e[0] * e[3] - e[2] * e[1]
- },
- multiply: function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = r[0]
- , l = r[1]
- , h = r[2]
- , u = r[3];
- return e[0] = i * s + a * l,
- e[1] = n * s + o * l,
- e[2] = i * h + a * u,
- e[3] = n * h + o * u,
- e
- }
- };
- Bn.mul = Bn.multiply,
- Bn.rotate = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = Math.sin(r)
- , l = Math.cos(r);
- return e[0] = i * l + a * s,
- e[1] = n * l + o * s,
- e[2] = i * -s + a * l,
- e[3] = n * -s + o * l,
- e
- }
- ,
- Bn.scale = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = r[0]
- , l = r[1];
- return e[0] = i * s,
- e[1] = n * s,
- e[2] = a * l,
- e[3] = o * l,
- e
- }
- ,
- Bn.frob = function (e) {
- return Math.sqrt(Math.pow(e[0], 2) + Math.pow(e[1], 2) + Math.pow(e[2], 2) + Math.pow(e[3], 2))
- }
- ,
- Bn.LDU = function (e, t, r, i) {
- return e[2] = i[2] / i[0],
- r[0] = i[0],
- r[1] = i[1],
- r[3] = i[3] - e[2] * r[1],
- [e, t, r]
- }
- ;
- const Fn = Bn;
- var zn = function () {
- this.array = Fn.create(),
- this._dirty = !0
- };
- zn.prototype = {
- constructor: zn,
- setArray: function (e) {
- for (var t = 0; t < this.array.length; t++)
- this.array[t] = e[t];
- return this._dirty = !0,
- this
- },
- clone: function () {
- return (new zn).copy(this)
- },
- copy: function (e) {
- return Fn.copy(this.array, e.array),
- this._dirty = !0,
- this
- },
- adjoint: function () {
- return Fn.adjoint(this.array, this.array),
- this._dirty = !0,
- this
- },
- determinant: function () {
- return Fn.determinant(this.array)
- },
- identity: function () {
- return Fn.identity(this.array),
- this._dirty = !0,
- this
- },
- invert: function () {
- return Fn.invert(this.array, this.array),
- this._dirty = !0,
- this
- },
- mul: function (e) {
- return Fn.mul(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- mulLeft: function (e) {
- return Fn.mul(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- multiply: function (e) {
- return Fn.multiply(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- multiplyLeft: function (e) {
- return Fn.multiply(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- rotate: function (e) {
- return Fn.rotate(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- scale: function (e) {
- return Fn.scale(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- transpose: function () {
- return Fn.transpose(this.array, this.array),
- this._dirty = !0,
- this
- },
- toString: function () {
- return "[" + Array.prototype.join.call(this.array, ",") + "]"
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array)
- }
- },
- zn.adjoint = function (e, t) {
- return Fn.adjoint(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- zn.copy = function (e, t) {
- return Fn.copy(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- zn.determinant = function (e) {
- return Fn.determinant(e.array)
- }
- ,
- zn.identity = function (e) {
- return Fn.identity(e.array),
- e._dirty = !0,
- e
- }
- ,
- zn.invert = function (e, t) {
- return Fn.invert(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- zn.multiply = zn.mul = function (e, t, r) {
- return Fn.mul(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- zn.rotate = function (e, t, r) {
- return Fn.rotate(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- zn.scale = function (e, t, r) {
- return Fn.scale(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- zn.transpose = function (e, t) {
- return Fn.transpose(e.array, t.array),
- e._dirty = !0,
- e
- }
- ;
- const Gn = zn;
- var Un = {
- create: function () {
- var e = new ce(6);
- return e[0] = 1,
- e[1] = 0,
- e[2] = 0,
- e[3] = 1,
- e[4] = 0,
- e[5] = 0,
- e
- },
- clone: function (e) {
- var t = new ce(6);
- return t[0] = e[0],
- t[1] = e[1],
- t[2] = e[2],
- t[3] = e[3],
- t[4] = e[4],
- t[5] = e[5],
- t
- },
- copy: function (e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e[4] = t[4],
- e[5] = t[5],
- e
- },
- identity: function (e) {
- return e[0] = 1,
- e[1] = 0,
- e[2] = 0,
- e[3] = 1,
- e[4] = 0,
- e[5] = 0,
- e
- },
- invert: function (e, t) {
- var r = t[0]
- , i = t[1]
- , n = t[2]
- , a = t[3]
- , o = t[4]
- , s = t[5]
- , l = r * a - i * n;
- return l ? (l = 1 / l,
- e[0] = a * l,
- e[1] = -i * l,
- e[2] = -n * l,
- e[3] = r * l,
- e[4] = (n * s - a * o) * l,
- e[5] = (i * o - r * s) * l,
- e) : null
- },
- determinant: function (e) {
- return e[0] * e[3] - e[1] * e[2]
- },
- multiply: function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = t[4]
- , l = t[5]
- , h = r[0]
- , u = r[1]
- , c = r[2]
- , d = r[3]
- , f = r[4]
- , p = r[5];
- return e[0] = i * h + a * u,
- e[1] = n * h + o * u,
- e[2] = i * c + a * d,
- e[3] = n * c + o * d,
- e[4] = i * f + a * p + s,
- e[5] = n * f + o * p + l,
- e
- }
- };
- Un.mul = Un.multiply,
- Un.rotate = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = t[4]
- , l = t[5]
- , h = Math.sin(r)
- , u = Math.cos(r);
- return e[0] = i * u + a * h,
- e[1] = n * u + o * h,
- e[2] = i * -h + a * u,
- e[3] = n * -h + o * u,
- e[4] = s,
- e[5] = l,
- e
- }
- ,
- Un.scale = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = t[4]
- , l = t[5]
- , h = r[0]
- , u = r[1];
- return e[0] = i * h,
- e[1] = n * h,
- e[2] = a * u,
- e[3] = o * u,
- e[4] = s,
- e[5] = l,
- e
- }
- ,
- Un.translate = function (e, t, r) {
- var i = t[0]
- , n = t[1]
- , a = t[2]
- , o = t[3]
- , s = t[4]
- , l = t[5]
- , h = r[0]
- , u = r[1];
- return e[0] = i,
- e[1] = n,
- e[2] = a,
- e[3] = o,
- e[4] = i * h + a * u + s,
- e[5] = n * h + o * u + l,
- e
- }
- ,
- Un.frob = function (e) {
- return Math.sqrt(Math.pow(e[0], 2) + Math.pow(e[1], 2) + Math.pow(e[2], 2) + Math.pow(e[3], 2) + Math.pow(e[4], 2) + Math.pow(e[5], 2) + 1)
- }
- ;
- const kn = Un;
- var Vn = function () {
- this.array = kn.create(),
- this._dirty = !0
- };
- Vn.prototype = {
- constructor: Vn,
- setArray: function (e) {
- for (var t = 0; t < this.array.length; t++)
- this.array[t] = e[t];
- return this._dirty = !0,
- this
- },
- clone: function () {
- return (new Vn).copy(this)
- },
- copy: function (e) {
- return kn.copy(this.array, e.array),
- this._dirty = !0,
- this
- },
- determinant: function () {
- return kn.determinant(this.array)
- },
- identity: function () {
- return kn.identity(this.array),
- this._dirty = !0,
- this
- },
- invert: function () {
- return kn.invert(this.array, this.array),
- this._dirty = !0,
- this
- },
- mul: function (e) {
- return kn.mul(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- mulLeft: function (e) {
- return kn.mul(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- multiply: function (e) {
- return kn.multiply(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- multiplyLeft: function (e) {
- return kn.multiply(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- rotate: function (e) {
- return kn.rotate(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- scale: function (e) {
- return kn.scale(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- translate: function (e) {
- return kn.translate(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- toString: function () {
- return "[" + Array.prototype.join.call(this.array, ",") + "]"
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array)
- }
- },
- Vn.copy = function (e, t) {
- return kn.copy(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Vn.determinant = function (e) {
- return kn.determinant(e.array)
- }
- ,
- Vn.identity = function (e) {
- return kn.identity(e.array),
- e._dirty = !0,
- e
- }
- ,
- Vn.invert = function (e, t) {
- return kn.invert(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Vn.multiply = Vn.mul = function (e, t, r) {
- return kn.mul(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Vn.rotate = function (e, t, r) {
- return kn.rotate(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Vn.scale = function (e, t, r) {
- return kn.scale(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Vn.translate = function (e, t, r) {
- return kn.translate(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ;
- const Hn = Vn;
- var Wn = function () {
- this.array = Dt.create(),
- this._dirty = !0
- };
- Wn.prototype = {
- constructor: Wn,
- setArray: function (e) {
- for (var t = 0; t < this.array.length; t++)
- this.array[t] = e[t];
- return this._dirty = !0,
- this
- },
- adjoint: function () {
- return Dt.adjoint(this.array, this.array),
- this._dirty = !0,
- this
- },
- clone: function () {
- return (new Wn).copy(this)
- },
- copy: function (e) {
- return Dt.copy(this.array, e.array),
- this._dirty = !0,
- this
- },
- determinant: function () {
- return Dt.determinant(this.array)
- },
- fromMat2d: function (e) {
- return Dt.fromMat2d(this.array, e.array),
- this._dirty = !0,
- this
- },
- fromMat4: function (e) {
- return Dt.fromMat4(this.array, e.array),
- this._dirty = !0,
- this
- },
- fromQuat: function (e) {
- return Dt.fromQuat(this.array, e.array),
- this._dirty = !0,
- this
- },
- identity: function () {
- return Dt.identity(this.array),
- this._dirty = !0,
- this
- },
- invert: function () {
- return Dt.invert(this.array, this.array),
- this._dirty = !0,
- this
- },
- mul: function (e) {
- return Dt.mul(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- mulLeft: function (e) {
- return Dt.mul(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- multiply: function (e) {
- return Dt.multiply(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- multiplyLeft: function (e) {
- return Dt.multiply(this.array, e.array, this.array),
- this._dirty = !0,
- this
- },
- rotate: function (e) {
- return Dt.rotate(this.array, this.array, e),
- this._dirty = !0,
- this
- },
- scale: function (e) {
- return Dt.scale(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- translate: function (e) {
- return Dt.translate(this.array, this.array, e.array),
- this._dirty = !0,
- this
- },
- normalFromMat4: function (e) {
- return Dt.normalFromMat4(this.array, e.array),
- this._dirty = !0,
- this
- },
- transpose: function () {
- return Dt.transpose(this.array, this.array),
- this._dirty = !0,
- this
- },
- toString: function () {
- return "[" + Array.prototype.join.call(this.array, ",") + "]"
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array)
- }
- },
- Wn.adjoint = function (e, t) {
- return Dt.adjoint(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.copy = function (e, t) {
- return Dt.copy(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.determinant = function (e) {
- return Dt.determinant(e.array)
- }
- ,
- Wn.identity = function (e) {
- return Dt.identity(e.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.invert = function (e, t) {
- return Dt.invert(e.array, t.array),
- e
- }
- ,
- Wn.multiply = Wn.mul = function (e, t, r) {
- return Dt.mul(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.fromMat2d = function (e, t) {
- return Dt.fromMat2d(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.fromMat4 = function (e, t) {
- return Dt.fromMat4(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.fromQuat = function (e, t) {
- return Dt.fromQuat(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.normalFromMat4 = function (e, t) {
- return Dt.normalFromMat4(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.rotate = function (e, t, r) {
- return Dt.rotate(e.array, t.array, r),
- e._dirty = !0,
- e
- }
- ,
- Wn.scale = function (e, t, r) {
- return Dt.scale(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.transpose = function (e, t) {
- return Dt.transpose(e.array, t.array),
- e._dirty = !0,
- e
- }
- ,
- Wn.translate = function (e, t, r) {
- return Dt.translate(e.array, t.array, r.array),
- e._dirty = !0,
- e
- }
- ;
- const jn = Wn;
- var Xn = {
- linear: function (e) {
- return e
- },
- quadraticIn: function (e) {
- return e * e
- },
- quadraticOut: function (e) {
- return e * (2 - e)
- },
- quadraticInOut: function (e) {
- return (e *= 2) < 1 ? .5 * e * e : -.5 * (--e * (e - 2) - 1)
- },
- cubicIn: function (e) {
- return e * e * e
- },
- cubicOut: function (e) {
- return --e * e * e + 1
- },
- cubicInOut: function (e) {
- return (e *= 2) < 1 ? .5 * e * e * e : .5 * ((e -= 2) * e * e + 2)
- },
- quarticIn: function (e) {
- return e * e * e * e
- },
- quarticOut: function (e) {
- return 1 - --e * e * e * e
- },
- quarticInOut: function (e) {
- return (e *= 2) < 1 ? .5 * e * e * e * e : -.5 * ((e -= 2) * e * e * e - 2)
- },
- quinticIn: function (e) {
- return e * e * e * e * e
- },
- quinticOut: function (e) {
- return --e * e * e * e * e + 1
- },
- quinticInOut: function (e) {
- return (e *= 2) < 1 ? .5 * e * e * e * e * e : .5 * ((e -= 2) * e * e * e * e + 2)
- },
- sinusoidalIn: function (e) {
- return 1 - Math.cos(e * Math.PI / 2)
- },
- sinusoidalOut: function (e) {
- return Math.sin(e * Math.PI / 2)
- },
- sinusoidalInOut: function (e) {
- return .5 * (1 - Math.cos(Math.PI * e))
- },
- exponentialIn: function (e) {
- return 0 === e ? 0 : Math.pow(1024, e - 1)
- },
- exponentialOut: function (e) {
- return 1 === e ? 1 : 1 - Math.pow(2, -10 * e)
- },
- exponentialInOut: function (e) {
- return 0 === e ? 0 : 1 === e ? 1 : (e *= 2) < 1 ? .5 * Math.pow(1024, e - 1) : .5 * (2 - Math.pow(2, -10 * (e - 1)))
- },
- circularIn: function (e) {
- return 1 - Math.sqrt(1 - e * e)
- },
- circularOut: function (e) {
- return Math.sqrt(1 - --e * e)
- },
- circularInOut: function (e) {
- return (e *= 2) < 1 ? -.5 * (Math.sqrt(1 - e * e) - 1) : .5 * (Math.sqrt(1 - (e -= 2) * e) + 1)
- },
- elasticIn: function (e) {
- var t, r = .1;
- return 0 === e ? 0 : 1 === e ? 1 : (!r || r < 1 ? (r = 1,
- t = .1) : t = .4 * Math.asin(1 / r) / (2 * Math.PI),
- -r * Math.pow(2, 10 * (e -= 1)) * Math.sin((e - t) * (2 * Math.PI) / .4))
- },
- elasticOut: function (e) {
- var t, r = .1;
- return 0 === e ? 0 : 1 === e ? 1 : (!r || r < 1 ? (r = 1,
- t = .1) : t = .4 * Math.asin(1 / r) / (2 * Math.PI),
- r * Math.pow(2, -10 * e) * Math.sin((e - t) * (2 * Math.PI) / .4) + 1)
- },
- elasticInOut: function (e) {
- var t, r = .1;
- return 0 === e ? 0 : 1 === e ? 1 : (!r || r < 1 ? (r = 1,
- t = .1) : t = .4 * Math.asin(1 / r) / (2 * Math.PI),
- (e *= 2) < 1 ? r * Math.pow(2, 10 * (e -= 1)) * Math.sin((e - t) * (2 * Math.PI) / .4) * -.5 : r * Math.pow(2, -10 * (e -= 1)) * Math.sin((e - t) * (2 * Math.PI) / .4) * .5 + 1)
- },
- backIn: function (e) {
- var t = 1.70158;
- return e * e * ((t + 1) * e - t)
- },
- backOut: function (e) {
- var t = 1.70158;
- return --e * e * ((t + 1) * e + t) + 1
- },
- backInOut: function (e) {
- var t = 2.5949095;
- return (e *= 2) < 1 ? e * e * ((t + 1) * e - t) * .5 : .5 * ((e -= 2) * e * ((t + 1) * e + t) + 2)
- },
- bounceIn: function (e) {
- return 1 - Xn.bounceOut(1 - e)
- },
- bounceOut: function (e) {
- return e < 1 / 2.75 ? 7.5625 * e * e : e < 2 / 2.75 ? 7.5625 * (e -= 1.5 / 2.75) * e + .75 : e < 2.5 / 2.75 ? 7.5625 * (e -= 2.25 / 2.75) * e + .9375 : 7.5625 * (e -= 2.625 / 2.75) * e + .984375
- },
- bounceInOut: function (e) {
- return e < .5 ? .5 * Xn.bounceIn(2 * e) : .5 * Xn.bounceOut(2 * e - 1) + .5
- }
- };
- const qn = Xn
- , Zn = function () {
- function e(e) {
- this._initialized = !1,
- this._startTime = 0,
- this._pausedTime = 0,
- this._paused = !1,
- this._life = e.life || 1e3,
- this._delay = e.delay || 0,
- this.loop = null != e.loop && e.loop,
- this.gap = e.gap || 0,
- this.easing = e.easing || "linear",
- this.onframe = e.onframe,
- this.ondestroy = e.ondestroy,
- this.onrestart = e.onrestart
- }
- return e.prototype.step = function (e, t) {
- if (this._initialized || (this._startTime = e + this._delay,
- this._initialized = !0),
- !this._paused) {
- var r = (e - this._startTime - this._pausedTime) / this._life;
- r < 0 && (r = 0),
- r = Math.min(r, 1);
- var i = this.easing
- , n = "string" == typeof i ? qn[i] : i
- , a = "function" == typeof n ? n(r) : r;
- if (this.onframe && this.onframe(a),
- 1 === r) {
- if (!this.loop)
- return !0;
- this._restart(e),
- this.onrestart && this.onrestart()
- }
- return !1
- }
- this._pausedTime += t
- }
- ,
- e.prototype._restart = function (e) {
- var t = (e - this._startTime - this._pausedTime) % this._life;
- this._startTime = e - t + this.gap,
- this._pausedTime = 0
- }
- ,
- e.prototype.pause = function () {
- this._paused = !0
- }
- ,
- e.prototype.resume = function () {
- this._paused = !1
- }
- ,
- e
- }();
- var Yn = {
- transparent: [0, 0, 0, 0],
- aliceblue: [240, 248, 255, 1],
- antiquewhite: [250, 235, 215, 1],
- aqua: [0, 255, 255, 1],
- aquamarine: [127, 255, 212, 1],
- azure: [240, 255, 255, 1],
- beige: [245, 245, 220, 1],
- bisque: [255, 228, 196, 1],
- black: [0, 0, 0, 1],
- blanchedalmond: [255, 235, 205, 1],
- blue: [0, 0, 255, 1],
- blueviolet: [138, 43, 226, 1],
- brown: [165, 42, 42, 1],
- burlywood: [222, 184, 135, 1],
- cadetblue: [95, 158, 160, 1],
- chartreuse: [127, 255, 0, 1],
- chocolate: [210, 105, 30, 1],
- coral: [255, 127, 80, 1],
- cornflowerblue: [100, 149, 237, 1],
- cornsilk: [255, 248, 220, 1],
- crimson: [220, 20, 60, 1],
- cyan: [0, 255, 255, 1],
- darkblue: [0, 0, 139, 1],
- darkcyan: [0, 139, 139, 1],
- darkgoldenrod: [184, 134, 11, 1],
- darkgray: [169, 169, 169, 1],
- darkgreen: [0, 100, 0, 1],
- darkgrey: [169, 169, 169, 1],
- darkkhaki: [189, 183, 107, 1],
- darkmagenta: [139, 0, 139, 1],
- darkolivegreen: [85, 107, 47, 1],
- darkorange: [255, 140, 0, 1],
- darkorchid: [153, 50, 204, 1],
- darkred: [139, 0, 0, 1],
- darksalmon: [233, 150, 122, 1],
- darkseagreen: [143, 188, 143, 1],
- darkslateblue: [72, 61, 139, 1],
- darkslategray: [47, 79, 79, 1],
- darkslategrey: [47, 79, 79, 1],
- darkturquoise: [0, 206, 209, 1],
- darkviolet: [148, 0, 211, 1],
- deeppink: [255, 20, 147, 1],
- deepskyblue: [0, 191, 255, 1],
- dimgray: [105, 105, 105, 1],
- dimgrey: [105, 105, 105, 1],
- dodgerblue: [30, 144, 255, 1],
- firebrick: [178, 34, 34, 1],
- floralwhite: [255, 250, 240, 1],
- forestgreen: [34, 139, 34, 1],
- fuchsia: [255, 0, 255, 1],
- gainsboro: [220, 220, 220, 1],
- ghostwhite: [248, 248, 255, 1],
- gold: [255, 215, 0, 1],
- goldenrod: [218, 165, 32, 1],
- gray: [128, 128, 128, 1],
- green: [0, 128, 0, 1],
- greenyellow: [173, 255, 47, 1],
- grey: [128, 128, 128, 1],
- honeydew: [240, 255, 240, 1],
- hotpink: [255, 105, 180, 1],
- indianred: [205, 92, 92, 1],
- indigo: [75, 0, 130, 1],
- ivory: [255, 255, 240, 1],
- khaki: [240, 230, 140, 1],
- lavender: [230, 230, 250, 1],
- lavenderblush: [255, 240, 245, 1],
- lawngreen: [124, 252, 0, 1],
- lemonchiffon: [255, 250, 205, 1],
- lightblue: [173, 216, 230, 1],
- lightcoral: [240, 128, 128, 1],
- lightcyan: [224, 255, 255, 1],
- lightgoldenrodyellow: [250, 250, 210, 1],
- lightgray: [211, 211, 211, 1],
- lightgreen: [144, 238, 144, 1],
- lightgrey: [211, 211, 211, 1],
- lightpink: [255, 182, 193, 1],
- lightsalmon: [255, 160, 122, 1],
- lightseagreen: [32, 178, 170, 1],
- lightskyblue: [135, 206, 250, 1],
- lightslategray: [119, 136, 153, 1],
- lightslategrey: [119, 136, 153, 1],
- lightsteelblue: [176, 196, 222, 1],
- lightyellow: [255, 255, 224, 1],
- lime: [0, 255, 0, 1],
- limegreen: [50, 205, 50, 1],
- linen: [250, 240, 230, 1],
- magenta: [255, 0, 255, 1],
- maroon: [128, 0, 0, 1],
- mediumaquamarine: [102, 205, 170, 1],
- mediumblue: [0, 0, 205, 1],
- mediumorchid: [186, 85, 211, 1],
- mediumpurple: [147, 112, 219, 1],
- mediumseagreen: [60, 179, 113, 1],
- mediumslateblue: [123, 104, 238, 1],
- mediumspringgreen: [0, 250, 154, 1],
- mediumturquoise: [72, 209, 204, 1],
- mediumvioletred: [199, 21, 133, 1],
- midnightblue: [25, 25, 112, 1],
- mintcream: [245, 255, 250, 1],
- mistyrose: [255, 228, 225, 1],
- moccasin: [255, 228, 181, 1],
- navajowhite: [255, 222, 173, 1],
- navy: [0, 0, 128, 1],
- oldlace: [253, 245, 230, 1],
- olive: [128, 128, 0, 1],
- olivedrab: [107, 142, 35, 1],
- orange: [255, 165, 0, 1],
- orangered: [255, 69, 0, 1],
- orchid: [218, 112, 214, 1],
- palegoldenrod: [238, 232, 170, 1],
- palegreen: [152, 251, 152, 1],
- paleturquoise: [175, 238, 238, 1],
- palevioletred: [219, 112, 147, 1],
- papayawhip: [255, 239, 213, 1],
- peachpuff: [255, 218, 185, 1],
- peru: [205, 133, 63, 1],
- pink: [255, 192, 203, 1],
- plum: [221, 160, 221, 1],
- powderblue: [176, 224, 230, 1],
- purple: [128, 0, 128, 1],
- red: [255, 0, 0, 1],
- rosybrown: [188, 143, 143, 1],
- royalblue: [65, 105, 225, 1],
- saddlebrown: [139, 69, 19, 1],
- salmon: [250, 128, 114, 1],
- sandybrown: [244, 164, 96, 1],
- seagreen: [46, 139, 87, 1],
- seashell: [255, 245, 238, 1],
- sienna: [160, 82, 45, 1],
- silver: [192, 192, 192, 1],
- skyblue: [135, 206, 235, 1],
- slateblue: [106, 90, 205, 1],
- slategray: [112, 128, 144, 1],
- slategrey: [112, 128, 144, 1],
- snow: [255, 250, 250, 1],
- springgreen: [0, 255, 127, 1],
- steelblue: [70, 130, 180, 1],
- tan: [210, 180, 140, 1],
- teal: [0, 128, 128, 1],
- thistle: [216, 191, 216, 1],
- tomato: [255, 99, 71, 1],
- turquoise: [64, 224, 208, 1],
- violet: [238, 130, 238, 1],
- wheat: [245, 222, 179, 1],
- white: [255, 255, 255, 1],
- whitesmoke: [245, 245, 245, 1],
- yellow: [255, 255, 0, 1],
- yellowgreen: [154, 205, 50, 1]
- };
- function Kn(e) {
- return (e = Math.round(e)) < 0 ? 0 : e > 255 ? 255 : e
- }
- function Qn(e) {
- return e < 0 ? 0 : e > 1 ? 1 : e
- }
- function Jn(e) {
- var t = e;
- return t.length && "%" === t.charAt(t.length - 1) ? Kn(parseFloat(t) / 100 * 255) : Kn(parseInt(t, 10))
- }
- function $n(e) {
- var t = e;
- return t.length && "%" === t.charAt(t.length - 1) ? Qn(parseFloat(t) / 100) : Qn(parseFloat(t))
- }
- function ea(e, t, r) {
- return r < 0 ? r += 1 : r > 1 && (r -= 1),
- 6 * r < 1 ? e + (t - e) * r * 6 : 2 * r < 1 ? t : 3 * r < 2 ? e + (t - e) * (2 / 3 - r) * 6 : e
- }
- function ta(e, t, r, i, n) {
- return e[0] = t,
- e[1] = r,
- e[2] = i,
- e[3] = n,
- e
- }
- function ra(e, t) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e
- }
- var ia = new bi(20)
- , na = null;
- function aa(e, t) {
- na && ra(na, t),
- na = ia.put(e, na || t.slice())
- }
- function oa(e, t) {
- if (e) {
- t = t || [];
- var r = ia.get(e);
- if (r)
- return ra(t, r);
- var i = (e += "").replace(/ /g, "").toLowerCase();
- if (i in Yn)
- return ra(t, Yn[i]),
- aa(e, t),
- t;
- var n, a = i.length;
- if ("#" === i.charAt(0))
- return 4 === a || 5 === a ? (n = parseInt(i.slice(1, 4), 16)) >= 0 && n <= 4095 ? (ta(t, (3840 & n) >> 4 | (3840 & n) >> 8, 240 & n | (240 & n) >> 4, 15 & n | (15 & n) << 4, 5 === a ? parseInt(i.slice(4), 16) / 15 : 1),
- aa(e, t),
- t) : void ta(t, 0, 0, 0, 1) : 7 === a || 9 === a ? (n = parseInt(i.slice(1, 7), 16)) >= 0 && n <= 16777215 ? (ta(t, (16711680 & n) >> 16, (65280 & n) >> 8, 255 & n, 9 === a ? parseInt(i.slice(7), 16) / 255 : 1),
- aa(e, t),
- t) : void ta(t, 0, 0, 0, 1) : void 0;
- var o = i.indexOf("(")
- , s = i.indexOf(")");
- if (-1 !== o && s + 1 === a) {
- var l = i.substr(0, o)
- , h = i.substr(o + 1, s - (o + 1)).split(",")
- , u = 1;
- switch (l) {
- case "rgba":
- if (4 !== h.length)
- return 3 === h.length ? ta(t, +h[0], +h[1], +h[2], 1) : ta(t, 0, 0, 0, 1);
- u = $n(h.pop());
- case "rgb":
- return 3 !== h.length ? void ta(t, 0, 0, 0, 1) : (ta(t, Jn(h[0]), Jn(h[1]), Jn(h[2]), u),
- aa(e, t),
- t);
- case "hsla":
- return 4 !== h.length ? void ta(t, 0, 0, 0, 1) : (h[3] = $n(h[3]),
- sa(h, t),
- aa(e, t),
- t);
- case "hsl":
- return 3 !== h.length ? void ta(t, 0, 0, 0, 1) : (sa(h, t),
- aa(e, t),
- t);
- default:
- return
- }
- }
- ta(t, 0, 0, 0, 1)
- }
- }
- function sa(e, t) {
- var r = (parseFloat(e[0]) % 360 + 360) % 360 / 360
- , i = $n(e[1])
- , n = $n(e[2])
- , a = n <= .5 ? n * (i + 1) : n + i - n * i
- , o = 2 * n - a;
- return ta(t = t || [], Kn(255 * ea(o, a, r + 1 / 3)), Kn(255 * ea(o, a, r)), Kn(255 * ea(o, a, r - 1 / 3)), 1),
- 4 === e.length && (t[3] = e[3]),
- t
- }
- var la = Object.prototype.toString
- , ha = Array.prototype
- , ua = ha.forEach
- , ca = ha.filter
- , da = ha.slice
- , fa = ha.map
- , pa = function () { }
- .constructor
- , ma = pa ? pa.prototype : null;
- function ga(e, t) {
- if (Object.assign)
- Object.assign(e, t);
- else
- for (var r in t)
- t.hasOwnProperty(r) && (e[r] = t[r]);
- return e
- }
- function _a(e, t, r) {
- if (e = "prototype" in e ? e.prototype : e,
- t = "prototype" in t ? t.prototype : t,
- Object.getOwnPropertyNames)
- for (var i = Object.getOwnPropertyNames(t), n = 0; n < i.length; n++) {
- var a = i[n];
- "constructor" !== a && (r ? null != t[a] : null == e[a]) && (e[a] = t[a])
- }
- else
- !function (e, t, r) {
- for (var i = ba(t), n = 0; n < i.length; n++) {
- var a = i[n];
- (r ? null != t[a] : null == e[a]) && (e[a] = t[a])
- }
- }(e, t, r)
- }
- function va(e) {
- return !!e && "string" != typeof e && "number" == typeof e.length
- }
- function ya(e, t, r) {
- if (e && t)
- if (e.forEach && e.forEach === ua)
- e.forEach(t, r);
- else if (e.length === +e.length)
- for (var i = 0, n = e.length; i < n; i++)
- t.call(r, e[i], i, e);
- else
- for (var a in e)
- e.hasOwnProperty(a) && t.call(r, e[a], a, e)
- }
- function xa(e, t, r) {
- if (!e)
- return [];
- if (!t)
- return Sa(e);
- if (e.map && e.map === fa)
- return e.map(t, r);
- for (var i = [], n = 0, a = e.length; n < a; n++)
- i.push(t.call(r, e[n], n, e));
- return i
- }
- function ba(e) {
- if (!e)
- return [];
- if (Object.keys)
- return Object.keys(e);
- var t = [];
- for (var r in e)
- e.hasOwnProperty(r) && t.push(r);
- return t
- }
- function wa(e) {
- for (var t = [], r = 1; r < arguments.length; r++)
- t[r - 1] = arguments[r];
- return function () {
- return e.apply(this, t.concat(da.call(arguments)))
- }
- }
- function Ta(e, t) {
- return null != e ? e : t
- }
- function Sa(e) {
- for (var t = [], r = 1; r < arguments.length; r++)
- t[r - 1] = arguments[r];
- return da.apply(e, t)
- }
- ma && "function" == typeof ma.bind && ma.call.bind(ma.bind);
- var Ma = function () {
- function e(t) {
- this.data = {};
- var r, i = (r = t,
- Array.isArray ? Array.isArray(r) : "[object Array]" === la.call(r));
- this.data = {};
- var n = this;
- function a(e, t) {
- i ? n.set(e, t) : n.set(t, e)
- }
- t instanceof e ? t.each(a) : t && ya(t, a)
- }
- return e.prototype.get = function (e) {
- return this.data.hasOwnProperty(e) ? this.data[e] : null
- }
- ,
- e.prototype.set = function (e, t) {
- return this.data[e] = t
- }
- ,
- e.prototype.each = function (e, t) {
- for (var r in this.data)
- this.data.hasOwnProperty(r) && e.call(t, this.data[r], r)
- }
- ,
- e.prototype.keys = function () {
- return ba(this.data)
- }
- ,
- e.prototype.removeKey = function (e) {
- delete this.data[e]
- }
- ,
- e
- }();
- function Aa(e, t) {
- for (var r = new e.constructor(e.length + t.length), i = 0; i < e.length; i++)
- r[i] = e[i];
- var n = e.length;
- for (i = 0; i < t.length; i++)
- r[i + n] = t[i];
- return r
- }
- var Ea = Array.prototype.slice;
- function Ca(e, t, r) {
- return (t - e) * r + e
- }
- function Da(e, t, r, i) {
- for (var n = t.length, a = 0; a < n; a++)
- e[a] = Ca(t[a], r[a], i)
- }
- function La(e, t, r, i) {
- for (var n = t.length, a = 0; a < n; a++)
- e[a] = t[a] + r[a] * i;
- return e
- }
- function Pa(e, t, r, i) {
- for (var n = t.length, a = n && t[0].length, o = 0; o < n; o++) {
- e[o] || (e[o] = []);
- for (var s = 0; s < a; s++)
- e[o][s] = t[o][s] + r[o][s] * i
- }
- return e
- }
- function Oa(e, t, r) {
- var i = e
- , n = t;
- if (i.push && n.push) {
- var a = i.length
- , o = n.length;
- if (a !== o)
- if (a > o)
- i.length = o;
- else
- for (var s = a; s < o; s++)
- i.push(1 === r ? n[s] : Ea.call(n[s]));
- var l = i[0] && i[0].length;
- for (s = 0; s < i.length; s++)
- if (1 === r)
- isNaN(i[s]) && (i[s] = n[s]);
- else
- for (var h = 0; h < l; h++)
- isNaN(i[s][h]) && (i[s][h] = n[s][h])
- }
- }
- function Na(e, t) {
- var r = e.length;
- if (r !== t.length)
- return !1;
- for (var i = 0; i < r; i++)
- if (e[i] !== t[i])
- return !1;
- return !0
- }
- function Ia(e, t, r, i, n, a, o) {
- var s = .5 * (r - e)
- , l = .5 * (i - t);
- return (2 * (t - r) + s + l) * o + (-3 * (t - r) - 2 * s - l) * a + s * n + t
- }
- function Ra(e, t, r, i, n, a, o, s) {
- for (var l = t.length, h = 0; h < l; h++)
- e[h] = Ia(t[h], r[h], i[h], n[h], a, o, s)
- }
- function Ba(e) {
- if (va(e)) {
- var t = e.length;
- if (va(e[0])) {
- for (var r = [], i = 0; i < t; i++)
- r.push(Ea.call(e[i]));
- return r
- }
- return Ea.call(e)
- }
- return e
- }
- function Fa(e) {
- return e[0] = Math.floor(e[0]),
- e[1] = Math.floor(e[1]),
- e[2] = Math.floor(e[2]),
- "rgba(" + e.join(",") + ")"
- }
- var za = [0, 0, 0, 0]
- , Ga = function () {
- function e(e) {
- this.keyframes = [],
- this.maxTime = 0,
- this.arrDim = 0,
- this.interpolable = !0,
- this._needsSort = !1,
- this._isAllValueEqual = !0,
- this._lastFrame = 0,
- this._lastFramePercent = 0,
- this.propName = e
- }
- return e.prototype.isFinished = function () {
- return this._finished
- }
- ,
- e.prototype.setFinished = function () {
- this._finished = !0,
- this._additiveTrack && this._additiveTrack.setFinished()
- }
- ,
- e.prototype.needsAnimate = function () {
- return !this._isAllValueEqual && this.keyframes.length >= 2 && this.interpolable
- }
- ,
- e.prototype.getAdditiveTrack = function () {
- return this._additiveTrack
- }
- ,
- e.prototype.addKeyframe = function (e, t) {
- e >= this.maxTime ? this.maxTime = e : this._needsSort = !0;
- var r = this.keyframes
- , i = r.length;
- if (this.interpolable)
- if (va(t)) {
- var n = function (e) {
- return va(e && e[0]) ? 2 : 1
- }(t);
- if (i > 0 && this.arrDim !== n)
- return void (this.interpolable = !1);
- if (1 === n && "number" != typeof t[0] || 2 === n && "number" != typeof t[0][0])
- return void (this.interpolable = !1);
- if (i > 0) {
- var a = r[i - 1];
- this._isAllValueEqual && (1 === n && Na(t, a.value) || (this._isAllValueEqual = !1))
- }
- this.arrDim = n
- } else {
- if (this.arrDim > 0)
- return void (this.interpolable = !1);
- if ("string" == typeof t) {
- var o = oa(t);
- o ? (t = o,
- this.isValueColor = !0) : this.interpolable = !1
- } else if ("number" != typeof t || isNaN(t))
- return void (this.interpolable = !1);
- this._isAllValueEqual && i > 0 && (a = r[i - 1],
- (this.isValueColor && !Na(a.value, t) || a.value !== t) && (this._isAllValueEqual = !1))
- }
- var s = {
- time: e,
- value: t,
- percent: 0
- };
- return this.keyframes.push(s),
- s
- }
- ,
- e.prototype.prepare = function (e) {
- var t = this.keyframes;
- this._needsSort && t.sort((function (e, t) {
- return e.time - t.time
- }
- ));
- for (var r = this.arrDim, i = t.length, n = t[i - 1], a = 0; a < i; a++)
- t[a].percent = t[a].time / this.maxTime,
- r > 0 && a !== i - 1 && Oa(t[a].value, n.value, r);
- if (e && this.needsAnimate() && e.needsAnimate() && r === e.arrDim && this.isValueColor === e.isValueColor && !e._finished) {
- this._additiveTrack = e;
- var o = t[0].value;
- for (a = 0; a < i; a++)
- 0 === r ? this.isValueColor ? t[a].additiveValue = La([], t[a].value, o, -1) : t[a].additiveValue = t[a].value - o : 1 === r ? t[a].additiveValue = La([], t[a].value, o, -1) : 2 === r && (t[a].additiveValue = Pa([], t[a].value, o, -1))
- }
- }
- ,
- e.prototype.step = function (e, t) {
- if (!this._finished) {
- this._additiveTrack && this._additiveTrack._finished && (this._additiveTrack = null);
- var r, i = null != this._additiveTrack, n = i ? "additiveValue" : "value", a = this.keyframes, o = this.keyframes.length, s = this.propName, l = this.arrDim, h = this.isValueColor;
- if (t < 0)
- r = 0;
- else if (t < this._lastFramePercent) {
- for (r = Math.min(this._lastFrame + 1, o - 1); r >= 0 && !(a[r].percent <= t); r--)
- ;
- r = Math.min(r, o - 2)
- } else {
- for (r = this._lastFrame; r < o && !(a[r].percent > t); r++)
- ;
- r = Math.min(r - 1, o - 2)
- }
- var u = a[r + 1]
- , c = a[r];
- if (c && u) {
- this._lastFrame = r,
- this._lastFramePercent = t;
- var d = u.percent - c.percent;
- if (0 !== d) {
- var f = (t - c.percent) / d
- , p = i ? this._additiveValue : h ? za : e[s];
- if ((l > 0 || h) && !p && (p = this._additiveValue = []),
- this.useSpline) {
- var m = a[r][n]
- , g = a[0 === r ? r : r - 1][n]
- , _ = a[r > o - 2 ? o - 1 : r + 1][n]
- , v = a[r > o - 3 ? o - 1 : r + 2][n];
- if (l > 0)
- 1 === l ? Ra(p, g, m, _, v, f, f * f, f * f * f) : function (e, t, r, i, n, a, o, s) {
- for (var l = t.length, h = t[0].length, u = 0; u < l; u++) {
- e[u] || (e[1] = []);
- for (var c = 0; c < h; c++)
- e[u][c] = Ia(t[u][c], r[u][c], i[u][c], n[u][c], a, o, s)
- }
- }(p, g, m, _, v, f, f * f, f * f * f);
- else if (h)
- Ra(p, g, m, _, v, f, f * f, f * f * f),
- i || (e[s] = Fa(p));
- else {
- var y = void 0;
- y = this.interpolable ? Ia(g, m, _, v, f, f * f, f * f * f) : _,
- i ? this._additiveValue = y : e[s] = y
- }
- } else
- l > 0 ? 1 === l ? Da(p, c[n], u[n], f) : function (e, t, r, i) {
- for (var n = t.length, a = n && t[0].length, o = 0; o < n; o++) {
- e[o] || (e[o] = []);
- for (var s = 0; s < a; s++)
- e[o][s] = Ca(t[o][s], r[o][s], i)
- }
- }(p, c[n], u[n], f) : h ? (Da(p, c[n], u[n], f),
- i || (e[s] = Fa(p))) : (y = void 0,
- y = this.interpolable ? Ca(c[n], u[n], f) : function (e, t, r) {
- return r > .5 ? t : e
- }(c[n], u[n], f),
- i ? this._additiveValue = y : e[s] = y);
- i && this._addToTarget(e)
- }
- }
- }
- }
- ,
- e.prototype._addToTarget = function (e) {
- var t = this.arrDim
- , r = this.propName
- , i = this._additiveValue;
- 0 === t ? this.isValueColor ? (oa(e[r], za),
- La(za, za, i, 1),
- e[r] = Fa(za)) : e[r] = e[r] + i : 1 === t ? La(e[r], e[r], i, 1) : 2 === t && Pa(e[r], e[r], i, 1)
- }
- ,
- e
- }();
- const Ua = function () {
- function e(e, t, r) {
- this._tracks = {},
- this._trackKeys = [],
- this._delay = 0,
- this._maxTime = 0,
- this._paused = !1,
- this._started = 0,
- this._clip = null,
- this._target = e,
- this._loop = t,
- t && r ? function () {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- "undefined" != typeof console && console.error.apply(console, e)
- }("Can' use additive animation on looped animation.") : this._additiveAnimators = r
- }
- return e.prototype.getTarget = function () {
- return this._target
- }
- ,
- e.prototype.changeTarget = function (e) {
- this._target = e
- }
- ,
- e.prototype.when = function (e, t) {
- return this.whenWithKeys(e, t, ba(t))
- }
- ,
- e.prototype.whenWithKeys = function (e, t, r) {
- for (var i = this._tracks, n = 0; n < r.length; n++) {
- var a = r[n]
- , o = i[a];
- if (!o) {
- o = i[a] = new Ga(a);
- var s = void 0
- , l = this._getAdditiveTrack(a);
- if (l) {
- var h = l.keyframes[l.keyframes.length - 1];
- s = h && h.value,
- l.isValueColor && s && (s = Fa(s))
- } else
- s = this._target[a];
- if (null == s)
- continue;
- 0 !== e && o.addKeyframe(0, Ba(s)),
- this._trackKeys.push(a)
- }
- o.addKeyframe(e, Ba(t[a]))
- }
- return this._maxTime = Math.max(this._maxTime, e),
- this
- }
- ,
- e.prototype.pause = function () {
- this._clip.pause(),
- this._paused = !0
- }
- ,
- e.prototype.resume = function () {
- this._clip.resume(),
- this._paused = !1
- }
- ,
- e.prototype.isPaused = function () {
- return !!this._paused
- }
- ,
- e.prototype._doneCallback = function () {
- this._setTracksFinished(),
- this._clip = null;
- var e = this._doneList;
- if (e)
- for (var t = e.length, r = 0; r < t; r++)
- e[r].call(this)
- }
- ,
- e.prototype._abortedCallback = function () {
- this._setTracksFinished();
- var e = this.animation
- , t = this._abortedList;
- if (e && e.removeClip(this._clip),
- this._clip = null,
- t)
- for (var r = 0; r < t.length; r++)
- t[r].call(this)
- }
- ,
- e.prototype._setTracksFinished = function () {
- for (var e = this._tracks, t = this._trackKeys, r = 0; r < t.length; r++)
- e[t[r]].setFinished()
- }
- ,
- e.prototype._getAdditiveTrack = function (e) {
- var t, r = this._additiveAnimators;
- if (r)
- for (var i = 0; i < r.length; i++) {
- var n = r[i].getTrack(e);
- n && (t = n)
- }
- return t
- }
- ,
- e.prototype.start = function (e, t) {
- if (!(this._started > 0)) {
- this._started = 1;
- for (var r = this, i = [], n = 0; n < this._trackKeys.length; n++) {
- var a = this._trackKeys[n]
- , o = this._tracks[a]
- , s = this._getAdditiveTrack(a)
- , l = o.keyframes;
- if (o.prepare(s),
- o.needsAnimate())
- i.push(o);
- else if (!o.interpolable) {
- var h = l[l.length - 1];
- h && (r._target[o.propName] = h.value)
- }
- }
- if (i.length || t) {
- var u = new Zn({
- life: this._maxTime,
- loop: this._loop,
- delay: this._delay,
- onframe: function (e) {
- r._started = 2;
- var t = r._additiveAnimators;
- if (t) {
- for (var n = !1, a = 0; a < t.length; a++)
- if (t[a]._clip) {
- n = !0;
- break
- }
- n || (r._additiveAnimators = null)
- }
- for (a = 0; a < i.length; a++)
- i[a].step(r._target, e);
- var o = r._onframeList;
- if (o)
- for (a = 0; a < o.length; a++)
- o[a](r._target, e)
- },
- ondestroy: function () {
- r._doneCallback()
- }
- });
- this._clip = u,
- this.animation && this.animation.addClip(u),
- e && "spline" !== e && (u.easing = e)
- } else
- this._doneCallback();
- return this
- }
- }
- ,
- e.prototype.stop = function (e) {
- if (this._clip) {
- var t = this._clip;
- e && t.onframe(1),
- this._abortedCallback()
- }
- }
- ,
- e.prototype.delay = function (e) {
- return this._delay = e,
- this
- }
- ,
- e.prototype.during = function (e) {
- return e && (this._onframeList || (this._onframeList = []),
- this._onframeList.push(e)),
- this
- }
- ,
- e.prototype.done = function (e) {
- return e && (this._doneList || (this._doneList = []),
- this._doneList.push(e)),
- this
- }
- ,
- e.prototype.aborted = function (e) {
- return e && (this._abortedList || (this._abortedList = []),
- this._abortedList.push(e)),
- this
- }
- ,
- e.prototype.getClip = function () {
- return this._clip
- }
- ,
- e.prototype.getTrack = function (e) {
- return this._tracks[e]
- }
- ,
- e.prototype.stopTracks = function (e, t) {
- if (!e.length || !this._clip)
- return !0;
- for (var r = this._tracks, i = this._trackKeys, n = 0; n < e.length; n++) {
- var a = r[e[n]];
- a && (t ? a.step(this._target, 1) : 1 === this._started && a.step(this._target, 0),
- a.setFinished())
- }
- var o = !0;
- for (n = 0; n < i.length; n++)
- if (!r[i[n]].isFinished()) {
- o = !1;
- break
- }
- return o && this._abortedCallback(),
- o
- }
- ,
- e.prototype.saveFinalToTarget = function (e, t) {
- if (e) {
- t = t || this._trackKeys;
- for (var r = 0; r < t.length; r++) {
- var i = t[r]
- , n = this._tracks[i];
- if (n && !n.isFinished()) {
- var a = n.keyframes
- , o = a[a.length - 1];
- if (o) {
- var s = Ba(o.value);
- n.isValueColor && (s = Fa(s)),
- e[i] = s
- }
- }
- }
- }
- }
- ,
- e.prototype.__changeFinalValue = function (e, t) {
- t = t || ba(e);
- for (var r = 0; r < t.length; r++) {
- var i = t[r]
- , n = this._tracks[i];
- if (n) {
- var a = n.keyframes;
- if (a.length > 1) {
- var o = a.pop();
- n.addKeyframe(o.time, e[i]),
- n.prepare(n.getAdditiveTrack())
- }
- }
- }
- }
- ,
- e
- }()
- , ka = {
- _animators: null,
- getAnimators: function () {
- return this._animators = this._animators || [],
- this._animators
- },
- animate: function (e, t) {
- var r;
- if (this._animators = this._animators || [],
- e) {
- for (var i = e.split("."), n = this, a = 0, o = i.length; a < o; a++)
- n && (n = n[i[a]]);
- n && (r = n)
- } else
- r = this;
- if (null == r)
- throw new Error("Target " + e + " not exists");
- var s = this._animators
- , l = new Ua(r, t)
- , h = this;
- return l.during((function () {
- h.__zr && h.__zr.refresh()
- }
- )).done((function () {
- var e = s.indexOf(l);
- e >= 0 && s.splice(e, 1)
- }
- )),
- s.push(l),
- this.__zr && this.__zr.animation.addAnimator(l),
- l
- },
- stopAnimation: function (e) {
- this._animators = this._animators || [];
- for (var t = this._animators, r = t.length, i = 0; i < r; i++)
- t[i].stop(e);
- return t.length = 0,
- this
- },
- addAnimatorsToZr: function (e) {
- if (this._animators)
- for (var t = 0; t < this._animators.length; t++)
- e.animation.addAnimator(this._animators[t])
- },
- removeAnimatorsFromZr: function (e) {
- if (this._animators)
- for (var t = 0; t < this._animators.length; t++)
- e.animation.removeAnimator(this._animators[t])
- }
- }
- , Va = "\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end";
- function Ha(e) {
- return e instanceof HTMLCanvasElement || e instanceof HTMLImageElement || e instanceof Image
- }
- Object.assign(sr.prototype, ka),
- Xe.import(Va),
- Xe.import(qe),
- Xe.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),
- Xe.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),
- Xe.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),
- Xe.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),
- Xe.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),
- Xe.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");
- var Wa = vi.prototype.addToScene
- , ja = vi.prototype.removeFromScene;
- vi.prototype.addToScene = function (e) {
- if (Wa.call(this, e),
- this.__zr) {
- var t = this.__zr;
- e.traverse((function (e) {
- e.__zr = t,
- e.addAnimatorsToZr && e.addAnimatorsToZr(t)
- }
- ))
- }
- }
- ,
- vi.prototype.removeFromScene = function (e) {
- ja.call(this, e),
- e.traverse((function (e) {
- var t = e.__zr;
- e.__zr = null,
- t && e.removeAnimatorsFromZr && e.removeAnimatorsFromZr(t)
- }
- ))
- }
- ,
- le.prototype.setTextureImage = function (e, t, r, i) {
- if (this.shader) {
- var n, a = r.getZr(), o = this;
- return o.autoUpdateTextureStatus = !1,
- o.disableTexture(e),
- !(s = t) || "none" === s || (n = Xa.loadTexture(t, r, i, (function (t) {
- o.enableTexture(e),
- a && a.refresh()
- }
- )),
- o.set(e, n)),
- n
- }
- var s
- }
- ;
- var Xa = {};
- Xa.Renderer = ut,
- Xa.Node = sr,
- Xa.Mesh = Sr,
- Xa.Shader = Xe,
- Xa.Material = le,
- Xa.Texture = wr,
- Xa.Texture2D = Dr,
- Xa.Geometry = Vr,
- Xa.SphereGeometry = En,
- Xa.PlaneGeometry = ki,
- Xa.CubeGeometry = Wi,
- Xa.AmbientLight = Cn,
- Xa.DirectionalLight = Dn,
- Xa.PointLight = Ln,
- Xa.SpotLight = Pn,
- Xa.PerspectiveCamera = Ei,
- Xa.OrthographicCamera = un,
- Xa.Vector2 = _e,
- Xa.Vector3 = vt,
- Xa.Vector4 = Rn,
- Xa.Quaternion = qt,
- Xa.Matrix2 = Gn,
- Xa.Matrix2d = Hn,
- Xa.Matrix3 = jn,
- Xa.Matrix4 = Ht,
- Xa.Plane = $r,
- Xa.Ray = Mt,
- Xa.BoundingBox = ir,
- Xa.Frustum = si;
- var qa = null;
- function Za(e) {
- return Math.pow(2, Math.round(Math.log(e) / Math.LN2))
- }
- function Ya(e) {
- if ((e.wrapS === wr.REPEAT || e.wrapT === wr.REPEAT) && e.image) {
- var t = Za(e.width)
- , r = Za(e.height);
- if (t !== e.width || r !== e.height) {
- var i = document.createElement("canvas");
- i.width = t,
- i.height = r,
- i.getContext("2d").drawImage(e.image, 0, 0, t, r),
- e.image = i
- }
- }
- }
- Xa.loadTexture = function (e, t, r, i) {
- "function" == typeof r && (i = r,
- r = {}),
- r = r || {};
- for (var n = Object.keys(r).sort(), a = "", o = 0; o < n.length; o++)
- a += n[o] + "_" + r[n[o]] + "_";
- var s, l = t.__textureCache = t.__textureCache || new bi(20);
- if ((s = e).getZr && s.setOption) {
- var h = e.__textureid__;
- if (c = l.get(a + h))
- c.texture.surface.setECharts(e),
- i && i(c.texture);
- else {
- var u = new hn(e);
- for (u.onupdate = function () {
- t.getZr().refresh()
- }
- ,
- c = {
- texture: u.getTexture()
- },
- o = 0; o < n.length; o++)
- c.texture[n[o]] = r[n[o]];
- h = e.__textureid__ || "__ecgl_ec__" + c.texture.__uid__,
- e.__textureid__ = h,
- l.put(a + h, c),
- i && i(c.texture)
- }
- return c.texture
- }
- if (Ha(e)) {
- var c;
- if (h = e.__textureid__,
- !(c = l.get(a + h))) {
- for (c = {
- texture: new Xa.Texture2D({
- image: e
- })
- },
- o = 0; o < n.length; o++)
- c.texture[n[o]] = r[n[o]];
- h = e.__textureid__ || "__ecgl_image__" + c.texture.__uid__,
- e.__textureid__ = h,
- l.put(a + h, c),
- Ya(c.texture),
- i && i(c.texture)
- }
- return c.texture
- }
- if (c = l.get(a + e))
- c.callbacks ? c.callbacks.push(i) : i && i(c.texture);
- else if (e.match(/.hdr$|^data:application\/octet-stream/)) {
- c = {
- callbacks: [i]
- };
- var d = an.loadTexture(e, {
- exposure: r.exposure,
- fileType: "hdr"
- }, (function () {
- d.dirty(),
- c.callbacks.forEach((function (e) {
- e && e(d)
- }
- )),
- c.callbacks = null
- }
- ));
- c.texture = d,
- l.put(a + e, c)
- } else {
- for (d = new Xa.Texture2D({
- image: new Image
- }),
- o = 0; o < n.length; o++)
- d[n[o]] = r[n[o]];
- c = {
- texture: d,
- callbacks: [i]
- };
- var f = d.image;
- f.onload = function () {
- d.image = f,
- Ya(d),
- d.dirty(),
- c.callbacks.forEach((function (e) {
- e && e(d)
- }
- )),
- c.callbacks = null
- }
- ,
- f.crossOrigin = "Anonymous",
- f.src = e,
- d.image = null !== qa ? qa : qa = an.createBlank("rgba(255,255,255,0)").image,
- l.put(a + e, c)
- }
- return c.texture
- }
- ,
- Xa.createAmbientCubemap = function (e, t, r, i) {
- var n = (e = e || {}).texture
- , a = Mn(e.exposure, 1)
- , o = new vn({
- intensity: Mn(e.specularIntensity, 1)
- })
- , s = new yn({
- intensity: Mn(e.diffuseIntensity, 1),
- coefficients: [.844, .712, .691, -.037, .083, .167, .343, .288, .299, -.041, -.021, -.009, -.003, -.041, -.064, -.011, -.007, -.004, -.031, .034, .081, -.06, -.049, -.06, .046, .056, .05]
- });
- return o.cubemap = Xa.loadTexture(n, r, {
- exposure: a
- }, (function () {
- o.cubemap.flipY = !1,
- o.prefilter(t, 32),
- s.coefficients = Sn.projectEnvironmentMap(t, o.cubemap, {
- lod: 1
- }),
- i && i()
- }
- )),
- {
- specular: o,
- diffuse: s
- }
- }
- ,
- Xa.createBlankTexture = an.createBlank,
- Xa.isImage = Ha,
- Xa.additiveBlend = function (e) {
- e.blendEquation(e.FUNC_ADD),
- e.blendFunc(e.SRC_ALPHA, e.ONE)
- }
- ,
- Xa.parseColor = function (e, t) {
- return e instanceof Array ? (t || (t = []),
- t[0] = e[0],
- t[1] = e[1],
- t[2] = e[2],
- e.length > 3 ? t[3] = e[3] : t[3] = 1,
- t) : ((t = i.color.parse(e || "#000", t) || [0, 0, 0, 0])[0] /= 255,
- t[1] /= 255,
- t[2] /= 255,
- t)
- }
- ,
- Xa.directionFromAlphaBeta = function (e, t) {
- var r = e / 180 * Math.PI + Math.PI / 2
- , i = -t / 180 * Math.PI + Math.PI / 2
- , n = []
- , a = Math.sin(r);
- return n[0] = a * Math.cos(i),
- n[1] = -Math.cos(r),
- n[2] = a * Math.sin(i),
- n
- }
- ,
- Xa.getShadowResolution = function (e) {
- var t = 1024;
- switch (e) {
- case "low":
- t = 512;
- break;
- case "medium":
- break;
- case "high":
- t = 2048;
- break;
- case "ultra":
- t = 4096
- }
- return t
- }
- ,
- Xa.COMMON_SHADERS = ["lambert", "color", "realistic", "hatching", "shadow"],
- Xa.createShader = function (e) {
- "ecgl.shadow" === e && (e = "ecgl.displayShadow");
- var t = Xe.source(e + ".vertex")
- , r = Xe.source(e + ".fragment");
- t || console.error("Vertex shader of '%s' not exits", e),
- r || console.error("Fragment shader of '%s' not exits", e);
- var i = new Xe(t, r);
- return i.name = e,
- i
- }
- ,
- Xa.createMaterial = function (e, t) {
- t instanceof Array || (t = [t]);
- var r = Xa.createShader(e)
- , i = new le({
- shader: r
- });
- return t.forEach((function (e) {
- "string" == typeof e && i.define(e)
- }
- )),
- i
- }
- ,
- Xa.setMaterialFromModel = function (e, t, r, i) {
- t.autoUpdateTextureStatus = !1;
- var n = r.getModel(e + "Material")
- , a = n.get("detailTexture")
- , o = Mn(n.get("textureTiling"), 1)
- , s = Mn(n.get("textureOffset"), 0);
- "number" == typeof o && (o = [o, o]),
- "number" == typeof s && (s = [s, s]);
- var l = o[0] > 1 || o[1] > 1 ? Xa.Texture.REPEAT : Xa.Texture.CLAMP_TO_EDGE
- , h = {
- anisotropic: 8,
- wrapS: l,
- wrapT: l
- };
- if ("realistic" === e) {
- var u = n.get("roughness")
- , c = n.get("metalness");
- null != c ? isNaN(c) && (t.setTextureImage("metalnessMap", c, i, h),
- c = Mn(n.get("metalnessAdjust"), .5)) : c = 0,
- null != u ? isNaN(u) && (t.setTextureImage("roughnessMap", u, i, h),
- u = Mn(n.get("roughnessAdjust"), .5)) : u = .5;
- var d = n.get("normalTexture");
- t.setTextureImage("detailMap", a, i, h),
- t.setTextureImage("normalMap", d, i, h),
- t.set({
- roughness: u,
- metalness: c,
- detailUvRepeat: o,
- detailUvOffset: s
- })
- } else if ("lambert" === e)
- t.setTextureImage("detailMap", a, i, h),
- t.set({
- detailUvRepeat: o,
- detailUvOffset: s
- });
- else if ("color" === e)
- t.setTextureImage("detailMap", a, i, h),
- t.set({
- detailUvRepeat: o,
- detailUvOffset: s
- });
- else if ("hatching" === e) {
- var f = n.get("hatchingTextures") || [];
- f.length;
- for (var p = 0; p < 6; p++)
- t.setTextureImage("hatch" + (p + 1), f[p], i, {
- anisotropic: 8,
- wrapS: Xa.Texture.REPEAT,
- wrapT: Xa.Texture.REPEAT
- });
- t.set({
- detailUvRepeat: o,
- detailUvOffset: s
- })
- }
- }
- ,
- Xa.updateVertexAnimation = function (e, t, r, i) {
- var n = i.get("animation")
- , a = i.get("animationDurationUpdate")
- , o = i.get("animationEasingUpdate")
- , s = r.shadowDepthMaterial;
- if (n && t && a > 0 && t.geometry.vertexCount === r.geometry.vertexCount) {
- r.material.define("vertex", "VERTEX_ANIMATION"),
- r.ignorePreZ = !0,
- s && s.define("vertex", "VERTEX_ANIMATION");
- for (var l = 0; l < e.length; l++)
- r.geometry.attributes[e[l][0]].value = t.geometry.attributes[e[l][1]].value;
- r.geometry.dirty(),
- r.__percent = 0,
- r.material.set("percent", 0),
- r.stopAnimation(),
- r.animate().when(a, {
- __percent: 1
- }).during((function () {
- r.material.set("percent", r.__percent),
- s && s.set("percent", r.__percent)
- }
- )).done((function () {
- r.ignorePreZ = !1,
- r.material.undefine("vertex", "VERTEX_ANIMATION"),
- s && s.undefine("vertex", "VERTEX_ANIMATION")
- }
- )).start(o)
- } else
- r.material.undefine("vertex", "VERTEX_ANIMATION"),
- s && s.undefine("vertex", "VERTEX_ANIMATION")
- }
- ;
- const Ka = Xa
- , Qa = "undefined" != typeof window && (window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window) || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame) || function (e) {
- return setTimeout(e, 16)
- }
- ;
- var Ja = function (e, t) {
- this.id = e,
- this.zr = t;
- try {
- this.renderer = new ut({
- clearBit: 0,
- devicePixelRatio: t.painter.dpr,
- preserveDrawingBuffer: !0,
- premultipliedAlpha: !0
- }),
- this.renderer.resize(t.painter.getWidth(), t.painter.getHeight())
- } catch (e) {
- return this.renderer = null,
- this.dom = document.createElement("div"),
- this.dom.style.cssText = "position:absolute; left: 0; top: 0; right: 0; bottom: 0;",
- this.dom.className = "ecgl-nowebgl",
- this.dom.innerHTML = "Sorry, your browser does not support WebGL",
- void console.error(e)
- }
- this.onglobalout = this.onglobalout.bind(this),
- t.on("globalout", this.onglobalout),
- this.dom = this.renderer.canvas;
- var r = this.dom.style;
- r.position = "absolute",
- r.left = "0",
- r.top = "0",
- this.views = [],
- this._picking = new _r({
- renderer: this.renderer
- }),
- this._viewsToDispose = [],
- this._accumulatingId = 0,
- this._zrEventProxy = new i.graphic.Rect({
- shape: {
- x: -1,
- y: -1,
- width: 2,
- height: 2
- },
- __isGLToZRProxy: !0
- }),
- this._backgroundColor = null,
- this._disposed = !1
- };
- function $a(e) {
- var t = e.__zr;
- e.__zr = null,
- t && e.removeAnimatorsFromZr && e.removeAnimatorsFromZr(t)
- }
- Ja.prototype.setUnpainted = function () { }
- ,
- Ja.prototype.addView = function (e) {
- if (e.layer !== this) {
- var t = this._viewsToDispose.indexOf(e);
- t >= 0 && this._viewsToDispose.splice(t, 1),
- this.views.push(e),
- e.layer = this;
- var r = this.zr;
- e.scene.traverse((function (e) {
- e.__zr = r,
- e.addAnimatorsToZr && e.addAnimatorsToZr(r)
- }
- ))
- }
- }
- ,
- Ja.prototype.removeView = function (e) {
- if (e.layer === this) {
- var t = this.views.indexOf(e);
- t >= 0 && (this.views.splice(t, 1),
- e.scene.traverse($a, this),
- e.layer = null,
- this._viewsToDispose.push(e))
- }
- }
- ,
- Ja.prototype.removeViewsAll = function () {
- this.views.forEach((function (e) {
- e.scene.traverse($a, this),
- e.layer = null,
- this._viewsToDispose.push(e)
- }
- ), this),
- this.views.length = 0
- }
- ,
- Ja.prototype.resize = function (e, t) {
- this.renderer.resize(e, t)
- }
- ,
- Ja.prototype.clear = function () {
- var e = this.renderer.gl
- , t = this._backgroundColor || [0, 0, 0, 0];
- e.clearColor(t[0], t[1], t[2], t[3]),
- e.depthMask(!0),
- e.colorMask(!0, !0, !0, !0),
- e.clear(e.DEPTH_BUFFER_BIT | e.COLOR_BUFFER_BIT)
- }
- ,
- Ja.prototype.clearDepth = function () {
- var e = this.renderer.gl;
- e.clear(e.DEPTH_BUFFER_BIT)
- }
- ,
- Ja.prototype.clearColor = function () {
- var e = this.renderer.gl;
- e.clearColor(0, 0, 0, 0),
- e.clear(e.COLOR_BUFFER_BIT)
- }
- ,
- Ja.prototype.needsRefresh = function () {
- this.zr.refresh()
- }
- ,
- Ja.prototype.refresh = function (e) {
- this._backgroundColor = e ? Ka.parseColor(e) : [0, 0, 0, 0],
- this.renderer.clearColor = this._backgroundColor;
- for (var t = 0; t < this.views.length; t++)
- this.views[t].prepareRender(this.renderer);
- for (this._doRender(!1),
- this._trackAndClean(),
- t = 0; t < this._viewsToDispose.length; t++)
- this._viewsToDispose[t].dispose(this.renderer);
- this._viewsToDispose.length = 0,
- this._startAccumulating()
- }
- ,
- Ja.prototype.renderToCanvas = function (e) {
- this._startAccumulating(!0),
- e.drawImage(this.dom, 0, 0, e.canvas.width, e.canvas.height)
- }
- ,
- Ja.prototype._doRender = function (e) {
- this.clear(),
- this.renderer.saveViewport();
- for (var t = 0; t < this.views.length; t++)
- this.views[t].render(this.renderer, e);
- this.renderer.restoreViewport()
- }
- ,
- Ja.prototype._stopAccumulating = function () {
- this._accumulatingId = 0,
- clearTimeout(this._accumulatingTimeout)
- }
- ;
- var eo = 1;
- function to(e) {
- for (var t = 0; t < e.length; t++)
- e[t].__used__ = 0
- }
- function ro(e, t) {
- for (var r = 0; r < t.length; r++)
- t[r].__used__ || t[r].dispose(e)
- }
- function io(e, t) {
- e.__used__ = e.__used__ || 0,
- e.__used__++,
- 1 === e.__used__ && t.push(e)
- }
- function no(e, t, r) {
- var i, n;
- e.traverse((function (e) {
- if (e.isRenderable()) {
- var a = e.geometry
- , o = e.material;
- if (o !== i)
- for (var s = o.getTextureUniforms(), l = 0; l < s.length; l++) {
- var h = s[l]
- , u = o.uniforms[h].value;
- if (u)
- if (u instanceof wr)
- io(u, t);
- else if (u instanceof Array)
- for (var c = 0; c < u.length; c++)
- u[c] instanceof wr && io(u[c], t)
- }
- a !== n && io(a, r),
- i = o,
- n = a
- }
- }
- ));
- for (var a = 0; a < e.lights.length; a++)
- e.lights[a].cubemap && io(e.lights[a].cubemap, t)
- }
- Ja.prototype._startAccumulating = function (e) {
- var t = this;
- this._stopAccumulating();
- for (var r = !1, i = 0; i < this.views.length; i++)
- r = this.views[i].needsAccumulate() || r;
- function n(i) {
- if (t._accumulatingId && i === t._accumulatingId) {
- for (var a = !0, o = 0; o < t.views.length; o++)
- a = t.views[o].isAccumulateFinished() && r;
- a || (t._doRender(!0),
- e ? n(i) : Qa((function () {
- n(i)
- }
- )))
- }
- }
- r && (this._accumulatingId = eo++,
- e ? n(t._accumulatingId) : this._accumulatingTimeout = setTimeout((function () {
- n(t._accumulatingId)
- }
- ), 50))
- }
- ,
- Ja.prototype._trackAndClean = function () {
- var e = []
- , t = [];
- this._textureList && (to(this._textureList),
- to(this._geometriesList));
- for (var r = 0; r < this.views.length; r++)
- no(this.views[r].scene, e, t);
- this._textureList && (ro(this.renderer, this._textureList),
- ro(this.renderer, this._geometriesList)),
- this._textureList = e,
- this._geometriesList = t
- }
- ,
- Ja.prototype.dispose = function () {
- this._disposed || (this._stopAccumulating(),
- this._textureList && (to(this._textureList),
- to(this._geometriesList),
- ro(this.renderer, this._textureList),
- ro(this.renderer, this._geometriesList)),
- this.zr.off("globalout", this.onglobalout),
- this._disposed = !0)
- }
- ,
- Ja.prototype.onmousedown = function (e) {
- if (!e.target || !e.target.__isGLToZRProxy) {
- e = e.event;
- var t = this.pickObject(e.offsetX, e.offsetY);
- t && (this._dispatchEvent("mousedown", e, t),
- this._dispatchDataEvent("mousedown", e, t)),
- this._downX = e.offsetX,
- this._downY = e.offsetY
- }
- }
- ,
- Ja.prototype.onmousemove = function (e) {
- if (!e.target || !e.target.__isGLToZRProxy) {
- e = e.event;
- var t = this.pickObject(e.offsetX, e.offsetY)
- , r = t && t.target
- , i = this._hovered;
- this._hovered = t,
- i && r !== i.target && (i.relatedTarget = r,
- this._dispatchEvent("mouseout", e, i),
- this.zr.setCursorStyle("default")),
- this._dispatchEvent("mousemove", e, t),
- t && (this.zr.setCursorStyle("pointer"),
- i && r === i.target || this._dispatchEvent("mouseover", e, t)),
- this._dispatchDataEvent("mousemove", e, t)
- }
- }
- ,
- Ja.prototype.onmouseup = function (e) {
- if (!e.target || !e.target.__isGLToZRProxy) {
- e = e.event;
- var t = this.pickObject(e.offsetX, e.offsetY);
- t && (this._dispatchEvent("mouseup", e, t),
- this._dispatchDataEvent("mouseup", e, t)),
- this._upX = e.offsetX,
- this._upY = e.offsetY
- }
- }
- ,
- Ja.prototype.onclick = Ja.prototype.dblclick = function (e) {
- if (!e.target || !e.target.__isGLToZRProxy) {
- var t = this._upX - this._downX
- , r = this._upY - this._downY;
- if (!(Math.sqrt(t * t + r * r) > 20)) {
- e = e.event;
- var i = this.pickObject(e.offsetX, e.offsetY);
- i && (this._dispatchEvent(e.type, e, i),
- this._dispatchDataEvent(e.type, e, i));
- var n = this._clickToSetFocusPoint(e);
- n && n.view.setDOFFocusOnPoint(n.distance) && this.zr.refresh()
- }
- }
- }
- ,
- Ja.prototype._clickToSetFocusPoint = function (e) {
- for (var t = this.renderer, r = t.viewport, i = this.views.length - 1; i >= 0; i--) {
- var n = this.views[i];
- if (n.hasDOF() && n.containPoint(e.offsetX, e.offsetY)) {
- this._picking.scene = n.scene,
- this._picking.camera = n.camera,
- t.viewport = n.viewport;
- var a = this._picking.pick(e.offsetX, e.offsetY, !0);
- if (a)
- return a.view = n,
- a
- }
- }
- t.viewport = r
- }
- ,
- Ja.prototype.onglobalout = function (e) {
- var t = this._hovered;
- t && this._dispatchEvent("mouseout", e, {
- target: t.target
- })
- }
- ,
- Ja.prototype.pickObject = function (e, t) {
- for (var r = [], i = this.renderer, n = i.viewport, a = 0; a < this.views.length; a++) {
- var o = this.views[a];
- o.containPoint(e, t) && (this._picking.scene = o.scene,
- this._picking.camera = o.camera,
- i.viewport = o.viewport,
- this._picking.pickAll(e, t, r))
- }
- return i.viewport = n,
- r.sort((function (e, t) {
- return e.distance - t.distance
- }
- )),
- r[0]
- }
- ,
- Ja.prototype._dispatchEvent = function (e, t, r) {
- r || (r = {});
- var i = r.target;
- for (r.cancelBubble = !1,
- r.event = t,
- r.type = e,
- r.offsetX = t.offsetX,
- r.offsetY = t.offsetY; i && (i.trigger(e, r),
- i = i.getParent(),
- !r.cancelBubble);)
- ;
- this._dispatchToView(e, r)
- }
- ,
- Ja.prototype._dispatchDataEvent = function (e, t, r) {
- var n = r && r.target
- , a = n && n.dataIndex
- , o = n && n.seriesIndex
- , s = n && n.eventData
- , l = !1
- , h = this._zrEventProxy;
- h.x = t.offsetX,
- h.y = t.offsetY,
- h.update();
- var u = {
- target: h
- };
- const c = i.helper.getECData(h);
- "mousemove" === e && (null != a ? a !== this._lastDataIndex && (parseInt(this._lastDataIndex, 10) >= 0 && (c.dataIndex = this._lastDataIndex,
- c.seriesIndex = this._lastSeriesIndex,
- this.zr.handler.dispatchToElement(u, "mouseout", t)),
- l = !0) : null != s && s !== this._lastEventData && (null != this._lastEventData && (c.eventData = this._lastEventData,
- this.zr.handler.dispatchToElement(u, "mouseout", t)),
- l = !0),
- this._lastEventData = s,
- this._lastDataIndex = a,
- this._lastSeriesIndex = o),
- c.eventData = s,
- c.dataIndex = a,
- c.seriesIndex = o,
- (null != s || parseInt(a, 10) >= 0 && parseInt(o, 10) >= 0) && (this.zr.handler.dispatchToElement(u, e, t),
- l && this.zr.handler.dispatchToElement(u, "mouseover", t))
- }
- ,
- Ja.prototype._dispatchToView = function (e, t) {
- for (var r = 0; r < this.views.length; r++)
- this.views[r].containPoint(t.offsetX, t.offsetY) && this.views[r].trigger(e, t)
- }
- ,
- Object.assign(Ja.prototype, h);
- const ao = Ja;
- var oo = ["bar3D", "line3D", "map3D", "scatter3D", "surface", "lines3D", "scatterGL", "scatter3D"];
- function so(e, t) {
- if (e && e[t] && (e[t].normal || e[t].emphasis)) {
- var r = e[t].normal
- , i = e[t].emphasis;
- r && (e[t] = r),
- i && (e.emphasis = e.emphasis || {},
- e.emphasis[t] = i)
- }
- }
- function lo(e) {
- e && (e instanceof Array || (e = [e]),
- i.util.each(e, (function (e) {
- if (e.axisLabel) {
- var t = e.axisLabel;
- Object.assign(t, t.textStyle),
- t.textStyle = null
- }
- }
- )))
- }
- function ho(e) {
- this._layers = {},
- this._zr = e
- }
- ho.prototype.update = function (e, t) {
- var r = this
- , n = t.getZr();
- if (n.getWidth() && n.getHeight()) {
- for (var a in this._layers)
- this._layers[a].removeViewsAll();
- e.eachComponent((function (r, i) {
- if ("series" !== r) {
- var n = t.getViewOfComponentModel(i)
- , a = i.coordinateSystem;
- if (n.__ecgl__) {
- if (a) {
- if (!a.viewGL)
- return void console.error("Can't find viewGL in coordinateSystem of component " + i.id);
- l = a.viewGL
- } else {
- if (!i.viewGL)
- return void console.error("Can't find viewGL of component " + i.id);
- l = a.viewGL
- }
- var l = a.viewGL
- , h = o(i);
- h.addView(l),
- n.afterRender && n.afterRender(i, e, t, h),
- s(n.groupGL, i.get("silent"))
- }
- }
- }
- )),
- e.eachSeries((function (r) {
- var i = t.getViewOfSeriesModel(r)
- , n = r.coordinateSystem;
- if (i.__ecgl__) {
- if (n && !n.viewGL && !i.viewGL)
- return void console.error("Can't find viewGL of series " + i.id);
- var a = n && n.viewGL || i.viewGL
- , l = o(r);
- l.addView(a),
- i.afterRender && i.afterRender(r, e, t, l),
- s(i.groupGL, r.get("silent"))
- }
- }
- ))
- } else
- console.warn("Dom has no width or height");
- function o(e) {
- var t;
- n.setSleepAfterStill(0),
- e.coordinateSystem && e.coordinateSystem.model,
- t = e.get("zlevel");
- var a = r._layers
- , o = a[t];
- if (!o) {
- if (o = a[t] = new ao("gl-" + t, n),
- n.painter.isSingleCanvas()) {
- o.virtual = !0;
- var s = new i.graphic.Image({
- z: 1e4,
- style: {
- image: o.renderer.canvas
- },
- silent: !0
- });
- o.__hostImage = s,
- n.add(s)
- }
- n.painter.insertLayer(t, o)
- }
- return o.__hostImage && o.__hostImage.setStyle({
- width: o.renderer.getWidth(),
- height: o.renderer.getHeight()
- }),
- o
- }
- function s(e, t) {
- e && e.traverse((function (e) {
- e.isRenderable && e.isRenderable() && (e.ignorePicking = null != e.$ignorePicking ? e.$ignorePicking : t)
- }
- ))
- }
- }
- ,
- i.registerPostInit((function (e) {
- var t = e.getZr()
- , r = t.painter.dispose;
- t.painter.dispose = function () {
- "function" == typeof this.eachOtherLayer && this.eachOtherLayer((function (e) {
- e instanceof ao && e.dispose()
- }
- )),
- r.call(this)
- }
- ,
- t.painter.getRenderedCanvas = function (e) {
- if (e = e || {},
- this._singleCanvas)
- return this._layers[0].dom;
- var t = document.createElement("canvas")
- , r = e.pixelRatio || this.dpr;
- t.width = this.getWidth() * r,
- t.height = this.getHeight() * r;
- var i = t.getContext("2d");
- i.dpr = r,
- i.clearRect(0, 0, t.width, t.height),
- e.backgroundColor && (i.fillStyle = e.backgroundColor,
- i.fillRect(0, 0, t.width, t.height));
- var n, a = this.storage.getDisplayList(!0), o = {}, s = this;
- function l(e, t) {
- var r, n = s._zlevelList;
- null == e && (e = -1 / 0);
- for (var a = 0; a < n.length; a++) {
- var o = n[a]
- , l = s._layers[o];
- if (!l.__builtin__ && o > e && o < t) {
- r = l;
- break
- }
- }
- r && r.renderToCanvas && (i.save(),
- r.renderToCanvas(i),
- i.restore())
- }
- for (var h = {
- ctx: i
- }, u = 0; u < a.length; u++) {
- var c = a[u];
- c.zlevel !== n && (l(n, c.zlevel),
- n = c.zlevel),
- this._doPaintEl(c, h, !0, null, o)
- }
- return l(n, 1 / 0),
- t
- }
- }
- )),
- i.registerPostUpdate((function (e, t) {
- var r = t.getZr();
- (r.__egl = r.__egl || new ho(r)).update(e, t)
- }
- )),
- i.registerPreprocessor((function (e) {
- i.util.each(e.series, (function (t) {
- i.util.indexOf(oo, t.type) >= 0 && (function (e) {
- so(e, "itemStyle"),
- so(e, "lineStyle"),
- so(e, "areaStyle"),
- so(e, "label")
- }(t),
- "mapbox" === t.coordinateSystem && (t.coordinateSystem = "mapbox3D",
- e.mapbox3D = e.mapbox))
- }
- )),
- lo(e.xAxis3D),
- lo(e.yAxis3D),
- lo(e.zAxis3D),
- lo(e.grid3D),
- so(e.geo3D)
- }
- ));
- const uo = {
- defaultOption: {
- viewControl: {
- projection: "perspective",
- autoRotate: !1,
- autoRotateDirection: "cw",
- autoRotateSpeed: 10,
- autoRotateAfterStill: 3,
- damping: .8,
- rotateSensitivity: 1,
- zoomSensitivity: 1,
- panSensitivity: 1,
- panMouseButton: "middle",
- rotateMouseButton: "left",
- distance: 150,
- minDistance: 40,
- maxDistance: 400,
- orthographicSize: 150,
- maxOrthographicSize: 400,
- minOrthographicSize: 20,
- center: [0, 0, 0],
- alpha: 0,
- beta: 0,
- minAlpha: -90,
- maxAlpha: 90
- }
- },
- setView: function (e) {
- e = e || {},
- this.option.viewControl = this.option.viewControl || {},
- null != e.alpha && (this.option.viewControl.alpha = e.alpha),
- null != e.beta && (this.option.viewControl.beta = e.beta),
- null != e.distance && (this.option.viewControl.distance = e.distance),
- null != e.center && (this.option.viewControl.center = e.center)
- }
- }
- , co = {
- defaultOption: {
- postEffect: {
- enable: !1,
- bloom: {
- enable: !0,
- intensity: .1
- },
- depthOfField: {
- enable: !1,
- focalRange: 20,
- focalDistance: 50,
- blurRadius: 10,
- fstop: 2.8,
- quality: "medium"
- },
- screenSpaceAmbientOcclusion: {
- enable: !1,
- radius: 2,
- quality: "medium",
- intensity: 1
- },
- screenSpaceReflection: {
- enable: !1,
- quality: "medium",
- maxRoughness: .8
- },
- colorCorrection: {
- enable: !0,
- exposure: 0,
- brightness: 0,
- contrast: 1,
- saturation: 1,
- lookupTexture: ""
- },
- edge: {
- enable: !1
- },
- FXAA: {
- enable: !1
- }
- },
- temporalSuperSampling: {
- enable: "auto"
- }
- }
- }
- , fo = {
- defaultOption: {
- light: {
- main: {
- shadow: !1,
- shadowQuality: "high",
- color: "#fff",
- intensity: 1,
- alpha: 0,
- beta: 0
- },
- ambient: {
- color: "#fff",
- intensity: .2
- },
- ambientCubemap: {
- texture: null,
- exposure: 1,
- diffuseIntensity: .5,
- specularIntensity: .5
- }
- }
- }
- };
- var po = i.ComponentModel.extend({
- type: "grid3D",
- dependencies: ["xAxis3D", "yAxis3D", "zAxis3D"],
- defaultOption: {
- show: !0,
- zlevel: -10,
- left: 0,
- top: 0,
- width: "100%",
- height: "100%",
- environment: "auto",
- boxWidth: 100,
- boxHeight: 100,
- boxDepth: 100,
- axisPointer: {
- show: !0,
- lineStyle: {
- color: "rgba(0, 0, 0, 0.8)",
- width: 1
- },
- label: {
- show: !0,
- formatter: null,
- margin: 8,
- textStyle: {
- fontSize: 14,
- color: "#fff",
- backgroundColor: "rgba(0,0,0,0.5)",
- padding: 3,
- borderRadius: 3
- }
- }
- },
- axisLine: {
- show: !0,
- lineStyle: {
- color: "#333",
- width: 2,
- type: "solid"
- }
- },
- axisTick: {
- show: !0,
- inside: !1,
- length: 3,
- lineStyle: {
- width: 1
- }
- },
- axisLabel: {
- show: !0,
- inside: !1,
- rotate: 0,
- margin: 8,
- textStyle: {
- fontSize: 12
- }
- },
- splitLine: {
- show: !0,
- lineStyle: {
- color: ["#ccc"],
- width: 1,
- type: "solid"
- }
- },
- splitArea: {
- show: !1,
- areaStyle: {
- color: ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
- }
- },
- light: {
- main: {
- alpha: 30,
- beta: 40
- },
- ambient: {
- intensity: .4
- }
- },
- viewControl: {
- alpha: 20,
- beta: 40,
- autoRotate: !1,
- distance: 200,
- minDistance: 40,
- maxDistance: 400
- }
- }
- });
- i.util.merge(po.prototype, uo),
- i.util.merge(po.prototype, co),
- i.util.merge(po.prototype, fo);
- const mo = po;
- function go(e, t) {
- switch (e) {
- case "center":
- case "middle":
- e = "50%";
- break;
- case "left":
- case "top":
- e = "0%";
- break;
- case "right":
- case "bottom":
- e = "100%"
- }
- return "string" == typeof e ? (r = e,
- r.replace(/^\s+|\s+$/g, "")).match(/%$/) ? parseFloat(e) / 100 * t : parseFloat(e) : null == e ? NaN : +e;
- var r
- }
- function _o() {
- var e = "__ec_inner_" + vo++;
- return function (t) {
- return t[e] || (t[e] = {})
- }
- }
- var vo = Math.round(9 * Math.random())
- , yo = {};
- function xo(e, t, r, i, n) {
- var a = {};
- return function (e, t, r, i, n) {
- r = r || yo;
- var a, o = t.ecModel, s = o && o.option.textStyle, l = function (e) {
- for (var t; e && e !== e.ecModel;) {
- var r = (e.option || yo).rich;
- if (r) {
- t = t || {};
- for (var i = ba(r), n = 0; n < i.length; n++)
- t[i[n]] = 1
- }
- e = e.parentModel
- }
- return t
- }(t);
- if (l)
- for (var h in a = {},
- l)
- if (l.hasOwnProperty(h)) {
- var u = t.getModel(["rich", h]);
- So(a[h] = {}, u, s, r, i, n, !1, !0)
- }
- a && (e.rich = a);
- var c = t.get("overflow");
- c && (e.overflow = c);
- var d = t.get("minMargin");
- null != d && (e.margin = d),
- So(e, t, s, r, i, n, !0, !1)
- }(a, e, r, i, n),
- t && ga(a, t),
- a
- }
- var bo = ["fontStyle", "fontWeight", "fontSize", "fontFamily", "textShadowColor", "textShadowBlur", "textShadowOffsetX", "textShadowOffsetY"]
- , wo = ["align", "lineHeight", "width", "height", "tag", "verticalAlign"]
- , To = ["padding", "borderWidth", "borderRadius", "borderDashOffset", "backgroundColor", "borderColor", "shadowColor", "shadowBlur", "shadowOffsetX", "shadowOffsetY"];
- function So(e, t, r, i, n, a, o, s) {
- r = !n && r || yo;
- var l = i && i.inheritColor
- , h = t.getShallow("color")
- , u = t.getShallow("textBorderColor")
- , c = Ta(t.getShallow("opacity"), r.opacity);
- "inherit" !== h && "auto" !== h || (h = l || null),
- "inherit" !== u && "auto" !== u || (u = l || null),
- a || (h = h || r.color,
- u = u || r.textBorderColor),
- null != h && (e.fill = h),
- null != u && (e.stroke = u);
- var d = Ta(t.getShallow("textBorderWidth"), r.textBorderWidth);
- null != d && (e.lineWidth = d);
- var f = Ta(t.getShallow("textBorderType"), r.textBorderType);
- null != f && (e.lineDash = f);
- var p = Ta(t.getShallow("textBorderDashOffset"), r.textBorderDashOffset);
- null != p && (e.lineDashOffset = p),
- n || null != c || s || (c = i && i.defaultOpacity),
- null != c && (e.opacity = c),
- n || a || null == e.fill && i.inheritColor && (e.fill = i.inheritColor);
- for (var m = 0; m < bo.length; m++) {
- var g = bo[m];
- null != (v = Ta(t.getShallow(g), r[g])) && (e[g] = v)
- }
- for (m = 0; m < wo.length; m++)
- g = wo[m],
- null != (v = t.getShallow(g)) && (e[g] = v);
- if (null == e.verticalAlign) {
- var _ = t.getShallow("baseline");
- null != _ && (e.verticalAlign = _)
- }
- if (!o || !i.disableBox) {
- for (m = 0; m < To.length; m++) {
- var v;
- g = To[m],
- null != (v = t.getShallow(g)) && (e[g] = v)
- }
- var y = t.getShallow("borderType");
- null != y && (e.borderDash = y),
- "auto" !== e.backgroundColor && "inherit" !== e.backgroundColor || !l || (e.backgroundColor = l),
- "auto" !== e.borderColor && "inherit" !== e.borderColor || !l || (e.borderColor = l)
- }
- }
- _o();
- var Mo = Mn
- , Ao = {
- left: 0,
- middle: 1,
- right: 2
- };
- function Eo(e) {
- return e instanceof Array || (e = [e, e]),
- e
- }
- var Co = m.extend((function () {
- return {
- zr: null,
- viewGL: null,
- _center: new vt,
- minDistance: .5,
- maxDistance: 1.5,
- maxOrthographicSize: 300,
- minOrthographicSize: 30,
- minAlpha: -90,
- maxAlpha: 90,
- minBeta: -1 / 0,
- maxBeta: 1 / 0,
- autoRotateAfterStill: 0,
- autoRotateDirection: "cw",
- autoRotateSpeed: 60,
- damping: .8,
- rotateSensitivity: 1,
- zoomSensitivity: 1,
- panSensitivity: 1,
- panMouseButton: "middle",
- rotateMouseButton: "left",
- _mode: "rotate",
- _camera: null,
- _needsUpdate: !1,
- _rotating: !1,
- _phi: 0,
- _theta: 0,
- _mouseX: 0,
- _mouseY: 0,
- _rotateVelocity: new _e,
- _panVelocity: new _e,
- _distance: 500,
- _zoomSpeed: 0,
- _stillTimeout: 0,
- _animators: []
- }
- }
- ), (function () {
- ["_mouseDownHandler", "_mouseWheelHandler", "_mouseMoveHandler", "_mouseUpHandler", "_pinchHandler", "_contextMenuHandler", "_update"].forEach((function (e) {
- this[e] = this[e].bind(this)
- }
- ), this)
- }
- ), {
- init: function () {
- var e = this.zr;
- e && (e.on("mousedown", this._mouseDownHandler),
- e.on("globalout", this._mouseUpHandler),
- e.on("mousewheel", this._mouseWheelHandler),
- e.on("pinch", this._pinchHandler),
- e.animation.on("frame", this._update),
- e.dom.addEventListener("contextmenu", this._contextMenuHandler))
- },
- dispose: function () {
- var e = this.zr;
- e && (e.off("mousedown", this._mouseDownHandler),
- e.off("mousemove", this._mouseMoveHandler),
- e.off("mouseup", this._mouseUpHandler),
- e.off("mousewheel", this._mouseWheelHandler),
- e.off("pinch", this._pinchHandler),
- e.off("globalout", this._mouseUpHandler),
- e.dom.removeEventListener("contextmenu", this._contextMenuHandler),
- e.animation.off("frame", this._update)),
- this.stopAllAnimation()
- },
- getDistance: function () {
- return this._distance
- },
- setDistance: function (e) {
- this._distance = e,
- this._needsUpdate = !0
- },
- getOrthographicSize: function () {
- return this._orthoSize
- },
- setOrthographicSize: function (e) {
- this._orthoSize = e,
- this._needsUpdate = !0
- },
- getAlpha: function () {
- return this._theta / Math.PI * 180
- },
- getBeta: function () {
- return -this._phi / Math.PI * 180
- },
- getCenter: function () {
- return this._center.toArray()
- },
- setAlpha: function (e) {
- e = Math.max(Math.min(this.maxAlpha, e), this.minAlpha),
- this._theta = e / 180 * Math.PI,
- this._needsUpdate = !0
- },
- setBeta: function (e) {
- e = Math.max(Math.min(this.maxBeta, e), this.minBeta),
- this._phi = -e / 180 * Math.PI,
- this._needsUpdate = !0
- },
- setCenter: function (e) {
- this._center.setArray(e)
- },
- setViewGL: function (e) {
- this.viewGL = e
- },
- getCamera: function () {
- return this.viewGL.camera
- },
- setFromViewControlModel: function (e, t) {
- var r = (t = t || {}).baseDistance || 0
- , i = t.baseOrthoSize || 1
- , n = e.get("projection");
- "perspective" !== n && "orthographic" !== n && "isometric" !== n && (n = "perspective"),
- this._projection = n,
- this.viewGL.setProjection(n);
- var a = e.get("distance") + r
- , o = e.get("orthographicSize") + i;
- [["damping", .8], ["autoRotate", !1], ["autoRotateAfterStill", 3], ["autoRotateDirection", "cw"], ["autoRotateSpeed", 10], ["minDistance", 30], ["maxDistance", 400], ["minOrthographicSize", 30], ["maxOrthographicSize", 300], ["minAlpha", -90], ["maxAlpha", 90], ["minBeta", -1 / 0], ["maxBeta", 1 / 0], ["rotateSensitivity", 1], ["zoomSensitivity", 1], ["panSensitivity", 1], ["panMouseButton", "left"], ["rotateMouseButton", "middle"]].forEach((function (t) {
- this[t[0]] = Mo(e.get(t[0]), t[1])
- }
- ), this),
- this.minDistance += r,
- this.maxDistance += r,
- this.minOrthographicSize += i,
- this.maxOrthographicSize += i;
- var s = e.ecModel
- , l = {};
- ["animation", "animationDurationUpdate", "animationEasingUpdate"].forEach((function (t) {
- l[t] = Mo(e.get(t), s && s.get(t))
- }
- ));
- var h = Mo(t.alpha, e.get("alpha")) || 0
- , u = Mo(t.beta, e.get("beta")) || 0
- , c = Mo(t.center, e.get("center")) || [0, 0, 0];
- l.animation && l.animationDurationUpdate > 0 && this._notFirst ? this.animateTo({
- alpha: h,
- beta: u,
- center: c,
- distance: a,
- orthographicSize: o,
- easing: l.animationEasingUpdate,
- duration: l.animationDurationUpdate
- }) : (this.setDistance(a),
- this.setAlpha(h),
- this.setBeta(u),
- this.setCenter(c),
- this.setOrthographicSize(o)),
- this._notFirst = !0,
- this._validateProperties()
- },
- _validateProperties: function () { },
- animateTo: function (e) {
- var t = this.zr
- , r = this
- , i = {}
- , n = {};
- return null != e.distance && (i.distance = this.getDistance(),
- n.distance = e.distance),
- null != e.orthographicSize && (i.orthographicSize = this.getOrthographicSize(),
- n.orthographicSize = e.orthographicSize),
- null != e.alpha && (i.alpha = this.getAlpha(),
- n.alpha = e.alpha),
- null != e.beta && (i.beta = this.getBeta(),
- n.beta = e.beta),
- null != e.center && (i.center = this.getCenter(),
- n.center = e.center),
- this._addAnimator(t.animation.animate(i).when(e.duration || 1e3, n).during((function () {
- null != i.alpha && r.setAlpha(i.alpha),
- null != i.beta && r.setBeta(i.beta),
- null != i.distance && r.setDistance(i.distance),
- null != i.center && r.setCenter(i.center),
- null != i.orthographicSize && r.setOrthographicSize(i.orthographicSize),
- r._needsUpdate = !0
- }
- ))).start(e.easing || "linear")
- },
- stopAllAnimation: function () {
- for (var e = 0; e < this._animators.length; e++)
- this._animators[e].stop();
- this._animators.length = 0
- },
- update: function () {
- this._needsUpdate = !0,
- this._update(20)
- },
- _isAnimating: function () {
- return this._animators.length > 0
- },
- _update: function (e) {
- if (this._rotating) {
- var t = ("cw" === this.autoRotateDirection ? 1 : -1) * this.autoRotateSpeed / 180 * Math.PI;
- this._phi -= t * e / 1e3,
- this._needsUpdate = !0
- } else
- this._rotateVelocity.len() > 0 && (this._needsUpdate = !0);
- (Math.abs(this._zoomSpeed) > .1 || this._panVelocity.len() > 0) && (this._needsUpdate = !0),
- this._needsUpdate && (e = Math.min(e, 50),
- this._updateDistanceOrSize(e),
- this._updatePan(e),
- this._updateRotate(e),
- this._updateTransform(),
- this.getCamera().update(),
- this.zr && this.zr.refresh(),
- this.trigger("update"),
- this._needsUpdate = !1)
- },
- _updateRotate: function (e) {
- var t = this._rotateVelocity;
- this._phi = t.y * e / 20 + this._phi,
- this._theta = t.x * e / 20 + this._theta,
- this.setAlpha(this.getAlpha()),
- this.setBeta(this.getBeta()),
- this._vectorDamping(t, Math.pow(this.damping, e / 16))
- },
- _updateDistanceOrSize: function (e) {
- "perspective" === this._projection ? this._setDistance(this._distance + this._zoomSpeed * e / 20) : this._setOrthoSize(this._orthoSize + this._zoomSpeed * e / 20),
- this._zoomSpeed *= Math.pow(this.damping, e / 16)
- },
- _setDistance: function (e) {
- this._distance = Math.max(Math.min(e, this.maxDistance), this.minDistance)
- },
- _setOrthoSize: function (e) {
- this._orthoSize = Math.max(Math.min(e, this.maxOrthographicSize), this.minOrthographicSize);
- var t = this.getCamera()
- , r = this._orthoSize
- , i = r / this.viewGL.viewport.height * this.viewGL.viewport.width;
- t.left = -i / 2,
- t.right = i / 2,
- t.top = r / 2,
- t.bottom = -r / 2
- },
- _updatePan: function (e) {
- var t = this._panVelocity
- , r = this._distance
- , i = this.getCamera()
- , n = i.worldTransform.y
- , a = i.worldTransform.x;
- this._center.scaleAndAdd(a, -t.x * r / 200).scaleAndAdd(n, -t.y * r / 200),
- this._vectorDamping(t, 0)
- },
- _updateTransform: function () {
- var e = this.getCamera()
- , t = new vt
- , r = this._theta + Math.PI / 2
- , i = this._phi + Math.PI / 2
- , n = Math.sin(r);
- t.x = n * Math.cos(i),
- t.y = -Math.cos(r),
- t.z = n * Math.sin(i),
- e.position.copy(this._center).scaleAndAdd(t, this._distance),
- e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)
- },
- _startCountingStill: function () {
- clearTimeout(this._stillTimeout);
- var e = this.autoRotateAfterStill
- , t = this;
- !isNaN(e) && e > 0 && (this._stillTimeout = setTimeout((function () {
- t._rotating = !0
- }
- ), 1e3 * e))
- },
- _vectorDamping: function (e, t) {
- var r = e.len();
- (r *= t) < 1e-4 && (r = 0),
- e.normalize().scale(r)
- },
- _decomposeTransform: function () {
- if (this.getCamera()) {
- this.getCamera().updateWorldTransform();
- var e = this.getCamera().worldTransform.z
- , t = Math.asin(e.y)
- , r = Math.atan2(e.x, e.z);
- this._theta = t,
- this._phi = -r,
- this.setBeta(this.getBeta()),
- this.setAlpha(this.getAlpha()),
- this.getCamera().aspect ? this._setDistance(this.getCamera().position.dist(this._center)) : this._setOrthoSize(this.getCamera().top - this.getCamera().bottom)
- }
- },
- _mouseDownHandler: function (e) {
- if (!e.target && !this._isAnimating()) {
- var t = e.offsetX
- , r = e.offsetY;
- this.viewGL && !this.viewGL.containPoint(t, r) || (this.zr.on("mousemove", this._mouseMoveHandler),
- this.zr.on("mouseup", this._mouseUpHandler),
- e.event.targetTouches ? 1 === e.event.targetTouches.length && (this._mode = "rotate") : e.event.button === Ao[this.rotateMouseButton] ? this._mode = "rotate" : e.event.button === Ao[this.panMouseButton] ? this._mode = "pan" : this._mode = "",
- this._rotateVelocity.set(0, 0),
- this._rotating = !1,
- this.autoRotate && this._startCountingStill(),
- this._mouseX = e.offsetX,
- this._mouseY = e.offsetY)
- }
- },
- _mouseMoveHandler: function (e) {
- if (!(e.target && e.target.__isGLToZRProxy || this._isAnimating())) {
- var t = Eo(this.panSensitivity)
- , r = Eo(this.rotateSensitivity);
- "rotate" === this._mode ? (this._rotateVelocity.y = (e.offsetX - this._mouseX) / this.zr.getHeight() * 2 * r[0],
- this._rotateVelocity.x = (e.offsetY - this._mouseY) / this.zr.getWidth() * 2 * r[1]) : "pan" === this._mode && (this._panVelocity.x = (e.offsetX - this._mouseX) / this.zr.getWidth() * t[0] * 400,
- this._panVelocity.y = (-e.offsetY + this._mouseY) / this.zr.getHeight() * t[1] * 400),
- this._mouseX = e.offsetX,
- this._mouseY = e.offsetY,
- e.event.preventDefault()
- }
- },
- _mouseWheelHandler: function (e) {
- if (!this._isAnimating()) {
- var t = e.event.wheelDelta || -e.event.detail;
- this._zoomHandler(e, t)
- }
- },
- _pinchHandler: function (e) {
- this._isAnimating() || (this._zoomHandler(e, e.pinchScale > 1 ? 1 : -1),
- this._mode = "")
- },
- _zoomHandler: function (e, t) {
- if (0 !== t) {
- var r, i = e.offsetX, n = e.offsetY;
- this.viewGL && !this.viewGL.containPoint(i, n) || (r = "perspective" === this._projection ? Math.max(Math.max(Math.min(this._distance - this.minDistance, this.maxDistance - this._distance)) / 20, .5) : Math.max(Math.max(Math.min(this._orthoSize - this.minOrthographicSize, this.maxOrthographicSize - this._orthoSize)) / 20, .5),
- this._zoomSpeed = (t > 0 ? -1 : 1) * r * this.zoomSensitivity,
- this._rotating = !1,
- this.autoRotate && "rotate" === this._mode && this._startCountingStill(),
- e.event.preventDefault())
- }
- },
- _mouseUpHandler: function () {
- this.zr.off("mousemove", this._mouseMoveHandler),
- this.zr.off("mouseup", this._mouseUpHandler)
- },
- _isRightMouseButtonUsed: function () {
- return "right" === this.rotateMouseButton || "right" === this.panMouseButton
- },
- _contextMenuHandler: function (e) {
- this._isRightMouseButtonUsed() && e.preventDefault()
- },
- _addAnimator: function (e) {
- var t = this._animators;
- return t.push(e),
- e.done((function () {
- var r = t.indexOf(e);
- r >= 0 && t.splice(r, 1)
- }
- )),
- e
- }
- });
- Object.defineProperty(Co.prototype, "autoRotate", {
- get: function (e) {
- return this._autoRotate
- },
- set: function (e) {
- this._autoRotate = e,
- this._rotating = e
- }
- });
- const Do = Co
- , Lo = {
- convertToDynamicArray: function (e) {
- e && this.resetOffset();
- var t = this.attributes;
- for (var r in t)
- e || !t[r].value ? t[r].value = [] : t[r].value = Array.prototype.slice.call(t[r].value);
- e || !this.indices ? this.indices = [] : this.indices = Array.prototype.slice.call(this.indices)
- },
- convertToTypedArray: function () {
- var e = this.attributes;
- for (var t in e)
- e[t].value && e[t].value.length > 0 ? e[t].value = new Float32Array(e[t].value) : e[t].value = null;
- this.indices && this.indices.length > 0 && (this.indices = this.vertexCount > 65535 ? new Uint32Array(this.indices) : new Uint16Array(this.indices)),
- this.dirty()
- }
- }
- , Po = {
- vec2: pe,
- vec3: Qe,
- vec4: Et,
- mat2: Fn,
- mat2d: kn,
- mat3: Dt,
- mat4: Ye,
- quat: Rt
- };
- var Oo = Po.vec3
- , No = [[0, 0], [1, 1]]
- , Io = Vr.extend((function () {
- return {
- segmentScale: 1,
- dynamic: !0,
- useNativeLine: !0,
- attributes: {
- position: new Vr.Attribute("position", "float", 3, "POSITION"),
- positionPrev: new Vr.Attribute("positionPrev", "float", 3),
- positionNext: new Vr.Attribute("positionNext", "float", 3),
- prevPositionPrev: new Vr.Attribute("prevPositionPrev", "float", 3),
- prevPosition: new Vr.Attribute("prevPosition", "float", 3),
- prevPositionNext: new Vr.Attribute("prevPositionNext", "float", 3),
- offset: new Vr.Attribute("offset", "float", 1),
- color: new Vr.Attribute("color", "float", 4, "COLOR")
- }
- }
- }
- ), {
- resetOffset: function () {
- this._vertexOffset = 0,
- this._triangleOffset = 0,
- this._itemVertexOffsets = []
- },
- setVertexCount: function (e) {
- var t = this.attributes;
- this.vertexCount !== e && (t.position.init(e),
- t.color.init(e),
- this.useNativeLine || (t.positionPrev.init(e),
- t.positionNext.init(e),
- t.offset.init(e)),
- e > 65535 ? this.indices instanceof Uint16Array && (this.indices = new Uint32Array(this.indices)) : this.indices instanceof Uint32Array && (this.indices = new Uint16Array(this.indices)))
- },
- setTriangleCount: function (e) {
- this.triangleCount !== e && (this.indices = 0 === e ? null : this.vertexCount > 65535 ? new Uint32Array(3 * e) : new Uint16Array(3 * e))
- },
- _getCubicCurveApproxStep: function (e, t, r, i) {
- return 1 / (Oo.dist(e, t) + Oo.dist(r, t) + Oo.dist(i, r) + 1) * this.segmentScale
- },
- getCubicCurveVertexCount: function (e, t, r, i) {
- var n = this._getCubicCurveApproxStep(e, t, r, i)
- , a = Math.ceil(1 / n);
- return this.useNativeLine ? 2 * a : 2 * a + 2
- },
- getCubicCurveTriangleCount: function (e, t, r, i) {
- var n = this._getCubicCurveApproxStep(e, t, r, i)
- , a = Math.ceil(1 / n);
- return this.useNativeLine ? 0 : 2 * a
- },
- getLineVertexCount: function () {
- return this.getPolylineVertexCount(No)
- },
- getLineTriangleCount: function () {
- return this.getPolylineTriangleCount(No)
- },
- getPolylineVertexCount: function (e) {
- var t;
- return t = "number" == typeof e ? e : "number" != typeof e[0] ? e.length : e.length / 3,
- this.useNativeLine ? 2 * (t - 1) : 2 * (t - 1) + 2
- },
- getPolylineTriangleCount: function (e) {
- var t;
- return t = "number" == typeof e ? e : "number" != typeof e[0] ? e.length : e.length / 3,
- this.useNativeLine ? 0 : 2 * Math.max(t - 1, 0)
- },
- addCubicCurve: function (e, t, r, i, n, a) {
- null == a && (a = 1);
- var o = e[0]
- , s = e[1]
- , l = e[2]
- , h = t[0]
- , u = t[1]
- , c = t[2]
- , d = r[0]
- , f = r[1]
- , p = r[2]
- , m = i[0]
- , g = i[1]
- , _ = i[2]
- , v = this._getCubicCurveApproxStep(e, t, r, i)
- , y = v * v
- , x = y * v
- , b = 3 * v
- , w = 3 * y
- , T = 6 * y
- , S = 6 * x
- , M = o - 2 * h + d
- , A = s - 2 * u + f
- , E = l - 2 * c + p
- , C = 3 * (h - d) - o + m
- , D = 3 * (u - f) - s + g
- , L = 3 * (c - p) - l + _
- , P = o
- , O = s
- , N = l
- , I = (h - o) * b + M * w + C * x
- , R = (u - s) * b + A * w + D * x
- , B = (c - l) * b + E * w + L * x
- , F = M * T + C * S
- , z = A * T + D * S
- , G = E * T + L * S
- , U = C * S
- , k = D * S
- , V = L * S
- , H = 0
- , W = 0
- , j = Math.ceil(1 / v)
- , X = new Float32Array(3 * (j + 1))
- , q = (X = [],
- 0);
- for (W = 0; W < j + 1; W++)
- X[q++] = P,
- X[q++] = O,
- X[q++] = N,
- P += I,
- O += R,
- N += B,
- I += F,
- R += z,
- B += G,
- F += U,
- z += k,
- G += V,
- (H += v) > 1 && (P = I > 0 ? Math.min(P, m) : Math.max(P, m),
- O = R > 0 ? Math.min(O, g) : Math.max(O, g),
- N = B > 0 ? Math.min(N, _) : Math.max(N, _));
- return this.addPolyline(X, n, a)
- },
- addLine: function (e, t, r, i) {
- return this.addPolyline([e, t], r, i)
- },
- addPolyline: function (e, t, r, i, n) {
- if (e.length) {
- var a = "number" != typeof e[0];
- if (null == n && (n = a ? e.length : e.length / 3),
- !(n < 2)) {
- null == i && (i = 0),
- null == r && (r = 1),
- this._itemVertexOffsets.push(this._vertexOffset);
- var o, s, l = (a = "number" != typeof e[0]) ? "number" != typeof t[0] : t.length / 4 === n, h = this.attributes.position, u = this.attributes.positionPrev, c = this.attributes.positionNext, d = this.attributes.color, f = this.attributes.offset, p = this.indices, m = this._vertexOffset;
- r = Math.max(r, .01);
- for (var g = i; g < n; g++) {
- if (a)
- o = e[g],
- s = l ? t[g] : t;
- else {
- var _ = 3 * g;
- if ((o = o || [])[0] = e[_],
- o[1] = e[_ + 1],
- o[2] = e[_ + 2],
- l) {
- var v = 4 * g;
- (s = s || [])[0] = t[v],
- s[1] = t[v + 1],
- s[2] = t[v + 2],
- s[3] = t[v + 3]
- } else
- s = t
- }
- if (this.useNativeLine ? g > 1 && (h.copy(m, m - 1),
- d.copy(m, m - 1),
- m++) : (g < n - 1 && (u.set(m + 2, o),
- u.set(m + 3, o)),
- g > 0 && (c.set(m - 2, o),
- c.set(m - 1, o)),
- h.set(m, o),
- h.set(m + 1, o),
- d.set(m, s),
- d.set(m + 1, s),
- f.set(m, r / 2),
- f.set(m + 1, -r / 2),
- m += 2),
- this.useNativeLine)
- d.set(m, s),
- h.set(m, o),
- m++;
- else if (g > 0) {
- var y = 3 * this._triangleOffset;
- (p = this.indices)[y] = m - 4,
- p[y + 1] = m - 3,
- p[y + 2] = m - 2,
- p[y + 3] = m - 3,
- p[y + 4] = m - 1,
- p[y + 5] = m - 2,
- this._triangleOffset += 2
- }
- }
- if (!this.useNativeLine) {
- var x = this._vertexOffset
- , b = this._vertexOffset + 2 * n;
- u.copy(x, x + 2),
- u.copy(x + 1, x + 3),
- c.copy(b - 1, b - 3),
- c.copy(b - 2, b - 4)
- }
- return this._vertexOffset = m,
- this._vertexOffset
- }
- }
- },
- setItemColor: function (e, t) {
- for (var r = this._itemVertexOffsets[e], i = e < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[e + 1] : this._vertexOffset, n = r; n < i; n++)
- this.attributes.color.set(n, t);
- this.dirty("color")
- },
- currentTriangleOffset: function () {
- return this._triangleOffset
- },
- currentVertexOffset: function () {
- return this._vertexOffset
- }
- });
- i.util.defaults(Io.prototype, Lo);
- const Ro = Io;
- function Bo(e, t, r, i, n, a, o) {
- this._zr = e,
- this._x = 0,
- this._y = 0,
- this._rowHeight = 0,
- this.width = i,
- this.height = n,
- this.offsetX = t,
- this.offsetY = r,
- this.dpr = o,
- this.gap = a
- }
- function Fo(e) {
- (e = e || {}).width = e.width || 512,
- e.height = e.height || 512,
- e.devicePixelRatio = e.devicePixelRatio || 1,
- e.gap = null == e.gap ? 2 : e.gap;
- var t = document.createElement("canvas");
- t.width = e.width * e.devicePixelRatio,
- t.height = e.height * e.devicePixelRatio,
- this._canvas = t,
- this._texture = new Dr({
- image: t,
- flipY: !1
- });
- var r = this;
- this._zr = i.zrender.init(t);
- var n = this._zr.refreshImmediately;
- this._zr.refreshImmediately = function () {
- n.call(this),
- r._texture.dirty(),
- r.onupdate && r.onupdate()
- }
- ,
- this._dpr = e.devicePixelRatio,
- this._coords = {},
- this.onupdate = e.onupdate,
- this._gap = e.gap,
- this._textureAtlasNodes = [new Bo(this._zr, 0, 0, e.width, e.height, this._gap, this._dpr)],
- this._nodeWidth = e.width,
- this._nodeHeight = e.height,
- this._currentNodeIdx = 0
- }
- Bo.prototype = {
- constructor: Bo,
- clear: function () {
- this._x = 0,
- this._y = 0,
- this._rowHeight = 0
- },
- add: function (e, t, r) {
- var i = e.getBoundingRect();
- null == t && (t = i.width),
- null == r && (r = i.height),
- t *= this.dpr,
- r *= this.dpr,
- this._fitElement(e, t, r);
- var n = this._x
- , a = this._y
- , o = this.width * this.dpr
- , s = this.height * this.dpr
- , l = this.gap;
- if (n + t + l > o && (n = this._x = 0,
- a += this._rowHeight + l,
- this._y = a,
- this._rowHeight = 0),
- this._x += t + l,
- this._rowHeight = Math.max(this._rowHeight, r),
- a + r + l > s)
- return null;
- e.x += this.offsetX * this.dpr + n,
- e.y += this.offsetY * this.dpr + a,
- this._zr.add(e);
- var h = [this.offsetX / this.width, this.offsetY / this.height];
- return [[n / o + h[0], a / s + h[1]], [(n + t) / o + h[0], (a + r) / s + h[1]]]
- },
- _fitElement: function (e, t, r) {
- var i = e.getBoundingRect()
- , n = t / i.width
- , a = r / i.height;
- e.x = -i.x * n,
- e.y = -i.y * a,
- e.scaleX = n,
- e.scaleY = a,
- e.update()
- }
- },
- Fo.prototype = {
- clear: function () {
- for (var e = 0; e < this._textureAtlasNodes.length; e++)
- this._textureAtlasNodes[e].clear();
- this._currentNodeIdx = 0,
- this._zr.clear(),
- this._coords = {}
- },
- getWidth: function () {
- return this._width
- },
- getHeight: function () {
- return this._height
- },
- getTexture: function () {
- return this._texture
- },
- getDevicePixelRatio: function () {
- return this._dpr
- },
- getZr: function () {
- return this._zr
- },
- _getCurrentNode: function () {
- return this._textureAtlasNodes[this._currentNodeIdx]
- },
- _expand: function () {
- if (this._currentNodeIdx++,
- this._textureAtlasNodes[this._currentNodeIdx])
- return this._textureAtlasNodes[this._currentNodeIdx];
- var e = 4096 / this._dpr
- , t = this._textureAtlasNodes.length
- , r = t * this._nodeWidth % e
- , i = Math.floor(t * this._nodeWidth / e) * this._nodeHeight;
- if (!(i >= e)) {
- var n = (r + this._nodeWidth) * this._dpr
- , a = (i + this._nodeHeight) * this._dpr;
- try {
- this._zr.resize({
- width: n,
- height: a
- })
- } catch (e) {
- this._canvas.width = n,
- this._canvas.height = a
- }
- var o = new Bo(this._zr, r, i, this._nodeWidth, this._nodeHeight, this._gap, this._dpr);
- return this._textureAtlasNodes.push(o),
- o
- }
- },
- add: function (e, t, r) {
- if (this._coords[e.id])
- return this._coords[e.id];
- var i = this._getCurrentNode().add(e, t, r);
- if (!i) {
- var n = this._expand();
- if (!n)
- return;
- i = n.add(e, t, r)
- }
- return this._coords[e.id] = i,
- i
- },
- getCoordsScale: function () {
- var e = this._dpr;
- return [this._nodeWidth / this._canvas.width * e, this._nodeHeight / this._canvas.height * e]
- },
- getCoords: function (e) {
- return this._coords[e]
- },
- dispose: function () {
- this._zr.dispose()
- }
- };
- const zo = Fo;
- function Go() { }
- Go.prototype = {
- constructor: Go,
- setScene: function (e) {
- this._scene = e,
- this._skybox && this._skybox.attachScene(this._scene)
- },
- initLight: function (e) {
- this._lightRoot = e,
- this.mainLight = new Ka.DirectionalLight({
- shadowBias: .005
- }),
- this.ambientLight = new Ka.AmbientLight,
- e.add(this.mainLight),
- e.add(this.ambientLight)
- },
- dispose: function () {
- this._lightRoot && (this._lightRoot.remove(this.mainLight),
- this._lightRoot.remove(this.ambientLight))
- },
- updateLight: function (e) {
- var t = this.mainLight
- , r = this.ambientLight
- , i = e.getModel("light")
- , n = i.getModel("main")
- , a = i.getModel("ambient");
- t.intensity = n.get("intensity"),
- r.intensity = a.get("intensity"),
- t.color = Ka.parseColor(n.get("color")).slice(0, 3),
- r.color = Ka.parseColor(a.get("color")).slice(0, 3);
- var o = n.get("alpha") || 0
- , s = n.get("beta") || 0;
- t.position.setArray(Ka.directionFromAlphaBeta(o, s)),
- t.lookAt(Ka.Vector3.ZERO),
- t.castShadow = n.get("shadow"),
- t.shadowResolution = Ka.getShadowResolution(n.get("shadowQuality"))
- },
- updateAmbientCubemap: function (e, t, r) {
- var i = t.getModel("light.ambientCubemap")
- , n = i.get("texture");
- if (n) {
- this._cubemapLightsCache = this._cubemapLightsCache || {};
- var a = this._cubemapLightsCache[n];
- if (!a) {
- var o = this;
- a = this._cubemapLightsCache[n] = Ka.createAmbientCubemap(i.option, e, r, (function () {
- o._isSkyboxFromAmbientCubemap && o._skybox.setEnvironmentMap(a.specular.cubemap),
- r.getZr().refresh()
- }
- ))
- }
- this._lightRoot.add(a.diffuse),
- this._lightRoot.add(a.specular),
- this._currentCubemapLights = a
- } else
- this._currentCubemapLights && (this._lightRoot.remove(this._currentCubemapLights.diffuse),
- this._lightRoot.remove(this._currentCubemapLights.specular),
- this._currentCubemapLights = null)
- },
- updateSkybox: function (e, t, r) {
- var n = t.get("environment")
- , a = this
- , o = (a._skybox = a._skybox || new ji,
- a._skybox);
- if (n && "none" !== n)
- if ("auto" === n)
- if (this._isSkyboxFromAmbientCubemap = !0,
- this._currentCubemapLights) {
- var s = this._currentCubemapLights.specular.cubemap;
- o.setEnvironmentMap(s),
- this._scene && o.attachScene(this._scene),
- o.material.set("lod", 3)
- } else
- this._skybox && this._skybox.detachScene();
- else if ("object" == typeof n && n.colorStops || "string" == typeof n && i.color.parse(n)) {
- this._isSkyboxFromAmbientCubemap = !1;
- var l = new Ka.Texture2D({
- anisotropic: 8,
- flipY: !1
- });
- o.setEnvironmentMap(l);
- var h = l.image = document.createElement("canvas");
- h.width = h.height = 16;
- var u = h.getContext("2d")
- , c = new i.graphic.Rect({
- shape: {
- x: 0,
- y: 0,
- width: 16,
- height: 16
- },
- style: {
- fill: n
- }
- });
- i.innerDrawElementOnCanvas(u, c),
- o.attachScene(this._scene)
- } else
- this._isSkyboxFromAmbientCubemap = !1,
- l = Ka.loadTexture(n, r, {
- anisotropic: 8,
- flipY: !1
- }),
- o.setEnvironmentMap(l),
- o.attachScene(this._scene);
- else
- this._skybox && this._skybox.detachScene(this._scene),
- this._skybox = null;
- var d = t.coordinateSystem;
- if (this._skybox)
- if (!d || !d.viewGL || "auto" === n || n.match && n.match(/.hdr$/))
- this._skybox.material.undefine("fragment", "SRGB_DECODE");
- else {
- var f = d.viewGL.isLinearSpace() ? "define" : "undefine";
- this._skybox.material[f]("fragment", "SRGB_DECODE")
- }
- }
- };
- const Uo = Go;
- var ko = Po.vec3
- , Vo = Vr.extend((function () {
- return {
- segmentScale: 1,
- useNativeLine: !0,
- attributes: {
- position: new Vr.Attribute("position", "float", 3, "POSITION"),
- normal: new Vr.Attribute("normal", "float", 3, "NORMAL"),
- color: new Vr.Attribute("color", "float", 4, "COLOR")
- }
- }
- }
- ), {
- resetOffset: function () {
- this._vertexOffset = 0,
- this._faceOffset = 0
- },
- setQuadCount: function (e) {
- var t = this.attributes
- , r = this.getQuadVertexCount() * e
- , i = this.getQuadTriangleCount() * e;
- this.vertexCount !== r && (t.position.init(r),
- t.normal.init(r),
- t.color.init(r)),
- this.triangleCount !== i && (this.indices = r > 65535 ? new Uint32Array(3 * i) : new Uint16Array(3 * i))
- },
- getQuadVertexCount: function () {
- return 4
- },
- getQuadTriangleCount: function () {
- return 2
- },
- addQuad: function () {
- var e = ko.create()
- , t = ko.create()
- , r = ko.create()
- , i = [0, 3, 1, 3, 2, 1];
- return function (n, a) {
- var o = this.attributes.position
- , s = this.attributes.normal
- , l = this.attributes.color;
- ko.sub(e, n[1], n[0]),
- ko.sub(t, n[2], n[1]),
- ko.cross(r, e, t),
- ko.normalize(r, r);
- for (var h = 0; h < 4; h++)
- o.set(this._vertexOffset + h, n[h]),
- l.set(this._vertexOffset + h, a),
- s.set(this._vertexOffset + h, r);
- var u = 3 * this._faceOffset;
- for (h = 0; h < 6; h++)
- this.indices[u + h] = i[h] + this._vertexOffset;
- this._vertexOffset += 4,
- this._faceOffset += 2
- }
- }()
- });
- i.util.defaults(Vo.prototype, Lo);
- const Ho = Vo;
- var Wo = Mn
- , jo = {
- x: 0,
- y: 2,
- z: 1
- };
- function Xo(e, t, r) {
- this.rootNode = new Ka.Node;
- var i = new Ka.Mesh({
- geometry: new Ro({
- useNativeLine: !1
- }),
- material: t,
- castShadow: !1,
- ignorePicking: !0,
- $ignorePicking: !0,
- renderOrder: 1
- })
- , n = new Ka.Mesh({
- geometry: new Ho,
- material: r,
- castShadow: !1,
- culling: !1,
- ignorePicking: !0,
- $ignorePicking: !0,
- renderOrder: 0
- });
- this.rootNode.add(n),
- this.rootNode.add(i),
- this.faceInfo = e,
- this.plane = new Ka.Plane,
- this.linesMesh = i,
- this.quadsMesh = n
- }
- Xo.prototype.update = function (e, t, r) {
- var i = e.coordinateSystem
- , n = [i.getAxis(this.faceInfo[0]), i.getAxis(this.faceInfo[1])]
- , a = this.linesMesh.geometry
- , o = this.quadsMesh.geometry;
- a.convertToDynamicArray(!0),
- o.convertToDynamicArray(!0),
- this._updateSplitLines(a, n, e, r),
- this._udpateSplitAreas(o, n, e, r),
- a.convertToTypedArray(),
- o.convertToTypedArray();
- var s = i.getAxis(this.faceInfo[2]);
- !function (e, t, r, i) {
- var n = [0, 0, 0]
- , a = i < 0 ? r.getExtentMin() : r.getExtentMax();
- n[jo[r.dim]] = a,
- e.position.setArray(n),
- e.rotation.identity(),
- t.distance = -Math.abs(a),
- t.normal.set(0, 0, 0),
- "x" === r.dim ? (e.rotation.rotateY(i * Math.PI / 2),
- t.normal.x = -i) : "z" === r.dim ? (e.rotation.rotateX(-i * Math.PI / 2),
- t.normal.y = -i) : (i > 0 && e.rotation.rotateY(Math.PI),
- t.normal.z = -i)
- }(this.rootNode, this.plane, s, this.faceInfo[3])
- }
- ,
- Xo.prototype._updateSplitLines = function (e, t, r, n) {
- var a = n.getDevicePixelRatio();
- t.forEach((function (n, o) {
- var s = n.model
- , l = t[1 - o].getExtent();
- if (!n.scale.isBlank()) {
- var h = s.getModel("splitLine", r.getModel("splitLine"));
- if (h.get("show")) {
- var u = h.getModel("lineStyle")
- , c = u.get("color")
- , d = Wo(u.get("opacity"), 1)
- , f = Wo(u.get("width"), 1);
- c = i.util.isArray(c) ? c : [c];
- for (var p = n.getTicksCoords({
- tickModel: h
- }), m = 0, g = 0; g < p.length; g++) {
- var _ = p[g].coord
- , v = Ka.parseColor(c[m % c.length]);
- v[3] *= d;
- var y = [0, 0, 0]
- , x = [0, 0, 0];
- y[o] = x[o] = _,
- y[1 - o] = l[0],
- x[1 - o] = l[1],
- e.addLine(y, x, v, f * a),
- m++
- }
- }
- }
- }
- ))
- }
- ,
- Xo.prototype._udpateSplitAreas = function (e, t, r, n) {
- t.forEach((function (n, a) {
- var o = n.model
- , s = t[1 - a].getExtent();
- if (!n.scale.isBlank()) {
- var l = o.getModel("splitArea", r.getModel("splitArea"));
- if (l.get("show")) {
- var h = l.getModel("areaStyle")
- , u = h.get("color")
- , c = Wo(h.get("opacity"), 1);
- u = i.util.isArray(u) ? u : [u];
- for (var d = n.getTicksCoords({
- tickModel: l,
- clamp: !0
- }), f = 0, p = [0, 0, 0], m = [0, 0, 0], g = 0; g < d.length; g++) {
- var _ = d[g].coord
- , v = [0, 0, 0]
- , y = [0, 0, 0];
- if (v[a] = y[a] = _,
- v[1 - a] = s[0],
- y[1 - a] = s[1],
- 0 !== g) {
- var x = Ka.parseColor(u[f % u.length]);
- x[3] *= c,
- e.addQuad([p, v, y, m], x),
- p = v,
- m = y,
- f++
- } else
- p = v,
- m = y
- }
- }
- }
- }
- ))
- }
- ;
- const qo = Xo;
- var Zo = [0, 1, 2, 0, 2, 3]
- , Yo = Vr.extend((function () {
- return {
- attributes: {
- position: new Vr.Attribute("position", "float", 3, "POSITION"),
- texcoord: new Vr.Attribute("texcoord", "float", 2, "TEXCOORD_0"),
- offset: new Vr.Attribute("offset", "float", 2),
- color: new Vr.Attribute("color", "float", 4, "COLOR")
- }
- }
- }
- ), {
- resetOffset: function () {
- this._vertexOffset = 0,
- this._faceOffset = 0
- },
- setSpriteCount: function (e) {
- this._spriteCount = e;
- var t = 4 * e
- , r = 2 * e;
- this.vertexCount !== t && (this.attributes.position.init(t),
- this.attributes.offset.init(t),
- this.attributes.color.init(t)),
- this.triangleCount !== r && (this.indices = t > 65535 ? new Uint32Array(3 * r) : new Uint16Array(3 * r))
- },
- setSpriteAlign: function (e, t, r, i, n) {
- var a, o, s, l;
- switch (null == r && (r = "left"),
- null == i && (i = "top"),
- n = n || 0,
- r) {
- case "left":
- a = n,
- s = t[0] + n;
- break;
- case "center":
- case "middle":
- a = -t[0] / 2,
- s = t[0] / 2;
- break;
- case "right":
- a = -t[0] - n,
- s = -n
- }
- switch (i) {
- case "bottom":
- o = n,
- l = t[1] + n;
- break;
- case "middle":
- o = -t[1] / 2,
- l = t[1] / 2;
- break;
- case "top":
- o = -t[1] - n,
- l = -n
- }
- var h = 4 * e
- , u = this.attributes.offset;
- u.set(h, [a, l]),
- u.set(h + 1, [s, l]),
- u.set(h + 2, [s, o]),
- u.set(h + 3, [a, o])
- },
- addSprite: function (e, t, r, i, n, a) {
- var o = this._vertexOffset;
- this.setSprite(this._vertexOffset / 4, e, t, r, i, n, a);
- for (var s = 0; s < Zo.length; s++)
- this.indices[3 * this._faceOffset + s] = Zo[s] + o;
- return this._faceOffset += 2,
- this._vertexOffset += 4,
- o / 4
- },
- setSprite: function (e, t, r, i, n, a, o) {
- for (var s = 4 * e, l = this.attributes, h = 0; h < 4; h++)
- l.position.set(s + h, t);
- var u = l.texcoord;
- u.set(s, [i[0][0], i[0][1]]),
- u.set(s + 1, [i[1][0], i[0][1]]),
- u.set(s + 2, [i[1][0], i[1][1]]),
- u.set(s + 3, [i[0][0], i[1][1]]),
- this.setSpriteAlign(e, r, n, a, o)
- }
- });
- i.util.defaults(Yo.prototype, Lo);
- const Ko = Yo;
- Ka.Shader.import("@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end");
- const Qo = Ka.Mesh.extend((function () {
- return {
- geometry: new Ko({
- dynamic: !0
- }),
- material: new Ka.Material({
- shader: Ka.createShader("ecgl.labels"),
- transparent: !0,
- depthMask: !1
- }),
- culling: !1,
- castShadow: !1,
- ignorePicking: !0
- }
- }
- ));
- var Jo = Mn
- , $o = {
- x: 0,
- y: 2,
- z: 1
- };
- function es(e, t) {
- var r = new Ka.Mesh({
- geometry: new Ro({
- useNativeLine: !1
- }),
- material: t,
- castShadow: !1,
- ignorePicking: !0,
- renderOrder: 2
- })
- , i = new Qo;
- i.material.depthMask = !1;
- var n = new Ka.Node;
- n.add(r),
- n.add(i),
- this.rootNode = n,
- this.dim = e,
- this.linesMesh = r,
- this.labelsMesh = i,
- this.axisLineCoords = null,
- this.labelElements = []
- }
- var ts = {
- x: "y",
- y: "x",
- z: "y"
- };
- es.prototype.update = function (e, t, r) {
- var n = e.coordinateSystem.getAxis(this.dim)
- , a = this.linesMesh.geometry
- , o = this.labelsMesh.geometry;
- a.convertToDynamicArray(!0),
- o.convertToDynamicArray(!0);
- var s = n.model
- , l = n.getExtent()
- , h = r.getDevicePixelRatio()
- , u = s.getModel("axisLine", e.getModel("axisLine"))
- , c = s.getModel("axisTick", e.getModel("axisTick"))
- , d = s.getModel("axisLabel", e.getModel("axisLabel"))
- , f = u.get("lineStyle.color");
- if (u.get("show")) {
- var p = u.getModel("lineStyle")
- , m = [0, 0, 0];
- (M = [0, 0, 0])[A = $o[n.dim]] = l[0],
- m[A] = l[1],
- this.axisLineCoords = [M, m];
- var g = Ka.parseColor(f)
- , _ = Jo(p.get("width"), 1)
- , v = Jo(p.get("opacity"), 1);
- g[3] *= v,
- a.addLine(M, m, g, _ * h)
- }
- if (c.get("show")) {
- var y = c.getModel("lineStyle")
- , x = Ka.parseColor(Jo(y.get("color"), f));
- _ = Jo(y.get("width"), 1),
- x[3] *= Jo(y.get("opacity"), 1);
- for (var b = n.getTicksCoords(), w = c.get("length"), T = 0; T < b.length; T++) {
- var S = b[T].coord
- , M = [0, 0, 0]
- , A = (m = [0, 0, 0],
- $o[n.dim])
- , E = $o[ts[n.dim]];
- M[A] = m[A] = S,
- m[E] = w,
- a.addLine(M, m, x, _ * h)
- }
- }
- if (this.labelElements = [],
- h = r.getDevicePixelRatio(),
- d.get("show")) {
- b = n.getTicksCoords();
- var C = s.get("data")
- , D = d.get("margin")
- , L = n.getViewLabels();
- for (T = 0; T < L.length; T++) {
- var P = L[T].tickValue
- , O = L[T].formattedLabel
- , N = L[T].rawLabel
- , I = (S = n.dataToCoord(P),
- [0, 0, 0]);
- A = $o[n.dim],
- E = $o[ts[n.dim]],
- I[A] = I[A] = S,
- I[E] = D;
- var R = d;
- C && C[P] && C[P].textStyle && (R = new i.Model(C[P].textStyle, d, s.ecModel));
- var B = Jo(R.get("color"), f)
- , F = new i.graphic.Text({
- style: xo(R, {
- text: O,
- fill: "function" == typeof B ? B("category" === n.type ? N : "value" === n.type ? P + "" : P, T) : B,
- verticalAlign: "top",
- align: "left"
- })
- })
- , z = t.add(F)
- , G = F.getBoundingRect();
- o.addSprite(I, [G.width * h, G.height * h], z),
- this.labelElements.push(F)
- }
- }
- if (s.get("name")) {
- var U = s.getModel("nameTextStyle")
- , k = (I = [0, 0, 0],
- A = $o[n.dim],
- E = $o[ts[n.dim]],
- Jo(U.get("color"), f))
- , V = U.get("borderColor");
- _ = U.get("borderWidth"),
- I[A] = I[A] = (l[0] + l[1]) / 2,
- I[E] = s.get("nameGap"),
- F = new i.graphic.Text({
- style: xo(U, {
- text: s.get("name"),
- fill: k,
- stroke: V,
- lineWidth: _
- })
- }),
- z = t.add(F),
- G = F.getBoundingRect(),
- o.addSprite(I, [G.width * h, G.height * h], z),
- F.__idx = this.labelElements.length,
- this.nameLabelElement = F
- }
- this.labelsMesh.material.set("textureAtlas", t.getTexture()),
- this.labelsMesh.material.set("uvScale", t.getCoordsScale()),
- a.convertToTypedArray(),
- o.convertToTypedArray()
- }
- ,
- es.prototype.setSpriteAlign = function (e, t, r) {
- for (var i = r.getDevicePixelRatio(), n = this.labelsMesh.geometry, a = 0; a < this.labelElements.length; a++) {
- var o = this.labelElements[a].getBoundingRect();
- n.setSpriteAlign(a, [o.width * i, o.height * i], e, t)
- }
- var s = this.nameLabelElement;
- s && (o = s.getBoundingRect(),
- n.setSpriteAlign(s.__idx, [o.width * i, o.height * i], e, t),
- n.dirty()),
- this.textAlign = e,
- this.textVerticalAlign = t
- }
- ;
- const rs = es
- , is = "@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end";
- var ns = Mn;
- Ka.Shader.import(is);
- var as = {
- x: 0,
- y: 2,
- z: 1
- };
- const os = i.ComponentView.extend({
- type: "grid3D",
- __ecgl__: !0,
- init: function (e, t) {
- var r = new Ka.Material({
- shader: Ka.createShader("ecgl.color"),
- depthMask: !1,
- transparent: !0
- })
- , i = new Ka.Material({
- shader: Ka.createShader("ecgl.meshLines3D"),
- depthMask: !1,
- transparent: !0
- });
- r.define("fragment", "DOUBLE_SIDED"),
- r.define("both", "VERTEX_COLOR"),
- this.groupGL = new Ka.Node,
- this._control = new Do({
- zr: t.getZr()
- }),
- this._control.init(),
- this._faces = [["y", "z", "x", -1, "left"], ["y", "z", "x", 1, "right"], ["x", "y", "z", -1, "bottom"], ["x", "y", "z", 1, "top"], ["x", "z", "y", -1, "far"], ["x", "z", "y", 1, "near"]].map((function (e) {
- var t = new qo(e, i, r);
- return this.groupGL.add(t.rootNode),
- t
- }
- ), this),
- this._axes = ["x", "y", "z"].map((function (e) {
- var t = new rs(e, i);
- return this.groupGL.add(t.rootNode),
- t
- }
- ), this);
- var n = t.getDevicePixelRatio();
- this._axisLabelSurface = new zo({
- width: 256,
- height: 256,
- devicePixelRatio: n
- }),
- this._axisLabelSurface.onupdate = function () {
- t.getZr().refresh()
- }
- ,
- this._axisPointerLineMesh = new Ka.Mesh({
- geometry: new Ro({
- useNativeLine: !1
- }),
- material: i,
- castShadow: !1,
- ignorePicking: !0,
- renderOrder: 3
- }),
- this.groupGL.add(this._axisPointerLineMesh),
- this._axisPointerLabelsSurface = new zo({
- width: 128,
- height: 128,
- devicePixelRatio: n
- }),
- this._axisPointerLabelsMesh = new Qo({
- ignorePicking: !0,
- renderOrder: 4,
- castShadow: !1
- }),
- this._axisPointerLabelsMesh.material.set("textureAtlas", this._axisPointerLabelsSurface.getTexture()),
- this.groupGL.add(this._axisPointerLabelsMesh),
- this._lightRoot = new Ka.Node,
- this._sceneHelper = new Uo,
- this._sceneHelper.initLight(this._lightRoot)
- },
- render: function (e, t, r) {
- this._model = e,
- this._api = r;
- var i = e.coordinateSystem;
- i.viewGL.add(this._lightRoot),
- e.get("show") ? i.viewGL.add(this.groupGL) : i.viewGL.remove(this.groupGL);
- var n = this._control;
- n.setViewGL(i.viewGL);
- var a = e.getModel("viewControl");
- n.setFromViewControlModel(a, 0),
- this._axisLabelSurface.clear(),
- n.off("update"),
- e.get("show") && (this._faces.forEach((function (i) {
- i.update(e, t, r)
- }
- ), this),
- this._axes.forEach((function (t) {
- t.update(e, this._axisLabelSurface, r)
- }
- ), this)),
- n.on("update", this._onCameraChange.bind(this, e, r), this),
- this._sceneHelper.setScene(i.viewGL.scene),
- this._sceneHelper.updateLight(e),
- i.viewGL.setPostEffect(e.getModel("postEffect"), r),
- i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),
- this._initMouseHandler(e)
- },
- afterRender: function (e, t, r, i) {
- var n = i.renderer;
- this._sceneHelper.updateAmbientCubemap(n, e, r),
- this._sceneHelper.updateSkybox(n, e, r)
- },
- showAxisPointer: function (e, t, r, i) {
- this._doShowAxisPointer(),
- this._updateAxisPointer(i.value)
- },
- hideAxisPointer: function (e, t, r, i) {
- this._doHideAxisPointer()
- },
- _initMouseHandler: function (e) {
- var t = e.coordinateSystem.viewGL;
- e.get("show") && e.get("axisPointer.show") ? t.on("mousemove", this._updateAxisPointerOnMousePosition, this) : t.off("mousemove", this._updateAxisPointerOnMousePosition)
- },
- _updateAxisPointerOnMousePosition: function (e) {
- if (!e.target) {
- for (var t, r = this._model.coordinateSystem, i = r.viewGL, n = i.castRay(e.offsetX, e.offsetY, new Ka.Ray), a = 0; a < this._faces.length; a++) {
- var o = this._faces[a];
- if (!o.rootNode.invisible) {
- o.plane.normal.dot(i.camera.worldTransform.z) < 0 && o.plane.normal.negate();
- var s = n.intersectPlane(o.plane);
- if (s) {
- var l = r.getAxis(o.faceInfo[0])
- , h = r.getAxis(o.faceInfo[1])
- , u = as[o.faceInfo[0]]
- , c = as[o.faceInfo[1]];
- l.contain(s.array[u]) && h.contain(s.array[c]) && (t = s)
- }
- }
- }
- if (t) {
- var d = r.pointToData(t.array, [], !0);
- this._updateAxisPointer(d),
- this._doShowAxisPointer()
- } else
- this._doHideAxisPointer()
- }
- },
- _onCameraChange: function (e, t) {
- e.get("show") && (this._updateFaceVisibility(),
- this._updateAxisLinePosition());
- var r = this._control;
- t.dispatchAction({
- type: "grid3DChangeCamera",
- alpha: r.getAlpha(),
- beta: r.getBeta(),
- distance: r.getDistance(),
- center: r.getCenter(),
- from: this.uid,
- grid3DId: e.id
- })
- },
- _updateFaceVisibility: function () {
- var e = this._control.getCamera()
- , t = new Ka.Vector3;
- e.update();
- for (var r = 0; r < this._faces.length / 2; r++) {
- for (var i = [], n = 0; n < 2; n++)
- this._faces[2 * r + n].rootNode.getWorldPosition(t),
- t.transformMat4(e.viewMatrix),
- i[n] = t.z;
- var a = i[0] > i[1] ? 0 : 1
- , o = this._faces[2 * r + a]
- , s = this._faces[2 * r + 1 - a];
- o.rootNode.invisible = !0,
- s.rootNode.invisible = !1
- }
- },
- _updateAxisLinePosition: function () {
- var e = this._model.coordinateSystem
- , t = e.getAxis("x")
- , r = e.getAxis("y")
- , i = e.getAxis("z")
- , n = i.getExtentMax()
- , a = i.getExtentMin()
- , o = t.getExtentMin()
- , s = t.getExtentMax()
- , l = r.getExtentMax()
- , h = r.getExtentMin()
- , u = this._axes[0].rootNode
- , c = this._axes[1].rootNode
- , d = this._axes[2].rootNode
- , f = this._faces
- , p = f[4].rootNode.invisible ? h : l
- , m = f[2].rootNode.invisible ? n : a
- , g = f[0].rootNode.invisible ? o : s
- , _ = f[2].rootNode.invisible ? n : a
- , v = f[0].rootNode.invisible ? s : o
- , y = f[4].rootNode.invisible ? h : l;
- u.rotation.identity(),
- c.rotation.identity(),
- d.rotation.identity(),
- f[4].rootNode.invisible && (this._axes[0].flipped = !0,
- u.rotation.rotateX(Math.PI)),
- f[0].rootNode.invisible && (this._axes[1].flipped = !0,
- c.rotation.rotateZ(Math.PI)),
- f[4].rootNode.invisible && (this._axes[2].flipped = !0,
- d.rotation.rotateY(Math.PI)),
- u.position.set(0, m, p),
- c.position.set(g, _, 0),
- d.position.set(v, 0, y),
- u.update(),
- c.update(),
- d.update(),
- this._updateAxisLabelAlign()
- },
- _updateAxisLabelAlign: function () {
- var e = this._control.getCamera()
- , t = [new Ka.Vector4, new Ka.Vector4]
- , r = new Ka.Vector4;
- this.groupGL.getWorldPosition(r),
- r.w = 1,
- r.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),
- r.x /= r.w,
- r.y /= r.w,
- this._axes.forEach((function (i) {
- for (var n = i.axisLineCoords, a = (i.labelsMesh.geometry,
- 0); a < t.length; a++)
- t[a].setArray(n[a]),
- t[a].w = 1,
- t[a].transformMat4(i.rootNode.worldTransform).transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),
- t[a].x /= t[a].w,
- t[a].y /= t[a].w;
- var o, s, l = t[1].x - t[0].x, h = t[1].y - t[0].y, u = (t[1].x + t[0].x) / 2, c = (t[1].y + t[0].y) / 2;
- Math.abs(h / l) < .5 ? (o = "center",
- s = c > r.y ? "bottom" : "top") : (s = "middle",
- o = u > r.x ? "left" : "right"),
- i.setSpriteAlign(o, s, this._api)
- }
- ), this)
- },
- _doShowAxisPointer: function () {
- this._axisPointerLineMesh.invisible && (this._axisPointerLineMesh.invisible = !1,
- this._axisPointerLabelsMesh.invisible = !1,
- this._api.getZr().refresh())
- },
- _doHideAxisPointer: function () {
- this._axisPointerLineMesh.invisible || (this._axisPointerLineMesh.invisible = !0,
- this._axisPointerLabelsMesh.invisible = !0,
- this._api.getZr().refresh())
- },
- _updateAxisPointer: function (e) {
- var t = this._model.coordinateSystem
- , r = t.dataToPoint(e)
- , i = this._axisPointerLineMesh.geometry
- , n = this._model.getModel("axisPointer")
- , a = this._api.getDevicePixelRatio();
- function o(e) {
- return Mn(e.model.get("axisPointer.show"), n.get("show"))
- }
- function s(e) {
- var t = e.model.getModel("axisPointer", n).getModel("lineStyle")
- , r = Ka.parseColor(t.get("color"))
- , i = ns(t.get("width"), 1)
- , a = ns(t.get("opacity"), 1);
- return r[3] *= a,
- {
- color: r,
- lineWidth: i
- }
- }
- i.convertToDynamicArray(!0);
- for (var l = 0; l < this._faces.length; l++) {
- var h = this._faces[l];
- if (!h.rootNode.invisible) {
- for (var u = h.faceInfo, c = u[3] < 0 ? t.getAxis(u[2]).getExtentMin() : t.getAxis(u[2]).getExtentMax(), d = as[u[2]], f = 0; f < 2; f++) {
- var p = u[f]
- , m = u[1 - f]
- , g = t.getAxis(p)
- , _ = t.getAxis(m);
- if (o(g)) {
- var v = as[p]
- , y = as[m];
- (w = [0, 0, 0])[v] = (b = [0, 0, 0])[v] = r[v],
- w[d] = b[d] = c,
- w[y] = _.getExtentMin(),
- b[y] = _.getExtentMax();
- var x = s(g);
- i.addLine(w, b, x.color, x.lineWidth * a)
- }
- }
- if (o(t.getAxis(u[2]))) {
- var b, w = r.slice();
- (b = r.slice())[d] = c,
- x = s(t.getAxis(u[2])),
- i.addLine(w, b, x.color, x.lineWidth * a)
- }
- }
- }
- i.convertToTypedArray(),
- this._updateAxisPointerLabelsMesh(e),
- this._api.getZr().refresh()
- },
- _updateAxisPointerLabelsMesh: function (e) {
- var t = this._model
- , r = this._axisPointerLabelsMesh
- , n = this._axisPointerLabelsSurface
- , a = t.coordinateSystem
- , o = t.getModel("axisPointer");
- r.geometry.convertToDynamicArray(!0),
- n.clear();
- var s = {
- x: "y",
- y: "x",
- z: "y"
- };
- this._axes.forEach((function (t, l) {
- var h = a.getAxis(t.dim)
- , u = h.model.getModel("axisPointer", o)
- , c = u.getModel("label")
- , d = u.get("lineStyle.color");
- if (c.get("show") && u.get("show")) {
- var f = e[l]
- , p = c.get("formatter")
- , m = h.scale.getLabel({
- value: f
- });
- if (null != p)
- m = p(m, e);
- else if ("interval" === h.scale.type || "log" === h.scale.type) {
- var g = i.number.getPrecisionSafe(h.scale.getTicks()[0]);
- m = f.toFixed(g + 2)
- }
- var _ = c.get("color")
- , v = new i.graphic.Text({
- style: xo(c, {
- text: m,
- fill: _ || d,
- align: "left",
- verticalAlign: "top"
- })
- })
- , y = n.add(v)
- , x = v.getBoundingRect()
- , b = this._api.getDevicePixelRatio()
- , w = t.rootNode.position.toArray();
- w[as[s[t.dim]]] += (t.flipped ? -1 : 1) * c.get("margin"),
- w[as[t.dim]] = h.dataToCoord(e[l]),
- r.geometry.addSprite(w, [x.width * b, x.height * b], y, t.textAlign, t.textVerticalAlign)
- }
- }
- ), this),
- n.getZr().refreshImmediately(),
- r.material.set("uvScale", n.getCoordsScale()),
- r.geometry.convertToTypedArray()
- },
- dispose: function () {
- this.groupGL.removeAll(),
- this._control.dispose(),
- this._axisLabelSurface.dispose(),
- this._axisPointerLabelsSurface.dispose()
- }
- })
- , ss = function () {
- function e(e) {
- this.type = "cartesian",
- this._dimList = [],
- this._axes = {},
- this.name = e || ""
- }
- return e.prototype.getAxis = function (e) {
- return this._axes[e]
- }
- ,
- e.prototype.getAxes = function () {
- return xa(this._dimList, (function (e) {
- return this._axes[e]
- }
- ), this)
- }
- ,
- e.prototype.getAxesByScale = function (e) {
- return e = e.toLowerCase(),
- function (e, t, r) {
- if (!e)
- return [];
- if (!t)
- return Sa(e);
- if (e.filter && e.filter === ca)
- return e.filter(t, r);
- for (var i = [], n = 0, a = e.length; n < a; n++)
- t.call(r, e[n], n, e) && i.push(e[n]);
- return i
- }(this.getAxes(), (function (t) {
- return t.scale.type === e
- }
- ))
- }
- ,
- e.prototype.addAxis = function (e) {
- var t = e.dim;
- this._axes[t] = e,
- this._dimList.push(t)
- }
- ,
- e
- }();
- function ls(e) {
- ss.call(this, e),
- this.type = "cartesian3D",
- this.dimensions = ["x", "y", "z"],
- this.size = [0, 0, 0]
- }
- ls.prototype = {
- constructor: ls,
- model: null,
- containPoint: function (e) {
- return this.getAxis("x").contain(e[0]) && this.getAxis("y").contain(e[2]) && this.getAxis("z").contain(e[1])
- },
- containData: function (e) {
- return this.getAxis("x").containData(e[0]) && this.getAxis("y").containData(e[1]) && this.getAxis("z").containData(e[2])
- },
- dataToPoint: function (e, t, r) {
- return (t = t || [])[0] = this.getAxis("x").dataToCoord(e[0], r),
- t[2] = this.getAxis("y").dataToCoord(e[1], r),
- t[1] = this.getAxis("z").dataToCoord(e[2], r),
- t
- },
- pointToData: function (e, t, r) {
- return (t = t || [])[0] = this.getAxis("x").coordToData(e[0], r),
- t[1] = this.getAxis("y").coordToData(e[2], r),
- t[2] = this.getAxis("z").coordToData(e[1], r),
- t
- }
- },
- i.util.inherits(ls, ss);
- const hs = ls;
- function us(e, t, r) {
- i.Axis.call(this, e, t, r)
- }
- us.prototype = {
- constructor: us,
- getExtentMin: function () {
- var e = this._extent;
- return Math.min(e[0], e[1])
- },
- getExtentMax: function () {
- var e = this._extent;
- return Math.max(e[0], e[1])
- },
- calculateCategoryInterval: function () {
- return Math.floor(this.scale.count() / 8)
- }
- },
- i.util.inherits(us, i.Axis);
- const cs = us;
- function ds(e, t, r) {
- return e[0] = t[0],
- e[1] = t[1],
- e[2] = t[2],
- e[3] = t[3],
- e[4] = t[4] + r[0],
- e[5] = t[5] + r[1],
- e
- }
- const fs = function () {
- function e(e, t) {
- this.x = e || 0,
- this.y = t || 0
- }
- return e.prototype.copy = function (e) {
- return this.x = e.x,
- this.y = e.y,
- this
- }
- ,
- e.prototype.clone = function () {
- return new e(this.x, this.y)
- }
- ,
- e.prototype.set = function (e, t) {
- return this.x = e,
- this.y = t,
- this
- }
- ,
- e.prototype.equal = function (e) {
- return e.x === this.x && e.y === this.y
- }
- ,
- e.prototype.add = function (e) {
- return this.x += e.x,
- this.y += e.y,
- this
- }
- ,
- e.prototype.scale = function (e) {
- this.x *= e,
- this.y *= e
- }
- ,
- e.prototype.scaleAndAdd = function (e, t) {
- this.x += e.x * t,
- this.y += e.y * t
- }
- ,
- e.prototype.sub = function (e) {
- return this.x -= e.x,
- this.y -= e.y,
- this
- }
- ,
- e.prototype.dot = function (e) {
- return this.x * e.x + this.y * e.y
- }
- ,
- e.prototype.len = function () {
- return Math.sqrt(this.x * this.x + this.y * this.y)
- }
- ,
- e.prototype.lenSquare = function () {
- return this.x * this.x + this.y * this.y
- }
- ,
- e.prototype.normalize = function () {
- var e = this.len();
- return this.x /= e,
- this.y /= e,
- this
- }
- ,
- e.prototype.distance = function (e) {
- var t = this.x - e.x
- , r = this.y - e.y;
- return Math.sqrt(t * t + r * r)
- }
- ,
- e.prototype.distanceSquare = function (e) {
- var t = this.x - e.x
- , r = this.y - e.y;
- return t * t + r * r
- }
- ,
- e.prototype.negate = function () {
- return this.x = -this.x,
- this.y = -this.y,
- this
- }
- ,
- e.prototype.transform = function (e) {
- if (e) {
- var t = this.x
- , r = this.y;
- return this.x = e[0] * t + e[2] * r + e[4],
- this.y = e[1] * t + e[3] * r + e[5],
- this
- }
- }
- ,
- e.prototype.toArray = function (e) {
- return e[0] = this.x,
- e[1] = this.y,
- e
- }
- ,
- e.prototype.fromArray = function (e) {
- this.x = e[0],
- this.y = e[1]
- }
- ,
- e.set = function (e, t, r) {
- e.x = t,
- e.y = r
- }
- ,
- e.copy = function (e, t) {
- e.x = t.x,
- e.y = t.y
- }
- ,
- e.len = function (e) {
- return Math.sqrt(e.x * e.x + e.y * e.y)
- }
- ,
- e.lenSquare = function (e) {
- return e.x * e.x + e.y * e.y
- }
- ,
- e.dot = function (e, t) {
- return e.x * t.x + e.y * t.y
- }
- ,
- e.add = function (e, t, r) {
- e.x = t.x + r.x,
- e.y = t.y + r.y
- }
- ,
- e.sub = function (e, t, r) {
- e.x = t.x - r.x,
- e.y = t.y - r.y
- }
- ,
- e.scale = function (e, t, r) {
- e.x = t.x * r,
- e.y = t.y * r
- }
- ,
- e.scaleAndAdd = function (e, t, r, i) {
- e.x = t.x + r.x * i,
- e.y = t.y + r.y * i
- }
- ,
- e.lerp = function (e, t, r, i) {
- var n = 1 - i;
- e.x = n * t.x + i * r.x,
- e.y = n * t.y + i * r.y
- }
- ,
- e
- }();
- var ps = Math.min
- , ms = Math.max
- , gs = new fs
- , _s = new fs
- , vs = new fs
- , ys = new fs
- , xs = new fs
- , bs = new fs;
- const ws = function () {
- function e(e, t, r, i) {
- r < 0 && (e += r,
- r = -r),
- i < 0 && (t += i,
- i = -i),
- this.x = e,
- this.y = t,
- this.width = r,
- this.height = i
- }
- return e.prototype.union = function (e) {
- var t = ps(e.x, this.x)
- , r = ps(e.y, this.y);
- isFinite(this.x) && isFinite(this.width) ? this.width = ms(e.x + e.width, this.x + this.width) - t : this.width = e.width,
- isFinite(this.y) && isFinite(this.height) ? this.height = ms(e.y + e.height, this.y + this.height) - r : this.height = e.height,
- this.x = t,
- this.y = r
- }
- ,
- e.prototype.applyTransform = function (t) {
- e.applyTransform(this, this, t)
- }
- ,
- e.prototype.calculateTransform = function (e) {
- var t = this
- , r = e.width / t.width
- , i = e.height / t.height
- , n = [1, 0, 0, 1, 0, 0];
- return ds(n, n, [-t.x, -t.y]),
- function (e, t, r) {
- var i = r[0]
- , n = r[1];
- e[0] = t[0] * i,
- e[1] = t[1] * n,
- e[2] = t[2] * i,
- e[3] = t[3] * n,
- e[4] = t[4] * i,
- e[5] = t[5] * n
- }(n, n, [r, i]),
- ds(n, n, [e.x, e.y]),
- n
- }
- ,
- e.prototype.intersect = function (t, r) {
- if (!t)
- return !1;
- t instanceof e || (t = e.create(t));
- var i = this
- , n = i.x
- , a = i.x + i.width
- , o = i.y
- , s = i.y + i.height
- , l = t.x
- , h = t.x + t.width
- , u = t.y
- , c = t.y + t.height
- , d = !(a < l || h < n || s < u || c < o);
- if (r) {
- var f = 1 / 0
- , p = 0
- , m = Math.abs(a - l)
- , g = Math.abs(h - n)
- , _ = Math.abs(s - u)
- , v = Math.abs(c - o)
- , y = Math.min(m, g)
- , x = Math.min(_, v);
- a < l || h < n ? y > p && (p = y,
- m < g ? fs.set(bs, -m, 0) : fs.set(bs, g, 0)) : y < f && (f = y,
- m < g ? fs.set(xs, m, 0) : fs.set(xs, -g, 0)),
- s < u || c < o ? x > p && (p = x,
- _ < v ? fs.set(bs, 0, -_) : fs.set(bs, 0, v)) : y < f && (f = y,
- _ < v ? fs.set(xs, 0, _) : fs.set(xs, 0, -v))
- }
- return r && fs.copy(r, d ? xs : bs),
- d
- }
- ,
- e.prototype.contain = function (e, t) {
- var r = this;
- return e >= r.x && e <= r.x + r.width && t >= r.y && t <= r.y + r.height
- }
- ,
- e.prototype.clone = function () {
- return new e(this.x, this.y, this.width, this.height)
- }
- ,
- e.prototype.copy = function (t) {
- e.copy(this, t)
- }
- ,
- e.prototype.plain = function () {
- return {
- x: this.x,
- y: this.y,
- width: this.width,
- height: this.height
- }
- }
- ,
- e.prototype.isFinite = function () {
- return isFinite(this.x) && isFinite(this.y) && isFinite(this.width) && isFinite(this.height)
- }
- ,
- e.prototype.isZero = function () {
- return 0 === this.width || 0 === this.height
- }
- ,
- e.create = function (t) {
- return new e(t.x, t.y, t.width, t.height)
- }
- ,
- e.copy = function (e, t) {
- e.x = t.x,
- e.y = t.y,
- e.width = t.width,
- e.height = t.height
- }
- ,
- e.applyTransform = function (t, r, i) {
- if (i) {
- if (i[1] < 1e-5 && i[1] > -1e-5 && i[2] < 1e-5 && i[2] > -1e-5) {
- var n = i[0]
- , a = i[3]
- , o = i[4]
- , s = i[5];
- return t.x = r.x * n + o,
- t.y = r.y * a + s,
- t.width = r.width * n,
- t.height = r.height * a,
- t.width < 0 && (t.x += t.width,
- t.width = -t.width),
- void (t.height < 0 && (t.y += t.height,
- t.height = -t.height))
- }
- gs.x = vs.x = r.x,
- gs.y = ys.y = r.y,
- _s.x = ys.x = r.x + r.width,
- _s.y = vs.y = r.y + r.height,
- gs.transform(i),
- ys.transform(i),
- _s.transform(i),
- vs.transform(i),
- t.x = ps(gs.x, _s.x, vs.x, ys.x),
- t.y = ps(gs.y, _s.y, vs.y, ys.y);
- var l = ms(gs.x, _s.x, vs.x, ys.x)
- , h = ms(gs.y, _s.y, vs.y, ys.y);
- t.width = l - t.x,
- t.height = h - t.y
- } else
- t !== r && e.copy(t, r)
- }
- ,
- e
- }();
- function Ts(e, t, r, i, n) {
- var a = 0
- , o = 0;
- null == i && (i = 1 / 0),
- null == n && (n = 1 / 0);
- var s = 0;
- t.eachChild((function (l, h) {
- var u, c, d = l.getBoundingRect(), f = t.childAt(h + 1), p = f && f.getBoundingRect();
- if ("horizontal" === e) {
- var m = d.width + (p ? -p.x + d.x : 0);
- (u = a + m) > i || l.newline ? (a = 0,
- u = m,
- o += s + r,
- s = d.height) : s = Math.max(s, d.height)
- } else {
- var g = d.height + (p ? -p.y + d.y : 0);
- (c = o + g) > n || l.newline ? (a += s + r,
- o = 0,
- c = g,
- s = d.width) : s = Math.max(s, d.width)
- }
- l.newline || (l.x = a,
- l.y = o,
- l.markRedraw(),
- "horizontal" === e ? a = u + r : o = c + r)
- }
- ))
- }
- function Ss(e, t, r) {
- r = function (e) {
- if ("number" == typeof e)
- return [e, e, e, e];
- var t = e.length;
- return 2 === t ? [e[0], e[1], e[0], e[1]] : 3 === t ? [e[0], e[1], e[2], e[1]] : e
- }(r || 0);
- var i = t.width
- , n = t.height
- , a = go(e.left, i)
- , o = go(e.top, n)
- , s = go(e.right, i)
- , l = go(e.bottom, n)
- , h = go(e.width, i)
- , u = go(e.height, n)
- , c = r[2] + r[0]
- , d = r[1] + r[3]
- , f = e.aspect;
- switch (isNaN(h) && (h = i - s - d - a),
- isNaN(u) && (u = n - l - c - o),
- null != f && (isNaN(h) && isNaN(u) && (f > i / n ? h = .8 * i : u = .8 * n),
- isNaN(h) && (h = f * u),
- isNaN(u) && (u = h / f)),
- isNaN(a) && (a = i - s - h - d),
- isNaN(o) && (o = n - l - u - c),
- e.left || e.right) {
- case "center":
- a = i / 2 - h / 2 - r[3];
- break;
- case "right":
- a = i - h - d
- }
- switch (e.top || e.bottom) {
- case "middle":
- case "center":
- o = n / 2 - u / 2 - r[0];
- break;
- case "bottom":
- o = n - u - c
- }
- a = a || 0,
- o = o || 0,
- isNaN(h) && (h = i - d - a - (s || 0)),
- isNaN(u) && (u = n - c - o - (l || 0));
- var p = new ws(a + r[3], o + r[0], h, u);
- return p.margin = r,
- p
- }
- wa(Ts, "vertical"),
- wa(Ts, "horizontal");
- var Ms = function () {
- this._pool = {},
- this._allocatedTextures = []
- };
- Ms.prototype = {
- constructor: Ms,
- get: function (e) {
- var t = Cs(e);
- this._pool.hasOwnProperty(t) || (this._pool[t] = []);
- var r = this._pool[t];
- if (!r.length) {
- var i = new Dr(e);
- return this._allocatedTextures.push(i),
- i
- }
- return r.pop()
- },
- put: function (e) {
- var t = Cs(e);
- this._pool.hasOwnProperty(t) || (this._pool[t] = []),
- this._pool[t].push(e)
- },
- clear: function (e) {
- for (var t = 0; t < this._allocatedTextures.length; t++)
- this._allocatedTextures[t].dispose(e);
- this._pool = {},
- this._allocatedTextures = []
- }
- };
- var As = {
- width: 512,
- height: 512,
- type: T,
- format: A,
- wrapS: I,
- wrapT: I,
- minFilter: O,
- magFilter: C,
- useMipmap: !0,
- anisotropic: 1,
- flipY: !0,
- unpackAlignment: 4,
- premultiplyAlpha: !1
- }
- , Es = Object.keys(As);
- function Cs(e) {
- var t, r, i, n;
- f.defaultsWithPropList(e, As, Es),
- r = (t = e).width,
- i = t.height,
- n = 0 == (r & r - 1) && 0 == (i & i - 1),
- t.format === M && (t.useMipmap = !1),
- n && t.useMipmap || (t.minFilter == D || t.minFilter == P ? t.minFilter = E : t.minFilter != O && t.minFilter != L || (t.minFilter = C)),
- n || (t.wrapS = I,
- t.wrapT = I);
- for (var a = "", o = 0; o < Es.length; o++)
- a += e[Es[o]].toString();
- return a
- }
- const Ds = Ms;
- var Ls = ["px", "nx", "py", "ny", "pz", "nz"];
- function Ps(e, t, r) {
- return "alphaMap" === r ? e.material.get("diffuseMap") : "alphaCutoff" === r ? e.material.isDefined("fragment", "ALPHA_TEST") && e.material.get("diffuseMap") && e.material.get("alphaCutoff") || 0 : "uvRepeat" === r ? e.material.get("uvRepeat") : "uvOffset" === r ? e.material.get("uvOffset") : t.get(r)
- }
- function Os(e, t) {
- var r = e.material
- , i = t.material;
- return r.get("diffuseMap") !== i.get("diffuseMap") || (r.get("alphaCutoff") || 0) !== (i.get("alphaCutoff") || 0)
- }
- Xe.import("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n v_ViewPosition = worldViewProjection * P;\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n #endif\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n #else\n depth += bias;\n #endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = worldViewProjection * P;\n v_WorldPosition = (world * P).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end");
- var Ns, Is, Rs, Bs, Fs, zs, Gs, Us = m.extend((function () {
- return {
- softShadow: Us.PCF,
- shadowBlur: 1,
- lightFrustumBias: "auto",
- kernelPCF: new Float32Array([1, 0, 1, 1, -1, 1, 0, 1, -1, 0, -1, -1, 1, -1, 0, -1]),
- precision: "highp",
- _lastRenderNotCastShadow: !1,
- _frameBuffer: new zi,
- _textures: {},
- _shadowMapNumber: {
- POINT_LIGHT: 0,
- DIRECTIONAL_LIGHT: 0,
- SPOT_LIGHT: 0
- },
- _depthMaterials: {},
- _distanceMaterials: {},
- _receivers: [],
- _lightsCastShadow: [],
- _lightCameras: {},
- _lightMaterials: {},
- _texturePool: new Ds
- }
- }
- ), (function () {
- this._gaussianPassH = new pn({
- fragment: Xe.source("clay.compositor.gaussian_blur")
- }),
- this._gaussianPassV = new pn({
- fragment: Xe.source("clay.compositor.gaussian_blur")
- }),
- this._gaussianPassH.setUniform("blurSize", this.shadowBlur),
- this._gaussianPassH.setUniform("blurDir", 0),
- this._gaussianPassV.setUniform("blurSize", this.shadowBlur),
- this._gaussianPassV.setUniform("blurDir", 1),
- this._outputDepthPass = new pn({
- fragment: Xe.source("clay.sm.debug_depth")
- })
- }
- ), {
- render: function (e, t, r, i) {
- r || (r = t.getMainCamera()),
- this.trigger("beforerender", this, e, t, r),
- this._renderShadowPass(e, t, r, i),
- this.trigger("afterrender", this, e, t, r)
- },
- renderDebug: function (e, t) {
- e.saveClear();
- var r = e.viewport
- , i = 0
- , n = t || r.width / 4
- , a = n;
- for (var o in this.softShadow === Us.VSM ? this._outputDepthPass.material.define("fragment", "USE_VSM") : this._outputDepthPass.material.undefine("fragment", "USE_VSM"),
- this._textures) {
- var s = this._textures[o];
- e.setViewport(i, 0, n * s.width / s.height, a),
- this._outputDepthPass.setUniform("depthMap", s),
- this._outputDepthPass.render(e),
- i += n * s.width / s.height
- }
- e.setViewport(r),
- e.restoreClear()
- },
- _updateReceivers: function (e, t) {
- if (t.receiveShadow ? (this._receivers.push(t),
- t.material.set("shadowEnabled", 1),
- t.material.set("pcfKernel", this.kernelPCF)) : t.material.set("shadowEnabled", 0),
- this.softShadow === Us.VSM)
- t.material.define("fragment", "USE_VSM"),
- t.material.undefine("fragment", "PCF_KERNEL_SIZE");
- else {
- t.material.undefine("fragment", "USE_VSM");
- var r = this.kernelPCF;
- r && r.length ? t.material.define("fragment", "PCF_KERNEL_SIZE", r.length / 2) : t.material.undefine("fragment", "PCF_KERNEL_SIZE")
- }
- },
- _update: function (e, t) {
- var r = this;
- t.traverse((function (t) {
- t.isRenderable() && r._updateReceivers(e, t)
- }
- ));
- for (var i = 0; i < t.lights.length; i++) {
- var n = t.lights[i];
- n.castShadow && !n.invisible && this._lightsCastShadow.push(n)
- }
- },
- _renderShadowPass: function (e, t, r, i) {
- for (var n in this._shadowMapNumber)
- this._shadowMapNumber[n] = 0;
- this._lightsCastShadow.length = 0,
- this._receivers.length = 0;
- var a = e.gl;
- if (i || t.update(),
- r && r.update(),
- t.updateLights(),
- this._update(e, t),
- this._lightsCastShadow.length || !this._lastRenderNotCastShadow) {
- this._lastRenderNotCastShadow = 0 === this._lightsCastShadow,
- a.enable(a.DEPTH_TEST),
- a.depthMask(!0),
- a.disable(a.BLEND),
- a.clearColor(1, 1, 1, 1);
- for (var o, s = [], l = [], h = [], u = [], c = [], d = [], f = 0; f < this._lightsCastShadow.length; f++) {
- var p = this._lightsCastShadow[f];
- if ("DIRECTIONAL_LIGHT" === p.type) {
- if (o) {
- console.warn("Only one direectional light supported with shadow cascade");
- continue
- }
- if (p.shadowCascade > 4) {
- console.warn("Support at most 4 cascade");
- continue
- }
- p.shadowCascade > 1 && (o = p),
- this.renderDirectionalLightShadow(e, t, r, p, c, u, h)
- } else
- "SPOT_LIGHT" === p.type ? this.renderSpotLightShadow(e, t, p, l, s) : "POINT_LIGHT" === p.type && this.renderPointLightShadow(e, t, p, d);
- this._shadowMapNumber[p.type]++
- }
- for (var m in this._shadowMapNumber) {
- var g = this._shadowMapNumber[m]
- , _ = m + "_SHADOWMAP_COUNT";
- for (f = 0; f < this._receivers.length; f++)
- (v = this._receivers[f].material).fragmentDefines[_] !== g && (g > 0 ? v.define("fragment", _, g) : v.isDefined("fragment", _) && v.undefine("fragment", _))
- }
- for (f = 0; f < this._receivers.length; f++) {
- var v = this._receivers[f].material;
- o ? v.define("fragment", "SHADOW_CASCADE", o.shadowCascade) : v.undefine("fragment", "SHADOW_CASCADE")
- }
- var y = t.shadowUniforms;
- if (h.length > 0) {
- var x = h.map(S);
- if (y.directionalLightShadowMaps = {
- value: h,
- type: "tv"
- },
- y.directionalLightMatrices = {
- value: u,
- type: "m4v"
- },
- y.directionalLightShadowMapSizes = {
- value: x,
- type: "1fv"
- },
- o) {
- var b = c.slice()
- , w = c.slice();
- b.pop(),
- w.shift(),
- b.reverse(),
- w.reverse(),
- u.reverse(),
- y.shadowCascadeClipsNear = {
- value: b,
- type: "1fv"
- },
- y.shadowCascadeClipsFar = {
- value: w,
- type: "1fv"
- }
- }
- }
- if (s.length > 0) {
- var T = s.map(S);
- (y = t.shadowUniforms).spotLightShadowMaps = {
- value: s,
- type: "tv"
- },
- y.spotLightMatrices = {
- value: l,
- type: "m4v"
- },
- y.spotLightShadowMapSizes = {
- value: T,
- type: "1fv"
- }
- }
- d.length > 0 && (y.pointLightShadowMaps = {
- value: d,
- type: "tv"
- })
- }
- function S(e) {
- return e.height
- }
- },
- renderDirectionalLightShadow: (Ns = new si,
- Is = new Ht,
- Rs = new ir,
- Bs = new Ht,
- Fs = new Ht,
- zs = new Ht,
- Gs = new Ht,
- function (e, t, r, i, n, a, o) {
- var s = this._getDepthMaterial(i)
- , l = {
- getMaterial: function (e) {
- return e.shadowDepthMaterial || s
- },
- isMaterialChanged: Os,
- getUniform: Ps,
- ifRender: function (e) {
- return e.castShadow
- },
- sortCompare: ut.opaqueSortCompare
- };
- if (!t.viewBoundingBoxLastFrame.isFinite()) {
- var h = t.getBoundingBox();
- t.viewBoundingBoxLastFrame.copy(h).applyTransform(r.viewMatrix)
- }
- var u = Math.min(-t.viewBoundingBoxLastFrame.min.z, r.far)
- , c = Math.max(-t.viewBoundingBoxLastFrame.max.z, r.near)
- , d = this._getDirectionalLightCamera(i, t, r)
- , f = zs.array;
- Gs.copy(d.projectionMatrix),
- Ye.invert(Fs.array, d.worldTransform.array),
- Ye.multiply(Fs.array, Fs.array, r.worldTransform.array),
- Ye.multiply(f, Gs.array, Fs.array);
- for (var p = [], m = r instanceof Ei, g = (r.near + r.far) / (r.near - r.far), _ = 2 * r.near * r.far / (r.near - r.far), v = 0; v <= i.shadowCascade; v++) {
- var y = c * Math.pow(u / c, v / i.shadowCascade)
- , x = c + (u - c) * v / i.shadowCascade
- , b = y * i.cascadeSplitLogFactor + x * (1 - i.cascadeSplitLogFactor);
- p.push(b),
- n.push(-(-b * g + _) / -b)
- }
- var w = this._getTexture(i, i.shadowCascade);
- o.push(w);
- var T = e.viewport
- , S = e.gl;
- for (this._frameBuffer.attach(w),
- this._frameBuffer.bind(e),
- S.clear(S.COLOR_BUFFER_BIT | S.DEPTH_BUFFER_BIT),
- v = 0; v < i.shadowCascade; v++) {
- var M = p[v]
- , A = p[v + 1];
- m ? Ye.perspective(Is.array, r.fov / 180 * Math.PI, r.aspect, M, A) : Ye.ortho(Is.array, r.left, r.right, r.bottom, r.top, M, A),
- Ns.setFromProjection(Is),
- Ns.getTransformedBoundingBox(Rs, Fs),
- Rs.applyProjection(Gs);
- var E = Rs.min.array
- , C = Rs.max.array;
- E[0] = Math.max(E[0], -1),
- E[1] = Math.max(E[1], -1),
- C[0] = Math.min(C[0], 1),
- C[1] = Math.min(C[1], 1),
- Bs.ortho(E[0], C[0], E[1], C[1], 1, -1),
- d.projectionMatrix.multiplyLeft(Bs);
- var D = i.shadowResolution || 512;
- e.setViewport((i.shadowCascade - v - 1) * D, 0, D, D, 1);
- var L = t.updateRenderList(d);
- e.renderPass(L.opaque, d, l),
- this.softShadow === Us.VSM && this._gaussianFilter(e, w, w.width);
- var P = new Ht;
- P.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),
- a.push(P.array),
- d.projectionMatrix.copy(Gs)
- }
- this._frameBuffer.unbind(e),
- e.setViewport(T)
- }
- ),
- renderSpotLightShadow: function (e, t, r, i, n) {
- var a = this._getTexture(r)
- , o = this._getSpotLightCamera(r)
- , s = e.gl;
- this._frameBuffer.attach(a),
- this._frameBuffer.bind(e),
- s.clear(s.COLOR_BUFFER_BIT | s.DEPTH_BUFFER_BIT);
- var l = this._getDepthMaterial(r)
- , h = {
- getMaterial: function (e) {
- return e.shadowDepthMaterial || l
- },
- isMaterialChanged: Os,
- getUniform: Ps,
- ifRender: function (e) {
- return e.castShadow
- },
- sortCompare: ut.opaqueSortCompare
- }
- , u = t.updateRenderList(o);
- e.renderPass(u.opaque, o, h),
- this._frameBuffer.unbind(e),
- this.softShadow === Us.VSM && this._gaussianFilter(e, a, a.width);
- var c = new Ht;
- c.copy(o.worldTransform).invert().multiplyLeft(o.projectionMatrix),
- n.push(a),
- i.push(c.array)
- },
- renderPointLightShadow: function (e, t, r, i) {
- var n = this._getTexture(r)
- , a = e.gl;
- i.push(n);
- var o = this._getDepthMaterial(r)
- , s = {
- getMaterial: function (e) {
- return e.shadowDepthMaterial || o
- },
- getUniform: Ps,
- sortCompare: ut.opaqueSortCompare
- }
- , l = {
- px: [],
- py: [],
- pz: [],
- nx: [],
- ny: [],
- nz: []
- }
- , h = new ir
- , u = r.getWorldPosition().array
- , c = new ir
- , d = r.range;
- c.min.setArray(u),
- c.max.setArray(u);
- var f = new vt(d, d, d);
- c.max.add(f),
- c.min.sub(f);
- var p = {
- px: !1,
- py: !1,
- pz: !1,
- nx: !1,
- ny: !1,
- nz: !1
- };
- t.traverse((function (e) {
- if (e.isRenderable() && e.castShadow) {
- var t = e.geometry;
- if (!t.boundingBox) {
- for (var r = 0; r < Ls.length; r++)
- l[Ls[r]].push(e);
- return
- }
- if (h.transformFrom(t.boundingBox, e.worldTransform),
- !h.intersectBoundingBox(c))
- return;
- for (h.updateVertices(),
- r = 0; r < Ls.length; r++)
- p[Ls[r]] = !1;
- for (r = 0; r < 8; r++) {
- var i = h.vertices[r]
- , n = i[0] - u[0]
- , a = i[1] - u[1]
- , o = i[2] - u[2]
- , s = Math.abs(n)
- , d = Math.abs(a)
- , f = Math.abs(o);
- s > d ? s > f ? p[n > 0 ? "px" : "nx"] = !0 : p[o > 0 ? "pz" : "nz"] = !0 : d > f ? p[a > 0 ? "py" : "ny"] = !0 : p[o > 0 ? "pz" : "nz"] = !0
- }
- for (r = 0; r < Ls.length; r++)
- p[Ls[r]] && l[Ls[r]].push(e)
- }
- }
- ));
- for (var m = 0; m < 6; m++) {
- var g = Ls[m]
- , _ = this._getPointLightCamera(r, g);
- this._frameBuffer.attach(n, a.COLOR_ATTACHMENT0, a.TEXTURE_CUBE_MAP_POSITIVE_X + m),
- this._frameBuffer.bind(e),
- a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT),
- e.renderPass(l[g], _, s)
- }
- this._frameBuffer.unbind(e)
- },
- _getDepthMaterial: function (e) {
- var t = this._lightMaterials[e.__uid__]
- , r = "POINT_LIGHT" === e.type;
- if (!t) {
- var i = r ? "clay.sm.distance." : "clay.sm.depth.";
- t = new le({
- precision: this.precision,
- shader: new Xe(Xe.source(i + "vertex"), Xe.source(i + "fragment"))
- }),
- this._lightMaterials[e.__uid__] = t
- }
- return null != e.shadowSlopeScale && t.setUniform("slopeScale", e.shadowSlopeScale),
- null != e.shadowBias && t.setUniform("bias", e.shadowBias),
- this.softShadow === Us.VSM ? t.define("fragment", "USE_VSM") : t.undefine("fragment", "USE_VSM"),
- r && (t.set("lightPosition", e.getWorldPosition().array),
- t.set("range", e.range)),
- t
- },
- _gaussianFilter: function (e, t, r) {
- var i = {
- width: r,
- height: r,
- type: wr.FLOAT
- }
- , n = this._texturePool.get(i);
- this._frameBuffer.attach(n),
- this._frameBuffer.bind(e),
- this._gaussianPassH.setUniform("texture", t),
- this._gaussianPassH.setUniform("textureWidth", r),
- this._gaussianPassH.render(e),
- this._frameBuffer.attach(t),
- this._gaussianPassV.setUniform("texture", n),
- this._gaussianPassV.setUniform("textureHeight", r),
- this._gaussianPassV.render(e),
- this._frameBuffer.unbind(e),
- this._texturePool.put(n)
- },
- _getTexture: function (e, t) {
- var r = e.__uid__
- , i = this._textures[r]
- , n = e.shadowResolution || 512;
- return t = t || 1,
- i || ((i = "POINT_LIGHT" === e.type ? new Ai : new Dr).width = n * t,
- i.height = n,
- this.softShadow === Us.VSM ? (i.type = wr.FLOAT,
- i.anisotropic = 4) : (i.minFilter = E,
- i.magFilter = E,
- i.useMipmap = !1),
- this._textures[r] = i),
- i
- },
- _getPointLightCamera: function (e, t) {
- this._lightCameras.point || (this._lightCameras.point = {
- px: new Ei,
- nx: new Ei,
- py: new Ei,
- ny: new Ei,
- pz: new Ei,
- nz: new Ei
- });
- var r = this._lightCameras.point[t];
- switch (r.far = e.range,
- r.fov = 90,
- r.position.set(0, 0, 0),
- t) {
- case "px":
- r.lookAt(vt.POSITIVE_X, vt.NEGATIVE_Y);
- break;
- case "nx":
- r.lookAt(vt.NEGATIVE_X, vt.NEGATIVE_Y);
- break;
- case "py":
- r.lookAt(vt.POSITIVE_Y, vt.POSITIVE_Z);
- break;
- case "ny":
- r.lookAt(vt.NEGATIVE_Y, vt.NEGATIVE_Z);
- break;
- case "pz":
- r.lookAt(vt.POSITIVE_Z, vt.NEGATIVE_Y);
- break;
- case "nz":
- r.lookAt(vt.NEGATIVE_Z, vt.NEGATIVE_Y)
- }
- return e.getWorldPosition(r.position),
- r.update(),
- r
- },
- _getDirectionalLightCamera: function () {
- var e = new Ht
- , t = new ir
- , r = new ir;
- return function (i, n, a) {
- this._lightCameras.directional || (this._lightCameras.directional = new un);
- var o = this._lightCameras.directional;
- t.copy(n.viewBoundingBoxLastFrame),
- t.intersection(a.frustum.boundingBox),
- o.position.copy(t.min).add(t.max).scale(.5).transformMat4(a.worldTransform),
- o.rotation.copy(i.rotation),
- o.scale.copy(i.scale),
- o.updateWorldTransform(),
- Ht.invert(e, o.worldTransform),
- Ht.multiply(e, e, a.worldTransform),
- r.copy(t).applyTransform(e);
- var s = r.min.array
- , l = r.max.array;
- return o.position.set((s[0] + l[0]) / 2, (s[1] + l[1]) / 2, l[2]).transformMat4(o.worldTransform),
- o.near = 0,
- o.far = -s[2] + l[2],
- isNaN(this.lightFrustumBias) ? o.far *= 4 : o.far += this.lightFrustumBias,
- o.left = s[0],
- o.right = l[0],
- o.top = l[1],
- o.bottom = s[1],
- o.update(!0),
- o
- }
- }(),
- _getSpotLightCamera: function (e) {
- this._lightCameras.spot || (this._lightCameras.spot = new Ei);
- var t = this._lightCameras.spot;
- return t.fov = 2 * e.penumbraAngle,
- t.far = e.range,
- t.worldTransform.copy(e.worldTransform),
- t.updateProjectionMatrix(),
- Ye.invert(t.viewMatrix.array, t.worldTransform.array),
- t
- },
- dispose: function (e) {
- var t = e.gl || e;
- for (var r in this._frameBuffer && this._frameBuffer.dispose(t),
- this._textures)
- this._textures[r].dispose(t);
- this._texturePool.clear(e.gl),
- this._depthMaterials = {},
- this._distanceMaterials = {},
- this._textures = {},
- this._lightCameras = {},
- this._shadowMapNumber = {
- POINT_LIGHT: 0,
- DIRECTIONAL_LIGHT: 0,
- SPOT_LIGHT: 0
- },
- this._meshMaterials = {};
- for (var i = 0; i < this._receivers.length; i++) {
- var n = this._receivers[i];
- if (n.material) {
- var a = n.material;
- a.undefine("fragment", "POINT_LIGHT_SHADOW_COUNT"),
- a.undefine("fragment", "DIRECTIONAL_LIGHT_SHADOW_COUNT"),
- a.undefine("fragment", "AMBIENT_LIGHT_SHADOW_COUNT"),
- a.set("shadowEnabled", 0)
- }
- }
- this._receivers = [],
- this._lightsCastShadow = []
- }
- });
- Us.VSM = 1,
- Us.PCF = 2;
- const ks = Us
- , Vs = m.extend((function () {
- return {
- name: "",
- inputLinks: {},
- outputLinks: {},
- _prevOutputTextures: {},
- _outputTextures: {},
- _outputReferences: {},
- _rendering: !1,
- _rendered: !1,
- _compositor: null
- }
- }
- ), {
- updateParameter: function (e, t) {
- var r, i, n = this.outputs[e], a = n.parameters, o = n._parametersCopy;
- if (o || (o = n._parametersCopy = {}),
- a)
- for (var s in a)
- "width" !== s && "height" !== s && (o[s] = a[s]);
- return r = a.width instanceof Function ? a.width.call(this, t) : a.width,
- i = a.height instanceof Function ? a.height.call(this, t) : a.height,
- o.width === r && o.height === i || this._outputTextures[e] && this._outputTextures[e].dispose(t.gl),
- o.width = r,
- o.height = i,
- o
- },
- setParameter: function (e, t) { },
- getParameter: function (e) { },
- setParameters: function (e) {
- for (var t in e)
- this.setParameter(t, e[t])
- },
- render: function () { },
- getOutput: function (e, t) {
- if (null == t)
- return t = e,
- this._outputTextures[t];
- var r = this.outputs[t];
- return r ? this._rendered ? r.outputLastFrame ? this._prevOutputTextures[t] : this._outputTextures[t] : this._rendering ? (this._prevOutputTextures[t] || (this._prevOutputTextures[t] = this._compositor.allocateTexture(r.parameters || {})),
- this._prevOutputTextures[t]) : (this.render(e),
- this._outputTextures[t]) : void 0
- },
- removeReference: function (e) {
- this._outputReferences[e]--,
- 0 === this._outputReferences[e] && (this.outputs[e].keepLastFrame ? (this._prevOutputTextures[e] && this._compositor.releaseTexture(this._prevOutputTextures[e]),
- this._prevOutputTextures[e] = this._outputTextures[e]) : this._compositor.releaseTexture(this._outputTextures[e]))
- },
- link: function (e, t, r) {
- this.inputLinks[e] = {
- node: t,
- pin: r
- },
- t.outputLinks[r] || (t.outputLinks[r] = []),
- t.outputLinks[r].push({
- node: this,
- pin: e
- }),
- this.pass.material.enableTexture(e)
- },
- clear: function () {
- this.inputLinks = {},
- this.outputLinks = {}
- },
- updateReference: function (e) {
- if (!this._rendering) {
- for (var t in this._rendering = !0,
- this.inputLinks) {
- var r = this.inputLinks[t];
- r.node.updateReference(r.pin)
- }
- this._rendering = !1
- }
- e && this._outputReferences[e]++
- },
- beforeFrame: function () {
- for (var e in this._rendered = !1,
- this.outputLinks)
- this._outputReferences[e] = 0
- },
- afterFrame: function () {
- for (var e in this.outputLinks)
- this._outputReferences[e] > 0 && (this.outputs[e].keepLastFrame ? (this._prevOutputTextures[e] && this._compositor.releaseTexture(this._prevOutputTextures[e]),
- this._prevOutputTextures[e] = this._outputTextures[e]) : this._compositor.releaseTexture(this._outputTextures[e]))
- }
- })
- , Hs = m.extend((function () {
- return {
- nodes: []
- }
- }
- ), {
- dirty: function () {
- this._dirty = !0
- },
- addNode: function (e) {
- this.nodes.indexOf(e) >= 0 || (this.nodes.push(e),
- this._dirty = !0)
- },
- removeNode: function (e) {
- "string" == typeof e && (e = this.getNodeByName(e));
- var t = this.nodes.indexOf(e);
- t >= 0 && (this.nodes.splice(t, 1),
- this._dirty = !0)
- },
- getNodeByName: function (e) {
- for (var t = 0; t < this.nodes.length; t++)
- if (this.nodes[t].name === e)
- return this.nodes[t]
- },
- update: function () {
- for (var e = 0; e < this.nodes.length; e++)
- this.nodes[e].clear();
- for (e = 0; e < this.nodes.length; e++) {
- var t = this.nodes[e];
- if (t.inputs)
- for (var r in t.inputs)
- if (t.inputs[r])
- if (!t.pass || t.pass.material.isUniformEnabled(r)) {
- var i = t.inputs[r]
- , n = this.findPin(i);
- n ? t.link(r, n.node, n.pin) : "string" == typeof i ? console.warn("Node " + i + " not exist") : console.warn("Pin of " + i.node + "." + i.pin + " not exist")
- } else
- console.warn("Pin " + t.name + "." + r + " not used.")
- }
- },
- findPin: function (e) {
- var t;
- if (("string" == typeof e || e instanceof Vs) && (e = {
- node: e
- }),
- "string" == typeof e.node)
- for (var r = 0; r < this.nodes.length; r++) {
- var i = this.nodes[r];
- i.name === e.node && (t = i)
- }
- else
- t = e.node;
- if (t) {
- var n = e.pin;
- if (n || t.outputs && (n = Object.keys(t.outputs)[0]),
- t.outputs[n])
- return {
- node: t,
- pin: n
- }
- }
- }
- })
- , Ws = Hs.extend((function () {
- return {
- _outputs: [],
- _texturePool: new Ds,
- _frameBuffer: new zi({
- depthBuffer: !1
- })
- }
- }
- ), {
- addNode: function (e) {
- Hs.prototype.addNode.call(this, e),
- e._compositor = this
- },
- render: function (e, t) {
- if (this._dirty) {
- this.update(),
- this._dirty = !1,
- this._outputs.length = 0;
- for (var r = 0; r < this.nodes.length; r++)
- this.nodes[r].outputs || this._outputs.push(this.nodes[r])
- }
- for (r = 0; r < this.nodes.length; r++)
- this.nodes[r].beforeFrame();
- for (r = 0; r < this._outputs.length; r++)
- this._outputs[r].updateReference();
- for (r = 0; r < this._outputs.length; r++)
- this._outputs[r].render(e, t);
- for (r = 0; r < this.nodes.length; r++)
- this.nodes[r].afterFrame()
- },
- allocateTexture: function (e) {
- return this._texturePool.get(e)
- },
- releaseTexture: function (e) {
- this._texturePool.put(e)
- },
- getFrameBuffer: function () {
- return this._frameBuffer
- },
- dispose: function (e) {
- this._texturePool.clear(e)
- }
- })
- , js = Vs.extend({
- name: "scene",
- scene: null,
- camera: null,
- autoUpdateScene: !0,
- preZ: !1
- }, (function () {
- this.frameBuffer = new zi
- }
- ), {
- render: function (e) {
- this._rendering = !0;
- var t, r = e.gl;
- if (this.trigger("beforerender"),
- this.outputs) {
- var i = this.frameBuffer;
- for (var n in this.outputs) {
- var a = this.updateParameter(n, e)
- , o = this.outputs[n]
- , s = this._compositor.allocateTexture(a);
- this._outputTextures[n] = s,
- "string" == typeof (u = o.attachment || r.COLOR_ATTACHMENT0) && (u = r[u]),
- i.attach(s, u)
- }
- i.bind(e);
- var l = e.getGLExtension("EXT_draw_buffers");
- if (l) {
- var h = [];
- for (var u in this.outputs)
- (u = parseInt(u)) >= r.COLOR_ATTACHMENT0 && u <= r.COLOR_ATTACHMENT0 + 8 && h.push(u);
- l.drawBuffersEXT(h)
- }
- e.saveClear(),
- e.clearBit = 16640,
- t = e.render(this.scene, this.camera, !this.autoUpdateScene, this.preZ),
- e.restoreClear(),
- i.unbind(e)
- } else
- t = e.render(this.scene, this.camera, !this.autoUpdateScene, this.preZ);
- this.trigger("afterrender", t),
- this._rendering = !1,
- this._rendered = !0
- }
- })
- , Xs = Vs.extend((function () {
- return {
- texture: null,
- outputs: {
- color: {}
- }
- }
- }
- ), (function () { }
- ), {
- getOutput: function (e, t) {
- return this.texture
- },
- beforeFrame: function () { },
- afterFrame: function () { }
- })
- , qs = Vs.extend((function () {
- return {
- name: "",
- inputs: {},
- outputs: null,
- shader: "",
- inputLinks: {},
- outputLinks: {},
- pass: null,
- _prevOutputTextures: {},
- _outputTextures: {},
- _outputReferences: {},
- _rendering: !1,
- _rendered: !1,
- _compositor: null
- }
- }
- ), (function () {
- var e = new pn({
- fragment: this.shader
- });
- this.pass = e
- }
- ), {
- render: function (e, t) {
- this.trigger("beforerender", e),
- this._rendering = !0;
- var r = e.gl;
- for (var i in this.inputLinks) {
- var n = (c = this.inputLinks[i]).node.getOutput(e, c.pin);
- this.pass.setUniform(i, n)
- }
- if (this.outputs) {
- this.pass.outputs = {};
- var a = {};
- for (var o in this.outputs) {
- var s = this.updateParameter(o, e);
- isNaN(s.width) && this.updateParameter(o, e);
- var l = this.outputs[o]
- , h = this._compositor.allocateTexture(s);
- this._outputTextures[o] = h,
- "string" == typeof (u = l.attachment || r.COLOR_ATTACHMENT0) && (u = r[u]),
- a[u] = h
- }
- for (var u in this._compositor.getFrameBuffer().bind(e),
- a)
- this._compositor.getFrameBuffer().attach(a[u], u);
- this.pass.render(e),
- this._compositor.getFrameBuffer().updateMipmap(e)
- } else
- this.pass.outputs = null,
- this._compositor.getFrameBuffer().unbind(e),
- this.pass.render(e, t);
- for (var i in this.inputLinks) {
- var c;
- (c = this.inputLinks[i]).node.removeReference(c.pin)
- }
- this._rendering = !1,
- this._rendered = !0,
- this.trigger("afterrender", e)
- },
- updateParameter: function (e, t) {
- var r, i, n = this.outputs[e], a = n.parameters, o = n._parametersCopy;
- if (o || (o = n._parametersCopy = {}),
- a)
- for (var s in a)
- "width" !== s && "height" !== s && (o[s] = a[s]);
- return r = "function" == typeof a.width ? a.width.call(this, t) : a.width,
- i = "function" == typeof a.height ? a.height.call(this, t) : a.height,
- r = Math.ceil(r),
- i = Math.ceil(i),
- o.width === r && o.height === i || this._outputTextures[e] && this._outputTextures[e].dispose(t),
- o.width = r,
- o.height = i,
- o
- },
- setParameter: function (e, t) {
- this.pass.setUniform(e, t)
- },
- getParameter: function (e) {
- return this.pass.getUniform(e)
- },
- setParameters: function (e) {
- for (var t in e)
- this.setParameter(t, e[t])
- },
- define: function (e, t) {
- this.pass.material.define("fragment", e, t)
- },
- undefine: function (e) {
- this.pass.material.undefine("fragment", e)
- },
- removeReference: function (e) {
- this._outputReferences[e]--,
- 0 === this._outputReferences[e] && (this.outputs[e].keepLastFrame ? (this._prevOutputTextures[e] && this._compositor.releaseTexture(this._prevOutputTextures[e]),
- this._prevOutputTextures[e] = this._outputTextures[e]) : this._compositor.releaseTexture(this._outputTextures[e]))
- },
- clear: function () {
- Vs.prototype.clear.call(this),
- this.pass.material.disableTexturesAll()
- }
- })
- , Zs = "@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n"
- , Ys = "\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end"
- , Ks = "@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"
- , Qs = "@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n"
- , Js = "@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end"
- , $s = "\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end"
- , el = "@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"
- , tl = "@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end"
- , rl = "@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end";
- !function (e) {
- e.import("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"),
- e.import(Zs),
- e.import("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"),
- e.import(Ys),
- e.import("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"),
- e.import(Ks),
- e.import(Qs),
- e.import(Js),
- e.import($s),
- e.import(el),
- e.import("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"),
- e.import(tl),
- e.import(rl)
- }(Xe);
- var il = /^#source\((.*?)\)/;
- function nl(e, t, r) {
- var i, n, a, o, s = e.type || "filter";
- if ("filter" === s) {
- var l = e.shader.trim()
- , h = il.exec(l);
- if (h ? i = Xe.source(h[1].trim()) : "#" === l.charAt(0) && (i = t.shaders[l.substr(1)]),
- i || (i = l),
- !i)
- return
- }
- if (e.inputs)
- for (var u in n = {},
- e.inputs)
- "string" == typeof e.inputs[u] ? n[u] = e.inputs[u] : n[u] = {
- node: e.inputs[u].node,
- pin: e.inputs[u].pin
- };
- if (e.outputs)
- for (var u in a = {},
- e.outputs) {
- var c = e.outputs[u];
- a[u] = {},
- null != c.attachment && (a[u].attachment = c.attachment),
- null != c.keepLastFrame && (a[u].keepLastFrame = c.keepLastFrame),
- null != c.outputLastFrame && (a[u].outputLastFrame = c.outputLastFrame),
- c.parameters && (a[u].parameters = sl(c.parameters))
- }
- if (o = "scene" === s ? new js({
- name: e.name,
- scene: r.scene,
- camera: r.camera,
- outputs: a
- }) : "texture" === s ? new Xs({
- name: e.name,
- outputs: a
- }) : new qs({
- name: e.name,
- shader: i,
- inputs: n,
- outputs: a
- })) {
- if (e.parameters)
- for (var u in e.parameters)
- "string" == typeof (d = e.parameters[u]) ? "#" === (d = d.trim()).charAt(0) ? d = t.textures[d.substr(1)] : o.on("beforerender", ll(u, hl(d))) : "function" == typeof d && o.on("beforerender", d),
- o.setParameter(u, d);
- if (e.defines && o.pass)
- for (var u in e.defines) {
- var d = e.defines[u];
- o.pass.material.define("fragment", u, d)
- }
- }
- return o
- }
- function al(e, t) {
- return e
- }
- function ol(e, t) {
- return t
- }
- function sl(e) {
- var t = {};
- if (!e)
- return t;
- ["type", "minFilter", "magFilter", "wrapS", "wrapT", "flipY", "useMipmap"].forEach((function (r) {
- var i = e[r];
- null != i && ("string" == typeof i && (i = wr[i]),
- t[r] = i)
- }
- ));
- var r = e.scale || 1;
- return ["width", "height"].forEach((function (i) {
- if (null != e[i]) {
- var n = e[i];
- "string" == typeof n ? (n = n.trim(),
- t[i] = (a = hl(n),
- o = (o = r) || 1,
- function (e) {
- var t = e.getDevicePixelRatio()
- , r = e.getWidth() * o
- , i = e.getHeight() * o;
- return a(r, i, t)
- }
- )) : t[i] = n
- }
- var a, o
- }
- )),
- t.width || (t.width = al),
- t.height || (t.height = ol),
- null != e.useMipmap && (t.useMipmap = e.useMipmap),
- t
- }
- function ll(e, t) {
- return function (r) {
- var i = r.getDevicePixelRatio()
- , n = r.getWidth()
- , a = r.getHeight()
- , o = t(n, a, i);
- this.setParameter(e, o)
- }
- }
- function hl(e) {
- var t = /^expr\((.*)\)$/.exec(e);
- if (t)
- try {
- var r = new Function("width", "height", "dpr", "return " + t[1]);
- return r(1, 1),
- r
- } catch (e) {
- throw new Error("Invalid expression.")
- }
- }
- const ul = function (e, t) {
- for (var r = 0, i = 1 / t, n = e; n > 0;)
- r += i * (n % t),
- n = Math.floor(n / t),
- i /= t;
- return r
- };
- function cl(e) {
- for (var t = new Uint8Array(e * e * 4), r = 0, i = new vt, n = 0; n < e; n++)
- for (var a = 0; a < e; a++)
- i.set(2 * Math.random() - 1, 2 * Math.random() - 1, 0).normalize(),
- t[r++] = 255 * (.5 * i.x + .5),
- t[r++] = 255 * (.5 * i.y + .5),
- t[r++] = 0,
- t[r++] = 255;
- return t
- }
- function dl(e) {
- return new Dr({
- pixels: cl(e),
- wrapS: wr.REPEAT,
- wrapT: wr.REPEAT,
- width: e,
- height: e
- })
- }
- function fl(e, t, r) {
- var i = new Float32Array(3 * e);
- t = t || 0;
- for (var n = 0; n < e; n++) {
- var a = ul(n + t, 2) * (r ? 1 : 2) * Math.PI
- , o = ul(n + t, 3) * Math.PI
- , s = Math.random()
- , l = Math.cos(a) * Math.sin(o) * s
- , h = Math.cos(o) * s
- , u = Math.sin(a) * Math.sin(o) * s;
- i[3 * n] = l,
- i[3 * n + 1] = h,
- i[3 * n + 2] = u
- }
- return i
- }
- function pl(e) {
- e = e || {},
- this._ssaoPass = new pn({
- fragment: Xe.source("ecgl.ssao.estimate")
- }),
- this._blurPass = new pn({
- fragment: Xe.source("ecgl.ssao.blur")
- }),
- this._framebuffer = new zi({
- depthBuffer: !1
- }),
- this._ssaoTexture = new Dr,
- this._blurTexture = new Dr,
- this._blurTexture2 = new Dr,
- this._depthTex = e.depthTexture,
- this._normalTex = e.normalTexture,
- this.setNoiseSize(4),
- this.setKernelSize(e.kernelSize || 12),
- null != e.radius && this.setParameter("radius", e.radius),
- null != e.power && this.setParameter("power", e.power),
- this._normalTex || (this._ssaoPass.material.disableTexture("normalTex"),
- this._blurPass.material.disableTexture("normalTex")),
- this._depthTex || this._blurPass.material.disableTexture("depthTex"),
- this._blurPass.material.setUniform("normalTex", this._normalTex),
- this._blurPass.material.setUniform("depthTex", this._depthTex)
- }
- Xe.import("@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),
- pl.prototype.setDepthTexture = function (e) {
- this._depthTex = e
- }
- ,
- pl.prototype.setNormalTexture = function (e) {
- this._normalTex = e,
- this._ssaoPass.material[e ? "enableTexture" : "disableTexture"]("normalTex"),
- this.setKernelSize(this._kernelSize)
- }
- ,
- pl.prototype.update = function (e, t, r) {
- var i = e.getWidth()
- , n = e.getHeight()
- , a = this._ssaoPass
- , o = this._blurPass;
- a.setUniform("kernel", this._kernels[r % this._kernels.length]),
- a.setUniform("depthTex", this._depthTex),
- null != this._normalTex && a.setUniform("normalTex", this._normalTex),
- a.setUniform("depthTexSize", [this._depthTex.width, this._depthTex.height]);
- var s = new Ht;
- Ht.transpose(s, t.worldTransform),
- a.setUniform("projection", t.projectionMatrix.array),
- a.setUniform("projectionInv", t.invProjectionMatrix.array),
- a.setUniform("viewInverseTranspose", s.array);
- var l = this._ssaoTexture
- , h = this._blurTexture
- , u = this._blurTexture2;
- l.width = i / 2,
- l.height = n / 2,
- h.width = i,
- h.height = n,
- u.width = i,
- u.height = n,
- this._framebuffer.attach(l),
- this._framebuffer.bind(e),
- e.gl.clearColor(1, 1, 1, 1),
- e.gl.clear(e.gl.COLOR_BUFFER_BIT),
- a.render(e),
- o.setUniform("textureSize", [i / 2, n / 2]),
- o.setUniform("projection", t.projectionMatrix.array),
- this._framebuffer.attach(h),
- o.setUniform("direction", 0),
- o.setUniform("ssaoTexture", l),
- o.render(e),
- this._framebuffer.attach(u),
- o.setUniform("textureSize", [i, n]),
- o.setUniform("direction", 1),
- o.setUniform("ssaoTexture", h),
- o.render(e),
- this._framebuffer.unbind(e);
- var c = e.clearColor;
- e.gl.clearColor(c[0], c[1], c[2], c[3])
- }
- ,
- pl.prototype.getTargetTexture = function () {
- return this._blurTexture2
- }
- ,
- pl.prototype.setParameter = function (e, t) {
- "noiseTexSize" === e ? this.setNoiseSize(t) : "kernelSize" === e ? this.setKernelSize(t) : "intensity" === e ? this._ssaoPass.material.set("intensity", t) : this._ssaoPass.setUniform(e, t)
- }
- ,
- pl.prototype.setKernelSize = function (e) {
- this._kernelSize = e,
- this._ssaoPass.material.define("fragment", "KERNEL_SIZE", e),
- this._kernels = this._kernels || [];
- for (var t = 0; t < 30; t++)
- this._kernels[t] = fl(e, t * e, !!this._normalTex)
- }
- ,
- pl.prototype.setNoiseSize = function (e) {
- var t = this._ssaoPass.getUniform("noiseTex");
- t ? (t.data = cl(e),
- t.width = t.height = e,
- t.dirty()) : (t = dl(e),
- this._ssaoPass.setUniform("noiseTex", dl(e))),
- this._ssaoPass.setUniform("noiseTexSize", [e, e])
- }
- ,
- pl.prototype.dispose = function (e) {
- this._blurTexture.dispose(e),
- this._ssaoTexture.dispose(e),
- this._blurTexture2.dispose(e)
- }
- ;
- const ml = pl;
- function gl(e) {
- e = e || {},
- this._ssrPass = new pn({
- fragment: Xe.source("ecgl.ssr.main"),
- clearColor: [0, 0, 0, 0]
- }),
- this._blurPass1 = new pn({
- fragment: Xe.source("ecgl.ssr.blur"),
- clearColor: [0, 0, 0, 0]
- }),
- this._blurPass2 = new pn({
- fragment: Xe.source("ecgl.ssr.blur"),
- clearColor: [0, 0, 0, 0]
- }),
- this._blendPass = new pn({
- fragment: Xe.source("clay.compositor.blend")
- }),
- this._blendPass.material.disableTexturesAll(),
- this._blendPass.material.enableTexture(["texture1", "texture2"]),
- this._ssrPass.setUniform("gBufferTexture1", e.normalTexture),
- this._ssrPass.setUniform("gBufferTexture2", e.depthTexture),
- this._blurPass1.setUniform("gBufferTexture1", e.normalTexture),
- this._blurPass1.setUniform("gBufferTexture2", e.depthTexture),
- this._blurPass2.setUniform("gBufferTexture1", e.normalTexture),
- this._blurPass2.setUniform("gBufferTexture2", e.depthTexture),
- this._blurPass2.material.define("fragment", "VERTICAL"),
- this._blurPass2.material.define("fragment", "BLEND"),
- this._ssrTexture = new Dr({
- type: wr.HALF_FLOAT
- }),
- this._texture2 = new Dr({
- type: wr.HALF_FLOAT
- }),
- this._texture3 = new Dr({
- type: wr.HALF_FLOAT
- }),
- this._prevTexture = new Dr({
- type: wr.HALF_FLOAT
- }),
- this._currentTexture = new Dr({
- type: wr.HALF_FLOAT
- }),
- this._frameBuffer = new zi({
- depthBuffer: !1
- }),
- this._normalDistribution = null,
- this._totalSamples = 256,
- this._samplePerFrame = 4,
- this._ssrPass.material.define("fragment", "SAMPLE_PER_FRAME", this._samplePerFrame),
- this._ssrPass.material.define("fragment", "TOTAL_SAMPLES", this._totalSamples),
- this._downScale = 1
- }
- Xe.import("@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),
- gl.prototype.setAmbientCubemap = function (e, t) {
- this._ssrPass.material.set("specularCubemap", e),
- this._ssrPass.material.set("specularIntensity", t);
- var r = e && t;
- this._ssrPass.material[r ? "enableTexture" : "disableTexture"]("specularCubemap")
- }
- ,
- gl.prototype.update = function (e, t, r, i) {
- var n = e.getWidth()
- , a = e.getHeight()
- , o = this._ssrTexture
- , s = this._texture2
- , l = this._texture3;
- o.width = this._prevTexture.width = this._currentTexture.width = n / this._downScale,
- o.height = this._prevTexture.height = this._currentTexture.height = a / this._downScale,
- s.width = l.width = n,
- s.height = l.height = a;
- var h = this._frameBuffer
- , u = this._ssrPass
- , c = this._blurPass1
- , d = this._blurPass2
- , f = this._blendPass
- , p = new Ht
- , m = new Ht;
- Ht.transpose(p, t.worldTransform),
- Ht.transpose(m, t.viewMatrix),
- u.setUniform("sourceTexture", r),
- u.setUniform("projection", t.projectionMatrix.array),
- u.setUniform("projectionInv", t.invProjectionMatrix.array),
- u.setUniform("toViewSpace", p.array),
- u.setUniform("toWorldSpace", m.array),
- u.setUniform("nearZ", t.near);
- var g = i / this._totalSamples * this._samplePerFrame;
- if (u.setUniform("jitterOffset", g),
- u.setUniform("sampleOffset", i * this._samplePerFrame),
- c.setUniform("textureSize", [o.width, o.height]),
- d.setUniform("textureSize", [n, a]),
- d.setUniform("sourceTexture", r),
- c.setUniform("projection", t.projectionMatrix.array),
- d.setUniform("projection", t.projectionMatrix.array),
- h.attach(o),
- h.bind(e),
- u.render(e),
- this._physicallyCorrect && (h.attach(this._currentTexture),
- f.setUniform("texture1", this._prevTexture),
- f.setUniform("texture2", o),
- f.material.set({
- weight1: i >= 1 ? .95 : 0,
- weight2: i >= 1 ? .05 : 1
- }),
- f.render(e)),
- h.attach(s),
- c.setUniform("texture", this._physicallyCorrect ? this._currentTexture : o),
- c.render(e),
- h.attach(l),
- d.setUniform("texture", s),
- d.render(e),
- h.unbind(e),
- this._physicallyCorrect) {
- var _ = this._prevTexture;
- this._prevTexture = this._currentTexture,
- this._currentTexture = _
- }
- }
- ,
- gl.prototype.getTargetTexture = function () {
- return this._texture3
- }
- ,
- gl.prototype.setParameter = function (e, t) {
- "maxIteration" === e ? this._ssrPass.material.define("fragment", "MAX_ITERATION", t) : this._ssrPass.setUniform(e, t)
- }
- ,
- gl.prototype.setPhysicallyCorrect = function (e) {
- e ? (this._normalDistribution || (this._normalDistribution = _n.generateNormalDistribution(64, this._totalSamples)),
- this._ssrPass.material.define("fragment", "PHYSICALLY_CORRECT"),
- this._ssrPass.material.set("normalDistribution", this._normalDistribution),
- this._ssrPass.material.set("normalDistributionSize", [64, this._totalSamples])) : this._ssrPass.material.undefine("fragment", "PHYSICALLY_CORRECT"),
- this._physicallyCorrect = e
- }
- ,
- gl.prototype.setSSAOTexture = function (e) {
- var t = this._blurPass2;
- e ? (t.material.enableTexture("ssaoTex"),
- t.material.set("ssaoTex", e)) : t.material.disableTexture("ssaoTex")
- }
- ,
- gl.prototype.isFinished = function (e) {
- return !this._physicallyCorrect || e > this._totalSamples / this._samplePerFrame
- }
- ,
- gl.prototype.dispose = function (e) {
- this._ssrTexture.dispose(e),
- this._texture2.dispose(e),
- this._texture3.dispose(e),
- this._prevTexture.dispose(e),
- this._currentTexture.dispose(e),
- this._frameBuffer.dispose(e)
- }
- ;
- const _l = gl
- , vl = [0, 0, -.321585265978, -.154972575841, .458126042375, .188473391593, .842080129861, .527766490688, .147304551086, -.659453822776, -.331943915203, -.940619700594, .0479226680259, .54812163202, .701581552186, -.709825561388, -.295436780218, .940589268233, -.901489676764, .237713156085, .973570876096, -.109899459384, -.866792314779, -.451805525005, .330975007087, .800048655954, -.344275183665, .381779221166, -.386139432542, -.437418421534, -.576478634965, -.0148463392551, .385798197415, -.262426961053, -.666302061145, .682427250835, -.628010632582, -.732836215494, .10163141741, -.987658134403, .711995289051, -.320024291314, .0296005138058, .950296523438, .0130612307608, -.351024443122, -.879596633704, -.10478487883, .435712737232, .504254490347, .779203817497, .206477676721, .388264289969, -.896736162545, -.153106280781, -.629203242522, -.245517550697, .657969239148, .126830499058, .26862328493, -.634888119007, -.302301223431, .617074219636, .779817204925];
- function yl(e, t, r, i, n) {
- var a = e.gl;
- t.setUniform(a, "1i", r, n),
- a.activeTexture(a.TEXTURE0 + n),
- i.isRenderable() ? i.bind(e) : i.unbind(e)
- }
- function xl(e, t, r, i, n) {
- var a, o, s, l, h = e.gl;
- return function (n, u, c) {
- if (!l || l.material !== n.material) {
- var d = n.material
- , f = n.__program
- , p = d.get("roughness");
- null == p && (p = 1);
- var m = d.get("normalMap") || t
- , g = d.get("roughnessMap")
- , _ = d.get("bumpMap")
- , v = d.get("uvRepeat")
- , y = d.get("uvOffset")
- , x = d.get("detailUvRepeat")
- , b = d.get("detailUvOffset")
- , w = !!_ && d.isTextureEnabled("bumpMap")
- , T = !!g && d.isTextureEnabled("roughnessMap")
- , S = d.isDefined("fragment", "DOUBLE_SIDED");
- _ = _ || r,
- g = g || i,
- c !== u ? (u.set("normalMap", m),
- u.set("bumpMap", _),
- u.set("roughnessMap", g),
- u.set("useBumpMap", w),
- u.set("useRoughnessMap", T),
- u.set("doubleSide", S),
- null != v && u.set("uvRepeat", v),
- null != y && u.set("uvOffset", y),
- null != x && u.set("detailUvRepeat", x),
- null != b && u.set("detailUvOffset", b),
- u.set("roughness", p)) : (f.setUniform(h, "1f", "roughness", p),
- a !== m && yl(e, f, "normalMap", m, 0),
- o !== _ && _ && yl(e, f, "bumpMap", _, 1),
- s !== g && g && yl(e, f, "roughnessMap", g, 2),
- null != v && f.setUniform(h, "2f", "uvRepeat", v),
- null != y && f.setUniform(h, "2f", "uvOffset", y),
- null != x && f.setUniform(h, "2f", "detailUvRepeat", x),
- null != b && f.setUniform(h, "2f", "detailUvOffset", b),
- f.setUniform(h, "1i", "useBumpMap", +w),
- f.setUniform(h, "1i", "useRoughnessMap", +T),
- f.setUniform(h, "1i", "doubleSide", +S)),
- a = m,
- o = _,
- s = g,
- l = n
- }
- }
- }
- function bl(e) {
- e = e || {},
- this._depthTex = new Dr({
- format: wr.DEPTH_COMPONENT,
- type: wr.UNSIGNED_INT
- }),
- this._normalTex = new Dr({
- type: wr.HALF_FLOAT
- }),
- this._framebuffer = new zi,
- this._framebuffer.attach(this._normalTex),
- this._framebuffer.attach(this._depthTex, zi.DEPTH_ATTACHMENT),
- this._normalMaterial = new le({
- shader: new Xe(Xe.source("ecgl.normal.vertex"), Xe.source("ecgl.normal.fragment"))
- }),
- this._normalMaterial.enableTexture(["normalMap", "bumpMap", "roughnessMap"]),
- this._defaultNormalMap = an.createBlank("#000"),
- this._defaultBumpMap = an.createBlank("#000"),
- this._defaultRoughessMap = an.createBlank("#000"),
- this._debugPass = new pn({
- fragment: Xe.source("clay.compositor.output")
- }),
- this._debugPass.setUniform("texture", this._normalTex),
- this._debugPass.material.undefine("fragment", "OUTPUT_ALPHA")
- }
- Xe.import("@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"),
- bl.prototype.getDepthTexture = function () {
- return this._depthTex
- }
- ,
- bl.prototype.getNormalTexture = function () {
- return this._normalTex
- }
- ,
- bl.prototype.update = function (e, t, r) {
- var i = e.getWidth()
- , n = e.getHeight()
- , a = this._depthTex
- , o = this._normalTex
- , s = this._normalMaterial;
- a.width = i,
- a.height = n,
- o.width = i,
- o.height = n;
- var l = t.getRenderList(r).opaque;
- this._framebuffer.bind(e),
- e.gl.clearColor(0, 0, 0, 0),
- e.gl.clear(e.gl.COLOR_BUFFER_BIT | e.gl.DEPTH_BUFFER_BIT),
- e.gl.disable(e.gl.BLEND),
- e.renderPass(l, r, {
- getMaterial: function () {
- return s
- },
- ifRender: function (e) {
- return e.renderNormal
- },
- beforeRender: xl(e, this._defaultNormalMap, this._defaultBumpMap, this._defaultRoughessMap, this._normalMaterial),
- sort: e.opaqueSortCompare
- }),
- this._framebuffer.unbind(e)
- }
- ,
- bl.prototype.renderDebug = function (e) {
- this._debugPass.render(e)
- }
- ,
- bl.prototype.dispose = function (e) {
- this._depthTex.dispose(e),
- this._normalTex.dispose(e)
- }
- ;
- const wl = bl;
- function Tl(e) {
- e = e || {},
- this._edgePass = new pn({
- fragment: Xe.source("ecgl.edge")
- }),
- this._edgePass.setUniform("normalTexture", e.normalTexture),
- this._edgePass.setUniform("depthTexture", e.depthTexture),
- this._targetTexture = new Dr({
- type: wr.HALF_FLOAT
- }),
- this._frameBuffer = new zi,
- this._frameBuffer.attach(this._targetTexture)
- }
- Tl.prototype.update = function (e, t, r, i) {
- var n = e.getWidth()
- , a = e.getHeight()
- , o = this._targetTexture;
- o.width = n,
- o.height = a;
- var s = this._frameBuffer;
- s.bind(e),
- this._edgePass.setUniform("projectionInv", t.invProjectionMatrix.array),
- this._edgePass.setUniform("textureSize", [n, a]),
- this._edgePass.setUniform("texture", r),
- this._edgePass.render(e),
- s.unbind(e)
- }
- ,
- Tl.prototype.getTargetTexture = function () {
- return this._targetTexture
- }
- ,
- Tl.prototype.setParameter = function (e, t) {
- this._edgePass.setUniform(e, t)
- }
- ,
- Tl.prototype.dispose = function (e) {
- this._targetTexture.dispose(e),
- this._frameBuffer.dispose(e)
- }
- ;
- const Sl = Tl
- , Ml = {
- type: "compositor",
- nodes: [{
- name: "source",
- type: "texture",
- outputs: {
- color: {}
- }
- }, {
- name: "source_half",
- shader: "#source(clay.compositor.downsample)",
- inputs: {
- texture: "source"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 2)",
- height: "expr(height * 1.0 / 2)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- textureSize: "expr( [width * 1.0, height * 1.0] )"
- }
- }, {
- name: "bright",
- shader: "#source(clay.compositor.bright)",
- inputs: {
- texture: "source_half"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 2)",
- height: "expr(height * 1.0 / 2)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- threshold: 2,
- scale: 4,
- textureSize: "expr([width * 1.0 / 2, height / 2])"
- }
- }, {
- name: "bright_downsample_4",
- shader: "#source(clay.compositor.downsample)",
- inputs: {
- texture: "bright"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 4)",
- height: "expr(height * 1.0 / 4)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- textureSize: "expr( [width * 1.0 / 2, height / 2] )"
- }
- }, {
- name: "bright_downsample_8",
- shader: "#source(clay.compositor.downsample)",
- inputs: {
- texture: "bright_downsample_4"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 8)",
- height: "expr(height * 1.0 / 8)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- textureSize: "expr( [width * 1.0 / 4, height / 4] )"
- }
- }, {
- name: "bright_downsample_16",
- shader: "#source(clay.compositor.downsample)",
- inputs: {
- texture: "bright_downsample_8"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 16)",
- height: "expr(height * 1.0 / 16)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- textureSize: "expr( [width * 1.0 / 8, height / 8] )"
- }
- }, {
- name: "bright_downsample_32",
- shader: "#source(clay.compositor.downsample)",
- inputs: {
- texture: "bright_downsample_16"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 32)",
- height: "expr(height * 1.0 / 32)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- textureSize: "expr( [width * 1.0 / 16, height / 16] )"
- }
- }, {
- name: "bright_upsample_16_blur_h",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_downsample_32"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 16)",
- height: "expr(height * 1.0 / 16)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 0,
- textureSize: "expr( [width * 1.0 / 32, height / 32] )"
- }
- }, {
- name: "bright_upsample_16_blur_v",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_upsample_16_blur_h"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 16)",
- height: "expr(height * 1.0 / 16)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 1,
- textureSize: "expr( [width * 1.0 / 16, height * 1.0 / 16] )"
- }
- }, {
- name: "bright_upsample_8_blur_h",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_downsample_16"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 8)",
- height: "expr(height * 1.0 / 8)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 0,
- textureSize: "expr( [width * 1.0 / 16, height * 1.0 / 16] )"
- }
- }, {
- name: "bright_upsample_8_blur_v",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_upsample_8_blur_h"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 8)",
- height: "expr(height * 1.0 / 8)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 1,
- textureSize: "expr( [width * 1.0 / 8, height * 1.0 / 8] )"
- }
- }, {
- name: "bright_upsample_8_blend",
- shader: "#source(clay.compositor.blend)",
- inputs: {
- texture1: "bright_upsample_8_blur_v",
- texture2: "bright_upsample_16_blur_v"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 8)",
- height: "expr(height * 1.0 / 8)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- weight1: .3,
- weight2: .7
- }
- }, {
- name: "bright_upsample_4_blur_h",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_downsample_8"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 4)",
- height: "expr(height * 1.0 / 4)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 0,
- textureSize: "expr( [width * 1.0 / 8, height * 1.0 / 8] )"
- }
- }, {
- name: "bright_upsample_4_blur_v",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_upsample_4_blur_h"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 4)",
- height: "expr(height * 1.0 / 4)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 1,
- textureSize: "expr( [width * 1.0 / 4, height * 1.0 / 4] )"
- }
- }, {
- name: "bright_upsample_4_blend",
- shader: "#source(clay.compositor.blend)",
- inputs: {
- texture1: "bright_upsample_4_blur_v",
- texture2: "bright_upsample_8_blend"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 4)",
- height: "expr(height * 1.0 / 4)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- weight1: .3,
- weight2: .7
- }
- }, {
- name: "bright_upsample_2_blur_h",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_downsample_4"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 2)",
- height: "expr(height * 1.0 / 2)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 0,
- textureSize: "expr( [width * 1.0 / 4, height * 1.0 / 4] )"
- }
- }, {
- name: "bright_upsample_2_blur_v",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_upsample_2_blur_h"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 2)",
- height: "expr(height * 1.0 / 2)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 1,
- textureSize: "expr( [width * 1.0 / 2, height * 1.0 / 2] )"
- }
- }, {
- name: "bright_upsample_2_blend",
- shader: "#source(clay.compositor.blend)",
- inputs: {
- texture1: "bright_upsample_2_blur_v",
- texture2: "bright_upsample_4_blend"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0 / 2)",
- height: "expr(height * 1.0 / 2)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- weight1: .3,
- weight2: .7
- }
- }, {
- name: "bright_upsample_full_blur_h",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 0,
- textureSize: "expr( [width * 1.0 / 2, height * 1.0 / 2] )"
- }
- }, {
- name: "bright_upsample_full_blur_v",
- shader: "#source(clay.compositor.gaussian_blur)",
- inputs: {
- texture: "bright_upsample_full_blur_h"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- blurSize: 1,
- blurDir: 1,
- textureSize: "expr( [width * 1.0, height * 1.0] )"
- }
- }, {
- name: "bloom_composite",
- shader: "#source(clay.compositor.blend)",
- inputs: {
- texture1: "bright_upsample_full_blur_v",
- texture2: "bright_upsample_2_blend"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- weight1: .3,
- weight2: .7
- }
- }, {
- name: "coc",
- shader: "#source(ecgl.dof.coc)",
- outputs: {
- color: {
- parameters: {
- minFilter: "NEAREST",
- magFilter: "NEAREST",
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)"
- }
- }
- },
- parameters: {
- focalDist: 50,
- focalRange: 30
- }
- }, {
- name: "dof_far_blur",
- shader: "#source(ecgl.dof.diskBlur)",
- inputs: {
- texture: "source",
- coc: "coc"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- textureSize: "expr( [width * 1.0, height * 1.0] )"
- }
- }, {
- name: "dof_near_blur",
- shader: "#source(ecgl.dof.diskBlur)",
- inputs: {
- texture: "source",
- coc: "coc"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)",
- type: "HALF_FLOAT"
- }
- }
- },
- parameters: {
- textureSize: "expr( [width * 1.0, height * 1.0] )"
- },
- defines: {
- BLUR_NEARFIELD: null
- }
- }, {
- name: "dof_coc_blur",
- shader: "#source(ecgl.dof.diskBlur)",
- inputs: {
- texture: "coc"
- },
- outputs: {
- color: {
- parameters: {
- minFilter: "NEAREST",
- magFilter: "NEAREST",
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)"
- }
- }
- },
- parameters: {
- textureSize: "expr( [width * 1.0, height * 1.0] )"
- },
- defines: {
- BLUR_COC: null
- }
- }, {
- name: "dof_composite",
- shader: "#source(ecgl.dof.composite)",
- inputs: {
- original: "source",
- blurred: "dof_far_blur",
- nearfield: "dof_near_blur",
- coc: "coc",
- nearcoc: "dof_coc_blur"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)",
- type: "HALF_FLOAT"
- }
- }
- }
- }, {
- name: "composite",
- shader: "#source(clay.compositor.hdr.composite)",
- inputs: {
- texture: "source",
- bloom: "bloom_composite"
- },
- outputs: {
- color: {
- parameters: {
- width: "expr(width * 1.0)",
- height: "expr(height * 1.0)"
- }
- }
- },
- defines: {}
- }, {
- name: "FXAA",
- shader: "#source(clay.compositor.fxaa)",
- inputs: {
- texture: "composite"
- }
- }]
- };
- function Al(e, t) {
- return {
- color: {
- parameters: {
- width: e,
- height: t
- }
- }
- }
- }
- Xe.import(Zs),
- Xe.import(Ys),
- Xe.import(Ks),
- Xe.import(Qs),
- Xe.import(Js),
- Xe.import($s),
- Xe.import(el),
- Xe.import(tl),
- Xe.import(rl),
- Xe.import("@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"),
- Xe.import("@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end");
- var El = ["composite", "FXAA"];
- function Cl() {
- this._width,
- this._height,
- this._dpr,
- this._sourceTexture = new Dr({
- type: wr.HALF_FLOAT
- }),
- this._depthTexture = new Dr({
- format: wr.DEPTH_COMPONENT,
- type: wr.UNSIGNED_INT
- }),
- this._framebuffer = new zi,
- this._framebuffer.attach(this._sourceTexture),
- this._framebuffer.attach(this._depthTexture, zi.DEPTH_ATTACHMENT),
- this._normalPass = new wl,
- this._compositor = function (e, t) {
- var r = new Ws;
- t = t || {};
- var i = {
- textures: {},
- parameters: {}
- };
- for (var n in e.parameters) {
- var a = e.parameters[n];
- i.parameters[n] = sl(a)
- }
- return function (e, t, r, i) {
- if (e.textures) {
- var n = {}
- , a = 0
- , o = !1
- , s = r.textureRootPath;
- f.each(e.textures, (function (e, t) {
- var r, l = e.path, h = sl(e.parameters);
- if (Array.isArray(l) && 6 === l.length)
- s && (l = l.map((function (e) {
- return f.relative2absolute(e, s)
- }
- ))),
- r = new Ai(h);
- else {
- if ("string" != typeof l)
- return;
- s && (l = f.relative2absolute(l, s)),
- r = new Dr(h)
- }
- r.load(l),
- a++,
- r.once("success", (function () {
- n[t] = r,
- 0 == --a && (i(n),
- o = !0)
- }
- ))
- }
- )),
- 0 !== a || o || i(n)
- } else
- i({})
- }(e, 0, t, (function (n) {
- i.textures = n,
- function (n, a) {
- for (var o = 0; o < e.nodes.length; o++) {
- var s = nl(e.nodes[o], i, t);
- s && r.addNode(s)
- }
- }()
- }
- )),
- r
- }(Ml);
- var e = this._compositor.getNodeByName("source");
- e.texture = this._sourceTexture;
- var t = this._compositor.getNodeByName("coc");
- this._sourceNode = e,
- this._cocNode = t,
- this._compositeNode = this._compositor.getNodeByName("composite"),
- this._fxaaNode = this._compositor.getNodeByName("FXAA"),
- this._dofBlurNodes = ["dof_far_blur", "dof_near_blur", "dof_coc_blur"].map((function (e) {
- return this._compositor.getNodeByName(e)
- }
- ), this),
- this._dofBlurKernel = 0,
- this._dofBlurKernelSize = new Float32Array(0),
- this._finalNodesChain = El.map((function (e) {
- return this._compositor.getNodeByName(e)
- }
- ), this);
- var r = {
- normalTexture: this._normalPass.getNormalTexture(),
- depthTexture: this._normalPass.getDepthTexture()
- };
- this._ssaoPass = new ml(r),
- this._ssrPass = new _l(r),
- this._edgePass = new Sl(r)
- }
- Cl.prototype.resize = function (e, t, r) {
- e *= r = r || 1,
- t *= r;
- var i = this._sourceTexture
- , n = this._depthTexture;
- i.width = e,
- i.height = t,
- n.width = e,
- n.height = t;
- var a = {
- getWidth: function () {
- return e
- },
- getHeight: function () {
- return t
- },
- getDevicePixelRatio: function () {
- return r
- }
- };
- function o(e, t) {
- if ("function" == typeof e[t]) {
- var r = e[t].__original || e[t];
- e[t] = function (e) {
- return r.call(this, a)
- }
- ,
- e[t].__original = r
- }
- }
- this._compositor.nodes.forEach((function (e) {
- for (var t in e.outputs) {
- var r = e.outputs[t].parameters;
- r && (o(r, "width"),
- o(r, "height"))
- }
- for (var i in e.parameters)
- o(e.parameters, i)
- }
- )),
- this._width = e,
- this._height = t,
- this._dpr = r
- }
- ,
- Cl.prototype.getWidth = function () {
- return this._width
- }
- ,
- Cl.prototype.getHeight = function () {
- return this._height
- }
- ,
- Cl.prototype._ifRenderNormalPass = function () {
- return this._enableSSAO || this._enableEdge || this._enableSSR
- }
- ,
- Cl.prototype._getPrevNode = function (e) {
- for (var t = El.indexOf(e.name) - 1, r = this._finalNodesChain[t]; r && !this._compositor.getNodeByName(r.name);)
- t -= 1,
- r = this._finalNodesChain[t];
- return r
- }
- ,
- Cl.prototype._getNextNode = function (e) {
- for (var t = El.indexOf(e.name) + 1, r = this._finalNodesChain[t]; r && !this._compositor.getNodeByName(r.name);)
- t += 1,
- r = this._finalNodesChain[t];
- return r
- }
- ,
- Cl.prototype._addChainNode = function (e) {
- var t = this._getPrevNode(e)
- , r = this._getNextNode(e);
- t && (e.inputs.texture = t.name,
- r ? (e.outputs = Al(this.getWidth.bind(this), this.getHeight.bind(this)),
- r.inputs.texture = e.name) : e.outputs = null,
- this._compositor.addNode(e))
- }
- ,
- Cl.prototype._removeChainNode = function (e) {
- var t = this._getPrevNode(e)
- , r = this._getNextNode(e);
- t && (r ? (t.outputs = Al(this.getWidth.bind(this), this.getHeight.bind(this)),
- r.inputs.texture = t.name) : t.outputs = null,
- this._compositor.removeNode(e))
- }
- ,
- Cl.prototype.updateNormal = function (e, t, r, i) {
- this._ifRenderNormalPass() && this._normalPass.update(e, t, r)
- }
- ,
- Cl.prototype.updateSSAO = function (e, t, r, i) {
- this._ssaoPass.update(e, r, i)
- }
- ,
- Cl.prototype.enableSSAO = function () {
- this._enableSSAO = !0
- }
- ,
- Cl.prototype.disableSSAO = function () {
- this._enableSSAO = !1
- }
- ,
- Cl.prototype.enableSSR = function () {
- this._enableSSR = !0
- }
- ,
- Cl.prototype.disableSSR = function () {
- this._enableSSR = !1
- }
- ,
- Cl.prototype.getSSAOTexture = function () {
- return this._ssaoPass.getTargetTexture()
- }
- ,
- Cl.prototype.getSourceFrameBuffer = function () {
- return this._framebuffer
- }
- ,
- Cl.prototype.getSourceTexture = function () {
- return this._sourceTexture
- }
- ,
- Cl.prototype.disableFXAA = function () {
- this._removeChainNode(this._fxaaNode)
- }
- ,
- Cl.prototype.enableFXAA = function () {
- this._addChainNode(this._fxaaNode)
- }
- ,
- Cl.prototype.enableBloom = function () {
- this._compositeNode.inputs.bloom = "bloom_composite",
- this._compositor.dirty()
- }
- ,
- Cl.prototype.disableBloom = function () {
- this._compositeNode.inputs.bloom = null,
- this._compositor.dirty()
- }
- ,
- Cl.prototype.enableDOF = function () {
- this._compositeNode.inputs.texture = "dof_composite",
- this._compositor.dirty()
- }
- ,
- Cl.prototype.disableDOF = function () {
- this._compositeNode.inputs.texture = "source",
- this._compositor.dirty()
- }
- ,
- Cl.prototype.enableColorCorrection = function () {
- this._compositeNode.define("COLOR_CORRECTION"),
- this._enableColorCorrection = !0
- }
- ,
- Cl.prototype.disableColorCorrection = function () {
- this._compositeNode.undefine("COLOR_CORRECTION"),
- this._enableColorCorrection = !1
- }
- ,
- Cl.prototype.enableEdge = function () {
- this._enableEdge = !0
- }
- ,
- Cl.prototype.disableEdge = function () {
- this._enableEdge = !1
- }
- ,
- Cl.prototype.setBloomIntensity = function (e) {
- this._compositeNode.setParameter("bloomIntensity", e)
- }
- ,
- Cl.prototype.setSSAOParameter = function (e, t) {
- switch (e) {
- case "quality":
- var r = {
- low: 6,
- medium: 12,
- high: 32,
- ultra: 62
- }[t] || 12;
- this._ssaoPass.setParameter("kernelSize", r);
- break;
- case "radius":
- this._ssaoPass.setParameter(e, t),
- this._ssaoPass.setParameter("bias", t / 200);
- break;
- case "intensity":
- this._ssaoPass.setParameter(e, t)
- }
- }
- ,
- Cl.prototype.setDOFParameter = function (e, t) {
- switch (e) {
- case "focalDistance":
- case "focalRange":
- case "fstop":
- this._cocNode.setParameter(e, t);
- break;
- case "blurRadius":
- for (var r = 0; r < this._dofBlurNodes.length; r++)
- this._dofBlurNodes[r].setParameter("blurRadius", t);
- break;
- case "quality":
- var i = {
- low: 4,
- medium: 8,
- high: 16,
- ultra: 32
- }[t] || 8;
- for (this._dofBlurKernelSize = i,
- r = 0; r < this._dofBlurNodes.length; r++)
- this._dofBlurNodes[r].pass.material.define("POISSON_KERNEL_SIZE", i);
- this._dofBlurKernel = new Float32Array(2 * i)
- }
- }
- ,
- Cl.prototype.setSSRParameter = function (e, t) {
- if (null != t)
- switch (e) {
- case "quality":
- var r = {
- low: 10,
- medium: 15,
- high: 30,
- ultra: 80
- }[t] || 20
- , i = {
- low: 32,
- medium: 16,
- high: 8,
- ultra: 4
- }[t] || 16;
- this._ssrPass.setParameter("maxIteration", r),
- this._ssrPass.setParameter("pixelStride", i);
- break;
- case "maxRoughness":
- this._ssrPass.setParameter("minGlossiness", Math.max(Math.min(1 - t, 1), 0));
- break;
- case "physical":
- this.setPhysicallyCorrectSSR(t);
- break;
- default:
- console.warn("Unkown SSR parameter " + e)
- }
- }
- ,
- Cl.prototype.setPhysicallyCorrectSSR = function (e) {
- this._ssrPass.setPhysicallyCorrect(e)
- }
- ,
- Cl.prototype.setEdgeColor = function (e) {
- var t = Ka.parseColor(e);
- this._edgePass.setParameter("edgeColor", t)
- }
- ,
- Cl.prototype.setExposure = function (e) {
- this._compositeNode.setParameter("exposure", Math.pow(2, e))
- }
- ,
- Cl.prototype.setColorLookupTexture = function (e, t) {
- this._compositeNode.pass.material.setTextureImage("lut", this._enableColorCorrection ? e : "none", t, {
- minFilter: Ka.Texture.NEAREST,
- magFilter: Ka.Texture.NEAREST,
- flipY: !1
- })
- }
- ,
- Cl.prototype.setColorCorrection = function (e, t) {
- this._compositeNode.setParameter(e, t)
- }
- ,
- Cl.prototype.isSSREnabled = function () {
- return this._enableSSR
- }
- ,
- Cl.prototype.composite = function (e, t, r, i, n) {
- var a = this._sourceTexture
- , o = a;
- this._enableEdge && (this._edgePass.update(e, r, a, n),
- a = o = this._edgePass.getTargetTexture()),
- this._enableSSR && (this._ssrPass.update(e, r, a, n),
- o = this._ssrPass.getTargetTexture(),
- this._ssrPass.setSSAOTexture(this._enableSSAO ? this._ssaoPass.getTargetTexture() : null)),
- this._sourceNode.texture = o,
- this._cocNode.setParameter("depth", this._depthTexture);
- for (var s = this._dofBlurKernel, l = this._dofBlurKernelSize, h = n % Math.floor(vl.length / 2 / l), u = 0; u < 2 * l; u++)
- s[u] = vl[u + h * l * 2];
- for (u = 0; u < this._dofBlurNodes.length; u++)
- this._dofBlurNodes[u].setParameter("percent", n / 30),
- this._dofBlurNodes[u].setParameter("poissonKernel", s);
- this._cocNode.setParameter("zNear", r.near),
- this._cocNode.setParameter("zFar", r.far),
- this._compositor.render(e, i)
- }
- ,
- Cl.prototype.dispose = function (e) {
- this._sourceTexture.dispose(e),
- this._depthTexture.dispose(e),
- this._framebuffer.dispose(e),
- this._compositor.dispose(e),
- this._normalPass.dispose(e),
- this._ssaoPass.dispose(e)
- }
- ;
- const Dl = Cl;
- function Ll(e) {
- for (var t = [], r = 0; r < 30; r++)
- t.push([ul(r, 2), ul(r, 3)]);
- this._haltonSequence = t,
- this._frame = 0,
- this._sourceTex = new Dr,
- this._sourceFb = new zi,
- this._sourceFb.attach(this._sourceTex),
- this._prevFrameTex = new Dr,
- this._outputTex = new Dr;
- var i = this._blendPass = new pn({
- fragment: Xe.source("clay.compositor.blend")
- });
- i.material.disableTexturesAll(),
- i.material.enableTexture(["texture1", "texture2"]),
- this._blendFb = new zi({
- depthBuffer: !1
- }),
- this._outputPass = new pn({
- fragment: Xe.source("clay.compositor.output"),
- blendWithPrevious: !0
- }),
- this._outputPass.material.define("fragment", "OUTPUT_ALPHA"),
- this._outputPass.material.blend = function (e) {
- e.blendEquationSeparate(e.FUNC_ADD, e.FUNC_ADD),
- e.blendFuncSeparate(e.ONE, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA)
- }
- }
- Ll.prototype = {
- constructor: Ll,
- jitterProjection: function (e, t) {
- var r = e.viewport
- , i = r.devicePixelRatio || e.getDevicePixelRatio()
- , n = r.width * i
- , a = r.height * i
- , o = this._haltonSequence[this._frame % this._haltonSequence.length]
- , s = new Ht;
- s.array[12] = (2 * o[0] - 1) / n,
- s.array[13] = (2 * o[1] - 1) / a,
- Ht.mul(t.projectionMatrix, s, t.projectionMatrix),
- Ht.invert(t.invProjectionMatrix, t.projectionMatrix)
- },
- resetFrame: function () {
- this._frame = 0
- },
- getFrame: function () {
- return this._frame
- },
- getSourceFrameBuffer: function () {
- return this._sourceFb
- },
- getOutputTexture: function () {
- return this._outputTex
- },
- resize: function (e, t) {
- this._prevFrameTex.width = e,
- this._prevFrameTex.height = t,
- this._outputTex.width = e,
- this._outputTex.height = t,
- this._sourceTex.width = e,
- this._sourceTex.height = t,
- this._prevFrameTex.dirty(),
- this._outputTex.dirty(),
- this._sourceTex.dirty()
- },
- isFinished: function () {
- return this._frame >= this._haltonSequence.length
- },
- render: function (e, t, r) {
- var i = this._blendPass;
- 0 === this._frame ? (i.setUniform("weight1", 0),
- i.setUniform("weight2", 1)) : (i.setUniform("weight1", .9),
- i.setUniform("weight2", .1)),
- i.setUniform("texture1", this._prevFrameTex),
- i.setUniform("texture2", t || this._sourceTex),
- this._blendFb.attach(this._outputTex),
- this._blendFb.bind(e),
- i.render(e),
- this._blendFb.unbind(e),
- r || (this._outputPass.setUniform("texture", this._outputTex),
- this._outputPass.render(e));
- var n = this._prevFrameTex;
- this._prevFrameTex = this._outputTex,
- this._outputTex = n,
- this._frame++
- },
- dispose: function (e) {
- this._sourceFb.dispose(e),
- this._blendFb.dispose(e),
- this._prevFrameTex.dispose(e),
- this._outputTex.dispose(e),
- this._sourceTex.dispose(e),
- this._outputPass.dispose(e),
- this._blendPass.dispose(e)
- }
- };
- const Pl = Ll;
- function Ol(e) {
- e = e || "perspective",
- this.layer = null,
- this.scene = new vi,
- this.rootNode = this.scene,
- this.viewport = {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- },
- this.setProjection(e),
- this._compositor = new Dl,
- this._temporalSS = new Pl,
- this._shadowMapPass = new ks;
- for (var t = [], r = 0, i = 0; i < 30; i++) {
- for (var n = [], a = 0; a < 6; a++)
- n.push(4 * ul(r, 2) - 2),
- n.push(4 * ul(r, 3) - 2),
- r++;
- t.push(n)
- }
- this._pcfKernels = t,
- this.scene.on("beforerender", (function (e, t, r) {
- this.needsTemporalSS() && this._temporalSS.jitterProjection(e, r)
- }
- ), this)
- }
- Ol.prototype.setProjection = function (e) {
- var t = this.camera;
- t && t.update(),
- "perspective" === e ? this.camera instanceof Ei || (this.camera = new Ei,
- t && this.camera.setLocalTransform(t.localTransform)) : this.camera instanceof un || (this.camera = new un,
- t && this.camera.setLocalTransform(t.localTransform)),
- this.camera.near = .1,
- this.camera.far = 2e3
- }
- ,
- Ol.prototype.setViewport = function (e, t, r, i, n) {
- this.camera instanceof Ei && (this.camera.aspect = r / i),
- n = n || 1,
- this.viewport.x = e,
- this.viewport.y = t,
- this.viewport.width = r,
- this.viewport.height = i,
- this.viewport.devicePixelRatio = n,
- this._compositor.resize(r * n, i * n),
- this._temporalSS.resize(r * n, i * n)
- }
- ,
- Ol.prototype.containPoint = function (e, t) {
- var r = this.viewport;
- return t = this.layer.renderer.getHeight() - t,
- e >= r.x && t >= r.y && e <= r.x + r.width && t <= r.y + r.height
- }
- ;
- var Nl = new _e;
- Ol.prototype.castRay = function (e, t, r) {
- var i = this.layer.renderer
- , n = i.viewport;
- return i.viewport = this.viewport,
- i.screenToNDC(e, t, Nl),
- this.camera.castRay(Nl, r),
- i.viewport = n,
- r
- }
- ,
- Ol.prototype.prepareRender = function () {
- this.scene.update(),
- this.camera.update(),
- this.scene.updateLights();
- var e = this.scene.updateRenderList(this.camera);
- this._needsSortProgressively = !1;
- for (var t = 0; t < e.transparent.length; t++) {
- var r = e.transparent[t].geometry;
- r.needsSortVerticesProgressively && r.needsSortVerticesProgressively() && (this._needsSortProgressively = !0),
- r.needsSortTrianglesProgressively && r.needsSortTrianglesProgressively() && (this._needsSortProgressively = !0)
- }
- this._frame = 0,
- this._temporalSS.resetFrame()
- }
- ,
- Ol.prototype.render = function (e, t) {
- this._doRender(e, t, this._frame),
- this._frame++
- }
- ,
- Ol.prototype.needsAccumulate = function () {
- return this.needsTemporalSS() || this._needsSortProgressively
- }
- ,
- Ol.prototype.needsTemporalSS = function () {
- var e = this._enableTemporalSS;
- return "auto" === e && (e = this._enablePostEffect),
- e
- }
- ,
- Ol.prototype.hasDOF = function () {
- return this._enableDOF
- }
- ,
- Ol.prototype.isAccumulateFinished = function () {
- return this.needsTemporalSS() ? this._temporalSS.isFinished() : this._frame > 30
- }
- ,
- Ol.prototype._doRender = function (e, t, r) {
- var i = this.scene
- , n = this.camera;
- r = r || 0,
- this._updateTransparent(e, i, n, r),
- t || (this._shadowMapPass.kernelPCF = this._pcfKernels[0],
- this._shadowMapPass.render(e, i, n, !0)),
- this._updateShadowPCFKernel(r);
- var a, o = e.clearColor;
- e.gl.clearColor(o[0], o[1], o[2], o[3]),
- this._enablePostEffect && (this.needsTemporalSS() && this._temporalSS.jitterProjection(e, n),
- this._compositor.updateNormal(e, i, n, this._temporalSS.getFrame())),
- this._updateSSAO(e, i, n, this._temporalSS.getFrame()),
- this._enablePostEffect ? ((a = this._compositor.getSourceFrameBuffer()).bind(e),
- e.gl.clear(e.gl.DEPTH_BUFFER_BIT | e.gl.COLOR_BUFFER_BIT),
- e.render(i, n, !0, !0),
- a.unbind(e),
- this.needsTemporalSS() && t ? (this._compositor.composite(e, i, n, this._temporalSS.getSourceFrameBuffer(), this._temporalSS.getFrame()),
- e.setViewport(this.viewport),
- this._temporalSS.render(e)) : (e.setViewport(this.viewport),
- this._compositor.composite(e, i, n, null, 0))) : this.needsTemporalSS() && t ? ((a = this._temporalSS.getSourceFrameBuffer()).bind(e),
- e.saveClear(),
- e.clearBit = e.gl.DEPTH_BUFFER_BIT | e.gl.COLOR_BUFFER_BIT,
- e.render(i, n, !0, !0),
- e.restoreClear(),
- a.unbind(e),
- e.setViewport(this.viewport),
- this._temporalSS.render(e)) : (e.setViewport(this.viewport),
- e.render(i, n, !0, !0))
- }
- ,
- Ol.prototype._updateTransparent = function (e, t, r, i) {
- for (var n = new vt, a = new Ht, o = r.getWorldPosition(), s = t.getRenderList(r).transparent, l = 0; l < s.length; l++) {
- var h = s[l]
- , u = h.geometry;
- Ht.invert(a, h.worldTransform),
- vt.transformMat4(n, o, a),
- u.needsSortTriangles && u.needsSortTriangles() && u.doSortTriangles(n, i),
- u.needsSortVertices && u.needsSortVertices() && u.doSortVertices(n, i)
- }
- }
- ,
- Ol.prototype._updateSSAO = function (e, t, r) {
- var i = this._enableSSAO && this._enablePostEffect;
- i && this._compositor.updateSSAO(e, t, r, this._temporalSS.getFrame());
- for (var n = t.getRenderList(r), a = 0; a < n.opaque.length; a++) {
- var o = n.opaque[a];
- o.renderNormal && o.material[i ? "enableTexture" : "disableTexture"]("ssaoMap"),
- i && o.material.set("ssaoMap", this._compositor.getSSAOTexture())
- }
- }
- ,
- Ol.prototype._updateShadowPCFKernel = function (e) {
- for (var t = this._pcfKernels[e % this._pcfKernels.length], r = this.scene.getRenderList(this.camera).opaque, i = 0; i < r.length; i++)
- r[i].receiveShadow && (r[i].material.set("pcfKernel", t),
- r[i].material.define("fragment", "PCF_KERNEL_SIZE", t.length / 2))
- }
- ,
- Ol.prototype.dispose = function (e) {
- this._compositor.dispose(e.gl),
- this._temporalSS.dispose(e.gl),
- this._shadowMapPass.dispose(e)
- }
- ,
- Ol.prototype.setPostEffect = function (e, t) {
- var r = this._compositor;
- this._enablePostEffect = e.get("enable");
- var i = e.getModel("bloom")
- , n = e.getModel("edge")
- , a = e.getModel("DOF", e.getModel("depthOfField"))
- , o = e.getModel("SSAO", e.getModel("screenSpaceAmbientOcclusion"))
- , s = e.getModel("SSR", e.getModel("screenSpaceReflection"))
- , l = e.getModel("FXAA")
- , h = e.getModel("colorCorrection");
- i.get("enable") ? r.enableBloom() : r.disableBloom(),
- a.get("enable") ? r.enableDOF() : r.disableDOF(),
- s.get("enable") ? r.enableSSR() : r.disableSSR(),
- h.get("enable") ? r.enableColorCorrection() : r.disableColorCorrection(),
- n.get("enable") ? r.enableEdge() : r.disableEdge(),
- l.get("enable") ? r.enableFXAA() : r.disableFXAA(),
- this._enableDOF = a.get("enable"),
- this._enableSSAO = o.get("enable"),
- this._enableSSAO ? r.enableSSAO() : r.disableSSAO(),
- r.setBloomIntensity(i.get("intensity")),
- r.setEdgeColor(n.get("color")),
- r.setColorLookupTexture(h.get("lookupTexture"), t),
- r.setExposure(h.get("exposure")),
- ["radius", "quality", "intensity"].forEach((function (e) {
- r.setSSAOParameter(e, o.get(e))
- }
- )),
- ["quality", "maxRoughness", "physical"].forEach((function (e) {
- r.setSSRParameter(e, s.get(e))
- }
- )),
- ["quality", "focalDistance", "focalRange", "blurRadius", "fstop"].forEach((function (e) {
- r.setDOFParameter(e, a.get(e))
- }
- )),
- ["brightness", "contrast", "saturation"].forEach((function (e) {
- r.setColorCorrection(e, h.get(e))
- }
- ))
- }
- ,
- Ol.prototype.setDOFFocusOnPoint = function (e) {
- if (this._enablePostEffect) {
- if (e > this.camera.far || e < this.camera.near)
- return;
- return this._compositor.setDOFParameter("focalDistance", e),
- !0
- }
- }
- ,
- Ol.prototype.setTemporalSuperSampling = function (e) {
- this._enableTemporalSS = e.get("enable")
- }
- ,
- Ol.prototype.isLinearSpace = function () {
- return this._enablePostEffect
- }
- ,
- Ol.prototype.setRootNode = function (e) {
- if (this.rootNode !== e) {
- for (var t = this.rootNode.children(), r = 0; r < t.length; r++)
- e.add(t[r]);
- e !== this.scene && this.scene.add(e),
- this.rootNode = e
- }
- }
- ,
- Ol.prototype.add = function (e) {
- this.rootNode.add(e)
- }
- ,
- Ol.prototype.remove = function (e) {
- this.rootNode.remove(e)
- }
- ,
- Ol.prototype.removeAll = function (e) {
- this.rootNode.removeAll(e)
- }
- ,
- Object.assign(Ol.prototype, h);
- const Il = Ol;
- function Rl(e, t) {
- var r = Ss(e.getBoxLayoutParams(), {
- width: t.getWidth(),
- height: t.getHeight()
- });
- r.y = t.getHeight() - r.y - r.height,
- this.viewGL.setViewport(r.x, r.y, r.width, r.height, t.getDevicePixelRatio());
- var i = e.get("boxWidth")
- , n = e.get("boxHeight")
- , a = e.get("boxDepth");
- this.getAxis("x").setExtent(-i / 2, i / 2),
- this.getAxis("y").setExtent(a / 2, -a / 2),
- this.getAxis("z").setExtent(-n / 2, n / 2),
- this.size = [i, n, a]
- }
- function Bl(e, t) {
- var r = {};
- e.eachSeries((function (e) {
- if (e.coordinateSystem === this) {
- var t = e.getData();
- ["x", "y", "z"].forEach((function (e) {
- t.mapDimensionsAll(e, !0).forEach((function (i) {
- var n, a;
- n = e,
- a = t.getDataExtent(i, !0),
- r[n] = r[n] || [1 / 0, -1 / 0],
- r[n][0] = Math.min(a[0], r[n][0]),
- r[n][1] = Math.max(a[1], r[n][1])
- }
- ))
- }
- ))
- }
- }
- ), this),
- ["xAxis3D", "yAxis3D", "zAxis3D"].forEach((function (t) {
- e.eachComponent(t, (function (e) {
- var n = t.charAt(0)
- , a = e.getReferringComponents("grid3D").models[0]
- , o = a.coordinateSystem;
- if (o === this) {
- var s = o.getAxis(n);
- if (!s) {
- var l = i.helper.createScale(r[n] || [1 / 0, -1 / 0], e);
- (s = new cs(n, l)).type = e.get("type");
- var h = "category" === s.type;
- s.onBand = h && e.get("boundaryGap"),
- s.inverse = e.get("inverse"),
- e.axis = s,
- s.model = e,
- s.getLabelModel = function () {
- return e.getModel("axisLabel", a.getModel("axisLabel"))
- }
- ,
- s.getTickModel = function () {
- return e.getModel("axisTick", a.getModel("axisTick"))
- }
- ,
- o.addAxis(s)
- }
- }
- }
- ), this)
- }
- ), this),
- this.resize(this.model, t)
- }
- const Fl = {
- dimensions: hs.prototype.dimensions,
- create: function (e, t) {
- var r = [];
- e.eachComponent("grid3D", (function (e) {
- e.__viewGL = e.__viewGL || new Il;
- var t = new hs;
- t.model = e,
- t.viewGL = e.__viewGL,
- e.coordinateSystem = t,
- r.push(t),
- t.resize = Rl,
- t.update = Bl
- }
- ));
- var i = ["xAxis3D", "yAxis3D", "zAxis3D"];
- return e.eachSeries((function (t) {
- if ("cartesian3D" === t.get("coordinateSystem")) {
- if (null == (n = t.getReferringComponents("grid3D").models[0])) {
- var r = function (e, t) {
- return i.map((function (r) {
- var i = e.getReferringComponents(r).models[0];
- return null == i && (i = t.getComponent(r)),
- i
- }
- ))
- }(t, e)
- , n = r[0].getCoordSysModel();
- r.forEach((function (e) {
- e.getCoordSysModel()
- }
- ))
- }
- var a = n.coordinateSystem;
- t.coordinateSystem = a
- }
- }
- )),
- r
- }
- };
- var zl = i.ComponentModel.extend({
- type: "cartesian3DAxis",
- axis: null,
- getCoordSysModel: function () {
- return this.ecModel.queryComponents({
- mainType: "grid3D",
- index: this.option.gridIndex,
- id: this.option.gridId
- })[0]
- }
- });
- i.helper.mixinAxisModelCommonMethods(zl);
- const Gl = zl;
- var Ul = {
- show: !0,
- grid3DIndex: 0,
- inverse: !1,
- name: "",
- nameLocation: "middle",
- nameTextStyle: {
- fontSize: 16
- },
- nameGap: 20,
- axisPointer: {},
- axisLine: {},
- axisTick: {},
- axisLabel: {},
- splitArea: {}
- }
- , kl = i.util.merge({
- boundaryGap: !0,
- axisTick: {
- alignWithLabel: !1,
- interval: "auto"
- },
- axisLabel: {
- interval: "auto"
- },
- axisPointer: {
- label: {
- show: !1
- }
- }
- }, Ul)
- , Vl = i.util.merge({
- boundaryGap: [0, 0],
- splitNumber: 5,
- axisPointer: {
- label: {}
- }
- }, Ul)
- , Hl = i.util.defaults({
- scale: !0,
- min: "dataMin",
- max: "dataMax"
- }, Vl)
- , Wl = i.util.defaults({
- logBase: 10
- }, Vl);
- Wl.scale = !0;
- const jl = {
- categoryAxis3D: kl,
- valueAxis3D: Vl,
- timeAxis3D: Hl,
- logAxis3D: Wl
- };
- function Xl(e) {
- return ("function" === (r = typeof (t = e)) || t && "object" === r) && null != e.value ? e.value : e + "";
- var t, r
- }
- const ql = function () {
- function e(e) {
- this.categories = e.categories || [],
- this._needCollect = e.needCollect,
- this._deduplication = e.deduplication
- }
- return e.createByAxisModel = function (t) {
- var r = t.option
- , i = r.data
- , n = i && xa(i, Xl);
- return new e({
- categories: n,
- needCollect: !n,
- deduplication: !1 !== r.dedplication
- })
- }
- ,
- e.prototype.getOrdinal = function (e) {
- return this._getOrCreateMap().get(e)
- }
- ,
- e.prototype.parseAndCollect = function (e) {
- var t, r = this._needCollect;
- if ("string" != typeof e && !r)
- return e;
- if (r && !this._deduplication)
- return t = this.categories.length,
- this.categories[t] = e,
- t;
- var i = this._getOrCreateMap();
- return null == (t = i.get(e)) && (r ? (t = this.categories.length,
- this.categories[t] = e,
- i.set(e, t)) : t = NaN),
- t
- }
- ,
- e.prototype._getOrCreateMap = function () {
- return this._map || (this._map = (e = this.categories,
- new Ma(e)));
- var e
- }
- ,
- e
- }();
- var Zl = ["value", "category", "time", "log"];
- function Yl(e, t) {
- return t.type || (t.data ? "category" : "value")
- }
- (0,
- i.use)((function (e) {
- e.registerComponentModel(mo),
- e.registerComponentView(os),
- e.registerCoordinateSystem("grid3D", Fl),
- ["x", "y", "z"].forEach((function (t) {
- !function (e, t, r, n, a) {
- Zl.forEach((function (o) {
- var s = r.extend({
- type: t + "Axis3D." + o,
- __ordinalMeta: null,
- mergeDefaultAndTheme: function (e, r) {
- var a = r.getTheme();
- i.util.merge(e, a.get(o + "Axis3D")),
- i.util.merge(e, this.getDefaultOption()),
- e.type = n(t, e)
- },
- optionUpdated: function () {
- "category" === this.option.type && (this.__ordinalMeta = ql.createByAxisModel(this))
- },
- getCategories: function () {
- if ("category" === this.option.type)
- return this.__ordinalMeta.categories
- },
- getOrdinalMeta: function () {
- return this.__ordinalMeta
- },
- defaultOption: i.util.merge(i.util.clone(jl[o + "Axis3D"]), a || {}, !0)
- });
- e.registerComponentModel(s)
- }
- )),
- e.registerSubTypeDefaulter(t + "Axis3D", i.util.curry(n, t))
- }(e, t, Gl, Yl, {
- name: t.toUpperCase()
- });
- const r = e.ComponentView.extend({
- type: t + "Axis3D"
- });
- e.registerComponentView(r)
- }
- )),
- e.registerAction({
- type: "grid3DChangeCamera",
- event: "grid3dcamerachanged",
- update: "series:updateCamera"
- }, (function (e, t) {
- t.eachComponent({
- mainType: "grid3D",
- query: e
- }, (function (t) {
- t.setView(e)
- }
- ))
- }
- )),
- e.registerAction({
- type: "grid3DShowAxisPointer",
- event: "grid3dshowaxispointer",
- update: "grid3D:showAxisPointer"
- }, (function (e, t) { }
- )),
- e.registerAction({
- type: "grid3DHideAxisPointer",
- event: "grid3dhideaxispointer",
- update: "grid3D:hideAxisPointer"
- }, (function (e, t) { }
- ))
- }
- ));
- const Kl = {
- defaultOption: {
- shading: null,
- realisticMaterial: {
- textureTiling: 1,
- textureOffset: 0,
- detailTexture: null
- },
- lambertMaterial: {
- textureTiling: 1,
- textureOffset: 0,
- detailTexture: null
- },
- colorMaterial: {
- textureTiling: 1,
- textureOffset: 0,
- detailTexture: null
- },
- hatchingMaterial: {
- textureTiling: 1,
- textureOffset: 0,
- paperColor: "#fff"
- }
- }
- }
- , Ql = {
- getFilledRegions: function (e, t) {
- var r, n = (e || []).slice();
- if ("string" == typeof t ? r = (t = i.getMap(t)) && t.geoJson : t && t.features && (r = t),
- !r)
- return [];
- for (var a = {}, o = r.features, s = 0; s < n.length; s++)
- a[n[s].name] = n[s];
- for (s = 0; s < o.length; s++) {
- var l = o[s].properties.name;
- a[l] || n.push({
- name: l
- })
- }
- return n
- },
- defaultOption: {
- show: !0,
- zlevel: -10,
- map: "",
- left: 0,
- top: 0,
- width: "100%",
- height: "100%",
- boxWidth: 100,
- boxHeight: 10,
- boxDepth: "auto",
- regionHeight: 3,
- environment: "auto",
- groundPlane: {
- show: !1,
- color: "#aaa"
- },
- shading: "lambert",
- light: {
- main: {
- alpha: 40,
- beta: 30
- }
- },
- viewControl: {
- alpha: 40,
- beta: 0,
- distance: 100,
- orthographicSize: 60,
- minAlpha: 5,
- minBeta: -80,
- maxBeta: 80
- },
- label: {
- show: !1,
- distance: 2,
- textStyle: {
- fontSize: 20,
- color: "#000",
- backgroundColor: "rgba(255,255,255,0.7)",
- padding: 3,
- borderRadius: 4
- }
- },
- itemStyle: {
- color: "#fff",
- borderWidth: 0,
- borderColor: "#333"
- },
- emphasis: {
- itemStyle: {
- color: "#639fc0"
- },
- label: {
- show: !0
- }
- }
- }
- };
- var Jl = i.ComponentModel.extend({
- type: "geo3D",
- layoutMode: "box",
- coordinateSystem: null,
- optionUpdated: function () {
- var e = this.option;
- e.regions = this.getFilledRegions(e.regions, e.map);
- var t = i.helper.createDimensions(e.data || [], {
- coordDimensions: ["value"],
- encodeDefine: this.get("encode"),
- dimensionsDefine: this.get("dimensions")
- })
- , r = new i.List(t, this);
- r.initData(e.regions);
- var n = {};
- r.each((function (e) {
- var t = r.getName(e)
- , i = r.getItemModel(e);
- n[t] = i
- }
- )),
- this._regionModelMap = n,
- this._data = r
- },
- getData: function () {
- return this._data
- },
- getRegionModel: function (e) {
- var t = this.getData().getName(e);
- return this._regionModelMap[t] || new i.Model(null, this)
- },
- getRegionPolygonCoords: function (e) {
- var t = this.getData().getName(e)
- , r = this.coordinateSystem.getRegion(t);
- return r ? r.geometries : []
- },
- getFormattedLabel: function (e, t) {
- var r = this._data.getName(e)
- , i = this.getRegionModel(e)
- , n = i.get("normal" === t ? ["label", "formatter"] : ["emphasis", "label", "formatter"]);
- null == n && (n = i.get(["label", "formatter"]));
- var a = {
- name: r
- };
- if ("function" == typeof n)
- return a.status = t,
- n(a);
- if ("string" == typeof n) {
- var o = a.seriesName;
- return n.replace("{a}", null != o ? o : "")
- }
- return r
- },
- defaultOption: {
- regions: []
- }
- });
- i.util.merge(Jl.prototype, Ql),
- i.util.merge(Jl.prototype, uo),
- i.util.merge(Jl.prototype, co),
- i.util.merge(Jl.prototype, fo),
- i.util.merge(Jl.prototype, Kl);
- const $l = Jl
- , eh = th;
- function th(e, t, r) {
- r = r || 2;
- var i, n, a, o, s, l, h, u = t && t.length, c = u ? t[0] * r : e.length, d = rh(e, 0, c, r, !0), f = [];
- if (!d)
- return f;
- if (u && (d = function (e, t, r, i) {
- var n, a, o, s = [];
- for (n = 0,
- a = t.length; n < a; n++)
- (o = rh(e, t[n] * i, n < a - 1 ? t[n + 1] * i : e.length, i, !1)) === o.next && (o.steiner = !0),
- s.push(dh(o));
- for (s.sort(hh),
- n = 0; n < s.length; n++)
- uh(s[n], r),
- r = ih(r, r.next);
- return r
- }(e, t, d, r)),
- e.length > 80 * r) {
- i = a = e[0],
- n = o = e[1];
- for (var p = r; p < c; p += r)
- (s = e[p]) < i && (i = s),
- (l = e[p + 1]) < n && (n = l),
- s > a && (a = s),
- l > o && (o = l);
- h = Math.max(a - i, o - n)
- }
- return nh(d, f, r, i, n, h),
- f
- }
- function rh(e, t, r, i, n) {
- var a, o;
- if (n === Th(e, t, r, i) > 0)
- for (a = t; a < r; a += i)
- o = xh(a, e[a], e[a + 1], o);
- else
- for (a = r - i; a >= t; a -= i)
- o = xh(a, e[a], e[a + 1], o);
- return o && gh(o, o.next) && (bh(o),
- o = o.next),
- o
- }
- function ih(e, t) {
- if (!e)
- return e;
- t || (t = e);
- var r, i = e;
- do {
- if (r = !1,
- i.steiner || !gh(i, i.next) && 0 !== mh(i.prev, i, i.next))
- i = i.next;
- else {
- if (bh(i),
- (i = t = i.prev) === i.next)
- return null;
- r = !0
- }
- } while (r || i !== t);
- return t
- }
- function nh(e, t, r, i, n, a, o) {
- if (e) {
- !o && a && function (e, t, r, i) {
- var n = e;
- do {
- null === n.z && (n.z = ch(n.x, n.y, t, r, i)),
- n.prevZ = n.prev,
- n.nextZ = n.next,
- n = n.next
- } while (n !== e);
- n.prevZ.nextZ = null,
- n.prevZ = null,
- function (e) {
- var t, r, i, n, a, o, s, l, h = 1;
- do {
- for (r = e,
- e = null,
- a = null,
- o = 0; r;) {
- for (o++,
- i = r,
- s = 0,
- t = 0; t < h && (s++,
- i = i.nextZ); t++)
- ;
- for (l = h; s > 0 || l > 0 && i;)
- 0 !== s && (0 === l || !i || r.z <= i.z) ? (n = r,
- r = r.nextZ,
- s--) : (n = i,
- i = i.nextZ,
- l--),
- a ? a.nextZ = n : e = n,
- n.prevZ = a,
- a = n;
- r = i
- }
- a.nextZ = null,
- h *= 2
- } while (o > 1)
- }(n)
- }(e, i, n, a);
- for (var s, l, h = e; e.prev !== e.next;)
- if (s = e.prev,
- l = e.next,
- a ? oh(e, i, n, a) : ah(e))
- t.push(s.i / r),
- t.push(e.i / r),
- t.push(l.i / r),
- bh(e),
- e = l.next,
- h = l.next;
- else if ((e = l) === h) {
- o ? 1 === o ? nh(e = sh(e, t, r), t, r, i, n, a, 2) : 2 === o && lh(e, t, r, i, n, a) : nh(ih(e), t, r, i, n, a, 1);
- break
- }
- }
- }
- function ah(e) {
- var t = e.prev
- , r = e
- , i = e.next;
- if (mh(t, r, i) >= 0)
- return !1;
- for (var n = e.next.next; n !== e.prev;) {
- if (fh(t.x, t.y, r.x, r.y, i.x, i.y, n.x, n.y) && mh(n.prev, n, n.next) >= 0)
- return !1;
- n = n.next
- }
- return !0
- }
- function oh(e, t, r, i) {
- var n = e.prev
- , a = e
- , o = e.next;
- if (mh(n, a, o) >= 0)
- return !1;
- for (var s = n.x < a.x ? n.x < o.x ? n.x : o.x : a.x < o.x ? a.x : o.x, l = n.y < a.y ? n.y < o.y ? n.y : o.y : a.y < o.y ? a.y : o.y, h = n.x > a.x ? n.x > o.x ? n.x : o.x : a.x > o.x ? a.x : o.x, u = n.y > a.y ? n.y > o.y ? n.y : o.y : a.y > o.y ? a.y : o.y, c = ch(s, l, t, r, i), d = ch(h, u, t, r, i), f = e.nextZ; f && f.z <= d;) {
- if (f !== e.prev && f !== e.next && fh(n.x, n.y, a.x, a.y, o.x, o.y, f.x, f.y) && mh(f.prev, f, f.next) >= 0)
- return !1;
- f = f.nextZ
- }
- for (f = e.prevZ; f && f.z >= c;) {
- if (f !== e.prev && f !== e.next && fh(n.x, n.y, a.x, a.y, o.x, o.y, f.x, f.y) && mh(f.prev, f, f.next) >= 0)
- return !1;
- f = f.prevZ
- }
- return !0
- }
- function sh(e, t, r) {
- var i = e;
- do {
- var n = i.prev
- , a = i.next.next;
- !gh(n, a) && _h(n, i, i.next, a) && vh(n, a) && vh(a, n) && (t.push(n.i / r),
- t.push(i.i / r),
- t.push(a.i / r),
- bh(i),
- bh(i.next),
- i = e = a),
- i = i.next
- } while (i !== e);
- return i
- }
- function lh(e, t, r, i, n, a) {
- var o = e;
- do {
- for (var s = o.next.next; s !== o.prev;) {
- if (o.i !== s.i && ph(o, s)) {
- var l = yh(o, s);
- return o = ih(o, o.next),
- l = ih(l, l.next),
- nh(o, t, r, i, n, a),
- void nh(l, t, r, i, n, a)
- }
- s = s.next
- }
- o = o.next
- } while (o !== e)
- }
- function hh(e, t) {
- return e.x - t.x
- }
- function uh(e, t) {
- if (t = function (e, t) {
- var r, i = t, n = e.x, a = e.y, o = -1 / 0;
- do {
- if (a <= i.y && a >= i.next.y && i.next.y !== i.y) {
- var s = i.x + (a - i.y) * (i.next.x - i.x) / (i.next.y - i.y);
- if (s <= n && s > o) {
- if (o = s,
- s === n) {
- if (a === i.y)
- return i;
- if (a === i.next.y)
- return i.next
- }
- r = i.x < i.next.x ? i : i.next
- }
- }
- i = i.next
- } while (i !== t);
- if (!r)
- return null;
- if (n === o)
- return r.prev;
- var l, h = r, u = r.x, c = r.y, d = 1 / 0;
- for (i = r.next; i !== h;)
- n >= i.x && i.x >= u && n !== i.x && fh(a < c ? n : o, a, u, c, a < c ? o : n, a, i.x, i.y) && ((l = Math.abs(a - i.y) / (n - i.x)) < d || l === d && i.x > r.x) && vh(i, e) && (r = i,
- d = l),
- i = i.next;
- return r
- }(e, t)) {
- var r = yh(t, e);
- ih(r, r.next)
- }
- }
- function ch(e, t, r, i, n) {
- return (e = 1431655765 & ((e = 858993459 & ((e = 252645135 & ((e = 16711935 & ((e = 32767 * (e - r) / n) | e << 8)) | e << 4)) | e << 2)) | e << 1)) | (t = 1431655765 & ((t = 858993459 & ((t = 252645135 & ((t = 16711935 & ((t = 32767 * (t - i) / n) | t << 8)) | t << 4)) | t << 2)) | t << 1)) << 1
- }
- function dh(e) {
- var t = e
- , r = e;
- do {
- t.x < r.x && (r = t),
- t = t.next
- } while (t !== e);
- return r
- }
- function fh(e, t, r, i, n, a, o, s) {
- return (n - o) * (t - s) - (e - o) * (a - s) >= 0 && (e - o) * (i - s) - (r - o) * (t - s) >= 0 && (r - o) * (a - s) - (n - o) * (i - s) >= 0
- }
- function ph(e, t) {
- return e.next.i !== t.i && e.prev.i !== t.i && !function (e, t) {
- var r = e;
- do {
- if (r.i !== e.i && r.next.i !== e.i && r.i !== t.i && r.next.i !== t.i && _h(r, r.next, e, t))
- return !0;
- r = r.next
- } while (r !== e);
- return !1
- }(e, t) && vh(e, t) && vh(t, e) && function (e, t) {
- var r = e
- , i = !1
- , n = (e.x + t.x) / 2
- , a = (e.y + t.y) / 2;
- do {
- r.y > a != r.next.y > a && r.next.y !== r.y && n < (r.next.x - r.x) * (a - r.y) / (r.next.y - r.y) + r.x && (i = !i),
- r = r.next
- } while (r !== e);
- return i
- }(e, t)
- }
- function mh(e, t, r) {
- return (t.y - e.y) * (r.x - t.x) - (t.x - e.x) * (r.y - t.y)
- }
- function gh(e, t) {
- return e.x === t.x && e.y === t.y
- }
- function _h(e, t, r, i) {
- return !!(gh(e, t) && gh(r, i) || gh(e, i) && gh(r, t)) || mh(e, t, r) > 0 != mh(e, t, i) > 0 && mh(r, i, e) > 0 != mh(r, i, t) > 0
- }
- function vh(e, t) {
- return mh(e.prev, e, e.next) < 0 ? mh(e, t, e.next) >= 0 && mh(e, e.prev, t) >= 0 : mh(e, t, e.prev) < 0 || mh(e, e.next, t) < 0
- }
- function yh(e, t) {
- var r = new wh(e.i, e.x, e.y)
- , i = new wh(t.i, t.x, t.y)
- , n = e.next
- , a = t.prev;
- return e.next = t,
- t.prev = e,
- r.next = n,
- n.prev = r,
- i.next = r,
- r.prev = i,
- a.next = i,
- i.prev = a,
- i
- }
- function xh(e, t, r, i) {
- var n = new wh(e, t, r);
- return i ? (n.next = i.next,
- n.prev = i,
- i.next.prev = n,
- i.next = n) : (n.prev = n,
- n.next = n),
- n
- }
- function bh(e) {
- e.next.prev = e.prev,
- e.prev.next = e.next,
- e.prevZ && (e.prevZ.nextZ = e.nextZ),
- e.nextZ && (e.nextZ.prevZ = e.prevZ)
- }
- function wh(e, t, r) {
- this.i = e,
- this.x = t,
- this.y = r,
- this.prev = null,
- this.next = null,
- this.z = null,
- this.prevZ = null,
- this.nextZ = null,
- this.steiner = !1
- }
- function Th(e, t, r, i) {
- for (var n = 0, a = t, o = r - i; a < r; a += i)
- n += (e[o] - e[a]) * (e[a + 1] + e[o + 1]),
- o = a;
- return n
- }
- function Sh(e, t, r) {
- var i = e[t];
- e[t] = e[r],
- e[r] = i
- }
- function Mh(e, t, r, i, n) {
- var a = r
- , o = e[t];
- Sh(e, t, i);
- for (var s = r; s < i; s++)
- n(e[s], o) < 0 && (Sh(e, s, a),
- a++);
- return Sh(e, i, a),
- a
- }
- function Ah(e, t, r, i) {
- if (r < i) {
- var n = Mh(e, Math.floor((r + i) / 2), r, i, t);
- Ah(e, t, r, n - 1),
- Ah(e, t, n + 1, i)
- }
- }
- function Eh() {
- this._parts = []
- }
- th.deviation = function (e, t, r, i) {
- var n = t && t.length
- , a = n ? t[0] * r : e.length
- , o = Math.abs(Th(e, 0, a, r));
- if (n)
- for (var s = 0, l = t.length; s < l; s++) {
- var h = t[s] * r
- , u = s < l - 1 ? t[s + 1] * r : e.length;
- o -= Math.abs(Th(e, h, u, r))
- }
- var c = 0;
- for (s = 0; s < i.length; s += 3) {
- var d = i[s] * r
- , f = i[s + 1] * r
- , p = i[s + 2] * r;
- c += Math.abs((e[d] - e[p]) * (e[f + 1] - e[d + 1]) - (e[d] - e[f]) * (e[p + 1] - e[d + 1]))
- }
- return 0 === o && 0 === c ? 0 : Math.abs((c - o) / o)
- }
- ,
- Eh.prototype.step = function (e, t, r) {
- var i = e.length;
- if (0 === r) {
- this._parts = [],
- this._sorted = !1;
- var n = Math.floor(i / 2);
- this._parts.push({
- pivot: n,
- left: 0,
- right: i - 1
- }),
- this._currentSortPartIdx = 0
- }
- if (!this._sorted) {
- var a = this._parts;
- if (0 === a.length)
- return this._sorted = !0,
- !0;
- if (a.length < 512) {
- for (var o = 0; o < a.length; o++)
- a[o].pivot = Mh(e, a[o].pivot, a[o].left, a[o].right, t);
- var s = [];
- for (o = 0; o < a.length; o++) {
- var l, h = a[o].left;
- (l = a[o].pivot - 1) > h && s.push({
- pivot: Math.floor((l + h) / 2),
- left: h,
- right: l
- }),
- h = a[o].pivot + 1,
- (l = a[o].right) > h && s.push({
- pivot: Math.floor((l + h) / 2),
- left: h,
- right: l
- })
- }
- a = this._parts = s
- } else
- for (o = 0; o < Math.floor(a.length / 10); o++) {
- var u = a.length - 1 - this._currentSortPartIdx;
- if (Ah(e, t, a[u].left, a[u].right),
- this._currentSortPartIdx++,
- this._currentSortPartIdx === a.length)
- return this._sorted = !0,
- !0
- }
- return !1
- }
- }
- ,
- Eh.sort = Ah;
- const Ch = Eh;
- var Dh = Po.vec3
- , Lh = Dh.create()
- , Ph = Dh.create()
- , Oh = Dh.create();
- const Nh = {
- needsSortTriangles: function () {
- return this.indices && this.sortTriangles
- },
- needsSortTrianglesProgressively: function () {
- return this.needsSortTriangles() && this.triangleCount >= 2e4
- },
- doSortTriangles: function (e, t) {
- var r = this.indices;
- if (0 === t) {
- var i = this.attributes.position;
- e = e.array,
- this._triangleZList && this._triangleZList.length === this.triangleCount || (this._triangleZList = new Float32Array(this.triangleCount),
- this._sortedTriangleIndices = new Uint32Array(this.triangleCount),
- this._indicesTmp = new r.constructor(r.length),
- this._triangleZListTmp = new Float32Array(this.triangleCount));
- for (var n, a = 0, o = 0; o < r.length;) {
- i.get(r[o++], Lh),
- i.get(r[o++], Ph),
- i.get(r[o++], Oh);
- var s = Dh.sqrDist(Lh, e)
- , l = Dh.sqrDist(Ph, e)
- , h = Dh.sqrDist(Oh, e)
- , u = Math.min(s, l);
- u = Math.min(u, h),
- 3 === o ? (n = u,
- u = 0) : u -= n,
- this._triangleZList[a++] = u
- }
- }
- var c = this._sortedTriangleIndices;
- for (o = 0; o < c.length; o++)
- c[o] = o;
- if (this.triangleCount < 2e4)
- 0 === t && this._simpleSort(!0);
- else
- for (o = 0; o < 3; o++)
- this._progressiveQuickSort(3 * t + o);
- var d = this._indicesTmp
- , f = this._triangleZListTmp
- , p = this._triangleZList;
- for (o = 0; o < this.triangleCount; o++) {
- var m = 3 * c[o]
- , g = 3 * o;
- d[g++] = r[m++],
- d[g++] = r[m++],
- d[g] = r[m],
- f[o] = p[c[o]]
- }
- var _ = this._indicesTmp;
- this._indicesTmp = this.indices,
- this.indices = _,
- _ = this._triangleZListTmp,
- this._triangleZListTmp = this._triangleZList,
- this._triangleZList = _,
- this.dirtyIndices()
- },
- _simpleSort: function (e) {
- var t = this._triangleZList
- , r = this._sortedTriangleIndices;
- function i(e, r) {
- return t[r] - t[e]
- }
- e ? Array.prototype.sort.call(r, i) : Ch.sort(r, i, 0, r.length - 1)
- },
- _progressiveQuickSort: function (e) {
- var t = this._triangleZList
- , r = this._sortedTriangleIndices;
- this._quickSort = this._quickSort || new Ch,
- this._quickSort.step(r, (function (e, r) {
- return t[r] - t[e]
- }
- ), e)
- }
- };
- function Ih(e, t) {
- const r = e.getItemVisual(t, "style");
- if (r)
- return r[e.getVisual("drawType")]
- }
- function Rh(e, t) {
- const r = e.getItemVisual(t, "style");
- return r && r.opacity
- }
- function Bh(e, t, r) {
- this._labelsMesh = new Qo,
- this._labelTextureSurface = new zo({
- width: 512,
- height: 512,
- devicePixelRatio: r.getDevicePixelRatio(),
- onupdate: function () {
- r.getZr().refresh()
- }
- }),
- this._api = r,
- this._labelsMesh.material.set("textureAtlas", this._labelTextureSurface.getTexture())
- }
- Bh.prototype.getLabelPosition = function (e, t, r) {
- return [0, 0, 0]
- }
- ,
- Bh.prototype.getLabelDistance = function (e, t, r) {
- return 0
- }
- ,
- Bh.prototype.getMesh = function () {
- return this._labelsMesh
- }
- ,
- Bh.prototype.updateData = function (e, t, r) {
- null == t && (t = 0),
- null == r && (r = e.count()),
- this._labelsVisibilitiesBits && this._labelsVisibilitiesBits.length === r - t || (this._labelsVisibilitiesBits = new Uint8Array(r - t));
- for (var i = ["label", "show"], n = ["emphasis", "label", "show"], a = t; a < r; a++) {
- var o = e.getItemModel(a)
- , s = o.get(i)
- , l = o.get(n);
- null == l && (l = s);
- var h = (s ? 1 : 0) | (l ? 2 : 0);
- this._labelsVisibilitiesBits[a - t] = h
- }
- this._start = t,
- this._end = r,
- this._data = e
- }
- ,
- Bh.prototype.updateLabels = function (e) {
- if (this._data) {
- for (var t = (e = e || []).length > 0, r = {}, n = 0; n < e.length; n++)
- r[e[n]] = !0;
- this._labelsMesh.geometry.convertToDynamicArray(!0),
- this._labelTextureSurface.clear();
- for (var a = ["label"], o = ["emphasis", "label"], s = this._data.hostModel, l = this._data, h = s.getModel(a), u = s.getModel(o, h), c = {
- left: "right",
- right: "left",
- top: "center",
- bottom: "center"
- }, d = {
- left: "middle",
- right: "middle",
- top: "bottom",
- bottom: "top"
- }, f = this._start; f < this._end; f++) {
- var p = !1;
- if (t && r[f] && (p = !0),
- this._labelsVisibilitiesBits[f - this._start] & (p ? 2 : 1)) {
- var m = l.getItemModel(f).getModel(p ? o : a, p ? u : h)
- , g = m.get("distance") || 0
- , _ = m.get("position")
- , v = this._api.getDevicePixelRatio()
- , y = s.getFormattedLabel(f, p ? "emphasis" : "normal");
- if (null == y || "" === y)
- return;
- var x = new i.graphic.Text({
- style: xo(m, {
- text: y,
- fill: m.get("color") || Ih(l, f) || "#000",
- align: "left",
- verticalAlign: "top",
- opacity: Mn(m.get("opacity"), Rh(l, f), 1)
- })
- })
- , b = x.getBoundingRect();
- b.height *= 1.2;
- var w = this._labelTextureSurface.add(x)
- , T = c[_] || "center"
- , S = d[_] || "bottom";
- this._labelsMesh.geometry.addSprite(this.getLabelPosition(f, _, g), [b.width * v, b.height * v], w, T, S, this.getLabelDistance(f, _, g) * v)
- }
- }
- this._labelsMesh.material.set("uvScale", this._labelTextureSurface.getCoordsScale()),
- this._labelTextureSurface.getZr().refreshImmediately(),
- this._labelsMesh.geometry.convertToTypedArray(),
- this._labelsMesh.geometry.dirty()
- }
- }
- ,
- Bh.prototype.dispose = function () {
- this._labelTextureSurface.dispose()
- }
- ;
- const Fh = Bh;
- var zh = Po.vec3;
- function Gh(e) {
- this.rootNode = new Ka.Node,
- this._triangulationResults = {},
- this._shadersMap = Ka.COMMON_SHADERS.filter((function (e) {
- return "shadow" !== e
- }
- )).reduce((function (e, t) {
- return e[t] = Ka.createShader("ecgl." + t),
- e
- }
- ), {}),
- this._linesShader = Ka.createShader("ecgl.meshLines3D");
- var t = {};
- Ka.COMMON_SHADERS.forEach((function (e) {
- t[e] = new Ka.Material({
- shader: Ka.createShader("ecgl." + e)
- })
- }
- )),
- this._groundMaterials = t,
- this._groundMesh = new Ka.Mesh({
- geometry: new Ka.PlaneGeometry({
- dynamic: !0
- }),
- castShadow: !1,
- renderNormal: !0,
- $ignorePicking: !0
- }),
- this._groundMesh.rotation.rotateX(-Math.PI / 2),
- this._labelsBuilder = new Fh(512, 512, e),
- this._labelsBuilder.getMesh().renderOrder = 100,
- this._labelsBuilder.getMesh().material.depthTest = !1,
- this.rootNode.add(this._labelsBuilder.getMesh()),
- this._initMeshes(),
- this._api = e
- }
- Ka.Shader.import(is),
- Gh.prototype = {
- constructor: Gh,
- extrudeY: !0,
- update: function (e, t, r, i, n) {
- var a = e.getData();
- null == i && (i = 0),
- null == n && (n = a.count()),
- this._startIndex = i,
- this._endIndex = n - 1,
- this._triangulation(e, i, n);
- var o = this._getShader(e.get("shading"));
- this._prepareMesh(e, o, r, i, n),
- this.rootNode.updateWorldTransform(),
- this._updateRegionMesh(e, r, i, n);
- var s = e.coordinateSystem;
- "geo3D" === s.type && this._updateGroundPlane(e, s, r);
- var l = this;
- this._labelsBuilder.updateData(a, i, n),
- this._labelsBuilder.getLabelPosition = function (e, t, r) {
- var i = a.getName(e)
- , n = r;
- if ("geo3D" === s.type) {
- var o = s.getRegion(i);
- return o ? (u = o.getCenter(),
- s.dataToPoint([u[0], u[1], n])) : [NaN, NaN, NaN]
- }
- var h = l._triangulationResults[e - l._startIndex]
- , u = l.extrudeY ? [(h.max[0] + h.min[0]) / 2, h.max[1] + n, (h.max[2] + h.min[2]) / 2] : [(h.max[0] + h.min[0]) / 2, (h.max[1] + h.min[1]) / 2, h.max[2] + n]
- }
- ,
- this._data = a,
- this._labelsBuilder.updateLabels(),
- this._updateDebugWireframe(e),
- this._lastHoverDataIndex = 0
- },
- _initMeshes: function () {
- var e = this
- , t = function () {
- var t = new Ka.Mesh({
- name: "Polygon",
- material: new Ka.Material({
- shader: e._shadersMap.lambert
- }),
- geometry: new Ka.Geometry({
- sortTriangles: !0,
- dynamic: !0
- }),
- culling: !1,
- ignorePicking: !0,
- renderNormal: !0
- });
- return Object.assign(t.geometry, Nh),
- t
- }()
- , r = new Ka.Mesh({
- material: new Ka.Material({
- shader: this._linesShader
- }),
- castShadow: !1,
- ignorePicking: !0,
- $ignorePicking: !0,
- geometry: new Ro({
- useNativeLine: !1
- })
- });
- this.rootNode.add(t),
- this.rootNode.add(r),
- t.material.define("both", "VERTEX_COLOR"),
- t.material.define("fragment", "DOUBLE_SIDED"),
- this._polygonMesh = t,
- this._linesMesh = r,
- this.rootNode.add(this._groundMesh)
- },
- _getShader: function (e) {
- var t = this._shadersMap[e];
- return t || (t = this._shadersMap.lambert),
- t.__shading = e,
- t
- },
- _prepareMesh: function (e, t, r, i, n) {
- for (var a = 0, o = 0, s = 0, l = 0, h = i; h < n; h++) {
- var u = this._getRegionPolygonInfo(h)
- , c = this._getRegionLinesInfo(h, e, this._linesMesh.geometry);
- a += u.vertexCount,
- o += u.triangleCount,
- s += c.vertexCount,
- l += c.triangleCount
- }
- var d = this._polygonMesh
- , f = d.geometry;
- ["position", "normal", "texcoord0", "color"].forEach((function (e) {
- f.attributes[e].init(a)
- }
- )),
- f.indices = a > 65535 ? new Uint32Array(3 * o) : new Uint16Array(3 * o),
- d.material.shader !== t && d.material.attachShader(t, !0),
- Ka.setMaterialFromModel(t.__shading, d.material, e, r),
- s > 0 && (this._linesMesh.geometry.resetOffset(),
- this._linesMesh.geometry.setVertexCount(s),
- this._linesMesh.geometry.setTriangleCount(l)),
- this._dataIndexOfVertex = new Uint32Array(a),
- this._vertexRangeOfDataIndex = new Uint32Array(2 * (n - i))
- },
- _updateRegionMesh: function (e, t, r, i) {
- for (var n = e.getData(), a = 0, o = 0, s = !1, l = this._polygonMesh, h = this._linesMesh, u = r; u < i; u++) {
- var c = e.getRegionModel(u)
- , d = c.getModel("itemStyle")
- , f = Mn(Ih(n, u), d.get("color"), "#fff")
- , p = Mn(Rh(n, u), d.get("opacity"), 1)
- , m = Ka.parseColor(f)
- , g = Ka.parseColor(d.get("borderColor"));
- m[3] *= p,
- g[3] *= p;
- var _ = m[3] < .99;
- l.material.set("color", [1, 1, 1, 1]),
- s = s || _;
- for (var v = Mn(c.get("height", !0), e.get("regionHeight")), y = this._updatePolygonGeometry(e, l.geometry, u, v, a, o, m), x = a; x < y.vertexOffset; x++)
- this._dataIndexOfVertex[x] = u;
- this._vertexRangeOfDataIndex[2 * (u - r)] = a,
- this._vertexRangeOfDataIndex[2 * (u - r) + 1] = y.vertexOffset,
- a = y.vertexOffset,
- o = y.triangleOffset;
- var b = d.get("borderWidth")
- , w = b > 0;
- w && (b *= t.getDevicePixelRatio(),
- this._updateLinesGeometry(h.geometry, e, u, v, b, e.coordinateSystem.transform)),
- h.invisible = !w,
- h.material.set({
- color: g
- })
- }
- (l = this._polygonMesh).material.transparent = s,
- l.material.depthMask = !s,
- l.geometry.updateBoundingBox(),
- l.frontFace = this.extrudeY ? Ka.Mesh.CCW : Ka.Mesh.CW,
- l.material.get("normalMap") && l.geometry.generateTangents(),
- l.seriesIndex = e.seriesIndex,
- l.on("mousemove", this._onmousemove, this),
- l.on("mouseout", this._onmouseout, this)
- },
- _updateDebugWireframe: function (e) {
- var t = e.getModel("debug.wireframe");
- if (t.get("show")) {
- var r = Ka.parseColor(t.get("lineStyle.color") || "rgba(0,0,0,0.5)")
- , i = Mn(t.get("lineStyle.width"), 1)
- , n = this._polygonMesh;
- n.geometry.generateBarycentric(),
- n.material.define("both", "WIREFRAME_TRIANGLE"),
- n.material.set("wireframeLineColor", r),
- n.material.set("wireframeLineWidth", i)
- }
- },
- _onmousemove: function (e) {
- var t = this._dataIndexOfVertex[e.triangle[0]];
- null == t && (t = -1),
- t !== this._lastHoverDataIndex && (this.downplay(this._lastHoverDataIndex),
- this.highlight(t),
- this._labelsBuilder.updateLabels([t])),
- this._lastHoverDataIndex = t,
- this._polygonMesh.dataIndex = t
- },
- _onmouseout: function (e) {
- e.target && (this.downplay(this._lastHoverDataIndex),
- this._lastHoverDataIndex = -1,
- this._polygonMesh.dataIndex = -1),
- this._labelsBuilder.updateLabels([])
- },
- _updateGroundPlane: function (e, t, r) {
- var i = e.getModel("groundPlane", e);
- if (this._groundMesh.invisible = !i.get("show", !0),
- !this._groundMesh.invisible) {
- var n = e.get("shading")
- , a = this._groundMaterials[n];
- a || (a = this._groundMaterials.lambert),
- Ka.setMaterialFromModel(n, a, i, r),
- a.get("normalMap") && this._groundMesh.geometry.generateTangents(),
- this._groundMesh.material = a,
- this._groundMesh.material.set("color", Ka.parseColor(i.get("color"))),
- this._groundMesh.scale.set(t.size[0], t.size[2], 1)
- }
- },
- _triangulation: function (e, t, r) {
- this._triangulationResults = [];
- for (var i = [1 / 0, 1 / 0, 1 / 0], n = [-1 / 0, -1 / 0, -1 / 0], a = e.coordinateSystem, o = t; o < r; o++) {
- for (var s = [], l = e.getRegionPolygonCoords(o), h = 0; h < l.length; h++) {
- var u = l[h].exterior
- , c = l[h].interiors
- , d = []
- , f = [];
- if (!(u.length < 3)) {
- for (var p = 0, m = 0; m < u.length; m++) {
- var g = u[m];
- d[p++] = g[0],
- d[p++] = g[1]
- }
- for (m = 0; m < c.length; m++)
- if (!(c[m].length < 3)) {
- for (var _ = d.length / 2, v = 0; v < c[m].length; v++)
- g = c[m][v],
- d.push(g[0]),
- d.push(g[1]);
- f.push(_)
- }
- var y = eh(d, f)
- , x = new Float64Array(d.length / 2 * 3)
- , b = []
- , w = [1 / 0, 1 / 0, 1 / 0]
- , T = [-1 / 0, -1 / 0, -1 / 0]
- , S = 0;
- for (m = 0; m < d.length;)
- zh.set(b, d[m++], 0, d[m++]),
- a && a.transform && zh.transformMat4(b, b, a.transform),
- zh.min(w, w, b),
- zh.max(T, T, b),
- x[S++] = b[0],
- x[S++] = b[1],
- x[S++] = b[2];
- zh.min(i, i, w),
- zh.max(n, n, T),
- s.push({
- points: x,
- indices: y,
- min: w,
- max: T
- })
- }
- }
- this._triangulationResults.push(s)
- }
- this._geoBoundingBox = [i, n]
- },
- _getRegionPolygonInfo: function (e) {
- for (var t = this._triangulationResults[e - this._startIndex], r = 0, i = 0, n = 0; n < t.length; n++)
- r += t[n].points.length / 3,
- i += t[n].indices.length / 3;
- return {
- vertexCount: 2 * r + 4 * r,
- triangleCount: 2 * i + 2 * r
- }
- },
- _updatePolygonGeometry: function (e, t, r, i, n, a, o) {
- var s = e.get("projectUVOnGround")
- , l = t.attributes.position
- , h = t.attributes.normal
- , u = t.attributes.texcoord0
- , c = t.attributes.color
- , d = this._triangulationResults[r - this._startIndex]
- , f = c.value && o
- , p = t.indices
- , m = this.extrudeY ? 1 : 2
- , g = this.extrudeY ? 2 : 1
- , _ = [this.rootNode.worldTransform.x.len(), this.rootNode.worldTransform.y.len(), this.rootNode.worldTransform.z.len()]
- , v = zh.mul([], this._geoBoundingBox[0], _)
- , y = zh.mul([], this._geoBoundingBox[1], _)
- , x = Math.max(y[0] - v[0], y[2] - v[2]);
- function b(e, t, r) {
- var i = n;
- !function (e, t, r) {
- for (var i = e.points, a = i.length, s = [], h = [], d = 0; d < a; d += 3)
- s[0] = i[d],
- s[m] = t,
- s[g] = i[d + 2],
- h[0] = (i[d] * _[0] - v[0]) / x,
- h[1] = (i[d + 2] * _[g] - v[2]) / x,
- l.set(n, s),
- f && c.set(n, o),
- u.set(n++, h)
- }(e, t);
- for (var s = e.indices.length, h = 0; h < s; h++)
- p[3 * a + h] = e.indices[h] + i;
- a += e.indices.length / 3
- }
- for (var w = this.extrudeY ? [0, 1, 0] : [0, 0, 1], T = zh.negate([], w), S = 0; S < d.length; S++) {
- var M = n
- , A = d[S];
- b(A, 0),
- b(A, i);
- for (var E = A.points.length / 3, C = 0; C < E; C++)
- h.set(M + C, T),
- h.set(M + C + E, w);
- var D = [0, 3, 1, 1, 3, 2]
- , L = [[], [], [], []]
- , P = []
- , O = []
- , N = []
- , I = []
- , R = 0;
- for (C = 0; C < E; C++) {
- for (var B = (C + 1) % E, F = (A.points[3 * B] - A.points[3 * C]) * _[0], z = (A.points[3 * B + 2] - A.points[3 * C + 2]) * _[g], G = Math.sqrt(F * F + z * z), U = 0; U < 4; U++) {
- var k = 0 === U || 3 === U
- , V = 3 * (k ? C : B);
- L[U][0] = A.points[V],
- L[U][m] = U > 1 ? i : 0,
- L[U][g] = A.points[V + 2],
- l.set(n + U, L[U]),
- s ? (I[0] = (A.points[V] * _[0] - v[0]) / x,
- I[1] = (A.points[V + 2] * _[g] - v[g]) / x) : (I[0] = (k ? R : R + G) / x,
- I[1] = (L[U][m] * _[m] - v[m]) / x),
- u.set(n + U, I)
- }
- for (zh.sub(P, L[1], L[0]),
- zh.sub(O, L[3], L[0]),
- zh.cross(N, P, O),
- zh.normalize(N, N),
- U = 0; U < 4; U++)
- h.set(n + U, N),
- f && c.set(n + U, o);
- for (U = 0; U < 6; U++)
- p[3 * a + U] = D[U] + n;
- n += 4,
- a += 2,
- R += G
- }
- }
- return t.dirty(),
- {
- vertexOffset: n,
- triangleOffset: a
- }
- },
- _getRegionLinesInfo: function (e, t, r) {
- var i = 0
- , n = 0;
- return t.getRegionModel(e).getModel("itemStyle").get("borderWidth") > 0 && t.getRegionPolygonCoords(e).forEach((function (e) {
- var t = e.exterior
- , a = e.interiors;
- i += r.getPolylineVertexCount(t),
- n += r.getPolylineTriangleCount(t);
- for (var o = 0; o < a.length; o++)
- i += r.getPolylineVertexCount(a[o]),
- n += r.getPolylineTriangleCount(a[o])
- }
- ), this),
- {
- vertexCount: i,
- triangleCount: n
- }
- },
- _updateLinesGeometry: function (e, t, r, i, n, a) {
- function o(e) {
- for (var t = new Float64Array(3 * e.length), r = 0, n = [], o = 0; o < e.length; o++)
- n[0] = e[o][0],
- n[1] = i + .1,
- n[2] = e[o][1],
- a && zh.transformMat4(n, n, a),
- t[r++] = n[0],
- t[r++] = n[1],
- t[r++] = n[2];
- return t
- }
- var s = [1, 1, 1, 1];
- t.getRegionPolygonCoords(r).forEach((function (t) {
- var r = t.exterior
- , i = t.interiors;
- e.addPolyline(o(r), s, n);
- for (var a = 0; a < i.length; a++)
- e.addPolyline(o(i[a]), s, n)
- }
- ))
- },
- highlight: function (e) {
- var t = this._data;
- if (t) {
- var r = t.getItemModel(e).getModel(["emphasis", "itemStyle"])
- , n = r.get("color")
- , a = Mn(r.get("opacity"), Rh(t, e), 1);
- if (null == n) {
- var o = Ih(t, e);
- n = i.color.lift(o, -.4)
- }
- null == a && (a = Rh(t, e));
- var s = Ka.parseColor(n);
- s[3] *= a,
- this._setColorOfDataIndex(t, e, s)
- }
- },
- downplay: function (e) {
- var t = this._data;
- if (t) {
- var r = t.getItemModel(e)
- , i = Mn(Ih(t, e), r.get(["itemStyle", "color"]), "#fff")
- , n = Mn(Rh(t, e), r.get(["itemStyle", "opacity"]), 1)
- , a = Ka.parseColor(i);
- a[3] *= n,
- this._setColorOfDataIndex(t, e, a)
- }
- },
- dispose: function () {
- this._labelsBuilder.dispose()
- },
- _setColorOfDataIndex: function (e, t, r) {
- if (!(t < this._startIndex && t > this._endIndex)) {
- t -= this._startIndex;
- for (var i = this._vertexRangeOfDataIndex[2 * t]; i < this._vertexRangeOfDataIndex[2 * t + 1]; i++)
- this._polygonMesh.geometry.attributes.color.set(i, r);
- this._polygonMesh.geometry.dirty(),
- this._api.getZr().refresh()
- }
- }
- };
- const Uh = Gh
- , kh = i.ComponentView.extend({
- type: "geo3D",
- __ecgl__: !0,
- init: function (e, t) {
- this._geo3DBuilder = new Uh(t),
- this.groupGL = new Ka.Node,
- this._lightRoot = new Ka.Node,
- this._sceneHelper = new Uo(this._lightRoot),
- this._sceneHelper.initLight(this._lightRoot),
- this._control = new Do({
- zr: t.getZr()
- }),
- this._control.init()
- },
- render: function (e, t, r) {
- this.groupGL.add(this._geo3DBuilder.rootNode);
- var i = e.coordinateSystem;
- if (i && i.viewGL) {
- i.viewGL.add(this._lightRoot),
- e.get("show") ? i.viewGL.add(this.groupGL) : i.viewGL.remove(this.groupGL);
- var n = this._control;
- n.setViewGL(i.viewGL);
- var a = e.getModel("viewControl");
- n.setFromViewControlModel(a, 0),
- this._sceneHelper.setScene(i.viewGL.scene),
- this._sceneHelper.updateLight(e),
- i.viewGL.setPostEffect(e.getModel("postEffect"), r),
- i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),
- this._geo3DBuilder.update(e, t, r, 0, e.getData().count());
- var o = i.viewGL.isLinearSpace() ? "define" : "undefine";
- this._geo3DBuilder.rootNode.traverse((function (e) {
- e.material && e.material[o]("fragment", "SRGB_DECODE")
- }
- )),
- n.off("update"),
- n.on("update", (function () {
- r.dispatchAction({
- type: "geo3DChangeCamera",
- alpha: n.getAlpha(),
- beta: n.getBeta(),
- distance: n.getDistance(),
- center: n.getCenter(),
- from: this.uid,
- geo3DId: e.id
- })
- }
- )),
- n.update()
- }
- },
- afterRender: function (e, t, r, i) {
- var n = i.renderer;
- this._sceneHelper.updateAmbientCubemap(n, e, r),
- this._sceneHelper.updateSkybox(n, e, r)
- },
- dispose: function () {
- this._control.dispose(),
- this._geo3DBuilder.dispose()
- }
- });
- var Vh = {
- 南海诸岛: [32, 80],
- 广东: [0, -10],
- 香港: [10, 5],
- 澳门: [-10, 10],
- 天津: [5, 5]
- }
- , Hh = {
- Russia: [100, 60],
- "United States": [-99, 38],
- "United States of America": [-99, 38]
- }
- , Wh = Po.vec3
- , jh = Po.mat4
- , Xh = [function (e, t) {
- if ("china" === e) {
- var r = Vh[t.name];
- if (r) {
- var i = t.getCenter();
- i[0] += r[0] / 10.5,
- i[1] += -r[1] / 14,
- t.setCenter(i)
- }
- }
- }
- , function (e, t) {
- if ("world" === e) {
- var r = Hh[t.name];
- if (r) {
- var i = [r[0], r[1]];
- t.setCenter(i)
- }
- }
- }
- ];
- function qh(e, t, r, i, n) {
- this.name = e,
- this.map = t,
- this.regionHeight = 0,
- this.regions = [],
- this._nameCoordMap = {},
- this.loadGeoJson(r, i, n),
- this.transform = jh.identity(new Float64Array(16)),
- this.invTransform = jh.identity(new Float64Array(16)),
- this.extrudeY = !0,
- this.altitudeAxis
- }
- qh.prototype = {
- constructor: qh,
- type: "geo3D",
- dimensions: ["lng", "lat", "alt"],
- containPoint: function () { },
- loadGeoJson: function (e, t, r) {
- var n = i.parseGeoJSON || i.parseGeoJson;
- try {
- this.regions = e ? n(e) : []
- } catch (e) {
- throw "Invalid geoJson format\n" + e
- }
- t = t || {},
- r = r || {};
- for (var a = this.regions, o = {}, s = 0; s < a.length; s++) {
- var l = a[s].name;
- l = r[l] || l,
- a[s].name = l,
- o[l] = a[s],
- this.addGeoCoord(l, a[s].getCenter());
- var h = t[l];
- h && a[s].transformTo(h.left, h.top, h.width, h.height)
- }
- this._regionsMap = o,
- this._geoRect = null,
- Xh.forEach((function (e) {
- e(this)
- }
- ), this)
- },
- getGeoBoundingRect: function () {
- if (this._geoRect)
- return this._geoRect;
- for (var e, t = this.regions, r = 0; r < t.length; r++) {
- var n = t[r].getBoundingRect();
- (e = e || n.clone()).union(n)
- }
- return this._geoRect = e || new i.graphic.BoundingRect(0, 0, 0, 0)
- },
- addGeoCoord: function (e, t) {
- this._nameCoordMap[e] = t
- },
- getRegion: function (e) {
- return this._regionsMap[e]
- },
- getRegionByCoord: function (e) {
- for (var t = this.regions, r = 0; r < t.length; r++)
- if (t[r].contain(e))
- return t[r]
- },
- setSize: function (e, t, r) {
- this.size = [e, t, r];
- var i = this.getGeoBoundingRect()
- , n = e / i.width
- , a = -r / i.height
- , o = -e / 2 - i.x * n
- , s = r / 2 - i.y * a
- , l = this.extrudeY ? [o, 0, s] : [o, s, 0]
- , h = this.extrudeY ? [n, 1, a] : [n, a, 1]
- , u = this.transform;
- jh.identity(u),
- jh.translate(u, u, l),
- jh.scale(u, u, h),
- jh.invert(this.invTransform, u)
- },
- dataToPoint: function (e, t) {
- t = t || [];
- var r = this.extrudeY ? 1 : 2
- , i = this.extrudeY ? 2 : 1
- , n = e[2];
- return isNaN(n) && (n = 0),
- t[0] = e[0],
- t[i] = e[1],
- this.altitudeAxis ? t[r] = this.altitudeAxis.dataToCoord(n) : t[r] = 0,
- t[r] += this.regionHeight,
- Wh.transformMat4(t, t, this.transform),
- t
- },
- pointToData: function (e, t) { }
- };
- const Zh = qh;
- function Yh(e, t) {
- var r = Ss(e.getBoxLayoutParams(), {
- width: t.getWidth(),
- height: t.getHeight()
- });
- r.y = t.getHeight() - r.y - r.height,
- this.viewGL.setViewport(r.x, r.y, r.width, r.height, t.getDevicePixelRatio());
- var i = this.getGeoBoundingRect()
- , n = i.width / i.height * (e.get("aspectScale") || .75)
- , a = e.get("boxWidth")
- , o = e.get("boxDepth")
- , s = e.get("boxHeight");
- null == s && (s = 5),
- isNaN(a) && isNaN(o) && (a = 100),
- isNaN(o) ? o = a / n : isNaN(a) && (a = o / n),
- this.setSize(a, s, o),
- this.regionHeight = e.get("regionHeight"),
- this.altitudeAxis && this.altitudeAxis.setExtent(0, Math.max(s - this.regionHeight, 0))
- }
- function Kh(e, t) {
- var r = [1 / 0, -1 / 0];
- if (e.eachSeries((function (e) {
- if (e.coordinateSystem === this && "series.map3D" !== e.type) {
- var t = e.getData()
- , i = e.coordDimToDataDim("alt")
- , n = i && i[0];
- if (n) {
- var a = t.getDataExtent(n, !0);
- r[0] = Math.min(r[0], a[0]),
- r[1] = Math.max(r[1], a[1])
- }
- }
- }
- ), this),
- r && isFinite(r[1] - r[0])) {
- var n = i.helper.createScale(r, {
- type: "value",
- min: "dataMin",
- max: "dataMax"
- });
- this.altitudeAxis = new i.Axis("altitude", n),
- this.resize(this.model, t)
- }
- }
- var Qh = 0
- , Jh = {
- dimensions: Zh.prototype.dimensions,
- create: function (e, t) {
- var r = [];
- if (!i.getMap)
- throw new Error("geo3D component depends on geo component");
- function n(e, i) {
- var n = Jh.createGeo3D(e);
- e.__viewGL = e.__viewGL || new Il,
- n.viewGL = e.__viewGL,
- e.coordinateSystem = n,
- n.model = e,
- r.push(n),
- n.resize = Yh,
- n.resize(e, t),
- n.update = Kh
- }
- return e.eachComponent("geo3D", (function (e, t) {
- n(e)
- }
- )),
- e.eachSeriesByType("map3D", (function (e, t) {
- var r = e.get("coordinateSystem");
- null == r && (r = "geo3D"),
- "geo3D" === r && n(e)
- }
- )),
- e.eachSeries((function (t) {
- if ("geo3D" === t.get("coordinateSystem")) {
- if ("series.map3D" === t.type)
- return;
- var r = t.getReferringComponents("geo3D").models[0];
- if (r || (r = e.getComponent("geo3D")),
- !r)
- throw new Error('geo "' + Mn(t.get("geo3DIndex"), t.get("geo3DId"), 0) + '" not found');
- t.coordinateSystem = r.coordinateSystem
- }
- }
- )),
- r
- },
- createGeo3D: function (e) {
- var t, r = e.get("map");
- return "string" == typeof r ? (t = r,
- r = i.getMap(r)) : r && r.features && (r = {
- geoJson: r
- }),
- null == t && (t = "GEO_ANONYMOUS_" + Qh++),
- new Zh(t + Qh++, t, r && r.geoJson, r && r.specialAreas, e.get("nameMap"))
- }
- };
- const $h = Jh;
- function eu(e) {
- e.registerComponentModel($l),
- e.registerComponentView(kh),
- e.registerAction({
- type: "geo3DChangeCamera",
- event: "geo3dcamerachanged",
- update: "series:updateCamera"
- }, (function (e, t) {
- t.eachComponent({
- mainType: "geo3D",
- query: e
- }, (function (t) {
- t.setView(e)
- }
- ))
- }
- )),
- e.registerCoordinateSystem("geo3D", $h)
- }
- function tu(e, t) {
- e.id = e.id || e.name || t + ""
- }
- (0,
- i.use)(eu);
- var ru = i.ComponentModel.extend({
- type: "globe",
- layoutMode: "box",
- coordinateSystem: null,
- init: function () {
- ru.superApply(this, "init", arguments),
- i.util.each(this.option.layers, (function (e, t) {
- i.util.merge(e, this.defaultLayerOption),
- tu(e, t)
- }
- ), this)
- },
- mergeOption: function (e) {
- var t = this.option.layers;
- function r(e) {
- return i.util.reduce(e, (function (e, t, r) {
- return tu(t, r),
- e[t.id] = t,
- e
- }
- ), {})
- }
- if (this.option.layers = null,
- ru.superApply(this, "mergeOption", arguments),
- t && t.length) {
- var n = r(e.layers)
- , a = r(t);
- for (var o in n)
- a[o] ? i.util.merge(a[o], n[o], !0) : t.push(e.layers[o]);
- this.option.layers = t
- }
- i.util.each(this.option.layers, (function (e) {
- i.util.merge(e, this.defaultLayerOption)
- }
- ), this)
- },
- optionUpdated: function () {
- this.updateDisplacementHash()
- },
- defaultLayerOption: {
- show: !0,
- type: "overlay"
- },
- defaultOption: {
- show: !0,
- zlevel: -10,
- left: 0,
- top: 0,
- width: "100%",
- height: "100%",
- environment: "auto",
- baseColor: "#fff",
- baseTexture: "",
- heightTexture: "",
- displacementTexture: "",
- displacementScale: 0,
- displacementQuality: "medium",
- globeRadius: 100,
- globeOuterRadius: 150,
- shading: "lambert",
- light: {
- main: {
- time: ""
- }
- },
- atmosphere: {
- show: !1,
- offset: 5,
- color: "#ffffff",
- glowPower: 6,
- innerGlowPower: 2
- },
- viewControl: {
- autoRotate: !0,
- panSensitivity: 0,
- targetCoord: null
- },
- layers: []
- },
- setDisplacementData: function (e, t, r) {
- this.displacementData = e,
- this.displacementWidth = t,
- this.displacementHeight = r
- },
- getDisplacementTexture: function () {
- return this.get("displacementTexture") || this.get("heightTexture")
- },
- getDisplacemenScale: function () {
- var e = this.getDisplacementTexture()
- , t = this.get("displacementScale");
- return e && "none" !== e || (t = 0),
- t
- },
- hasDisplacement: function () {
- return this.getDisplacemenScale() > 0
- },
- _displacementChanged: !0,
- _displacementScale: 0,
- updateDisplacementHash: function () {
- var e = this.getDisplacementTexture()
- , t = this.getDisplacemenScale();
- this._displacementChanged = this._displacementTexture !== e || this._displacementScale !== t,
- this._displacementTexture = e,
- this._displacementScale = t
- },
- isDisplacementChanged: function () {
- return this._displacementChanged
- }
- });
- i.util.merge(ru.prototype, uo),
- i.util.merge(ru.prototype, co),
- i.util.merge(ru.prototype, fo),
- i.util.merge(ru.prototype, Kl);
- const iu = ru;
- var nu = Math.PI
- , au = Math.sin
- , ou = Math.cos
- , su = Math.tan
- , lu = Math.asin
- , hu = Math.atan2
- , uu = nu / 180
- , cu = 23.4397 * uu;
- function du(e, t) {
- return hu(au(e) * ou(cu) - su(t) * au(cu), ou(e))
- }
- function fu(e, t, r) {
- return hu(au(e), ou(e) * au(t) - su(r) * ou(t))
- }
- function pu(e, t, r) {
- return lu(au(t) * au(r) + ou(t) * ou(r) * ou(e))
- }
- var mu = {};
- mu.getPosition = function (e, t, r) {
- var i = uu * -r
- , n = uu * t
- , a = function (e) {
- return function (e) {
- return e.valueOf() / 864e5 - .5 + 2440588
- }(e) - 2451545
- }(e)
- , o = function (e) {
- var t, r, i = (r = function (e) {
- return uu * (357.5291 + .98560028 * e)
- }(e)) + uu * (1.9148 * au(r) + .02 * au(2 * r) + 3e-4 * au(3 * r)) + 102.9372 * uu + nu;
- return {
- dec: (t = i,
- lu(au(0) * ou(cu) + ou(0) * au(cu) * au(t))),
- ra: du(i, 0)
- }
- }(a)
- , s = function (e, t) {
- return uu * (280.16 + 360.9856235 * e) - t
- }(a, i) - o.ra;
- return {
- azimuth: fu(s, n, o.dec),
- altitude: pu(s, n, o.dec)
- }
- }
- ;
- const gu = mu;
- Ka.Shader.import(Va),
- Ka.Shader.import("@export ecgl.atmosphere.vertex\nattribute vec3 position: POSITION;\nattribute vec3 normal : NORMAL;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 normalMatrix : WORLDINVERSETRANSPOSE;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n v_Normal = normalize((normalMatrix * vec4(normal, 0.0)).xyz);\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n\n\n@export ecgl.atmosphere.fragment\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform float glowPower;\nuniform vec3 glowColor;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n float intensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor = vec4(glowColor, intensity * intensity);\n}\n@end");
- const _u = i.ComponentView.extend({
- type: "globe",
- __ecgl__: !0,
- _displacementScale: 0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this._sphereGeometry = new Ka.SphereGeometry({
- widthSegments: 200,
- heightSegments: 100,
- dynamic: !0
- }),
- this._overlayGeometry = new Ka.SphereGeometry({
- widthSegments: 80,
- heightSegments: 40
- }),
- this._planeGeometry = new Ka.PlaneGeometry,
- this._earthMesh = new Ka.Mesh({
- renderNormal: !0
- }),
- this._atmosphereMesh = new Ka.Mesh,
- this._atmosphereGeometry = new Ka.SphereGeometry({
- widthSegments: 80,
- heightSegments: 40
- }),
- this._atmosphereMaterial = new Ka.Material({
- shader: new Ka.Shader(Ka.Shader.source("ecgl.atmosphere.vertex"), Ka.Shader.source("ecgl.atmosphere.fragment")),
- transparent: !0
- }),
- this._atmosphereMesh.geometry = this._atmosphereGeometry,
- this._atmosphereMesh.material = this._atmosphereMaterial,
- this._atmosphereMesh.frontFace = Ka.Mesh.CW,
- this._lightRoot = new Ka.Node,
- this._sceneHelper = new Uo,
- this._sceneHelper.initLight(this._lightRoot),
- this.groupGL.add(this._atmosphereMesh),
- this.groupGL.add(this._earthMesh),
- this._control = new Do({
- zr: t.getZr()
- }),
- this._control.init(),
- this._layerMeshes = {}
- },
- render: function (e, t, r) {
- var i = e.coordinateSystem
- , n = e.get("shading");
- i.viewGL.add(this._lightRoot),
- e.get("show") ? i.viewGL.add(this.groupGL) : i.viewGL.remove(this.groupGL),
- this._sceneHelper.setScene(i.viewGL.scene),
- i.viewGL.setPostEffect(e.getModel("postEffect"), r),
- i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));
- var a = this._earthMesh;
- a.geometry = this._sphereGeometry;
- var o = "ecgl." + n;
- a.material && a.material.shader.name === o || (a.material = Ka.createMaterial(o)),
- Ka.setMaterialFromModel(n, a.material, e, r),
- ["roughnessMap", "metalnessMap", "detailMap", "normalMap"].forEach((function (e) {
- var t = a.material.get(e);
- t && (t.flipY = !1)
- }
- )),
- a.material.set("color", Ka.parseColor(e.get("baseColor")));
- var s = .99 * i.radius;
- if (a.scale.set(s, s, s),
- e.get("atmosphere.show")) {
- a.material.define("both", "ATMOSPHERE_ENABLED"),
- this._atmosphereMesh.invisible = !1,
- this._atmosphereMaterial.setUniforms({
- glowPower: e.get("atmosphere.glowPower") || 6,
- glowColor: e.get("atmosphere.color") || "#ffffff"
- }),
- a.material.setUniforms({
- glowPower: e.get("atmosphere.innerGlowPower") || 2,
- glowColor: e.get("atmosphere.color") || "#ffffff"
- });
- var l = e.get("atmosphere.offset") || 5;
- this._atmosphereMesh.scale.set(s + l, s + l, s + l)
- } else
- a.material.undefine("both", "ATMOSPHERE_ENABLED"),
- this._atmosphereMesh.invisible = !0;
- var h = a.material.setTextureImage("diffuseMap", e.get("baseTexture"), r, {
- flipY: !1,
- anisotropic: 8
- });
- h && h.surface && h.surface.attachToMesh(a);
- var u = a.material.setTextureImage("bumpMap", e.get("heightTexture"), r, {
- flipY: !1,
- anisotropic: 8
- });
- u && u.surface && u.surface.attachToMesh(a),
- a.material[e.get("postEffect.enable") ? "define" : "undefine"]("fragment", "SRGB_DECODE"),
- this._updateLight(e, r),
- this._displaceVertices(e, r),
- this._updateViewControl(e, r),
- this._updateLayers(e, r)
- },
- afterRender: function (e, t, r, i) {
- var n = i.renderer;
- this._sceneHelper.updateAmbientCubemap(n, e, r),
- this._sceneHelper.updateSkybox(n, e, r)
- },
- _updateLayers: function (e, t) {
- var r = e.coordinateSystem
- , n = e.get("layers")
- , a = r.radius
- , o = []
- , s = []
- , l = []
- , h = [];
- i.util.each(n, (function (e) {
- var n = new i.Model(e)
- , u = n.get("type")
- , c = Ka.loadTexture(n.get("texture"), t, {
- flipY: !1,
- anisotropic: 8
- });
- if (c.surface && c.surface.attachToMesh(this._earthMesh),
- "blend" === u) {
- var d = n.get("blendTo")
- , f = Mn(n.get("intensity"), 1);
- "emission" === d ? (l.push(c),
- h.push(f)) : (o.push(c),
- s.push(f))
- } else {
- var p = n.get("id")
- , m = this._layerMeshes[p];
- m || (m = this._layerMeshes[p] = new Ka.Mesh({
- geometry: this._overlayGeometry,
- castShadow: !1,
- ignorePicking: !0
- })),
- "lambert" === n.get("shading") ? (m.material = m.__lambertMaterial || new Ka.Material({
- autoUpdateTextureStatus: !1,
- shader: Ka.createShader("ecgl.lambert"),
- transparent: !0,
- depthMask: !1
- }),
- m.__lambertMaterial = m.material) : (m.material = m.__colorMaterial || new Ka.Material({
- autoUpdateTextureStatus: !1,
- shader: Ka.createShader("ecgl.color"),
- transparent: !0,
- depthMask: !1
- }),
- m.__colorMaterial = m.material),
- m.material.enableTexture("diffuseMap");
- var g = n.get("distance")
- , _ = a + (null == g ? r.radius / 100 : g);
- m.scale.set(_, _, _),
- a = _;
- var v = this._blankTexture || (this._blankTexture = Ka.createBlankTexture("rgba(255, 255, 255, 0)"));
- m.material.set("diffuseMap", v),
- Ka.loadTexture(n.get("texture"), t, {
- flipY: !1,
- anisotropic: 8
- }, (function (e) {
- e.surface && e.surface.attachToMesh(m),
- m.material.set("diffuseMap", e),
- t.getZr().refresh()
- }
- )),
- n.get("show") ? this.groupGL.add(m) : this.groupGL.remove(m)
- }
- }
- ), this);
- var u = this._earthMesh.material;
- u.define("fragment", "LAYER_DIFFUSEMAP_COUNT", o.length),
- u.define("fragment", "LAYER_EMISSIVEMAP_COUNT", l.length),
- u.set("layerDiffuseMap", o),
- u.set("layerDiffuseIntensity", s),
- u.set("layerEmissiveMap", l),
- u.set("layerEmissionIntensity", h);
- var c = e.getModel("debug.wireframe");
- if (c.get("show")) {
- u.define("both", "WIREFRAME_TRIANGLE");
- var d = Ka.parseColor(c.get("lineStyle.color") || "rgba(0,0,0,0.5)")
- , f = Mn(c.get("lineStyle.width"), 1);
- u.set("wireframeLineWidth", f),
- u.set("wireframeLineColor", d)
- } else
- u.undefine("both", "WIREFRAME_TRIANGLE")
- },
- _updateViewControl: function (e, t) {
- var r = e.coordinateSystem
- , i = e.getModel("viewControl")
- , n = (r.viewGL.camera,
- this)
- , a = this._control;
- a.setViewGL(r.viewGL);
- var o, s, l = i.get("targetCoord");
- null != l && (s = l[0] + 90,
- o = l[1]),
- a.setFromViewControlModel(i, {
- baseDistance: r.radius,
- alpha: o,
- beta: s
- }),
- a.off("update"),
- a.on("update", (function () {
- t.dispatchAction({
- type: "globeChangeCamera",
- alpha: a.getAlpha(),
- beta: a.getBeta(),
- distance: a.getDistance() - r.radius,
- center: a.getCenter(),
- from: n.uid,
- globeId: e.id
- })
- }
- ))
- },
- _displaceVertices: function (e, t) {
- var r = e.get("displacementQuality")
- , i = e.get("debug.wireframe.show")
- , n = e.coordinateSystem;
- if (e.isDisplacementChanged() || r !== this._displacementQuality || i !== this._showDebugWireframe) {
- this._displacementQuality = r,
- this._showDebugWireframe = i;
- var a = this._sphereGeometry
- , o = {
- low: 100,
- medium: 200,
- high: 400,
- ultra: 800
- }[r] || 200
- , s = o / 2;
- (a.widthSegments !== o || i) && (a.widthSegments = o,
- a.heightSegments = s,
- a.build()),
- this._doDisplaceVertices(a, n),
- i && a.generateBarycentric()
- }
- },
- _doDisplaceVertices: function (e, t) {
- var r = e.attributes.position.value
- , i = e.attributes.texcoord0.value
- , n = e.__originalPosition;
- n && n.length === r.length || ((n = new Float32Array(r.length)).set(r),
- e.__originalPosition = n);
- for (var a = t.displacementWidth, o = t.displacementHeight, s = t.displacementData, l = 0; l < e.vertexCount; l++) {
- var h = 3 * l
- , u = 2 * l
- , c = n[h + 1]
- , d = n[h + 2]
- , f = n[h + 3]
- , p = i[u++]
- , m = i[u++]
- , g = Math.round(p * (a - 1))
- , _ = Math.round(m * (o - 1))
- , v = s ? s[_ * a + g] : 0;
- r[h + 1] = c + c * v,
- r[h + 2] = d + d * v,
- r[h + 3] = f + f * v
- }
- e.generateVertexNormals(),
- e.dirty(),
- e.updateBoundingBox()
- },
- _updateLight: function (e, t) {
- var r = this._earthMesh;
- this._sceneHelper.updateLight(e);
- var n = this._sceneHelper.mainLight
- , a = e.get("light.main.time") || new Date
- , o = gu.getPosition(i.number.parseDate(a), 0, 0)
- , s = Math.cos(o.altitude);
- n.position.y = -s * Math.cos(o.azimuth),
- n.position.x = Math.sin(o.altitude),
- n.position.z = s * Math.sin(o.azimuth),
- n.lookAt(r.getWorldPosition())
- },
- dispose: function (e, t) {
- this.groupGL.removeAll(),
- this._control.dispose()
- }
- });
- var vu = Po.vec3;
- function yu(e) {
- this.radius = e,
- this.viewGL = null,
- this.altitudeAxis,
- this.displacementData = null,
- this.displacementWidth,
- this.displacementHeight
- }
- yu.prototype = {
- constructor: yu,
- dimensions: ["lng", "lat", "alt"],
- type: "globe",
- containPoint: function () { },
- setDisplacementData: function (e, t, r) {
- this.displacementData = e,
- this.displacementWidth = t,
- this.displacementHeight = r
- },
- _getDisplacementScale: function (e, t) {
- var r = (e + 180) / 360 * (this.displacementWidth - 1)
- , i = (90 - t) / 180 * (this.displacementHeight - 1)
- , n = Math.round(r) + Math.round(i) * this.displacementWidth;
- return this.displacementData[n]
- },
- dataToPoint: function (e, t) {
- var r = e[0]
- , i = e[1]
- , n = e[2] || 0
- , a = this.radius;
- this.displacementData && (a *= 1 + this._getDisplacementScale(r, i)),
- this.altitudeAxis && (a += this.altitudeAxis.dataToCoord(n)),
- r = r * Math.PI / 180,
- i = i * Math.PI / 180;
- var o = Math.cos(i) * a;
- return (t = t || [])[0] = -o * Math.cos(r + Math.PI),
- t[1] = Math.sin(i) * a,
- t[2] = o * Math.sin(r + Math.PI),
- t
- },
- pointToData: function (e, t) {
- var r = e[0]
- , i = e[1]
- , n = e[2]
- , a = vu.len(e);
- r /= a,
- i /= a,
- n /= a;
- var o = Math.asin(i)
- , s = Math.atan2(n, -r);
- s < 0 && (s = 2 * Math.PI + s);
- var l = 180 * o / Math.PI
- , h = 180 * s / Math.PI - 180;
- return (t = t || [])[0] = h,
- t[1] = l,
- t[2] = a - this.radius,
- this.altitudeAxis && (t[2] = this.altitudeAxis.coordToData(t[2])),
- t
- }
- };
- const xu = yu;
- function bu(e, t) {
- var r = Ss(e.getBoxLayoutParams(), {
- width: t.getWidth(),
- height: t.getHeight()
- });
- r.y = t.getHeight() - r.y - r.height,
- this.viewGL.setViewport(r.x, r.y, r.width, r.height, t.getDevicePixelRatio()),
- this.radius = e.get("globeRadius");
- var i = e.get("globeOuterRadius");
- this.altitudeAxis && this.altitudeAxis.setExtent(0, i - this.radius)
- }
- function wu(e, t) {
- var r = [1 / 0, -1 / 0];
- if (e.eachSeries((function (e) {
- if (e.coordinateSystem === this) {
- var t = e.getData()
- , i = e.coordDimToDataDim("alt")
- , n = i && i[0];
- if (n) {
- var a = t.getDataExtent(n, !0);
- r[0] = Math.min(r[0], a[0]),
- r[1] = Math.max(r[1], a[1])
- }
- }
- }
- ), this),
- r && isFinite(r[1] - r[0])) {
- var n = i.helper.createScale(r, {
- type: "value",
- min: "dataMin",
- max: "dataMax"
- });
- this.altitudeAxis = new i.Axis("altitude", n),
- this.resize(this.model, t)
- }
- }
- const Tu = {
- dimensions: xu.prototype.dimensions,
- create: function (e, t) {
- var r = [];
- return e.eachComponent("globe", (function (e) {
- e.__viewGL = e.__viewGL || new Il;
- var i = new xu;
- i.viewGL = e.__viewGL,
- e.coordinateSystem = i,
- i.model = e,
- r.push(i),
- i.resize = bu,
- i.resize(e, t),
- i.update = wu
- }
- )),
- e.eachSeries((function (t) {
- if ("globe" === t.get("coordinateSystem")) {
- var r = t.getReferringComponents("globe").models[0];
- if (r || (r = e.getComponent("globe")),
- !r)
- throw new Error('globe "' + Mn(t.get("globe3DIndex"), t.get("globe3DId"), 0) + '" not found');
- var i = r.coordinateSystem;
- t.coordinateSystem = i
- }
- }
- )),
- e.eachComponent("globe", (function (e, r) {
- var i = e.coordinateSystem
- , n = e.getDisplacementTexture()
- , a = e.getDisplacemenScale();
- if (e.isDisplacementChanged()) {
- if (e.hasDisplacement()) {
- var o = !0;
- Ka.loadTexture(n, t, (function (r) {
- var i = function (e, t) {
- var r = document.createElement("canvas")
- , i = r.getContext("2d")
- , n = e.width
- , a = e.height;
- r.width = n,
- r.height = a,
- i.drawImage(e, 0, 0, n, a);
- for (var o = i.getImageData(0, 0, n, a).data, s = new Float32Array(o.length / 4), l = 0; l < o.length / 4; l++) {
- var h = o[4 * l];
- s[l] = h / 255 * t
- }
- return {
- data: s,
- width: n,
- height: a
- }
- }(r.image, a);
- e.setDisplacementData(i.data, i.width, i.height),
- o || t.dispatchAction({
- type: "globeUpdateDisplacment"
- })
- }
- )),
- o = !1
- } else
- i.setDisplacementData(null, 0, 0);
- i.setDisplacementData(e.displacementData, e.displacementWidth, e.displacementHeight)
- }
- }
- )),
- r
- }
- };
- (0,
- i.use)((function (e) {
- e.registerComponentModel(iu),
- e.registerComponentView(_u),
- e.registerCoordinateSystem("globe", Tu),
- e.registerAction({
- type: "globeChangeCamera",
- event: "globecamerachanged",
- update: "series:updateCamera"
- }, (function (e, t) {
- t.eachComponent({
- mainType: "globe",
- query: e
- }, (function (t) {
- t.setView(e)
- }
- ))
- }
- )),
- e.registerAction({
- type: "globeUpdateDisplacment",
- event: "globedisplacementupdated",
- update: "update"
- }, (function (e, t) { }
- ))
- }
- ));
- var Su = ["zoom", "center", "pitch", "bearing"]
- , Mu = i.ComponentModel.extend({
- type: "mapbox3D",
- layoutMode: "box",
- coordinateSystem: null,
- defaultOption: {
- zlevel: -10,
- style: "mapbox://styles/mapbox/light-v9",
- center: [0, 0],
- zoom: 0,
- pitch: 0,
- bearing: 0,
- light: {
- main: {
- alpha: 20,
- beta: 30
- }
- },
- altitudeScale: 1,
- boxHeight: "auto"
- },
- getMapboxCameraOption: function () {
- var e = this;
- return Su.reduce((function (t, r) {
- return t[r] = e.get(r),
- t
- }
- ), {})
- },
- setMapboxCameraOption: function (e) {
- null != e && Su.forEach((function (t) {
- null != e[t] && (this.option[t] = e[t])
- }
- ), this)
- },
- getMapbox: function () {
- return this._mapbox
- },
- setMapbox: function (e) {
- this._mapbox = e
- }
- });
- i.util.merge(Mu.prototype, co),
- i.util.merge(Mu.prototype, fo);
- const Au = Mu;
- function Eu(e, t) {
- if (this.id = e,
- this.zr = t,
- this.dom = document.createElement("div"),
- this.dom.style.cssText = "position:absolute;left:0;right:0;top:0;bottom:0;",
- !mapboxgl)
- throw new Error("Mapbox GL library must be included. See https://www.mapbox.com/mapbox-gl-js/api/");
- this._mapbox = new mapboxgl.Map({
- container: this.dom
- }),
- this._initEvents()
- }
- Eu.prototype.setUnpainted = function () { }
- ,
- Eu.prototype.resize = function () {
- this._mapbox.resize()
- }
- ,
- Eu.prototype.getMapbox = function () {
- return this._mapbox
- }
- ,
- Eu.prototype.clear = function () { }
- ,
- Eu.prototype.refresh = function () {
- this._mapbox.resize()
- }
- ;
- var Cu = ["mousedown", "mouseup", "click", "dblclick", "mousemove", "mousewheel", "wheel", "touchstart", "touchend", "touchmove", "touchcancel"];
- Eu.prototype._initEvents = function () {
- var e = this._mapbox.getCanvasContainer();
- this._handlers = this._handlers || {
- contextmenu: function (e) {
- return e.preventDefault(),
- !1
- }
- },
- Cu.forEach((function (t) {
- this._handlers[t] = function (t) {
- var r = {};
- for (var i in t)
- r[i] = t[i];
- r.bubbles = !1;
- var n = new t.constructor(t.type, r);
- e.dispatchEvent(n)
- }
- ,
- this.zr.dom.addEventListener(t, this._handlers[t])
- }
- ), this),
- this.zr.dom.addEventListener("contextmenu", this._handlers.contextmenu)
- }
- ,
- Eu.prototype.dispose = function () {
- Cu.forEach((function (e) {
- this.zr.dom.removeEventListener(e, this._handlers[e])
- }
- ), this)
- }
- ;
- const Du = Eu
- , Lu = "\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end";
- Ka.Shader.import(Lu);
- const Pu = i.ComponentView.extend({
- type: "mapbox3D",
- __ecgl__: !0,
- init: function (e, t) {
- var r = t.getZr();
- this._zrLayer = new Du("mapbox3D", r),
- r.painter.insertLayer(-1e3, this._zrLayer),
- this._lightRoot = new Ka.Node,
- this._sceneHelper = new Uo(this._lightRoot),
- this._sceneHelper.initLight(this._lightRoot);
- var i = this._zrLayer.getMapbox()
- , n = this._dispatchInteractAction.bind(this, t, i);
- ["zoom", "rotate", "drag", "pitch", "rotate", "move"].forEach((function (e) {
- i.on(e, n)
- }
- )),
- this._groundMesh = new Ka.Mesh({
- geometry: new Ka.PlaneGeometry,
- material: new Ka.Material({
- shader: new Ka.Shader({
- vertex: Ka.Shader.source("ecgl.displayShadow.vertex"),
- fragment: Ka.Shader.source("ecgl.displayShadow.fragment")
- }),
- depthMask: !1
- }),
- renderOrder: -100,
- culling: !1,
- castShadow: !1,
- $ignorePicking: !0,
- renderNormal: !0
- })
- },
- render: function (e, t, r) {
- var i = this._zrLayer.getMapbox()
- , n = e.get("style")
- , a = JSON.stringify(n);
- a !== this._oldStyleStr && n && i.setStyle(n),
- this._oldStyleStr = a,
- i.setCenter(e.get("center")),
- i.setZoom(e.get("zoom")),
- i.setPitch(e.get("pitch")),
- i.setBearing(e.get("bearing")),
- e.setMapbox(i);
- var o = e.coordinateSystem;
- o.viewGL.scene.add(this._lightRoot),
- o.viewGL.add(this._groundMesh),
- this._updateGroundMesh(),
- this._sceneHelper.setScene(o.viewGL.scene),
- this._sceneHelper.updateLight(e),
- o.viewGL.setPostEffect(e.getModel("postEffect"), r),
- o.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),
- this._mapbox3DModel = e
- },
- afterRender: function (e, t, r, i) {
- var n = i.renderer;
- this._sceneHelper.updateAmbientCubemap(n, e, r),
- this._sceneHelper.updateSkybox(n, e, r),
- e.coordinateSystem.viewGL.scene.traverse((function (e) {
- e.material && (e.material.define("fragment", "NORMAL_UP_AXIS", 2),
- e.material.define("fragment", "NORMAL_FRONT_AXIS", 1))
- }
- ))
- },
- updateCamera: function (e, t, r, i) {
- e.coordinateSystem.setCameraOption(i),
- this._updateGroundMesh(),
- r.getZr().refresh()
- },
- _dispatchInteractAction: function (e, t, r) {
- e.dispatchAction({
- type: "mapbox3DChangeCamera",
- pitch: t.getPitch(),
- zoom: t.getZoom(),
- center: t.getCenter().toArray(),
- bearing: t.getBearing(),
- mapbox3DId: this._mapbox3DModel && this._mapbox3DModel.id
- })
- },
- _updateGroundMesh: function () {
- if (this._mapbox3DModel) {
- var e = this._mapbox3DModel.coordinateSystem
- , t = e.dataToPoint(e.center);
- this._groundMesh.position.set(t[0], t[1], -.001);
- var r = new Ka.Plane(new Ka.Vector3(0, 0, 1), 0)
- , i = e.viewGL.camera.castRay(new Ka.Vector2(-1, -1))
- , n = e.viewGL.camera.castRay(new Ka.Vector2(1, 1))
- , a = i.intersectPlane(r)
- , o = n.intersectPlane(r)
- , s = a.dist(o) / e.viewGL.rootNode.scale.x;
- this._groundMesh.scale.set(s, s, 1)
- }
- },
- dispose: function (e, t) {
- this._zrLayer && this._zrLayer.dispose(),
- t.getZr().painter.delLayer(-1e3)
- }
- });
- var Ou = Po.mat4
- , Nu = 512
- , Iu = .6435011087932844
- , Ru = Math.PI
- , Bu = .1;
- function Fu() {
- this.width = 0,
- this.height = 0,
- this.altitudeScale = 1,
- this.boxHeight = "auto",
- this.altitudeExtent,
- this.bearing = 0,
- this.pitch = 0,
- this.center = [0, 0],
- this._origin,
- this.zoom = 0,
- this._initialZoom,
- this.maxPitch = 60,
- this.zoomOffset = 0
- }
- Fu.prototype = {
- constructor: Fu,
- dimensions: ["lng", "lat", "alt"],
- containPoint: function () { },
- setCameraOption: function (e) {
- this.bearing = e.bearing,
- this.pitch = e.pitch,
- this.center = e.center,
- this.zoom = e.zoom,
- this._origin || (this._origin = this.projectOnTileWithScale(this.center, Nu)),
- null == this._initialZoom && (this._initialZoom = this.zoom),
- this.updateTransform()
- },
- updateTransform: function () {
- if (this.height) {
- var e = .5 / Math.tan(Iu / 2) * this.height * Bu
- , t = Math.max(Math.min(this.pitch, this.maxPitch), 0) / 180 * Math.PI
- , r = Iu / 2
- , i = Math.PI / 2 + t
- , n = Math.sin(r) * e / Math.sin(Math.PI - i - r)
- , a = 1.1 * (Math.cos(Math.PI / 2 - t) * n + e);
- this.pitch > 50 && (a = 1e3);
- var o = [];
- Ou.perspective(o, Iu, this.width / this.height, 1, a),
- this.viewGL.camera.projectionMatrix.setArray(o),
- this.viewGL.camera.decomposeProjectionMatrix(),
- o = Ou.identity([]);
- var s = this.dataToPoint(this.center);
- Ou.scale(o, o, [1, -1, 1]),
- Ou.translate(o, o, [0, 0, -e]),
- Ou.rotateX(o, o, t),
- Ou.rotateZ(o, o, -this.bearing / 180 * Math.PI),
- Ou.translate(o, o, [-s[0] * this.getScale() * Bu, -s[1] * this.getScale() * Bu, 0]),
- this.viewGL.camera.viewMatrix.array = o;
- var l = [];
- Ou.invert(l, o),
- this.viewGL.camera.worldTransform.array = l,
- this.viewGL.camera.decomposeWorldTransform();
- var h, u = Nu * this.getScale();
- if (this.altitudeExtent && !isNaN(this.boxHeight)) {
- var c = this.altitudeExtent[1] - this.altitudeExtent[0];
- h = this.boxHeight / c * this.getScale() / Math.pow(2, this._initialZoom - this.zoomOffset)
- } else
- h = u / (2 * Math.PI * 6378e3 * Math.abs(Math.cos(this.center[1] * (Math.PI / 180)))) * this.altitudeScale * Bu;
- this.viewGL.rootNode.scale.set(this.getScale() * Bu, this.getScale() * Bu, h)
- }
- },
- getScale: function () {
- return Math.pow(2, this.zoom - this.zoomOffset)
- },
- projectOnTile: function (e, t) {
- return this.projectOnTileWithScale(e, this.getScale() * Nu, t)
- },
- projectOnTileWithScale: function (e, t, r) {
- var i = e[0]
- , n = e[1] * Ru / 180
- , a = t * (i * Ru / 180 + Ru) / (2 * Ru)
- , o = t * (Ru - Math.log(Math.tan(Ru / 4 + .5 * n))) / (2 * Ru);
- return (r = r || [])[0] = a,
- r[1] = o,
- r
- },
- unprojectFromTile: function (e, t) {
- return this.unprojectOnTileWithScale(e, this.getScale() * Nu, t)
- },
- unprojectOnTileWithScale: function (e, t, r) {
- var i = e[0]
- , n = e[1]
- , a = i / t * (2 * Ru) - Ru
- , o = 2 * (Math.atan(Math.exp(Ru - n / t * (2 * Ru))) - Ru / 4);
- return (r = r || [])[0] = 180 * a / Ru,
- r[1] = 180 * o / Ru,
- r
- },
- dataToPoint: function (e, t) {
- return (t = this.projectOnTileWithScale(e, Nu, t))[0] -= this._origin[0],
- t[1] -= this._origin[1],
- t[2] = isNaN(e[2]) ? 0 : e[2],
- isNaN(e[2]) || (t[2] = e[2],
- this.altitudeExtent && (t[2] -= this.altitudeExtent[0])),
- t
- }
- };
- const zu = Fu;
- function Gu() {
- zu.apply(this, arguments)
- }
- function Uu(e, t, r) {
- function i(e, t) {
- var r = t.getWidth()
- , i = t.getHeight()
- , n = t.getDevicePixelRatio();
- this.viewGL.setViewport(0, 0, r, i, n),
- this.width = r,
- this.height = i,
- this.altitudeScale = e.get("altitudeScale"),
- this.boxHeight = e.get("boxHeight")
- }
- function n(e, t) {
- if ("auto" !== this.model.get("boxHeight")) {
- var r = [1 / 0, -1 / 0];
- e.eachSeries((function (e) {
- if (e.coordinateSystem === this) {
- var t = e.getData()
- , i = e.coordDimToDataDim("alt")[0];
- if (i) {
- var n = t.getDataExtent(i, !0);
- r[0] = Math.min(r[0], n[0]),
- r[1] = Math.max(r[1], n[1])
- }
- }
- }
- ), this),
- r && isFinite(r[1] - r[0]) && (this.altitudeExtent = r)
- }
- }
- return {
- dimensions: t.prototype.dimensions,
- create: function (a, o) {
- var s = [];
- return a.eachComponent(e, (function (e) {
- var r = e.__viewGL;
- r || (r = e.__viewGL = new Il).setRootNode(new Ka.Node);
- var a = new t;
- a.viewGL = e.__viewGL,
- a.resize = i,
- a.resize(e, o),
- s.push(a),
- e.coordinateSystem = a,
- a.model = e,
- a.update = n
- }
- )),
- a.eachSeries((function (t) {
- if (t.get("coordinateSystem") === e) {
- var r = t.getReferringComponents(e).models[0];
- if (r || (r = a.getComponent(e)),
- !r)
- throw new Error(e + ' "' + Mn(t.get(e + "Index"), t.get(e + "Id"), 0) + '" not found');
- t.coordinateSystem = r.coordinateSystem
- }
- }
- )),
- r && r(s, a, o),
- s
- }
- }
- }
- Gu.prototype = new zu,
- Gu.prototype.constructor = Gu,
- Gu.prototype.type = "mapbox3D";
- const ku = Uu("mapbox3D", Gu, (function (e) {
- e.forEach((function (e) {
- e.setCameraOption(e.model.getMapboxCameraOption())
- }
- ))
- }
- ));
- (0,
- i.use)((function (e) {
- e.registerComponentModel(Au),
- e.registerComponentView(Pu),
- e.registerCoordinateSystem("mapbox3D", ku),
- e.registerAction({
- type: "mapbox3DChangeCamera",
- event: "mapbox3dcamerachanged",
- update: "mapbox3D:updateCamera"
- }, (function (e, t) {
- t.eachComponent({
- mainType: "mapbox3D",
- query: e
- }, (function (t) {
- t.setMapboxCameraOption(e)
- }
- ))
- }
- ))
- }
- ));
- var Vu = ["zoom", "center", "pitch", "bearing"]
- , Hu = i.ComponentModel.extend({
- type: "maptalks3D",
- layoutMode: "box",
- coordinateSystem: null,
- defaultOption: {
- zlevel: -10,
- urlTemplate: "http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
- attribution: '© <a href="http://osm.org">OpenStreetMap</a> contributors, © <a href="https://carto.com/">CARTO</a>',
- center: [0, 0],
- zoom: 0,
- pitch: 0,
- bearing: 0,
- light: {
- main: {
- alpha: 20,
- beta: 30
- }
- },
- altitudeScale: 1,
- boxHeight: "auto"
- },
- getMaptalksCameraOption: function () {
- var e = this;
- return Vu.reduce((function (t, r) {
- return t[r] = e.get(r),
- t
- }
- ), {})
- },
- setMaptalksCameraOption: function (e) {
- null != e && Vu.forEach((function (t) {
- null != e[t] && (this.option[t] = e[t])
- }
- ), this)
- },
- getMaptalks: function () {
- return this._maptalks
- },
- setMaptalks: function (e) {
- this._maptalks = e
- }
- });
- i.util.merge(Hu.prototype, co),
- i.util.merge(Hu.prototype, fo);
- const Wu = Hu;
- function ju(e, t, r, i) {
- if (this.id = e,
- this.zr = t,
- this.dom = document.createElement("div"),
- this.dom.style.cssText = "position:absolute;left:0;right:0;top:0;bottom:0;",
- !maptalks)
- throw new Error("Maptalks library must be included. See https://maptalks.org");
- this._maptalks = new maptalks.Map(this.dom, {
- center: r,
- zoom: i,
- doubleClickZoom: !1,
- fog: !1
- }),
- this._initEvents()
- }
- ju.prototype.setUnpainted = function () { }
- ,
- ju.prototype.resize = function () {
- this._maptalks.checkSize()
- }
- ,
- ju.prototype.getMaptalks = function () {
- return this._maptalks
- }
- ,
- ju.prototype.clear = function () { }
- ,
- ju.prototype.refresh = function () {
- this._maptalks.checkSize()
- }
- ;
- var Xu = ["mousedown", "mouseup", "click", "dblclick", "mousemove", "mousewheel", "DOMMouseScroll", "touchstart", "touchend", "touchmove", "touchcancel"];
- ju.prototype._initEvents = function () {
- var e = this.dom;
- this._handlers = this._handlers || {
- contextmenu: function (e) {
- return e.preventDefault(),
- !1
- }
- },
- Xu.forEach((function (t) {
- this._handlers[t] = function (r) {
- var i = {};
- for (var n in r)
- i[n] = r[n];
- i.bubbles = !1;
- var a = new r.constructor(r.type, i);
- "mousewheel" === t || "DOMMouseScroll" === t ? e.dispatchEvent(a) : e.firstElementChild.dispatchEvent(a)
- }
- ,
- this.zr.dom.addEventListener(t, this._handlers[t])
- }
- ), this),
- this.zr.dom.addEventListener("contextmenu", this._handlers.contextmenu)
- }
- ,
- ju.prototype.dispose = function () {
- Xu.forEach((function (e) {
- this.zr.dom.removeEventListener(e, this._handlers[e])
- }
- ), this),
- this._maptalks.remove()
- }
- ;
- const qu = ju;
- Ka.Shader.import(Lu);
- const Zu = i.ComponentView.extend({
- type: "maptalks3D",
- __ecgl__: !0,
- init: function (e, t) {
- this._groundMesh = new Ka.Mesh({
- geometry: new Ka.PlaneGeometry,
- material: new Ka.Material({
- shader: new Ka.Shader({
- vertex: Ka.Shader.source("ecgl.displayShadow.vertex"),
- fragment: Ka.Shader.source("ecgl.displayShadow.fragment")
- }),
- depthMask: !1
- }),
- renderOrder: -100,
- culling: !1,
- castShadow: !1,
- $ignorePicking: !0,
- renderNormal: !0
- })
- },
- _initMaptalksLayer: function (e, t) {
- var r = t.getZr();
- this._zrLayer = new qu("maptalks3D", r, e.get("center"), e.get("zoom")),
- r.painter.insertLayer(-1e3, this._zrLayer),
- this._lightRoot = new Ka.Node,
- this._sceneHelper = new Uo(this._lightRoot),
- this._sceneHelper.initLight(this._lightRoot);
- var i = this._zrLayer.getMaptalks()
- , n = this._dispatchInteractAction.bind(this, t, i);
- ["zoomend", "zooming", "zoomstart", "dragrotating", "pitch", "pitchend", "movestart", "moving", "moveend", "resize", "touchstart", "touchmove", "touchend", "animating"].forEach((function (e) {
- i.on(e, n)
- }
- ))
- },
- render: function (e, t, r) {
- this._zrLayer || this._initMaptalksLayer(e, r);
- var i = this._zrLayer.getMaptalks()
- , n = e.get("urlTemplate")
- , a = i.getBaseLayer();
- n !== this._oldUrlTemplate && (a ? a.setOptions({
- urlTemplate: n,
- attribution: e.get("attribution")
- }) : (a = new maptalks.TileLayer("maptalks-echarts-gl-baselayer", {
- urlTemplate: n,
- subdomains: ["a", "b", "c"],
- attribution: e.get("attribution")
- }),
- i.setBaseLayer(a))),
- this._oldUrlTemplate = n,
- i.setCenter(e.get("center")),
- i.setZoom(e.get("zoom"), {
- animation: !1
- }),
- i.setPitch(e.get("pitch")),
- i.setBearing(e.get("bearing")),
- e.setMaptalks(i);
- var o = e.coordinateSystem;
- o.viewGL.scene.add(this._lightRoot),
- o.viewGL.add(this._groundMesh),
- this._updateGroundMesh(),
- this._sceneHelper.setScene(o.viewGL.scene),
- this._sceneHelper.updateLight(e),
- o.viewGL.setPostEffect(e.getModel("postEffect"), r),
- o.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),
- this._maptalks3DModel = e
- },
- afterRender: function (e, t, r, i) {
- var n = i.renderer;
- this._sceneHelper.updateAmbientCubemap(n, e, r),
- this._sceneHelper.updateSkybox(n, e, r),
- e.coordinateSystem.viewGL.scene.traverse((function (e) {
- e.material && (e.material.define("fragment", "NORMAL_UP_AXIS", 2),
- e.material.define("fragment", "NORMAL_FRONT_AXIS", 1))
- }
- ))
- },
- updateCamera: function (e, t, r, i) {
- e.coordinateSystem.setCameraOption(i),
- this._updateGroundMesh(),
- r.getZr().refresh()
- },
- _dispatchInteractAction: function (e, t, r) {
- var i;
- e.dispatchAction({
- type: "maptalks3DChangeCamera",
- pitch: t.getPitch(),
- zoom: (i = t.getResolution(),
- 19 - Math.log(i / Yu) / Math.LN2 + 1),
- center: t.getCenter().toArray(),
- bearing: t.getBearing(),
- maptalks3DId: this._maptalks3DModel && this._maptalks3DModel.id
- })
- },
- _updateGroundMesh: function () {
- if (this._maptalks3DModel) {
- var e = this._maptalks3DModel.coordinateSystem
- , t = e.dataToPoint(e.center);
- this._groundMesh.position.set(t[0], t[1], -.001);
- var r = new Ka.Plane(new Ka.Vector3(0, 0, 1), 0)
- , i = e.viewGL.camera.castRay(new Ka.Vector2(-1, -1))
- , n = e.viewGL.camera.castRay(new Ka.Vector2(1, 1))
- , a = i.intersectPlane(r)
- , o = n.intersectPlane(r)
- , s = a.dist(o) / e.viewGL.rootNode.scale.x;
- this._groundMesh.scale.set(s, s, 1)
- }
- },
- dispose: function (e, t) {
- this._zrLayer && this._zrLayer.dispose(),
- t.getZr().painter.delLayer(-1e3)
- }
- })
- , Yu = 12756274 * Math.PI / (256 * Math.pow(2, 20));
- function Ku() {
- zu.apply(this, arguments),
- this.maxPitch = 85,
- this.zoomOffset = 1
- }
- Ku.prototype = new zu,
- Ku.prototype.constructor = Ku,
- Ku.prototype.type = "maptalks3D";
- const Qu = Uu("maptalks3D", Ku, (function (e) {
- e.forEach((function (e) {
- e.setCameraOption(e.model.getMaptalksCameraOption())
- }
- ))
- }
- ));
- (0,
- i.use)((function (e) {
- e.registerComponentModel(Wu),
- e.registerComponentView(Zu),
- e.registerCoordinateSystem("maptalks3D", Qu),
- e.registerAction({
- type: "maptalks3DChangeCamera",
- event: "maptalks3dcamerachanged",
- update: "maptalks3D:updateCamera"
- }, (function (e, t) {
- t.eachComponent({
- mainType: "maptalks3D",
- query: e
- }, (function (t) {
- t.setMaptalksCameraOption(e)
- }
- ))
- }
- ))
- }
- ));
- var Ju = Po.vec3
- , $u = i.helper.dataStack.isDimensionStacked;
- function ec(e, t, r) {
- for (var i = e.getDataExtent(t), n = e.getDataExtent(r), a = i[1] - i[0] || i[0], o = n[1] - n[0] || n[0], s = new Uint8Array(2500), l = 0; l < e.count(); l++) {
- var h = e.get(t, l)
- , u = e.get(r, l)
- , c = Math.floor((h - i[0]) / a * 49)
- , d = 50 * Math.floor((u - n[0]) / o * 49) + c;
- s[d] = s[d] || 1
- }
- var f = 0;
- for (l = 0; l < s.length; l++)
- s[l] && f++;
- return f / s.length
- }
- var tc = Po.vec3
- , rc = i.helper.dataStack.isDimensionStacked;
- function ic(e, t) {
- var r = rc(e, t[2]);
- return {
- dimension: r ? e.getCalculationInfo("stackResultDimension") : t[2],
- isStacked: r
- }
- }
- function nc(e) {
- e.registerLayout((function (e, t) {
- e.eachSeriesByType("bar3D", (function (e) {
- var t = e.coordinateSystem
- , r = t && t.type;
- "globe" === r ? function (e, t) {
- var r = e.getData()
- , n = e.get("minHeight") || 0
- , a = e.get("barSize")
- , o = ["lng", "lat", "alt"].map((function (t) {
- return e.coordDimToDataDim(t)[0]
- }
- ));
- if (null == a) {
- var s = t.radius * Math.PI
- , l = ec(r, o[0], o[1]);
- a = [s / Math.sqrt(r.count() / l), s / Math.sqrt(r.count() / l)]
- } else
- i.util.isArray(a) || (a = [a, a]);
- var h = ic(r, o);
- r.each(o, (function (e, i, o, s) {
- var l = r.get(h.dimension, s)
- , u = h.isStacked ? l - o : t.altitudeAxis.scale.getExtent()[0]
- , c = Math.max(t.altitudeAxis.dataToCoord(o), n)
- , d = t.dataToPoint([e, i, u])
- , f = t.dataToPoint([e, i, l])
- , p = tc.sub([], f, d);
- tc.normalize(p, p);
- var m = [a[0], c, a[1]];
- r.setItemLayout(s, [d, p, m])
- }
- )),
- r.setLayout("orient", vt.UP.array)
- }(e, t) : "cartesian3D" === r ? function (e, t) {
- var r = e.getData()
- , n = e.get("barSize");
- if (null == n) {
- var a, o, s = t.size, l = t.getAxis("x"), h = t.getAxis("y");
- a = "category" === l.type ? .7 * l.getBandWidth() : .6 * Math.round(s[0] / Math.sqrt(r.count())),
- o = "category" === h.type ? .7 * h.getBandWidth() : .6 * Math.round(s[1] / Math.sqrt(r.count())),
- n = [a, o]
- } else
- i.util.isArray(n) || (n = [n, n]);
- var u, c, d, f = t.getAxis("z").scale.getExtent(), p = (c = (u = f)[0],
- d = u[1],
- !(c > 0 && d > 0 || c < 0 && d < 0)), m = ["x", "y", "z"].map((function (t) {
- return e.coordDimToDataDim(t)[0]
- }
- )), g = $u(r, m[2]), _ = g ? r.getCalculationInfo("stackResultDimension") : m[2];
- r.each(m, (function (e, i, a, o) {
- var s = r.get(_, o)
- , l = g ? s - a : p ? 0 : f[0]
- , h = t.dataToPoint([e, i, l])
- , u = t.dataToPoint([e, i, s])
- , c = Ju.dist(h, u)
- , d = [0, u[1] < h[1] ? -1 : 1, 0];
- 0 === Math.abs(c) && (c = .1);
- var m = [n[0], c, n[1]];
- r.setItemLayout(o, [h, d, m])
- }
- )),
- r.setLayout("orient", [1, 0, 0])
- }(e, t) : "geo3D" === r ? function (e, t) {
- var r = e.getData()
- , n = e.get("barSize")
- , a = e.get("minHeight") || 0
- , o = ["lng", "lat", "alt"].map((function (t) {
- return e.coordDimToDataDim(t)[0]
- }
- ));
- if (null == n) {
- var s = Math.min(t.size[0], t.size[2])
- , l = ec(r, o[0], o[1]);
- n = [s / Math.sqrt(r.count() / l), s / Math.sqrt(r.count() / l)]
- } else
- i.util.isArray(n) || (n = [n, n]);
- var h = [0, 1, 0]
- , u = ic(r, o);
- r.each(o, (function (e, i, o, s) {
- var l = r.get(u.dimension, s)
- , c = u.isStacked ? l - o : t.altitudeAxis.scale.getExtent()[0]
- , d = Math.max(t.altitudeAxis.dataToCoord(o), a)
- , f = t.dataToPoint([e, i, c])
- , p = [n[0], d, n[1]];
- r.setItemLayout(s, [f, h, p])
- }
- )),
- r.setLayout("orient", [1, 0, 0])
- }(e, t) : ("mapbox3D" === r || "maptalks3D" === r) && function (e, t) {
- var r = e.getData()
- , n = e.coordDimToDataDim("lng")[0]
- , a = e.coordDimToDataDim("lat")[0]
- , o = e.coordDimToDataDim("alt")[0]
- , s = e.get("barSize")
- , l = e.get("minHeight") || 0;
- if (null == s) {
- var h = r.getDataExtent(n)
- , u = r.getDataExtent(a)
- , c = t.dataToPoint([h[0], u[0]])
- , d = t.dataToPoint([h[1], u[1]])
- , f = Math.min(Math.abs(c[0] - d[0]), Math.abs(c[1] - d[1])) || 1
- , p = ec(r, n, a);
- s = [f / Math.sqrt(r.count() / p), f / Math.sqrt(r.count() / p)]
- } else
- i.util.isArray(s) || (s = [s, s]),
- s[0] /= t.getScale() / 16,
- s[1] /= t.getScale() / 16;
- var m = [0, 0, 1]
- , g = [n, a, o]
- , _ = ic(r, g);
- r.each(g, (function (e, i, n, a) {
- var o = r.get(_.dimension, a)
- , h = _.isStacked ? o - n : 0
- , u = t.dataToPoint([e, i, h])
- , c = t.dataToPoint([e, i, o])
- , d = Math.max(c[2] - u[2], l)
- , f = [s[0], d, s[1]];
- r.setItemLayout(a, [u, m, f])
- }
- )),
- r.setLayout("orient", [1, 0, 0])
- }(e, t)
- }
- ))
- }
- ))
- }
- const ac = {
- getFormattedLabel: function (e, t, r, n, a) {
- r = r || "normal";
- var o = e.getData(n).getItemModel(t)
- , s = e.getDataParams(t, n);
- null != a && s.value instanceof Array && (s.value = s.value[a]);
- var l, h = o.get("normal" === r ? ["label", "formatter"] : ["emphasis", "label", "formatter"]);
- return null == h && (h = o.get(["label", "formatter"])),
- "function" == typeof h ? (s.status = r,
- l = h(s)) : "string" == typeof h && (l = i.format.formatTpl(h, s)),
- l
- },
- normalizeToArray: function (e) {
- return e instanceof Array ? e : null == e ? [] : [e]
- }
- };
- function oc(e, t, r) {
- var n = e.getData()
- , a = e.getRawValue(t)
- , o = i.util.isArray(a) ? function (e) {
- var a = []
- , o = function (e, t) {
- var r = [];
- return i.util.each(e.dimensions, (function (t) {
- var i = e.getDimensionInfo(t)
- , n = i.otherDims.tooltip;
- null != n && !1 !== n && (r[n] = i.name)
- }
- )),
- r
- }(n);
- function s(e, t) {
- var o = n.getDimensionInfo(t);
- if (o && !1 !== o.otherDims.tooltip) {
- var s = o.type
- , l = "- " + (o.tooltipName || o.name) + ": " + ("ordinal" === s ? e + "" : "time" === s ? r ? "" : i.format.formatTime("yyyy/MM/dd hh:mm:ss", e) : i.format.addCommas(e));
- l && a.push(i.format.encodeHTML(l))
- }
- }
- return o.length ? i.util.each(o, (function (e) {
- s(n.get(e, t), e)
- }
- )) : i.util.each(e, s),
- "<br/>" + a.join("<br/>")
- }(a) : i.format.encodeHTML(i.format.addCommas(a))
- , s = n.getName(t)
- , l = Ih(n, t);
- i.util.isObject(l) && l.colorStops && (l = (l.colorStops[0] || {}).color),
- l = l || "transparent";
- var h = i.format.getTooltipMarker(l)
- , u = e.name;
- return "\0-" === u && (u = ""),
- u = u ? i.format.encodeHTML(u) + (r ? ": " : "<br/>") : "",
- r ? h + u + o : u + h + (s ? i.format.encodeHTML(s) + ": " + o : o)
- }
- function sc(e, t, r) {
- r = r || e.getSource();
- var n = t || i.getCoordinateSystemDimensions(e.get("coordinateSystem")) || ["x", "y", "z"]
- , a = i.helper.createDimensions(r, {
- dimensionsDefine: r.dimensionsDefine || e.get("dimensions"),
- encodeDefine: r.encodeDefine || e.get("encode"),
- coordDimensions: n.map((function (t) {
- var r = e.getReferringComponents(t + "Axis3D").models[0];
- return {
- type: r && "category" === r.get("type") ? "ordinal" : "float",
- name: t
- }
- }
- ))
- });
- "cartesian3D" === e.get("coordinateSystem") && a.forEach((function (t) {
- if (n.indexOf(t.coordDim) >= 0) {
- var r = e.getReferringComponents(t.coordDim + "Axis3D").models[0];
- r && "category" === r.get("type") && (t.ordinalMeta = r.getOrdinalMeta())
- }
- }
- ));
- var o = i.helper.dataStack.enableDataStack(e, a, {
- byIndex: !0,
- stackedCoordDimension: "z"
- })
- , s = new i.List(a, e);
- return s.setCalculationInfo(o),
- s.initData(r),
- s
- }
- var lc = i.SeriesModel.extend({
- type: "series.bar3D",
- dependencies: ["globe"],
- visualStyleAccessPathvisu: "itemStyle",
- getInitialData: function (e, t) {
- return sc(this)
- },
- getFormattedLabel: function (e, t, r, i) {
- var n = ac.getFormattedLabel(this, e, t, r, i);
- return null == n && (n = this.getData().get("z", e)),
- n
- },
- formatTooltip: function (e) {
- return oc(this, e)
- },
- defaultOption: {
- coordinateSystem: "cartesian3D",
- globeIndex: 0,
- grid3DIndex: 0,
- zlevel: -10,
- bevelSize: 0,
- bevelSmoothness: 2,
- onGridPlane: "xy",
- shading: "color",
- minHeight: 0,
- itemStyle: {
- opacity: 1
- },
- label: {
- show: !1,
- distance: 2,
- textStyle: {
- fontSize: 14,
- color: "#000",
- backgroundColor: "rgba(255,255,255,0.7)",
- padding: 3,
- borderRadius: 3
- }
- },
- emphasis: {
- label: {
- show: !0
- }
- },
- animationDurationUpdate: 500
- }
- });
- i.util.merge(lc.prototype, Kl);
- const hc = lc;
- var uc, cc, dc, fc, pc, mc, gc, _c, vc = Po.vec3, yc = Po.mat3, xc = Vr.extend((function () {
- return {
- attributes: {
- position: new Vr.Attribute("position", "float", 3, "POSITION"),
- normal: new Vr.Attribute("normal", "float", 3, "NORMAL"),
- color: new Vr.Attribute("color", "float", 4, "COLOR"),
- prevPosition: new Vr.Attribute("prevPosition", "float", 3),
- prevNormal: new Vr.Attribute("prevNormal", "float", 3)
- },
- dynamic: !0,
- enableNormal: !1,
- bevelSize: 1,
- bevelSegments: 0,
- _dataIndices: null,
- _vertexOffset: 0,
- _triangleOffset: 0
- }
- }
- ), {
- resetOffset: function () {
- this._vertexOffset = 0,
- this._triangleOffset = 0
- },
- setBarCount: function (e) {
- var t = this.enableNormal
- , r = this.getBarVertexCount() * e
- , i = this.getBarTriangleCount() * e;
- this.vertexCount !== r && (this.attributes.position.init(r),
- t ? this.attributes.normal.init(r) : this.attributes.normal.value = null,
- this.attributes.color.init(r)),
- this.triangleCount !== i && (this.indices = r > 65535 ? new Uint32Array(3 * i) : new Uint16Array(3 * i),
- this._dataIndices = new Uint32Array(r))
- },
- getBarVertexCount: function () {
- var e = this.bevelSize > 0 ? this.bevelSegments : 0;
- return e > 0 ? this._getBevelBarVertexCount(e) : this.enableNormal ? 24 : 8
- },
- getBarTriangleCount: function () {
- var e = this.bevelSize > 0 ? this.bevelSegments : 0;
- return e > 0 ? this._getBevelBarTriangleCount(e) : 12
- },
- _getBevelBarVertexCount: function (e) {
- return 4 * (e + 1) * (e + 1) * 2
- },
- _getBevelBarTriangleCount: function (e) {
- return (4 * e + 3 + 1) * (2 * e + 1) * 2 + 4
- },
- setColor: function (e, t) {
- for (var r = this.getBarVertexCount(), i = r * (e + 1), n = r * e; n < i; n++)
- this.attributes.color.set(n, t);
- this.dirtyAttribute("color")
- },
- getDataIndexOfVertex: function (e) {
- return this._dataIndices ? this._dataIndices[e] : null
- },
- addBar: function () {
- for (var e = vc.create, t = vc.scaleAndAdd, r = e(), i = e(), n = e(), a = e(), o = e(), s = e(), l = e(), h = [], u = [], c = 0; c < 8; c++)
- h[c] = e();
- var d = [[0, 1, 5, 4], [2, 3, 7, 6], [4, 5, 6, 7], [3, 2, 1, 0], [0, 4, 7, 3], [1, 2, 6, 5]]
- , f = [0, 1, 2, 0, 2, 3]
- , p = [];
- for (c = 0; c < d.length; c++)
- for (var m = d[c], g = 0; g < 2; g++) {
- for (var _ = [], v = 0; v < 3; v++)
- _.push(m[f[3 * g + v]]);
- p.push(_)
- }
- return function (e, c, m, g, _, v) {
- var y = this._vertexOffset;
- if (this.bevelSize > 0 && this.bevelSegments > 0)
- this._addBevelBar(e, c, m, g, this.bevelSize, this.bevelSegments, _);
- else {
- vc.copy(n, c),
- vc.normalize(n, n),
- vc.cross(a, m, n),
- vc.normalize(a, a),
- vc.cross(i, n, a),
- vc.normalize(a, a),
- vc.negate(o, i),
- vc.negate(s, n),
- vc.negate(l, a),
- t(h[0], e, i, g[0] / 2),
- t(h[0], h[0], a, g[2] / 2),
- t(h[1], e, i, g[0] / 2),
- t(h[1], h[1], l, g[2] / 2),
- t(h[2], e, o, g[0] / 2),
- t(h[2], h[2], l, g[2] / 2),
- t(h[3], e, o, g[0] / 2),
- t(h[3], h[3], a, g[2] / 2),
- t(r, e, n, g[1]),
- t(h[4], r, i, g[0] / 2),
- t(h[4], h[4], a, g[2] / 2),
- t(h[5], r, i, g[0] / 2),
- t(h[5], h[5], l, g[2] / 2),
- t(h[6], r, o, g[0] / 2),
- t(h[6], h[6], l, g[2] / 2),
- t(h[7], r, o, g[0] / 2),
- t(h[7], h[7], a, g[2] / 2);
- var x = this.attributes;
- if (this.enableNormal) {
- u[0] = i,
- u[1] = o,
- u[2] = n,
- u[3] = s,
- u[4] = a,
- u[5] = l;
- for (var b = this._vertexOffset, w = 0; w < d.length; w++) {
- for (var T = 3 * this._triangleOffset, S = 0; S < 6; S++)
- this.indices[T++] = b + f[S];
- b += 4,
- this._triangleOffset += 2
- }
- for (w = 0; w < d.length; w++) {
- var M = u[w];
- for (S = 0; S < 4; S++) {
- var A = d[w][S];
- x.position.set(this._vertexOffset, h[A]),
- x.normal.set(this._vertexOffset, M),
- x.color.set(this._vertexOffset++, _)
- }
- }
- } else {
- for (w = 0; w < p.length; w++) {
- for (T = 3 * this._triangleOffset,
- S = 0; S < 3; S++)
- this.indices[T + S] = p[w][S] + this._vertexOffset;
- this._triangleOffset++
- }
- for (w = 0; w < h.length; w++)
- x.position.set(this._vertexOffset, h[w]),
- x.color.set(this._vertexOffset++, _)
- }
- }
- var E = this._vertexOffset;
- for (w = y; w < E; w++)
- this._dataIndices[w] = v
- }
- }(),
- _addBevelBar: (uc = vc.create(),
- cc = vc.create(),
- dc = vc.create(),
- fc = yc.create(),
- pc = [],
- mc = [1, -1, -1, 1],
- gc = [1, 1, -1, -1],
- _c = [2, 0],
- function (e, t, r, i, n, a, o) {
- vc.copy(cc, t),
- vc.normalize(cc, cc),
- vc.cross(dc, r, cc),
- vc.normalize(dc, dc),
- vc.cross(uc, cc, dc),
- vc.normalize(dc, dc),
- fc[0] = uc[0],
- fc[1] = uc[1],
- fc[2] = uc[2],
- fc[3] = cc[0],
- fc[4] = cc[1],
- fc[5] = cc[2],
- fc[6] = dc[0],
- fc[7] = dc[1],
- fc[8] = dc[2],
- n = Math.min(i[0], i[2]) / 2 * n;
- for (var s = 0; s < 3; s++)
- pc[s] = Math.max(i[s] - 2 * n, 0);
- var l = (i[0] - pc[0]) / 2
- , h = (i[1] - pc[1]) / 2
- , u = (i[2] - pc[2]) / 2
- , c = []
- , d = []
- , f = this._vertexOffset
- , p = [];
- for (s = 0; s < 2; s++) {
- p[s] = p[s] = [];
- for (var m = 0; m <= a; m++)
- for (var g = 0; g < 4; g++) {
- (0 === m && 0 === s || 1 === s && m === a) && p[s].push(f);
- for (var _ = 0; _ <= a; _++) {
- var v = _ / a * Math.PI / 2 + Math.PI / 2 * g
- , y = m / a * Math.PI / 2 + Math.PI / 2 * s;
- d[0] = l * Math.cos(v) * Math.sin(y),
- d[1] = h * Math.cos(y),
- d[2] = u * Math.sin(v) * Math.sin(y),
- c[0] = d[0] + mc[g] * pc[0] / 2,
- c[1] = d[1] + h + _c[s] * pc[1] / 2,
- c[2] = d[2] + gc[g] * pc[2] / 2,
- Math.abs(l - h) < 1e-6 && Math.abs(h - u) < 1e-6 || (d[0] /= l * l,
- d[1] /= h * h,
- d[2] /= u * u),
- vc.normalize(d, d),
- vc.transformMat3(c, c, fc),
- vc.transformMat3(d, d, fc),
- vc.add(c, c, e),
- this.attributes.position.set(f, c),
- this.enableNormal && this.attributes.normal.set(f, d),
- this.attributes.color.set(f, o),
- f++
- }
- }
- }
- var x = 4 * a + 3
- , b = 2 * a + 1
- , w = x + 1;
- for (g = 0; g < b; g++)
- for (s = 0; s <= x; s++) {
- var T = g * w + s + this._vertexOffset
- , S = g * w + (s + 1) % w + this._vertexOffset
- , M = (g + 1) * w + (s + 1) % w + this._vertexOffset
- , A = (g + 1) * w + s + this._vertexOffset;
- this.setTriangleIndices(this._triangleOffset++, [M, T, S]),
- this.setTriangleIndices(this._triangleOffset++, [M, A, T])
- }
- this.setTriangleIndices(this._triangleOffset++, [p[0][0], p[0][2], p[0][1]]),
- this.setTriangleIndices(this._triangleOffset++, [p[0][0], p[0][3], p[0][2]]),
- this.setTriangleIndices(this._triangleOffset++, [p[1][0], p[1][1], p[1][2]]),
- this.setTriangleIndices(this._triangleOffset++, [p[1][0], p[1][2], p[1][3]]),
- this._vertexOffset = f
- }
- )
- });
- i.util.defaults(xc.prototype, Lo),
- i.util.defaults(xc.prototype, Nh);
- const bc = xc;
- var wc = Po.vec3;
- const Tc = i.ChartView.extend({
- type: "bar3D",
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this._api = t,
- this._labelsBuilder = new Fh(256, 256, t);
- var r = this;
- this._labelsBuilder.getLabelPosition = function (e, t, i) {
- if (r._data) {
- var n = r._data.getItemLayout(e)
- , a = n[0]
- , o = n[1]
- , s = n[2][1];
- return wc.scaleAndAdd([], a, o, i + s)
- }
- return [0, 0]
- }
- ,
- this._labelsBuilder.getMesh().renderOrder = 100
- },
- render: function (e, t, r) {
- var i = this._prevBarMesh;
- this._prevBarMesh = this._barMesh,
- this._barMesh = i,
- this._barMesh || (this._barMesh = new Ka.Mesh({
- geometry: new bc,
- shadowDepthMaterial: new Ka.Material({
- shader: new Ka.Shader(Ka.Shader.source("ecgl.sm.depth.vertex"), Ka.Shader.source("ecgl.sm.depth.fragment"))
- }),
- culling: "cartesian3D" === e.coordinateSystem.type,
- renderOrder: 10,
- renderNormal: !0
- })),
- this.groupGL.remove(this._prevBarMesh),
- this.groupGL.add(this._barMesh),
- this.groupGL.add(this._labelsBuilder.getMesh());
- var n = e.coordinateSystem;
- if (this._doRender(e, r),
- n && n.viewGL) {
- n.viewGL.add(this.groupGL);
- var a = n.viewGL.isLinearSpace() ? "define" : "undefine";
- this._barMesh.material[a]("fragment", "SRGB_DECODE")
- }
- this._data = e.getData(),
- this._labelsBuilder.updateData(this._data),
- this._labelsBuilder.updateLabels(),
- this._updateAnimation(e)
- },
- _updateAnimation: function (e) {
- Ka.updateVertexAnimation([["prevPosition", "position"], ["prevNormal", "normal"]], this._prevBarMesh, this._barMesh, e)
- },
- _doRender: function (e, t) {
- var r = e.getData()
- , i = e.get("shading")
- , n = "color" !== i
- , a = this
- , o = this._barMesh
- , s = "ecgl." + i;
- o.material && o.material.shader.name === s || (o.material = Ka.createMaterial(s, ["VERTEX_COLOR"])),
- Ka.setMaterialFromModel(i, o.material, e, t),
- o.geometry.enableNormal = n,
- o.geometry.resetOffset();
- var l = e.get("bevelSize")
- , h = e.get("bevelSmoothness");
- o.geometry.bevelSegments = h,
- o.geometry.bevelSize = l;
- var u = []
- , c = new Float32Array(4 * r.count())
- , d = 0
- , f = 0
- , p = !1;
- r.each((function (e) {
- if (r.hasValue(e)) {
- var t = Ih(r, e)
- , i = Rh(r, e);
- null == i && (i = 1),
- Ka.parseColor(t, u),
- u[3] *= i,
- c[d++] = u[0],
- c[d++] = u[1],
- c[d++] = u[2],
- c[d++] = u[3],
- u[3] > 0 && (f++,
- u[3] < .99 && (p = !0))
- }
- }
- )),
- o.geometry.setBarCount(f);
- var m = r.getLayout("orient")
- , g = this._barIndexOfData = new Int32Array(r.count());
- f = 0,
- r.each((function (e) {
- if (r.hasValue(e)) {
- var t = r.getItemLayout(e)
- , i = t[0]
- , n = t[1]
- , o = t[2]
- , s = 4 * e;
- u[0] = c[s++],
- u[1] = c[s++],
- u[2] = c[s++],
- u[3] = c[s++],
- u[3] > 0 && (a._barMesh.geometry.addBar(i, n, m, o, u, e),
- g[e] = f++)
- } else
- g[e] = -1
- }
- )),
- o.geometry.dirty(),
- o.geometry.updateBoundingBox();
- var _ = o.material;
- _.transparent = p,
- _.depthMask = !p,
- o.geometry.sortTriangles = p,
- this._initHandler(e, t)
- },
- _initHandler: function (e, t) {
- var r = e.getData()
- , i = this._barMesh
- , n = "cartesian3D" === e.coordinateSystem.type;
- i.seriesIndex = e.seriesIndex;
- var a = -1;
- i.off("mousemove"),
- i.off("mouseout"),
- i.on("mousemove", (function (e) {
- var o = i.geometry.getDataIndexOfVertex(e.triangle[0]);
- o !== a && (this._downplay(a),
- this._highlight(o),
- this._labelsBuilder.updateLabels([o]),
- n && t.dispatchAction({
- type: "grid3DShowAxisPointer",
- value: [r.get("x", o), r.get("y", o), r.get("z", o, !0)]
- })),
- a = o,
- i.dataIndex = o
- }
- ), this),
- i.on("mouseout", (function (e) {
- this._downplay(a),
- this._labelsBuilder.updateLabels(),
- a = -1,
- i.dataIndex = -1,
- n && t.dispatchAction({
- type: "grid3DHideAxisPointer"
- })
- }
- ), this)
- },
- _highlight: function (e) {
- var t = this._data;
- if (t) {
- var r = this._barIndexOfData[e];
- if (!(r < 0)) {
- var n = t.getItemModel(e).getModel("emphasis.itemStyle")
- , a = n.get("color")
- , o = n.get("opacity");
- if (null == a) {
- var s = Ih(t, e);
- a = i.color.lift(s, -.4)
- }
- null == o && (o = Rh(t, e));
- var l = Ka.parseColor(a);
- l[3] *= o,
- this._barMesh.geometry.setColor(r, l),
- this._api.getZr().refresh()
- }
- }
- },
- _downplay: function (e) {
- var t = this._data;
- if (t) {
- var r = this._barIndexOfData[e];
- if (!(r < 0)) {
- var i = Ih(t, e)
- , n = Rh(t, e)
- , a = Ka.parseColor(i);
- a[3] *= n,
- this._barMesh.geometry.setColor(r, a),
- this._api.getZr().refresh()
- }
- }
- },
- highlight: function (e, t, r, i) {
- this._toggleStatus("highlight", e, t, r, i)
- },
- downplay: function (e, t, r, i) {
- this._toggleStatus("downplay", e, t, r, i)
- },
- _toggleStatus: function (e, t, r, n, a) {
- var o = t.getData()
- , s = An(o, a)
- , l = this;
- null != s ? i.util.each(ac.normalizeToArray(s), (function (t) {
- "highlight" === e ? this._highlight(t) : this._downplay(t)
- }
- ), this) : o.each((function (t) {
- "highlight" === e ? l._highlight(t) : l._downplay(t)
- }
- ))
- },
- remove: function () {
- this.groupGL.removeAll()
- },
- dispose: function () {
- this._labelsBuilder.dispose(),
- this.groupGL.removeAll()
- }
- });
- (0,
- i.use)((function (e) {
- e.registerChartView(Tc),
- e.registerSeriesModel(hc),
- nc(e),
- e.registerProcessor((function (e, t) {
- e.eachSeriesByType("bar3d", (function (e) {
- var t = e.getData();
- t.filterSelf((function (e) {
- return t.hasValue(e)
- }
- ))
- }
- ))
- }
- ))
- }
- ));
- const Sc = i.SeriesModel.extend({
- type: "series.line3D",
- dependencies: ["grid3D"],
- visualStyleAccessPath: "lineStyle",
- visualDrawType: "stroke",
- getInitialData: function (e, t) {
- return sc(this)
- },
- formatTooltip: function (e) {
- return oc(this, e)
- },
- defaultOption: {
- coordinateSystem: "cartesian3D",
- zlevel: -10,
- grid3DIndex: 0,
- lineStyle: {
- width: 2
- },
- animationDurationUpdate: 500
- }
- });
- function Mc(e, t, r, i, n, a, o) {
- if (0 === n)
- return !1;
- var s, l = n;
- if (o > t + l && o > i + l || o < t - l && o < i - l || a > e + l && a > r + l || a < e - l && a < r - l)
- return !1;
- if (e === r)
- return Math.abs(a - e) <= l / 2;
- var h = (s = (t - i) / (e - r)) * a - o + (e * i - r * t) / (e - r);
- return h * h / (s * s + 1) <= l / 2 * l / 2
- }
- var Ac = Po.vec3;
- Ka.Shader.import(is);
- const Ec = i.ChartView.extend({
- type: "line3D",
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this._api = t
- },
- render: function (e, t, r) {
- var i = this._prevLine3DMesh;
- this._prevLine3DMesh = this._line3DMesh,
- this._line3DMesh = i,
- this._line3DMesh || (this._line3DMesh = new Ka.Mesh({
- geometry: new Ro({
- useNativeLine: !1,
- sortTriangles: !0
- }),
- material: new Ka.Material({
- shader: Ka.createShader("ecgl.meshLines3D")
- }),
- renderOrder: 10
- }),
- this._line3DMesh.geometry.pick = this._pick.bind(this)),
- this.groupGL.remove(this._prevLine3DMesh),
- this.groupGL.add(this._line3DMesh);
- var n = e.coordinateSystem;
- if (n && n.viewGL) {
- n.viewGL.add(this.groupGL);
- var a = n.viewGL.isLinearSpace() ? "define" : "undefine";
- this._line3DMesh.material[a]("fragment", "SRGB_DECODE")
- }
- this._doRender(e, r),
- this._data = e.getData(),
- this._camera = n.viewGL.camera,
- this.updateCamera(),
- this._updateAnimation(e)
- },
- updateCamera: function () {
- this._updateNDCPosition()
- },
- _doRender: function (e, t) {
- var r = e.getData()
- , i = this._line3DMesh;
- i.geometry.resetOffset();
- var n = r.getLayout("points")
- , a = []
- , o = new Float32Array(n.length / 3 * 4)
- , s = 0
- , l = !1;
- r.each((function (e) {
- var t = Ih(r, e)
- , i = Rh(r, e);
- null == i && (i = 1),
- Ka.parseColor(t, a),
- a[3] *= i,
- o[s++] = a[0],
- o[s++] = a[1],
- o[s++] = a[2],
- o[s++] = a[3],
- a[3] < .99 && (l = !0)
- }
- )),
- i.geometry.setVertexCount(i.geometry.getPolylineVertexCount(n)),
- i.geometry.setTriangleCount(i.geometry.getPolylineTriangleCount(n)),
- i.geometry.addPolyline(n, o, Mn(e.get("lineStyle.width"), 1)),
- i.geometry.dirty(),
- i.geometry.updateBoundingBox();
- var h = i.material;
- h.transparent = l,
- h.depthMask = !l;
- var u = e.getModel("debug.wireframe");
- u.get("show") ? (i.geometry.createAttribute("barycentric", "float", 3),
- i.geometry.generateBarycentric(),
- i.material.set("both", "WIREFRAME_TRIANGLE"),
- i.material.set("wireframeLineColor", Ka.parseColor(u.get("lineStyle.color") || "rgba(0,0,0,0.5)")),
- i.material.set("wireframeLineWidth", Mn(u.get("lineStyle.width"), 1))) : i.material.set("both", "WIREFRAME_TRIANGLE"),
- this._points = n,
- this._initHandler(e, t)
- },
- _updateAnimation: function (e) {
- Ka.updateVertexAnimation([["prevPosition", "position"], ["prevPositionPrev", "positionPrev"], ["prevPositionNext", "positionNext"]], this._prevLine3DMesh, this._line3DMesh, e)
- },
- _initHandler: function (e, t) {
- var r = e.getData()
- , i = e.coordinateSystem
- , n = this._line3DMesh
- , a = -1;
- n.seriesIndex = e.seriesIndex,
- n.off("mousemove"),
- n.off("mouseout"),
- n.on("mousemove", (function (e) {
- var o = i.pointToData(e.point.array)
- , s = r.indicesOfNearest("x", o[0])[0];
- s !== a && (t.dispatchAction({
- type: "grid3DShowAxisPointer",
- value: [r.get("x", s), r.get("y", s), r.get("z", s)]
- }),
- n.dataIndex = s),
- a = s
- }
- ), this),
- n.on("mouseout", (function (e) {
- a = -1,
- n.dataIndex = -1,
- t.dispatchAction({
- type: "grid3DHideAxisPointer"
- })
- }
- ), this)
- },
- _updateNDCPosition: function () {
- var e = new Ht
- , t = this._camera;
- Ht.multiply(e, t.projectionMatrix, t.viewMatrix);
- var r = this._positionNDC
- , i = this._points
- , n = i.length / 3;
- r && r.length / 2 === n || (r = this._positionNDC = new Float32Array(2 * n));
- for (var a = [], o = 0; o < n; o++) {
- var s = 3 * o
- , l = 2 * o;
- a[0] = i[s],
- a[1] = i[s + 1],
- a[2] = i[s + 2],
- a[3] = 1,
- Ac.transformMat4(a, a, e.array),
- r[l] = a[0] / a[3],
- r[l + 1] = a[1] / a[3]
- }
- },
- _pick: function (e, t, r, i, n, a) {
- var o = this._positionNDC
- , s = this._data.hostModel.get("lineStyle.width")
- , l = -1
- , h = .5 * r.viewport.width
- , u = .5 * r.viewport.height;
- e = (e + 1) * h,
- t = (t + 1) * u;
- for (var c = 1; c < o.length / 2; c++) {
- var d = (o[2 * (c - 1)] + 1) * h
- , f = (o[2 * (c - 1) + 1] + 1) * u
- , p = (o[2 * c] + 1) * h
- , m = (o[2 * c + 1] + 1) * u;
- Mc(d, f, p, m, s, e, t) && (l = (d - e) * (d - e) + (f - t) * (f - t) < (p - e) * (p - e) + (m - t) * (m - t) ? c - 1 : c)
- }
- if (l >= 0) {
- var g = 3 * l
- , _ = new vt(this._points[g], this._points[g + 1], this._points[g + 2]);
- a.push({
- dataIndex: l,
- point: _,
- pointWorld: _.clone(),
- target: this._line3DMesh,
- distance: this._camera.getWorldPosition().dist(_)
- })
- }
- },
- remove: function () {
- this.groupGL.removeAll()
- },
- dispose: function () {
- this.groupGL.removeAll()
- }
- });
- (0,
- i.use)((function (e) {
- e.registerChartView(Ec),
- e.registerSeriesModel(Sc),
- e.registerLayout((function (e, t) {
- e.eachSeriesByType("line3D", (function (e) {
- var t = e.getData()
- , r = e.coordinateSystem;
- if (r) {
- if ("cartesian3D" !== r.type)
- return;
- var i = new Float32Array(3 * t.count())
- , n = []
- , a = []
- , o = r.dimensions.map((function (t) {
- return e.coordDimToDataDim(t)[0]
- }
- ));
- r && t.each(o, (function (e, t, o, s) {
- n[0] = e,
- n[1] = t,
- n[2] = o,
- r.dataToPoint(n, a),
- i[3 * s] = a[0],
- i[3 * s + 1] = a[1],
- i[3 * s + 2] = a[2]
- }
- )),
- t.setLayout("points", i)
- }
- }
- ))
- }
- ))
- }
- ));
- const Cc = i.SeriesModel.extend({
- type: "series.scatter3D",
- dependencies: ["globe", "grid3D", "geo3D"],
- visualStyleAccessPath: "itemStyle",
- hasSymbolVisual: !0,
- getInitialData: function (e, t) {
- return sc(this)
- },
- getFormattedLabel: function (e, t, r, i) {
- var n = ac.getFormattedLabel(this, e, t, r, i);
- if (null == n) {
- var a = this.getData()
- , o = a.dimensions[a.dimensions.length - 1];
- n = a.get(o, e)
- }
- return n
- },
- formatTooltip: function (e) {
- return oc(this, e)
- },
- defaultOption: {
- coordinateSystem: "cartesian3D",
- zlevel: -10,
- progressive: 1e5,
- progressiveThreshold: 1e5,
- grid3DIndex: 0,
- globeIndex: 0,
- symbol: "circle",
- symbolSize: 10,
- blendMode: "source-over",
- label: {
- show: !1,
- position: "right",
- distance: 5,
- textStyle: {
- fontSize: 14,
- color: "#000",
- backgroundColor: "rgba(255,255,255,0.7)",
- padding: 3,
- borderRadius: 3
- }
- },
- itemStyle: {
- opacity: .8
- },
- emphasis: {
- label: {
- show: !0
- }
- },
- animationDurationUpdate: 500
- }
- });
- function Dc(e, t, r) {
- (t = t || document.createElement("canvas")).width = e,
- t.height = e;
- var i = t.getContext("2d");
- return r && r(i),
- t
- }
- var Lc = {
- getMarginByStyle: function (e) {
- var t = e.minMargin || 0
- , r = 0;
- e.stroke && "none" !== e.stroke && (r = null == e.lineWidth ? 1 : e.lineWidth);
- var i = e.shadowBlur || 0
- , n = e.shadowOffsetX || 0
- , a = e.shadowOffsetY || 0
- , o = {};
- return o.left = Math.max(r / 2, -n + i, t),
- o.right = Math.max(r / 2, n + i, t),
- o.top = Math.max(r / 2, -a + i, t),
- o.bottom = Math.max(r / 2, a + i, t),
- o
- },
- createSymbolSprite: function (e, t, r, n) {
- var a = function (e, t, r, n) {
- i.util.isArray(t) || (t = [t, t]);
- var a = Lc.getMarginByStyle(r, void 0)
- , o = t[0] + a.left + a.right
- , s = t[1] + a.top + a.bottom
- , l = i.helper.createSymbol(e, 0, 0, t[0], t[1])
- , h = Math.max(o, s);
- l.x = a.left,
- l.y = a.top,
- o > s ? l.y += (h - s) / 2 : l.x += (h - o) / 2;
- var u = l.getBoundingRect();
- return l.x -= u.x,
- l.y -= u.y,
- l.setStyle(r),
- l.update(),
- l.__size = h,
- l
- }(e, t, r)
- , o = Lc.getMarginByStyle(r);
- return {
- image: Dc(a.__size, n, (function (e) {
- i.innerDrawElementOnCanvas(e, a)
- }
- )),
- margin: o
- }
- },
- createSDFFromCanvas: function (e, t, r, i) {
- return Dc(t, i, (function (t) {
- var i = e.getContext("2d").getImageData(0, 0, e.width, e.height);
- t.putImageData(function (e, t, r) {
- var i = t.width
- , n = t.height
- , a = e.canvas.width
- , o = e.canvas.height
- , s = i / a
- , l = n / o;
- function h(e) {
- return e < 128 ? 1 : -1
- }
- function u(e, a) {
- var o = 1 / 0;
- e = Math.floor(e * s);
- for (var u = (a = Math.floor(a * l)) * i + e, c = h(t.data[4 * u]), d = Math.max(a - r, 0); d < Math.min(a + r, n); d++)
- for (var f = Math.max(e - r, 0); f < Math.min(e + r, i); f++) {
- u = d * i + f;
- var p = f - e
- , m = d - a;
- if (c !== h(t.data[4 * u])) {
- var g = p * p + m * m;
- g < o && (o = g)
- }
- }
- return c * Math.sqrt(o)
- }
- for (var c = e.createImageData(a, o), d = 0; d < o; d++)
- for (var f = 0; f < a; f++) {
- var p = u(f, d) / r * .5 + .5
- , m = 4 * (d * a + f);
- c.data[m++] = 255 * (1 - p),
- c.data[m++] = 255 * (1 - p),
- c.data[m++] = 255 * (1 - p),
- c.data[m++] = 255
- }
- return c
- }(t, i, r), 0, 0)
- }
- ))
- },
- createSimpleSprite: function (e, t) {
- return Dc(e, t, (function (t) {
- var r = e / 2;
- t.beginPath(),
- t.arc(r, r, 60, 0, 2 * Math.PI, !1),
- t.closePath();
- var i = t.createRadialGradient(r, r, 0, r, r, r);
- i.addColorStop(0, "rgba(255, 255, 255, 1)"),
- i.addColorStop(.5, "rgba(255, 255, 255, 0.5)"),
- i.addColorStop(1, "rgba(255, 255, 255, 0)"),
- t.fillStyle = i,
- t.fill()
- }
- ))
- }
- };
- const Pc = Lc;
- var Oc = Po.vec3;
- const Nc = {
- needsSortVertices: function () {
- return this.sortVertices
- },
- needsSortVerticesProgressively: function () {
- return this.needsSortVertices() && this.vertexCount >= 2e4
- },
- doSortVertices: function (e, t) {
- var r = this.indices
- , i = Oc.create();
- if (!r) {
- r = this.indices = this.vertexCount > 65535 ? new Uint32Array(this.vertexCount) : new Uint16Array(this.vertexCount);
- for (var n = 0; n < r.length; n++)
- r[n] = n
- }
- if (0 === t) {
- var a, o = this.attributes.position, s = (e = e.array,
- 0);
- for (this._zList && this._zList.length === this.vertexCount || (this._zList = new Float32Array(this.vertexCount)),
- n = 0; n < this.vertexCount; n++) {
- o.get(n, i);
- var l = Oc.sqrDist(i, e);
- isNaN(l) && (l = 1e7,
- s++),
- 0 === n ? (a = l,
- l = 0) : l -= a,
- this._zList[n] = l
- }
- this._noneCount = s
- }
- if (this.vertexCount < 2e4)
- 0 === t && this._simpleSort(this._noneCount / this.vertexCount > .05);
- else
- for (n = 0; n < 3; n++)
- this._progressiveQuickSort(3 * t + n);
- this.dirtyIndices()
- },
- _simpleSort: function (e) {
- var t = this._zList
- , r = this.indices;
- function i(e, r) {
- return t[r] - t[e]
- }
- e ? Array.prototype.sort.call(r, i) : Ch.sort(r, i, 0, r.length - 1)
- },
- _progressiveQuickSort: function (e) {
- var t = this._zList
- , r = this.indices;
- this._quickSort = this._quickSort || new Ch,
- this._quickSort.step(r, (function (e, r) {
- return t[r] - t[e]
- }
- ), e)
- }
- };
- var Ic = Po.vec4;
- Ka.Shader.import("@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end");
- const Rc = Ka.Mesh.extend((function () {
- var e = new Ka.Geometry({
- dynamic: !0,
- attributes: {
- color: new Ka.Geometry.Attribute("color", "float", 4, "COLOR"),
- position: new Ka.Geometry.Attribute("position", "float", 3, "POSITION"),
- size: new Ka.Geometry.Attribute("size", "float", 1),
- prevPosition: new Ka.Geometry.Attribute("prevPosition", "float", 3),
- prevSize: new Ka.Geometry.Attribute("prevSize", "float", 1)
- }
- });
- Object.assign(e, Nc);
- var t = new Ka.Material({
- shader: Ka.createShader("ecgl.sdfSprite"),
- transparent: !0,
- depthMask: !1
- });
- t.enableTexture("sprite"),
- t.define("both", "VERTEX_COLOR"),
- t.define("both", "VERTEX_SIZE");
- var r = new Ka.Texture2D({
- image: document.createElement("canvas"),
- flipY: !1
- });
- return t.set("sprite", r),
- e.pick = this._pick.bind(this),
- {
- geometry: e,
- material: t,
- mode: Ka.Mesh.POINTS,
- sizeScale: 1
- }
- }
- ), {
- _pick: function (e, t, r, i, n, a) {
- var o = this._positionNDC;
- if (o)
- for (var s = r.viewport, l = 2 / s.width, h = 2 / s.height, u = this.geometry.vertexCount - 1; u >= 0; u--) {
- var c, d = o[2 * (c = this.geometry.indices ? this.geometry.indices[u] : u)], f = o[2 * c + 1], p = this.geometry.attributes.size.get(c) / this.sizeScale / 2;
- if (e > d - p * l && e < d + p * l && t > f - p * h && t < f + p * h) {
- var m = new Ka.Vector3
- , g = new Ka.Vector3;
- this.geometry.attributes.position.get(c, m.array),
- Ka.Vector3.transformMat4(g, m, this.worldTransform),
- a.push({
- vertexIndex: c,
- point: m,
- pointWorld: g,
- target: this,
- distance: g.distance(i.getWorldPosition())
- })
- }
- }
- },
- updateNDCPosition: function (e, t, r) {
- var i = this._positionNDC
- , n = this.geometry;
- i && i.length / 2 === n.vertexCount || (i = this._positionNDC = new Float32Array(2 * n.vertexCount));
- for (var a = Ic.create(), o = 0; o < n.vertexCount; o++)
- n.attributes.position.get(o, a),
- a[3] = 1,
- Ic.transformMat4(a, a, e.array),
- Ic.scale(a, a, 1 / a[3]),
- i[2 * o] = a[0],
- i[2 * o + 1] = a[1]
- }
- });
- function Bc(e, t) {
- this.rootNode = new Ka.Node,
- this.is2D = e,
- this._labelsBuilder = new Fh(256, 256, t),
- this._labelsBuilder.getMesh().renderOrder = 100,
- this.rootNode.add(this._labelsBuilder.getMesh()),
- this._api = t,
- this._spriteImageCanvas = document.createElement("canvas"),
- this._startDataIndex = 0,
- this._endDataIndex = 0,
- this._sizeScale = 1
- }
- Bc.prototype = {
- constructor: Bc,
- highlightOnMouseover: !0,
- update: function (e, t, r, i, n) {
- var a = this._prevMesh;
- this._prevMesh = this._mesh,
- this._mesh = a;
- var o = e.getData();
- if (null == i && (i = 0),
- null == n && (n = o.count()),
- this._startDataIndex = i,
- this._endDataIndex = n - 1,
- !this._mesh) {
- var s = this._prevMesh && this._prevMesh.material;
- this._mesh = new Rc({
- renderOrder: 10,
- frustumCulling: !1
- }),
- s && (this._mesh.material = s)
- }
- s = this._mesh.material;
- var l = this._mesh.geometry
- , h = l.attributes;
- this.rootNode.remove(this._prevMesh),
- this.rootNode.add(this._mesh),
- this._setPositionTextureToMesh(this._mesh, this._positionTexture);
- var u = this._getSymbolInfo(e, i, n)
- , c = r.getDevicePixelRatio()
- , d = e.getModel("itemStyle").getItemStyle()
- , f = e.get("large")
- , p = 1;
- u.maxSize > 2 ? (p = this._updateSymbolSprite(e, d, u, c),
- s.enableTexture("sprite")) : s.disableTexture("sprite"),
- h.position.init(n - i);
- var m = [];
- if (f) {
- s.undefine("VERTEX_SIZE"),
- s.undefine("VERTEX_COLOR");
- var g = function (e) {
- const t = e.getVisual("style");
- if (t)
- return t[e.getVisual("drawType")]
- }(o)
- , _ = function (e) {
- return e.getVisual("style").opacity
- }(o);
- Ka.parseColor(g, m),
- m[3] *= _,
- s.set({
- color: m,
- u_Size: u.maxSize * this._sizeScale
- })
- } else
- s.set({
- color: [1, 1, 1, 1]
- }),
- s.define("VERTEX_SIZE"),
- s.define("VERTEX_COLOR"),
- h.size.init(n - i),
- h.color.init(n - i),
- this._originalOpacity = new Float32Array(n - i);
- for (var v = o.getLayout("points"), y = h.position.value, x = 0; x < n - i; x++) {
- var b = 3 * x
- , w = 2 * x;
- if (this.is2D ? (y[b] = v[w],
- y[b + 1] = v[w + 1],
- y[b + 2] = -10) : (y[b] = v[b],
- y[b + 1] = v[b + 1],
- y[b + 2] = v[b + 2]),
- !f) {
- g = Ih(o, x),
- _ = Rh(o, x),
- Ka.parseColor(g, m),
- m[3] *= _,
- h.color.set(x, m),
- m[3];
- var T = o.getItemVisual(x, "symbolSize");
- T = T instanceof Array ? Math.max(T[0], T[1]) : T,
- isNaN(T) && (T = 0),
- h.size.value[x] = T * p * this._sizeScale,
- this._originalOpacity[x] = m[3]
- }
- }
- this._mesh.sizeScale = p,
- l.updateBoundingBox(),
- l.dirty(),
- this._updateMaterial(e, d);
- var S = e.coordinateSystem;
- S && S.viewGL && s[S.viewGL.isLinearSpace() ? "define" : "undefine"]("fragment", "SRGB_DECODE"),
- f || this._updateLabelBuilder(e, i, n),
- this._updateHandler(e, t, r),
- this._updateAnimation(e),
- this._api = r
- },
- getPointsMesh: function () {
- return this._mesh
- },
- updateLabels: function (e) {
- this._labelsBuilder.updateLabels(e)
- },
- hideLabels: function () {
- this.rootNode.remove(this._labelsBuilder.getMesh())
- },
- showLabels: function () {
- this.rootNode.add(this._labelsBuilder.getMesh())
- },
- dispose: function () {
- this._labelsBuilder.dispose()
- },
- _updateSymbolSprite: function (e, t, r, i) {
- r.maxSize = Math.min(2 * r.maxSize, 200);
- var n, a, o = [];
- return r.aspect > 1 ? (o[0] = r.maxSize,
- o[1] = r.maxSize / r.aspect) : (o[1] = r.maxSize,
- o[0] = r.maxSize * r.aspect),
- o[0] = o[0] || 1,
- o[1] = o[1] || 1,
- this._symbolType === r.type && (a = o,
- (n = this._symbolSize) && a && n[0] === a[0] && n[1] === a[1]) && this._lineWidth === t.lineWidth || (Pc.createSymbolSprite(r.type, o, {
- fill: "#fff",
- lineWidth: t.lineWidth,
- stroke: "transparent",
- shadowColor: "transparent",
- minMargin: Math.min(o[0] / 2, 10)
- }, this._spriteImageCanvas),
- Pc.createSDFFromCanvas(this._spriteImageCanvas, Math.min(this._spriteImageCanvas.width, 32), 20, this._mesh.material.get("sprite").image),
- this._symbolType = r.type,
- this._symbolSize = o,
- this._lineWidth = t.lineWidth),
- this._spriteImageCanvas.width / r.maxSize * i
- },
- _updateMaterial: function (e, t) {
- var r = "lighter" === e.get("blendMode") ? Ka.additiveBlend : null
- , i = this._mesh.material;
- i.blend = r,
- i.set("lineWidth", t.lineWidth / 20);
- var n = Ka.parseColor(t.stroke);
- i.set("strokeColor", n),
- i.transparent = !0,
- i.depthMask = !1,
- i.depthTest = !this.is2D,
- i.sortVertices = !this.is2D
- },
- _updateLabelBuilder: function (e, t, r) {
- var i = e.getData()
- , n = this._mesh.geometry
- , a = n.attributes.position.value
- , o = (t = this._startDataIndex,
- this._mesh.sizeScale);
- this._labelsBuilder.updateData(i, t, r),
- this._labelsBuilder.getLabelPosition = function (e, r, i) {
- var n = 3 * (e - t);
- return [a[n], a[n + 1], a[n + 2]]
- }
- ,
- this._labelsBuilder.getLabelDistance = function (e, r, i) {
- return n.attributes.size.get(e - t) / o / 2 + i
- }
- ,
- this._labelsBuilder.updateLabels()
- },
- _updateAnimation: function (e) {
- Ka.updateVertexAnimation([["prevPosition", "position"], ["prevSize", "size"]], this._prevMesh, this._mesh, e)
- },
- _updateHandler: function (e, t, r) {
- var i, n = e.getData(), a = this._mesh, o = this, s = -1, l = e.coordinateSystem && "cartesian3D" === e.coordinateSystem.type;
- l && (i = e.coordinateSystem.model),
- a.seriesIndex = e.seriesIndex,
- a.off("mousemove"),
- a.off("mouseout"),
- a.on("mousemove", (function (t) {
- var h = t.vertexIndex + o._startDataIndex;
- h !== s && (this.highlightOnMouseover && (this.downplay(n, s),
- this.highlight(n, h),
- this._labelsBuilder.updateLabels([h])),
- l && r.dispatchAction({
- type: "grid3DShowAxisPointer",
- value: [n.get(e.coordDimToDataDim("x")[0], h), n.get(e.coordDimToDataDim("y")[0], h), n.get(e.coordDimToDataDim("z")[0], h)],
- grid3DIndex: i.componentIndex
- })),
- a.dataIndex = h,
- s = h
- }
- ), this),
- a.on("mouseout", (function (e) {
- var t = e.vertexIndex + o._startDataIndex;
- this.highlightOnMouseover && (this.downplay(n, t),
- this._labelsBuilder.updateLabels()),
- s = -1,
- a.dataIndex = -1,
- l && r.dispatchAction({
- type: "grid3DHideAxisPointer",
- grid3DIndex: i.componentIndex
- })
- }
- ), this)
- },
- updateLayout: function (e, t, r) {
- var i = e.getData();
- if (this._mesh) {
- var n = this._mesh.geometry.attributes.position.value
- , a = i.getLayout("points");
- if (this.is2D)
- for (var o = 0; o < a.length / 2; o++) {
- var s = 3 * o
- , l = 2 * o;
- n[s] = a[l],
- n[s + 1] = a[l + 1],
- n[s + 2] = -10
- }
- else
- for (o = 0; o < a.length; o++)
- n[o] = a[o];
- this._mesh.geometry.dirty(),
- r.getZr().refresh()
- }
- },
- updateView: function (e) {
- if (this._mesh) {
- var t = new Ht;
- Ht.mul(t, e.viewMatrix, this._mesh.worldTransform),
- Ht.mul(t, e.projectionMatrix, t),
- this._mesh.updateNDCPosition(t, this.is2D, this._api)
- }
- },
- highlight: function (e, t) {
- if (!(t > this._endDataIndex || t < this._startDataIndex)) {
- var r = e.getItemModel(t).getModel("emphasis.itemStyle")
- , n = r.get("color")
- , a = r.get("opacity");
- if (null == n) {
- var o = Ih(e, t);
- n = i.color.lift(o, -.4)
- }
- null == a && (a = Rh(e, t));
- var s = Ka.parseColor(n);
- s[3] *= a,
- this._mesh.geometry.attributes.color.set(t - this._startDataIndex, s),
- this._mesh.geometry.dirtyAttribute("color"),
- this._api.getZr().refresh()
- }
- },
- downplay: function (e, t) {
- if (!(t > this._endDataIndex || t < this._startDataIndex)) {
- var r = Ih(e, t)
- , i = Rh(e, t)
- , n = Ka.parseColor(r);
- n[3] *= i,
- this._mesh.geometry.attributes.color.set(t - this._startDataIndex, n),
- this._mesh.geometry.dirtyAttribute("color"),
- this._api.getZr().refresh()
- }
- },
- fadeOutAll: function (e) {
- if (this._originalOpacity) {
- for (var t = this._mesh.geometry, r = 0; r < t.vertexCount; r++) {
- var i = this._originalOpacity[r] * e;
- t.attributes.color.value[4 * r + 3] = i
- }
- t.dirtyAttribute("color"),
- this._api.getZr().refresh()
- }
- },
- fadeInAll: function () {
- this.fadeOutAll(1)
- },
- setPositionTexture: function (e) {
- this._mesh && this._setPositionTextureToMesh(this._mesh, e),
- this._positionTexture = e
- },
- removePositionTexture: function () {
- this._positionTexture = null,
- this._mesh && this._setPositionTextureToMesh(this._mesh, null)
- },
- setSizeScale: function (e) {
- if (e !== this._sizeScale) {
- if (this._mesh) {
- var t = this._mesh.material.get("u_Size");
- this._mesh.material.set("u_Size", t / this._sizeScale * e);
- var r = this._mesh.geometry.attributes;
- if (r.size.value)
- for (var i = 0; i < r.size.value.length; i++)
- r.size.value[i] = r.size.value[i] / this._sizeScale * e
- }
- this._sizeScale = e
- }
- },
- _setPositionTextureToMesh: function (e, t) {
- t && e.material.set("positionTexture", t),
- e.material[t ? "enableTexture" : "disableTexture"]("positionTexture")
- },
- _getSymbolInfo: function (e, t, r) {
- if (e.get("large"))
- return (h = Mn(e.get("symbolSize"), 1)) instanceof Array ? (o = Math.max(h[0], h[1]),
- i = h[0] / h[1]) : (o = h,
- i = 1),
- {
- maxSize: h,
- type: e.get("symbol"),
- aspect: i
- };
- for (var i, n = e.getData(), a = n.getItemVisual(0, "symbol") || "circle", o = 0, s = t; s < r; s++) {
- var l, h = n.getItemVisual(s, "symbolSize"), u = n.getItemVisual(s, "symbol");
- if (h instanceof Array)
- l = h[0] / h[1],
- o = Math.max(Math.max(h[0], h[1]), o);
- else {
- if (isNaN(h))
- continue;
- l = 1,
- o = Math.max(h, o)
- }
- a = u,
- i = l
- }
- return {
- maxSize: o,
- type: a,
- aspect: i
- }
- }
- };
- const Fc = Bc
- , zc = i.ChartView.extend({
- type: "scatter3D",
- hasSymbolVisual: !0,
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this._pointsBuilderList = [],
- this._currentStep = 0
- },
- render: function (e, t, r) {
- if (this.groupGL.removeAll(),
- e.getData().count()) {
- var i = e.coordinateSystem;
- if (i && i.viewGL) {
- i.viewGL.add(this.groupGL),
- this._camera = i.viewGL.camera;
- var n = this._pointsBuilderList[0];
- n || (n = this._pointsBuilderList[0] = new Fc(!1, r)),
- this._pointsBuilderList.length = 1,
- this.groupGL.add(n.rootNode),
- n.update(e, t, r),
- n.updateView(i.viewGL.camera)
- }
- }
- },
- incrementalPrepareRender: function (e, t, r) {
- var i = e.coordinateSystem;
- i && i.viewGL && (i.viewGL.add(this.groupGL),
- this._camera = i.viewGL.camera),
- this.groupGL.removeAll(),
- this._currentStep = 0
- },
- incrementalRender: function (e, t, r, i) {
- if (!(e.end <= e.start)) {
- var n = this._pointsBuilderList[this._currentStep];
- n || (n = new Fc(!1, i),
- this._pointsBuilderList[this._currentStep] = n),
- this.groupGL.add(n.rootNode),
- n.update(t, r, i, e.start, e.end),
- n.updateView(t.coordinateSystem.viewGL.camera),
- this._currentStep++
- }
- },
- updateCamera: function () {
- this._pointsBuilderList.forEach((function (e) {
- e.updateView(this._camera)
- }
- ), this)
- },
- highlight: function (e, t, r, i) {
- this._toggleStatus("highlight", e, t, r, i)
- },
- downplay: function (e, t, r, i) {
- this._toggleStatus("downplay", e, t, r, i)
- },
- _toggleStatus: function (e, t, r, n, a) {
- var o = t.getData()
- , s = An(o, a)
- , l = "highlight" === e;
- null != s ? i.util.each(ac.normalizeToArray(s), (function (e) {
- for (var t = 0; t < this._pointsBuilderList.length; t++) {
- var r = this._pointsBuilderList[t];
- l ? r.highlight(o, e) : r.downplay(o, e)
- }
- }
- ), this) : o.each((function (e) {
- for (var t = 0; t < this._pointsBuilderList.length; t++) {
- var r = this._pointsBuilderList[t];
- l ? r.highlight(o, e) : r.downplay(o, e)
- }
- }
- ))
- },
- dispose: function () {
- this._pointsBuilderList.forEach((function (e) {
- e.dispose()
- }
- )),
- this.groupGL.removeAll()
- },
- remove: function () {
- this.groupGL.removeAll()
- }
- });
- (0,
- i.use)((function (e) {
- e.registerChartView(zc),
- e.registerSeriesModel(Cc),
- e.registerLayout({
- seriesType: "scatter3D",
- reset: function (e) {
- var t = e.coordinateSystem;
- if (t) {
- var r = t.dimensions;
- if (r.length < 3)
- return;
- var i = r.map((function (t) {
- return e.coordDimToDataDim(t)[0]
- }
- ))
- , n = []
- , a = [];
- return {
- progress: function (e, r) {
- for (var o = new Float32Array(3 * (e.end - e.start)), s = e.start; s < e.end; s++) {
- var l = 3 * (s - e.start);
- n[0] = r.get(i[0], s),
- n[1] = r.get(i[1], s),
- n[2] = r.get(i[2], s),
- t.dataToPoint(n, a),
- o[l] = a[0],
- o[l + 1] = a[1],
- o[l + 2] = a[2]
- }
- r.setLayout("points", o)
- }
- }
- }
- }
- })
- }
- ));
- var Gc = Po.vec3
- , Uc = Po.vec2
- , kc = Gc.normalize
- , Vc = Gc.cross
- , Hc = Gc.sub
- , Wc = Gc.add
- , jc = Gc.create
- , Xc = jc()
- , qc = jc()
- , Zc = jc()
- , Yc = jc()
- , Kc = []
- , Qc = [];
- function Jc(e, t) {
- Uc.copy(Kc, e[0]),
- Uc.copy(Qc, e[1]);
- var r = []
- , i = r[0] = jc()
- , n = r[1] = jc()
- , a = r[2] = jc()
- , o = r[3] = jc();
- t.dataToPoint(Kc, i),
- t.dataToPoint(Qc, o),
- kc(Xc, i),
- Hc(qc, o, i),
- kc(qc, qc),
- Vc(Zc, qc, Xc),
- kc(Zc, Zc),
- Vc(qc, Xc, Zc),
- Wc(n, Xc, qc),
- kc(n, n),
- kc(Xc, o),
- Hc(qc, i, o),
- kc(qc, qc),
- Vc(Zc, qc, Xc),
- kc(Zc, Zc),
- Vc(qc, Xc, Zc),
- Wc(a, Xc, qc),
- kc(a, a),
- Wc(Yc, i, o),
- kc(Yc, Yc);
- var s = Gc.dot(i, Yc)
- , l = Gc.dot(Yc, n)
- , h = (Math.max(Gc.len(i), Gc.len(o)) - s) / l * 2;
- return Gc.scaleAndAdd(n, i, n, h),
- Gc.scaleAndAdd(a, o, a, h),
- r
- }
- function $c(e, t) {
- for (var r = new Float32Array(3 * e.length), i = 0, n = [], a = 0; a < e.length; a++)
- t.dataToPoint(e[a], n),
- r[i++] = n[0],
- r[i++] = n[1],
- r[i++] = n[2];
- return r
- }
- function ed(e) {
- var t = [];
- return e.each((function (r) {
- var i = e.getItemModel(r)
- , n = i.option instanceof Array ? i.option : i.getShallow("coords", !0);
- t.push(n)
- }
- )),
- {
- coordsList: t
- }
- }
- function td(e, t, r) {
- var i = e.getData()
- , n = e.get("polyline")
- , a = ed(i);
- i.setLayout("lineType", n ? "polyline" : "cubicBezier"),
- i.each((function (e) {
- var o = a.coordsList[e]
- , s = n ? $c(o, t) : function (e, t, r) {
- var i = []
- , n = i[0] = Gc.create()
- , a = i[1] = Gc.create()
- , o = i[2] = Gc.create()
- , s = i[3] = Gc.create();
- t.dataToPoint(e[0], n),
- t.dataToPoint(e[1], s);
- var l = Gc.dist(n, s);
- return Gc.lerp(a, n, s, .3),
- Gc.lerp(o, n, s, .3),
- Gc.scaleAndAdd(a, a, r, Math.min(.1 * l, 10)),
- Gc.scaleAndAdd(o, o, r, Math.min(.1 * l, 10)),
- i
- }(o, t, r);
- i.setItemLayout(e, s)
- }
- ))
- }
- function rd(e, t) {
- e.eachSeriesByType("lines3D", (function (e) {
- var t = e.coordinateSystem;
- "globe" === t.type ? function (e, t) {
- var r = e.getData()
- , i = e.get("polyline");
- r.setLayout("lineType", i ? "polyline" : "cubicBezier");
- var n = ed(r);
- r.each((function (e) {
- var a = n.coordsList[e]
- , o = i ? $c : Jc;
- r.setItemLayout(e, o(a, t))
- }
- ))
- }(e, t) : "geo3D" === t.type ? td(e, t, [0, 1, 0]) : "mapbox3D" !== t.type && "maptalks3D" !== t.type || td(e, t, [0, 0, 1])
- }
- ))
- }
- const id = i.SeriesModel.extend({
- type: "series.lines3D",
- dependencies: ["globe"],
- visualStyleAccessPath: "lineStyle",
- visualDrawType: "stroke",
- getInitialData: function (e, t) {
- var r = new i.List(["value"], this);
- return r.hasItemOption = !1,
- r.initData(e.data, [], (function (e, t, i, n) {
- if (e instanceof Array)
- return NaN;
- r.hasItemOption = !0;
- var a = e.value;
- return null != a ? a instanceof Array ? a[n] : a : void 0
- }
- )),
- r
- },
- defaultOption: {
- coordinateSystem: "globe",
- globeIndex: 0,
- geo3DIndex: 0,
- zlevel: -10,
- polyline: !1,
- effect: {
- show: !1,
- period: 4,
- trailWidth: 4,
- trailLength: .2,
- spotIntensity: 6
- },
- silent: !0,
- blendMode: "source-over",
- lineStyle: {
- width: 1,
- opacity: .5
- }
- }
- });
- var nd = Po.vec3;
- Ka.Shader.import("@export ecgl.trail2.vertex\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute float dist;\nattribute float distAll;\nattribute float start;\n\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nuniform float speed : 0;\nuniform float trailLength: 0.3;\nuniform float time;\nuniform float period: 1000;\n\nuniform float spotSize: 1;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n\n#ifdef CONSTANT_SPEED\n float t = mod((speed * time + start) / distAll, 1. + trailLength) - trailLength;\n#else\n float t = mod((time + start) / period, 1. + trailLength) - trailLength;\n#endif\n\n float trailLen = distAll * trailLength;\n\n v_Percent = (dist - t * distAll) / trailLen;\n\n v_SpotPercent = spotSize / distAll;\n\n }\n@end\n\n\n@export ecgl.trail2.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float spotIntensity: 5;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n if (v_Percent > 1.0 || v_Percent < 0.0) {\n discard;\n }\n\n float fade = v_Percent;\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n\n if (v_Percent > (1.0 - v_SpotPercent)) {\n gl_FragColor.rgb *= spotIntensity;\n }\n\n gl_FragColor.a *= fade;\n}\n\n@end");
- const ad = Ka.Mesh.extend((function () {
- var e = new Ka.Material({
- shader: new Ka.Shader(Ka.Shader.source("ecgl.trail2.vertex"), Ka.Shader.source("ecgl.trail2.fragment")),
- transparent: !0,
- depthMask: !1
- })
- , t = new Ro({
- dynamic: !0
- });
- return t.createAttribute("dist", "float", 1),
- t.createAttribute("distAll", "float", 1),
- t.createAttribute("start", "float", 1),
- {
- geometry: t,
- material: e,
- culling: !1,
- $ignorePicking: !0
- }
- }
- ), {
- updateData: function (e, t, r) {
- var i = e.hostModel
- , n = this.geometry
- , a = i.getModel("effect")
- , o = a.get("trailWidth") * t.getDevicePixelRatio()
- , s = a.get("trailLength")
- , l = i.get("effect.constantSpeed")
- , h = 1e3 * i.get("effect.period")
- , u = null != l;
- u ? this.material.set("speed", l / 1e3) : this.material.set("period", h),
- this.material[u ? "define" : "undefine"]("vertex", "CONSTANT_SPEED");
- var c = i.get("polyline");
- n.trailLength = s,
- this.material.set("trailLength", s),
- n.resetOffset(),
- ["position", "positionPrev", "positionNext"].forEach((function (e) {
- n.attributes[e].value = r.attributes[e].value
- }
- )),
- ["dist", "distAll", "start", "offset", "color"].forEach((function (e) {
- n.attributes[e].init(n.vertexCount)
- }
- )),
- n.indices = r.indices;
- var d = []
- , f = a.get("trailColor")
- , p = a.get("trailOpacity")
- , m = null != f
- , g = null != p;
- this.updateWorldTransform();
- var _ = this.worldTransform.x.len()
- , v = this.worldTransform.y.len()
- , y = this.worldTransform.z.len()
- , x = 0
- , b = 0;
- e.each((function (t) {
- var i = e.getItemLayout(t)
- , a = g ? p : Rh(e, t)
- , s = Ih(e, t);
- null == a && (a = 1),
- (d = Ka.parseColor(m ? f : s, d))[3] *= a;
- for (var l = c ? r.getPolylineVertexCount(i) : r.getCubicCurveVertexCount(i[0], i[1], i[2], i[3]), w = 0, T = [], S = [], M = x; M < x + l; M++)
- n.attributes.position.get(M, T),
- T[0] *= _,
- T[1] *= v,
- T[2] *= y,
- M > x && (w += nd.dist(T, S)),
- n.attributes.dist.set(M, w),
- nd.copy(S, T);
- b = Math.max(b, w);
- var A = Math.random() * (u ? w : h);
- for (M = x; M < x + l; M++)
- n.attributes.distAll.set(M, w),
- n.attributes.start.set(M, A),
- n.attributes.offset.set(M, (r.attributes.offset.get(M) > 0 ? 1 : -1) * o / 2),
- n.attributes.color.set(M, d);
- x += l
- }
- )),
- this.material.set("spotSize", .1 * b * s),
- this.material.set("spotIntensity", a.get("spotIntensity")),
- n.dirty()
- },
- setAnimationTime: function (e) {
- this.material.set("time", e)
- }
- });
- Ka.Shader.import(is);
- const od = i.ChartView.extend({
- type: "lines3D",
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this._meshLinesMaterial = new Ka.Material({
- shader: Ka.createShader("ecgl.meshLines3D"),
- transparent: !0,
- depthMask: !1
- }),
- this._linesMesh = new Ka.Mesh({
- geometry: new Ro,
- material: this._meshLinesMaterial,
- $ignorePicking: !0
- }),
- this._trailMesh = new ad
- },
- render: function (e, t, r) {
- this.groupGL.add(this._linesMesh);
- var i = e.coordinateSystem
- , n = e.getData();
- if (i && i.viewGL) {
- i.viewGL.add(this.groupGL),
- this._updateLines(e, t, r);
- var a = i.viewGL.isLinearSpace() ? "define" : "undefine";
- this._linesMesh.material[a]("fragment", "SRGB_DECODE"),
- this._trailMesh.material[a]("fragment", "SRGB_DECODE")
- }
- var o = this._trailMesh;
- if (o.stopAnimation(),
- e.get("effect.show")) {
- this.groupGL.add(o),
- o.updateData(n, r, this._linesMesh.geometry),
- o.__time = o.__time || 0;
- var s = 36e5;
- this._curveEffectsAnimator = o.animate("", {
- loop: !0
- }).when(s, {
- __time: s
- }).during((function () {
- o.setAnimationTime(o.__time)
- }
- )).start()
- } else
- this.groupGL.remove(o),
- this._curveEffectsAnimator = null;
- this._linesMesh.material.blend = this._trailMesh.material.blend = "lighter" === e.get("blendMode") ? Ka.additiveBlend : null
- },
- pauseEffect: function () {
- this._curveEffectsAnimator && this._curveEffectsAnimator.pause()
- },
- resumeEffect: function () {
- this._curveEffectsAnimator && this._curveEffectsAnimator.resume()
- },
- toggleEffect: function () {
- var e = this._curveEffectsAnimator;
- e && (e.isPaused() ? e.resume() : e.pause())
- },
- _updateLines: function (e, t, r) {
- var i = e.getData()
- , n = e.coordinateSystem
- , a = this._linesMesh.geometry
- , o = e.get("polyline");
- a.expandLine = !0;
- var s = function (e) {
- return null != e.radius ? e.radius : null != e.size ? Math.max(e.size[0], e.size[1], e.size[2]) : 100
- }(n);
- a.segmentScale = s / 20;
- var l = "lineStyle.width".split(".")
- , h = r.getDevicePixelRatio()
- , u = 0;
- i.each((function (e) {
- var t = i.getItemModel(e).get(l);
- null == t && (t = 1),
- i.setItemVisual(e, "lineWidth", t),
- u = Math.max(t, u)
- }
- )),
- a.useNativeLine = !1;
- var c = 0
- , d = 0;
- i.each((function (e) {
- var t = i.getItemLayout(e);
- o ? (c += a.getPolylineVertexCount(t),
- d += a.getPolylineTriangleCount(t)) : (c += a.getCubicCurveVertexCount(t[0], t[1], t[2], t[3]),
- d += a.getCubicCurveTriangleCount(t[0], t[1], t[2], t[3]))
- }
- )),
- a.setVertexCount(c),
- a.setTriangleCount(d),
- a.resetOffset();
- var f = [];
- i.each((function (e) {
- var t = i.getItemLayout(e)
- , r = Ih(i, e)
- , n = Rh(i, e)
- , s = i.getItemVisual(e, "lineWidth") * h;
- null == n && (n = 1),
- (f = Ka.parseColor(r, f))[3] *= n,
- o ? a.addPolyline(t, f, s) : a.addCubicCurve(t[0], t[1], t[2], t[3], f, s)
- }
- )),
- a.dirty()
- },
- remove: function () {
- this.groupGL.removeAll()
- },
- dispose: function () {
- this.groupGL.removeAll()
- }
- });
- function sd(e, t) {
- for (var r = [], i = 0; i < t.length; i++)
- r.push(e.dataToPoint(t[i]));
- return r
- }
- (0,
- i.use)((function (e) {
- e.registerChartView(od),
- e.registerSeriesModel(id),
- e.registerLayout(rd),
- e.registerAction({
- type: "lines3DPauseEffect",
- event: "lines3deffectpaused",
- update: "series.lines3D:pauseEffect"
- }, (function () { }
- )),
- e.registerAction({
- type: "lines3DResumeEffect",
- event: "lines3deffectresumed",
- update: "series.lines3D:resumeEffect"
- }, (function () { }
- )),
- e.registerAction({
- type: "lines3DToggleEffect",
- event: "lines3deffectchanged",
- update: "series.lines3D:toggleEffect"
- }, (function () { }
- ))
- }
- ));
- var ld = i.SeriesModel.extend({
- type: "series.polygons3D",
- getRegionModel: function (e) {
- return this.getData().getItemModel(e)
- },
- getRegionPolygonCoords: function (e) {
- var t = this.coordinateSystem
- , r = this.getData().getItemModel(e)
- , i = r.option instanceof Array ? r.option : r.getShallow("coords");
- r.get("multiPolygon") || (i = [i]);
- for (var n = [], a = 0; a < i.length; a++) {
- for (var o = [], s = 1; s < i[a].length; s++)
- o.push(sd(t, i[a][s]));
- n.push({
- exterior: sd(t, i[a][0]),
- interiors: o
- })
- }
- return n
- },
- getInitialData: function (e) {
- var t = new i.List(["value"], this);
- return t.hasItemOption = !1,
- t.initData(e.data, [], (function (e, r, i, n) {
- if (e instanceof Array)
- return NaN;
- t.hasItemOption = !0;
- var a = e.value;
- return null != a ? a instanceof Array ? a[n] : a : void 0
- }
- )),
- t
- },
- defaultOption: {
- show: !0,
- data: null,
- multiPolygon: !1,
- progressiveThreshold: 1e3,
- progressive: 1e3,
- zlevel: -10,
- label: {
- show: !1,
- distance: 2,
- textStyle: {
- fontSize: 20,
- color: "#000",
- backgroundColor: "rgba(255,255,255,0.7)",
- padding: 3,
- borderRadius: 4
- }
- },
- itemStyle: {
- color: "#fff",
- borderWidth: 0,
- borderColor: "#333"
- },
- emphasis: {
- itemStyle: {
- color: "#639fc0"
- },
- label: {
- show: !0
- }
- }
- }
- });
- i.util.merge(ld.prototype, Kl);
- const hd = ld
- , ud = i.ChartView.extend({
- type: "polygons3D",
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this._geo3DBuilderList = [],
- this._currentStep = 0
- },
- render: function (e, t, r) {
- this.groupGL.removeAll();
- var i = e.coordinateSystem;
- i && i.viewGL && i.viewGL.add(this.groupGL);
- var n = this._geo3DBuilderList[0];
- n || ((n = new Uh(r)).extrudeY = "mapbox3D" !== i.type && "maptalks3D" !== i.type,
- this._geo3DBuilderList[0] = n),
- this._updateShaderDefines(i, n),
- n.update(e, t, r),
- this._geo3DBuilderList.length = 1,
- this.groupGL.add(n.rootNode)
- },
- incrementalPrepareRender: function (e, t, r) {
- this.groupGL.removeAll();
- var i = e.coordinateSystem;
- i && i.viewGL && i.viewGL.add(this.groupGL),
- this._currentStep = 0
- },
- incrementalRender: function (e, t, r, i) {
- var n = this._geo3DBuilderList[this._currentStep]
- , a = t.coordinateSystem;
- n || ((n = new Uh(i)).extrudeY = "mapbox3D" !== a.type && "maptalks3D" !== a.type,
- this._geo3DBuilderList[this._currentStep] = n),
- n.update(t, r, i, e.start, e.end),
- this.groupGL.add(n.rootNode),
- this._updateShaderDefines(a, n),
- this._currentStep++
- },
- _updateShaderDefines: function (e, t) {
- var r = e.viewGL.isLinearSpace() ? "define" : "undefine";
- t.rootNode.traverse((function (t) {
- t.material && (t.material[r]("fragment", "SRGB_DECODE"),
- "mapbox3D" !== e.type && "maptalks3D" !== e.type || (t.material.define("fragment", "NORMAL_UP_AXIS", 2),
- t.material.define("fragment", "NORMAL_FRONT_AXIS", 1)))
- }
- ))
- },
- remove: function () {
- this.groupGL.removeAll()
- },
- dispose: function () {
- this.groupGL.removeAll(),
- this._geo3DBuilderList.forEach((function (e) {
- e.dispose()
- }
- ))
- }
- });
- (0,
- i.use)((function (e) {
- e.registerChartView(ud),
- e.registerSeriesModel(hd)
- }
- ));
- var cd = i.SeriesModel.extend({
- type: "series.surface",
- dependencies: ["globe", "grid3D", "geo3D"],
- visualStyleAccessPath: "itemStyle",
- formatTooltip: function (e) {
- return oc(this, e)
- },
- getInitialData: function (e, t) {
- var r = e.data;
- function n(e) {
- return !(isNaN(e.min) || isNaN(e.max) || isNaN(e.step))
- }
- function a(e) {
- var t = i.number.getPrecisionSafe;
- return Math.max(t(e.min), t(e.max), t(e.step)) + 1
- }
- if (!r)
- if (e.parametric) {
- var o = e.parametricEquation || {}
- , s = o.u || {}
- , l = o.v || {};
- ["u", "v"].forEach((function (e) {
- n(o[e])
- }
- )),
- ["x", "y", "z"].forEach((function (e) {
- o[e]
- }
- ));
- var h = Math.floor((s.max + s.step - s.min) / s.step)
- , u = Math.floor((l.max + l.step - l.min) / l.step);
- r = new Float32Array(h * u * 5);
- var c = a(s)
- , d = a(l);
- for (S = 0,
- M = 0; M < u; M++)
- for (A = 0; A < h; A++) {
- var f = A * s.step + s.min
- , p = M * l.step + l.min
- , m = i.number.round(Math.min(f, s.max), c)
- , g = i.number.round(Math.min(p, l.max), d);
- E = o.x(m, g),
- C = o.y(m, g),
- P = o.z(m, g),
- r[S++] = E,
- r[S++] = C,
- r[S++] = P,
- r[S++] = m,
- r[S++] = g
- }
- } else {
- var _ = e.equation || {}
- , v = _.x || {}
- , y = _.y || {};
- if (["x", "y"].forEach((function (e) {
- n(_[e])
- }
- )),
- "function" != typeof _.z)
- return;
- var x = Math.floor((v.max + v.step - v.min) / v.step)
- , b = Math.floor((y.max + y.step - y.min) / y.step);
- r = new Float32Array(x * b * 3);
- for (var w = a(v), T = a(y), S = 0, M = 0; M < b; M++)
- for (var A = 0; A < x; A++) {
- var E = A * v.step + v.min
- , C = M * y.step + y.min
- , D = i.number.round(Math.min(E, v.max), w)
- , L = i.number.round(Math.min(C, y.max), T)
- , P = _.z(D, L);
- r[S++] = D,
- r[S++] = L,
- r[S++] = P
- }
- }
- var O = ["x", "y", "z"];
- return e.parametric && O.push("u", "v"),
- sc(this, O, r)
- },
- defaultOption: {
- coordinateSystem: "cartesian3D",
- zlevel: -10,
- grid3DIndex: 0,
- shading: "lambert",
- parametric: !1,
- wireframe: {
- show: !0,
- lineStyle: {
- color: "rgba(0,0,0,0.5)",
- width: 1
- }
- },
- equation: {
- x: {
- min: -1,
- max: 1,
- step: .1
- },
- y: {
- min: -1,
- max: 1,
- step: .1
- },
- z: null
- },
- parametricEquation: {
- u: {
- min: -1,
- max: 1,
- step: .1
- },
- v: {
- min: -1,
- max: 1,
- step: .1
- },
- x: null,
- y: null,
- z: null
- },
- dataShape: null,
- itemStyle: {},
- animationDurationUpdate: 500
- }
- });
- i.util.merge(cd.prototype, Kl);
- const dd = cd;
- var fd = Po.vec3;
- const pd = i.ChartView.extend({
- type: "surface",
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node
- },
- render: function (e, t, r) {
- var i = this._prevSurfaceMesh;
- this._prevSurfaceMesh = this._surfaceMesh,
- this._surfaceMesh = i,
- this._surfaceMesh || (this._surfaceMesh = this._createSurfaceMesh()),
- this.groupGL.remove(this._prevSurfaceMesh),
- this.groupGL.add(this._surfaceMesh);
- var n = e.coordinateSystem
- , a = e.get("shading")
- , o = e.getData()
- , s = "ecgl." + a;
- if (this._surfaceMesh.material && this._surfaceMesh.material.shader.name === s || (this._surfaceMesh.material = Ka.createMaterial(s, ["VERTEX_COLOR", "DOUBLE_SIDED"])),
- Ka.setMaterialFromModel(a, this._surfaceMesh.material, e, r),
- n && n.viewGL) {
- n.viewGL.add(this.groupGL);
- var l = n.viewGL.isLinearSpace() ? "define" : "undefine";
- this._surfaceMesh.material[l]("fragment", "SRGB_DECODE")
- }
- var h = e.get("parametric")
- , u = e.get("dataShape");
- u || (u = this._getDataShape(o, h));
- var c = e.getModel("wireframe")
- , d = c.get("lineStyle.width")
- , f = c.get("show") && d > 0;
- this._updateSurfaceMesh(this._surfaceMesh, e, u, f);
- var p = this._surfaceMesh.material;
- f ? (p.define("WIREFRAME_QUAD"),
- p.set("wireframeLineWidth", d),
- p.set("wireframeLineColor", Ka.parseColor(c.get("lineStyle.color")))) : p.undefine("WIREFRAME_QUAD"),
- this._initHandler(e, r),
- this._updateAnimation(e)
- },
- _updateAnimation: function (e) {
- Ka.updateVertexAnimation([["prevPosition", "position"], ["prevNormal", "normal"]], this._prevSurfaceMesh, this._surfaceMesh, e)
- },
- _createSurfaceMesh: function () {
- var e = new Ka.Mesh({
- geometry: new Ka.Geometry({
- dynamic: !0,
- sortTriangles: !0
- }),
- shadowDepthMaterial: new Ka.Material({
- shader: new Ka.Shader(Ka.Shader.source("ecgl.sm.depth.vertex"), Ka.Shader.source("ecgl.sm.depth.fragment"))
- }),
- culling: !1,
- renderOrder: 10,
- renderNormal: !0
- });
- return e.geometry.createAttribute("barycentric", "float", 4),
- e.geometry.createAttribute("prevPosition", "float", 3),
- e.geometry.createAttribute("prevNormal", "float", 3),
- Object.assign(e.geometry, Nh),
- e
- },
- _initHandler: function (e, t) {
- var r = e.getData()
- , i = this._surfaceMesh
- , n = e.coordinateSystem;
- i.seriesIndex = e.seriesIndex;
- var a = -1;
- i.off("mousemove"),
- i.off("mouseout"),
- i.on("mousemove", (function (e) {
- var o = function (e, t) {
- for (var r = 1 / 0, n = -1, a = [], o = 0; o < e.length; o++) {
- i.geometry.attributes.position.get(e[o], a);
- var s = fd.dist(t.array, a);
- s < r && (r = s,
- n = e[o])
- }
- return n
- }(e.triangle, e.point);
- if (o >= 0) {
- var s = [];
- i.geometry.attributes.position.get(o, s);
- for (var l = n.pointToData(s), h = 1 / 0, u = -1, c = [], d = 0; d < r.count(); d++) {
- c[0] = r.get("x", d),
- c[1] = r.get("y", d),
- c[2] = r.get("z", d);
- var f = fd.squaredDistance(c, l);
- f < h && (u = d,
- h = f)
- }
- u !== a && t.dispatchAction({
- type: "grid3DShowAxisPointer",
- value: l
- }),
- a = u,
- i.dataIndex = u
- } else
- i.dataIndex = -1
- }
- ), this),
- i.on("mouseout", (function (e) {
- a = -1,
- i.dataIndex = -1,
- t.dispatchAction({
- type: "grid3DHideAxisPointer"
- })
- }
- ), this)
- },
- _updateSurfaceMesh: function (e, t, r, i) {
- var n = e.geometry
- , a = t.getData()
- , o = a.getLayout("points")
- , s = 0;
- a.each((function (e) {
- a.hasValue(e) || s++
- }
- ));
- var l = s || i
- , h = n.attributes.position
- , u = n.attributes.normal
- , c = n.attributes.texcoord0
- , d = n.attributes.barycentric
- , f = n.attributes.color
- , p = r[0]
- , m = r[1]
- , g = "color" !== t.get("shading");
- if (l) {
- var _ = (p - 1) * (m - 1) * 4;
- h.init(_),
- i && d.init(_)
- } else
- h.value = new Float32Array(o);
- f.init(n.vertexCount),
- c.init(n.vertexCount);
- var v, y = [0, 3, 1, 1, 3, 2], x = [[1, 1, 0, 0], [0, 1, 0, 1], [1, 0, 0, 1], [1, 0, 1, 0]], b = n.indices = new (n.vertexCount > 65535 ? Uint32Array : Uint16Array)((p - 1) * (m - 1) * 6), w = function (e, t, r) {
- r[1] = e * m + t,
- r[0] = e * m + t + 1,
- r[3] = (e + 1) * m + t + 1,
- r[2] = (e + 1) * m + t
- }, T = !1;
- if (l) {
- var S = []
- , M = []
- , A = 0;
- g ? u.init(n.vertexCount) : u.value = null;
- for (var E = [[], [], []], C = [], D = [], L = fd.create(), P = function (e, t, r) {
- var i = 3 * t;
- return r[0] = e[i],
- r[1] = e[i + 1],
- r[2] = e[i + 2],
- r
- }, O = new Float32Array(o.length), N = new Float32Array(o.length / 3 * 4), I = 0; I < a.count(); I++)
- if (a.hasValue(I)) {
- var R = Ka.parseColor(Ih(a, I));
- null != (X = Rh(a, I)) && (R[3] *= X),
- R[3] < .99 && (T = !0);
- for (var B = 0; B < 4; B++)
- N[4 * I + B] = R[B]
- }
- var F = [1e7, 1e7, 1e7];
- for (I = 0; I < p - 1; I++)
- for (var z = 0; z < m - 1; z++) {
- var G = 4 * (I * (m - 1) + z);
- w(I, z, S);
- var U = !1;
- for (B = 0; B < 4; B++)
- P(o, S[B], M),
- v = M,
- (isNaN(v[0]) || isNaN(v[1]) || isNaN(v[2])) && (U = !0);
- for (B = 0; B < 4; B++)
- U ? h.set(G + B, F) : (P(o, S[B], M),
- h.set(G + B, M)),
- i && d.set(G + B, x[B]);
- for (B = 0; B < 6; B++)
- b[A++] = y[B] + G;
- if (g && !U)
- for (B = 0; B < 2; B++) {
- for (var k = 3 * B, V = 0; V < 3; V++)
- P(o, j = S[y[k] + V], E[V]);
- for (fd.sub(C, E[0], E[1]),
- fd.sub(D, E[1], E[2]),
- fd.cross(L, C, D),
- V = 0; V < 3; V++) {
- var H = 3 * S[y[k] + V];
- O[H] = O[H] + L[0],
- O[H + 1] = O[H + 1] + L[1],
- O[H + 2] = O[H + 2] + L[2]
- }
- }
- }
- if (g)
- for (I = 0; I < O.length / 3; I++)
- P(O, I, L),
- fd.normalize(L, L),
- O[3 * I] = L[0],
- O[3 * I + 1] = L[1],
- O[3 * I + 2] = L[2];
- R = [];
- var W = [];
- for (I = 0; I < p - 1; I++)
- for (z = 0; z < m - 1; z++)
- for (G = 4 * (I * (m - 1) + z),
- w(I, z, S),
- B = 0; B < 4; B++) {
- for (V = 0; V < 4; V++)
- R[V] = N[4 * S[B] + V];
- f.set(G + B, R),
- g && (P(O, S[B], L),
- u.set(G + B, L));
- var j = S[B];
- W[0] = j % m / (m - 1),
- W[1] = Math.floor(j / m) / (p - 1),
- c.set(G + B, W)
- }
- } else {
- for (W = [],
- I = 0; I < a.count(); I++) {
- var X;
- W[0] = I % m / (m - 1),
- W[1] = Math.floor(I / m) / (p - 1),
- R = Ka.parseColor(Ih(a, I)),
- null != (X = Rh(a, I)) && (R[3] *= X),
- R[3] < .99 && (T = !0),
- f.set(I, R),
- c.set(I, W)
- }
- S = [];
- var q = 0;
- for (I = 0; I < p - 1; I++)
- for (z = 0; z < m - 1; z++)
- for (w(I, z, S),
- B = 0; B < 6; B++)
- b[q++] = S[y[B]];
- g ? n.generateVertexNormals() : u.value = null
- }
- e.material.get("normalMap") && n.generateTangents(),
- n.updateBoundingBox(),
- n.dirty(),
- e.material.transparent = T,
- e.material.depthMask = !T
- },
- _getDataShape: function (e, t) {
- for (var r = -1 / 0, i = 0, n = 0, a = !1, o = t ? "u" : "x", s = e.count(), l = 0; l < s; l++) {
- var h = e.get(o, l);
- h < r && (n = 0,
- i++),
- r = h,
- n++
- }
- if (i && 1 !== n || (a = !0),
- !a)
- return [i + 1, n];
- for (var u = Math.floor(Math.sqrt(s)); u > 0;) {
- if (Math.floor(s / u) === s / u)
- return [u, s / u];
- u--
- }
- return [u = Math.floor(Math.sqrt(s)), u]
- },
- dispose: function () {
- this.groupGL.removeAll()
- },
- remove: function () {
- this.groupGL.removeAll()
- }
- });
- function md(e, t) {
- for (var r = [], i = 0; i < t.length; i++)
- r.push(e.dataToPoint(t[i]));
- return r
- }
- (0,
- i.use)((function (e) {
- e.registerChartView(pd),
- e.registerSeriesModel(dd),
- e.registerLayout((function (e, t) {
- e.eachSeriesByType("surface", (function (e) {
- var t = e.coordinateSystem;
- t && t.type;
- var r = e.getData()
- , i = new Float32Array(3 * r.count())
- , n = [NaN, NaN, NaN];
- if (t && "cartesian3D" === t.type) {
- var a = t.dimensions.map((function (t) {
- return e.coordDimToDataDim(t)[0]
- }
- ));
- r.each(a, (function (e, a, o, s) {
- var l;
- l = r.hasValue(s) ? t.dataToPoint([e, a, o]) : n,
- i[3 * s] = l[0],
- i[3 * s + 1] = l[1],
- i[3 * s + 2] = l[2]
- }
- ))
- }
- r.setLayout("points", i)
- }
- ))
- }
- ))
- }
- ));
- var gd = i.SeriesModel.extend({
- type: "series.map3D",
- layoutMode: "box",
- coordinateSystem: null,
- visualStyleAccessPath: "itemStyle",
- optionUpdated: function (e) {
- e = e || {};
- var t = this.get("coordinateSystem");
- null != t && "geo3D" !== t && (this.get("groundPlane.show") && (this.option.groundPlane.show = !1),
- this._geo = null)
- },
- getInitialData: function (e) {
- e.data = this.getFilledRegions(e.data, e.map);
- var t = i.helper.createDimensions(e.data, {
- coordDimensions: ["value"]
- })
- , r = new i.List(t, this);
- r.initData(e.data);
- var n = {};
- return r.each((function (e) {
- var t = r.getName(e)
- , i = r.getItemModel(e);
- n[t] = i
- }
- )),
- this._regionModelMap = n,
- r
- },
- formatTooltip: function (e) {
- return oc(this, e)
- },
- getRegionModel: function (e) {
- var t = this.getData().getName(e);
- return this._regionModelMap[t] || new i.Model(null, this)
- },
- getRegionPolygonCoords: function (e) {
- var t = this.coordinateSystem
- , r = this.getData().getName(e);
- if (t.transform)
- return (i = t.getRegion(r)) ? i.geometries : [];
- this._geo || (this._geo = $h.createGeo3D(this));
- for (var i = this._geo.getRegion(r), n = [], a = 0; a < i.geometries.length; a++) {
- var o = i.geometries[a]
- , s = []
- , l = md(t, o.exterior);
- if (s && s.length)
- for (var h = 0; h < o.interiors.length; h++)
- s.push(md(t, s[h]));
- n.push({
- interiors: s,
- exterior: l
- })
- }
- return n
- },
- getFormattedLabel: function (e, t) {
- var r = ac.getFormattedLabel(this, e, t);
- return null == r && (r = this.getData().getName(e)),
- r
- },
- defaultOption: {
- coordinateSystem: "geo3D",
- data: null
- }
- });
- i.util.merge(gd.prototype, Ql),
- i.util.merge(gd.prototype, uo),
- i.util.merge(gd.prototype, co),
- i.util.merge(gd.prototype, fo),
- i.util.merge(gd.prototype, Kl);
- const _d = gd
- , vd = i.ChartView.extend({
- type: "map3D",
- __ecgl__: !0,
- init: function (e, t) {
- this._geo3DBuilder = new Uh(t),
- this.groupGL = new Ka.Node
- },
- render: function (e, t, r) {
- var i = e.coordinateSystem;
- if (i && i.viewGL) {
- if (this.groupGL.add(this._geo3DBuilder.rootNode),
- i.viewGL.add(this.groupGL),
- "geo3D" === i.type) {
- this._sceneHelper || (this._sceneHelper = new Uo,
- this._sceneHelper.initLight(this.groupGL)),
- this._sceneHelper.setScene(i.viewGL.scene),
- this._sceneHelper.updateLight(e),
- i.viewGL.setPostEffect(e.getModel("postEffect"), r),
- i.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));
- var n = this._control;
- n || (n = this._control = new Do({
- zr: r.getZr()
- }),
- this._control.init());
- var a = e.getModel("viewControl");
- n.setViewGL(i.viewGL),
- n.setFromViewControlModel(a, 0),
- n.off("update"),
- n.on("update", (function () {
- r.dispatchAction({
- type: "map3DChangeCamera",
- alpha: n.getAlpha(),
- beta: n.getBeta(),
- distance: n.getDistance(),
- from: this.uid,
- map3DId: e.id
- })
- }
- )),
- this._geo3DBuilder.extrudeY = !0
- } else
- this._control && (this._control.dispose(),
- this._control = null),
- this._sceneHelper && (this._sceneHelper.dispose(),
- this._sceneHelper = null),
- e.getData().getLayout("geo3D"),
- this._geo3DBuilder.extrudeY = !1;
- this._geo3DBuilder.update(e, t, r, 0, e.getData().count());
- var o = i.viewGL.isLinearSpace() ? "define" : "undefine";
- this._geo3DBuilder.rootNode.traverse((function (e) {
- e.material && e.material[o]("fragment", "SRGB_DECODE")
- }
- ))
- }
- },
- afterRender: function (e, t, r, i) {
- var n = i.renderer
- , a = e.coordinateSystem;
- a && "geo3D" === a.type && (this._sceneHelper.updateAmbientCubemap(n, e, r),
- this._sceneHelper.updateSkybox(n, e, r))
- },
- dispose: function () {
- this.groupGL.removeAll(),
- this._control.dispose(),
- this._geo3DBuilder.dispose()
- }
- });
- (0,
- i.use)((function (e) {
- eu(e),
- e.registerChartView(vd),
- e.registerSeriesModel(_d),
- e.registerAction({
- type: "map3DChangeCamera",
- event: "map3dcamerachanged",
- update: "series:updateCamera"
- }, (function (e, t) {
- t.eachComponent({
- mainType: "series",
- subType: "map3D",
- query: e
- }, (function (t) {
- t.setView(e)
- }
- ))
- }
- ))
- }
- ));
- const yd = i.SeriesModel.extend({
- type: "series.scatterGL",
- dependencies: ["grid", "polar", "geo", "singleAxis"],
- visualStyleAccessPath: "itemStyle",
- hasSymbolVisual: !0,
- getInitialData: function () {
- return i.helper.createList(this)
- },
- defaultOption: {
- coordinateSystem: "cartesian2d",
- zlevel: 10,
- progressive: 1e5,
- progressiveThreshold: 1e5,
- large: !1,
- symbol: "circle",
- symbolSize: 10,
- zoomScale: 0,
- blendMode: "source-over",
- itemStyle: {
- opacity: .8
- },
- postEffect: {
- enable: !1,
- colorCorrection: {
- exposure: 0,
- brightness: 0,
- contrast: 1,
- saturation: 1,
- enable: !0
- }
- }
- }
- });
- function xd(e, t, r) {
- var i = t[0]
- , n = t[1];
- return e[0] = r[0] * i + r[2] * n + r[4],
- e[1] = r[1] * i + r[3] * n + r[5],
- e
- }
- function bd(e) {
- this.viewGL = e
- }
- bd.prototype.reset = function (e, t) {
- this._updateCamera(t.getWidth(), t.getHeight(), t.getDevicePixelRatio()),
- this._viewTransform = [1, 0, 0, 1, 0, 0],
- this.updateTransform(e, t)
- }
- ,
- bd.prototype.updateTransform = function (e, t) {
- var r, i, n, a, o, s, l, h, u, c = e.coordinateSystem;
- c.getRoamTransform && (r = this._viewTransform,
- n = (i = c.getRoamTransform())[0],
- a = i[2],
- o = i[4],
- s = i[1],
- l = i[3],
- h = i[5],
- (u = n * l - s * a) && (u = 1 / u,
- r[0] = l * u,
- r[1] = -s * u,
- r[2] = -a * u,
- r[3] = n * u,
- r[4] = (a * h - l * o) * u,
- r[5] = (s * o - n * h) * u),
- this._setCameraTransform(this._viewTransform),
- t.getZr().refresh())
- }
- ,
- bd.prototype.dataToPoint = function (e, t, r) {
- r = e.dataToPoint(t, null, r);
- var i = this._viewTransform;
- i && xd(r, r, i)
- }
- ,
- bd.prototype.removeTransformInPoint = function (e) {
- return this._viewTransform && xd(e, e, this._viewTransform),
- e
- }
- ,
- bd.prototype.getZoom = function () {
- if (this._viewTransform) {
- var e = this._viewTransform;
- return 1 / Math.max(Math.sqrt(e[0] * e[0] + e[1] * e[1]), Math.sqrt(e[2] * e[2] + e[3] * e[3]))
- }
- return 1
- }
- ,
- bd.prototype._setCameraTransform = function (e) {
- var t = this.viewGL.camera;
- t.position.set(e[4], e[5], 0),
- t.scale.set(Math.sqrt(e[0] * e[0] + e[1] * e[1]), Math.sqrt(e[2] * e[2] + e[3] * e[3]), 1)
- }
- ,
- bd.prototype._updateCamera = function (e, t, r) {
- this.viewGL.setViewport(0, 0, e, t, r);
- var i = this.viewGL.camera;
- i.left = i.top = 0,
- i.bottom = t,
- i.right = e,
- i.near = 0,
- i.far = 100
- }
- ;
- const wd = bd
- , Td = i.ChartView.extend({
- type: "scatterGL",
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this.viewGL = new Il("orthographic"),
- this.viewGL.add(this.groupGL),
- this._pointsBuilderList = [],
- this._currentStep = 0,
- this._sizeScale = 1,
- this._glViewHelper = new wd(this.viewGL)
- },
- render: function (e, t, r) {
- if (this.groupGL.removeAll(),
- this._glViewHelper.reset(e, r),
- e.getData().count()) {
- var i = this._pointsBuilderList[0];
- i || (i = this._pointsBuilderList[0] = new Fc(!0, r)),
- this._pointsBuilderList.length = 1,
- this.groupGL.add(i.rootNode),
- this._removeTransformInPoints(e.getData().getLayout("points")),
- i.update(e, t, r),
- this.viewGL.setPostEffect(e.getModel("postEffect"), r)
- }
- },
- incrementalPrepareRender: function (e, t, r) {
- this.groupGL.removeAll(),
- this._glViewHelper.reset(e, r),
- this._currentStep = 0,
- this.viewGL.setPostEffect(e.getModel("postEffect"), r)
- },
- incrementalRender: function (e, t, r, i) {
- if (!(e.end <= e.start)) {
- var n = this._pointsBuilderList[this._currentStep];
- n || (n = new Fc(!0, i),
- this._pointsBuilderList[this._currentStep] = n),
- this.groupGL.add(n.rootNode),
- this._removeTransformInPoints(t.getData().getLayout("points")),
- n.setSizeScale(this._sizeScale),
- n.update(t, r, i, e.start, e.end),
- i.getZr().refresh(),
- this._currentStep++
- }
- },
- updateTransform: function (e, t, r) {
- if (e.coordinateSystem.getRoamTransform) {
- this._glViewHelper.updateTransform(e, r);
- var i = this._glViewHelper.getZoom()
- , n = Math.max((e.get("zoomScale") || 0) * (i - 1) + 1, 0);
- this._sizeScale = n,
- this._pointsBuilderList.forEach((function (e) {
- e.setSizeScale(n)
- }
- ))
- }
- },
- _removeTransformInPoints: function (e) {
- if (e)
- for (var t = [], r = 0; r < e.length; r += 2)
- t[0] = e[r],
- t[1] = e[r + 1],
- this._glViewHelper.removeTransformInPoint(t),
- e[r] = t[0],
- e[r + 1] = t[1]
- },
- dispose: function () {
- this.groupGL.removeAll(),
- this._pointsBuilderList.forEach((function (e) {
- e.dispose()
- }
- ))
- },
- remove: function () {
- this.groupGL.removeAll()
- }
- });
- function Sd(e) {
- return "_EC_" + e
- }
- (0,
- i.use)((function (e) {
- e.registerChartView(Td),
- e.registerSeriesModel(yd),
- e.registerLayout({
- seriesType: "scatterGL",
- reset: function (e) {
- var t, r = e.coordinateSystem, i = e.getData();
- if (r) {
- var n = r.dimensions.map((function (e) {
- return i.mapDimension(e)
- }
- )).slice(0, 2)
- , a = [];
- 1 === n.length ? t = function (e) {
- for (var t = new Float32Array(2 * (e.end - e.start)), a = e.start; a < e.end; a++) {
- var o = 2 * (a - e.start)
- , s = i.get(n[0], a)
- , l = r.dataToPoint(s);
- t[o] = l[0],
- t[o + 1] = l[1]
- }
- i.setLayout("points", t)
- }
- : 2 === n.length && (t = function (e) {
- for (var t = new Float32Array(2 * (e.end - e.start)), o = e.start; o < e.end; o++) {
- var s = 2 * (o - e.start)
- , l = i.get(n[0], o)
- , h = i.get(n[1], o);
- a[0] = l,
- a[1] = h,
- a = r.dataToPoint(a),
- t[s] = a[0],
- t[s + 1] = a[1]
- }
- i.setLayout("points", t)
- }
- )
- }
- return {
- progress: t
- }
- }
- })
- }
- ));
- var Md = function () {
- function e(e) {
- this.type = "graph",
- this.nodes = [],
- this.edges = [],
- this._nodesMap = {},
- this._edgesMap = {},
- this._directed = e || !1
- }
- return e.prototype.isDirected = function () {
- return this._directed
- }
- ,
- e.prototype.addNode = function (e, t) {
- e = null == e ? "" + t : "" + e;
- var r = this._nodesMap;
- if (!r[Sd(e)]) {
- var i = new Ad(e, t);
- return i.hostGraph = this,
- this.nodes.push(i),
- r[Sd(e)] = i,
- i
- }
- }
- ,
- e.prototype.getNodeByIndex = function (e) {
- var t = this.data.getRawIndex(e);
- return this.nodes[t]
- }
- ,
- e.prototype.getNodeById = function (e) {
- return this._nodesMap[Sd(e)]
- }
- ,
- e.prototype.addEdge = function (e, t, r) {
- var i = this._nodesMap
- , n = this._edgesMap;
- if ("number" == typeof e && (e = this.nodes[e]),
- "number" == typeof t && (t = this.nodes[t]),
- e instanceof Ad || (e = i[Sd(e)]),
- t instanceof Ad || (t = i[Sd(t)]),
- e && t) {
- var a = e.id + "-" + t.id
- , o = new Ed(e, t, r);
- return o.hostGraph = this,
- this._directed && (e.outEdges.push(o),
- t.inEdges.push(o)),
- e.edges.push(o),
- e !== t && t.edges.push(o),
- this.edges.push(o),
- n[a] = o,
- o
- }
- }
- ,
- e.prototype.getEdgeByIndex = function (e) {
- var t = this.edgeData.getRawIndex(e);
- return this.edges[t]
- }
- ,
- e.prototype.getEdge = function (e, t) {
- e instanceof Ad && (e = e.id),
- t instanceof Ad && (t = t.id);
- var r = this._edgesMap;
- return this._directed ? r[e + "-" + t] : r[e + "-" + t] || r[t + "-" + e]
- }
- ,
- e.prototype.eachNode = function (e, t) {
- for (var r = this.nodes, i = r.length, n = 0; n < i; n++)
- r[n].dataIndex >= 0 && e.call(t, r[n], n)
- }
- ,
- e.prototype.eachEdge = function (e, t) {
- for (var r = this.edges, i = r.length, n = 0; n < i; n++)
- r[n].dataIndex >= 0 && r[n].node1.dataIndex >= 0 && r[n].node2.dataIndex >= 0 && e.call(t, r[n], n)
- }
- ,
- e.prototype.breadthFirstTraverse = function (e, t, r, i) {
- if (t instanceof Ad || (t = this._nodesMap[Sd(t)]),
- t) {
- for (var n = "out" === r ? "outEdges" : "in" === r ? "inEdges" : "edges", a = 0; a < this.nodes.length; a++)
- this.nodes[a].__visited = !1;
- if (!e.call(i, t, null))
- for (var o = [t]; o.length;) {
- var s = o.shift()
- , l = s[n];
- for (a = 0; a < l.length; a++) {
- var h = l[a]
- , u = h.node1 === s ? h.node2 : h.node1;
- if (!u.__visited) {
- if (e.call(i, u, s))
- return;
- o.push(u),
- u.__visited = !0
- }
- }
- }
- }
- }
- ,
- e.prototype.update = function () {
- for (var e = this.data, t = this.edgeData, r = this.nodes, i = this.edges, n = 0, a = r.length; n < a; n++)
- r[n].dataIndex = -1;
- for (n = 0,
- a = e.count(); n < a; n++)
- r[e.getRawIndex(n)].dataIndex = n;
- for (t.filterSelf((function (e) {
- var r = i[t.getRawIndex(e)];
- return r.node1.dataIndex >= 0 && r.node2.dataIndex >= 0
- }
- )),
- n = 0,
- a = i.length; n < a; n++)
- i[n].dataIndex = -1;
- for (n = 0,
- a = t.count(); n < a; n++)
- i[t.getRawIndex(n)].dataIndex = n
- }
- ,
- e.prototype.clone = function () {
- for (var t = new e(this._directed), r = this.nodes, i = this.edges, n = 0; n < r.length; n++)
- t.addNode(r[n].id, r[n].dataIndex);
- for (n = 0; n < i.length; n++) {
- var a = i[n];
- t.addEdge(a.node1.id, a.node2.id, a.dataIndex)
- }
- return t
- }
- ,
- e
- }()
- , Ad = function () {
- function e(e, t) {
- this.inEdges = [],
- this.outEdges = [],
- this.edges = [],
- this.dataIndex = -1,
- this.id = null == e ? "" : e,
- this.dataIndex = null == t ? -1 : t
- }
- return e.prototype.degree = function () {
- return this.edges.length
- }
- ,
- e.prototype.inDegree = function () {
- return this.inEdges.length
- }
- ,
- e.prototype.outDegree = function () {
- return this.outEdges.length
- }
- ,
- e.prototype.getModel = function (e) {
- if (!(this.dataIndex < 0))
- return this.hostGraph.data.getItemModel(this.dataIndex).getModel(e)
- }
- ,
- e.prototype.getAdjacentDataIndices = function () {
- for (var e = {
- edge: [],
- node: []
- }, t = 0; t < this.edges.length; t++) {
- var r = this.edges[t];
- r.dataIndex < 0 || (e.edge.push(r.dataIndex),
- e.node.push(r.node1.dataIndex, r.node2.dataIndex))
- }
- return e
- }
- ,
- e
- }()
- , Ed = function () {
- function e(e, t, r) {
- this.dataIndex = -1,
- this.node1 = e,
- this.node2 = t,
- this.dataIndex = null == r ? -1 : r
- }
- return e.prototype.getModel = function (e) {
- if (!(this.dataIndex < 0))
- return this.hostGraph.edgeData.getItemModel(this.dataIndex).getModel(e)
- }
- ,
- e.prototype.getAdjacentDataIndices = function () {
- return {
- edge: [this.dataIndex],
- node: [this.node1.dataIndex, this.node2.dataIndex]
- }
- }
- ,
- e
- }();
- function Cd(e, t) {
- return {
- getValue: function (r) {
- var i = this[e][t];
- return i.get(i.getDimension(r || "value"), this.dataIndex)
- },
- setVisual: function (r, i) {
- this.dataIndex >= 0 && this[e][t].setItemVisual(this.dataIndex, r, i)
- },
- getVisual: function (r) {
- return this[e][t].getItemVisual(this.dataIndex, r)
- },
- setLayout: function (r, i) {
- this.dataIndex >= 0 && this[e][t].setItemLayout(this.dataIndex, r, i)
- },
- getLayout: function () {
- return this[e][t].getItemLayout(this.dataIndex)
- },
- getGraphicEl: function () {
- return this[e][t].getItemGraphicEl(this.dataIndex)
- },
- getRawIndex: function () {
- return this[e][t].getRawIndex(this.dataIndex)
- }
- }
- }
- _a(Ad, Cd("hostGraph", "data")),
- _a(Ed, Cd("hostGraph", "edgeData"));
- const Dd = Md;
- var Ld = _o();
- function Pd(e, t) {
- if (Ld(this).mainData === this) {
- var r = ga({}, Ld(this).datas);
- r[this.dataType] = t,
- Bd(t, r, e)
- } else
- Fd(t, this.dataType, Ld(this).mainData, e);
- return t
- }
- function Od(e, t) {
- return e.struct && e.struct.update(),
- t
- }
- function Nd(e, t) {
- return ya(Ld(t).datas, (function (r, i) {
- r !== t && Fd(r.cloneShallow(), i, t, e)
- }
- )),
- t
- }
- function Id(e) {
- var t = Ld(this).mainData;
- return null == e || null == t ? t : Ld(t).datas[e]
- }
- function Rd() {
- var e = Ld(this).mainData;
- return null == e ? [{
- data: e
- }] : xa(ba(Ld(e).datas), (function (t) {
- return {
- type: t,
- data: Ld(e).datas[t]
- }
- }
- ))
- }
- function Bd(e, t, r) {
- Ld(e).datas = {},
- ya(t, (function (t, i) {
- Fd(t, i, e, r)
- }
- ))
- }
- function Fd(e, t, r, i) {
- Ld(r).datas[t] = e,
- Ld(e).mainData = r,
- e.dataType = t,
- i.struct && (e[i.structAttr] = i.struct,
- i.struct[i.datasAttr[t]] = e),
- e.getLinkedData = Id,
- e.getLinkedDataAll = Rd
- }
- var zd = i.SeriesModel.extend({
- type: "series.graphGL",
- visualStyleAccessPath: "itemStyle",
- hasSymbolVisual: !0,
- init: function (e) {
- zd.superApply(this, "init", arguments),
- this.legendDataProvider = function () {
- return this._categoriesData
- }
- ,
- this._updateCategoriesData()
- },
- mergeOption: function (e) {
- zd.superApply(this, "mergeOption", arguments),
- this._updateCategoriesData()
- },
- getFormattedLabel: function (e, t, r, i) {
- var n = ac.getFormattedLabel(this, e, t, r, i);
- if (null == n) {
- var a = this.getData()
- , o = a.dimensions[a.dimensions.length - 1];
- n = a.get(o, e)
- }
- return n
- },
- getInitialData: function (e, t) {
- var r = e.edges || e.links || []
- , n = e.data || e.nodes || []
- , a = this;
- if (n && r)
- return function (e, t, r, n, a) {
- for (var o = new Dd(!0), s = 0; s < e.length; s++)
- o.addNode(Mn(e[s].id, e[s].name, s), s);
- var l, h = [], u = [], c = 0;
- for (s = 0; s < t.length; s++) {
- var d = t[s]
- , f = d.source
- , p = d.target;
- o.addEdge(f, p, c) && (u.push(d),
- h.push(Mn(d.id, f + " > " + p)),
- c++)
- }
- var m = i.helper.createDimensions(e, {
- coordDimensions: ["value"]
- });
- (l = new i.List(m, r)).initData(e);
- var g, _, v, y = new i.List(["value"], r);
- return y.initData(u, h),
- a && a(l, y),
- _ = (g = {
- mainData: l,
- struct: o,
- structAttr: "graph",
- datas: {
- node: l,
- edge: y
- },
- datasAttr: {
- node: "data",
- edge: "edgeData"
- }
- }).mainData,
- (v = g.datas) || (v = {
- main: _
- },
- g.datasAttr = {
- main: "data"
- }),
- g.datas = g.mainData = null,
- Bd(_, v, g),
- ya(v, (function (e) {
- ya(_.TRANSFERABLE_METHODS, (function (t) {
- e.wrapMethod(t, wa(Pd, g))
- }
- ))
- }
- )),
- _.wrapMethod("cloneShallow", wa(Nd, g)),
- ya(_.CHANGABLE_METHODS, (function (e) {
- _.wrapMethod(e, wa(Od, g))
- }
- )),
- function (e, t) {
- if (!e)
- throw new Error(void 0)
- }(v[_.dataType] === _),
- o.update(),
- o
- }(n, r, this, 0, (function (e, r) {
- e.wrapMethod("getItemModel", (function (e) {
- const t = a._categoriesModels[e.getShallow("category")];
- return t && (t.parentModel = e.parentModel,
- e.parentModel = t),
- e
- }
- ));
- const i = t.getModel([]).getModel;
- function n(e, t) {
- const r = i.call(this, e, t);
- return r.resolveParentPath = o,
- r
- }
- function o(e) {
- if (e && ("label" === e[0] || "label" === e[1])) {
- const t = e.slice();
- return "label" === e[0] ? t[0] = "edgeLabel" : "label" === e[1] && (t[1] = "edgeLabel"),
- t
- }
- return e
- }
- r.wrapMethod("getItemModel", (function (e) {
- return e.resolveParentPath = o,
- e.getModel = n,
- e
- }
- ))
- }
- )).data
- },
- getGraph: function () {
- return this.getData().graph
- },
- getEdgeData: function () {
- return this.getGraph().edgeData
- },
- getCategoriesData: function () {
- return this._categoriesData
- },
- formatTooltip: function (e, t, r) {
- if ("edge" === r) {
- var n = this.getData()
- , a = this.getDataParams(e, r)
- , o = n.graph.getEdgeByIndex(e)
- , s = n.getName(o.node1.dataIndex)
- , l = n.getName(o.node2.dataIndex)
- , h = [];
- return null != s && h.push(s),
- null != l && h.push(l),
- h = i.format.encodeHTML(h.join(" > ")),
- a.value && (h += " : " + i.format.encodeHTML(a.value)),
- h
- }
- return zd.superApply(this, "formatTooltip", arguments)
- },
- _updateCategoriesData: function () {
- var e = (this.option.categories || []).map((function (e) {
- return null != e.value ? e : Object.assign({
- value: 0
- }, e)
- }
- ))
- , t = new i.List(["value"], this);
- t.initData(e),
- this._categoriesData = t,
- this._categoriesModels = t.mapArray((function (e) {
- return t.getItemModel(e, !0)
- }
- ))
- },
- setView: function (e) {
- null != e.zoom && (this.option.zoom = e.zoom),
- null != e.offset && (this.option.offset = e.offset)
- },
- setNodePosition: function (e) {
- for (var t = 0; t < e.length / 2; t++) {
- var r = e[2 * t]
- , i = e[2 * t + 1]
- , n = this.getData().getRawDataItem(t);
- n.x = r,
- n.y = i
- }
- },
- isAnimationEnabled: function () {
- return zd.superCall(this, "isAnimationEnabled") && !("force" === this.get("layout") && this.get("force.layoutAnimation"))
- },
- defaultOption: {
- zlevel: 10,
- z: 2,
- legendHoverLink: !0,
- layout: "forceAtlas2",
- forceAtlas2: {
- initLayout: null,
- GPU: !0,
- steps: 1,
- maxSteps: 1e3,
- repulsionByDegree: !0,
- linLogMode: !1,
- strongGravityMode: !1,
- gravity: 1,
- edgeWeightInfluence: 1,
- edgeWeight: [1, 4],
- nodeWeight: [1, 4],
- preventOverlap: !1,
- gravityCenter: null
- },
- focusNodeAdjacency: !0,
- focusNodeAdjacencyOn: "mouseover",
- left: "center",
- top: "center",
- symbol: "circle",
- symbolSize: 5,
- roam: !1,
- center: null,
- zoom: 1,
- label: {
- show: !1,
- formatter: "{b}",
- position: "right",
- distance: 5,
- textStyle: {
- fontSize: 14
- }
- },
- itemStyle: {},
- lineStyle: {
- color: "#aaa",
- width: 1,
- opacity: .5
- },
- emphasis: {
- label: {
- show: !0
- }
- },
- animation: !1
- }
- });
- const Gd = zd;
- var Ud = Po.vec2
- , kd = [[0, 0], [1, 1]]
- , Vd = Vr.extend((function () {
- return {
- segmentScale: 4,
- dynamic: !0,
- useNativeLine: !0,
- attributes: {
- position: new Vr.Attribute("position", "float", 2, "POSITION"),
- normal: new Vr.Attribute("normal", "float", 2),
- offset: new Vr.Attribute("offset", "float", 1),
- color: new Vr.Attribute("color", "float", 4, "COLOR")
- }
- }
- }
- ), {
- resetOffset: function () {
- this._vertexOffset = 0,
- this._faceOffset = 0,
- this._itemVertexOffsets = []
- },
- setVertexCount: function (e) {
- var t = this.attributes;
- this.vertexCount !== e && (t.position.init(e),
- t.color.init(e),
- this.useNativeLine || (t.offset.init(e),
- t.normal.init(e)),
- e > 65535 ? this.indices instanceof Uint16Array && (this.indices = new Uint32Array(this.indices)) : this.indices instanceof Uint32Array && (this.indices = new Uint16Array(this.indices)))
- },
- setTriangleCount: function (e) {
- this.triangleCount !== e && (this.indices = 0 === e ? null : this.vertexCount > 65535 ? new Uint32Array(3 * e) : new Uint16Array(3 * e))
- },
- _getCubicCurveApproxStep: function (e, t, r, i) {
- return 1 / (Ud.dist(e, t) + Ud.dist(r, t) + Ud.dist(i, r) + 1) * this.segmentScale
- },
- getCubicCurveVertexCount: function (e, t, r, i) {
- var n = this._getCubicCurveApproxStep(e, t, r, i)
- , a = Math.ceil(1 / n);
- return this.useNativeLine ? 2 * a : 2 * a + 2
- },
- getCubicCurveTriangleCount: function (e, t, r, i) {
- var n = this._getCubicCurveApproxStep(e, t, r, i)
- , a = Math.ceil(1 / n);
- return this.useNativeLine ? 0 : 2 * a
- },
- getLineVertexCount: function () {
- return this.getPolylineVertexCount(kd)
- },
- getLineTriangleCount: function () {
- return this.getPolylineTriangleCount(kd)
- },
- getPolylineVertexCount: function (e) {
- var t;
- return t = "number" == typeof e ? e : "number" != typeof e[0] ? e.length : e.length / 2,
- this.useNativeLine ? 2 * (t - 1) : 2 * (t - 1) + 2
- },
- getPolylineTriangleCount: function (e) {
- var t;
- return t = "number" == typeof e ? e : "number" != typeof e[0] ? e.length : e.length / 2,
- this.useNativeLine ? 0 : 2 * (t - 1)
- },
- addCubicCurve: function (e, t, r, i, n, a) {
- null == a && (a = 1);
- var o = e[0]
- , s = e[1]
- , l = t[0]
- , h = t[1]
- , u = r[0]
- , c = r[1]
- , d = i[0]
- , f = i[1]
- , p = this._getCubicCurveApproxStep(e, t, r, i)
- , m = p * p
- , g = m * p
- , _ = 3 * p
- , v = 3 * m
- , y = 6 * m
- , x = 6 * g
- , b = o - 2 * l + u
- , w = s - 2 * h + c
- , T = 3 * (l - u) - o + d
- , S = 3 * (h - c) - s + f
- , M = o
- , A = s
- , E = (l - o) * _ + b * v + T * g
- , C = (h - s) * _ + w * v + S * g
- , D = b * y + T * x
- , L = w * y + S * x
- , P = T * x
- , O = S * x
- , N = 0
- , I = 0
- , R = Math.ceil(1 / p)
- , B = new Float32Array(3 * (R + 1))
- , F = (B = [],
- 0);
- for (I = 0; I < R + 1; I++)
- B[F++] = M,
- B[F++] = A,
- M += E,
- A += C,
- E += D,
- C += L,
- D += P,
- L += O,
- (N += p) > 1 && (M = E > 0 ? Math.min(M, d) : Math.max(M, d),
- A = C > 0 ? Math.min(A, f) : Math.max(A, f));
- this.addPolyline(B, n, a)
- },
- addLine: function (e, t, r, i) {
- this.addPolyline([e, t], r, i)
- },
- addPolyline: function () {
- var e = Ud.create()
- , t = Ud.create()
- , r = Ud.create()
- , i = Ud.create()
- , n = []
- , a = []
- , o = [];
- return function (s, l, h, u, c) {
- if (s.length) {
- var d = "number" != typeof s[0];
- if (null == c && (c = d ? s.length : s.length / 2),
- !(c < 2)) {
- null == u && (u = 0),
- null == h && (h = 1),
- this._itemVertexOffsets.push(this._vertexOffset);
- for (var f, p = d ? "number" != typeof l[0] : l.length / 4 === c, m = this.attributes.position, g = this.attributes.color, _ = this.attributes.offset, v = this.attributes.normal, y = this.indices, x = this._vertexOffset, b = 0; b < c; b++) {
- if (d)
- n = s[b + u],
- f = p ? l[b + u] : l;
- else {
- var w = 2 * b + u;
- if ((n = n || [])[0] = s[w],
- n[1] = s[w + 1],
- p) {
- var T = 4 * b + u;
- (f = f || [])[0] = l[T],
- f[1] = l[T + 1],
- f[2] = l[T + 2],
- f[3] = l[T + 3]
- } else
- f = l
- }
- if (this.useNativeLine)
- b > 1 && (m.copy(x, x - 1),
- g.copy(x, x - 1),
- x++);
- else {
- var S;
- if (b < c - 1)
- if (d ? Ud.copy(a, s[b + 1]) : (w = 2 * (b + 1) + u,
- (a = a || [])[0] = s[w],
- a[1] = s[w + 1]),
- b > 0) {
- Ud.sub(e, n, o),
- Ud.sub(t, a, n),
- Ud.normalize(e, e),
- Ud.normalize(t, t),
- Ud.add(i, e, t),
- Ud.normalize(i, i);
- var M = h / 2 * Math.min(1 / Ud.dot(e, i), 2);
- r[0] = -i[1],
- r[1] = i[0],
- S = M
- } else
- Ud.sub(e, a, n),
- Ud.normalize(e, e),
- r[0] = -e[1],
- r[1] = e[0],
- S = h / 2;
- else
- Ud.sub(e, n, o),
- Ud.normalize(e, e),
- r[0] = -e[1],
- r[1] = e[0],
- S = h / 2;
- v.set(x, r),
- v.set(x + 1, r),
- _.set(x, S),
- _.set(x + 1, -S),
- Ud.copy(o, n),
- m.set(x, n),
- m.set(x + 1, n),
- g.set(x, f),
- g.set(x + 1, f),
- x += 2
- }
- if (this.useNativeLine)
- g.set(x, f),
- m.set(x, n),
- x++;
- else if (b > 0) {
- var A = 3 * this._faceOffset;
- (y = this.indices)[A] = x - 4,
- y[A + 1] = x - 3,
- y[A + 2] = x - 2,
- y[A + 3] = x - 3,
- y[A + 4] = x - 1,
- y[A + 5] = x - 2,
- this._faceOffset += 2
- }
- }
- this._vertexOffset = x
- }
- }
- }
- }(),
- setItemColor: function (e, t) {
- for (var r = this._itemVertexOffsets[e], i = e < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[e + 1] : this._vertexOffset, n = r; n < i; n++)
- this.attributes.color.set(n, t);
- this.dirty("color")
- }
- });
- i.util.defaults(Vd.prototype, Lo);
- const Hd = Vd;
- Ka.Shader.import("@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end");
- var Wd = {
- repulsionByDegree: !0,
- linLogMode: !1,
- strongGravityMode: !1,
- gravity: 1,
- scaling: 1,
- edgeWeightInfluence: 1,
- jitterTolerence: .1,
- preventOverlap: !1,
- dissuadeHubs: !1,
- gravityCenter: null
- };
- function jd(e) {
- var t = {
- type: Ka.Texture.FLOAT,
- minFilter: Ka.Texture.NEAREST,
- magFilter: Ka.Texture.NEAREST
- };
- this._positionSourceTex = new Ka.Texture2D(t),
- this._positionSourceTex.flipY = !1,
- this._positionTex = new Ka.Texture2D(t),
- this._positionPrevTex = new Ka.Texture2D(t),
- this._forceTex = new Ka.Texture2D(t),
- this._forcePrevTex = new Ka.Texture2D(t),
- this._weightedSumTex = new Ka.Texture2D(t),
- this._weightedSumTex.width = this._weightedSumTex.height = 1,
- this._globalSpeedTex = new Ka.Texture2D(t),
- this._globalSpeedPrevTex = new Ka.Texture2D(t),
- this._globalSpeedTex.width = this._globalSpeedTex.height = 1,
- this._globalSpeedPrevTex.width = this._globalSpeedPrevTex.height = 1,
- this._nodeRepulsionPass = new pn({
- fragment: Ka.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")
- }),
- this._positionPass = new pn({
- fragment: Ka.Shader.source("ecgl.forceAtlas2.updatePosition")
- }),
- this._globalSpeedPass = new pn({
- fragment: Ka.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")
- }),
- this._copyPass = new pn({
- fragment: Ka.Shader.source("clay.compositor.output")
- });
- var r = function (e) {
- e.blendEquation(e.FUNC_ADD),
- e.blendFunc(e.ONE, e.ONE)
- };
- this._edgeForceMesh = new Ka.Mesh({
- geometry: new Ka.Geometry({
- attributes: {
- node1: new Ka.Geometry.Attribute("node1", "float", 2),
- node2: new Ka.Geometry.Attribute("node2", "float", 2),
- weight: new Ka.Geometry.Attribute("weight", "float", 1)
- },
- dynamic: !0,
- mainAttribute: "node1"
- }),
- material: new Ka.Material({
- transparent: !0,
- shader: Ka.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),
- blend: r,
- depthMask: !1,
- depthText: !1
- }),
- mode: Ka.Mesh.POINTS
- }),
- this._weightedSumMesh = new Ka.Mesh({
- geometry: new Ka.Geometry({
- attributes: {
- node: new Ka.Geometry.Attribute("node", "float", 2)
- },
- dynamic: !0,
- mainAttribute: "node"
- }),
- material: new Ka.Material({
- transparent: !0,
- shader: Ka.createShader("ecgl.forceAtlas2.calcWeightedSum"),
- blend: r,
- depthMask: !1,
- depthText: !1
- }),
- mode: Ka.Mesh.POINTS
- }),
- this._framebuffer = new zi({
- depthBuffer: !1
- }),
- this._dummyCamera = new Ka.OrthographicCamera({
- left: -1,
- right: 1,
- top: 1,
- bottom: -1,
- near: 0,
- far: 100
- }),
- this._globalSpeed = 0
- }
- jd.prototype.updateOption = function (e) {
- for (var t in Wd)
- this[t] = Wd[t];
- var r = this._nodes.length;
- if (this.jitterTolerence = r > 5e4 ? 10 : r > 5e3 ? 1 : .1,
- this.scaling = r > 100 ? 2 : 10,
- e)
- for (var t in Wd)
- null != e[t] && (this[t] = e[t]);
- if (this.repulsionByDegree)
- for (var i = this._positionSourceTex.pixels, n = 0; n < this._nodes.length; n++)
- i[4 * n + 2] = (this._nodes[n].degree || 0) + 1
- }
- ,
- jd.prototype._updateGravityCenter = function (e) {
- var t = this._nodes
- , r = this._edges;
- if (this.gravityCenter)
- this._gravityCenter = this.gravityCenter;
- else {
- for (var i = [1 / 0, 1 / 0], n = [-1 / 0, -1 / 0], a = 0; a < t.length; a++)
- i[0] = Math.min(t[a].x, i[0]),
- i[1] = Math.min(t[a].y, i[1]),
- n[0] = Math.max(t[a].x, n[0]),
- n[1] = Math.max(t[a].y, n[1]);
- this._gravityCenter = [.5 * (i[0] + n[0]), .5 * (i[1] + n[1])]
- }
- for (a = 0; a < r.length; a++) {
- var o = r[a].node1
- , s = r[a].node2;
- t[o].degree = (t[o].degree || 0) + 1,
- t[s].degree = (t[s].degree || 0) + 1
- }
- }
- ,
- jd.prototype.initData = function (e, t) {
- this._nodes = e,
- this._edges = t,
- this._updateGravityCenter();
- var r = Math.ceil(Math.sqrt(e.length))
- , i = r
- , n = new Float32Array(r * i * 4);
- this._resize(r, i);
- for (var a = 0, o = 0; o < e.length; o++) {
- var s = e[o];
- n[a++] = s.x || 0,
- n[a++] = s.y || 0,
- n[a++] = s.mass || 1,
- n[a++] = s.size || 1
- }
- this._positionSourceTex.pixels = n;
- var l = this._edgeForceMesh.geometry
- , h = t.length;
- l.attributes.node1.init(2 * h),
- l.attributes.node2.init(2 * h),
- l.attributes.weight.init(2 * h);
- var u = [];
- for (o = 0; o < t.length; o++) {
- var c = l.attributes
- , d = t[o].weight;
- null == d && (d = 1),
- c.node1.set(o, this.getNodeUV(t[o].node1, u)),
- c.node2.set(o, this.getNodeUV(t[o].node2, u)),
- c.weight.set(o, d),
- c.node1.set(o + h, this.getNodeUV(t[o].node2, u)),
- c.node2.set(o + h, this.getNodeUV(t[o].node1, u)),
- c.weight.set(o + h, d)
- }
- var f = this._weightedSumMesh.geometry;
- for (f.attributes.node.init(e.length),
- o = 0; o < e.length; o++)
- f.attributes.node.set(o, this.getNodeUV(o, u));
- l.dirty(),
- f.dirty(),
- this._nodeRepulsionPass.material.define("fragment", "NODE_COUNT", e.length),
- this._nodeRepulsionPass.material.setUniform("textureSize", [r, i]),
- this._inited = !1,
- this._frame = 0
- }
- ,
- jd.prototype.getNodes = function () {
- return this._nodes
- }
- ,
- jd.prototype.getEdges = function () {
- return this._edges
- }
- ,
- jd.prototype.step = function (e) {
- this._inited || (this._initFromSource(e),
- this._inited = !0),
- this._frame++,
- this._framebuffer.attach(this._forceTex),
- this._framebuffer.bind(e);
- var t = this._nodeRepulsionPass;
- t.setUniform("strongGravityMode", this.strongGravityMode),
- t.setUniform("gravity", this.gravity),
- t.setUniform("gravityCenter", this._gravityCenter),
- t.setUniform("scaling", this.scaling),
- t.setUniform("preventOverlap", this.preventOverlap),
- t.setUniform("positionTex", this._positionPrevTex),
- t.render(e);
- var r = this._edgeForceMesh;
- r.material.set("linLogMode", this.linLogMode),
- r.material.set("edgeWeightInfluence", this.edgeWeightInfluence),
- r.material.set("preventOverlap", this.preventOverlap),
- r.material.set("positionTex", this._positionPrevTex),
- e.gl.enable(e.gl.BLEND),
- e.renderPass([r], this._dummyCamera),
- this._framebuffer.attach(this._weightedSumTex),
- e.gl.clearColor(0, 0, 0, 0),
- e.gl.clear(e.gl.COLOR_BUFFER_BIT),
- e.gl.enable(e.gl.BLEND);
- var i = this._weightedSumMesh;
- i.material.set("positionTex", this._positionPrevTex),
- i.material.set("forceTex", this._forceTex),
- i.material.set("forcePrevTex", this._forcePrevTex),
- e.renderPass([i], this._dummyCamera),
- this._framebuffer.attach(this._globalSpeedTex);
- var n = this._globalSpeedPass;
- n.setUniform("globalSpeedPrevTex", this._globalSpeedPrevTex),
- n.setUniform("weightedSumTex", this._weightedSumTex),
- n.setUniform("jitterTolerence", this.jitterTolerence),
- e.gl.disable(e.gl.BLEND),
- n.render(e);
- var a = this._positionPass;
- this._framebuffer.attach(this._positionTex),
- a.setUniform("globalSpeedTex", this._globalSpeedTex),
- a.setUniform("positionTex", this._positionPrevTex),
- a.setUniform("forceTex", this._forceTex),
- a.setUniform("forcePrevTex", this._forcePrevTex),
- a.render(e),
- this._framebuffer.unbind(e),
- this._swapTexture()
- }
- ,
- jd.prototype.update = function (e, t, r) {
- null == t && (t = 1),
- t = Math.max(t, 1);
- for (var i = 0; i < t; i++)
- this.step(e);
- r && r()
- }
- ,
- jd.prototype.getNodePositionTexture = function () {
- return this._inited ? this._positionPrevTex : this._positionSourceTex
- }
- ,
- jd.prototype.getNodeUV = function (e, t) {
- t = t || [];
- var r = this._positionTex.width
- , i = this._positionTex.height;
- return t[0] = e % r / (r - 1),
- t[1] = Math.floor(e / r) / (i - 1) || 0,
- t
- }
- ,
- jd.prototype.getNodePosition = function (e, t) {
- var r = this._positionArr
- , i = this._positionTex.width
- , n = this._positionTex.height
- , a = i * n;
- r && r.length === 4 * a || (r = this._positionArr = new Float32Array(4 * a)),
- this._framebuffer.bind(e),
- this._framebuffer.attach(this._positionPrevTex),
- e.gl.readPixels(0, 0, i, n, e.gl.RGBA, e.gl.FLOAT, r),
- this._framebuffer.unbind(e),
- t || (t = new Float32Array(2 * this._nodes.length));
- for (var o = 0; o < this._nodes.length; o++)
- t[2 * o] = r[4 * o],
- t[2 * o + 1] = r[4 * o + 1];
- return t
- }
- ,
- jd.prototype.getTextureData = function (e, t) {
- var r = this["_" + t + "Tex"]
- , i = r.width
- , n = r.height;
- this._framebuffer.bind(e),
- this._framebuffer.attach(r);
- var a = new Float32Array(i * n * 4);
- return e.gl.readPixels(0, 0, i, n, e.gl.RGBA, e.gl.FLOAT, a),
- this._framebuffer.unbind(e),
- a
- }
- ,
- jd.prototype.getTextureSize = function () {
- return {
- width: this._positionTex.width,
- height: this._positionTex.height
- }
- }
- ,
- jd.prototype.isFinished = function (e) {
- return this._frame > e
- }
- ,
- jd.prototype._swapTexture = function () {
- var e = this._positionPrevTex;
- this._positionPrevTex = this._positionTex,
- this._positionTex = e,
- e = this._forcePrevTex,
- this._forcePrevTex = this._forceTex,
- this._forceTex = e,
- e = this._globalSpeedPrevTex,
- this._globalSpeedPrevTex = this._globalSpeedTex,
- this._globalSpeedTex = e
- }
- ,
- jd.prototype._initFromSource = function (e) {
- this._framebuffer.attach(this._positionPrevTex),
- this._framebuffer.bind(e),
- this._copyPass.setUniform("texture", this._positionSourceTex),
- this._copyPass.render(e),
- e.gl.clearColor(0, 0, 0, 0),
- this._framebuffer.attach(this._forcePrevTex),
- e.gl.clear(e.gl.COLOR_BUFFER_BIT),
- this._framebuffer.attach(this._globalSpeedPrevTex),
- e.gl.clear(e.gl.COLOR_BUFFER_BIT),
- this._framebuffer.unbind(e)
- }
- ,
- jd.prototype._resize = function (e, t) {
- ["_positionSourceTex", "_positionTex", "_positionPrevTex", "_forceTex", "_forcePrevTex"].forEach((function (r) {
- this[r].width = e,
- this[r].height = t,
- this[r].dirty()
- }
- ), this)
- }
- ,
- jd.prototype.dispose = function (e) {
- this._framebuffer.dispose(e),
- this._copyPass.dispose(e),
- this._nodeRepulsionPass.dispose(e),
- this._positionPass.dispose(e),
- this._globalSpeedPass.dispose(e),
- this._edgeForceMesh.geometry.dispose(e),
- this._weightedSumMesh.geometry.dispose(e),
- this._positionSourceTex.dispose(e),
- this._positionTex.dispose(e),
- this._positionPrevTex.dispose(e),
- this._forceTex.dispose(e),
- this._forcePrevTex.dispose(e),
- this._weightedSumTex.dispose(e),
- this._globalSpeedTex.dispose(e),
- this._globalSpeedPrevTex.dispose(e)
- }
- ;
- const Xd = jd;
- var qd = function () {
- var e = function () {
- return new Float32Array(2)
- }
- , t = function (e, t) {
- var r = t[0] - e[0]
- , i = t[1] - e[1];
- return Math.sqrt(r * r + i * i)
- }
- , r = function (e) {
- var t = e[0]
- , r = e[1];
- return Math.sqrt(t * t + r * r)
- }
- , i = function (e, t, r, i) {
- return e[0] = t[0] + r[0] * i,
- e[1] = t[1] + r[1] * i,
- e
- }
- , n = function (e, t, r) {
- return e[0] = t[0] + r[0],
- e[1] = t[1] + r[1],
- e
- }
- , a = function (e, t, r) {
- return e[0] = t[0] - r[0],
- e[1] = t[1] - r[1],
- e
- }
- , o = function (e, t, r) {
- return e[0] = t,
- e[1] = r,
- e
- };
- function s() {
- this.subRegions = [],
- this.nSubRegions = 0,
- this.node = null,
- this.mass = 0,
- this.centerOfMass = null,
- this.bbox = new Float32Array(4),
- this.size = 0
- }
- var l = s.prototype;
- function h() {
- this.position = new Float32Array(2),
- this.force = e(),
- this.forcePrev = e(),
- this.mass = 1,
- this.inDegree = 0,
- this.outDegree = 0
- }
- function u(e, t) {
- this.source = e,
- this.target = t,
- this.weight = 1
- }
- function c() {
- this.autoSettings = !0,
- this.barnesHutOptimize = !0,
- this.barnesHutTheta = 1.5,
- this.repulsionByDegree = !0,
- this.linLogMode = !1,
- this.strongGravityMode = !1,
- this.gravity = 1,
- this.scaling = 1,
- this.edgeWeightInfluence = 1,
- this.jitterTolerence = .1,
- this.preventOverlap = !1,
- this.dissuadeHubs = !1,
- this.rootRegion = new s,
- this.rootRegion.centerOfMass = e(),
- this.nodes = [],
- this.edges = [],
- this.bbox = new Float32Array(4),
- this.gravityCenter = null,
- this._massArr = null,
- this._swingingArr = null,
- this._sizeArr = null,
- this._globalSpeed = 0
- }
- l.beforeUpdate = function () {
- for (var e = 0; e < this.nSubRegions; e++)
- this.subRegions[e].beforeUpdate();
- this.mass = 0,
- this.centerOfMass && (this.centerOfMass[0] = 0,
- this.centerOfMass[1] = 0),
- this.nSubRegions = 0,
- this.node = null
- }
- ,
- l.afterUpdate = function () {
- this.subRegions.length = this.nSubRegions;
- for (var e = 0; e < this.nSubRegions; e++)
- this.subRegions[e].afterUpdate()
- }
- ,
- l.addNode = function (e) {
- if (0 === this.nSubRegions) {
- if (null == this.node)
- return void (this.node = e);
- this._addNodeToSubRegion(this.node),
- this.node = null
- }
- this._addNodeToSubRegion(e),
- this._updateCenterOfMass(e)
- }
- ,
- l.findSubRegion = function (e, t) {
- for (var r = 0; r < this.nSubRegions; r++) {
- var i = this.subRegions[r];
- if (i.contain(e, t))
- return i
- }
- }
- ,
- l.contain = function (e, t) {
- return this.bbox[0] <= e && this.bbox[2] >= e && this.bbox[1] <= t && this.bbox[3] >= t
- }
- ,
- l.setBBox = function (e, t, r, i) {
- this.bbox[0] = e,
- this.bbox[1] = t,
- this.bbox[2] = r,
- this.bbox[3] = i,
- this.size = (r - e + i - t) / 2
- }
- ,
- l._newSubRegion = function () {
- var e = this.subRegions[this.nSubRegions];
- return e || (e = new s,
- this.subRegions[this.nSubRegions] = e),
- this.nSubRegions++,
- e
- }
- ,
- l._addNodeToSubRegion = function (e) {
- var t = this.findSubRegion(e.position[0], e.position[1])
- , r = this.bbox;
- if (!t) {
- var i = (r[0] + r[2]) / 2
- , n = (r[1] + r[3]) / 2
- , a = (r[2] - r[0]) / 2
- , o = (r[3] - r[1]) / 2
- , s = e.position[0] >= i ? 1 : 0
- , l = e.position[1] >= n ? 1 : 0;
- (t = this._newSubRegion()).setBBox(s * a + r[0], l * o + r[1], (s + 1) * a + r[0], (l + 1) * o + r[1])
- }
- t.addNode(e)
- }
- ,
- l._updateCenterOfMass = function (e) {
- null == this.centerOfMass && (this.centerOfMass = new Float32Array(2));
- var t = this.centerOfMass[0] * this.mass
- , r = this.centerOfMass[1] * this.mass;
- t += e.position[0] * e.mass,
- r += e.position[1] * e.mass,
- this.mass += e.mass,
- this.centerOfMass[0] = t / this.mass,
- this.centerOfMass[1] = r / this.mass
- }
- ;
- var d = c.prototype;
- d.initNodes = function (e, t, r) {
- var i = t.length;
- this.nodes.length = 0;
- for (var n = void 0 !== r, a = 0; a < i; a++) {
- var o = new h;
- o.position[0] = e[2 * a],
- o.position[1] = e[2 * a + 1],
- o.mass = t[a],
- n && (o.size = r[a]),
- this.nodes.push(o)
- }
- this._massArr = t,
- this._swingingArr = new Float32Array(i),
- n && (this._sizeArr = r)
- }
- ,
- d.initEdges = function (e, t) {
- var r = e.length / 2;
- this.edges.length = 0;
- for (var i = 0; i < r; i++) {
- var n = e[2 * i]
- , a = e[2 * i + 1]
- , o = this.nodes[n]
- , s = this.nodes[a];
- if (!o || !s)
- return void console.error("Node not exists, try initNodes before initEdges");
- o.outDegree++,
- s.inDegree++;
- var l = new u(o, s);
- t && (l.weight = t[i]),
- this.edges.push(l)
- }
- }
- ,
- d.updateSettings = function () {
- if (this.repulsionByDegree)
- for (var e = 0; e < this.nodes.length; e++)
- (t = this.nodes[e]).mass = t.inDegree + t.outDegree + 1;
- else
- for (e = 0; e < this.nodes.length; e++) {
- var t;
- (t = this.nodes[e]).mass = this._massArr[e]
- }
- }
- ,
- d.update = function () {
- var a, s, l = this.nodes.length;
- if (this.updateSettings(),
- this.updateBBox(),
- this.barnesHutOptimize) {
- this.rootRegion.setBBox(this.bbox[0], this.bbox[1], this.bbox[2], this.bbox[3]),
- this.rootRegion.beforeUpdate();
- for (var h = 0; h < l; h++)
- this.rootRegion.addNode(this.nodes[h]);
- this.rootRegion.afterUpdate()
- }
- for (h = 0; h < l; h++) {
- var u = this.nodes[h];
- a = u.forcePrev,
- s = u.force,
- a[0] = s[0],
- a[1] = s[1],
- o(u.force, 0, 0)
- }
- for (h = 0; h < l; h++) {
- var c = this.nodes[h];
- if (this.barnesHutOptimize)
- this.applyRegionToNodeRepulsion(this.rootRegion, c);
- else
- for (var d = h + 1; d < l; d++) {
- var f = this.nodes[d];
- this.applyNodeToNodeRepulsion(c, f, !1)
- }
- this.gravity > 0 && (this.strongGravityMode ? this.applyNodeStrongGravity(c) : this.applyNodeGravity(c))
- }
- for (h = 0; h < this.edges.length; h++)
- this.applyEdgeAttraction(this.edges[h]);
- var p = 0
- , m = 0
- , g = e();
- for (h = 0; h < l; h++)
- u = this.nodes[h],
- p += (v = t(u.force, u.forcePrev)) * u.mass,
- n(g, u.force, u.forcePrev),
- m += .5 * r(g) * u.mass,
- this._swingingArr[h] = v;
- var _ = this.jitterTolerence * this.jitterTolerence * m / p;
- for (this._globalSpeed > 0 && (_ = Math.min(_ / this._globalSpeed, 1.5) * this._globalSpeed),
- this._globalSpeed = _,
- h = 0; h < l; h++) {
- u = this.nodes[h];
- var v = this._swingingArr[h]
- , y = .1 * _ / (1 + _ * Math.sqrt(v))
- , x = r(u.force);
- x > 0 && (y = Math.min(x * y, 10) / x,
- i(u.position, u.position, u.force, y))
- }
- }
- ,
- d.applyRegionToNodeRepulsion = function () {
- var t = e();
- return function (e, r) {
- if (e.node)
- this.applyNodeToNodeRepulsion(e.node, r, !0);
- else {
- a(t, r.position, e.centerOfMass);
- var n = t[0] * t[0] + t[1] * t[1];
- if (n > this.barnesHutTheta * e.size * e.size) {
- var o = this.scaling * r.mass * e.mass / n;
- i(r.force, r.force, t, o)
- } else
- for (var s = 0; s < e.nSubRegions; s++)
- this.applyRegionToNodeRepulsion(e.subRegions[s], r)
- }
- }
- }(),
- d.applyNodeToNodeRepulsion = function () {
- var t = e();
- return function (e, r, n) {
- if (e != r) {
- a(t, e.position, r.position);
- var o = t[0] * t[0] + t[1] * t[1];
- if (0 !== o) {
- var s;
- if (this.preventOverlap) {
- var l = Math.sqrt(o);
- if ((l = l - e.size - r.size) > 0)
- s = this.scaling * e.mass * r.mass / (l * l);
- else {
- if (!(l < 0))
- return;
- s = 100 * this.scaling * e.mass * r.mass
- }
- } else
- s = this.scaling * e.mass * r.mass / o;
- i(e.force, e.force, t, s),
- i(r.force, r.force, t, -s)
- }
- }
- }
- }(),
- d.applyEdgeAttraction = function () {
- var t = e();
- return function (e) {
- var n = e.source
- , o = e.target;
- a(t, n.position, o.position);
- var s, l, h = r(t);
- s = 0 === this.edgeWeightInfluence ? 1 : 1 === this.edgeWeightInfluence ? e.weight : Math.pow(e.weight, this.edgeWeightInfluence),
- this.preventOverlap && (h = h - n.size - o.size) <= 0 || (l = this.linLogMode ? -s * Math.log(h + 1) / (h + 1) : -s,
- i(n.force, n.force, t, l),
- i(o.force, o.force, t, -l))
- }
- }(),
- d.applyNodeGravity = function () {
- var t = e();
- return function (e) {
- a(t, this.gravityCenter, e.position);
- var n = r(t);
- i(e.force, e.force, t, this.gravity * e.mass / (n + 1))
- }
- }(),
- d.applyNodeStrongGravity = function () {
- var t = e();
- return function (e) {
- a(t, this.gravityCenter, e.position),
- i(e.force, e.force, t, this.gravity * e.mass)
- }
- }(),
- d.updateBBox = function () {
- for (var e = 1 / 0, t = 1 / 0, r = -1 / 0, i = -1 / 0, n = 0; n < this.nodes.length; n++) {
- var a = this.nodes[n].position;
- e = Math.min(e, a[0]),
- t = Math.min(t, a[1]),
- r = Math.max(r, a[0]),
- i = Math.max(i, a[1])
- }
- this.bbox[0] = e,
- this.bbox[1] = t,
- this.bbox[2] = r,
- this.bbox[3] = i
- }
- ,
- d.getGlobalSpeed = function () {
- return this._globalSpeed
- }
- ;
- var f = null;
- self.onmessage = function (e) {
- switch (e.data.cmd) {
- case "init":
- (f = new c).initNodes(e.data.nodesPosition, e.data.nodesMass, e.data.nodesSize),
- f.initEdges(e.data.edges, e.data.edgesWeight);
- break;
- case "updateConfig":
- if (f)
- for (var t in e.data.config)
- f[t] = e.data.config[t];
- break;
- case "update":
- var r = e.data.steps;
- if (f) {
- for (var i = 0; i < r; i++)
- f.update();
- var n = f.nodes.length
- , a = new Float32Array(2 * n);
- for (i = 0; i < n; i++) {
- var o = f.nodes[i];
- a[2 * i] = o.position[0],
- a[2 * i + 1] = o.position[1]
- }
- self.postMessage({
- buffer: a.buffer,
- globalSpeed: f.getGlobalSpeed()
- }, [a.buffer])
- } else {
- var s = new Float32Array;
- self.postMessage({
- buffer: s.buffer,
- globalSpeed: f.getGlobalSpeed()
- }, [s.buffer])
- }
- }
- }
- }
- .toString();
- qd = qd.slice(qd.indexOf("{") + 1, qd.lastIndexOf("}"));
- var Zd = {
- barnesHutOptimize: !0,
- barnesHutTheta: 1.5,
- repulsionByDegree: !0,
- linLogMode: !1,
- strongGravityMode: !1,
- gravity: 1,
- scaling: 1,
- edgeWeightInfluence: 1,
- jitterTolerence: .1,
- preventOverlap: !1,
- dissuadeHubs: !1,
- gravityCenter: null
- }
- , Yd = function (e) {
- for (var t in Zd)
- this[t] = Zd[t];
- if (e)
- for (var t in e)
- this[t] = e[t];
- this._nodes = [],
- this._edges = [],
- this._disposed = !1,
- this._positionTex = new Dr({
- type: wr.FLOAT,
- flipY: !1,
- minFilter: wr.NEAREST,
- magFilter: wr.NEAREST
- })
- };
- Yd.prototype.initData = function (e, t) {
- var r = new Blob([qd])
- , i = window.URL.createObjectURL(r);
- this._worker = new Worker(i),
- this._worker.onmessage = this._$onupdate.bind(this),
- this._nodes = e,
- this._edges = t,
- this._frame = 0;
- for (var n = e.length, a = t.length, o = new Float32Array(2 * n), s = new Float32Array(n), l = new Float32Array(n), h = new Float32Array(2 * a), u = new Float32Array(a), c = 0; c < e.length; c++) {
- var d = e[c];
- o[2 * c] = d.x,
- o[2 * c + 1] = d.y,
- s[c] = null == d.mass ? 1 : d.mass,
- l[c] = null == d.size ? 1 : d.size
- }
- for (c = 0; c < t.length; c++) {
- var f = t[c]
- , p = f.node1
- , m = f.node2;
- h[2 * c] = p,
- h[2 * c + 1] = m,
- u[c] = null == f.weight ? 1 : f.weight
- }
- var g = Math.ceil(Math.sqrt(e.length))
- , _ = g
- , v = new Float32Array(g * _ * 4)
- , y = this._positionTex;
- y.width = g,
- y.height = _,
- y.pixels = v,
- this._worker.postMessage({
- cmd: "init",
- nodesPosition: o,
- nodesMass: s,
- nodesSize: l,
- edges: h,
- edgesWeight: u
- }),
- this._globalSpeed = 1 / 0
- }
- ,
- Yd.prototype.updateOption = function (e) {
- var t = {};
- for (var r in Zd)
- t[r] = Zd[r];
- var i = this._nodes
- , n = this._edges
- , a = i.length;
- if (t.jitterTolerence = a > 5e4 ? 10 : a > 5e3 ? 1 : .1,
- t.scaling = a > 100 ? 2 : 10,
- t.barnesHutOptimize = a > 1e3,
- e)
- for (var r in Zd)
- null != e[r] && (t[r] = e[r]);
- if (!t.gravityCenter) {
- for (var o = [1 / 0, 1 / 0], s = [-1 / 0, -1 / 0], l = 0; l < i.length; l++)
- o[0] = Math.min(i[l].x, o[0]),
- o[1] = Math.min(i[l].y, o[1]),
- s[0] = Math.max(i[l].x, s[0]),
- s[1] = Math.max(i[l].y, s[1]);
- t.gravityCenter = [.5 * (o[0] + s[0]), .5 * (o[1] + s[1])]
- }
- for (l = 0; l < n.length; l++) {
- var h = n[l].node1
- , u = n[l].node2;
- i[h].degree = (i[h].degree || 0) + 1,
- i[u].degree = (i[u].degree || 0) + 1
- }
- this._worker && this._worker.postMessage({
- cmd: "updateConfig",
- config: t
- })
- }
- ,
- Yd.prototype.update = function (e, t, r) {
- null == t && (t = 1),
- t = Math.max(t, 1),
- this._frame += t,
- this._onupdate = r,
- this._worker && this._worker.postMessage({
- cmd: "update",
- steps: Math.round(t)
- })
- }
- ,
- Yd.prototype._$onupdate = function (e) {
- if (!this._disposed) {
- var t = new Float32Array(e.data.buffer);
- this._globalSpeed = e.data.globalSpeed,
- this._positionArr = t,
- this._updateTexture(t),
- this._onupdate && this._onupdate()
- }
- }
- ,
- Yd.prototype.getNodePositionTexture = function () {
- return this._positionTex
- }
- ,
- Yd.prototype.getNodeUV = function (e, t) {
- t = t || [];
- var r = this._positionTex.width
- , i = this._positionTex.height;
- return t[0] = e % r / (r - 1),
- t[1] = Math.floor(e / r) / (i - 1),
- t
- }
- ,
- Yd.prototype.getNodes = function () {
- return this._nodes
- }
- ,
- Yd.prototype.getEdges = function () {
- return this._edges
- }
- ,
- Yd.prototype.isFinished = function (e) {
- return this._frame > e
- }
- ,
- Yd.prototype.getNodePosition = function (e, t) {
- if (t || (t = new Float32Array(2 * this._nodes.length)),
- this._positionArr)
- for (var r = 0; r < this._positionArr.length; r++)
- t[r] = this._positionArr[r];
- return t
- }
- ,
- Yd.prototype._updateTexture = function (e) {
- for (var t = this._positionTex.pixels, r = 0, i = 0; i < e.length;)
- t[r++] = e[i++],
- t[r++] = e[i++],
- t[r++] = 1,
- t[r++] = 1;
- this._positionTex.dirty()
- }
- ,
- Yd.prototype.dispose = function (e) {
- this._disposed = !0,
- this._worker = null
- }
- ;
- const Kd = Yd
- , Qd = m.extend((function () {
- return {
- zr: null,
- viewGL: null,
- minZoom: .2,
- maxZoom: 5,
- _needsUpdate: !1,
- _dx: 0,
- _dy: 0,
- _zoom: 1
- }
- }
- ), (function () {
- this._mouseDownHandler = this._mouseDownHandler.bind(this),
- this._mouseWheelHandler = this._mouseWheelHandler.bind(this),
- this._mouseMoveHandler = this._mouseMoveHandler.bind(this),
- this._mouseUpHandler = this._mouseUpHandler.bind(this),
- this._update = this._update.bind(this)
- }
- ), {
- init: function () {
- var e = this.zr;
- e.on("mousedown", this._mouseDownHandler),
- e.on("mousewheel", this._mouseWheelHandler),
- e.on("globalout", this._mouseUpHandler),
- e.animation.on("frame", this._update)
- },
- setTarget: function (e) {
- this._target = e
- },
- setZoom: function (e) {
- this._zoom = Math.max(Math.min(e, this.maxZoom), this.minZoom),
- this._needsUpdate = !0
- },
- setOffset: function (e) {
- this._dx = e[0],
- this._dy = e[1],
- this._needsUpdate = !0
- },
- getZoom: function () {
- return this._zoom
- },
- getOffset: function () {
- return [this._dx, this._dy]
- },
- _update: function () {
- if (this._target && this._needsUpdate) {
- var e = this._target
- , t = this._zoom;
- e.position.x = this._dx,
- e.position.y = this._dy,
- e.scale.set(t, t, t),
- this.zr.refresh(),
- this._needsUpdate = !1,
- this.trigger("update")
- }
- },
- _mouseDownHandler: function (e) {
- if (!e.target) {
- var t = e.offsetX
- , r = e.offsetY;
- if (!this.viewGL || this.viewGL.containPoint(t, r)) {
- this.zr.on("mousemove", this._mouseMoveHandler),
- this.zr.on("mouseup", this._mouseUpHandler);
- var i = this._convertPos(t, r);
- this._x = i.x,
- this._y = i.y
- }
- }
- },
- _convertPos: function (e, t) {
- var r = this.viewGL.camera
- , i = this.viewGL.viewport;
- return {
- x: (e - i.x) / i.width * (r.right - r.left) + r.left,
- y: (t - i.y) / i.height * (r.bottom - r.top) + r.top
- }
- },
- _mouseMoveHandler: function (e) {
- var t = this._convertPos(e.offsetX, e.offsetY);
- this._dx += t.x - this._x,
- this._dy += t.y - this._y,
- this._x = t.x,
- this._y = t.y,
- this._needsUpdate = !0
- },
- _mouseUpHandler: function (e) {
- this.zr.off("mousemove", this._mouseMoveHandler),
- this.zr.off("mouseup", this._mouseUpHandler)
- },
- _mouseWheelHandler: function (e) {
- var t = (e = e.event).wheelDelta || -e.detail;
- if (0 !== t) {
- var r = e.offsetX
- , i = e.offsetY;
- if (!this.viewGL || this.viewGL.containPoint(r, i)) {
- var n = t > 0 ? 1.1 : .9
- , a = Math.max(Math.min(this._zoom * n, this.maxZoom), this.minZoom);
- n = a / this._zoom;
- var o = this._convertPos(r, i)
- , s = (o.x - this._dx) * (n - 1)
- , l = (o.y - this._dy) * (n - 1);
- this._dx -= s,
- this._dy -= l,
- this._zoom = a,
- this._needsUpdate = !0
- }
- }
- },
- dispose: function () {
- var e = this.zr;
- e.off("mousedown", this._mouseDownHandler),
- e.off("mousemove", this._mouseMoveHandler),
- e.off("mouseup", this._mouseUpHandler),
- e.off("mousewheel", this._mouseWheelHandler),
- e.off("globalout", this._mouseUpHandler),
- e.animation.off("frame", this._update)
- }
- });
- var Jd = Po.vec2;
- Ka.Shader.import("@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end");
- var $d = 1;
- const ef = i.ChartView.extend({
- type: "graphGL",
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this.viewGL = new Il("orthographic"),
- this.viewGL.camera.left = this.viewGL.camera.right = 0,
- this.viewGL.add(this.groupGL),
- this._pointsBuilder = new Fc(!0, t),
- this._forceEdgesMesh = new Ka.Mesh({
- material: new Ka.Material({
- shader: Ka.createShader("ecgl.forceAtlas2.edges"),
- transparent: !0,
- depthMask: !1,
- depthTest: !1
- }),
- $ignorePicking: !0,
- geometry: new Ka.Geometry({
- attributes: {
- node: new Ka.Geometry.Attribute("node", "float", 2),
- color: new Ka.Geometry.Attribute("color", "float", 4, "COLOR")
- },
- dynamic: !0,
- mainAttribute: "node"
- }),
- renderOrder: -1,
- mode: Ka.Mesh.LINES
- }),
- this._edgesMesh = new Ka.Mesh({
- material: new Ka.Material({
- shader: Ka.createShader("ecgl.meshLines2D"),
- transparent: !0,
- depthMask: !1,
- depthTest: !1
- }),
- $ignorePicking: !0,
- geometry: new Hd({
- useNativeLine: !1,
- dynamic: !0
- }),
- renderOrder: -1,
- culling: !1
- }),
- this._layoutId = 0,
- this._control = new Qd({
- zr: t.getZr(),
- viewGL: this.viewGL
- }),
- this._control.setTarget(this.groupGL),
- this._control.init(),
- this._clickHandler = this._clickHandler.bind(this)
- },
- render: function (e, t, r) {
- this.groupGL.add(this._pointsBuilder.rootNode),
- this._model = e,
- this._api = r,
- this._initLayout(e, t, r),
- this._pointsBuilder.update(e, t, r),
- this._forceLayoutInstance instanceof Xd || this.groupGL.remove(this._forceEdgesMesh),
- this._updateCamera(e, r),
- this._control.off("update"),
- this._control.on("update", (function () {
- r.dispatchAction({
- type: "graphGLRoam",
- seriesId: e.id,
- zoom: this._control.getZoom(),
- offset: this._control.getOffset()
- }),
- this._pointsBuilder.updateView(this.viewGL.camera)
- }
- ), this),
- this._control.setZoom(Mn(e.get("zoom"), 1)),
- this._control.setOffset(e.get("offset") || [0, 0]);
- var i = this._pointsBuilder.getPointsMesh();
- if (i.off("mousemove", this._mousemoveHandler),
- i.off("mouseout", this._mouseOutHandler, this),
- r.getZr().off("click", this._clickHandler),
- this._pointsBuilder.highlightOnMouseover = !0,
- e.get("focusNodeAdjacency")) {
- var n = e.get("focusNodeAdjacencyOn");
- "click" === n ? r.getZr().on("click", this._clickHandler) : "mouseover" === n && (i.on("mousemove", this._mousemoveHandler, this),
- i.on("mouseout", this._mouseOutHandler, this),
- this._pointsBuilder.highlightOnMouseover = !1)
- }
- this._lastMouseOverDataIndex = -1
- },
- _clickHandler: function (e) {
- if (!this._layouting) {
- var t = this._pointsBuilder.getPointsMesh().dataIndex;
- t >= 0 ? this._api.dispatchAction({
- type: "graphGLFocusNodeAdjacency",
- seriesId: this._model.id,
- dataIndex: t
- }) : this._api.dispatchAction({
- type: "graphGLUnfocusNodeAdjacency",
- seriesId: this._model.id
- })
- }
- },
- _mousemoveHandler: function (e) {
- if (!this._layouting) {
- var t = this._pointsBuilder.getPointsMesh().dataIndex;
- t >= 0 ? t !== this._lastMouseOverDataIndex && this._api.dispatchAction({
- type: "graphGLFocusNodeAdjacency",
- seriesId: this._model.id,
- dataIndex: t
- }) : this._mouseOutHandler(e),
- this._lastMouseOverDataIndex = t
- }
- },
- _mouseOutHandler: function (e) {
- this._layouting || (this._api.dispatchAction({
- type: "graphGLUnfocusNodeAdjacency",
- seriesId: this._model.id
- }),
- this._lastMouseOverDataIndex = -1)
- },
- _updateForceEdgesGeometry: function (e, t) {
- var r = this._forceEdgesMesh.geometry
- , i = t.getEdgeData()
- , n = 0
- , a = this._forceLayoutInstance
- , o = 2 * i.count();
- r.attributes.node.init(o),
- r.attributes.color.init(o),
- i.each((function (t) {
- var o = e[t];
- r.attributes.node.set(n, a.getNodeUV(o.node1)),
- r.attributes.node.set(n + 1, a.getNodeUV(o.node2));
- var s = Ih(i, o.dataIndex)
- , l = Ka.parseColor(s);
- l[3] *= Mn(Rh(i, o.dataIndex), 1),
- r.attributes.color.set(n, l),
- r.attributes.color.set(n + 1, l),
- n += 2
- }
- )),
- r.dirty()
- },
- _updateMeshLinesGeometry: function () {
- var e = this._model.getEdgeData()
- , t = this._edgesMesh.geometry
- , r = (e = this._model.getEdgeData(),
- this._model.getData().getLayout("points"));
- t.resetOffset(),
- t.setVertexCount(e.count() * t.getLineVertexCount()),
- t.setTriangleCount(e.count() * t.getLineTriangleCount());
- var i = []
- , n = []
- , a = ["lineStyle", "width"];
- this._originalEdgeColors = new Float32Array(4 * e.count()),
- this._edgeIndicesMap = new Float32Array(e.count()),
- e.each((function (o) {
- var s = e.graph.getEdgeByIndex(o)
- , l = 2 * s.node1.dataIndex
- , h = 2 * s.node2.dataIndex;
- i[0] = r[l],
- i[1] = r[l + 1],
- n[0] = r[h],
- n[1] = r[h + 1];
- var u = Ih(e, s.dataIndex)
- , c = Ka.parseColor(u);
- c[3] *= Mn(Rh(e, s.dataIndex), 1);
- var d = e.getItemModel(s.dataIndex)
- , f = Mn(d.get(a), 1) * this._api.getDevicePixelRatio();
- t.addLine(i, n, c, f);
- for (var p = 0; p < 4; p++)
- this._originalEdgeColors[4 * s.dataIndex + p] = c[p];
- this._edgeIndicesMap[s.dataIndex] = o
- }
- ), this),
- t.dirty()
- },
- _updateForceNodesGeometry: function (e) {
- for (var t = this._pointsBuilder.getPointsMesh(), r = [], i = 0; i < e.count(); i++)
- this._forceLayoutInstance.getNodeUV(i, r),
- t.geometry.attributes.position.set(i, r);
- t.geometry.dirty("position")
- },
- _initLayout: function (e, t, r) {
- var n = e.get("layout")
- , a = e.getGraph()
- , o = Ss(e.getBoxLayoutParams(), {
- width: r.getWidth(),
- height: r.getHeight()
- });
- "force" === n && (n = "forceAtlas2"),
- this.stopLayout(e, t, r, {
- beforeLayout: !0
- });
- var s = e.getData()
- , l = e.getData();
- if ("forceAtlas2" === n) {
- var h = e.getModel("forceAtlas2")
- , u = this._forceLayoutInstance
- , c = []
- , d = []
- , f = s.getDataExtent("value")
- , p = l.getDataExtent("value")
- , m = Mn(h.get("edgeWeight"), 1)
- , g = Mn(h.get("nodeWeight"), 1);
- "number" == typeof m && (m = [m, m]),
- "number" == typeof g && (g = [g, g]);
- var _ = 0
- , v = {}
- , y = new Float32Array(2 * s.count());
- if (a.eachNode((function (e) {
- var t, r, n = e.dataIndex, a = s.get("value", n);
- if (s.hasItemOption) {
- var l = s.getItemModel(n);
- t = l.get("x"),
- r = l.get("y")
- }
- null == t && (t = o.x + Math.random() * o.width,
- r = o.y + Math.random() * o.height),
- y[2 * _] = t,
- y[2 * _ + 1] = r,
- v[e.id] = _++;
- var h = i.number.linearMap(a, f, g);
- isNaN(h) && (h = isNaN(g[0]) ? 1 : g[0]),
- c.push({
- x: t,
- y: r,
- mass: h,
- size: s.getItemVisual(n, "symbolSize")
- })
- }
- )),
- s.setLayout("points", y),
- a.eachEdge((function (e) {
- var t = e.dataIndex
- , r = s.get("value", t)
- , n = i.number.linearMap(r, p, m);
- isNaN(n) && (n = isNaN(m[0]) ? 1 : m[0]),
- d.push({
- node1: v[e.node1.id],
- node2: v[e.node2.id],
- weight: n,
- dataIndex: t
- })
- }
- )),
- !u) {
- var x = h.get("GPU");
- this._forceLayoutInstance && ((!x || this._forceLayoutInstance instanceof Xd) && (x || this._forceLayoutInstance instanceof Kd) || (this._forceLayoutInstanceToDispose = this._forceLayoutInstance)),
- u = this._forceLayoutInstance = x ? new Xd : new Kd
- }
- u.initData(c, d),
- u.updateOption(h.option),
- this._updateForceEdgesGeometry(u.getEdges(), e),
- this._updatePositionTexture(),
- r.dispatchAction({
- type: "graphGLStartLayout",
- from: this.uid
- })
- } else
- y = new Float32Array(2 * s.count()),
- _ = 0,
- a.eachNode((function (e) {
- var t, r, i = e.dataIndex;
- if (s.hasItemOption) {
- var n = s.getItemModel(i);
- t = n.get("x"),
- r = n.get("y")
- }
- y[_++] = t,
- y[_++] = r
- }
- )),
- s.setLayout("points", y),
- this._updateAfterLayout(e, t, r)
- },
- _updatePositionTexture: function () {
- var e = this._forceLayoutInstance.getNodePositionTexture();
- this._pointsBuilder.setPositionTexture(e),
- this._forceEdgesMesh.material.set("positionTex", e)
- },
- startLayout: function (e, t, r, i) {
- if (!i || null == i.from || i.from === this.uid) {
- var n = this.viewGL
- , a = (r = this._api,
- this._forceLayoutInstance)
- , o = this._model.getData()
- , s = this._model.getModel("forceAtlas2");
- if (a && (this.groupGL.remove(this._edgesMesh),
- this.groupGL.add(this._forceEdgesMesh),
- this._forceLayoutInstance)) {
- this._updateForceNodesGeometry(e.getData()),
- this._pointsBuilder.hideLabels();
- var l = this
- , h = this._layoutId = $d++
- , u = s.getShallow("maxSteps")
- , c = s.getShallow("steps")
- , d = 0
- , f = Math.max(2 * c, 20)
- , p = function (t) {
- if (t === l._layoutId)
- return a.isFinished(u) ? (r.dispatchAction({
- type: "graphGLStopLayout",
- from: l.uid
- }),
- void r.dispatchAction({
- type: "graphGLFinishLayout",
- points: o.getLayout("points"),
- from: l.uid
- })) : void a.update(n.layer.renderer, c, (function () {
- l._updatePositionTexture(),
- (d += c) >= f && (l._syncNodePosition(e),
- d = 0),
- r.getZr().refresh(),
- Qa((function () {
- p(t)
- }
- ))
- }
- ))
- };
- Qa((function () {
- l._forceLayoutInstanceToDispose && (l._forceLayoutInstanceToDispose.dispose(n.layer.renderer),
- l._forceLayoutInstanceToDispose = null),
- p(h)
- }
- )),
- this._layouting = !0
- }
- }
- },
- stopLayout: function (e, t, r, i) {
- i && null != i.from && i.from !== this.uid || (this._layoutId = 0,
- this.groupGL.remove(this._forceEdgesMesh),
- this.groupGL.add(this._edgesMesh),
- this._forceLayoutInstance && this.viewGL.layer && (i && i.beforeLayout || (this._syncNodePosition(e),
- this._updateAfterLayout(e, t, r)),
- this._api.getZr().refresh(),
- this._layouting = !1))
- },
- _syncNodePosition: function (e) {
- var t = this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);
- e.getData().setLayout("points", t),
- e.setNodePosition(t)
- },
- _updateAfterLayout: function (e, t, r) {
- this._updateMeshLinesGeometry(),
- this._pointsBuilder.removePositionTexture(),
- this._pointsBuilder.updateLayout(e, t, r),
- this._pointsBuilder.updateView(this.viewGL.camera),
- this._pointsBuilder.updateLabels(),
- this._pointsBuilder.showLabels()
- },
- focusNodeAdjacency: function (e, t, r, i) {
- var n = this._model.getData();
- this._downplayAll();
- var a = i.dataIndex
- , o = n.graph
- , s = []
- , l = o.getNodeByIndex(a);
- s.push(l),
- l.edges.forEach((function (e) {
- e.dataIndex < 0 || (e.node1 !== l && s.push(e.node1),
- e.node2 !== l && s.push(e.node2))
- }
- ), this),
- this._pointsBuilder.fadeOutAll(.05),
- this._fadeOutEdgesAll(.05),
- s.forEach((function (e) {
- this._pointsBuilder.highlight(n, e.dataIndex)
- }
- ), this),
- this._pointsBuilder.updateLabels(s.map((function (e) {
- return e.dataIndex
- }
- )));
- var h = [];
- l.edges.forEach((function (e) {
- e.dataIndex >= 0 && (this._highlightEdge(e.dataIndex),
- h.push(e))
- }
- ), this),
- this._focusNodes = s,
- this._focusEdges = h
- },
- unfocusNodeAdjacency: function (e, t, r, i) {
- this._downplayAll(),
- this._pointsBuilder.fadeInAll(),
- this._fadeInEdgesAll(),
- this._pointsBuilder.updateLabels()
- },
- _highlightEdge: function (e) {
- var t = this._model.getEdgeData().getItemModel(e)
- , r = Ka.parseColor(t.get("emphasis.lineStyle.color") || t.get("lineStyle.color"))
- , i = Mn(t.get("emphasis.lineStyle.opacity"), t.get("lineStyle.opacity"), 1);
- r[3] *= i,
- this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e], r)
- },
- _downplayAll: function () {
- this._focusNodes && this._focusNodes.forEach((function (e) {
- this._pointsBuilder.downplay(this._model.getData(), e.dataIndex)
- }
- ), this),
- this._focusEdges && this._focusEdges.forEach((function (e) {
- this._downplayEdge(e.dataIndex)
- }
- ), this)
- },
- _downplayEdge: function (e) {
- var t = this._getColor(e, []);
- this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e], t)
- },
- _setEdgeFade: (tf = [],
- function (e, t) {
- this._getColor(e, tf),
- tf[3] *= t,
- this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e], tf)
- }
- ),
- _getColor: function (e, t) {
- for (var r = 0; r < 4; r++)
- t[r] = this._originalEdgeColors[4 * e + r];
- return t
- },
- _fadeOutEdgesAll: function (e) {
- this._model.getData().graph.eachEdge((function (t) {
- this._setEdgeFade(t.dataIndex, e)
- }
- ), this)
- },
- _fadeInEdgesAll: function () {
- this._fadeOutEdgesAll(1)
- },
- _updateCamera: function (e, t) {
- this.viewGL.setViewport(0, 0, t.getWidth(), t.getHeight(), t.getDevicePixelRatio());
- for (var r = this.viewGL.camera, i = e.getData().getLayout("points"), n = Jd.create(1 / 0, 1 / 0), a = Jd.create(-1 / 0, -1 / 0), o = [], s = 0; s < i.length;)
- o[0] = i[s++],
- o[1] = i[s++],
- Jd.min(n, n, o),
- Jd.max(a, a, o);
- var l = (a[1] + n[1]) / 2
- , h = (a[0] + n[0]) / 2;
- if (!(h > r.left && h < r.right && l < r.bottom && l > r.top)) {
- var u = Math.max(a[0] - n[0], 10)
- , c = u / t.getWidth() * t.getHeight();
- u *= 1.4,
- c *= 1.4,
- n[0] -= .2 * u,
- r.left = n[0],
- r.top = l - c / 2,
- r.bottom = l + c / 2,
- r.right = u + n[0],
- r.near = 0,
- r.far = 100
- }
- },
- dispose: function () {
- var e = this.viewGL.layer.renderer;
- this._forceLayoutInstance && this._forceLayoutInstance.dispose(e),
- this.groupGL.removeAll(),
- this._layoutId = -1,
- this._pointsBuilder.dispose()
- },
- remove: function () {
- this.groupGL.removeAll(),
- this._control.dispose()
- }
- });
- var tf;
- function rf(e) {
- return e instanceof Array || (e = [e, e]),
- e
- }
- (0,
- i.use)((function (e) {
- function t() { }
- e.registerChartView(ef),
- e.registerSeriesModel(Gd),
- e.registerVisual((function (e) {
- const t = {};
- e.eachSeriesByType("graphGL", (function (e) {
- var r = e.getCategoriesData()
- , n = e.getData()
- , a = {};
- r.each((function (i) {
- var n = r.getName(i);
- a["ec-" + n] = i;
- var o = r.getItemModel(i)
- , s = o.getModel("itemStyle").getItemStyle();
- s.fill || (s.fill = e.getColorFromPalette(n, t)),
- r.setItemVisual(i, "style", s);
- var l = ["symbol", "symbolSize", "symbolKeepAspect"];
- for (let e = 0; e < l.length; e++) {
- var h = o.getShallow(l[e], !0);
- null != h && r.setItemVisual(i, l[e], h)
- }
- }
- )),
- r.count() && n.each((function (e) {
- let t = n.getItemModel(e).getShallow("category");
- if (null != t) {
- "string" == typeof t && (t = a["ec-" + t]);
- var o = r.getItemVisual(t, "style")
- , s = n.ensureUniqueItemVisual(e, "style");
- i.util.extend(s, o);
- var l = ["symbol", "symbolSize", "symbolKeepAspect"];
- for (let i = 0; i < l.length; i++)
- n.setItemVisual(e, l[i], r.getItemVisual(t, l[i]))
- }
- }
- ))
- }
- ))
- }
- )),
- e.registerVisual((function (e) {
- e.eachSeriesByType("graphGL", (function (e) {
- var t = e.getGraph()
- , r = e.getEdgeData()
- , n = rf(e.get("edgeSymbol"))
- , a = rf(e.get("edgeSymbolSize"));
- r.setVisual("drawType", "stroke"),
- r.setVisual("fromSymbol", n && n[0]),
- r.setVisual("toSymbol", n && n[1]),
- r.setVisual("fromSymbolSize", a && a[0]),
- r.setVisual("toSymbolSize", a && a[1]),
- r.setVisual("style", e.getModel("lineStyle").getLineStyle()),
- r.each((function (e) {
- var n = r.getItemModel(e)
- , a = t.getEdgeByIndex(e)
- , o = rf(n.getShallow("symbol", !0))
- , s = rf(n.getShallow("symbolSize", !0))
- , l = n.getModel("lineStyle").getLineStyle()
- , h = r.ensureUniqueItemVisual(e, "style");
- switch (i.util.extend(h, l),
- h.stroke) {
- case "source":
- var u = a.node1.getVisual("style");
- h.stroke = u && u.fill;
- break;
- case "target":
- u = a.node2.getVisual("style"),
- h.stroke = u && u.fill
- }
- o[0] && a.setVisual("fromSymbol", o[0]),
- o[1] && a.setVisual("toSymbol", o[1]),
- s[0] && a.setVisual("fromSymbolSize", s[0]),
- s[1] && a.setVisual("toSymbolSize", s[1])
- }
- ))
- }
- ))
- }
- )),
- e.registerAction({
- type: "graphGLRoam",
- event: "graphglroam",
- update: "series.graphGL:roam"
- }, (function (e, t) {
- t.eachComponent({
- mainType: "series",
- query: e
- }, (function (t) {
- t.setView(e)
- }
- ))
- }
- )),
- e.registerAction({
- type: "graphGLStartLayout",
- event: "graphgllayoutstarted",
- update: "series.graphGL:startLayout"
- }, t),
- e.registerAction({
- type: "graphGLStopLayout",
- event: "graphgllayoutstopped",
- update: "series.graphGL:stopLayout"
- }, t),
- e.registerAction({
- type: "graphGLFocusNodeAdjacency",
- event: "graphGLFocusNodeAdjacency",
- update: "series.graphGL:focusNodeAdjacency"
- }, t),
- e.registerAction({
- type: "graphGLUnfocusNodeAdjacency",
- event: "graphGLUnfocusNodeAdjacency",
- update: "series.graphGL:unfocusNodeAdjacency"
- }, t)
- }
- ));
- const nf = i.SeriesModel.extend({
- type: "series.flowGL",
- dependencies: ["geo", "grid", "bmap"],
- visualStyleAccessPath: "itemStyle",
- getInitialData: function (e, t) {
- var r = this.get("coordinateSystem")
- , n = "geo" === r ? ["lng", "lat"] : i.getCoordinateSystemDimensions(r) || ["x", "y"];
- n.push("vx", "vy");
- var a = i.helper.createDimensions(this.getSource(), {
- coordDimensions: n,
- encodeDefine: this.get("encode"),
- dimensionsDefine: this.get("dimensions")
- })
- , o = new i.List(a, this);
- return o.initData(this.getSource()),
- o
- },
- defaultOption: {
- coordinateSystem: "cartesian2d",
- zlevel: 10,
- supersampling: 1,
- particleType: "point",
- particleDensity: 128,
- particleSize: 1,
- particleSpeed: 1,
- particleTrail: 2,
- colorTexture: null,
- gridWidth: "auto",
- gridHeight: "auto",
- itemStyle: {
- color: "#fff",
- opacity: .8
- }
- }
- })
- , af = Vr.extend((function () {
- return {
- dynamic: !0,
- attributes: {
- position: new Vr.Attribute("position", "float", 3, "POSITION")
- }
- }
- }
- ), {
- resetOffset: function () {
- this._vertexOffset = 0,
- this._faceOffset = 0
- },
- setLineCount: function (e) {
- var t = this.attributes
- , r = 4 * e
- , i = 2 * e;
- this.vertexCount !== r && t.position.init(r),
- this.triangleCount !== i && (this.indices = 0 === i ? null : this.vertexCount > 65535 ? new Uint32Array(3 * i) : new Uint16Array(3 * i))
- },
- addLine: function (e) {
- var t = this._vertexOffset;
- this.attributes.position.set(t, [e[0], e[1], 1]),
- this.attributes.position.set(t + 1, [e[0], e[1], -1]),
- this.attributes.position.set(t + 2, [e[0], e[1], 2]),
- this.attributes.position.set(t + 3, [e[0], e[1], -2]),
- this.setTriangleIndices(this._faceOffset++, [t, t + 1, t + 2]),
- this.setTriangleIndices(this._faceOffset++, [t + 1, t + 2, t + 3]),
- this._vertexOffset += 4
- }
- });
- Xe.import("@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n");
- var of = function () {
- this.motionBlurFactor = .99,
- this.vectorFieldTexture = new Dr({
- type: wr.FLOAT,
- flipY: !1
- }),
- this.particleLife = [5, 20],
- this._particleType = "point",
- this._particleSize = 1,
- this.particleColor = [1, 1, 1, 1],
- this.particleSpeedScaling = 1,
- this._thisFrameTexture = null,
- this._particlePass = null,
- this._spawnTexture = null,
- this._particleTexture0 = null,
- this._particleTexture1 = null,
- this._particlePointsMesh = null,
- this._surfaceFrameBuffer = null,
- this._elapsedTime = 0,
- this._scene = null,
- this._camera = null,
- this._lastFrameTexture = null,
- this._supersampling = 1,
- this._downsampleTextures = [],
- this._width = 512,
- this._height = 512,
- this.init()
- };
- of.prototype = {
- constructor: of,
- init: function () {
- var e = {
- type: wr.FLOAT,
- minFilter: wr.NEAREST,
- magFilter: wr.NEAREST,
- useMipmap: !1
- };
- this._spawnTexture = new Dr(e),
- this._particleTexture0 = new Dr(e),
- this._particleTexture1 = new Dr(e),
- this._frameBuffer = new zi({
- depthBuffer: !1
- }),
- this._particlePass = new pn({
- fragment: Xe.source("ecgl.vfParticle.particle.fragment")
- }),
- this._particlePass.setUniform("velocityTexture", this.vectorFieldTexture),
- this._particlePass.setUniform("spawnTexture", this._spawnTexture),
- this._downsamplePass = new pn({
- fragment: Xe.source("clay.compositor.downsample")
- });
- var t = new Sr({
- renderOrder: 10,
- material: new le({
- shader: new Xe(Xe.source("ecgl.vfParticle.renderPoints.vertex"), Xe.source("ecgl.vfParticle.renderPoints.fragment"))
- }),
- mode: Sr.POINTS,
- geometry: new Vr({
- dynamic: !0,
- mainAttribute: "texcoord0"
- })
- })
- , r = new Sr({
- renderOrder: 10,
- material: new le({
- shader: new Xe(Xe.source("ecgl.vfParticle.renderLines.vertex"), Xe.source("ecgl.vfParticle.renderLines.fragment"))
- }),
- geometry: new af,
- culling: !1
- })
- , i = new Sr({
- material: new le({
- shader: new Xe(Xe.source("ecgl.color.vertex"), Xe.source("ecgl.color.fragment"))
- }),
- geometry: new ki
- });
- i.material.enableTexture("diffuseMap"),
- this._particlePointsMesh = t,
- this._particleLinesMesh = r,
- this._lastFrameFullQuadMesh = i,
- this._camera = new un,
- this._thisFrameTexture = new Dr,
- this._lastFrameTexture = new Dr
- },
- setParticleDensity: function (e, t) {
- for (var r = new Float32Array(e * t * 4), i = 0, n = this.particleLife, a = 0; a < e; a++)
- for (var o = 0; o < t; o++,
- i++) {
- r[4 * i] = Math.random(),
- r[4 * i + 1] = Math.random(),
- r[4 * i + 2] = Math.random();
- var s = (n[1] - n[0]) * Math.random() + n[0];
- r[4 * i + 3] = s
- }
- "line" === this._particleType ? this._setLineGeometry(e, t) : this._setPointsGeometry(e, t),
- this._spawnTexture.width = e,
- this._spawnTexture.height = t,
- this._spawnTexture.pixels = r,
- this._particleTexture0.width = this._particleTexture1.width = e,
- this._particleTexture0.height = this._particleTexture1.height = t,
- this._particlePass.setUniform("textureSize", [e, t])
- },
- _setPointsGeometry: function (e, t) {
- var r = e * t
- , i = this._particlePointsMesh.geometry
- , n = i.attributes;
- n.texcoord0.init(r);
- for (var a = 0, o = 0; o < e; o++)
- for (var s = 0; s < t; s++,
- a++)
- n.texcoord0.value[2 * a] = o / e,
- n.texcoord0.value[2 * a + 1] = s / t;
- i.dirty()
- },
- _setLineGeometry: function (e, t) {
- var r = e * t
- , i = this._getParticleMesh().geometry;
- i.setLineCount(r),
- i.resetOffset();
- for (var n = 0; n < e; n++)
- for (var a = 0; a < t; a++)
- i.addLine([n / e, a / t]);
- i.dirty()
- },
- _getParticleMesh: function () {
- return "line" === this._particleType ? this._particleLinesMesh : this._particlePointsMesh
- },
- update: function (e, t, r, i) {
- var n = this._getParticleMesh()
- , a = this._frameBuffer
- , o = this._particlePass;
- i && this._updateDownsampleTextures(e, t),
- n.material.set("size", this._particleSize * this._supersampling),
- n.material.set("color", this.particleColor),
- o.setUniform("speedScaling", this.particleSpeedScaling),
- a.attach(this._particleTexture1),
- o.setUniform("firstFrameTime", i ? (this.particleLife[1] + this.particleLife[0]) / 2 : 0),
- o.setUniform("particleTexture", this._particleTexture0),
- o.setUniform("deltaTime", r),
- o.setUniform("elapsedTime", this._elapsedTime),
- o.render(e, a),
- n.material.set("particleTexture", this._particleTexture1),
- n.material.set("prevParticleTexture", this._particleTexture0),
- a.attach(this._thisFrameTexture),
- a.bind(e),
- e.gl.clear(e.gl.DEPTH_BUFFER_BIT | e.gl.COLOR_BUFFER_BIT);
- var s = this._lastFrameFullQuadMesh;
- s.material.set("diffuseMap", this._lastFrameTexture),
- s.material.set("color", [1, 1, 1, this.motionBlurFactor]),
- this._camera.update(!0),
- e.renderPass([s, n], this._camera),
- a.unbind(e),
- this._downsample(e),
- this._swapTexture(),
- this._elapsedTime += r
- },
- _downsample: function (e) {
- var t = this._downsampleTextures;
- if (0 !== t.length)
- for (var r = 0, i = this._thisFrameTexture, n = t[r]; n;)
- this._frameBuffer.attach(n),
- this._downsamplePass.setUniform("texture", i),
- this._downsamplePass.setUniform("textureSize", [i.width, i.height]),
- this._downsamplePass.render(e, this._frameBuffer),
- i = n,
- n = t[++r]
- },
- getSurfaceTexture: function () {
- var e = this._downsampleTextures;
- return e.length > 0 ? e[e.length - 1] : this._lastFrameTexture
- },
- setRegion: function (e) {
- this._particlePass.setUniform("region", e)
- },
- resize: function (e, t) {
- this._lastFrameTexture.width = e * this._supersampling,
- this._lastFrameTexture.height = t * this._supersampling,
- this._thisFrameTexture.width = e * this._supersampling,
- this._thisFrameTexture.height = t * this._supersampling,
- this._width = e,
- this._height = t
- },
- setParticleSize: function (e) {
- var t = this._getParticleMesh();
- if (e <= 2)
- return t.material.disableTexture("spriteTexture"),
- void (t.material.transparent = !1);
- this._spriteTexture || (this._spriteTexture = new Dr),
- this._spriteTexture.image && this._spriteTexture.image.width === e || (this._spriteTexture.image = function (e) {
- var t = document.createElement("canvas");
- t.width = t.height = e;
- var r = t.getContext("2d");
- return r.fillStyle = "#fff",
- r.arc(e / 2, e / 2, e / 2, 0, 2 * Math.PI),
- r.fill(),
- t
- }(e),
- this._spriteTexture.dirty()),
- t.material.transparent = !0,
- t.material.enableTexture("spriteTexture"),
- t.material.set("spriteTexture", this._spriteTexture),
- this._particleSize = e
- },
- setGradientTexture: function (e) {
- var t = this._getParticleMesh().material;
- t[e ? "enableTexture" : "disableTexture"]("gradientTexture"),
- t.setUniform("gradientTexture", e)
- },
- setColorTextureImage: function (e, t) {
- this._getParticleMesh().material.setTextureImage("colorTexture", e, t, {
- flipY: !0
- })
- },
- setParticleType: function (e) {
- this._particleType = e
- },
- clearFrame: function (e) {
- var t = this._frameBuffer;
- t.attach(this._lastFrameTexture),
- t.bind(e),
- e.gl.clear(e.gl.DEPTH_BUFFER_BIT | e.gl.COLOR_BUFFER_BIT),
- t.unbind(e)
- },
- setSupersampling: function (e) {
- this._supersampling = e,
- this.resize(this._width, this._height)
- },
- _updateDownsampleTextures: function (e, t) {
- for (var r = this._downsampleTextures, i = Math.max(Math.floor(Math.log(this._supersampling / t.getDevicePixelRatio()) / Math.log(2)), 0), n = 2, a = this._width * this._supersampling, o = this._height * this._supersampling, s = 0; s < i; s++)
- r[s] = r[s] || new Dr,
- r[s].width = a / n,
- r[s].height = o / n,
- n *= 2;
- for (; s < r.length; s++)
- r[s].dispose(e);
- r.length = i
- },
- _swapTexture: function () {
- var e = this._particleTexture0;
- this._particleTexture0 = this._particleTexture1,
- this._particleTexture1 = e,
- e = this._thisFrameTexture,
- this._thisFrameTexture = this._lastFrameTexture,
- this._lastFrameTexture = e
- },
- dispose: function (e) {
- e.disposeFrameBuffer(this._frameBuffer),
- e.disposeTexture(this.vectorFieldTexture),
- e.disposeTexture(this._spawnTexture),
- e.disposeTexture(this._particleTexture0),
- e.disposeTexture(this._particleTexture1),
- e.disposeTexture(this._thisFrameTexture),
- e.disposeTexture(this._lastFrameTexture),
- e.disposeGeometry(this._particleLinesMesh.geometry),
- e.disposeGeometry(this._particlePointsMesh.geometry),
- e.disposeGeometry(this._lastFrameFullQuadMesh.geometry),
- this._spriteTexture && e.disposeTexture(this._spriteTexture),
- this._particlePass.dispose(e),
- this._downsamplePass.dispose(e),
- this._downsampleTextures.forEach((function (t) {
- t.dispose(e)
- }
- ))
- }
- };
- const sf = of
- , lf = i.ChartView.extend({
- type: "flowGL",
- __ecgl__: !0,
- init: function (e, t) {
- this.viewGL = new Il("orthographic"),
- this.groupGL = new Ka.Node,
- this.viewGL.add(this.groupGL),
- this._particleSurface = new sf;
- var r = new Ka.Mesh({
- geometry: new Ka.PlaneGeometry,
- material: new Ka.Material({
- shader: new Ka.Shader({
- vertex: Ka.Shader.source("ecgl.color.vertex"),
- fragment: Ka.Shader.source("ecgl.color.fragment")
- }),
- transparent: !0
- })
- });
- r.material.enableTexture("diffuseMap"),
- this.groupGL.add(r),
- this._planeMesh = r
- },
- render: function (e, t, r) {
- var i = this._particleSurface;
- i.setParticleType(e.get("particleType")),
- i.setSupersampling(e.get("supersampling")),
- this._updateData(e, r),
- this._updateCamera(r.getWidth(), r.getHeight(), r.getDevicePixelRatio());
- var n = Mn(e.get("particleDensity"), 128);
- i.setParticleDensity(n, n);
- var a = this._planeMesh
- , o = +new Date
- , s = this
- , l = !0;
- a.__percent = 0,
- a.stopAnimation(),
- a.animate("", {
- loop: !0
- }).when(1e5, {
- __percent: 1
- }).during((function () {
- var e = +new Date
- , t = Math.min(e - o, 20);
- o += t,
- s._renderer && (i.update(s._renderer, r, t / 1e3, l),
- a.material.set("diffuseMap", i.getSurfaceTexture())),
- l = !1
- }
- )).start();
- var h = e.getModel("itemStyle")
- , u = Ka.parseColor(h.get("color"));
- u[3] *= Mn(h.get("opacity"), 1),
- a.material.set("color", u),
- i.setColorTextureImage(e.get("colorTexture"), r),
- i.setParticleSize(e.get("particleSize")),
- i.particleSpeedScaling = e.get("particleSpeed"),
- i.motionBlurFactor = 1 - Math.pow(.1, e.get("particleTrail"))
- },
- updateTransform: function (e, t, r) {
- this._updateData(e, r)
- },
- afterRender: function (e, t, r, i) {
- var n = i.renderer;
- this._renderer = n
- },
- _updateData: function (e, t) {
- var r = e.coordinateSystem
- , i = r.dimensions.map((function (t) {
- return e.coordDimToDataDim(t)[0]
- }
- ))
- , n = e.getData()
- , a = n.getDataExtent(i[0])
- , o = n.getDataExtent(i[1])
- , s = e.get("gridWidth")
- , l = e.get("gridHeight");
- if (null == s || "auto" === s) {
- var h = (a[1] - a[0]) / (o[1] - o[0]);
- s = Math.round(Math.sqrt(h * n.count()))
- }
- null != l && "auto" !== l || (l = Math.ceil(n.count() / s));
- var u = this._particleSurface.vectorFieldTexture
- , c = u.pixels;
- if (c && c.length === l * s * 4)
- for (var d = 0; d < c.length; d++)
- c[d] = 0;
- else
- c = u.pixels = new Float32Array(s * l * 4);
- var f = 0
- , p = 1 / 0
- , m = new Float32Array(2 * n.count())
- , g = 0
- , _ = [[1 / 0, 1 / 0], [-1 / 0, -1 / 0]];
- n.each([i[0], i[1], "vx", "vy"], (function (e, t, i, n) {
- var a = r.dataToPoint([e, t]);
- m[g++] = a[0],
- m[g++] = a[1],
- _[0][0] = Math.min(a[0], _[0][0]),
- _[0][1] = Math.min(a[1], _[0][1]),
- _[1][0] = Math.max(a[0], _[1][0]),
- _[1][1] = Math.max(a[1], _[1][1]);
- var o = Math.sqrt(i * i + n * n);
- f = Math.max(f, o),
- p = Math.min(p, o)
- }
- )),
- n.each(["vx", "vy"], (function (e, t, r) {
- var i = Math.round((m[2 * r] - _[0][0]) / (_[1][0] - _[0][0]) * (s - 1))
- , n = 4 * ((l - 1 - Math.round((m[2 * r + 1] - _[0][1]) / (_[1][1] - _[0][1]) * (l - 1))) * s + i);
- c[n] = e / f * .5 + .5,
- c[n + 1] = t / f * .5 + .5,
- c[n + 3] = 1
- }
- )),
- u.width = s,
- u.height = l,
- "bmap" === e.get("coordinateSystem") && this._fillEmptyPixels(u),
- u.dirty(),
- this._updatePlanePosition(_[0], _[1], e, t),
- this._updateGradientTexture(n.getVisual("visualMeta"), [p, f])
- },
- _fillEmptyPixels: function (e) {
- var t = e.pixels
- , r = e.width
- , i = e.height;
- function n(e, n, a) {
- e = Math.max(Math.min(e, r - 1), 0);
- var o = 4 * ((n = Math.max(Math.min(n, i - 1), 0)) * (r - 1) + e);
- return 0 !== t[o + 3] && (a[0] = t[o],
- a[1] = t[o + 1],
- !0)
- }
- function a(e, t, r) {
- r[0] = e[0] + t[0],
- r[1] = e[1] + t[1]
- }
- for (var o = [], s = [], l = [], h = [], u = [], c = 0, d = 0; d < i; d++)
- for (var f = 0; f < r; f++) {
- var p = 4 * (d * (r - 1) + f);
- 0 === t[p + 3] && (c = o[0] = o[1] = 0,
- n(f - 1, d, s) && (c++,
- a(s, o, o)),
- n(f + 1, d, l) && (c++,
- a(l, o, o)),
- n(f, d - 1, h) && (c++,
- a(h, o, o)),
- n(f, d + 1, u) && (c++,
- a(u, o, o)),
- o[0] /= c,
- o[1] /= c,
- t[p] = o[0],
- t[p + 1] = o[1]),
- t[p + 3] = 1
- }
- },
- _updateGradientTexture: function (e, t) {
- if (e && e.length) {
- this._gradientTexture = this._gradientTexture || new Ka.Texture2D({
- image: document.createElement("canvas")
- });
- var r = this._gradientTexture
- , i = r.image;
- i.width = 200,
- i.height = 1;
- var n = i.getContext("2d")
- , a = n.createLinearGradient(0, .5, i.width, .5);
- e[0].stops.forEach((function (e) {
- var r;
- t[1] === t[0] ? r = 0 : (r = e.value / t[1],
- r = Math.min(Math.max(r, 0), 1)),
- a.addColorStop(r, e.color)
- }
- )),
- n.fillStyle = a,
- n.fillRect(0, 0, i.width, i.height),
- r.dirty(),
- this._particleSurface.setGradientTexture(this._gradientTexture)
- } else
- this._particleSurface.setGradientTexture(null)
- },
- _updatePlanePosition: function (e, t, r, i) {
- var n = this._limitInViewportAndFullFill(e, t, r, i);
- e = n.leftTop,
- t = n.rightBottom,
- this._particleSurface.setRegion(n.region),
- this._planeMesh.position.set((e[0] + t[0]) / 2, i.getHeight() - (e[1] + t[1]) / 2, 0);
- var a = t[0] - e[0]
- , o = t[1] - e[1];
- this._planeMesh.scale.set(a / 2, o / 2, 1),
- this._particleSurface.resize(Math.max(Math.min(a, 2048), 1), Math.max(Math.min(o, 2048), 1)),
- this._renderer && this._particleSurface.clearFrame(this._renderer)
- },
- _limitInViewportAndFullFill: function (e, t, r, i) {
- var n = [Math.max(e[0], 0), Math.max(e[1], 0)]
- , a = [Math.min(t[0], i.getWidth()), Math.min(t[1], i.getHeight())];
- if ("bmap" === r.get("coordinateSystem")) {
- var o = r.getData().getDataExtent(r.coordDimToDataDim("lng")[0]);
- Math.floor(o[1] - o[0]) >= 359 && (n[0] > 0 && (n[0] = 0),
- a[0] < i.getWidth() && (a[0] = i.getWidth()))
- }
- var s = t[0] - e[0]
- , l = t[1] - e[1]
- , h = a[0] - n[0]
- , u = a[1] - n[1];
- return {
- leftTop: n,
- rightBottom: a,
- region: [(n[0] - e[0]) / s, 1 - u / l - (n[1] - e[1]) / l, h / s, u / l]
- }
- },
- _updateCamera: function (e, t, r) {
- this.viewGL.setViewport(0, 0, e, t, r);
- var i = this.viewGL.camera;
- i.left = i.bottom = 0,
- i.top = t,
- i.right = e,
- i.near = 0,
- i.far = 100,
- i.position.z = 10
- },
- remove: function () {
- this._planeMesh.stopAnimation(),
- this.groupGL.removeAll()
- },
- dispose: function () {
- this._renderer && this._particleSurface.dispose(this._renderer),
- this.groupGL.removeAll()
- }
- });
- (0,
- i.use)((function (e) {
- e.registerChartView(lf),
- e.registerSeriesModel(nf)
- }
- ));
- var hf = i.SeriesModel.extend({
- type: "series.linesGL",
- dependencies: ["grid", "geo"],
- visualStyleAccessPath: "lineStyle",
- visualDrawType: "stroke",
- streamEnabled: !0,
- init: function (e) {
- var t = this._processFlatCoordsArray(e.data);
- this._flatCoords = t.flatCoords,
- this._flatCoordsOffset = t.flatCoordsOffset,
- t.flatCoords && (e.data = new Float32Array(t.count)),
- hf.superApply(this, "init", arguments)
- },
- mergeOption: function (e) {
- var t = this._processFlatCoordsArray(e.data);
- this._flatCoords = t.flatCoords,
- this._flatCoordsOffset = t.flatCoordsOffset,
- t.flatCoords && (e.data = new Float32Array(t.count)),
- hf.superApply(this, "mergeOption", arguments)
- },
- appendData: function (e) {
- var t = this._processFlatCoordsArray(e.data);
- t.flatCoords && (this._flatCoords ? (this._flatCoords = Aa(this._flatCoords, t.flatCoords),
- this._flatCoordsOffset = Aa(this._flatCoordsOffset, t.flatCoordsOffset)) : (this._flatCoords = t.flatCoords,
- this._flatCoordsOffset = t.flatCoordsOffset),
- e.data = new Float32Array(t.count)),
- this.getRawData().appendData(e.data)
- },
- _getCoordsFromItemModel: function (e) {
- var t = this.getData().getItemModel(e);
- return t.option instanceof Array ? t.option : t.getShallow("coords")
- },
- getLineCoordsCount: function (e) {
- return this._flatCoordsOffset ? this._flatCoordsOffset[2 * e + 1] : this._getCoordsFromItemModel(e).length
- },
- getLineCoords: function (e, t) {
- if (this._flatCoordsOffset) {
- for (var r = this._flatCoordsOffset[2 * e], i = this._flatCoordsOffset[2 * e + 1], n = 0; n < i; n++)
- t[n] = t[n] || [],
- t[n][0] = this._flatCoords[r + 2 * n],
- t[n][1] = this._flatCoords[r + 2 * n + 1];
- return i
- }
- var a = this._getCoordsFromItemModel(e);
- for (n = 0; n < a.length; n++)
- t[n] = t[n] || [],
- t[n][0] = a[n][0],
- t[n][1] = a[n][1];
- return a.length
- },
- _processFlatCoordsArray: function (e) {
- var t = 0;
- if (this._flatCoords && (t = this._flatCoords.length),
- "number" == typeof e[0]) {
- for (var r = e.length, i = new Uint32Array(r), n = new Float64Array(r), a = 0, o = 0, s = 0, l = 0; l < r;) {
- s++;
- var h = e[l++];
- i[o++] = a + t,
- i[o++] = h;
- for (var u = 0; u < h; u++) {
- var c = e[l++]
- , d = e[l++];
- n[a++] = c,
- n[a++] = d
- }
- }
- return {
- flatCoordsOffset: new Uint32Array(i.buffer, 0, o),
- flatCoords: n,
- count: s
- }
- }
- return {
- flatCoordsOffset: null,
- flatCoords: null,
- count: e.length
- }
- },
- getInitialData: function (e, t) {
- var r = new i.List(["value"], this);
- return r.hasItemOption = !1,
- r.initData(e.data, [], (function (e, t, i, n) {
- if (e instanceof Array)
- return NaN;
- r.hasItemOption = !0;
- var a = e.value;
- return null != a ? a instanceof Array ? a[n] : a : void 0
- }
- )),
- r
- },
- defaultOption: {
- coordinateSystem: "geo",
- zlevel: 10,
- progressive: 1e4,
- progressiveThreshold: 5e4,
- blendMode: "source-over",
- lineStyle: {
- opacity: .8
- },
- postEffect: {
- enable: !1,
- colorCorrection: {
- exposure: 0,
- brightness: 0,
- contrast: 1,
- saturation: 1,
- enable: !0
- }
- }
- }
- });
- const uf = hf
- , cf = i.ChartView.extend({
- type: "linesGL",
- __ecgl__: !0,
- init: function (e, t) {
- this.groupGL = new Ka.Node,
- this.viewGL = new Il("orthographic"),
- this.viewGL.add(this.groupGL),
- this._glViewHelper = new wd(this.viewGL),
- this._nativeLinesShader = Ka.createShader("ecgl.lines3D"),
- this._meshLinesShader = Ka.createShader("ecgl.meshLines3D"),
- this._linesMeshes = [],
- this._currentStep = 0
- },
- render: function (e, t, r) {
- this.groupGL.removeAll(),
- this._glViewHelper.reset(e, r);
- var i = this._linesMeshes[0];
- i || (i = this._linesMeshes[0] = this._createLinesMesh(e)),
- this._linesMeshes.length = 1,
- this.groupGL.add(i),
- this._updateLinesMesh(e, i, 0, e.getData().count()),
- this.viewGL.setPostEffect(e.getModel("postEffect"), r)
- },
- incrementalPrepareRender: function (e, t, r) {
- this.groupGL.removeAll(),
- this._glViewHelper.reset(e, r),
- this._currentStep = 0,
- this.viewGL.setPostEffect(e.getModel("postEffect"), r)
- },
- incrementalRender: function (e, t, r, i) {
- var n = this._linesMeshes[this._currentStep];
- n || (n = this._createLinesMesh(t),
- this._linesMeshes[this._currentStep] = n),
- this._updateLinesMesh(t, n, e.start, e.end),
- this.groupGL.add(n),
- i.getZr().refresh(),
- this._currentStep++
- },
- updateTransform: function (e, t, r) {
- e.coordinateSystem.getRoamTransform && this._glViewHelper.updateTransform(e, r)
- },
- _createLinesMesh: function (e) {
- return new Ka.Mesh({
- $ignorePicking: !0,
- material: new Ka.Material({
- shader: Ka.createShader("ecgl.lines3D"),
- transparent: !0,
- depthMask: !1,
- depthTest: !1
- }),
- geometry: new Hd({
- segmentScale: 10,
- useNativeLine: !0,
- dynamic: !1
- }),
- mode: Ka.Mesh.LINES,
- culling: !1
- })
- },
- _updateLinesMesh: function (e, t, r, i) {
- var n = e.getData();
- t.material.blend = "lighter" === e.get("blendMode") ? Ka.additiveBlend : null;
- var a = e.get("lineStyle.curveness") || 0
- , o = e.get("polyline")
- , s = t.geometry
- , l = e.coordinateSystem
- , h = Mn(e.get("lineStyle.width"), 1);
- h > 1 ? (t.material.shader !== this._meshLinesShader && t.material.attachShader(this._meshLinesShader),
- t.mode = Ka.Mesh.TRIANGLES) : (t.material.shader !== this._nativeLinesShader && t.material.attachShader(this._nativeLinesShader),
- t.mode = Ka.Mesh.LINES),
- r = r || 0,
- i = i || n.count(),
- s.resetOffset();
- var u = 0
- , c = 0
- , d = []
- , f = []
- , p = []
- , m = []
- , g = []
- , _ = .3
- , v = .7;
- function y() {
- f[0] = d[0] * v + m[0] * _ - (d[1] - m[1]) * a,
- f[1] = d[1] * v + m[1] * _ - (m[0] - d[0]) * a,
- p[0] = d[0] * _ + m[0] * v - (d[1] - m[1]) * a,
- p[1] = d[1] * _ + m[1] * v - (m[0] - d[0]) * a
- }
- if (o || 0 !== a)
- for (var x = r; x < i; x++)
- if (o) {
- var b = e.getLineCoordsCount(x);
- u += s.getPolylineVertexCount(b),
- c += s.getPolylineTriangleCount(b)
- } else
- e.getLineCoords(x, g),
- this._glViewHelper.dataToPoint(l, g[0], d),
- this._glViewHelper.dataToPoint(l, g[1], m),
- y(),
- u += s.getCubicCurveVertexCount(d, f, p, m),
- c += s.getCubicCurveTriangleCount(d, f, p, m);
- else {
- var w = i - r;
- u += w * s.getLineVertexCount(),
- c += w * s.getLineVertexCount()
- }
- s.setVertexCount(u),
- s.setTriangleCount(c);
- var T = r
- , S = [];
- for (x = r; x < i; x++) {
- Ka.parseColor(Ih(n, T), S);
- var M = Mn(Rh(n, T), 1);
- S[3] *= M,
- b = e.getLineCoords(x, g);
- for (var A = 0; A < b; A++)
- this._glViewHelper.dataToPoint(l, g[A], g[A]);
- o ? s.addPolyline(g, S, h, 0, b) : 0 !== a ? (d = g[0],
- m = g[1],
- y(),
- s.addCubicCurve(d, f, p, m, S, h)) : s.addPolyline(g, S, h, 0, 2),
- T++
- }
- },
- dispose: function () {
- this.groupGL.removeAll()
- },
- remove: function () {
- this.groupGL.removeAll()
- }
- });
- (0,
- i.use)((function (e) {
- e.registerChartView(cf),
- e.registerSeriesModel(uf)
- }
- ))
- }
- ,
- 83: t => {
- t.exports = e
- }
- }
- , r = {};
- function i(e) {
- if (r[e])
- return r[e].exports;
- var n = r[e] = {
- exports: {}
- };
- return t[e](n, n.exports, i),
- n.exports
- }
- return i.g = function () {
- if ("object" == typeof globalThis)
- return globalThis;
- try {
- return this || new Function("return this")()
- } catch (e) {
- if ("object" == typeof window)
- return window
- }
- }(),
- i.r = e => {
- "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
- value: "Module"
- }),
- Object.defineProperty(e, "__esModule", {
- value: !0
- })
- }
- ,
- i(468)
- }
- )()
- }
- ));
|