util.js 146 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["Util"] = factory();
  8. else
  9. root["Util"] = factory();
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, {
  50. /******/ configurable: false,
  51. /******/ enumerable: true,
  52. /******/ get: getter
  53. /******/ });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/
  66. /******/ // Object.prototype.hasOwnProperty.call
  67. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  68. /******/
  69. /******/ // __webpack_public_path__
  70. /******/ __webpack_require__.p = "";
  71. /******/
  72. /******/ // Load entry module and return exports
  73. /******/ return __webpack_require__(__webpack_require__.s = 40);
  74. /******/ })
  75. /************************************************************************/
  76. /******/ ([
  77. /* 0 */
  78. /***/ (function(module, exports, __webpack_require__) {
  79. var isObject = __webpack_require__(16);
  80. var isArray = __webpack_require__(1);
  81. var each = function each(elements, func) {
  82. if (!elements) {
  83. return;
  84. }
  85. var rst = void 0;
  86. if (isArray(elements)) {
  87. for (var i = 0, len = elements.length; i < len; i++) {
  88. rst = func(elements[i], i);
  89. if (rst === false) {
  90. break;
  91. }
  92. }
  93. } else if (isObject(elements)) {
  94. for (var k in elements) {
  95. if (elements.hasOwnProperty(k)) {
  96. rst = func(elements[k], k);
  97. if (rst === false) {
  98. break;
  99. }
  100. }
  101. }
  102. }
  103. };
  104. module.exports = each;
  105. /***/ }),
  106. /* 1 */
  107. /***/ (function(module, exports, __webpack_require__) {
  108. var isType = __webpack_require__(4);
  109. var isArray = Array.isArray ? Array.isArray : function (value) {
  110. return isType(value, 'Array');
  111. };
  112. module.exports = isArray;
  113. /***/ }),
  114. /* 2 */
  115. /***/ (function(module, exports, __webpack_require__) {
  116. /**
  117. * 是否为函数
  118. * @param {*} fn 对象
  119. * @return {Boolean} 是否函数
  120. */
  121. var isType = __webpack_require__(4);
  122. var isFunction = function isFunction(value) {
  123. return isType(value, 'Function');
  124. };
  125. module.exports = isFunction;
  126. /***/ }),
  127. /* 3 */
  128. /***/ (function(module, exports) {
  129. var isArrayLike = function isArrayLike(value) {
  130. /**
  131. * isArrayLike([1, 2, 3]) => true
  132. * isArrayLike(document.body.children) => true
  133. * isArrayLike('abc') => true
  134. * isArrayLike(Function) => false
  135. */
  136. return value !== null && typeof value !== 'function' && isFinite(value.length);
  137. };
  138. module.exports = isArrayLike;
  139. /***/ }),
  140. /* 4 */
  141. /***/ (function(module, exports) {
  142. var toString = {}.toString;
  143. var isType = function isType(value, type) {
  144. return toString.call(value) === '[object ' + type + ']';
  145. };
  146. module.exports = isType;
  147. /***/ }),
  148. /* 5 */
  149. /***/ (function(module, exports) {
  150. // isFinite,
  151. var isNil = function isNil(value) {
  152. /**
  153. * isNil(null) => true
  154. * isNil() => true
  155. */
  156. return value === null || value === undefined;
  157. };
  158. module.exports = isNil;
  159. /***/ }),
  160. /* 6 */
  161. /***/ (function(module, exports, __webpack_require__) {
  162. /**
  163. * 判断是否数字
  164. * @return {Boolean} 是否数字
  165. */
  166. var isType = __webpack_require__(4);
  167. var isNumber = function isNumber(value) {
  168. return isType(value, 'Number');
  169. };
  170. module.exports = isNumber;
  171. /***/ }),
  172. /* 7 */
  173. /***/ (function(module, exports, __webpack_require__) {
  174. var isObjectLike = __webpack_require__(13);
  175. var isType = __webpack_require__(4);
  176. var isPlainObject = function isPlainObject(value) {
  177. /**
  178. * isObjectLike(new Foo) => false
  179. * isObjectLike([1, 2, 3]) => false
  180. * isObjectLike({ x: 0, y: 0 }) => true
  181. * isObjectLike(Object.create(null)) => true
  182. */
  183. if (!isObjectLike(value) || !isType(value, 'Object')) {
  184. return false;
  185. }
  186. if (Object.getPrototypeOf(value) === null) {
  187. return true;
  188. }
  189. var proto = value;
  190. while (Object.getPrototypeOf(proto) !== null) {
  191. proto = Object.getPrototypeOf(proto);
  192. }
  193. return Object.getPrototypeOf(value) === proto;
  194. };
  195. module.exports = isPlainObject;
  196. /***/ }),
  197. /* 8 */
  198. /***/ (function(module, exports, __webpack_require__) {
  199. var isNil = __webpack_require__(5);
  200. function toString(value) {
  201. if (isNil(value)) return '';
  202. return value.toString();
  203. }
  204. module.exports = toString;
  205. /***/ }),
  206. /* 9 */
  207. /***/ (function(module, exports, __webpack_require__) {
  208. var isArrayLike = __webpack_require__(3);
  209. var indexOf = Array.prototype.indexOf;
  210. var contains = function contains(arr, value) {
  211. if (!isArrayLike(arr)) {
  212. return false;
  213. }
  214. return indexOf.call(arr, value) > -1;
  215. };
  216. module.exports = contains;
  217. /***/ }),
  218. /* 10 */
  219. /***/ (function(module, exports, __webpack_require__) {
  220. var isType = __webpack_require__(4);
  221. var isString = function isString(str) {
  222. return isType(str, 'String');
  223. };
  224. module.exports = isString;
  225. /***/ }),
  226. /* 11 */
  227. /***/ (function(module, exports) {
  228. function _mix(dist, obj) {
  229. for (var key in obj) {
  230. if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
  231. dist[key] = obj[key];
  232. }
  233. }
  234. }
  235. var mix = function mix(dist, src1, src2, src3) {
  236. if (src1) _mix(dist, src1);
  237. if (src2) _mix(dist, src2);
  238. if (src3) _mix(dist, src3);
  239. return dist;
  240. };
  241. module.exports = mix;
  242. /***/ }),
  243. /* 12 */
  244. /***/ (function(module, exports, __webpack_require__) {
  245. var each = __webpack_require__(0);
  246. var isArrayLike = __webpack_require__(3);
  247. var filter = function filter(arr, func) {
  248. if (!isArrayLike(arr)) {
  249. return arr;
  250. }
  251. var result = [];
  252. each(arr, function (value, index) {
  253. if (func(value, index)) {
  254. result.push(value);
  255. }
  256. });
  257. return result;
  258. };
  259. module.exports = filter;
  260. /***/ }),
  261. /* 13 */
  262. /***/ (function(module, exports) {
  263. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  264. var isObjectLike = function isObjectLike(value) {
  265. /**
  266. * isObjectLike({}) => true
  267. * isObjectLike([1, 2, 3]) => true
  268. * isObjectLike(Function) => false
  269. * isObjectLike(null) => false
  270. */
  271. return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
  272. };
  273. module.exports = isObjectLike;
  274. /***/ }),
  275. /* 14 */
  276. /***/ (function(module, exports, __webpack_require__) {
  277. var isArrayLike = __webpack_require__(3);
  278. function toArray(value) {
  279. return isArrayLike(value) ? Array.prototype.slice.call(value) : [];
  280. }
  281. module.exports = toArray;
  282. /***/ }),
  283. /* 15 */
  284. /***/ (function(module, exports) {
  285. Object.defineProperty(exports, "__esModule", {
  286. value: true
  287. });
  288. exports.setMatrixArrayType = setMatrixArrayType;
  289. exports.toRadian = toRadian;
  290. exports.equals = equals;
  291. /**
  292. * Common utilities
  293. * @module glMatrix
  294. */
  295. // Configuration Constants
  296. var EPSILON = exports.EPSILON = 0.000001;
  297. var ARRAY_TYPE = exports.ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
  298. var RANDOM = exports.RANDOM = Math.random;
  299. /**
  300. * Sets the type of array used when creating new vectors and matrices
  301. *
  302. * @param {Type} type Array type, such as Float32Array or Array
  303. */
  304. function setMatrixArrayType(type) {
  305. exports.ARRAY_TYPE = ARRAY_TYPE = type;
  306. }
  307. var degree = Math.PI / 180;
  308. /**
  309. * Convert Degree To Radian
  310. *
  311. * @param {Number} a Angle in Degrees
  312. */
  313. function toRadian(a) {
  314. return a * degree;
  315. }
  316. /**
  317. * Tests whether or not the arguments have approximately the same value, within an absolute
  318. * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
  319. * than or equal to 1.0, and a relative tolerance is used for larger values)
  320. *
  321. * @param {Number} a The first number to test.
  322. * @param {Number} b The second number to test.
  323. * @returns {Boolean} True if the numbers are approximately equal, false otherwise.
  324. */
  325. function equals(a, b) {
  326. return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
  327. }
  328. /***/ }),
  329. /* 16 */
  330. /***/ (function(module, exports) {
  331. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  332. var isObject = function isObject(value) {
  333. /**
  334. * isObject({}) => true
  335. * isObject([1, 2, 3]) => true
  336. * isObject(Function) => true
  337. * isObject(null) => false
  338. */
  339. var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
  340. return value !== null && type === 'object' || type === 'function';
  341. };
  342. module.exports = isObject;
  343. /***/ }),
  344. /* 17 */
  345. /***/ (function(module, exports, __webpack_require__) {
  346. var keys = __webpack_require__(18);
  347. var isNil = __webpack_require__(5);
  348. function isMatch(obj, attrs) {
  349. var _keys = keys(attrs);
  350. var length = _keys.length;
  351. if (isNil(obj)) return !length;
  352. for (var i = 0; i < length; i += 1) {
  353. var key = _keys[i];
  354. if (attrs[key] !== obj[key] || !(key in obj)) {
  355. return false;
  356. }
  357. }
  358. return true;
  359. }
  360. module.exports = isMatch;
  361. /***/ }),
  362. /* 18 */
  363. /***/ (function(module, exports, __webpack_require__) {
  364. var each = __webpack_require__(0);
  365. var isFunction = __webpack_require__(2);
  366. var keys = Object.keys ? function (obj) {
  367. return Object.keys(obj);
  368. } : function (obj) {
  369. var result = [];
  370. each(obj, function (value, key) {
  371. if (!(isFunction(obj) && key === 'prototype')) {
  372. result.push(key);
  373. }
  374. });
  375. return result;
  376. };
  377. module.exports = keys;
  378. /***/ }),
  379. /* 19 */
  380. /***/ (function(module, exports, __webpack_require__) {
  381. var isArrayLike = __webpack_require__(3);
  382. var splice = Array.prototype.splice;
  383. var pullAt = function pullAt(arr, indexes) {
  384. if (!isArrayLike(arr)) {
  385. return [];
  386. }
  387. var length = arr ? indexes.length : 0;
  388. var last = length - 1;
  389. while (length--) {
  390. var previous = void 0;
  391. var index = indexes[length];
  392. if (length === last || index !== previous) {
  393. previous = index;
  394. splice.call(arr, index, 1);
  395. }
  396. }
  397. return arr;
  398. };
  399. module.exports = pullAt;
  400. /***/ }),
  401. /* 20 */
  402. /***/ (function(module, exports, __webpack_require__) {
  403. var each = __webpack_require__(0);
  404. var contains = __webpack_require__(9);
  405. var uniq = function uniq(arr) {
  406. var resultArr = [];
  407. each(arr, function (item) {
  408. if (!contains(resultArr, item)) {
  409. resultArr.push(item);
  410. }
  411. });
  412. return resultArr;
  413. };
  414. module.exports = uniq;
  415. /***/ }),
  416. /* 21 */
  417. /***/ (function(module, exports) {
  418. var clamp = function clamp(a, min, max) {
  419. if (a < min) {
  420. return min;
  421. } else if (a > max) {
  422. return max;
  423. }
  424. return a;
  425. };
  426. module.exports = clamp;
  427. /***/ }),
  428. /* 22 */
  429. /***/ (function(module, exports) {
  430. module.exports = parseInt;
  431. /***/ }),
  432. /* 23 */
  433. /***/ (function(module, exports, __webpack_require__) {
  434. var mat3 = __webpack_require__(89);
  435. mat3.translate = function (out, a, v) {
  436. var transMat = new Array(9);
  437. mat3.fromTranslation(transMat, v);
  438. return mat3.multiply(out, transMat, a);
  439. };
  440. mat3.rotate = function (out, a, rad) {
  441. var rotateMat = new Array(9);
  442. mat3.fromRotation(rotateMat, rad);
  443. return mat3.multiply(out, rotateMat, a);
  444. };
  445. mat3.scale = function (out, a, v) {
  446. var scaleMat = new Array(9);
  447. mat3.fromScaling(scaleMat, v);
  448. return mat3.multiply(out, scaleMat, a);
  449. };
  450. module.exports = mat3;
  451. /***/ }),
  452. /* 24 */
  453. /***/ (function(module, exports, __webpack_require__) {
  454. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  455. var isArray = __webpack_require__(1);
  456. var clone = function clone(obj) {
  457. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
  458. return obj;
  459. }
  460. var rst = void 0;
  461. if (isArray(obj)) {
  462. rst = [];
  463. for (var i = 0, l = obj.length; i < l; i++) {
  464. if (_typeof(obj[i]) === 'object' && obj[i] != null) {
  465. rst[i] = clone(obj[i]);
  466. } else {
  467. rst[i] = obj[i];
  468. }
  469. }
  470. } else {
  471. rst = {};
  472. for (var k in obj) {
  473. if (_typeof(obj[k]) === 'object' && obj[k] != null) {
  474. rst[k] = clone(obj[k]);
  475. } else {
  476. rst[k] = obj[k];
  477. }
  478. }
  479. }
  480. return rst;
  481. };
  482. module.exports = clone;
  483. /***/ }),
  484. /* 25 */
  485. /***/ (function(module, exports) {
  486. module.exports = function (obj, key) {
  487. return obj.hasOwnProperty(key);
  488. };
  489. /***/ }),
  490. /* 26 */
  491. /***/ (function(module, exports, __webpack_require__) {
  492. var each = __webpack_require__(0);
  493. var isFunction = __webpack_require__(2);
  494. var values = Object.values ? function (obj) {
  495. return Object.values(obj);
  496. } : function (obj) {
  497. var result = [];
  498. each(obj, function (value, key) {
  499. if (!(isFunction(obj) && key === 'prototype')) {
  500. result.push(value);
  501. }
  502. });
  503. return result;
  504. };
  505. module.exports = values;
  506. /***/ }),
  507. /* 27 */
  508. /***/ (function(module, exports, __webpack_require__) {
  509. var parsePathArray = __webpack_require__(28);
  510. module.exports = function rectPath(x, y, w, h, r) {
  511. if (r) {
  512. return [['M', +x + +r, y], ['l', w - r * 2, 0], ['a', r, r, 0, 0, 1, r, r], ['l', 0, h - r * 2], ['a', r, r, 0, 0, 1, -r, r], ['l', r * 2 - w, 0], ['a', r, r, 0, 0, 1, -r, -r], ['l', 0, r * 2 - h], ['a', r, r, 0, 0, 1, r, -r], ['z']];
  513. }
  514. var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];
  515. res.parsePathArray = parsePathArray;
  516. return res;
  517. };
  518. /***/ }),
  519. /* 28 */
  520. /***/ (function(module, exports) {
  521. var p2s = /,?([a-z]),?/gi;
  522. module.exports = function parsePathArray(path) {
  523. return path.join(',').replace(p2s, '$1');
  524. };
  525. /***/ }),
  526. /* 29 */
  527. /***/ (function(module, exports, __webpack_require__) {
  528. var pathToAbsolute = __webpack_require__(30);
  529. var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
  530. // for more information of where this math came from visit:
  531. // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
  532. if (rx === ry) {
  533. rx += 1;
  534. }
  535. var _120 = Math.PI * 120 / 180;
  536. var rad = Math.PI / 180 * (+angle || 0);
  537. var res = [];
  538. var xy = void 0;
  539. var f1 = void 0;
  540. var f2 = void 0;
  541. var cx = void 0;
  542. var cy = void 0;
  543. var rotate = function rotate(x, y, rad) {
  544. var X = x * Math.cos(rad) - y * Math.sin(rad);
  545. var Y = x * Math.sin(rad) + y * Math.cos(rad);
  546. return {
  547. x: X,
  548. y: Y
  549. };
  550. };
  551. if (!recursive) {
  552. xy = rotate(x1, y1, -rad);
  553. x1 = xy.x;
  554. y1 = xy.y;
  555. xy = rotate(x2, y2, -rad);
  556. x2 = xy.x;
  557. y2 = xy.y;
  558. if (x1 === x2 && y1 === y2) {
  559. // 若弧的起始点和终点重叠则错开一点
  560. x2 += 1;
  561. y2 += 1;
  562. }
  563. // const cos = Math.cos(Math.PI / 180 * angle);
  564. // const sin = Math.sin(Math.PI / 180 * angle);
  565. var x = (x1 - x2) / 2;
  566. var y = (y1 - y2) / 2;
  567. var h = x * x / (rx * rx) + y * y / (ry * ry);
  568. if (h > 1) {
  569. h = Math.sqrt(h);
  570. rx = h * rx;
  571. ry = h * ry;
  572. }
  573. var rx2 = rx * rx;
  574. var ry2 = ry * ry;
  575. var k = (large_arc_flag === sweep_flag ? -1 : 1) * Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
  576. cx = k * rx * y / ry + (x1 + x2) / 2;
  577. cy = k * -ry * x / rx + (y1 + y2) / 2;
  578. f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
  579. f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
  580. f1 = x1 < cx ? Math.PI - f1 : f1;
  581. f2 = x2 < cx ? Math.PI - f2 : f2;
  582. f1 < 0 && (f1 = Math.PI * 2 + f1);
  583. f2 < 0 && (f2 = Math.PI * 2 + f2);
  584. if (sweep_flag && f1 > f2) {
  585. f1 = f1 - Math.PI * 2;
  586. }
  587. if (!sweep_flag && f2 > f1) {
  588. f2 = f2 - Math.PI * 2;
  589. }
  590. } else {
  591. f1 = recursive[0];
  592. f2 = recursive[1];
  593. cx = recursive[2];
  594. cy = recursive[3];
  595. }
  596. var df = f2 - f1;
  597. if (Math.abs(df) > _120) {
  598. var f2old = f2;
  599. var x2old = x2;
  600. var y2old = y2;
  601. f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
  602. x2 = cx + rx * Math.cos(f2);
  603. y2 = cy + ry * Math.sin(f2);
  604. res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
  605. }
  606. df = f2 - f1;
  607. var c1 = Math.cos(f1);
  608. var s1 = Math.sin(f1);
  609. var c2 = Math.cos(f2);
  610. var s2 = Math.sin(f2);
  611. var t = Math.tan(df / 4);
  612. var hx = 4 / 3 * rx * t;
  613. var hy = 4 / 3 * ry * t;
  614. var m1 = [x1, y1];
  615. var m2 = [x1 + hx * s1, y1 - hy * c1];
  616. var m3 = [x2 + hx * s2, y2 - hy * c2];
  617. var m4 = [x2, y2];
  618. m2[0] = 2 * m1[0] - m2[0];
  619. m2[1] = 2 * m1[1] - m2[1];
  620. if (recursive) {
  621. return [m2, m3, m4].concat(res);
  622. }
  623. res = [m2, m3, m4].concat(res).join().split(',');
  624. var newres = [];
  625. for (var i = 0, ii = res.length; i < ii; i++) {
  626. newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
  627. }
  628. return newres;
  629. };
  630. var l2c = function l2c(x1, y1, x2, y2) {
  631. return [x1, y1, x2, y2, x2, y2];
  632. };
  633. var q2c = function q2c(x1, y1, ax, ay, x2, y2) {
  634. var _13 = 1 / 3;
  635. var _23 = 2 / 3;
  636. return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];
  637. };
  638. module.exports = function pathTocurve(path, path2) {
  639. var p = pathToAbsolute(path);
  640. var p2 = path2 && pathToAbsolute(path2);
  641. var attrs = {
  642. x: 0,
  643. y: 0,
  644. bx: 0,
  645. by: 0,
  646. X: 0,
  647. Y: 0,
  648. qx: null,
  649. qy: null
  650. };
  651. var attrs2 = {
  652. x: 0,
  653. y: 0,
  654. bx: 0,
  655. by: 0,
  656. X: 0,
  657. Y: 0,
  658. qx: null,
  659. qy: null
  660. };
  661. var pcoms1 = []; // path commands of original path p
  662. var pcoms2 = []; // path commands of original path p2
  663. var pfirst = ''; // temporary holder for original path command
  664. var pcom = ''; // holder for previous path command of original path
  665. var ii = void 0;
  666. var processPath = function processPath(path, d, pcom) {
  667. var nx = void 0,
  668. ny = void 0;
  669. if (!path) {
  670. return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
  671. }!(path[0] in {
  672. T: 1,
  673. Q: 1
  674. }) && (d.qx = d.qy = null);
  675. switch (path[0]) {
  676. case 'M':
  677. d.X = path[1];
  678. d.Y = path[2];
  679. break;
  680. case 'A':
  681. path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
  682. break;
  683. case 'S':
  684. if (pcom === 'C' || pcom === 'S') {
  685. // In "S" case we have to take into account, if the previous command is C/S.
  686. nx = d.x * 2 - d.bx; // And reflect the previous
  687. ny = d.y * 2 - d.by; // command's control point relative to the current point.
  688. } else {
  689. // or some else or nothing
  690. nx = d.x;
  691. ny = d.y;
  692. }
  693. path = ['C', nx, ny].concat(path.slice(1));
  694. break;
  695. case 'T':
  696. if (pcom === 'Q' || pcom === 'T') {
  697. // In "T" case we have to take into account, if the previous command is Q/T.
  698. d.qx = d.x * 2 - d.qx; // And make a reflection similar
  699. d.qy = d.y * 2 - d.qy; // to case "S".
  700. } else {
  701. // or something else or nothing
  702. d.qx = d.x;
  703. d.qy = d.y;
  704. }
  705. path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
  706. break;
  707. case 'Q':
  708. d.qx = path[1];
  709. d.qy = path[2];
  710. path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
  711. break;
  712. case 'L':
  713. path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
  714. break;
  715. case 'H':
  716. path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
  717. break;
  718. case 'V':
  719. path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
  720. break;
  721. case 'Z':
  722. path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
  723. break;
  724. default:
  725. break;
  726. }
  727. return path;
  728. };
  729. var fixArc = function fixArc(pp, i) {
  730. if (pp[i].length > 7) {
  731. pp[i].shift();
  732. var pi = pp[i];
  733. while (pi.length) {
  734. pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
  735. p2 && (pcoms2[i] = 'A'); // the same as above
  736. pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
  737. }
  738. pp.splice(i, 1);
  739. ii = Math.max(p.length, p2 && p2.length || 0);
  740. }
  741. };
  742. var fixM = function fixM(path1, path2, a1, a2, i) {
  743. if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {
  744. path2.splice(i, 0, ['M', a2.x, a2.y]);
  745. a1.bx = 0;
  746. a1.by = 0;
  747. a1.x = path1[i][1];
  748. a1.y = path1[i][2];
  749. ii = Math.max(p.length, p2 && p2.length || 0);
  750. }
  751. };
  752. ii = Math.max(p.length, p2 && p2.length || 0);
  753. for (var i = 0; i < ii; i++) {
  754. p[i] && (pfirst = p[i][0]); // save current path command
  755. if (pfirst !== 'C') {
  756. // C is not saved yet, because it may be result of conversion
  757. pcoms1[i] = pfirst; // Save current path command
  758. i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
  759. }
  760. p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
  761. if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command
  762. // which may produce multiple C:s
  763. // so we have to make sure that C is also C in original path
  764. fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
  765. if (p2) {
  766. // the same procedures is done to p2
  767. p2[i] && (pfirst = p2[i][0]);
  768. if (pfirst !== 'C') {
  769. pcoms2[i] = pfirst;
  770. i && (pcom = pcoms2[i - 1]);
  771. }
  772. p2[i] = processPath(p2[i], attrs2, pcom);
  773. if (pcoms2[i] !== 'A' && pfirst === 'C') {
  774. pcoms2[i] = 'C';
  775. }
  776. fixArc(p2, i);
  777. }
  778. fixM(p, p2, attrs, attrs2, i);
  779. fixM(p2, p, attrs2, attrs, i);
  780. var seg = p[i];
  781. var seg2 = p2 && p2[i];
  782. var seglen = seg.length;
  783. var seg2len = p2 && seg2.length;
  784. attrs.x = seg[seglen - 2];
  785. attrs.y = seg[seglen - 1];
  786. attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
  787. attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
  788. attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x);
  789. attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y);
  790. attrs2.x = p2 && seg2[seg2len - 2];
  791. attrs2.y = p2 && seg2[seg2len - 1];
  792. }
  793. return p2 ? [p, p2] : p;
  794. };
  795. /***/ }),
  796. /* 30 */
  797. /***/ (function(module, exports, __webpack_require__) {
  798. var parsePathString = __webpack_require__(31);
  799. var catmullRom2bezier = __webpack_require__(32);
  800. function ellipsePath(x, y, rx, ry, a) {
  801. var res = [];
  802. if (a === null && ry === null) {
  803. ry = rx;
  804. }
  805. x = +x;
  806. y = +y;
  807. rx = +rx;
  808. ry = +ry;
  809. if (a !== null) {
  810. var rad = Math.PI / 180;
  811. var x1 = x + rx * Math.cos(-ry * rad);
  812. var x2 = x + rx * Math.cos(-a * rad);
  813. var y1 = y + rx * Math.sin(-ry * rad);
  814. var y2 = y + rx * Math.sin(-a * rad);
  815. res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
  816. } else {
  817. res = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']];
  818. }
  819. return res;
  820. }
  821. module.exports = function pathToAbsolute(pathArray) {
  822. pathArray = parsePathString(pathArray);
  823. if (!pathArray || !pathArray.length) {
  824. return [['M', 0, 0]];
  825. }
  826. var res = [];
  827. var x = 0;
  828. var y = 0;
  829. var mx = 0;
  830. var my = 0;
  831. var start = 0;
  832. var pa0 = void 0;
  833. var dots = void 0;
  834. if (pathArray[0][0] === 'M') {
  835. x = +pathArray[0][1];
  836. y = +pathArray[0][2];
  837. mx = x;
  838. my = y;
  839. start++;
  840. res[0] = ['M', x, y];
  841. }
  842. var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
  843. for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
  844. res.push(r = []);
  845. pa = pathArray[i];
  846. pa0 = pa[0];
  847. if (pa0 !== pa0.toUpperCase()) {
  848. r[0] = pa0.toUpperCase();
  849. switch (r[0]) {
  850. case 'A':
  851. r[1] = pa[1];
  852. r[2] = pa[2];
  853. r[3] = pa[3];
  854. r[4] = pa[4];
  855. r[5] = pa[5];
  856. r[6] = +pa[6] + x;
  857. r[7] = +pa[7] + y;
  858. break;
  859. case 'V':
  860. r[1] = +pa[1] + y;
  861. break;
  862. case 'H':
  863. r[1] = +pa[1] + x;
  864. break;
  865. case 'R':
  866. dots = [x, y].concat(pa.slice(1));
  867. for (var j = 2, jj = dots.length; j < jj; j++) {
  868. dots[j] = +dots[j] + x;
  869. dots[++j] = +dots[j] + y;
  870. }
  871. res.pop();
  872. res = res.concat(catmullRom2bezier(dots, crz));
  873. break;
  874. case 'O':
  875. res.pop();
  876. dots = ellipsePath(x, y, pa[1], pa[2]);
  877. dots.push(dots[0]);
  878. res = res.concat(dots);
  879. break;
  880. case 'U':
  881. res.pop();
  882. res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
  883. r = ['U'].concat(res[res.length - 1].slice(-2));
  884. break;
  885. case 'M':
  886. mx = +pa[1] + x;
  887. my = +pa[2] + y;
  888. break; // for lint
  889. default:
  890. for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {
  891. r[_j] = +pa[_j] + (_j % 2 ? x : y);
  892. }
  893. }
  894. } else if (pa0 === 'R') {
  895. dots = [x, y].concat(pa.slice(1));
  896. res.pop();
  897. res = res.concat(catmullRom2bezier(dots, crz));
  898. r = ['R'].concat(pa.slice(-2));
  899. } else if (pa0 === 'O') {
  900. res.pop();
  901. dots = ellipsePath(x, y, pa[1], pa[2]);
  902. dots.push(dots[0]);
  903. res = res.concat(dots);
  904. } else if (pa0 === 'U') {
  905. res.pop();
  906. res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
  907. r = ['U'].concat(res[res.length - 1].slice(-2));
  908. } else {
  909. for (var k = 0, kk = pa.length; k < kk; k++) {
  910. r[k] = pa[k];
  911. }
  912. }
  913. pa0 = pa0.toUpperCase();
  914. if (pa0 !== 'O') {
  915. switch (r[0]) {
  916. case 'Z':
  917. x = +mx;
  918. y = +my;
  919. break;
  920. case 'H':
  921. x = r[1];
  922. break;
  923. case 'V':
  924. y = r[1];
  925. break;
  926. case 'M':
  927. mx = r[r.length - 2];
  928. my = r[r.length - 1];
  929. break; // for lint
  930. default:
  931. x = r[r.length - 2];
  932. y = r[r.length - 1];
  933. }
  934. }
  935. }
  936. return res;
  937. };
  938. /***/ }),
  939. /* 31 */
  940. /***/ (function(module, exports) {
  941. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  942. var SPACES = '\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029';
  943. var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
  944. var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
  945. // Parses given path string into an array of arrays of path segments
  946. module.exports = function parsePathString(pathString) {
  947. if (!pathString) {
  948. return null;
  949. }
  950. if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) {
  951. return pathString;
  952. }
  953. var paramCounts = {
  954. a: 7,
  955. c: 6,
  956. o: 2,
  957. h: 1,
  958. l: 2,
  959. m: 2,
  960. r: 4,
  961. q: 4,
  962. s: 4,
  963. t: 2,
  964. v: 1,
  965. u: 3,
  966. z: 0
  967. };
  968. var data = [];
  969. String(pathString).replace(PATH_COMMAND, function (a, b, c) {
  970. var params = [];
  971. var name = b.toLowerCase();
  972. c.replace(PATH_VALUES, function (a, b) {
  973. b && params.push(+b);
  974. });
  975. if (name === 'm' && params.length > 2) {
  976. data.push([b].concat(params.splice(0, 2)));
  977. name = 'l';
  978. b = b === 'm' ? 'l' : 'L';
  979. }
  980. if (name === 'o' && params.length === 1) {
  981. data.push([b, params[0]]);
  982. }
  983. if (name === 'r') {
  984. data.push([b].concat(params));
  985. } else {
  986. while (params.length >= paramCounts[name]) {
  987. data.push([b].concat(params.splice(0, paramCounts[name])));
  988. if (!paramCounts[name]) {
  989. break;
  990. }
  991. }
  992. }
  993. });
  994. return data;
  995. };
  996. /***/ }),
  997. /* 32 */
  998. /***/ (function(module, exports) {
  999. // http://schepers.cc/getting-to-the-point
  1000. module.exports = function catmullRom2bezier(crp, z) {
  1001. var d = [];
  1002. for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
  1003. var p = [{
  1004. x: +crp[i - 2],
  1005. y: +crp[i - 1]
  1006. }, {
  1007. x: +crp[i],
  1008. y: +crp[i + 1]
  1009. }, {
  1010. x: +crp[i + 2],
  1011. y: +crp[i + 3]
  1012. }, {
  1013. x: +crp[i + 4],
  1014. y: +crp[i + 5]
  1015. }];
  1016. if (z) {
  1017. if (!i) {
  1018. p[0] = {
  1019. x: +crp[iLen - 2],
  1020. y: +crp[iLen - 1]
  1021. };
  1022. } else if (iLen - 4 === i) {
  1023. p[3] = {
  1024. x: +crp[0],
  1025. y: +crp[1]
  1026. };
  1027. } else if (iLen - 2 === i) {
  1028. p[2] = {
  1029. x: +crp[0],
  1030. y: +crp[1]
  1031. };
  1032. p[3] = {
  1033. x: +crp[2],
  1034. y: +crp[3]
  1035. };
  1036. }
  1037. } else {
  1038. if (iLen - 4 === i) {
  1039. p[3] = p[2];
  1040. } else if (!i) {
  1041. p[0] = {
  1042. x: +crp[i],
  1043. y: +crp[i + 1]
  1044. };
  1045. }
  1046. }
  1047. d.push(['C', (-p[0].x + 6 * p[1].x + p[2].x) / 6, (-p[0].y + 6 * p[1].y + p[2].y) / 6, (p[1].x + 6 * p[2].x - p[3].x) / 6, (p[1].y + 6 * p[2].y - p[3].y) / 6, p[2].x, p[2].y]);
  1048. }
  1049. return d;
  1050. };
  1051. /***/ }),
  1052. /* 33 */
  1053. /***/ (function(module, exports, __webpack_require__) {
  1054. var toString = __webpack_require__(8);
  1055. var lowerCase = function lowerCase(str) {
  1056. return toString(str).toLowerCase();
  1057. };
  1058. module.exports = lowerCase;
  1059. /***/ }),
  1060. /* 34 */
  1061. /***/ (function(module, exports, __webpack_require__) {
  1062. var toString = __webpack_require__(8);
  1063. var upperCase = function upperCase(str) {
  1064. return toString(str).toUpperCase();
  1065. };
  1066. module.exports = upperCase;
  1067. /***/ }),
  1068. /* 35 */
  1069. /***/ (function(module, exports) {
  1070. var toString = {}.toString;
  1071. var getType = function getType(value) {
  1072. return toString.call(value).replace(/^\[object /, '').replace(/\]$/, '');
  1073. };
  1074. module.exports = getType;
  1075. /***/ }),
  1076. /* 36 */
  1077. /***/ (function(module, exports) {
  1078. var objectProto = Object.prototype;
  1079. var isPrototype = function isPrototype(value) {
  1080. var Ctor = value && value.constructor;
  1081. var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
  1082. return value === proto;
  1083. };
  1084. module.exports = isPrototype;
  1085. /***/ }),
  1086. /* 37 */
  1087. /***/ (function(module, exports, __webpack_require__) {
  1088. var isFunction = __webpack_require__(2);
  1089. var isArray = __webpack_require__(1);
  1090. var groupBy = __webpack_require__(38);
  1091. var groupToMap = function groupToMap(data, condition) {
  1092. if (!condition) {
  1093. return {
  1094. 0: data
  1095. };
  1096. }
  1097. if (!isFunction(condition)) {
  1098. var paramsCondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*');
  1099. condition = function condition(row) {
  1100. var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
  1101. for (var i = 0, l = paramsCondition.length; i < l; i++) {
  1102. unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString();
  1103. }
  1104. return unique;
  1105. };
  1106. }
  1107. var groups = groupBy(data, condition);
  1108. return groups;
  1109. };
  1110. module.exports = groupToMap;
  1111. /***/ }),
  1112. /* 38 */
  1113. /***/ (function(module, exports, __webpack_require__) {
  1114. var each = __webpack_require__(0);
  1115. var isArray = __webpack_require__(1);
  1116. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1117. var groupBy = function groupBy(data, condition) {
  1118. if (!condition || !isArray(data)) {
  1119. return data;
  1120. }
  1121. var result = {};
  1122. var key = null;
  1123. each(data, function (item) {
  1124. key = condition(item);
  1125. if (hasOwnProperty.call(result, key)) {
  1126. result[key].push(item);
  1127. } else {
  1128. result[key] = [item];
  1129. }
  1130. });
  1131. return result;
  1132. };
  1133. module.exports = groupBy;
  1134. /***/ }),
  1135. /* 39 */
  1136. /***/ (function(module, exports, __webpack_require__) {
  1137. var isObjectLike = __webpack_require__(13);
  1138. var isArrayLike = __webpack_require__(3);
  1139. var isString = __webpack_require__(10);
  1140. var isEqual = function isEqual(value, other) {
  1141. if (value === other) {
  1142. return true;
  1143. }
  1144. if (!value || !other) {
  1145. return false;
  1146. }
  1147. if (isString(value) || isString(other)) {
  1148. return false;
  1149. }
  1150. if (isArrayLike(value) || isArrayLike(other)) {
  1151. if (value.length !== other.length) {
  1152. return false;
  1153. }
  1154. var rst = true;
  1155. for (var i = 0; i < value.length; i++) {
  1156. rst = isEqual(value[i], other[i]);
  1157. if (!rst) {
  1158. break;
  1159. }
  1160. }
  1161. return rst;
  1162. }
  1163. if (isObjectLike(value) || isObjectLike(other)) {
  1164. var valueKeys = Object.keys(value);
  1165. var otherKeys = Object.keys(other);
  1166. if (valueKeys.length !== otherKeys.length) {
  1167. return false;
  1168. }
  1169. var _rst = true;
  1170. for (var _i = 0; _i < valueKeys.length; _i++) {
  1171. _rst = isEqual(value[valueKeys[_i]], other[valueKeys[_i]]);
  1172. if (!_rst) {
  1173. break;
  1174. }
  1175. }
  1176. return _rst;
  1177. }
  1178. return false;
  1179. };
  1180. module.exports = isEqual;
  1181. /***/ }),
  1182. /* 40 */
  1183. /***/ (function(module, exports, __webpack_require__) {
  1184. var each = __webpack_require__(0);
  1185. var mix = __webpack_require__(11);
  1186. // collections
  1187. var DOMUtil = __webpack_require__(41);
  1188. var arrayUtil = __webpack_require__(53);
  1189. var eventUtil = __webpack_require__(67);
  1190. var formatUtil = __webpack_require__(70);
  1191. var mathUtil = __webpack_require__(74);
  1192. var matrixUtil = __webpack_require__(88);
  1193. var objectUtil = __webpack_require__(95);
  1194. var pathUtil = __webpack_require__(99);
  1195. var stringUtil = __webpack_require__(105);
  1196. var typeUtil = __webpack_require__(111);
  1197. var util = {
  1198. // collections
  1199. DOMUtil: DOMUtil,
  1200. DomUtil: DOMUtil,
  1201. MatrixUtil: matrixUtil,
  1202. PathUtil: pathUtil,
  1203. arrayUtil: arrayUtil,
  1204. domUtil: DOMUtil,
  1205. eventUtil: eventUtil,
  1206. formatUtil: formatUtil,
  1207. mathUtil: mathUtil,
  1208. matrixUtil: matrixUtil,
  1209. objectUtil: objectUtil,
  1210. stringUtil: stringUtil,
  1211. pathUtil: pathUtil,
  1212. typeUtil: typeUtil,
  1213. // others
  1214. augment: __webpack_require__(116),
  1215. clone: __webpack_require__(24),
  1216. deepMix: __webpack_require__(117),
  1217. each: each,
  1218. extend: __webpack_require__(118),
  1219. filter: __webpack_require__(12),
  1220. group: __webpack_require__(119),
  1221. groupBy: __webpack_require__(38),
  1222. groupToMap: __webpack_require__(37),
  1223. indexOf: __webpack_require__(120),
  1224. isEmpty: __webpack_require__(121),
  1225. isEqual: __webpack_require__(39),
  1226. isEqualWith: __webpack_require__(122),
  1227. map: __webpack_require__(123),
  1228. mix: mix,
  1229. pick: __webpack_require__(124),
  1230. toArray: __webpack_require__(14),
  1231. toString: __webpack_require__(8),
  1232. uniqueId: __webpack_require__(125)
  1233. };
  1234. each([DOMUtil, arrayUtil, eventUtil, formatUtil, mathUtil, matrixUtil, objectUtil, pathUtil, stringUtil, typeUtil], function (collection) {
  1235. mix(util, collection);
  1236. });
  1237. module.exports = util;
  1238. /***/ }),
  1239. /* 41 */
  1240. /***/ (function(module, exports, __webpack_require__) {
  1241. module.exports = {
  1242. addEventListener: __webpack_require__(42),
  1243. createDom: __webpack_require__(43),
  1244. getBoundingClientRect: __webpack_require__(44),
  1245. getHeight: __webpack_require__(45),
  1246. getOuterHeight: __webpack_require__(46),
  1247. getOuterWidth: __webpack_require__(47),
  1248. getRatio: __webpack_require__(48),
  1249. getStyle: __webpack_require__(49),
  1250. getWidth: __webpack_require__(50),
  1251. modifyCSS: __webpack_require__(51),
  1252. requestAnimationFrame: __webpack_require__(52)
  1253. };
  1254. /***/ }),
  1255. /* 42 */
  1256. /***/ (function(module, exports) {
  1257. /**
  1258. * 添加事件监听器
  1259. * @param {Object} target DOM对象
  1260. * @param {String} eventType 事件名
  1261. * @param {Funtion} callback 回调函数
  1262. * @return {Object} 返回对象
  1263. */
  1264. module.exports = function addEventListener(target, eventType, callback) {
  1265. if (target) {
  1266. if (target.addEventListener) {
  1267. target.addEventListener(eventType, callback, false);
  1268. return {
  1269. remove: function remove() {
  1270. target.removeEventListener(eventType, callback, false);
  1271. }
  1272. };
  1273. } else if (target.attachEvent) {
  1274. target.attachEvent('on' + eventType, callback);
  1275. return {
  1276. remove: function remove() {
  1277. target.detachEvent('on' + eventType, callback);
  1278. }
  1279. };
  1280. }
  1281. }
  1282. };
  1283. /***/ }),
  1284. /* 43 */
  1285. /***/ (function(module, exports) {
  1286. /**
  1287. * 创建DOM 节点
  1288. * @param {String} str Dom 字符串
  1289. * @return {HTMLElement} DOM 节点
  1290. */
  1291. var TABLE = document.createElement('table');
  1292. var TABLE_TR = document.createElement('tr');
  1293. var FRAGMENT_REG = /^\s*<(\w+|!)[^>]*>/;
  1294. var CONTAINERS = {
  1295. tr: document.createElement('tbody'),
  1296. tbody: TABLE,
  1297. thead: TABLE,
  1298. tfoot: TABLE,
  1299. td: TABLE_TR,
  1300. th: TABLE_TR,
  1301. '*': document.createElement('div')
  1302. };
  1303. module.exports = function createDom(str) {
  1304. var name = FRAGMENT_REG.test(str) && RegExp.$1;
  1305. if (!(name in CONTAINERS)) {
  1306. name = '*';
  1307. }
  1308. var container = CONTAINERS[name];
  1309. str = str.replace(/(^\s*)|(\s*$)/g, '');
  1310. container.innerHTML = '' + str;
  1311. var dom = container.childNodes[0];
  1312. container.removeChild(dom);
  1313. return dom;
  1314. };
  1315. /***/ }),
  1316. /* 44 */
  1317. /***/ (function(module, exports) {
  1318. module.exports = function getBoundingClientRect(node, defaultValue) {
  1319. if (node && node.getBoundingClientRect) {
  1320. var rect = node.getBoundingClientRect();
  1321. var top = document.documentElement.clientTop;
  1322. var left = document.documentElement.clientLeft;
  1323. return {
  1324. top: rect.top - top,
  1325. bottom: rect.bottom - top,
  1326. left: rect.left - left,
  1327. right: rect.right - left
  1328. };
  1329. }
  1330. return defaultValue || null;
  1331. };
  1332. /***/ }),
  1333. /* 45 */
  1334. /***/ (function(module, exports) {
  1335. /**
  1336. * 获取高度
  1337. * @param {HTMLElement} el dom节点
  1338. * @param {Number} defaultValue 默认值
  1339. * @return {Number} 高度
  1340. */
  1341. module.exports = function getHeight(el, defaultValue) {
  1342. var height = this.getStyle(el, 'height', defaultValue);
  1343. if (height === 'auto') {
  1344. height = el.offsetHeight;
  1345. }
  1346. return parseFloat(height);
  1347. };
  1348. /***/ }),
  1349. /* 46 */
  1350. /***/ (function(module, exports) {
  1351. /**
  1352. * 获取外层高度
  1353. * @param {HTMLElement} el dom节点
  1354. * @param {Number} defaultValue 默认值
  1355. * @return {Number} 高度
  1356. */
  1357. module.exports = function getOuterHeight(el, defaultValue) {
  1358. var height = this.getHeight(el, defaultValue);
  1359. var bTop = parseFloat(this.getStyle(el, 'borderTopWidth')) || 0;
  1360. var pTop = parseFloat(this.getStyle(el, 'paddingTop')) || 0;
  1361. var pBottom = parseFloat(this.getStyle(el, 'paddingBottom')) || 0;
  1362. var bBottom = parseFloat(this.getStyle(el, 'borderBottomWidth')) || 0;
  1363. return height + bTop + bBottom + pTop + pBottom;
  1364. };
  1365. /***/ }),
  1366. /* 47 */
  1367. /***/ (function(module, exports) {
  1368. /**
  1369. * 获取外层宽度
  1370. * @param {HTMLElement} el dom节点
  1371. * @param {Number} defaultValue 默认值
  1372. * @return {Number} 宽度
  1373. */
  1374. module.exports = function getOuterWidth(el, defaultValue) {
  1375. var width = this.getWidth(el, defaultValue);
  1376. var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0;
  1377. var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')) || 0;
  1378. var pRight = parseFloat(this.getStyle(el, 'paddingRight')) || 0;
  1379. var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0;
  1380. return width + bLeft + bRight + pLeft + pRight;
  1381. };
  1382. /***/ }),
  1383. /* 48 */
  1384. /***/ (function(module, exports) {
  1385. module.exports = function getRatio() {
  1386. return window.devicePixelRatio ? window.devicePixelRatio : 2;
  1387. };
  1388. /***/ }),
  1389. /* 49 */
  1390. /***/ (function(module, exports, __webpack_require__) {
  1391. var isNil = __webpack_require__(5);
  1392. /**
  1393. * 获取样式
  1394. * @param {Object} dom DOM节点
  1395. * @param {String} name 样式名
  1396. * @param {Any} defaultValue 默认值
  1397. * @return {String} 属性值
  1398. */
  1399. module.exports = function getStyle(dom, name, defaultValue) {
  1400. try {
  1401. if (window.getComputedStyle) {
  1402. return window.getComputedStyle(dom, null)[name];
  1403. }
  1404. return dom.currentStyle[name];
  1405. } catch (e) {
  1406. if (!isNil(defaultValue)) {
  1407. return defaultValue;
  1408. }
  1409. return null;
  1410. }
  1411. };
  1412. /***/ }),
  1413. /* 50 */
  1414. /***/ (function(module, exports) {
  1415. /**
  1416. * 获取宽度
  1417. * @param {HTMLElement} el dom节点
  1418. * @param {Number} defaultValue 默认值
  1419. * @return {Number} 宽度
  1420. */
  1421. module.exports = function getWidth(el, defaultValue) {
  1422. var width = this.getStyle(el, 'width', defaultValue);
  1423. if (width === 'auto') {
  1424. width = el.offsetWidth;
  1425. }
  1426. return parseFloat(width);
  1427. };
  1428. /***/ }),
  1429. /* 51 */
  1430. /***/ (function(module, exports) {
  1431. module.exports = function modifyCSS(dom, css) {
  1432. if (dom) {
  1433. for (var key in css) {
  1434. if (css.hasOwnProperty(key)) {
  1435. dom.style[key] = css[key];
  1436. }
  1437. }
  1438. }
  1439. return dom;
  1440. };
  1441. /***/ }),
  1442. /* 52 */
  1443. /***/ (function(module, exports) {
  1444. module.exports = function requestAnimationFrame(fn) {
  1445. var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
  1446. return setTimeout(fn, 16);
  1447. };
  1448. return method(fn);
  1449. };
  1450. /***/ }),
  1451. /* 53 */
  1452. /***/ (function(module, exports, __webpack_require__) {
  1453. module.exports = {
  1454. contains: __webpack_require__(9),
  1455. difference: __webpack_require__(54),
  1456. find: __webpack_require__(55),
  1457. firstValue: __webpack_require__(56),
  1458. flatten: __webpack_require__(57),
  1459. flattenDeep: __webpack_require__(58),
  1460. getRange: __webpack_require__(59),
  1461. merge: __webpack_require__(60),
  1462. pull: __webpack_require__(61),
  1463. pullAt: __webpack_require__(19),
  1464. reduce: __webpack_require__(62),
  1465. remove: __webpack_require__(63),
  1466. sortBy: __webpack_require__(64),
  1467. union: __webpack_require__(65),
  1468. uniq: __webpack_require__(20),
  1469. valuesOfKey: __webpack_require__(66)
  1470. };
  1471. /***/ }),
  1472. /* 54 */
  1473. /***/ (function(module, exports, __webpack_require__) {
  1474. var filter = __webpack_require__(12);
  1475. var contains = __webpack_require__(9);
  1476. /**
  1477. * Flattens `array` a single level deep.
  1478. *
  1479. * @param {Array} arr The array to inspect.
  1480. * @param {Array} values The values to exclude.
  1481. * @return {Array} Returns the new array of filtered values.
  1482. * @example
  1483. * difference([2, 1], [2, 3]); // => [1]
  1484. */
  1485. var difference = function difference(arr) {
  1486. var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  1487. return filter(arr, function (value) {
  1488. return !contains(values, value);
  1489. });
  1490. };
  1491. module.exports = difference;
  1492. /***/ }),
  1493. /* 55 */
  1494. /***/ (function(module, exports, __webpack_require__) {
  1495. var isFunction = __webpack_require__(2);
  1496. var isPlainObject = __webpack_require__(7);
  1497. var isMatch = __webpack_require__(17);
  1498. function find(arr, predicate) {
  1499. var _predicate = void 0;
  1500. if (isFunction(predicate)) {
  1501. _predicate = predicate;
  1502. }
  1503. if (isPlainObject(predicate)) {
  1504. _predicate = function _predicate(a) {
  1505. return isMatch(a, predicate);
  1506. };
  1507. }
  1508. if (_predicate) {
  1509. for (var i = 0; i < arr.length; i += 1) {
  1510. if (_predicate(arr[i])) {
  1511. return arr[i];
  1512. }
  1513. }
  1514. }
  1515. return null;
  1516. }
  1517. module.exports = find;
  1518. /***/ }),
  1519. /* 56 */
  1520. /***/ (function(module, exports, __webpack_require__) {
  1521. var isNil = __webpack_require__(5);
  1522. var isArray = __webpack_require__(1);
  1523. var firstValue = function firstValue(data, name) {
  1524. var rst = null;
  1525. for (var i = 0; i < data.length; i++) {
  1526. var obj = data[i];
  1527. var value = obj[name];
  1528. if (!isNil(value)) {
  1529. if (isArray(value)) {
  1530. rst = value[0];
  1531. } else {
  1532. rst = value;
  1533. }
  1534. break;
  1535. }
  1536. }
  1537. return rst;
  1538. };
  1539. module.exports = firstValue;
  1540. /***/ }),
  1541. /* 57 */
  1542. /***/ (function(module, exports, __webpack_require__) {
  1543. var isArray = __webpack_require__(1);
  1544. var each = __webpack_require__(0);
  1545. /**
  1546. * Flattens `array` a single level deep.
  1547. *
  1548. * @param {Array} arr The array to flatten.
  1549. * @return {Array} Returns the new flattened array.
  1550. * @example
  1551. *
  1552. * flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
  1553. */
  1554. var flatten = function flatten(arr) {
  1555. if (!isArray(arr)) {
  1556. return arr;
  1557. }
  1558. var result = [];
  1559. each(arr, function (item) {
  1560. if (isArray(item)) {
  1561. each(item, function (subItem) {
  1562. result.push(subItem);
  1563. });
  1564. } else {
  1565. result.push(item);
  1566. }
  1567. });
  1568. return result;
  1569. };
  1570. module.exports = flatten;
  1571. /***/ }),
  1572. /* 58 */
  1573. /***/ (function(module, exports, __webpack_require__) {
  1574. var isArray = __webpack_require__(1);
  1575. /**
  1576. * Flattens `array` a single level deep.
  1577. *
  1578. * @param {Array} arr The array to flatten.
  1579. * @param {Array} result The array to return.
  1580. * @return {Array} Returns the new flattened array.
  1581. * @example
  1582. *
  1583. * flattenDeep([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5]
  1584. */
  1585. var flattenDeep = function flattenDeep(arr) {
  1586. var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  1587. if (!isArray(arr)) {
  1588. result.push(arr);
  1589. } else {
  1590. for (var i = 0; i < arr.length; i += 1) {
  1591. flattenDeep(arr[i], result);
  1592. }
  1593. }
  1594. return result;
  1595. };
  1596. module.exports = flattenDeep;
  1597. /***/ }),
  1598. /* 59 */
  1599. /***/ (function(module, exports, __webpack_require__) {
  1600. var filter = __webpack_require__(12);
  1601. var isArray = __webpack_require__(1);
  1602. var getRange = function getRange(values) {
  1603. // 存在 NaN 时,min,max 判定会出问题
  1604. values = filter(values, function (v) {
  1605. return !isNaN(v);
  1606. });
  1607. if (!values.length) {
  1608. // 如果没有数值则直接返回0
  1609. return {
  1610. min: 0,
  1611. max: 0
  1612. };
  1613. }
  1614. if (isArray(values[0])) {
  1615. var tmp = [];
  1616. for (var i = 0; i < values.length; i++) {
  1617. tmp = tmp.concat(values[i]);
  1618. }
  1619. values = tmp;
  1620. }
  1621. var max = Math.max.apply(null, values);
  1622. var min = Math.min.apply(null, values);
  1623. return {
  1624. min: min,
  1625. max: max
  1626. };
  1627. };
  1628. module.exports = getRange;
  1629. /***/ }),
  1630. /* 60 */
  1631. /***/ (function(module, exports) {
  1632. var merge = function merge(dataArray) {
  1633. var rst = [];
  1634. for (var i = 0; i < dataArray.length; i++) {
  1635. rst = rst.concat(dataArray[i]);
  1636. }
  1637. return rst;
  1638. };
  1639. module.exports = merge;
  1640. /***/ }),
  1641. /* 61 */
  1642. /***/ (function(module, exports) {
  1643. var arrPrototype = Array.prototype;
  1644. var splice = arrPrototype.splice;
  1645. var indexOf = arrPrototype.indexOf;
  1646. var slice = arrPrototype.slice;
  1647. var pull = function pull(arr) {
  1648. var values = slice.call(arguments, 1);
  1649. for (var i = 0; i < values.length; i++) {
  1650. var value = values[i];
  1651. var fromIndex = -1;
  1652. while ((fromIndex = indexOf.call(arr, value)) > -1) {
  1653. splice.call(arr, fromIndex, 1);
  1654. }
  1655. }
  1656. return arr;
  1657. };
  1658. module.exports = pull;
  1659. /***/ }),
  1660. /* 62 */
  1661. /***/ (function(module, exports, __webpack_require__) {
  1662. var isArray = __webpack_require__(1);
  1663. var isPlainObject = __webpack_require__(7);
  1664. var each = __webpack_require__(0);
  1665. var reduce = function reduce(arr, fn, init) {
  1666. if (!isArray(arr) && !isPlainObject(arr)) {
  1667. return arr;
  1668. }
  1669. var result = init;
  1670. each(arr, function (data, i) {
  1671. result = fn(result, data, i);
  1672. });
  1673. return result;
  1674. };
  1675. module.exports = reduce;
  1676. /***/ }),
  1677. /* 63 */
  1678. /***/ (function(module, exports, __webpack_require__) {
  1679. var isArrayLike = __webpack_require__(3);
  1680. var pullAt = __webpack_require__(19);
  1681. var remove = function remove(arr, predicate) {
  1682. /**
  1683. * const arr = [1, 2, 3, 4]
  1684. * const evens = remove(arr, n => n % 2 == 0)
  1685. * console.log(arr) // => [1, 3]
  1686. * console.log(evens) // => [2, 4]
  1687. */
  1688. var result = [];
  1689. if (!isArrayLike(arr)) {
  1690. return result;
  1691. }
  1692. var i = -1;
  1693. var indexes = [];
  1694. var length = arr.length;
  1695. while (++i < length) {
  1696. var value = arr[i];
  1697. if (predicate(value, i, arr)) {
  1698. result.push(value);
  1699. indexes.push(i);
  1700. }
  1701. }
  1702. pullAt(arr, indexes);
  1703. return result;
  1704. };
  1705. module.exports = remove;
  1706. /***/ }),
  1707. /* 64 */
  1708. /***/ (function(module, exports, __webpack_require__) {
  1709. var isString = __webpack_require__(10);
  1710. var isFunction = __webpack_require__(2);
  1711. var isArray = __webpack_require__(1);
  1712. function sortBy(arr, key) {
  1713. var comparer = void 0;
  1714. if (isFunction(key)) {
  1715. comparer = function comparer(a, b) {
  1716. return key(a) - key(b);
  1717. };
  1718. } else {
  1719. var keys = [];
  1720. if (isString(key)) {
  1721. keys.push(key);
  1722. } else if (isArray(key)) {
  1723. keys = key;
  1724. }
  1725. comparer = function comparer(a, b) {
  1726. for (var i = 0; i < keys.length; i += 1) {
  1727. var prop = keys[i];
  1728. if (a[prop] > b[prop]) {
  1729. return 1;
  1730. }
  1731. if (a[prop] < b[prop]) {
  1732. return -1;
  1733. }
  1734. }
  1735. return 0;
  1736. };
  1737. }
  1738. arr.sort(comparer);
  1739. return arr;
  1740. }
  1741. module.exports = sortBy;
  1742. /***/ }),
  1743. /* 65 */
  1744. /***/ (function(module, exports, __webpack_require__) {
  1745. var each = __webpack_require__(0);
  1746. var toArray = __webpack_require__(14);
  1747. var uniq = __webpack_require__(20);
  1748. var union = function union() {
  1749. var result = [];
  1750. var sources = toArray(arguments);
  1751. each(sources, function (arr) {
  1752. result = result.concat(arr);
  1753. });
  1754. return uniq(result);
  1755. };
  1756. module.exports = union;
  1757. /***/ }),
  1758. /* 66 */
  1759. /***/ (function(module, exports, __webpack_require__) {
  1760. var isNil = __webpack_require__(5);
  1761. var isArray = __webpack_require__(1);
  1762. var each = __webpack_require__(0);
  1763. module.exports = function valuesOfKey(data, name) {
  1764. var rst = [];
  1765. var tmpMap = {};
  1766. for (var i = 0; i < data.length; i++) {
  1767. var obj = data[i];
  1768. var value = obj[name];
  1769. if (!isNil(value)) {
  1770. if (!isArray(value)) {
  1771. value = [value];
  1772. }
  1773. each(value, function (val) {
  1774. if (!tmpMap[val]) {
  1775. rst.push(val);
  1776. tmpMap[val] = true;
  1777. }
  1778. });
  1779. }
  1780. }
  1781. return rst;
  1782. };
  1783. /***/ }),
  1784. /* 67 */
  1785. /***/ (function(module, exports, __webpack_require__) {
  1786. module.exports = {
  1787. getWrapBehavior: __webpack_require__(68),
  1788. wrapBehavior: __webpack_require__(69)
  1789. };
  1790. /***/ }),
  1791. /* 68 */
  1792. /***/ (function(module, exports) {
  1793. /**
  1794. * 获取封装的事件
  1795. * @protected
  1796. * @param {Object} obj 对象
  1797. * @param {String} action 事件名称
  1798. * @return {Function} 返回事件处理函数
  1799. */
  1800. function getWrapBehavior(obj, action) {
  1801. return obj['_wrap_' + action];
  1802. }
  1803. module.exports = getWrapBehavior;
  1804. /***/ }),
  1805. /* 69 */
  1806. /***/ (function(module, exports) {
  1807. /**
  1808. * 封装事件,便于使用上下文this,和便于解除事件时使用
  1809. * @protected
  1810. * @param {Object} obj 对象
  1811. * @param {String} action 事件名称
  1812. * @return {Function} 返回事件处理函数
  1813. */
  1814. function wrapBehavior(obj, action) {
  1815. if (obj['_wrap_' + action]) {
  1816. return obj['_wrap_' + action];
  1817. }
  1818. var method = function method(e) {
  1819. obj[action](e);
  1820. };
  1821. obj['_wrap_' + action] = method;
  1822. return method;
  1823. }
  1824. module.exports = wrapBehavior;
  1825. /***/ }),
  1826. /* 70 */
  1827. /***/ (function(module, exports, __webpack_require__) {
  1828. var number2color = __webpack_require__(71);
  1829. module.exports = {
  1830. number2color: number2color,
  1831. numberToColor: number2color,
  1832. parsePath: __webpack_require__(72),
  1833. parseRadius: __webpack_require__(73)
  1834. };
  1835. /***/ }),
  1836. /* 71 */
  1837. /***/ (function(module, exports) {
  1838. var numColorCache = {};
  1839. module.exports = function numberToColor(num) {
  1840. // 增加缓存
  1841. var color = numColorCache[num];
  1842. if (!color) {
  1843. var str = num.toString(16);
  1844. for (var i = str.length; i < 6; i++) {
  1845. str = '0' + str;
  1846. }
  1847. color = '#' + str;
  1848. numColorCache[num] = color;
  1849. }
  1850. return color;
  1851. };
  1852. /***/ }),
  1853. /* 72 */
  1854. /***/ (function(module, exports, __webpack_require__) {
  1855. var isArray = __webpack_require__(1);
  1856. var isString = __webpack_require__(10);
  1857. var each = __webpack_require__(0);
  1858. var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
  1859. var regexDot = /[^\s\,]+/ig;
  1860. module.exports = function parsePath(path) {
  1861. path = path || [];
  1862. if (isArray(path)) {
  1863. return path;
  1864. }
  1865. if (isString(path)) {
  1866. path = path.match(regexTags);
  1867. each(path, function (item, index) {
  1868. item = item.match(regexDot);
  1869. if (item[0].length > 1) {
  1870. var tag = item[0].charAt(0);
  1871. item.splice(1, 0, item[0].substr(1));
  1872. item[0] = tag;
  1873. }
  1874. each(item, function (sub, i) {
  1875. if (!isNaN(sub)) {
  1876. item[i] = +sub;
  1877. }
  1878. });
  1879. path[index] = item;
  1880. });
  1881. return path;
  1882. }
  1883. };
  1884. /***/ }),
  1885. /* 73 */
  1886. /***/ (function(module, exports, __webpack_require__) {
  1887. var isArray = __webpack_require__(1);
  1888. module.exports = function parseRadius(radius) {
  1889. var r1 = 0,
  1890. r2 = 0,
  1891. r3 = 0,
  1892. r4 = 0;
  1893. if (isArray(radius)) {
  1894. if (radius.length === 1) {
  1895. r1 = r2 = r3 = r4 = radius[0];
  1896. } else if (radius.length === 2) {
  1897. r1 = r3 = radius[0];
  1898. r2 = r4 = radius[1];
  1899. } else if (radius.length === 3) {
  1900. r1 = radius[0];
  1901. r2 = r4 = radius[1];
  1902. r3 = radius[2];
  1903. } else {
  1904. r1 = radius[0];
  1905. r2 = radius[1];
  1906. r3 = radius[2];
  1907. r4 = radius[3];
  1908. }
  1909. } else {
  1910. r1 = r2 = r3 = r4 = radius;
  1911. }
  1912. return {
  1913. r1: r1,
  1914. r2: r2,
  1915. r3: r3,
  1916. r4: r4
  1917. };
  1918. };
  1919. /***/ }),
  1920. /* 74 */
  1921. /***/ (function(module, exports, __webpack_require__) {
  1922. var isNumberEqual = __webpack_require__(75);
  1923. module.exports = {
  1924. clamp: __webpack_require__(21),
  1925. fixedBase: __webpack_require__(76),
  1926. isDecimal: __webpack_require__(77),
  1927. isEven: __webpack_require__(78),
  1928. isInteger: __webpack_require__(79),
  1929. isNegative: __webpack_require__(80),
  1930. isNumberEqual: isNumberEqual,
  1931. isOdd: __webpack_require__(81),
  1932. isPositive: __webpack_require__(82),
  1933. maxBy: __webpack_require__(83),
  1934. minBy: __webpack_require__(84),
  1935. mod: __webpack_require__(85),
  1936. snapEqual: isNumberEqual,
  1937. toDegree: __webpack_require__(86),
  1938. toInt: __webpack_require__(22),
  1939. toInteger: __webpack_require__(22),
  1940. toRadian: __webpack_require__(87)
  1941. };
  1942. /***/ }),
  1943. /* 75 */
  1944. /***/ (function(module, exports) {
  1945. var PRECISION = 0.00001; // numbers less than this is considered as 0
  1946. module.exports = function isNumberEqual(a, b) {
  1947. var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PRECISION;
  1948. return Math.abs(a - b) < precision;
  1949. };
  1950. /***/ }),
  1951. /* 76 */
  1952. /***/ (function(module, exports) {
  1953. var fixedBase = function fixedBase(v, base) {
  1954. var str = base.toString();
  1955. var index = str.indexOf('.');
  1956. if (index === -1) {
  1957. return Math.round(v);
  1958. }
  1959. var length = str.substr(index + 1).length;
  1960. if (length > 20) {
  1961. length = 20;
  1962. }
  1963. return parseFloat(v.toFixed(length));
  1964. };
  1965. module.exports = fixedBase;
  1966. /***/ }),
  1967. /* 77 */
  1968. /***/ (function(module, exports, __webpack_require__) {
  1969. var isNumber = __webpack_require__(6);
  1970. var isDecimal = function isDecimal(num) {
  1971. return isNumber(num) && num % 1 !== 0;
  1972. };
  1973. module.exports = isDecimal;
  1974. /***/ }),
  1975. /* 78 */
  1976. /***/ (function(module, exports, __webpack_require__) {
  1977. var isNumber = __webpack_require__(6);
  1978. var isEven = function isEven(num) {
  1979. return isNumber(num) && num % 2 === 0;
  1980. };
  1981. module.exports = isEven;
  1982. /***/ }),
  1983. /* 79 */
  1984. /***/ (function(module, exports, __webpack_require__) {
  1985. var isNumber = __webpack_require__(6);
  1986. var isInteger = Number.isInteger ? Number.isInteger : function (num) {
  1987. return isNumber(num) && num % 1 === 0;
  1988. };
  1989. module.exports = isInteger;
  1990. /***/ }),
  1991. /* 80 */
  1992. /***/ (function(module, exports, __webpack_require__) {
  1993. var isNumber = __webpack_require__(6);
  1994. var isNagative = function isNagative(num) {
  1995. return isNumber(num) && num < 0;
  1996. };
  1997. module.exports = isNagative;
  1998. /***/ }),
  1999. /* 81 */
  2000. /***/ (function(module, exports, __webpack_require__) {
  2001. var isNumber = __webpack_require__(6);
  2002. var isOdd = function isOdd(num) {
  2003. return isNumber(num) && num % 2 !== 0;
  2004. };
  2005. module.exports = isOdd;
  2006. /***/ }),
  2007. /* 82 */
  2008. /***/ (function(module, exports, __webpack_require__) {
  2009. var isNumber = __webpack_require__(6);
  2010. var isPositive = function isPositive(num) {
  2011. return isNumber(num) && num > 0;
  2012. };
  2013. module.exports = isPositive;
  2014. /***/ }),
  2015. /* 83 */
  2016. /***/ (function(module, exports, __webpack_require__) {
  2017. var isArray = __webpack_require__(1);
  2018. var isFunction = __webpack_require__(2);
  2019. var each = __webpack_require__(0);
  2020. /**
  2021. * @param {Array} arr The array to iterate over.
  2022. * @param {Function} [fn] The iteratee invoked per element.
  2023. * @return {*} Returns the maximum value.
  2024. * @example
  2025. *
  2026. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  2027. *
  2028. * maxBy(objects, function(o) { return o.n; });
  2029. * // => { 'n': 2 }
  2030. *
  2031. * maxBy(objects, 'n');
  2032. * // => { 'n': 2 }
  2033. */
  2034. var maxBy = function maxBy(arr, fn) {
  2035. if (!isArray(arr)) {
  2036. return undefined;
  2037. }
  2038. var max = arr[0];
  2039. var maxData = void 0;
  2040. if (isFunction(fn)) {
  2041. maxData = fn(arr[0]);
  2042. } else {
  2043. maxData = arr[0][fn];
  2044. }
  2045. var data = void 0;
  2046. each(arr, function (val) {
  2047. if (isFunction(fn)) {
  2048. data = fn(val);
  2049. } else {
  2050. data = val[fn];
  2051. }
  2052. if (data > maxData) {
  2053. max = val;
  2054. maxData = data;
  2055. }
  2056. });
  2057. return max;
  2058. };
  2059. module.exports = maxBy;
  2060. /***/ }),
  2061. /* 84 */
  2062. /***/ (function(module, exports, __webpack_require__) {
  2063. var isArray = __webpack_require__(1);
  2064. var isFunction = __webpack_require__(2);
  2065. var each = __webpack_require__(0);
  2066. /**
  2067. * @param {Array} arr The array to iterate over.
  2068. * @param {Function} [fn] The iteratee invoked per element.
  2069. * @return {*} Returns the minimum value.
  2070. * @example
  2071. *
  2072. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  2073. *
  2074. * minBy(objects, function(o) { return o.n; });
  2075. * // => { 'n': 1 }
  2076. *
  2077. * minBy(objects, 'n');
  2078. * // => { 'n': 1 }
  2079. */
  2080. var minBy = function minBy(arr, fn) {
  2081. if (!isArray(arr)) {
  2082. return undefined;
  2083. }
  2084. var min = arr[0];
  2085. var minData = void 0;
  2086. if (isFunction(fn)) {
  2087. minData = fn(arr[0]);
  2088. } else {
  2089. minData = arr[0][fn];
  2090. }
  2091. var data = void 0;
  2092. each(arr, function (val) {
  2093. if (isFunction(fn)) {
  2094. data = fn(val);
  2095. } else {
  2096. data = val[fn];
  2097. }
  2098. if (data < minData) {
  2099. min = val;
  2100. minData = data;
  2101. }
  2102. });
  2103. return min;
  2104. };
  2105. module.exports = minBy;
  2106. /***/ }),
  2107. /* 85 */
  2108. /***/ (function(module, exports) {
  2109. var mod = function mod(n, m) {
  2110. return (n % m + m) % m;
  2111. };
  2112. module.exports = mod;
  2113. /***/ }),
  2114. /* 86 */
  2115. /***/ (function(module, exports) {
  2116. var DEGREE = 180 / Math.PI;
  2117. var toDegree = function toDegree(radian) {
  2118. return DEGREE * radian;
  2119. };
  2120. module.exports = toDegree;
  2121. /***/ }),
  2122. /* 87 */
  2123. /***/ (function(module, exports) {
  2124. var RADIAN = Math.PI / 180;
  2125. var toRadian = function toRadian(degree) {
  2126. return RADIAN * degree;
  2127. };
  2128. module.exports = toRadian;
  2129. /***/ }),
  2130. /* 88 */
  2131. /***/ (function(module, exports, __webpack_require__) {
  2132. module.exports = {
  2133. mat3: __webpack_require__(23),
  2134. vec2: __webpack_require__(90),
  2135. vec3: __webpack_require__(92),
  2136. transform: __webpack_require__(94)
  2137. };
  2138. /***/ }),
  2139. /* 89 */
  2140. /***/ (function(module, exports, __webpack_require__) {
  2141. Object.defineProperty(exports, "__esModule", {
  2142. value: true
  2143. });
  2144. exports.sub = exports.mul = undefined;
  2145. exports.create = create;
  2146. exports.fromMat4 = fromMat4;
  2147. exports.clone = clone;
  2148. exports.copy = copy;
  2149. exports.fromValues = fromValues;
  2150. exports.set = set;
  2151. exports.identity = identity;
  2152. exports.transpose = transpose;
  2153. exports.invert = invert;
  2154. exports.adjoint = adjoint;
  2155. exports.determinant = determinant;
  2156. exports.multiply = multiply;
  2157. exports.translate = translate;
  2158. exports.rotate = rotate;
  2159. exports.scale = scale;
  2160. exports.fromTranslation = fromTranslation;
  2161. exports.fromRotation = fromRotation;
  2162. exports.fromScaling = fromScaling;
  2163. exports.fromMat2d = fromMat2d;
  2164. exports.fromQuat = fromQuat;
  2165. exports.normalFromMat4 = normalFromMat4;
  2166. exports.projection = projection;
  2167. exports.str = str;
  2168. exports.frob = frob;
  2169. exports.add = add;
  2170. exports.subtract = subtract;
  2171. exports.multiplyScalar = multiplyScalar;
  2172. exports.multiplyScalarAndAdd = multiplyScalarAndAdd;
  2173. exports.exactEquals = exactEquals;
  2174. exports.equals = equals;
  2175. var _common = __webpack_require__(15);
  2176. var glMatrix = _interopRequireWildcard(_common);
  2177. function _interopRequireWildcard(obj) {
  2178. if (obj && obj.__esModule) {
  2179. return obj;
  2180. } else {
  2181. var newObj = {};if (obj != null) {
  2182. for (var key in obj) {
  2183. if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
  2184. }
  2185. }newObj.default = obj;return newObj;
  2186. }
  2187. }
  2188. /**
  2189. * 3x3 Matrix
  2190. * @module mat3
  2191. */
  2192. /**
  2193. * Creates a new identity mat3
  2194. *
  2195. * @returns {mat3} a new 3x3 matrix
  2196. */
  2197. function create() {
  2198. var out = new glMatrix.ARRAY_TYPE(9);
  2199. if (glMatrix.ARRAY_TYPE != Float32Array) {
  2200. out[1] = 0;
  2201. out[2] = 0;
  2202. out[3] = 0;
  2203. out[5] = 0;
  2204. out[6] = 0;
  2205. out[7] = 0;
  2206. }
  2207. out[0] = 1;
  2208. out[4] = 1;
  2209. out[8] = 1;
  2210. return out;
  2211. }
  2212. /**
  2213. * Copies the upper-left 3x3 values into the given mat3.
  2214. *
  2215. * @param {mat3} out the receiving 3x3 matrix
  2216. * @param {mat4} a the source 4x4 matrix
  2217. * @returns {mat3} out
  2218. */
  2219. function fromMat4(out, a) {
  2220. out[0] = a[0];
  2221. out[1] = a[1];
  2222. out[2] = a[2];
  2223. out[3] = a[4];
  2224. out[4] = a[5];
  2225. out[5] = a[6];
  2226. out[6] = a[8];
  2227. out[7] = a[9];
  2228. out[8] = a[10];
  2229. return out;
  2230. }
  2231. /**
  2232. * Creates a new mat3 initialized with values from an existing matrix
  2233. *
  2234. * @param {mat3} a matrix to clone
  2235. * @returns {mat3} a new 3x3 matrix
  2236. */
  2237. function clone(a) {
  2238. var out = new glMatrix.ARRAY_TYPE(9);
  2239. out[0] = a[0];
  2240. out[1] = a[1];
  2241. out[2] = a[2];
  2242. out[3] = a[3];
  2243. out[4] = a[4];
  2244. out[5] = a[5];
  2245. out[6] = a[6];
  2246. out[7] = a[7];
  2247. out[8] = a[8];
  2248. return out;
  2249. }
  2250. /**
  2251. * Copy the values from one mat3 to another
  2252. *
  2253. * @param {mat3} out the receiving matrix
  2254. * @param {mat3} a the source matrix
  2255. * @returns {mat3} out
  2256. */
  2257. function copy(out, a) {
  2258. out[0] = a[0];
  2259. out[1] = a[1];
  2260. out[2] = a[2];
  2261. out[3] = a[3];
  2262. out[4] = a[4];
  2263. out[5] = a[5];
  2264. out[6] = a[6];
  2265. out[7] = a[7];
  2266. out[8] = a[8];
  2267. return out;
  2268. }
  2269. /**
  2270. * Create a new mat3 with the given values
  2271. *
  2272. * @param {Number} m00 Component in column 0, row 0 position (index 0)
  2273. * @param {Number} m01 Component in column 0, row 1 position (index 1)
  2274. * @param {Number} m02 Component in column 0, row 2 position (index 2)
  2275. * @param {Number} m10 Component in column 1, row 0 position (index 3)
  2276. * @param {Number} m11 Component in column 1, row 1 position (index 4)
  2277. * @param {Number} m12 Component in column 1, row 2 position (index 5)
  2278. * @param {Number} m20 Component in column 2, row 0 position (index 6)
  2279. * @param {Number} m21 Component in column 2, row 1 position (index 7)
  2280. * @param {Number} m22 Component in column 2, row 2 position (index 8)
  2281. * @returns {mat3} A new mat3
  2282. */
  2283. function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
  2284. var out = new glMatrix.ARRAY_TYPE(9);
  2285. out[0] = m00;
  2286. out[1] = m01;
  2287. out[2] = m02;
  2288. out[3] = m10;
  2289. out[4] = m11;
  2290. out[5] = m12;
  2291. out[6] = m20;
  2292. out[7] = m21;
  2293. out[8] = m22;
  2294. return out;
  2295. }
  2296. /**
  2297. * Set the components of a mat3 to the given values
  2298. *
  2299. * @param {mat3} out the receiving matrix
  2300. * @param {Number} m00 Component in column 0, row 0 position (index 0)
  2301. * @param {Number} m01 Component in column 0, row 1 position (index 1)
  2302. * @param {Number} m02 Component in column 0, row 2 position (index 2)
  2303. * @param {Number} m10 Component in column 1, row 0 position (index 3)
  2304. * @param {Number} m11 Component in column 1, row 1 position (index 4)
  2305. * @param {Number} m12 Component in column 1, row 2 position (index 5)
  2306. * @param {Number} m20 Component in column 2, row 0 position (index 6)
  2307. * @param {Number} m21 Component in column 2, row 1 position (index 7)
  2308. * @param {Number} m22 Component in column 2, row 2 position (index 8)
  2309. * @returns {mat3} out
  2310. */
  2311. function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
  2312. out[0] = m00;
  2313. out[1] = m01;
  2314. out[2] = m02;
  2315. out[3] = m10;
  2316. out[4] = m11;
  2317. out[5] = m12;
  2318. out[6] = m20;
  2319. out[7] = m21;
  2320. out[8] = m22;
  2321. return out;
  2322. }
  2323. /**
  2324. * Set a mat3 to the identity matrix
  2325. *
  2326. * @param {mat3} out the receiving matrix
  2327. * @returns {mat3} out
  2328. */
  2329. function identity(out) {
  2330. out[0] = 1;
  2331. out[1] = 0;
  2332. out[2] = 0;
  2333. out[3] = 0;
  2334. out[4] = 1;
  2335. out[5] = 0;
  2336. out[6] = 0;
  2337. out[7] = 0;
  2338. out[8] = 1;
  2339. return out;
  2340. }
  2341. /**
  2342. * Transpose the values of a mat3
  2343. *
  2344. * @param {mat3} out the receiving matrix
  2345. * @param {mat3} a the source matrix
  2346. * @returns {mat3} out
  2347. */
  2348. function transpose(out, a) {
  2349. // If we are transposing ourselves we can skip a few steps but have to cache some values
  2350. if (out === a) {
  2351. var a01 = a[1],
  2352. a02 = a[2],
  2353. a12 = a[5];
  2354. out[1] = a[3];
  2355. out[2] = a[6];
  2356. out[3] = a01;
  2357. out[5] = a[7];
  2358. out[6] = a02;
  2359. out[7] = a12;
  2360. } else {
  2361. out[0] = a[0];
  2362. out[1] = a[3];
  2363. out[2] = a[6];
  2364. out[3] = a[1];
  2365. out[4] = a[4];
  2366. out[5] = a[7];
  2367. out[6] = a[2];
  2368. out[7] = a[5];
  2369. out[8] = a[8];
  2370. }
  2371. return out;
  2372. }
  2373. /**
  2374. * Inverts a mat3
  2375. *
  2376. * @param {mat3} out the receiving matrix
  2377. * @param {mat3} a the source matrix
  2378. * @returns {mat3} out
  2379. */
  2380. function invert(out, a) {
  2381. var a00 = a[0],
  2382. a01 = a[1],
  2383. a02 = a[2];
  2384. var a10 = a[3],
  2385. a11 = a[4],
  2386. a12 = a[5];
  2387. var a20 = a[6],
  2388. a21 = a[7],
  2389. a22 = a[8];
  2390. var b01 = a22 * a11 - a12 * a21;
  2391. var b11 = -a22 * a10 + a12 * a20;
  2392. var b21 = a21 * a10 - a11 * a20;
  2393. // Calculate the determinant
  2394. var det = a00 * b01 + a01 * b11 + a02 * b21;
  2395. if (!det) {
  2396. return null;
  2397. }
  2398. det = 1.0 / det;
  2399. out[0] = b01 * det;
  2400. out[1] = (-a22 * a01 + a02 * a21) * det;
  2401. out[2] = (a12 * a01 - a02 * a11) * det;
  2402. out[3] = b11 * det;
  2403. out[4] = (a22 * a00 - a02 * a20) * det;
  2404. out[5] = (-a12 * a00 + a02 * a10) * det;
  2405. out[6] = b21 * det;
  2406. out[7] = (-a21 * a00 + a01 * a20) * det;
  2407. out[8] = (a11 * a00 - a01 * a10) * det;
  2408. return out;
  2409. }
  2410. /**
  2411. * Calculates the adjugate of a mat3
  2412. *
  2413. * @param {mat3} out the receiving matrix
  2414. * @param {mat3} a the source matrix
  2415. * @returns {mat3} out
  2416. */
  2417. function adjoint(out, a) {
  2418. var a00 = a[0],
  2419. a01 = a[1],
  2420. a02 = a[2];
  2421. var a10 = a[3],
  2422. a11 = a[4],
  2423. a12 = a[5];
  2424. var a20 = a[6],
  2425. a21 = a[7],
  2426. a22 = a[8];
  2427. out[0] = a11 * a22 - a12 * a21;
  2428. out[1] = a02 * a21 - a01 * a22;
  2429. out[2] = a01 * a12 - a02 * a11;
  2430. out[3] = a12 * a20 - a10 * a22;
  2431. out[4] = a00 * a22 - a02 * a20;
  2432. out[5] = a02 * a10 - a00 * a12;
  2433. out[6] = a10 * a21 - a11 * a20;
  2434. out[7] = a01 * a20 - a00 * a21;
  2435. out[8] = a00 * a11 - a01 * a10;
  2436. return out;
  2437. }
  2438. /**
  2439. * Calculates the determinant of a mat3
  2440. *
  2441. * @param {mat3} a the source matrix
  2442. * @returns {Number} determinant of a
  2443. */
  2444. function determinant(a) {
  2445. var a00 = a[0],
  2446. a01 = a[1],
  2447. a02 = a[2];
  2448. var a10 = a[3],
  2449. a11 = a[4],
  2450. a12 = a[5];
  2451. var a20 = a[6],
  2452. a21 = a[7],
  2453. a22 = a[8];
  2454. return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
  2455. }
  2456. /**
  2457. * Multiplies two mat3's
  2458. *
  2459. * @param {mat3} out the receiving matrix
  2460. * @param {mat3} a the first operand
  2461. * @param {mat3} b the second operand
  2462. * @returns {mat3} out
  2463. */
  2464. function multiply(out, a, b) {
  2465. var a00 = a[0],
  2466. a01 = a[1],
  2467. a02 = a[2];
  2468. var a10 = a[3],
  2469. a11 = a[4],
  2470. a12 = a[5];
  2471. var a20 = a[6],
  2472. a21 = a[7],
  2473. a22 = a[8];
  2474. var b00 = b[0],
  2475. b01 = b[1],
  2476. b02 = b[2];
  2477. var b10 = b[3],
  2478. b11 = b[4],
  2479. b12 = b[5];
  2480. var b20 = b[6],
  2481. b21 = b[7],
  2482. b22 = b[8];
  2483. out[0] = b00 * a00 + b01 * a10 + b02 * a20;
  2484. out[1] = b00 * a01 + b01 * a11 + b02 * a21;
  2485. out[2] = b00 * a02 + b01 * a12 + b02 * a22;
  2486. out[3] = b10 * a00 + b11 * a10 + b12 * a20;
  2487. out[4] = b10 * a01 + b11 * a11 + b12 * a21;
  2488. out[5] = b10 * a02 + b11 * a12 + b12 * a22;
  2489. out[6] = b20 * a00 + b21 * a10 + b22 * a20;
  2490. out[7] = b20 * a01 + b21 * a11 + b22 * a21;
  2491. out[8] = b20 * a02 + b21 * a12 + b22 * a22;
  2492. return out;
  2493. }
  2494. /**
  2495. * Translate a mat3 by the given vector
  2496. *
  2497. * @param {mat3} out the receiving matrix
  2498. * @param {mat3} a the matrix to translate
  2499. * @param {vec2} v vector to translate by
  2500. * @returns {mat3} out
  2501. */
  2502. function translate(out, a, v) {
  2503. var a00 = a[0],
  2504. a01 = a[1],
  2505. a02 = a[2],
  2506. a10 = a[3],
  2507. a11 = a[4],
  2508. a12 = a[5],
  2509. a20 = a[6],
  2510. a21 = a[7],
  2511. a22 = a[8],
  2512. x = v[0],
  2513. y = v[1];
  2514. out[0] = a00;
  2515. out[1] = a01;
  2516. out[2] = a02;
  2517. out[3] = a10;
  2518. out[4] = a11;
  2519. out[5] = a12;
  2520. out[6] = x * a00 + y * a10 + a20;
  2521. out[7] = x * a01 + y * a11 + a21;
  2522. out[8] = x * a02 + y * a12 + a22;
  2523. return out;
  2524. }
  2525. /**
  2526. * Rotates a mat3 by the given angle
  2527. *
  2528. * @param {mat3} out the receiving matrix
  2529. * @param {mat3} a the matrix to rotate
  2530. * @param {Number} rad the angle to rotate the matrix by
  2531. * @returns {mat3} out
  2532. */
  2533. function rotate(out, a, rad) {
  2534. var a00 = a[0],
  2535. a01 = a[1],
  2536. a02 = a[2],
  2537. a10 = a[3],
  2538. a11 = a[4],
  2539. a12 = a[5],
  2540. a20 = a[6],
  2541. a21 = a[7],
  2542. a22 = a[8],
  2543. s = Math.sin(rad),
  2544. c = Math.cos(rad);
  2545. out[0] = c * a00 + s * a10;
  2546. out[1] = c * a01 + s * a11;
  2547. out[2] = c * a02 + s * a12;
  2548. out[3] = c * a10 - s * a00;
  2549. out[4] = c * a11 - s * a01;
  2550. out[5] = c * a12 - s * a02;
  2551. out[6] = a20;
  2552. out[7] = a21;
  2553. out[8] = a22;
  2554. return out;
  2555. };
  2556. /**
  2557. * Scales the mat3 by the dimensions in the given vec2
  2558. *
  2559. * @param {mat3} out the receiving matrix
  2560. * @param {mat3} a the matrix to rotate
  2561. * @param {vec2} v the vec2 to scale the matrix by
  2562. * @returns {mat3} out
  2563. **/
  2564. function scale(out, a, v) {
  2565. var x = v[0],
  2566. y = v[1];
  2567. out[0] = x * a[0];
  2568. out[1] = x * a[1];
  2569. out[2] = x * a[2];
  2570. out[3] = y * a[3];
  2571. out[4] = y * a[4];
  2572. out[5] = y * a[5];
  2573. out[6] = a[6];
  2574. out[7] = a[7];
  2575. out[8] = a[8];
  2576. return out;
  2577. }
  2578. /**
  2579. * Creates a matrix from a vector translation
  2580. * This is equivalent to (but much faster than):
  2581. *
  2582. * mat3.identity(dest);
  2583. * mat3.translate(dest, dest, vec);
  2584. *
  2585. * @param {mat3} out mat3 receiving operation result
  2586. * @param {vec2} v Translation vector
  2587. * @returns {mat3} out
  2588. */
  2589. function fromTranslation(out, v) {
  2590. out[0] = 1;
  2591. out[1] = 0;
  2592. out[2] = 0;
  2593. out[3] = 0;
  2594. out[4] = 1;
  2595. out[5] = 0;
  2596. out[6] = v[0];
  2597. out[7] = v[1];
  2598. out[8] = 1;
  2599. return out;
  2600. }
  2601. /**
  2602. * Creates a matrix from a given angle
  2603. * This is equivalent to (but much faster than):
  2604. *
  2605. * mat3.identity(dest);
  2606. * mat3.rotate(dest, dest, rad);
  2607. *
  2608. * @param {mat3} out mat3 receiving operation result
  2609. * @param {Number} rad the angle to rotate the matrix by
  2610. * @returns {mat3} out
  2611. */
  2612. function fromRotation(out, rad) {
  2613. var s = Math.sin(rad),
  2614. c = Math.cos(rad);
  2615. out[0] = c;
  2616. out[1] = s;
  2617. out[2] = 0;
  2618. out[3] = -s;
  2619. out[4] = c;
  2620. out[5] = 0;
  2621. out[6] = 0;
  2622. out[7] = 0;
  2623. out[8] = 1;
  2624. return out;
  2625. }
  2626. /**
  2627. * Creates a matrix from a vector scaling
  2628. * This is equivalent to (but much faster than):
  2629. *
  2630. * mat3.identity(dest);
  2631. * mat3.scale(dest, dest, vec);
  2632. *
  2633. * @param {mat3} out mat3 receiving operation result
  2634. * @param {vec2} v Scaling vector
  2635. * @returns {mat3} out
  2636. */
  2637. function fromScaling(out, v) {
  2638. out[0] = v[0];
  2639. out[1] = 0;
  2640. out[2] = 0;
  2641. out[3] = 0;
  2642. out[4] = v[1];
  2643. out[5] = 0;
  2644. out[6] = 0;
  2645. out[7] = 0;
  2646. out[8] = 1;
  2647. return out;
  2648. }
  2649. /**
  2650. * Copies the values from a mat2d into a mat3
  2651. *
  2652. * @param {mat3} out the receiving matrix
  2653. * @param {mat2d} a the matrix to copy
  2654. * @returns {mat3} out
  2655. **/
  2656. function fromMat2d(out, a) {
  2657. out[0] = a[0];
  2658. out[1] = a[1];
  2659. out[2] = 0;
  2660. out[3] = a[2];
  2661. out[4] = a[3];
  2662. out[5] = 0;
  2663. out[6] = a[4];
  2664. out[7] = a[5];
  2665. out[8] = 1;
  2666. return out;
  2667. }
  2668. /**
  2669. * Calculates a 3x3 matrix from the given quaternion
  2670. *
  2671. * @param {mat3} out mat3 receiving operation result
  2672. * @param {quat} q Quaternion to create matrix from
  2673. *
  2674. * @returns {mat3} out
  2675. */
  2676. function fromQuat(out, q) {
  2677. var x = q[0],
  2678. y = q[1],
  2679. z = q[2],
  2680. w = q[3];
  2681. var x2 = x + x;
  2682. var y2 = y + y;
  2683. var z2 = z + z;
  2684. var xx = x * x2;
  2685. var yx = y * x2;
  2686. var yy = y * y2;
  2687. var zx = z * x2;
  2688. var zy = z * y2;
  2689. var zz = z * z2;
  2690. var wx = w * x2;
  2691. var wy = w * y2;
  2692. var wz = w * z2;
  2693. out[0] = 1 - yy - zz;
  2694. out[3] = yx - wz;
  2695. out[6] = zx + wy;
  2696. out[1] = yx + wz;
  2697. out[4] = 1 - xx - zz;
  2698. out[7] = zy - wx;
  2699. out[2] = zx - wy;
  2700. out[5] = zy + wx;
  2701. out[8] = 1 - xx - yy;
  2702. return out;
  2703. }
  2704. /**
  2705. * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
  2706. *
  2707. * @param {mat3} out mat3 receiving operation result
  2708. * @param {mat4} a Mat4 to derive the normal matrix from
  2709. *
  2710. * @returns {mat3} out
  2711. */
  2712. function normalFromMat4(out, a) {
  2713. var a00 = a[0],
  2714. a01 = a[1],
  2715. a02 = a[2],
  2716. a03 = a[3];
  2717. var a10 = a[4],
  2718. a11 = a[5],
  2719. a12 = a[6],
  2720. a13 = a[7];
  2721. var a20 = a[8],
  2722. a21 = a[9],
  2723. a22 = a[10],
  2724. a23 = a[11];
  2725. var a30 = a[12],
  2726. a31 = a[13],
  2727. a32 = a[14],
  2728. a33 = a[15];
  2729. var b00 = a00 * a11 - a01 * a10;
  2730. var b01 = a00 * a12 - a02 * a10;
  2731. var b02 = a00 * a13 - a03 * a10;
  2732. var b03 = a01 * a12 - a02 * a11;
  2733. var b04 = a01 * a13 - a03 * a11;
  2734. var b05 = a02 * a13 - a03 * a12;
  2735. var b06 = a20 * a31 - a21 * a30;
  2736. var b07 = a20 * a32 - a22 * a30;
  2737. var b08 = a20 * a33 - a23 * a30;
  2738. var b09 = a21 * a32 - a22 * a31;
  2739. var b10 = a21 * a33 - a23 * a31;
  2740. var b11 = a22 * a33 - a23 * a32;
  2741. // Calculate the determinant
  2742. var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
  2743. if (!det) {
  2744. return null;
  2745. }
  2746. det = 1.0 / det;
  2747. out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
  2748. out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
  2749. out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
  2750. out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
  2751. out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
  2752. out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
  2753. out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
  2754. out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
  2755. out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
  2756. return out;
  2757. }
  2758. /**
  2759. * Generates a 2D projection matrix with the given bounds
  2760. *
  2761. * @param {mat3} out mat3 frustum matrix will be written into
  2762. * @param {number} width Width of your gl context
  2763. * @param {number} height Height of gl context
  2764. * @returns {mat3} out
  2765. */
  2766. function projection(out, width, height) {
  2767. out[0] = 2 / width;
  2768. out[1] = 0;
  2769. out[2] = 0;
  2770. out[3] = 0;
  2771. out[4] = -2 / height;
  2772. out[5] = 0;
  2773. out[6] = -1;
  2774. out[7] = 1;
  2775. out[8] = 1;
  2776. return out;
  2777. }
  2778. /**
  2779. * Returns a string representation of a mat3
  2780. *
  2781. * @param {mat3} a matrix to represent as a string
  2782. * @returns {String} string representation of the matrix
  2783. */
  2784. function str(a) {
  2785. return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')';
  2786. }
  2787. /**
  2788. * Returns Frobenius norm of a mat3
  2789. *
  2790. * @param {mat3} a the matrix to calculate Frobenius norm of
  2791. * @returns {Number} Frobenius norm
  2792. */
  2793. function frob(a) {
  2794. return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2));
  2795. }
  2796. /**
  2797. * Adds two mat3's
  2798. *
  2799. * @param {mat3} out the receiving matrix
  2800. * @param {mat3} a the first operand
  2801. * @param {mat3} b the second operand
  2802. * @returns {mat3} out
  2803. */
  2804. function add(out, a, b) {
  2805. out[0] = a[0] + b[0];
  2806. out[1] = a[1] + b[1];
  2807. out[2] = a[2] + b[2];
  2808. out[3] = a[3] + b[3];
  2809. out[4] = a[4] + b[4];
  2810. out[5] = a[5] + b[5];
  2811. out[6] = a[6] + b[6];
  2812. out[7] = a[7] + b[7];
  2813. out[8] = a[8] + b[8];
  2814. return out;
  2815. }
  2816. /**
  2817. * Subtracts matrix b from matrix a
  2818. *
  2819. * @param {mat3} out the receiving matrix
  2820. * @param {mat3} a the first operand
  2821. * @param {mat3} b the second operand
  2822. * @returns {mat3} out
  2823. */
  2824. function subtract(out, a, b) {
  2825. out[0] = a[0] - b[0];
  2826. out[1] = a[1] - b[1];
  2827. out[2] = a[2] - b[2];
  2828. out[3] = a[3] - b[3];
  2829. out[4] = a[4] - b[4];
  2830. out[5] = a[5] - b[5];
  2831. out[6] = a[6] - b[6];
  2832. out[7] = a[7] - b[7];
  2833. out[8] = a[8] - b[8];
  2834. return out;
  2835. }
  2836. /**
  2837. * Multiply each element of the matrix by a scalar.
  2838. *
  2839. * @param {mat3} out the receiving matrix
  2840. * @param {mat3} a the matrix to scale
  2841. * @param {Number} b amount to scale the matrix's elements by
  2842. * @returns {mat3} out
  2843. */
  2844. function multiplyScalar(out, a, b) {
  2845. out[0] = a[0] * b;
  2846. out[1] = a[1] * b;
  2847. out[2] = a[2] * b;
  2848. out[3] = a[3] * b;
  2849. out[4] = a[4] * b;
  2850. out[5] = a[5] * b;
  2851. out[6] = a[6] * b;
  2852. out[7] = a[7] * b;
  2853. out[8] = a[8] * b;
  2854. return out;
  2855. }
  2856. /**
  2857. * Adds two mat3's after multiplying each element of the second operand by a scalar value.
  2858. *
  2859. * @param {mat3} out the receiving vector
  2860. * @param {mat3} a the first operand
  2861. * @param {mat3} b the second operand
  2862. * @param {Number} scale the amount to scale b's elements by before adding
  2863. * @returns {mat3} out
  2864. */
  2865. function multiplyScalarAndAdd(out, a, b, scale) {
  2866. out[0] = a[0] + b[0] * scale;
  2867. out[1] = a[1] + b[1] * scale;
  2868. out[2] = a[2] + b[2] * scale;
  2869. out[3] = a[3] + b[3] * scale;
  2870. out[4] = a[4] + b[4] * scale;
  2871. out[5] = a[5] + b[5] * scale;
  2872. out[6] = a[6] + b[6] * scale;
  2873. out[7] = a[7] + b[7] * scale;
  2874. out[8] = a[8] + b[8] * scale;
  2875. return out;
  2876. }
  2877. /**
  2878. * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
  2879. *
  2880. * @param {mat3} a The first matrix.
  2881. * @param {mat3} b The second matrix.
  2882. * @returns {Boolean} True if the matrices are equal, false otherwise.
  2883. */
  2884. function exactEquals(a, b) {
  2885. return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
  2886. }
  2887. /**
  2888. * Returns whether or not the matrices have approximately the same elements in the same position.
  2889. *
  2890. * @param {mat3} a The first matrix.
  2891. * @param {mat3} b The second matrix.
  2892. * @returns {Boolean} True if the matrices are equal, false otherwise.
  2893. */
  2894. function equals(a, b) {
  2895. var a0 = a[0],
  2896. a1 = a[1],
  2897. a2 = a[2],
  2898. a3 = a[3],
  2899. a4 = a[4],
  2900. a5 = a[5],
  2901. a6 = a[6],
  2902. a7 = a[7],
  2903. a8 = a[8];
  2904. var b0 = b[0],
  2905. b1 = b[1],
  2906. b2 = b[2],
  2907. b3 = b[3],
  2908. b4 = b[4],
  2909. b5 = b[5],
  2910. b6 = b[6],
  2911. b7 = b[7],
  2912. b8 = b[8];
  2913. return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));
  2914. }
  2915. /**
  2916. * Alias for {@link mat3.multiply}
  2917. * @function
  2918. */
  2919. var mul = exports.mul = multiply;
  2920. /**
  2921. * Alias for {@link mat3.subtract}
  2922. * @function
  2923. */
  2924. var sub = exports.sub = subtract;
  2925. /***/ }),
  2926. /* 90 */
  2927. /***/ (function(module, exports, __webpack_require__) {
  2928. var vec2 = __webpack_require__(91);
  2929. var clamp = __webpack_require__(21);
  2930. vec2.angle = function (v1, v2) {
  2931. var theta = vec2.dot(v1, v2) / (vec2.length(v1) * vec2.length(v2));
  2932. return Math.acos(clamp(theta, -1, 1));
  2933. };
  2934. /**
  2935. * 向量 v1 到 向量 v2 夹角的方向
  2936. * @param {Array} v1 向量
  2937. * @param {Array} v2 向量
  2938. * @return {Boolean} >= 0 顺时针 < 0 逆时针
  2939. */
  2940. vec2.direction = function (v1, v2) {
  2941. return v1[0] * v2[1] - v2[0] * v1[1];
  2942. };
  2943. vec2.angleTo = function (v1, v2, direct) {
  2944. var angle = vec2.angle(v1, v2);
  2945. var angleLargeThanPI = vec2.direction(v1, v2) >= 0;
  2946. if (direct) {
  2947. if (angleLargeThanPI) {
  2948. return Math.PI * 2 - angle;
  2949. }
  2950. return angle;
  2951. }
  2952. if (angleLargeThanPI) {
  2953. return angle;
  2954. }
  2955. return Math.PI * 2 - angle;
  2956. };
  2957. vec2.vertical = function (out, v, flag) {
  2958. if (flag) {
  2959. out[0] = v[1];
  2960. out[1] = -1 * v[0];
  2961. } else {
  2962. out[0] = -1 * v[1];
  2963. out[1] = v[0];
  2964. }
  2965. return out;
  2966. };
  2967. module.exports = vec2;
  2968. /***/ }),
  2969. /* 91 */
  2970. /***/ (function(module, exports, __webpack_require__) {
  2971. Object.defineProperty(exports, "__esModule", {
  2972. value: true
  2973. });
  2974. exports.forEach = exports.sqrLen = exports.sqrDist = exports.dist = exports.div = exports.mul = exports.sub = exports.len = undefined;
  2975. exports.create = create;
  2976. exports.clone = clone;
  2977. exports.fromValues = fromValues;
  2978. exports.copy = copy;
  2979. exports.set = set;
  2980. exports.add = add;
  2981. exports.subtract = subtract;
  2982. exports.multiply = multiply;
  2983. exports.divide = divide;
  2984. exports.ceil = ceil;
  2985. exports.floor = floor;
  2986. exports.min = min;
  2987. exports.max = max;
  2988. exports.round = round;
  2989. exports.scale = scale;
  2990. exports.scaleAndAdd = scaleAndAdd;
  2991. exports.distance = distance;
  2992. exports.squaredDistance = squaredDistance;
  2993. exports.length = length;
  2994. exports.squaredLength = squaredLength;
  2995. exports.negate = negate;
  2996. exports.inverse = inverse;
  2997. exports.normalize = normalize;
  2998. exports.dot = dot;
  2999. exports.cross = cross;
  3000. exports.lerp = lerp;
  3001. exports.random = random;
  3002. exports.transformMat2 = transformMat2;
  3003. exports.transformMat2d = transformMat2d;
  3004. exports.transformMat3 = transformMat3;
  3005. exports.transformMat4 = transformMat4;
  3006. exports.rotate = rotate;
  3007. exports.angle = angle;
  3008. exports.str = str;
  3009. exports.exactEquals = exactEquals;
  3010. exports.equals = equals;
  3011. var _common = __webpack_require__(15);
  3012. var glMatrix = _interopRequireWildcard(_common);
  3013. function _interopRequireWildcard(obj) {
  3014. if (obj && obj.__esModule) {
  3015. return obj;
  3016. } else {
  3017. var newObj = {};if (obj != null) {
  3018. for (var key in obj) {
  3019. if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
  3020. }
  3021. }newObj.default = obj;return newObj;
  3022. }
  3023. }
  3024. /**
  3025. * 2 Dimensional Vector
  3026. * @module vec2
  3027. */
  3028. /**
  3029. * Creates a new, empty vec2
  3030. *
  3031. * @returns {vec2} a new 2D vector
  3032. */
  3033. function create() {
  3034. var out = new glMatrix.ARRAY_TYPE(2);
  3035. if (glMatrix.ARRAY_TYPE != Float32Array) {
  3036. out[0] = 0;
  3037. out[1] = 0;
  3038. }
  3039. return out;
  3040. }
  3041. /**
  3042. * Creates a new vec2 initialized with values from an existing vector
  3043. *
  3044. * @param {vec2} a vector to clone
  3045. * @returns {vec2} a new 2D vector
  3046. */
  3047. function clone(a) {
  3048. var out = new glMatrix.ARRAY_TYPE(2);
  3049. out[0] = a[0];
  3050. out[1] = a[1];
  3051. return out;
  3052. }
  3053. /**
  3054. * Creates a new vec2 initialized with the given values
  3055. *
  3056. * @param {Number} x X component
  3057. * @param {Number} y Y component
  3058. * @returns {vec2} a new 2D vector
  3059. */
  3060. function fromValues(x, y) {
  3061. var out = new glMatrix.ARRAY_TYPE(2);
  3062. out[0] = x;
  3063. out[1] = y;
  3064. return out;
  3065. }
  3066. /**
  3067. * Copy the values from one vec2 to another
  3068. *
  3069. * @param {vec2} out the receiving vector
  3070. * @param {vec2} a the source vector
  3071. * @returns {vec2} out
  3072. */
  3073. function copy(out, a) {
  3074. out[0] = a[0];
  3075. out[1] = a[1];
  3076. return out;
  3077. }
  3078. /**
  3079. * Set the components of a vec2 to the given values
  3080. *
  3081. * @param {vec2} out the receiving vector
  3082. * @param {Number} x X component
  3083. * @param {Number} y Y component
  3084. * @returns {vec2} out
  3085. */
  3086. function set(out, x, y) {
  3087. out[0] = x;
  3088. out[1] = y;
  3089. return out;
  3090. }
  3091. /**
  3092. * Adds two vec2's
  3093. *
  3094. * @param {vec2} out the receiving vector
  3095. * @param {vec2} a the first operand
  3096. * @param {vec2} b the second operand
  3097. * @returns {vec2} out
  3098. */
  3099. function add(out, a, b) {
  3100. out[0] = a[0] + b[0];
  3101. out[1] = a[1] + b[1];
  3102. return out;
  3103. }
  3104. /**
  3105. * Subtracts vector b from vector a
  3106. *
  3107. * @param {vec2} out the receiving vector
  3108. * @param {vec2} a the first operand
  3109. * @param {vec2} b the second operand
  3110. * @returns {vec2} out
  3111. */
  3112. function subtract(out, a, b) {
  3113. out[0] = a[0] - b[0];
  3114. out[1] = a[1] - b[1];
  3115. return out;
  3116. }
  3117. /**
  3118. * Multiplies two vec2's
  3119. *
  3120. * @param {vec2} out the receiving vector
  3121. * @param {vec2} a the first operand
  3122. * @param {vec2} b the second operand
  3123. * @returns {vec2} out
  3124. */
  3125. function multiply(out, a, b) {
  3126. out[0] = a[0] * b[0];
  3127. out[1] = a[1] * b[1];
  3128. return out;
  3129. }
  3130. /**
  3131. * Divides two vec2's
  3132. *
  3133. * @param {vec2} out the receiving vector
  3134. * @param {vec2} a the first operand
  3135. * @param {vec2} b the second operand
  3136. * @returns {vec2} out
  3137. */
  3138. function divide(out, a, b) {
  3139. out[0] = a[0] / b[0];
  3140. out[1] = a[1] / b[1];
  3141. return out;
  3142. }
  3143. /**
  3144. * Math.ceil the components of a vec2
  3145. *
  3146. * @param {vec2} out the receiving vector
  3147. * @param {vec2} a vector to ceil
  3148. * @returns {vec2} out
  3149. */
  3150. function ceil(out, a) {
  3151. out[0] = Math.ceil(a[0]);
  3152. out[1] = Math.ceil(a[1]);
  3153. return out;
  3154. }
  3155. /**
  3156. * Math.floor the components of a vec2
  3157. *
  3158. * @param {vec2} out the receiving vector
  3159. * @param {vec2} a vector to floor
  3160. * @returns {vec2} out
  3161. */
  3162. function floor(out, a) {
  3163. out[0] = Math.floor(a[0]);
  3164. out[1] = Math.floor(a[1]);
  3165. return out;
  3166. }
  3167. /**
  3168. * Returns the minimum of two vec2's
  3169. *
  3170. * @param {vec2} out the receiving vector
  3171. * @param {vec2} a the first operand
  3172. * @param {vec2} b the second operand
  3173. * @returns {vec2} out
  3174. */
  3175. function min(out, a, b) {
  3176. out[0] = Math.min(a[0], b[0]);
  3177. out[1] = Math.min(a[1], b[1]);
  3178. return out;
  3179. }
  3180. /**
  3181. * Returns the maximum of two vec2's
  3182. *
  3183. * @param {vec2} out the receiving vector
  3184. * @param {vec2} a the first operand
  3185. * @param {vec2} b the second operand
  3186. * @returns {vec2} out
  3187. */
  3188. function max(out, a, b) {
  3189. out[0] = Math.max(a[0], b[0]);
  3190. out[1] = Math.max(a[1], b[1]);
  3191. return out;
  3192. }
  3193. /**
  3194. * Math.round the components of a vec2
  3195. *
  3196. * @param {vec2} out the receiving vector
  3197. * @param {vec2} a vector to round
  3198. * @returns {vec2} out
  3199. */
  3200. function round(out, a) {
  3201. out[0] = Math.round(a[0]);
  3202. out[1] = Math.round(a[1]);
  3203. return out;
  3204. }
  3205. /**
  3206. * Scales a vec2 by a scalar number
  3207. *
  3208. * @param {vec2} out the receiving vector
  3209. * @param {vec2} a the vector to scale
  3210. * @param {Number} b amount to scale the vector by
  3211. * @returns {vec2} out
  3212. */
  3213. function scale(out, a, b) {
  3214. out[0] = a[0] * b;
  3215. out[1] = a[1] * b;
  3216. return out;
  3217. }
  3218. /**
  3219. * Adds two vec2's after scaling the second operand by a scalar value
  3220. *
  3221. * @param {vec2} out the receiving vector
  3222. * @param {vec2} a the first operand
  3223. * @param {vec2} b the second operand
  3224. * @param {Number} scale the amount to scale b by before adding
  3225. * @returns {vec2} out
  3226. */
  3227. function scaleAndAdd(out, a, b, scale) {
  3228. out[0] = a[0] + b[0] * scale;
  3229. out[1] = a[1] + b[1] * scale;
  3230. return out;
  3231. }
  3232. /**
  3233. * Calculates the euclidian distance between two vec2's
  3234. *
  3235. * @param {vec2} a the first operand
  3236. * @param {vec2} b the second operand
  3237. * @returns {Number} distance between a and b
  3238. */
  3239. function distance(a, b) {
  3240. var x = b[0] - a[0],
  3241. y = b[1] - a[1];
  3242. return Math.sqrt(x * x + y * y);
  3243. }
  3244. /**
  3245. * Calculates the squared euclidian distance between two vec2's
  3246. *
  3247. * @param {vec2} a the first operand
  3248. * @param {vec2} b the second operand
  3249. * @returns {Number} squared distance between a and b
  3250. */
  3251. function squaredDistance(a, b) {
  3252. var x = b[0] - a[0],
  3253. y = b[1] - a[1];
  3254. return x * x + y * y;
  3255. }
  3256. /**
  3257. * Calculates the length of a vec2
  3258. *
  3259. * @param {vec2} a vector to calculate length of
  3260. * @returns {Number} length of a
  3261. */
  3262. function length(a) {
  3263. var x = a[0],
  3264. y = a[1];
  3265. return Math.sqrt(x * x + y * y);
  3266. }
  3267. /**
  3268. * Calculates the squared length of a vec2
  3269. *
  3270. * @param {vec2} a vector to calculate squared length of
  3271. * @returns {Number} squared length of a
  3272. */
  3273. function squaredLength(a) {
  3274. var x = a[0],
  3275. y = a[1];
  3276. return x * x + y * y;
  3277. }
  3278. /**
  3279. * Negates the components of a vec2
  3280. *
  3281. * @param {vec2} out the receiving vector
  3282. * @param {vec2} a vector to negate
  3283. * @returns {vec2} out
  3284. */
  3285. function negate(out, a) {
  3286. out[0] = -a[0];
  3287. out[1] = -a[1];
  3288. return out;
  3289. }
  3290. /**
  3291. * Returns the inverse of the components of a vec2
  3292. *
  3293. * @param {vec2} out the receiving vector
  3294. * @param {vec2} a vector to invert
  3295. * @returns {vec2} out
  3296. */
  3297. function inverse(out, a) {
  3298. out[0] = 1.0 / a[0];
  3299. out[1] = 1.0 / a[1];
  3300. return out;
  3301. }
  3302. /**
  3303. * Normalize a vec2
  3304. *
  3305. * @param {vec2} out the receiving vector
  3306. * @param {vec2} a vector to normalize
  3307. * @returns {vec2} out
  3308. */
  3309. function normalize(out, a) {
  3310. var x = a[0],
  3311. y = a[1];
  3312. var len = x * x + y * y;
  3313. if (len > 0) {
  3314. //TODO: evaluate use of glm_invsqrt here?
  3315. len = 1 / Math.sqrt(len);
  3316. out[0] = a[0] * len;
  3317. out[1] = a[1] * len;
  3318. }
  3319. return out;
  3320. }
  3321. /**
  3322. * Calculates the dot product of two vec2's
  3323. *
  3324. * @param {vec2} a the first operand
  3325. * @param {vec2} b the second operand
  3326. * @returns {Number} dot product of a and b
  3327. */
  3328. function dot(a, b) {
  3329. return a[0] * b[0] + a[1] * b[1];
  3330. }
  3331. /**
  3332. * Computes the cross product of two vec2's
  3333. * Note that the cross product must by definition produce a 3D vector
  3334. *
  3335. * @param {vec3} out the receiving vector
  3336. * @param {vec2} a the first operand
  3337. * @param {vec2} b the second operand
  3338. * @returns {vec3} out
  3339. */
  3340. function cross(out, a, b) {
  3341. var z = a[0] * b[1] - a[1] * b[0];
  3342. out[0] = out[1] = 0;
  3343. out[2] = z;
  3344. return out;
  3345. }
  3346. /**
  3347. * Performs a linear interpolation between two vec2's
  3348. *
  3349. * @param {vec2} out the receiving vector
  3350. * @param {vec2} a the first operand
  3351. * @param {vec2} b the second operand
  3352. * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
  3353. * @returns {vec2} out
  3354. */
  3355. function lerp(out, a, b, t) {
  3356. var ax = a[0],
  3357. ay = a[1];
  3358. out[0] = ax + t * (b[0] - ax);
  3359. out[1] = ay + t * (b[1] - ay);
  3360. return out;
  3361. }
  3362. /**
  3363. * Generates a random vector with the given scale
  3364. *
  3365. * @param {vec2} out the receiving vector
  3366. * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
  3367. * @returns {vec2} out
  3368. */
  3369. function random(out, scale) {
  3370. scale = scale || 1.0;
  3371. var r = glMatrix.RANDOM() * 2.0 * Math.PI;
  3372. out[0] = Math.cos(r) * scale;
  3373. out[1] = Math.sin(r) * scale;
  3374. return out;
  3375. }
  3376. /**
  3377. * Transforms the vec2 with a mat2
  3378. *
  3379. * @param {vec2} out the receiving vector
  3380. * @param {vec2} a the vector to transform
  3381. * @param {mat2} m matrix to transform with
  3382. * @returns {vec2} out
  3383. */
  3384. function transformMat2(out, a, m) {
  3385. var x = a[0],
  3386. y = a[1];
  3387. out[0] = m[0] * x + m[2] * y;
  3388. out[1] = m[1] * x + m[3] * y;
  3389. return out;
  3390. }
  3391. /**
  3392. * Transforms the vec2 with a mat2d
  3393. *
  3394. * @param {vec2} out the receiving vector
  3395. * @param {vec2} a the vector to transform
  3396. * @param {mat2d} m matrix to transform with
  3397. * @returns {vec2} out
  3398. */
  3399. function transformMat2d(out, a, m) {
  3400. var x = a[0],
  3401. y = a[1];
  3402. out[0] = m[0] * x + m[2] * y + m[4];
  3403. out[1] = m[1] * x + m[3] * y + m[5];
  3404. return out;
  3405. }
  3406. /**
  3407. * Transforms the vec2 with a mat3
  3408. * 3rd vector component is implicitly '1'
  3409. *
  3410. * @param {vec2} out the receiving vector
  3411. * @param {vec2} a the vector to transform
  3412. * @param {mat3} m matrix to transform with
  3413. * @returns {vec2} out
  3414. */
  3415. function transformMat3(out, a, m) {
  3416. var x = a[0],
  3417. y = a[1];
  3418. out[0] = m[0] * x + m[3] * y + m[6];
  3419. out[1] = m[1] * x + m[4] * y + m[7];
  3420. return out;
  3421. }
  3422. /**
  3423. * Transforms the vec2 with a mat4
  3424. * 3rd vector component is implicitly '0'
  3425. * 4th vector component is implicitly '1'
  3426. *
  3427. * @param {vec2} out the receiving vector
  3428. * @param {vec2} a the vector to transform
  3429. * @param {mat4} m matrix to transform with
  3430. * @returns {vec2} out
  3431. */
  3432. function transformMat4(out, a, m) {
  3433. var x = a[0];
  3434. var y = a[1];
  3435. out[0] = m[0] * x + m[4] * y + m[12];
  3436. out[1] = m[1] * x + m[5] * y + m[13];
  3437. return out;
  3438. }
  3439. /**
  3440. * Rotate a 2D vector
  3441. * @param {vec2} out The receiving vec2
  3442. * @param {vec2} a The vec2 point to rotate
  3443. * @param {vec2} b The origin of the rotation
  3444. * @param {Number} c The angle of rotation
  3445. * @returns {vec2} out
  3446. */
  3447. function rotate(out, a, b, c) {
  3448. //Translate point to the origin
  3449. var p0 = a[0] - b[0],
  3450. p1 = a[1] - b[1],
  3451. sinC = Math.sin(c),
  3452. cosC = Math.cos(c);
  3453. //perform rotation and translate to correct position
  3454. out[0] = p0 * cosC - p1 * sinC + b[0];
  3455. out[1] = p0 * sinC + p1 * cosC + b[1];
  3456. return out;
  3457. }
  3458. /**
  3459. * Get the angle between two 2D vectors
  3460. * @param {vec2} a The first operand
  3461. * @param {vec2} b The second operand
  3462. * @returns {Number} The angle in radians
  3463. */
  3464. function angle(a, b) {
  3465. var x1 = a[0],
  3466. y1 = a[1],
  3467. x2 = b[0],
  3468. y2 = b[1];
  3469. var len1 = x1 * x1 + y1 * y1;
  3470. if (len1 > 0) {
  3471. //TODO: evaluate use of glm_invsqrt here?
  3472. len1 = 1 / Math.sqrt(len1);
  3473. }
  3474. var len2 = x2 * x2 + y2 * y2;
  3475. if (len2 > 0) {
  3476. //TODO: evaluate use of glm_invsqrt here?
  3477. len2 = 1 / Math.sqrt(len2);
  3478. }
  3479. var cosine = (x1 * x2 + y1 * y2) * len1 * len2;
  3480. if (cosine > 1.0) {
  3481. return 0;
  3482. } else if (cosine < -1.0) {
  3483. return Math.PI;
  3484. } else {
  3485. return Math.acos(cosine);
  3486. }
  3487. }
  3488. /**
  3489. * Returns a string representation of a vector
  3490. *
  3491. * @param {vec2} a vector to represent as a string
  3492. * @returns {String} string representation of the vector
  3493. */
  3494. function str(a) {
  3495. return 'vec2(' + a[0] + ', ' + a[1] + ')';
  3496. }
  3497. /**
  3498. * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
  3499. *
  3500. * @param {vec2} a The first vector.
  3501. * @param {vec2} b The second vector.
  3502. * @returns {Boolean} True if the vectors are equal, false otherwise.
  3503. */
  3504. function exactEquals(a, b) {
  3505. return a[0] === b[0] && a[1] === b[1];
  3506. }
  3507. /**
  3508. * Returns whether or not the vectors have approximately the same elements in the same position.
  3509. *
  3510. * @param {vec2} a The first vector.
  3511. * @param {vec2} b The second vector.
  3512. * @returns {Boolean} True if the vectors are equal, false otherwise.
  3513. */
  3514. function equals(a, b) {
  3515. var a0 = a[0],
  3516. a1 = a[1];
  3517. var b0 = b[0],
  3518. b1 = b[1];
  3519. return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1));
  3520. }
  3521. /**
  3522. * Alias for {@link vec2.length}
  3523. * @function
  3524. */
  3525. var len = exports.len = length;
  3526. /**
  3527. * Alias for {@link vec2.subtract}
  3528. * @function
  3529. */
  3530. var sub = exports.sub = subtract;
  3531. /**
  3532. * Alias for {@link vec2.multiply}
  3533. * @function
  3534. */
  3535. var mul = exports.mul = multiply;
  3536. /**
  3537. * Alias for {@link vec2.divide}
  3538. * @function
  3539. */
  3540. var div = exports.div = divide;
  3541. /**
  3542. * Alias for {@link vec2.distance}
  3543. * @function
  3544. */
  3545. var dist = exports.dist = distance;
  3546. /**
  3547. * Alias for {@link vec2.squaredDistance}
  3548. * @function
  3549. */
  3550. var sqrDist = exports.sqrDist = squaredDistance;
  3551. /**
  3552. * Alias for {@link vec2.squaredLength}
  3553. * @function
  3554. */
  3555. var sqrLen = exports.sqrLen = squaredLength;
  3556. /**
  3557. * Perform some operation over an array of vec2s.
  3558. *
  3559. * @param {Array} a the array of vectors to iterate over
  3560. * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
  3561. * @param {Number} offset Number of elements to skip at the beginning of the array
  3562. * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
  3563. * @param {Function} fn Function to call for each vector in the array
  3564. * @param {Object} [arg] additional argument to pass to fn
  3565. * @returns {Array} a
  3566. * @function
  3567. */
  3568. var forEach = exports.forEach = function () {
  3569. var vec = create();
  3570. return function (a, stride, offset, count, fn, arg) {
  3571. var i = void 0,
  3572. l = void 0;
  3573. if (!stride) {
  3574. stride = 2;
  3575. }
  3576. if (!offset) {
  3577. offset = 0;
  3578. }
  3579. if (count) {
  3580. l = Math.min(count * stride + offset, a.length);
  3581. } else {
  3582. l = a.length;
  3583. }
  3584. for (i = offset; i < l; i += stride) {
  3585. vec[0] = a[i];vec[1] = a[i + 1];
  3586. fn(vec, vec, arg);
  3587. a[i] = vec[0];a[i + 1] = vec[1];
  3588. }
  3589. return a;
  3590. };
  3591. }();
  3592. /***/ }),
  3593. /* 92 */
  3594. /***/ (function(module, exports, __webpack_require__) {
  3595. var vec3 = __webpack_require__(93);
  3596. module.exports = vec3;
  3597. /***/ }),
  3598. /* 93 */
  3599. /***/ (function(module, exports, __webpack_require__) {
  3600. Object.defineProperty(exports, "__esModule", {
  3601. value: true
  3602. });
  3603. exports.forEach = exports.sqrLen = exports.len = exports.sqrDist = exports.dist = exports.div = exports.mul = exports.sub = undefined;
  3604. exports.create = create;
  3605. exports.clone = clone;
  3606. exports.length = length;
  3607. exports.fromValues = fromValues;
  3608. exports.copy = copy;
  3609. exports.set = set;
  3610. exports.add = add;
  3611. exports.subtract = subtract;
  3612. exports.multiply = multiply;
  3613. exports.divide = divide;
  3614. exports.ceil = ceil;
  3615. exports.floor = floor;
  3616. exports.min = min;
  3617. exports.max = max;
  3618. exports.round = round;
  3619. exports.scale = scale;
  3620. exports.scaleAndAdd = scaleAndAdd;
  3621. exports.distance = distance;
  3622. exports.squaredDistance = squaredDistance;
  3623. exports.squaredLength = squaredLength;
  3624. exports.negate = negate;
  3625. exports.inverse = inverse;
  3626. exports.normalize = normalize;
  3627. exports.dot = dot;
  3628. exports.cross = cross;
  3629. exports.lerp = lerp;
  3630. exports.hermite = hermite;
  3631. exports.bezier = bezier;
  3632. exports.random = random;
  3633. exports.transformMat4 = transformMat4;
  3634. exports.transformMat3 = transformMat3;
  3635. exports.transformQuat = transformQuat;
  3636. exports.rotateX = rotateX;
  3637. exports.rotateY = rotateY;
  3638. exports.rotateZ = rotateZ;
  3639. exports.angle = angle;
  3640. exports.str = str;
  3641. exports.exactEquals = exactEquals;
  3642. exports.equals = equals;
  3643. var _common = __webpack_require__(15);
  3644. var glMatrix = _interopRequireWildcard(_common);
  3645. function _interopRequireWildcard(obj) {
  3646. if (obj && obj.__esModule) {
  3647. return obj;
  3648. } else {
  3649. var newObj = {};if (obj != null) {
  3650. for (var key in obj) {
  3651. if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
  3652. }
  3653. }newObj.default = obj;return newObj;
  3654. }
  3655. }
  3656. /**
  3657. * 3 Dimensional Vector
  3658. * @module vec3
  3659. */
  3660. /**
  3661. * Creates a new, empty vec3
  3662. *
  3663. * @returns {vec3} a new 3D vector
  3664. */
  3665. function create() {
  3666. var out = new glMatrix.ARRAY_TYPE(3);
  3667. if (glMatrix.ARRAY_TYPE != Float32Array) {
  3668. out[0] = 0;
  3669. out[1] = 0;
  3670. out[2] = 0;
  3671. }
  3672. return out;
  3673. }
  3674. /**
  3675. * Creates a new vec3 initialized with values from an existing vector
  3676. *
  3677. * @param {vec3} a vector to clone
  3678. * @returns {vec3} a new 3D vector
  3679. */
  3680. function clone(a) {
  3681. var out = new glMatrix.ARRAY_TYPE(3);
  3682. out[0] = a[0];
  3683. out[1] = a[1];
  3684. out[2] = a[2];
  3685. return out;
  3686. }
  3687. /**
  3688. * Calculates the length of a vec3
  3689. *
  3690. * @param {vec3} a vector to calculate length of
  3691. * @returns {Number} length of a
  3692. */
  3693. function length(a) {
  3694. var x = a[0];
  3695. var y = a[1];
  3696. var z = a[2];
  3697. return Math.sqrt(x * x + y * y + z * z);
  3698. }
  3699. /**
  3700. * Creates a new vec3 initialized with the given values
  3701. *
  3702. * @param {Number} x X component
  3703. * @param {Number} y Y component
  3704. * @param {Number} z Z component
  3705. * @returns {vec3} a new 3D vector
  3706. */
  3707. function fromValues(x, y, z) {
  3708. var out = new glMatrix.ARRAY_TYPE(3);
  3709. out[0] = x;
  3710. out[1] = y;
  3711. out[2] = z;
  3712. return out;
  3713. }
  3714. /**
  3715. * Copy the values from one vec3 to another
  3716. *
  3717. * @param {vec3} out the receiving vector
  3718. * @param {vec3} a the source vector
  3719. * @returns {vec3} out
  3720. */
  3721. function copy(out, a) {
  3722. out[0] = a[0];
  3723. out[1] = a[1];
  3724. out[2] = a[2];
  3725. return out;
  3726. }
  3727. /**
  3728. * Set the components of a vec3 to the given values
  3729. *
  3730. * @param {vec3} out the receiving vector
  3731. * @param {Number} x X component
  3732. * @param {Number} y Y component
  3733. * @param {Number} z Z component
  3734. * @returns {vec3} out
  3735. */
  3736. function set(out, x, y, z) {
  3737. out[0] = x;
  3738. out[1] = y;
  3739. out[2] = z;
  3740. return out;
  3741. }
  3742. /**
  3743. * Adds two vec3's
  3744. *
  3745. * @param {vec3} out the receiving vector
  3746. * @param {vec3} a the first operand
  3747. * @param {vec3} b the second operand
  3748. * @returns {vec3} out
  3749. */
  3750. function add(out, a, b) {
  3751. out[0] = a[0] + b[0];
  3752. out[1] = a[1] + b[1];
  3753. out[2] = a[2] + b[2];
  3754. return out;
  3755. }
  3756. /**
  3757. * Subtracts vector b from vector a
  3758. *
  3759. * @param {vec3} out the receiving vector
  3760. * @param {vec3} a the first operand
  3761. * @param {vec3} b the second operand
  3762. * @returns {vec3} out
  3763. */
  3764. function subtract(out, a, b) {
  3765. out[0] = a[0] - b[0];
  3766. out[1] = a[1] - b[1];
  3767. out[2] = a[2] - b[2];
  3768. return out;
  3769. }
  3770. /**
  3771. * Multiplies two vec3's
  3772. *
  3773. * @param {vec3} out the receiving vector
  3774. * @param {vec3} a the first operand
  3775. * @param {vec3} b the second operand
  3776. * @returns {vec3} out
  3777. */
  3778. function multiply(out, a, b) {
  3779. out[0] = a[0] * b[0];
  3780. out[1] = a[1] * b[1];
  3781. out[2] = a[2] * b[2];
  3782. return out;
  3783. }
  3784. /**
  3785. * Divides two vec3's
  3786. *
  3787. * @param {vec3} out the receiving vector
  3788. * @param {vec3} a the first operand
  3789. * @param {vec3} b the second operand
  3790. * @returns {vec3} out
  3791. */
  3792. function divide(out, a, b) {
  3793. out[0] = a[0] / b[0];
  3794. out[1] = a[1] / b[1];
  3795. out[2] = a[2] / b[2];
  3796. return out;
  3797. }
  3798. /**
  3799. * Math.ceil the components of a vec3
  3800. *
  3801. * @param {vec3} out the receiving vector
  3802. * @param {vec3} a vector to ceil
  3803. * @returns {vec3} out
  3804. */
  3805. function ceil(out, a) {
  3806. out[0] = Math.ceil(a[0]);
  3807. out[1] = Math.ceil(a[1]);
  3808. out[2] = Math.ceil(a[2]);
  3809. return out;
  3810. }
  3811. /**
  3812. * Math.floor the components of a vec3
  3813. *
  3814. * @param {vec3} out the receiving vector
  3815. * @param {vec3} a vector to floor
  3816. * @returns {vec3} out
  3817. */
  3818. function floor(out, a) {
  3819. out[0] = Math.floor(a[0]);
  3820. out[1] = Math.floor(a[1]);
  3821. out[2] = Math.floor(a[2]);
  3822. return out;
  3823. }
  3824. /**
  3825. * Returns the minimum of two vec3's
  3826. *
  3827. * @param {vec3} out the receiving vector
  3828. * @param {vec3} a the first operand
  3829. * @param {vec3} b the second operand
  3830. * @returns {vec3} out
  3831. */
  3832. function min(out, a, b) {
  3833. out[0] = Math.min(a[0], b[0]);
  3834. out[1] = Math.min(a[1], b[1]);
  3835. out[2] = Math.min(a[2], b[2]);
  3836. return out;
  3837. }
  3838. /**
  3839. * Returns the maximum of two vec3's
  3840. *
  3841. * @param {vec3} out the receiving vector
  3842. * @param {vec3} a the first operand
  3843. * @param {vec3} b the second operand
  3844. * @returns {vec3} out
  3845. */
  3846. function max(out, a, b) {
  3847. out[0] = Math.max(a[0], b[0]);
  3848. out[1] = Math.max(a[1], b[1]);
  3849. out[2] = Math.max(a[2], b[2]);
  3850. return out;
  3851. }
  3852. /**
  3853. * Math.round the components of a vec3
  3854. *
  3855. * @param {vec3} out the receiving vector
  3856. * @param {vec3} a vector to round
  3857. * @returns {vec3} out
  3858. */
  3859. function round(out, a) {
  3860. out[0] = Math.round(a[0]);
  3861. out[1] = Math.round(a[1]);
  3862. out[2] = Math.round(a[2]);
  3863. return out;
  3864. }
  3865. /**
  3866. * Scales a vec3 by a scalar number
  3867. *
  3868. * @param {vec3} out the receiving vector
  3869. * @param {vec3} a the vector to scale
  3870. * @param {Number} b amount to scale the vector by
  3871. * @returns {vec3} out
  3872. */
  3873. function scale(out, a, b) {
  3874. out[0] = a[0] * b;
  3875. out[1] = a[1] * b;
  3876. out[2] = a[2] * b;
  3877. return out;
  3878. }
  3879. /**
  3880. * Adds two vec3's after scaling the second operand by a scalar value
  3881. *
  3882. * @param {vec3} out the receiving vector
  3883. * @param {vec3} a the first operand
  3884. * @param {vec3} b the second operand
  3885. * @param {Number} scale the amount to scale b by before adding
  3886. * @returns {vec3} out
  3887. */
  3888. function scaleAndAdd(out, a, b, scale) {
  3889. out[0] = a[0] + b[0] * scale;
  3890. out[1] = a[1] + b[1] * scale;
  3891. out[2] = a[2] + b[2] * scale;
  3892. return out;
  3893. }
  3894. /**
  3895. * Calculates the euclidian distance between two vec3's
  3896. *
  3897. * @param {vec3} a the first operand
  3898. * @param {vec3} b the second operand
  3899. * @returns {Number} distance between a and b
  3900. */
  3901. function distance(a, b) {
  3902. var x = b[0] - a[0];
  3903. var y = b[1] - a[1];
  3904. var z = b[2] - a[2];
  3905. return Math.sqrt(x * x + y * y + z * z);
  3906. }
  3907. /**
  3908. * Calculates the squared euclidian distance between two vec3's
  3909. *
  3910. * @param {vec3} a the first operand
  3911. * @param {vec3} b the second operand
  3912. * @returns {Number} squared distance between a and b
  3913. */
  3914. function squaredDistance(a, b) {
  3915. var x = b[0] - a[0];
  3916. var y = b[1] - a[1];
  3917. var z = b[2] - a[2];
  3918. return x * x + y * y + z * z;
  3919. }
  3920. /**
  3921. * Calculates the squared length of a vec3
  3922. *
  3923. * @param {vec3} a vector to calculate squared length of
  3924. * @returns {Number} squared length of a
  3925. */
  3926. function squaredLength(a) {
  3927. var x = a[0];
  3928. var y = a[1];
  3929. var z = a[2];
  3930. return x * x + y * y + z * z;
  3931. }
  3932. /**
  3933. * Negates the components of a vec3
  3934. *
  3935. * @param {vec3} out the receiving vector
  3936. * @param {vec3} a vector to negate
  3937. * @returns {vec3} out
  3938. */
  3939. function negate(out, a) {
  3940. out[0] = -a[0];
  3941. out[1] = -a[1];
  3942. out[2] = -a[2];
  3943. return out;
  3944. }
  3945. /**
  3946. * Returns the inverse of the components of a vec3
  3947. *
  3948. * @param {vec3} out the receiving vector
  3949. * @param {vec3} a vector to invert
  3950. * @returns {vec3} out
  3951. */
  3952. function inverse(out, a) {
  3953. out[0] = 1.0 / a[0];
  3954. out[1] = 1.0 / a[1];
  3955. out[2] = 1.0 / a[2];
  3956. return out;
  3957. }
  3958. /**
  3959. * Normalize a vec3
  3960. *
  3961. * @param {vec3} out the receiving vector
  3962. * @param {vec3} a vector to normalize
  3963. * @returns {vec3} out
  3964. */
  3965. function normalize(out, a) {
  3966. var x = a[0];
  3967. var y = a[1];
  3968. var z = a[2];
  3969. var len = x * x + y * y + z * z;
  3970. if (len > 0) {
  3971. //TODO: evaluate use of glm_invsqrt here?
  3972. len = 1 / Math.sqrt(len);
  3973. out[0] = a[0] * len;
  3974. out[1] = a[1] * len;
  3975. out[2] = a[2] * len;
  3976. }
  3977. return out;
  3978. }
  3979. /**
  3980. * Calculates the dot product of two vec3's
  3981. *
  3982. * @param {vec3} a the first operand
  3983. * @param {vec3} b the second operand
  3984. * @returns {Number} dot product of a and b
  3985. */
  3986. function dot(a, b) {
  3987. return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  3988. }
  3989. /**
  3990. * Computes the cross product of two vec3's
  3991. *
  3992. * @param {vec3} out the receiving vector
  3993. * @param {vec3} a the first operand
  3994. * @param {vec3} b the second operand
  3995. * @returns {vec3} out
  3996. */
  3997. function cross(out, a, b) {
  3998. var ax = a[0],
  3999. ay = a[1],
  4000. az = a[2];
  4001. var bx = b[0],
  4002. by = b[1],
  4003. bz = b[2];
  4004. out[0] = ay * bz - az * by;
  4005. out[1] = az * bx - ax * bz;
  4006. out[2] = ax * by - ay * bx;
  4007. return out;
  4008. }
  4009. /**
  4010. * Performs a linear interpolation between two vec3's
  4011. *
  4012. * @param {vec3} out the receiving vector
  4013. * @param {vec3} a the first operand
  4014. * @param {vec3} b the second operand
  4015. * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
  4016. * @returns {vec3} out
  4017. */
  4018. function lerp(out, a, b, t) {
  4019. var ax = a[0];
  4020. var ay = a[1];
  4021. var az = a[2];
  4022. out[0] = ax + t * (b[0] - ax);
  4023. out[1] = ay + t * (b[1] - ay);
  4024. out[2] = az + t * (b[2] - az);
  4025. return out;
  4026. }
  4027. /**
  4028. * Performs a hermite interpolation with two control points
  4029. *
  4030. * @param {vec3} out the receiving vector
  4031. * @param {vec3} a the first operand
  4032. * @param {vec3} b the second operand
  4033. * @param {vec3} c the third operand
  4034. * @param {vec3} d the fourth operand
  4035. * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
  4036. * @returns {vec3} out
  4037. */
  4038. function hermite(out, a, b, c, d, t) {
  4039. var factorTimes2 = t * t;
  4040. var factor1 = factorTimes2 * (2 * t - 3) + 1;
  4041. var factor2 = factorTimes2 * (t - 2) + t;
  4042. var factor3 = factorTimes2 * (t - 1);
  4043. var factor4 = factorTimes2 * (3 - 2 * t);
  4044. out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
  4045. out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
  4046. out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
  4047. return out;
  4048. }
  4049. /**
  4050. * Performs a bezier interpolation with two control points
  4051. *
  4052. * @param {vec3} out the receiving vector
  4053. * @param {vec3} a the first operand
  4054. * @param {vec3} b the second operand
  4055. * @param {vec3} c the third operand
  4056. * @param {vec3} d the fourth operand
  4057. * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
  4058. * @returns {vec3} out
  4059. */
  4060. function bezier(out, a, b, c, d, t) {
  4061. var inverseFactor = 1 - t;
  4062. var inverseFactorTimesTwo = inverseFactor * inverseFactor;
  4063. var factorTimes2 = t * t;
  4064. var factor1 = inverseFactorTimesTwo * inverseFactor;
  4065. var factor2 = 3 * t * inverseFactorTimesTwo;
  4066. var factor3 = 3 * factorTimes2 * inverseFactor;
  4067. var factor4 = factorTimes2 * t;
  4068. out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
  4069. out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
  4070. out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
  4071. return out;
  4072. }
  4073. /**
  4074. * Generates a random vector with the given scale
  4075. *
  4076. * @param {vec3} out the receiving vector
  4077. * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
  4078. * @returns {vec3} out
  4079. */
  4080. function random(out, scale) {
  4081. scale = scale || 1.0;
  4082. var r = glMatrix.RANDOM() * 2.0 * Math.PI;
  4083. var z = glMatrix.RANDOM() * 2.0 - 1.0;
  4084. var zScale = Math.sqrt(1.0 - z * z) * scale;
  4085. out[0] = Math.cos(r) * zScale;
  4086. out[1] = Math.sin(r) * zScale;
  4087. out[2] = z * scale;
  4088. return out;
  4089. }
  4090. /**
  4091. * Transforms the vec3 with a mat4.
  4092. * 4th vector component is implicitly '1'
  4093. *
  4094. * @param {vec3} out the receiving vector
  4095. * @param {vec3} a the vector to transform
  4096. * @param {mat4} m matrix to transform with
  4097. * @returns {vec3} out
  4098. */
  4099. function transformMat4(out, a, m) {
  4100. var x = a[0],
  4101. y = a[1],
  4102. z = a[2];
  4103. var w = m[3] * x + m[7] * y + m[11] * z + m[15];
  4104. w = w || 1.0;
  4105. out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
  4106. out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
  4107. out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
  4108. return out;
  4109. }
  4110. /**
  4111. * Transforms the vec3 with a mat3.
  4112. *
  4113. * @param {vec3} out the receiving vector
  4114. * @param {vec3} a the vector to transform
  4115. * @param {mat3} m the 3x3 matrix to transform with
  4116. * @returns {vec3} out
  4117. */
  4118. function transformMat3(out, a, m) {
  4119. var x = a[0],
  4120. y = a[1],
  4121. z = a[2];
  4122. out[0] = x * m[0] + y * m[3] + z * m[6];
  4123. out[1] = x * m[1] + y * m[4] + z * m[7];
  4124. out[2] = x * m[2] + y * m[5] + z * m[8];
  4125. return out;
  4126. }
  4127. /**
  4128. * Transforms the vec3 with a quat
  4129. * Can also be used for dual quaternions. (Multiply it with the real part)
  4130. *
  4131. * @param {vec3} out the receiving vector
  4132. * @param {vec3} a the vector to transform
  4133. * @param {quat} q quaternion to transform with
  4134. * @returns {vec3} out
  4135. */
  4136. function transformQuat(out, a, q) {
  4137. // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed
  4138. var qx = q[0],
  4139. qy = q[1],
  4140. qz = q[2],
  4141. qw = q[3];
  4142. var x = a[0],
  4143. y = a[1],
  4144. z = a[2];
  4145. // var qvec = [qx, qy, qz];
  4146. // var uv = vec3.cross([], qvec, a);
  4147. var uvx = qy * z - qz * y,
  4148. uvy = qz * x - qx * z,
  4149. uvz = qx * y - qy * x;
  4150. // var uuv = vec3.cross([], qvec, uv);
  4151. var uuvx = qy * uvz - qz * uvy,
  4152. uuvy = qz * uvx - qx * uvz,
  4153. uuvz = qx * uvy - qy * uvx;
  4154. // vec3.scale(uv, uv, 2 * w);
  4155. var w2 = qw * 2;
  4156. uvx *= w2;
  4157. uvy *= w2;
  4158. uvz *= w2;
  4159. // vec3.scale(uuv, uuv, 2);
  4160. uuvx *= 2;
  4161. uuvy *= 2;
  4162. uuvz *= 2;
  4163. // return vec3.add(out, a, vec3.add(out, uv, uuv));
  4164. out[0] = x + uvx + uuvx;
  4165. out[1] = y + uvy + uuvy;
  4166. out[2] = z + uvz + uuvz;
  4167. return out;
  4168. }
  4169. /**
  4170. * Rotate a 3D vector around the x-axis
  4171. * @param {vec3} out The receiving vec3
  4172. * @param {vec3} a The vec3 point to rotate
  4173. * @param {vec3} b The origin of the rotation
  4174. * @param {Number} c The angle of rotation
  4175. * @returns {vec3} out
  4176. */
  4177. function rotateX(out, a, b, c) {
  4178. var p = [],
  4179. r = [];
  4180. //Translate point to the origin
  4181. p[0] = a[0] - b[0];
  4182. p[1] = a[1] - b[1];
  4183. p[2] = a[2] - b[2];
  4184. //perform rotation
  4185. r[0] = p[0];
  4186. r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
  4187. r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
  4188. //translate to correct position
  4189. out[0] = r[0] + b[0];
  4190. out[1] = r[1] + b[1];
  4191. out[2] = r[2] + b[2];
  4192. return out;
  4193. }
  4194. /**
  4195. * Rotate a 3D vector around the y-axis
  4196. * @param {vec3} out The receiving vec3
  4197. * @param {vec3} a The vec3 point to rotate
  4198. * @param {vec3} b The origin of the rotation
  4199. * @param {Number} c The angle of rotation
  4200. * @returns {vec3} out
  4201. */
  4202. function rotateY(out, a, b, c) {
  4203. var p = [],
  4204. r = [];
  4205. //Translate point to the origin
  4206. p[0] = a[0] - b[0];
  4207. p[1] = a[1] - b[1];
  4208. p[2] = a[2] - b[2];
  4209. //perform rotation
  4210. r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
  4211. r[1] = p[1];
  4212. r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
  4213. //translate to correct position
  4214. out[0] = r[0] + b[0];
  4215. out[1] = r[1] + b[1];
  4216. out[2] = r[2] + b[2];
  4217. return out;
  4218. }
  4219. /**
  4220. * Rotate a 3D vector around the z-axis
  4221. * @param {vec3} out The receiving vec3
  4222. * @param {vec3} a The vec3 point to rotate
  4223. * @param {vec3} b The origin of the rotation
  4224. * @param {Number} c The angle of rotation
  4225. * @returns {vec3} out
  4226. */
  4227. function rotateZ(out, a, b, c) {
  4228. var p = [],
  4229. r = [];
  4230. //Translate point to the origin
  4231. p[0] = a[0] - b[0];
  4232. p[1] = a[1] - b[1];
  4233. p[2] = a[2] - b[2];
  4234. //perform rotation
  4235. r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
  4236. r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
  4237. r[2] = p[2];
  4238. //translate to correct position
  4239. out[0] = r[0] + b[0];
  4240. out[1] = r[1] + b[1];
  4241. out[2] = r[2] + b[2];
  4242. return out;
  4243. }
  4244. /**
  4245. * Get the angle between two 3D vectors
  4246. * @param {vec3} a The first operand
  4247. * @param {vec3} b The second operand
  4248. * @returns {Number} The angle in radians
  4249. */
  4250. function angle(a, b) {
  4251. var tempA = fromValues(a[0], a[1], a[2]);
  4252. var tempB = fromValues(b[0], b[1], b[2]);
  4253. normalize(tempA, tempA);
  4254. normalize(tempB, tempB);
  4255. var cosine = dot(tempA, tempB);
  4256. if (cosine > 1.0) {
  4257. return 0;
  4258. } else if (cosine < -1.0) {
  4259. return Math.PI;
  4260. } else {
  4261. return Math.acos(cosine);
  4262. }
  4263. }
  4264. /**
  4265. * Returns a string representation of a vector
  4266. *
  4267. * @param {vec3} a vector to represent as a string
  4268. * @returns {String} string representation of the vector
  4269. */
  4270. function str(a) {
  4271. return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
  4272. }
  4273. /**
  4274. * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
  4275. *
  4276. * @param {vec3} a The first vector.
  4277. * @param {vec3} b The second vector.
  4278. * @returns {Boolean} True if the vectors are equal, false otherwise.
  4279. */
  4280. function exactEquals(a, b) {
  4281. return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
  4282. }
  4283. /**
  4284. * Returns whether or not the vectors have approximately the same elements in the same position.
  4285. *
  4286. * @param {vec3} a The first vector.
  4287. * @param {vec3} b The second vector.
  4288. * @returns {Boolean} True if the vectors are equal, false otherwise.
  4289. */
  4290. function equals(a, b) {
  4291. var a0 = a[0],
  4292. a1 = a[1],
  4293. a2 = a[2];
  4294. var b0 = b[0],
  4295. b1 = b[1],
  4296. b2 = b[2];
  4297. return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));
  4298. }
  4299. /**
  4300. * Alias for {@link vec3.subtract}
  4301. * @function
  4302. */
  4303. var sub = exports.sub = subtract;
  4304. /**
  4305. * Alias for {@link vec3.multiply}
  4306. * @function
  4307. */
  4308. var mul = exports.mul = multiply;
  4309. /**
  4310. * Alias for {@link vec3.divide}
  4311. * @function
  4312. */
  4313. var div = exports.div = divide;
  4314. /**
  4315. * Alias for {@link vec3.distance}
  4316. * @function
  4317. */
  4318. var dist = exports.dist = distance;
  4319. /**
  4320. * Alias for {@link vec3.squaredDistance}
  4321. * @function
  4322. */
  4323. var sqrDist = exports.sqrDist = squaredDistance;
  4324. /**
  4325. * Alias for {@link vec3.length}
  4326. * @function
  4327. */
  4328. var len = exports.len = length;
  4329. /**
  4330. * Alias for {@link vec3.squaredLength}
  4331. * @function
  4332. */
  4333. var sqrLen = exports.sqrLen = squaredLength;
  4334. /**
  4335. * Perform some operation over an array of vec3s.
  4336. *
  4337. * @param {Array} a the array of vectors to iterate over
  4338. * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
  4339. * @param {Number} offset Number of elements to skip at the beginning of the array
  4340. * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
  4341. * @param {Function} fn Function to call for each vector in the array
  4342. * @param {Object} [arg] additional argument to pass to fn
  4343. * @returns {Array} a
  4344. * @function
  4345. */
  4346. var forEach = exports.forEach = function () {
  4347. var vec = create();
  4348. return function (a, stride, offset, count, fn, arg) {
  4349. var i = void 0,
  4350. l = void 0;
  4351. if (!stride) {
  4352. stride = 3;
  4353. }
  4354. if (!offset) {
  4355. offset = 0;
  4356. }
  4357. if (count) {
  4358. l = Math.min(count * stride + offset, a.length);
  4359. } else {
  4360. l = a.length;
  4361. }
  4362. for (i = offset; i < l; i += stride) {
  4363. vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];
  4364. fn(vec, vec, arg);
  4365. a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];
  4366. }
  4367. return a;
  4368. };
  4369. }();
  4370. /***/ }),
  4371. /* 94 */
  4372. /***/ (function(module, exports, __webpack_require__) {
  4373. var clone = __webpack_require__(24);
  4374. var each = __webpack_require__(0);
  4375. var mat3 = __webpack_require__(23);
  4376. module.exports = function transform(m, ts) {
  4377. m = clone(m);
  4378. each(ts, function (t) {
  4379. switch (t[0]) {
  4380. case 't':
  4381. mat3.translate(m, m, [t[1], t[2]]);
  4382. break;
  4383. case 's':
  4384. mat3.scale(m, m, [t[1], t[2]]);
  4385. break;
  4386. case 'r':
  4387. mat3.rotate(m, m, t[1]);
  4388. break;
  4389. case 'm':
  4390. mat3.multiply(m, m, t[1]);
  4391. break;
  4392. default:
  4393. return false;
  4394. }
  4395. });
  4396. return m;
  4397. };
  4398. /***/ }),
  4399. /* 95 */
  4400. /***/ (function(module, exports, __webpack_require__) {
  4401. module.exports = {
  4402. forIn: __webpack_require__(96),
  4403. has: __webpack_require__(25),
  4404. hasKey: __webpack_require__(97),
  4405. hasValue: __webpack_require__(98),
  4406. keys: __webpack_require__(18),
  4407. isMatch: __webpack_require__(17),
  4408. values: __webpack_require__(26)
  4409. };
  4410. /***/ }),
  4411. /* 96 */
  4412. /***/ (function(module, exports, __webpack_require__) {
  4413. module.exports = __webpack_require__(0);
  4414. /***/ }),
  4415. /* 97 */
  4416. /***/ (function(module, exports, __webpack_require__) {
  4417. module.exports = __webpack_require__(25);
  4418. /***/ }),
  4419. /* 98 */
  4420. /***/ (function(module, exports, __webpack_require__) {
  4421. var contains = __webpack_require__(9);
  4422. var values = __webpack_require__(26);
  4423. module.exports = function (obj, value) {
  4424. return contains(values(obj), value);
  4425. };
  4426. /***/ }),
  4427. /* 99 */
  4428. /***/ (function(module, exports, __webpack_require__) {
  4429. var pathIntersection = __webpack_require__(100);
  4430. var path2absolute = __webpack_require__(30);
  4431. var path2curve = __webpack_require__(29);
  4432. var catmullRom2Bezier = __webpack_require__(32);
  4433. module.exports = {
  4434. catmullRom2Bezier: catmullRom2Bezier,
  4435. catmullRomToBezier: catmullRom2Bezier,
  4436. fillPath: __webpack_require__(101),
  4437. fillPathByDiff: __webpack_require__(102),
  4438. formatPath: __webpack_require__(104),
  4439. intersection: pathIntersection,
  4440. pathIntersection: pathIntersection,
  4441. parsePathArray: __webpack_require__(28),
  4442. parsePathString: __webpack_require__(31),
  4443. pathToAbsolute: path2absolute,
  4444. path2absolute: path2absolute,
  4445. pathTocurve: path2curve,
  4446. path2curve: path2curve,
  4447. rectPath: __webpack_require__(27)
  4448. };
  4449. /***/ }),
  4450. /* 100 */
  4451. /***/ (function(module, exports, __webpack_require__) {
  4452. var isArray = __webpack_require__(1);
  4453. var rectPath = __webpack_require__(27);
  4454. var pathTocurve = __webpack_require__(29);
  4455. var base3 = function base3(t, p1, p2, p3, p4) {
  4456. var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
  4457. var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
  4458. return t * t2 - 3 * p1 + 3 * p2;
  4459. };
  4460. var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
  4461. if (z === null) {
  4462. z = 1;
  4463. }
  4464. z = z > 1 ? 1 : z < 0 ? 0 : z;
  4465. var z2 = z / 2;
  4466. var n = 12;
  4467. var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
  4468. var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
  4469. var sum = 0;
  4470. for (var i = 0; i < n; i++) {
  4471. var ct = z2 * Tvalues[i] + z2;
  4472. var xbase = base3(ct, x1, x2, x3, x4);
  4473. var ybase = base3(ct, y1, y2, y3, y4);
  4474. var comb = xbase * xbase + ybase * ybase;
  4475. sum += Cvalues[i] * Math.sqrt(comb);
  4476. }
  4477. return z2 * sum;
  4478. };
  4479. var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
  4480. var tvalues = [];
  4481. var bounds = [[], []];
  4482. var a = void 0;
  4483. var b = void 0;
  4484. var c = void 0;
  4485. var t = void 0;
  4486. for (var i = 0; i < 2; ++i) {
  4487. if (i === 0) {
  4488. b = 6 * x0 - 12 * x1 + 6 * x2;
  4489. a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
  4490. c = 3 * x1 - 3 * x0;
  4491. } else {
  4492. b = 6 * y0 - 12 * y1 + 6 * y2;
  4493. a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
  4494. c = 3 * y1 - 3 * y0;
  4495. }
  4496. if (Math.abs(a) < 1e-12) {
  4497. if (Math.abs(b) < 1e-12) {
  4498. continue;
  4499. }
  4500. t = -c / b;
  4501. if (t > 0 && t < 1) {
  4502. tvalues.push(t);
  4503. }
  4504. continue;
  4505. }
  4506. var b2ac = b * b - 4 * c * a;
  4507. var sqrtb2ac = Math.sqrt(b2ac);
  4508. if (b2ac < 0) {
  4509. continue;
  4510. }
  4511. var t1 = (-b + sqrtb2ac) / (2 * a);
  4512. if (t1 > 0 && t1 < 1) {
  4513. tvalues.push(t1);
  4514. }
  4515. var t2 = (-b - sqrtb2ac) / (2 * a);
  4516. if (t2 > 0 && t2 < 1) {
  4517. tvalues.push(t2);
  4518. }
  4519. }
  4520. var j = tvalues.length;
  4521. var jlen = j;
  4522. var mt = void 0;
  4523. while (j--) {
  4524. t = tvalues[j];
  4525. mt = 1 - t;
  4526. bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
  4527. bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
  4528. }
  4529. bounds[0][jlen] = x0;
  4530. bounds[1][jlen] = y0;
  4531. bounds[0][jlen + 1] = x3;
  4532. bounds[1][jlen + 1] = y3;
  4533. bounds[0].length = bounds[1].length = jlen + 2;
  4534. return {
  4535. min: {
  4536. x: Math.min.apply(0, bounds[0]),
  4537. y: Math.min.apply(0, bounds[1])
  4538. },
  4539. max: {
  4540. x: Math.max.apply(0, bounds[0]),
  4541. y: Math.max.apply(0, bounds[1])
  4542. }
  4543. };
  4544. };
  4545. var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
  4546. if (Math.max(x1, x2) < Math.min(x3, x4) || Math.min(x1, x2) > Math.max(x3, x4) || Math.max(y1, y2) < Math.min(y3, y4) || Math.min(y1, y2) > Math.max(y3, y4)) {
  4547. return;
  4548. }
  4549. var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
  4550. var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
  4551. var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
  4552. if (!denominator) {
  4553. return;
  4554. }
  4555. var px = nx / denominator;
  4556. var py = ny / denominator;
  4557. var px2 = +px.toFixed(2);
  4558. var py2 = +py.toFixed(2);
  4559. if (px2 < +Math.min(x1, x2).toFixed(2) || px2 > +Math.max(x1, x2).toFixed(2) || px2 < +Math.min(x3, x4).toFixed(2) || px2 > +Math.max(x3, x4).toFixed(2) || py2 < +Math.min(y1, y2).toFixed(2) || py2 > +Math.max(y1, y2).toFixed(2) || py2 < +Math.min(y3, y4).toFixed(2) || py2 > +Math.max(y3, y4).toFixed(2)) {
  4560. return;
  4561. }
  4562. return {
  4563. x: px,
  4564. y: py
  4565. };
  4566. };
  4567. var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) {
  4568. return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
  4569. };
  4570. var box = function box(x, y, width, height) {
  4571. if (x === null) {
  4572. x = y = width = height = 0;
  4573. }
  4574. if (y === null) {
  4575. y = x.y;
  4576. width = x.width;
  4577. height = x.height;
  4578. x = x.x;
  4579. }
  4580. return {
  4581. x: x,
  4582. y: y,
  4583. width: width,
  4584. w: width,
  4585. height: height,
  4586. h: height,
  4587. x2: x + width,
  4588. y2: y + height,
  4589. cx: x + width / 2,
  4590. cy: y + height / 2,
  4591. r1: Math.min(width, height) / 2,
  4592. r2: Math.max(width, height) / 2,
  4593. r0: Math.sqrt(width * width + height * height) / 2,
  4594. path: rectPath(x, y, width, height),
  4595. vb: [x, y, width, height].join(' ')
  4596. };
  4597. };
  4598. var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) {
  4599. bbox1 = box(bbox1);
  4600. bbox2 = box(bbox2);
  4601. return isPointInsideBBox(bbox2, bbox1.x, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2) || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x) && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
  4602. };
  4603. var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
  4604. if (!isArray(p1x)) {
  4605. p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
  4606. }
  4607. var bbox = curveDim.apply(null, p1x);
  4608. return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
  4609. };
  4610. var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
  4611. var t1 = 1 - t;
  4612. var t13 = Math.pow(t1, 3);
  4613. var t12 = Math.pow(t1, 2);
  4614. var t2 = t * t;
  4615. var t3 = t2 * t;
  4616. var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x;
  4617. var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y;
  4618. var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x);
  4619. var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y);
  4620. var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x);
  4621. var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y);
  4622. var ax = t1 * p1x + t * c1x;
  4623. var ay = t1 * p1y + t * c1y;
  4624. var cx = t1 * c2x + t * p2x;
  4625. var cy = t1 * c2y + t * p2y;
  4626. var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI;
  4627. // (mx > nx || my < ny) && (alpha += 180);
  4628. return {
  4629. x: x,
  4630. y: y,
  4631. m: {
  4632. x: mx,
  4633. y: my
  4634. },
  4635. n: {
  4636. x: nx,
  4637. y: ny
  4638. },
  4639. start: {
  4640. x: ax,
  4641. y: ay
  4642. },
  4643. end: {
  4644. x: cx,
  4645. y: cy
  4646. },
  4647. alpha: alpha
  4648. };
  4649. };
  4650. var interHelper = function interHelper(bez1, bez2, justCount) {
  4651. var bbox1 = bezierBBox(bez1);
  4652. var bbox2 = bezierBBox(bez2);
  4653. if (!isBBoxIntersect(bbox1, bbox2)) {
  4654. return justCount ? 0 : [];
  4655. }
  4656. var l1 = bezlen.apply(0, bez1);
  4657. var l2 = bezlen.apply(0, bez2);
  4658. var n1 = ~~(l1 / 8);
  4659. var n2 = ~~(l2 / 8);
  4660. var dots1 = [];
  4661. var dots2 = [];
  4662. var xy = {};
  4663. var res = justCount ? 0 : [];
  4664. for (var i = 0; i < n1 + 1; i++) {
  4665. var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));
  4666. dots1.push({
  4667. x: d.x,
  4668. y: d.y,
  4669. t: i / n1
  4670. });
  4671. }
  4672. for (var _i = 0; _i < n2 + 1; _i++) {
  4673. var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
  4674. dots2.push({
  4675. x: _d.x,
  4676. y: _d.y,
  4677. t: _i / n2
  4678. });
  4679. }
  4680. for (var _i2 = 0; _i2 < n1; _i2++) {
  4681. for (var j = 0; j < n2; j++) {
  4682. var di = dots1[_i2];
  4683. var di1 = dots1[_i2 + 1];
  4684. var dj = dots2[j];
  4685. var dj1 = dots2[j + 1];
  4686. var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x';
  4687. var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x';
  4688. var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
  4689. if (is) {
  4690. if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {
  4691. continue;
  4692. }
  4693. xy[is.x.toFixed(4)] = is.y.toFixed(4);
  4694. var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
  4695. var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
  4696. if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
  4697. if (justCount) {
  4698. res++;
  4699. } else {
  4700. res.push({
  4701. x: is.x,
  4702. y: is.y,
  4703. t1: t1,
  4704. t2: t2
  4705. });
  4706. }
  4707. }
  4708. }
  4709. }
  4710. }
  4711. return res;
  4712. };
  4713. var interPathHelper = function interPathHelper(path1, path2, justCount) {
  4714. path1 = pathTocurve(path1);
  4715. path2 = pathTocurve(path2);
  4716. var x1 = void 0;
  4717. var y1 = void 0;
  4718. var x2 = void 0;
  4719. var y2 = void 0;
  4720. var x1m = void 0;
  4721. var y1m = void 0;
  4722. var x2m = void 0;
  4723. var y2m = void 0;
  4724. var bez1 = void 0;
  4725. var bez2 = void 0;
  4726. var res = justCount ? 0 : [];
  4727. for (var i = 0, ii = path1.length; i < ii; i++) {
  4728. var pi = path1[i];
  4729. if (pi[0] === 'M') {
  4730. x1 = x1m = pi[1];
  4731. y1 = y1m = pi[2];
  4732. } else {
  4733. if (pi[0] === 'C') {
  4734. bez1 = [x1, y1].concat(pi.slice(1));
  4735. x1 = bez1[6];
  4736. y1 = bez1[7];
  4737. } else {
  4738. bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
  4739. x1 = x1m;
  4740. y1 = y1m;
  4741. }
  4742. for (var j = 0, jj = path2.length; j < jj; j++) {
  4743. var pj = path2[j];
  4744. if (pj[0] === 'M') {
  4745. x2 = x2m = pj[1];
  4746. y2 = y2m = pj[2];
  4747. } else {
  4748. if (pj[0] === 'C') {
  4749. bez2 = [x2, y2].concat(pj.slice(1));
  4750. x2 = bez2[6];
  4751. y2 = bez2[7];
  4752. } else {
  4753. bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
  4754. x2 = x2m;
  4755. y2 = y2m;
  4756. }
  4757. var intr = interHelper(bez1, bez2, justCount);
  4758. if (justCount) {
  4759. res += intr;
  4760. } else {
  4761. for (var k = 0, kk = intr.length; k < kk; k++) {
  4762. intr[k].segment1 = i;
  4763. intr[k].segment2 = j;
  4764. intr[k].bez1 = bez1;
  4765. intr[k].bez2 = bez2;
  4766. }
  4767. res = res.concat(intr);
  4768. }
  4769. }
  4770. }
  4771. }
  4772. }
  4773. return res;
  4774. };
  4775. module.exports = function pathIntersection(path1, path2) {
  4776. return interPathHelper(path1, path2);
  4777. };
  4778. /***/ }),
  4779. /* 101 */
  4780. /***/ (function(module, exports) {
  4781. function decasteljau(points, t) {
  4782. var left = [];
  4783. var right = [];
  4784. function recurse(points, t) {
  4785. if (points.length === 1) {
  4786. left.push(points[0]);
  4787. right.push(points[0]);
  4788. } else {
  4789. var middlePoints = [];
  4790. for (var i = 0; i < points.length - 1; i++) {
  4791. if (i === 0) {
  4792. left.push(points[0]);
  4793. }
  4794. if (i === points.length - 2) {
  4795. right.push(points[i + 1]);
  4796. }
  4797. middlePoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]];
  4798. }
  4799. recurse(middlePoints, t);
  4800. }
  4801. }
  4802. if (points.length) {
  4803. recurse(points, t);
  4804. }
  4805. return { left: left, right: right.reverse() };
  4806. }
  4807. function splitCurve(start, end, count) {
  4808. var points = [[start[1], start[2]]];
  4809. count = count || 2;
  4810. var segments = [];
  4811. if (end[0] === 'A') {
  4812. points.push(end[6]);
  4813. points.push(end[7]);
  4814. } else if (end[0] === 'C') {
  4815. points.push([end[1], end[2]]);
  4816. points.push([end[3], end[4]]);
  4817. points.push([end[5], end[6]]);
  4818. } else if (end[0] === 'S' || end[0] === 'Q') {
  4819. points.push([end[1], end[2]]);
  4820. points.push([end[3], end[4]]);
  4821. } else {
  4822. points.push([end[1], end[2]]);
  4823. }
  4824. var leftSegments = points;
  4825. var t = 1 / count;
  4826. for (var i = 0; i < count - 1; i++) {
  4827. var rt = t / (1 - t * i);
  4828. var split = decasteljau(leftSegments, rt);
  4829. segments.push(split.left);
  4830. leftSegments = split.right;
  4831. }
  4832. segments.push(leftSegments);
  4833. var result = segments.map(function (segment) {
  4834. var cmd = [];
  4835. if (segment.length === 4) {
  4836. cmd.push('C');
  4837. cmd = cmd.concat(segment[2]);
  4838. }
  4839. if (segment.length >= 3) {
  4840. if (segment.length === 3) {
  4841. cmd.push('Q');
  4842. }
  4843. cmd = cmd.concat(segment[1]);
  4844. }
  4845. if (segment.length === 2) {
  4846. cmd.push('L');
  4847. }
  4848. cmd = cmd.concat(segment[segment.length - 1]);
  4849. return cmd;
  4850. });
  4851. return result;
  4852. }
  4853. function splitSegment(start, end, count) {
  4854. if (count === 1) {
  4855. return [[].concat(start)];
  4856. }
  4857. var segments = [];
  4858. if (end[0] === 'L' || end[0] === 'C' || end[0] === 'Q') {
  4859. segments = segments.concat(splitCurve(start, end, count));
  4860. } else {
  4861. var temp = [].concat(start);
  4862. if (temp[0] === 'M') {
  4863. temp[0] = 'L';
  4864. }
  4865. for (var i = 0; i <= count - 1; i++) {
  4866. segments.push(temp);
  4867. }
  4868. }
  4869. return segments;
  4870. }
  4871. module.exports = function fillPath(source, target) {
  4872. if (source.length === 1) {
  4873. return source;
  4874. }
  4875. var sourceLen = source.length - 1;
  4876. var targetLen = target.length - 1;
  4877. var ratio = sourceLen / targetLen;
  4878. var segmentsToFill = [];
  4879. if (source.length === 1 && source[0][0] === 'M') {
  4880. for (var i = 0; i < targetLen - sourceLen; i++) {
  4881. source.push(source[0]);
  4882. }
  4883. return source;
  4884. }
  4885. for (var _i = 0; _i < targetLen; _i++) {
  4886. var index = Math.floor(ratio * _i);
  4887. segmentsToFill[index] = (segmentsToFill[index] || 0) + 1;
  4888. }
  4889. var filled = segmentsToFill.reduce(function (filled, count, i) {
  4890. if (i === sourceLen) {
  4891. return filled.concat(source[sourceLen]);
  4892. }
  4893. return filled.concat(splitSegment(source[i], source[i + 1], count));
  4894. }, []);
  4895. filled.unshift(source[0]);
  4896. if (target[targetLen] === 'Z' || target[targetLen] === 'z') {
  4897. filled.push('Z');
  4898. }
  4899. return filled;
  4900. };
  4901. /***/ }),
  4902. /* 102 */
  4903. /***/ (function(module, exports, __webpack_require__) {
  4904. var isEqual = __webpack_require__(103);
  4905. function getMinDiff(del, add, modify) {
  4906. var type = null;
  4907. var min = modify;
  4908. if (add < min) {
  4909. min = add;
  4910. type = 'add';
  4911. }
  4912. if (del < min) {
  4913. min = del;
  4914. type = 'del';
  4915. }
  4916. return {
  4917. type: type,
  4918. min: min
  4919. };
  4920. }
  4921. /*
  4922. * https://en.wikipedia.org/wiki/Levenshtein_distance
  4923. * 计算两条path的编辑距离
  4924. */
  4925. var levenshteinDistance = function levenshteinDistance(source, target) {
  4926. var sourceLen = source.length;
  4927. var targetLen = target.length;
  4928. var sourceSegment = void 0,
  4929. targetSegment = void 0;
  4930. var temp = 0;
  4931. if (sourceLen === 0 || targetLen === 0) {
  4932. return null;
  4933. }
  4934. var dist = [];
  4935. for (var i = 0; i <= sourceLen; i++) {
  4936. dist[i] = [];
  4937. dist[i][0] = { min: i };
  4938. }
  4939. for (var j = 0; j <= targetLen; j++) {
  4940. dist[0][j] = { min: j };
  4941. }
  4942. for (var _i = 1; _i <= sourceLen; _i++) {
  4943. sourceSegment = source[_i - 1];
  4944. for (var _j = 1; _j <= targetLen; _j++) {
  4945. targetSegment = target[_j - 1];
  4946. if (isEqual(sourceSegment, targetSegment)) {
  4947. temp = 0;
  4948. } else {
  4949. temp = 1;
  4950. }
  4951. var del = dist[_i - 1][_j].min + 1;
  4952. var add = dist[_i][_j - 1].min + 1;
  4953. var modify = dist[_i - 1][_j - 1].min + temp;
  4954. dist[_i][_j] = getMinDiff(del, add, modify);
  4955. }
  4956. }
  4957. return dist;
  4958. };
  4959. module.exports = function fillPathByDiff(source, target) {
  4960. var diffMatrix = levenshteinDistance(source, target);
  4961. var sourceLen = source.length;
  4962. var targetLen = target.length;
  4963. var changes = [];
  4964. var index = 1;
  4965. var minPos = 1;
  4966. // 如果source和target不是完全不相等
  4967. if (diffMatrix[sourceLen][targetLen] !== sourceLen) {
  4968. // 获取从source到target所需改动
  4969. for (var i = 1; i <= sourceLen; i++) {
  4970. var min = diffMatrix[i][i].min;
  4971. minPos = i;
  4972. for (var j = index; j <= targetLen; j++) {
  4973. if (diffMatrix[i][j].min < min) {
  4974. min = diffMatrix[i][j].min;
  4975. minPos = j;
  4976. }
  4977. }
  4978. index = minPos;
  4979. if (diffMatrix[i][index].type) {
  4980. changes.push({ index: i - 1, type: diffMatrix[i][index].type });
  4981. }
  4982. }
  4983. // 对source进行增删path
  4984. for (var _i2 = changes.length - 1; _i2 >= 0; _i2--) {
  4985. index = changes[_i2].index;
  4986. if (changes[_i2].type === 'add') {
  4987. source.splice(index, 0, [].concat(source[index]));
  4988. } else {
  4989. source.splice(index, 1);
  4990. }
  4991. }
  4992. }
  4993. // source尾部补齐
  4994. sourceLen = source.length;
  4995. if (sourceLen < targetLen) {
  4996. for (var _i3 = 0; _i3 < targetLen - sourceLen; _i3++) {
  4997. if (source[sourceLen - 1][0] === 'z' || source[sourceLen - 1][0] === 'Z') {
  4998. source.splice(sourceLen - 2, 0, source[sourceLen - 2]);
  4999. } else {
  5000. source.push(source[sourceLen - 1]);
  5001. }
  5002. }
  5003. }
  5004. return source;
  5005. };
  5006. /***/ }),
  5007. /* 103 */
  5008. /***/ (function(module, exports, __webpack_require__) {
  5009. var each = __webpack_require__(0);
  5010. module.exports = function isEqual(obj1, obj2) {
  5011. if (obj1.length !== obj2.length) {
  5012. return false;
  5013. }
  5014. var result = true;
  5015. each(obj1, function (item, i) {
  5016. if (item !== obj2[i]) {
  5017. result = false;
  5018. return false;
  5019. }
  5020. });
  5021. return result;
  5022. };
  5023. /***/ }),
  5024. /* 104 */
  5025. /***/ (function(module, exports) {
  5026. /*
  5027. * 抽取pathSegment中的关键点
  5028. * M,L,A,Q,H,V一个端点
  5029. * Q, S抽取一个端点,一个控制点
  5030. * C抽取一个端点,两个控制点
  5031. */
  5032. function _getSegmentPoints(segment) {
  5033. var points = [];
  5034. switch (segment[0]) {
  5035. case 'M':
  5036. points.push([segment[1], segment[2]]);
  5037. break;
  5038. case 'L':
  5039. points.push([segment[1], segment[2]]);
  5040. break;
  5041. case 'A':
  5042. points.push([segment[6], segment[7]]);
  5043. break;
  5044. case 'Q':
  5045. points.push([segment[3], segment[4]]);
  5046. points.push([segment[1], segment[2]]);
  5047. break;
  5048. case 'T':
  5049. points.push([segment[1], segment[2]]);
  5050. break;
  5051. case 'C':
  5052. points.push([segment[5], segment[6]]);
  5053. points.push([segment[1], segment[2]]);
  5054. points.push([segment[3], segment[4]]);
  5055. break;
  5056. case 'S':
  5057. points.push([segment[3], segment[4]]);
  5058. points.push([segment[1], segment[2]]);
  5059. break;
  5060. case 'H':
  5061. points.push([segment[1], segment[1]]);
  5062. break;
  5063. case 'V':
  5064. points.push([segment[1], segment[1]]);
  5065. break;
  5066. default:
  5067. }
  5068. return points;
  5069. }
  5070. // 将两个点均分成count个点
  5071. function _splitPoints(points, former, count) {
  5072. var result = [].concat(points);
  5073. var index = void 0;
  5074. var t = 1 / (count + 1);
  5075. var formerEnd = _getSegmentPoints(former)[0];
  5076. for (var i = 1; i <= count; i++) {
  5077. t *= i;
  5078. index = Math.floor(points.length * t);
  5079. if (index === 0) {
  5080. result.unshift([formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);
  5081. } else {
  5082. result.splice(index, 0, [formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);
  5083. }
  5084. }
  5085. return result;
  5086. }
  5087. module.exports = function formatPath(fromPath, toPath) {
  5088. if (fromPath.length <= 1) {
  5089. return fromPath;
  5090. }
  5091. var points = void 0;
  5092. for (var i = 0; i < toPath.length; i++) {
  5093. if (fromPath[i][0] !== toPath[i][0]) {
  5094. // 获取fromPath的pathSegment的端点,根据toPath的指令对其改造
  5095. points = _getSegmentPoints(fromPath[i]);
  5096. switch (toPath[i][0]) {
  5097. case 'M':
  5098. fromPath[i] = ['M'].concat(points[0]);
  5099. break;
  5100. case 'L':
  5101. fromPath[i] = ['L'].concat(points[0]);
  5102. break;
  5103. case 'A':
  5104. fromPath[i] = [].concat(toPath[i]);
  5105. fromPath[i][6] = points[0][0];
  5106. fromPath[i][7] = points[0][1];
  5107. break;
  5108. case 'Q':
  5109. if (points.length < 2) {
  5110. if (i > 0) {
  5111. points = _splitPoints(points, fromPath[i - 1], 1);
  5112. } else {
  5113. fromPath[i] = toPath[i];
  5114. break;
  5115. }
  5116. }
  5117. fromPath[i] = ['Q'].concat(points.reduce(function (arr, i) {
  5118. return arr.concat(i);
  5119. }, []));
  5120. break;
  5121. case 'T':
  5122. fromPath[i] = ['T'].concat(points[0]);
  5123. break;
  5124. case 'C':
  5125. if (points.length < 3) {
  5126. if (i > 0) {
  5127. points = _splitPoints(points, fromPath[i - 1], 2);
  5128. } else {
  5129. fromPath[i] = toPath[i];
  5130. break;
  5131. }
  5132. }
  5133. fromPath[i] = ['C'].concat(points.reduce(function (arr, i) {
  5134. return arr.concat(i);
  5135. }, []));
  5136. break;
  5137. case 'S':
  5138. if (points.length < 2) {
  5139. if (i > 0) {
  5140. points = _splitPoints(points, fromPath[i - 1], 1);
  5141. } else {
  5142. fromPath[i] = toPath[i];
  5143. break;
  5144. }
  5145. }
  5146. fromPath[i] = ['S'].concat(points.reduce(function (arr, i) {
  5147. return arr.concat(i);
  5148. }, []));
  5149. break;
  5150. default:
  5151. fromPath[i] = toPath[i];
  5152. }
  5153. }
  5154. }
  5155. return fromPath;
  5156. };
  5157. /***/ }),
  5158. /* 105 */
  5159. /***/ (function(module, exports, __webpack_require__) {
  5160. var strUtil = {
  5161. lc: __webpack_require__(106),
  5162. lowerCase: __webpack_require__(33),
  5163. lowerFirst: __webpack_require__(107),
  5164. substitute: __webpack_require__(108),
  5165. uc: __webpack_require__(109),
  5166. upperCase: __webpack_require__(34),
  5167. upperFirst: __webpack_require__(110)
  5168. };
  5169. module.exports = strUtil;
  5170. /***/ }),
  5171. /* 106 */
  5172. /***/ (function(module, exports, __webpack_require__) {
  5173. module.exports = __webpack_require__(33);
  5174. /***/ }),
  5175. /* 107 */
  5176. /***/ (function(module, exports, __webpack_require__) {
  5177. var toString = __webpack_require__(8);
  5178. var lowerFirst = function lowerFirst(value) {
  5179. var str = toString(value);
  5180. return str.charAt(0).toLowerCase() + str.substring(1);
  5181. };
  5182. module.exports = lowerFirst;
  5183. /***/ }),
  5184. /* 108 */
  5185. /***/ (function(module, exports) {
  5186. var substitute = function substitute(str, o) {
  5187. if (!str || !o) {
  5188. return str;
  5189. }
  5190. return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
  5191. if (match.charAt(0) === '\\') {
  5192. return match.slice(1);
  5193. }
  5194. return o[name] === undefined ? '' : o[name];
  5195. });
  5196. };
  5197. module.exports = substitute;
  5198. /***/ }),
  5199. /* 109 */
  5200. /***/ (function(module, exports, __webpack_require__) {
  5201. module.exports = __webpack_require__(34);
  5202. /***/ }),
  5203. /* 110 */
  5204. /***/ (function(module, exports, __webpack_require__) {
  5205. var toString = __webpack_require__(8);
  5206. var upperFirst = function upperFirst(value) {
  5207. var str = toString(value);
  5208. return str.charAt(0).toUpperCase() + str.substring(1);
  5209. };
  5210. module.exports = upperFirst;
  5211. /***/ }),
  5212. /* 111 */
  5213. /***/ (function(module, exports, __webpack_require__) {
  5214. var isType = __webpack_require__(4);
  5215. var checkType = {
  5216. getType: __webpack_require__(35),
  5217. isArray: __webpack_require__(1),
  5218. isArrayLike: __webpack_require__(3),
  5219. isBoolean: __webpack_require__(112),
  5220. isFunction: __webpack_require__(2),
  5221. isNil: __webpack_require__(5),
  5222. isNull: __webpack_require__(113),
  5223. isNumber: __webpack_require__(6),
  5224. isObject: __webpack_require__(16),
  5225. isObjectLike: __webpack_require__(13),
  5226. isPlainObject: __webpack_require__(7),
  5227. isPrototype: __webpack_require__(36),
  5228. isType: isType,
  5229. isUndefined: __webpack_require__(114),
  5230. isString: __webpack_require__(10),
  5231. isRegExp: __webpack_require__(115)
  5232. };
  5233. ['Arguments', 'Date', 'Error'].forEach(function (type) {
  5234. checkType['is' + type] = function (value) {
  5235. return isType(value, type);
  5236. };
  5237. });
  5238. module.exports = checkType;
  5239. /***/ }),
  5240. /* 112 */
  5241. /***/ (function(module, exports, __webpack_require__) {
  5242. /**
  5243. * 是否是布尔类型
  5244. *
  5245. * @param {Object} value 测试的值
  5246. * @return {Boolean}
  5247. */
  5248. var isType = __webpack_require__(4);
  5249. var isBoolean = function isBoolean(value) {
  5250. return isType(value, 'Boolean');
  5251. };
  5252. module.exports = isBoolean;
  5253. /***/ }),
  5254. /* 113 */
  5255. /***/ (function(module, exports) {
  5256. var isNull = function isNull(value) {
  5257. return value === null;
  5258. };
  5259. module.exports = isNull;
  5260. /***/ }),
  5261. /* 114 */
  5262. /***/ (function(module, exports) {
  5263. var isUndefined = function isUndefined(value) {
  5264. return value === undefined;
  5265. };
  5266. module.exports = isUndefined;
  5267. /***/ }),
  5268. /* 115 */
  5269. /***/ (function(module, exports, __webpack_require__) {
  5270. var isType = __webpack_require__(4);
  5271. var isRegExp = function isRegExp(str) {
  5272. return isType(str, 'RegExp');
  5273. };
  5274. module.exports = isRegExp;
  5275. /***/ }),
  5276. /* 116 */
  5277. /***/ (function(module, exports, __webpack_require__) {
  5278. var isFunction = __webpack_require__(2);
  5279. var toArray = __webpack_require__(14);
  5280. var mix = __webpack_require__(11);
  5281. var augment = function augment(c) {
  5282. var args = toArray(arguments);
  5283. for (var i = 1; i < args.length; i++) {
  5284. var obj = args[i];
  5285. if (isFunction(obj)) {
  5286. obj = obj.prototype;
  5287. }
  5288. mix(c.prototype, obj);
  5289. }
  5290. };
  5291. module.exports = augment;
  5292. /***/ }),
  5293. /* 117 */
  5294. /***/ (function(module, exports, __webpack_require__) {
  5295. var isPlainObject = __webpack_require__(7);
  5296. var isArray = __webpack_require__(1);
  5297. var MAX_MIX_LEVEL = 5;
  5298. function _deepMix(dist, src, level, maxLevel) {
  5299. level = level || 0;
  5300. maxLevel = maxLevel || MAX_MIX_LEVEL;
  5301. for (var key in src) {
  5302. if (src.hasOwnProperty(key)) {
  5303. var value = src[key];
  5304. if (value !== null && isPlainObject(value)) {
  5305. if (!isPlainObject(dist[key])) {
  5306. dist[key] = {};
  5307. }
  5308. if (level < maxLevel) {
  5309. _deepMix(dist[key], value, level + 1, maxLevel);
  5310. } else {
  5311. dist[key] = src[key];
  5312. }
  5313. } else if (isArray(value)) {
  5314. dist[key] = [];
  5315. dist[key] = dist[key].concat(value);
  5316. } else if (value !== undefined) {
  5317. dist[key] = value;
  5318. }
  5319. }
  5320. }
  5321. }
  5322. var deepMix = function deepMix() {
  5323. var args = new Array(arguments.length);
  5324. var length = args.length;
  5325. for (var i = 0; i < length; i++) {
  5326. args[i] = arguments[i];
  5327. }
  5328. var rst = args[0];
  5329. for (var _i = 1; _i < length; _i++) {
  5330. _deepMix(rst, args[_i]);
  5331. }
  5332. return rst;
  5333. };
  5334. module.exports = deepMix;
  5335. /***/ }),
  5336. /* 118 */
  5337. /***/ (function(module, exports, __webpack_require__) {
  5338. var isFunction = __webpack_require__(2);
  5339. var mix = __webpack_require__(11);
  5340. var extend = function extend(subclass, superclass, overrides, staticOverrides) {
  5341. // 如果只提供父类构造函数,则自动生成子类构造函数
  5342. if (!isFunction(superclass)) {
  5343. overrides = superclass;
  5344. superclass = subclass;
  5345. subclass = function subclass() {};
  5346. }
  5347. var create = Object.create ? function (proto, c) {
  5348. return Object.create(proto, {
  5349. constructor: {
  5350. value: c
  5351. }
  5352. });
  5353. } : function (proto, c) {
  5354. function Tmp() {}
  5355. Tmp.prototype = proto;
  5356. var o = new Tmp();
  5357. o.constructor = c;
  5358. return o;
  5359. };
  5360. var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
  5361. subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype
  5362. subclass.superclass = create(superclass.prototype, superclass);
  5363. mix(superObj, overrides);
  5364. mix(subclass, staticOverrides);
  5365. return subclass;
  5366. };
  5367. module.exports = extend;
  5368. /***/ }),
  5369. /* 119 */
  5370. /***/ (function(module, exports, __webpack_require__) {
  5371. var groupToMap = __webpack_require__(37);
  5372. var group = function group(data, condition) {
  5373. if (!condition) {
  5374. return [data];
  5375. }
  5376. var groups = groupToMap(data, condition);
  5377. var array = [];
  5378. for (var i in groups) {
  5379. array.push(groups[i]);
  5380. }
  5381. return array;
  5382. };
  5383. module.exports = group;
  5384. /***/ }),
  5385. /* 120 */
  5386. /***/ (function(module, exports, __webpack_require__) {
  5387. var isArrayLike = __webpack_require__(3);
  5388. var indexOf = function indexOf(arr, obj) {
  5389. if (!isArrayLike(arr)) {
  5390. return -1;
  5391. }
  5392. var m = Array.prototype.indexOf;
  5393. if (m) {
  5394. return m.call(arr, obj);
  5395. }
  5396. var index = -1;
  5397. for (var i = 0; i < arr.length; i++) {
  5398. if (arr[i] === obj) {
  5399. index = i;
  5400. break;
  5401. }
  5402. }
  5403. return index;
  5404. };
  5405. module.exports = indexOf;
  5406. /***/ }),
  5407. /* 121 */
  5408. /***/ (function(module, exports, __webpack_require__) {
  5409. var isNil = __webpack_require__(5);
  5410. var isArrayLike = __webpack_require__(3);
  5411. var getType = __webpack_require__(35);
  5412. var isPrototype = __webpack_require__(36);
  5413. var hasOwnProperty = Object.prototype.hasOwnProperty;
  5414. function isEmpty(value) {
  5415. /**
  5416. * isEmpty(null) => true
  5417. * isEmpty() => true
  5418. * isEmpty(true) => true
  5419. * isEmpty(1) => true
  5420. * isEmpty([1, 2, 3]) => false
  5421. * isEmpty('abc') => false
  5422. * isEmpty({ a: 1 }) => false
  5423. */
  5424. if (isNil(value)) {
  5425. return true;
  5426. }
  5427. if (isArrayLike(value)) {
  5428. return !value.length;
  5429. }
  5430. var type = getType(value);
  5431. if (type === 'Map' || type === 'Set') {
  5432. return !value.size;
  5433. }
  5434. if (isPrototype(value)) {
  5435. return !Object.keys(value).length;
  5436. }
  5437. for (var key in value) {
  5438. if (hasOwnProperty.call(value, key)) {
  5439. return false;
  5440. }
  5441. }
  5442. return true;
  5443. }
  5444. module.exports = isEmpty;
  5445. /***/ }),
  5446. /* 122 */
  5447. /***/ (function(module, exports, __webpack_require__) {
  5448. var isFunction = __webpack_require__(2);
  5449. var isEqual = __webpack_require__(39);
  5450. /**
  5451. * @param {*} value The value to compare.
  5452. * @param {*} other The other value to compare.
  5453. * @param {Function} [fn] The function to customize comparisons.
  5454. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  5455. * @example
  5456. *
  5457. * function isGreeting(value) {
  5458. * return /^h(?:i|ello)$/.test(value);
  5459. * }
  5460. *
  5461. * function customizer(objValue, othValue) {
  5462. * if (isGreeting(objValue) && isGreeting(othValue)) {
  5463. * return true;
  5464. * }
  5465. * }
  5466. *
  5467. * var array = ['hello', 'goodbye'];
  5468. * var other = ['hi', 'goodbye'];
  5469. *
  5470. * isEqualWith(array, other, customizer); // => true
  5471. */
  5472. var isEqualWith = function isEqualWith(value, other, fn) {
  5473. if (!isFunction(fn)) {
  5474. return isEqual(value, other);
  5475. }
  5476. return !!fn(value, other);
  5477. };
  5478. module.exports = isEqualWith;
  5479. /***/ }),
  5480. /* 123 */
  5481. /***/ (function(module, exports, __webpack_require__) {
  5482. var each = __webpack_require__(0);
  5483. var isArrayLike = __webpack_require__(3);
  5484. var map = function map(arr, func) {
  5485. if (!isArrayLike(arr)) {
  5486. return arr;
  5487. }
  5488. var result = [];
  5489. each(arr, function (value, index) {
  5490. result.push(func(value, index));
  5491. });
  5492. return result;
  5493. };
  5494. module.exports = map;
  5495. /***/ }),
  5496. /* 124 */
  5497. /***/ (function(module, exports, __webpack_require__) {
  5498. var each = __webpack_require__(0);
  5499. var isPlaineObject = __webpack_require__(7);
  5500. var hasOwnProperty = Object.prototype.hasOwnProperty;
  5501. /**
  5502. * Creates an object composed of the picked `object` properties.
  5503. *
  5504. * @param {Object} object The source object.
  5505. * @param {...(string|string[])} [paths] The property paths to pick.
  5506. * @returns {Object} Returns the new object.
  5507. * @example
  5508. *
  5509. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  5510. * pick(object, ['a', 'c']); // => { 'a': 1, 'c': 3 }
  5511. */
  5512. var pick = function pick(object, keys) {
  5513. if (object === null || !isPlaineObject(object)) {
  5514. return {};
  5515. }
  5516. var result = {};
  5517. each(keys, function (key) {
  5518. if (hasOwnProperty.call(object, key)) {
  5519. result[key] = object[key];
  5520. }
  5521. });
  5522. return result;
  5523. };
  5524. module.exports = pick;
  5525. /***/ }),
  5526. /* 125 */
  5527. /***/ (function(module, exports) {
  5528. var uniqueId = function () {
  5529. var map = {};
  5530. return function (prefix) {
  5531. prefix = prefix || 'g';
  5532. if (!map[prefix]) {
  5533. map[prefix] = 1;
  5534. } else {
  5535. map[prefix] += 1;
  5536. }
  5537. return prefix + map[prefix];
  5538. };
  5539. }();
  5540. module.exports = uniqueId;
  5541. /***/ })
  5542. /******/ ]);
  5543. });