| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define([], factory);
- else if(typeof exports === 'object')
- exports["Util"] = factory();
- else
- root["Util"] = factory();
- })(this, function() {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 40);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(16);
- var isArray = __webpack_require__(1);
- var each = function each(elements, func) {
- if (!elements) {
- return;
- }
- var rst = void 0;
- if (isArray(elements)) {
- for (var i = 0, len = elements.length; i < len; i++) {
- rst = func(elements[i], i);
- if (rst === false) {
- break;
- }
- }
- } else if (isObject(elements)) {
- for (var k in elements) {
- if (elements.hasOwnProperty(k)) {
- rst = func(elements[k], k);
- if (rst === false) {
- break;
- }
- }
- }
- }
- };
- module.exports = each;
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(4);
- var isArray = Array.isArray ? Array.isArray : function (value) {
- return isType(value, 'Array');
- };
- module.exports = isArray;
- /***/ }),
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * 是否为函数
- * @param {*} fn 对象
- * @return {Boolean} 是否函数
- */
- var isType = __webpack_require__(4);
- var isFunction = function isFunction(value) {
- return isType(value, 'Function');
- };
- module.exports = isFunction;
- /***/ }),
- /* 3 */
- /***/ (function(module, exports) {
- var isArrayLike = function isArrayLike(value) {
- /**
- * isArrayLike([1, 2, 3]) => true
- * isArrayLike(document.body.children) => true
- * isArrayLike('abc') => true
- * isArrayLike(Function) => false
- */
- return value !== null && typeof value !== 'function' && isFinite(value.length);
- };
- module.exports = isArrayLike;
- /***/ }),
- /* 4 */
- /***/ (function(module, exports) {
- var toString = {}.toString;
- var isType = function isType(value, type) {
- return toString.call(value) === '[object ' + type + ']';
- };
- module.exports = isType;
- /***/ }),
- /* 5 */
- /***/ (function(module, exports) {
- // isFinite,
- var isNil = function isNil(value) {
- /**
- * isNil(null) => true
- * isNil() => true
- */
- return value === null || value === undefined;
- };
- module.exports = isNil;
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * 判断是否数字
- * @return {Boolean} 是否数字
- */
- var isType = __webpack_require__(4);
- var isNumber = function isNumber(value) {
- return isType(value, 'Number');
- };
- module.exports = isNumber;
- /***/ }),
- /* 7 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObjectLike = __webpack_require__(13);
- var isType = __webpack_require__(4);
- var isPlainObject = function isPlainObject(value) {
- /**
- * isObjectLike(new Foo) => false
- * isObjectLike([1, 2, 3]) => false
- * isObjectLike({ x: 0, y: 0 }) => true
- * isObjectLike(Object.create(null)) => true
- */
- if (!isObjectLike(value) || !isType(value, 'Object')) {
- return false;
- }
- if (Object.getPrototypeOf(value) === null) {
- return true;
- }
- var proto = value;
- while (Object.getPrototypeOf(proto) !== null) {
- proto = Object.getPrototypeOf(proto);
- }
- return Object.getPrototypeOf(value) === proto;
- };
- module.exports = isPlainObject;
- /***/ }),
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNil = __webpack_require__(5);
- function toString(value) {
- if (isNil(value)) return '';
- return value.toString();
- }
- module.exports = toString;
- /***/ }),
- /* 9 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArrayLike = __webpack_require__(3);
- var indexOf = Array.prototype.indexOf;
- var contains = function contains(arr, value) {
- if (!isArrayLike(arr)) {
- return false;
- }
- return indexOf.call(arr, value) > -1;
- };
- module.exports = contains;
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(4);
- var isString = function isString(str) {
- return isType(str, 'String');
- };
- module.exports = isString;
- /***/ }),
- /* 11 */
- /***/ (function(module, exports) {
- function _mix(dist, obj) {
- for (var key in obj) {
- if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
- dist[key] = obj[key];
- }
- }
- }
- var mix = function mix(dist, src1, src2, src3) {
- if (src1) _mix(dist, src1);
- if (src2) _mix(dist, src2);
- if (src3) _mix(dist, src3);
- return dist;
- };
- module.exports = mix;
- /***/ }),
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var isArrayLike = __webpack_require__(3);
- var filter = function filter(arr, func) {
- if (!isArrayLike(arr)) {
- return arr;
- }
- var result = [];
- each(arr, function (value, index) {
- if (func(value, index)) {
- result.push(value);
- }
- });
- return result;
- };
- module.exports = filter;
- /***/ }),
- /* 13 */
- /***/ (function(module, exports) {
- 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; };
- var isObjectLike = function isObjectLike(value) {
- /**
- * isObjectLike({}) => true
- * isObjectLike([1, 2, 3]) => true
- * isObjectLike(Function) => false
- * isObjectLike(null) => false
- */
- return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
- };
- module.exports = isObjectLike;
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArrayLike = __webpack_require__(3);
- function toArray(value) {
- return isArrayLike(value) ? Array.prototype.slice.call(value) : [];
- }
- module.exports = toArray;
- /***/ }),
- /* 15 */
- /***/ (function(module, exports) {
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.setMatrixArrayType = setMatrixArrayType;
- exports.toRadian = toRadian;
- exports.equals = equals;
- /**
- * Common utilities
- * @module glMatrix
- */
- // Configuration Constants
- var EPSILON = exports.EPSILON = 0.000001;
- var ARRAY_TYPE = exports.ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
- var RANDOM = exports.RANDOM = Math.random;
- /**
- * Sets the type of array used when creating new vectors and matrices
- *
- * @param {Type} type Array type, such as Float32Array or Array
- */
- function setMatrixArrayType(type) {
- exports.ARRAY_TYPE = ARRAY_TYPE = type;
- }
- var degree = Math.PI / 180;
- /**
- * Convert Degree To Radian
- *
- * @param {Number} a Angle in Degrees
- */
- function toRadian(a) {
- return a * degree;
- }
- /**
- * Tests whether or not the arguments have approximately the same value, within an absolute
- * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
- * than or equal to 1.0, and a relative tolerance is used for larger values)
- *
- * @param {Number} a The first number to test.
- * @param {Number} b The second number to test.
- * @returns {Boolean} True if the numbers are approximately equal, false otherwise.
- */
- function equals(a, b) {
- return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
- }
- /***/ }),
- /* 16 */
- /***/ (function(module, exports) {
- 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; };
- var isObject = function isObject(value) {
- /**
- * isObject({}) => true
- * isObject([1, 2, 3]) => true
- * isObject(Function) => true
- * isObject(null) => false
- */
- var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
- return value !== null && type === 'object' || type === 'function';
- };
- module.exports = isObject;
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- var keys = __webpack_require__(18);
- var isNil = __webpack_require__(5);
- function isMatch(obj, attrs) {
- var _keys = keys(attrs);
- var length = _keys.length;
- if (isNil(obj)) return !length;
- for (var i = 0; i < length; i += 1) {
- var key = _keys[i];
- if (attrs[key] !== obj[key] || !(key in obj)) {
- return false;
- }
- }
- return true;
- }
- module.exports = isMatch;
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var isFunction = __webpack_require__(2);
- var keys = Object.keys ? function (obj) {
- return Object.keys(obj);
- } : function (obj) {
- var result = [];
- each(obj, function (value, key) {
- if (!(isFunction(obj) && key === 'prototype')) {
- result.push(key);
- }
- });
- return result;
- };
- module.exports = keys;
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArrayLike = __webpack_require__(3);
- var splice = Array.prototype.splice;
- var pullAt = function pullAt(arr, indexes) {
- if (!isArrayLike(arr)) {
- return [];
- }
- var length = arr ? indexes.length : 0;
- var last = length - 1;
- while (length--) {
- var previous = void 0;
- var index = indexes[length];
- if (length === last || index !== previous) {
- previous = index;
- splice.call(arr, index, 1);
- }
- }
- return arr;
- };
- module.exports = pullAt;
- /***/ }),
- /* 20 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var contains = __webpack_require__(9);
- var uniq = function uniq(arr) {
- var resultArr = [];
- each(arr, function (item) {
- if (!contains(resultArr, item)) {
- resultArr.push(item);
- }
- });
- return resultArr;
- };
- module.exports = uniq;
- /***/ }),
- /* 21 */
- /***/ (function(module, exports) {
- var clamp = function clamp(a, min, max) {
- if (a < min) {
- return min;
- } else if (a > max) {
- return max;
- }
- return a;
- };
- module.exports = clamp;
- /***/ }),
- /* 22 */
- /***/ (function(module, exports) {
- module.exports = parseInt;
- /***/ }),
- /* 23 */
- /***/ (function(module, exports, __webpack_require__) {
- var mat3 = __webpack_require__(89);
- mat3.translate = function (out, a, v) {
- var transMat = new Array(9);
- mat3.fromTranslation(transMat, v);
- return mat3.multiply(out, transMat, a);
- };
- mat3.rotate = function (out, a, rad) {
- var rotateMat = new Array(9);
- mat3.fromRotation(rotateMat, rad);
- return mat3.multiply(out, rotateMat, a);
- };
- mat3.scale = function (out, a, v) {
- var scaleMat = new Array(9);
- mat3.fromScaling(scaleMat, v);
- return mat3.multiply(out, scaleMat, a);
- };
- module.exports = mat3;
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
- 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; };
- var isArray = __webpack_require__(1);
- var clone = function clone(obj) {
- if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
- return obj;
- }
- var rst = void 0;
- if (isArray(obj)) {
- rst = [];
- for (var i = 0, l = obj.length; i < l; i++) {
- if (_typeof(obj[i]) === 'object' && obj[i] != null) {
- rst[i] = clone(obj[i]);
- } else {
- rst[i] = obj[i];
- }
- }
- } else {
- rst = {};
- for (var k in obj) {
- if (_typeof(obj[k]) === 'object' && obj[k] != null) {
- rst[k] = clone(obj[k]);
- } else {
- rst[k] = obj[k];
- }
- }
- }
- return rst;
- };
- module.exports = clone;
- /***/ }),
- /* 25 */
- /***/ (function(module, exports) {
- module.exports = function (obj, key) {
- return obj.hasOwnProperty(key);
- };
- /***/ }),
- /* 26 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var isFunction = __webpack_require__(2);
- var values = Object.values ? function (obj) {
- return Object.values(obj);
- } : function (obj) {
- var result = [];
- each(obj, function (value, key) {
- if (!(isFunction(obj) && key === 'prototype')) {
- result.push(value);
- }
- });
- return result;
- };
- module.exports = values;
- /***/ }),
- /* 27 */
- /***/ (function(module, exports, __webpack_require__) {
- var parsePathArray = __webpack_require__(28);
- module.exports = function rectPath(x, y, w, h, r) {
- if (r) {
- 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']];
- }
- var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];
- res.parsePathArray = parsePathArray;
- return res;
- };
- /***/ }),
- /* 28 */
- /***/ (function(module, exports) {
- var p2s = /,?([a-z]),?/gi;
- module.exports = function parsePathArray(path) {
- return path.join(',').replace(p2s, '$1');
- };
- /***/ }),
- /* 29 */
- /***/ (function(module, exports, __webpack_require__) {
- var pathToAbsolute = __webpack_require__(30);
- var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
- // for more information of where this math came from visit:
- // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
- if (rx === ry) {
- rx += 1;
- }
- var _120 = Math.PI * 120 / 180;
- var rad = Math.PI / 180 * (+angle || 0);
- var res = [];
- var xy = void 0;
- var f1 = void 0;
- var f2 = void 0;
- var cx = void 0;
- var cy = void 0;
- var rotate = function rotate(x, y, rad) {
- var X = x * Math.cos(rad) - y * Math.sin(rad);
- var Y = x * Math.sin(rad) + y * Math.cos(rad);
- return {
- x: X,
- y: Y
- };
- };
- if (!recursive) {
- xy = rotate(x1, y1, -rad);
- x1 = xy.x;
- y1 = xy.y;
- xy = rotate(x2, y2, -rad);
- x2 = xy.x;
- y2 = xy.y;
- if (x1 === x2 && y1 === y2) {
- // 若弧的起始点和终点重叠则错开一点
- x2 += 1;
- y2 += 1;
- }
- // const cos = Math.cos(Math.PI / 180 * angle);
- // const sin = Math.sin(Math.PI / 180 * angle);
- var x = (x1 - x2) / 2;
- var y = (y1 - y2) / 2;
- var h = x * x / (rx * rx) + y * y / (ry * ry);
- if (h > 1) {
- h = Math.sqrt(h);
- rx = h * rx;
- ry = h * ry;
- }
- var rx2 = rx * rx;
- var ry2 = ry * ry;
- 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)));
- cx = k * rx * y / ry + (x1 + x2) / 2;
- cy = k * -ry * x / rx + (y1 + y2) / 2;
- f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
- f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
- f1 = x1 < cx ? Math.PI - f1 : f1;
- f2 = x2 < cx ? Math.PI - f2 : f2;
- f1 < 0 && (f1 = Math.PI * 2 + f1);
- f2 < 0 && (f2 = Math.PI * 2 + f2);
- if (sweep_flag && f1 > f2) {
- f1 = f1 - Math.PI * 2;
- }
- if (!sweep_flag && f2 > f1) {
- f2 = f2 - Math.PI * 2;
- }
- } else {
- f1 = recursive[0];
- f2 = recursive[1];
- cx = recursive[2];
- cy = recursive[3];
- }
- var df = f2 - f1;
- if (Math.abs(df) > _120) {
- var f2old = f2;
- var x2old = x2;
- var y2old = y2;
- f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
- x2 = cx + rx * Math.cos(f2);
- y2 = cy + ry * Math.sin(f2);
- res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
- }
- df = f2 - f1;
- var c1 = Math.cos(f1);
- var s1 = Math.sin(f1);
- var c2 = Math.cos(f2);
- var s2 = Math.sin(f2);
- var t = Math.tan(df / 4);
- var hx = 4 / 3 * rx * t;
- var hy = 4 / 3 * ry * t;
- var m1 = [x1, y1];
- var m2 = [x1 + hx * s1, y1 - hy * c1];
- var m3 = [x2 + hx * s2, y2 - hy * c2];
- var m4 = [x2, y2];
- m2[0] = 2 * m1[0] - m2[0];
- m2[1] = 2 * m1[1] - m2[1];
- if (recursive) {
- return [m2, m3, m4].concat(res);
- }
- res = [m2, m3, m4].concat(res).join().split(',');
- var newres = [];
- for (var i = 0, ii = res.length; i < ii; i++) {
- newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
- }
- return newres;
- };
- var l2c = function l2c(x1, y1, x2, y2) {
- return [x1, y1, x2, y2, x2, y2];
- };
- var q2c = function q2c(x1, y1, ax, ay, x2, y2) {
- var _13 = 1 / 3;
- var _23 = 2 / 3;
- return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];
- };
- module.exports = function pathTocurve(path, path2) {
- var p = pathToAbsolute(path);
- var p2 = path2 && pathToAbsolute(path2);
- var attrs = {
- x: 0,
- y: 0,
- bx: 0,
- by: 0,
- X: 0,
- Y: 0,
- qx: null,
- qy: null
- };
- var attrs2 = {
- x: 0,
- y: 0,
- bx: 0,
- by: 0,
- X: 0,
- Y: 0,
- qx: null,
- qy: null
- };
- var pcoms1 = []; // path commands of original path p
- var pcoms2 = []; // path commands of original path p2
- var pfirst = ''; // temporary holder for original path command
- var pcom = ''; // holder for previous path command of original path
- var ii = void 0;
- var processPath = function processPath(path, d, pcom) {
- var nx = void 0,
- ny = void 0;
- if (!path) {
- return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
- }!(path[0] in {
- T: 1,
- Q: 1
- }) && (d.qx = d.qy = null);
- switch (path[0]) {
- case 'M':
- d.X = path[1];
- d.Y = path[2];
- break;
- case 'A':
- path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
- break;
- case 'S':
- if (pcom === 'C' || pcom === 'S') {
- // In "S" case we have to take into account, if the previous command is C/S.
- nx = d.x * 2 - d.bx; // And reflect the previous
- ny = d.y * 2 - d.by; // command's control point relative to the current point.
- } else {
- // or some else or nothing
- nx = d.x;
- ny = d.y;
- }
- path = ['C', nx, ny].concat(path.slice(1));
- break;
- case 'T':
- if (pcom === 'Q' || pcom === 'T') {
- // In "T" case we have to take into account, if the previous command is Q/T.
- d.qx = d.x * 2 - d.qx; // And make a reflection similar
- d.qy = d.y * 2 - d.qy; // to case "S".
- } else {
- // or something else or nothing
- d.qx = d.x;
- d.qy = d.y;
- }
- path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
- break;
- case 'Q':
- d.qx = path[1];
- d.qy = path[2];
- path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
- break;
- case 'L':
- path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
- break;
- case 'H':
- path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
- break;
- case 'V':
- path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
- break;
- case 'Z':
- path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
- break;
- default:
- break;
- }
- return path;
- };
- var fixArc = function fixArc(pp, i) {
- if (pp[i].length > 7) {
- pp[i].shift();
- var pi = pp[i];
- while (pi.length) {
- pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
- p2 && (pcoms2[i] = 'A'); // the same as above
- pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
- }
- pp.splice(i, 1);
- ii = Math.max(p.length, p2 && p2.length || 0);
- }
- };
- var fixM = function fixM(path1, path2, a1, a2, i) {
- if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {
- path2.splice(i, 0, ['M', a2.x, a2.y]);
- a1.bx = 0;
- a1.by = 0;
- a1.x = path1[i][1];
- a1.y = path1[i][2];
- ii = Math.max(p.length, p2 && p2.length || 0);
- }
- };
- ii = Math.max(p.length, p2 && p2.length || 0);
- for (var i = 0; i < ii; i++) {
- p[i] && (pfirst = p[i][0]); // save current path command
- if (pfirst !== 'C') {
- // C is not saved yet, because it may be result of conversion
- pcoms1[i] = pfirst; // Save current path command
- i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
- }
- p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
- if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command
- // which may produce multiple C:s
- // so we have to make sure that C is also C in original path
- fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
- if (p2) {
- // the same procedures is done to p2
- p2[i] && (pfirst = p2[i][0]);
- if (pfirst !== 'C') {
- pcoms2[i] = pfirst;
- i && (pcom = pcoms2[i - 1]);
- }
- p2[i] = processPath(p2[i], attrs2, pcom);
- if (pcoms2[i] !== 'A' && pfirst === 'C') {
- pcoms2[i] = 'C';
- }
- fixArc(p2, i);
- }
- fixM(p, p2, attrs, attrs2, i);
- fixM(p2, p, attrs2, attrs, i);
- var seg = p[i];
- var seg2 = p2 && p2[i];
- var seglen = seg.length;
- var seg2len = p2 && seg2.length;
- attrs.x = seg[seglen - 2];
- attrs.y = seg[seglen - 1];
- attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
- attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
- attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x);
- attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y);
- attrs2.x = p2 && seg2[seg2len - 2];
- attrs2.y = p2 && seg2[seg2len - 1];
- }
- return p2 ? [p, p2] : p;
- };
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
- var parsePathString = __webpack_require__(31);
- var catmullRom2bezier = __webpack_require__(32);
- function ellipsePath(x, y, rx, ry, a) {
- var res = [];
- if (a === null && ry === null) {
- ry = rx;
- }
- x = +x;
- y = +y;
- rx = +rx;
- ry = +ry;
- if (a !== null) {
- var rad = Math.PI / 180;
- var x1 = x + rx * Math.cos(-ry * rad);
- var x2 = x + rx * Math.cos(-a * rad);
- var y1 = y + rx * Math.sin(-ry * rad);
- var y2 = y + rx * Math.sin(-a * rad);
- res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
- } else {
- 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']];
- }
- return res;
- }
- module.exports = function pathToAbsolute(pathArray) {
- pathArray = parsePathString(pathArray);
- if (!pathArray || !pathArray.length) {
- return [['M', 0, 0]];
- }
- var res = [];
- var x = 0;
- var y = 0;
- var mx = 0;
- var my = 0;
- var start = 0;
- var pa0 = void 0;
- var dots = void 0;
- if (pathArray[0][0] === 'M') {
- x = +pathArray[0][1];
- y = +pathArray[0][2];
- mx = x;
- my = y;
- start++;
- res[0] = ['M', x, y];
- }
- var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
- for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
- res.push(r = []);
- pa = pathArray[i];
- pa0 = pa[0];
- if (pa0 !== pa0.toUpperCase()) {
- r[0] = pa0.toUpperCase();
- switch (r[0]) {
- case 'A':
- r[1] = pa[1];
- r[2] = pa[2];
- r[3] = pa[3];
- r[4] = pa[4];
- r[5] = pa[5];
- r[6] = +pa[6] + x;
- r[7] = +pa[7] + y;
- break;
- case 'V':
- r[1] = +pa[1] + y;
- break;
- case 'H':
- r[1] = +pa[1] + x;
- break;
- case 'R':
- dots = [x, y].concat(pa.slice(1));
- for (var j = 2, jj = dots.length; j < jj; j++) {
- dots[j] = +dots[j] + x;
- dots[++j] = +dots[j] + y;
- }
- res.pop();
- res = res.concat(catmullRom2bezier(dots, crz));
- break;
- case 'O':
- res.pop();
- dots = ellipsePath(x, y, pa[1], pa[2]);
- dots.push(dots[0]);
- res = res.concat(dots);
- break;
- case 'U':
- res.pop();
- res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
- r = ['U'].concat(res[res.length - 1].slice(-2));
- break;
- case 'M':
- mx = +pa[1] + x;
- my = +pa[2] + y;
- break; // for lint
- default:
- for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {
- r[_j] = +pa[_j] + (_j % 2 ? x : y);
- }
- }
- } else if (pa0 === 'R') {
- dots = [x, y].concat(pa.slice(1));
- res.pop();
- res = res.concat(catmullRom2bezier(dots, crz));
- r = ['R'].concat(pa.slice(-2));
- } else if (pa0 === 'O') {
- res.pop();
- dots = ellipsePath(x, y, pa[1], pa[2]);
- dots.push(dots[0]);
- res = res.concat(dots);
- } else if (pa0 === 'U') {
- res.pop();
- res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
- r = ['U'].concat(res[res.length - 1].slice(-2));
- } else {
- for (var k = 0, kk = pa.length; k < kk; k++) {
- r[k] = pa[k];
- }
- }
- pa0 = pa0.toUpperCase();
- if (pa0 !== 'O') {
- switch (r[0]) {
- case 'Z':
- x = +mx;
- y = +my;
- break;
- case 'H':
- x = r[1];
- break;
- case 'V':
- y = r[1];
- break;
- case 'M':
- mx = r[r.length - 2];
- my = r[r.length - 1];
- break; // for lint
- default:
- x = r[r.length - 2];
- y = r[r.length - 1];
- }
- }
- }
- return res;
- };
- /***/ }),
- /* 31 */
- /***/ (function(module, exports) {
- 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; };
- 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';
- var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
- var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
- // Parses given path string into an array of arrays of path segments
- module.exports = function parsePathString(pathString) {
- if (!pathString) {
- return null;
- }
- if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) {
- return pathString;
- }
- var paramCounts = {
- a: 7,
- c: 6,
- o: 2,
- h: 1,
- l: 2,
- m: 2,
- r: 4,
- q: 4,
- s: 4,
- t: 2,
- v: 1,
- u: 3,
- z: 0
- };
- var data = [];
- String(pathString).replace(PATH_COMMAND, function (a, b, c) {
- var params = [];
- var name = b.toLowerCase();
- c.replace(PATH_VALUES, function (a, b) {
- b && params.push(+b);
- });
- if (name === 'm' && params.length > 2) {
- data.push([b].concat(params.splice(0, 2)));
- name = 'l';
- b = b === 'm' ? 'l' : 'L';
- }
- if (name === 'o' && params.length === 1) {
- data.push([b, params[0]]);
- }
- if (name === 'r') {
- data.push([b].concat(params));
- } else {
- while (params.length >= paramCounts[name]) {
- data.push([b].concat(params.splice(0, paramCounts[name])));
- if (!paramCounts[name]) {
- break;
- }
- }
- }
- });
- return data;
- };
- /***/ }),
- /* 32 */
- /***/ (function(module, exports) {
- // http://schepers.cc/getting-to-the-point
- module.exports = function catmullRom2bezier(crp, z) {
- var d = [];
- for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
- var p = [{
- x: +crp[i - 2],
- y: +crp[i - 1]
- }, {
- x: +crp[i],
- y: +crp[i + 1]
- }, {
- x: +crp[i + 2],
- y: +crp[i + 3]
- }, {
- x: +crp[i + 4],
- y: +crp[i + 5]
- }];
- if (z) {
- if (!i) {
- p[0] = {
- x: +crp[iLen - 2],
- y: +crp[iLen - 1]
- };
- } else if (iLen - 4 === i) {
- p[3] = {
- x: +crp[0],
- y: +crp[1]
- };
- } else if (iLen - 2 === i) {
- p[2] = {
- x: +crp[0],
- y: +crp[1]
- };
- p[3] = {
- x: +crp[2],
- y: +crp[3]
- };
- }
- } else {
- if (iLen - 4 === i) {
- p[3] = p[2];
- } else if (!i) {
- p[0] = {
- x: +crp[i],
- y: +crp[i + 1]
- };
- }
- }
- 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]);
- }
- return d;
- };
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- var toString = __webpack_require__(8);
- var lowerCase = function lowerCase(str) {
- return toString(str).toLowerCase();
- };
- module.exports = lowerCase;
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- var toString = __webpack_require__(8);
- var upperCase = function upperCase(str) {
- return toString(str).toUpperCase();
- };
- module.exports = upperCase;
- /***/ }),
- /* 35 */
- /***/ (function(module, exports) {
- var toString = {}.toString;
- var getType = function getType(value) {
- return toString.call(value).replace(/^\[object /, '').replace(/\]$/, '');
- };
- module.exports = getType;
- /***/ }),
- /* 36 */
- /***/ (function(module, exports) {
- var objectProto = Object.prototype;
- var isPrototype = function isPrototype(value) {
- var Ctor = value && value.constructor;
- var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
- return value === proto;
- };
- module.exports = isPrototype;
- /***/ }),
- /* 37 */
- /***/ (function(module, exports, __webpack_require__) {
- var isFunction = __webpack_require__(2);
- var isArray = __webpack_require__(1);
- var groupBy = __webpack_require__(38);
- var groupToMap = function groupToMap(data, condition) {
- if (!condition) {
- return {
- 0: data
- };
- }
- if (!isFunction(condition)) {
- var paramsCondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*');
- condition = function condition(row) {
- var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
- for (var i = 0, l = paramsCondition.length; i < l; i++) {
- unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString();
- }
- return unique;
- };
- }
- var groups = groupBy(data, condition);
- return groups;
- };
- module.exports = groupToMap;
- /***/ }),
- /* 38 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var isArray = __webpack_require__(1);
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var groupBy = function groupBy(data, condition) {
- if (!condition || !isArray(data)) {
- return data;
- }
- var result = {};
- var key = null;
- each(data, function (item) {
- key = condition(item);
- if (hasOwnProperty.call(result, key)) {
- result[key].push(item);
- } else {
- result[key] = [item];
- }
- });
- return result;
- };
- module.exports = groupBy;
- /***/ }),
- /* 39 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObjectLike = __webpack_require__(13);
- var isArrayLike = __webpack_require__(3);
- var isString = __webpack_require__(10);
- var isEqual = function isEqual(value, other) {
- if (value === other) {
- return true;
- }
- if (!value || !other) {
- return false;
- }
- if (isString(value) || isString(other)) {
- return false;
- }
- if (isArrayLike(value) || isArrayLike(other)) {
- if (value.length !== other.length) {
- return false;
- }
- var rst = true;
- for (var i = 0; i < value.length; i++) {
- rst = isEqual(value[i], other[i]);
- if (!rst) {
- break;
- }
- }
- return rst;
- }
- if (isObjectLike(value) || isObjectLike(other)) {
- var valueKeys = Object.keys(value);
- var otherKeys = Object.keys(other);
- if (valueKeys.length !== otherKeys.length) {
- return false;
- }
- var _rst = true;
- for (var _i = 0; _i < valueKeys.length; _i++) {
- _rst = isEqual(value[valueKeys[_i]], other[valueKeys[_i]]);
- if (!_rst) {
- break;
- }
- }
- return _rst;
- }
- return false;
- };
- module.exports = isEqual;
- /***/ }),
- /* 40 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var mix = __webpack_require__(11);
- // collections
- var DOMUtil = __webpack_require__(41);
- var arrayUtil = __webpack_require__(53);
- var eventUtil = __webpack_require__(67);
- var formatUtil = __webpack_require__(70);
- var mathUtil = __webpack_require__(74);
- var matrixUtil = __webpack_require__(88);
- var objectUtil = __webpack_require__(95);
- var pathUtil = __webpack_require__(99);
- var stringUtil = __webpack_require__(105);
- var typeUtil = __webpack_require__(111);
- var util = {
- // collections
- DOMUtil: DOMUtil,
- DomUtil: DOMUtil,
- MatrixUtil: matrixUtil,
- PathUtil: pathUtil,
- arrayUtil: arrayUtil,
- domUtil: DOMUtil,
- eventUtil: eventUtil,
- formatUtil: formatUtil,
- mathUtil: mathUtil,
- matrixUtil: matrixUtil,
- objectUtil: objectUtil,
- stringUtil: stringUtil,
- pathUtil: pathUtil,
- typeUtil: typeUtil,
- // others
- augment: __webpack_require__(116),
- clone: __webpack_require__(24),
- deepMix: __webpack_require__(117),
- each: each,
- extend: __webpack_require__(118),
- filter: __webpack_require__(12),
- group: __webpack_require__(119),
- groupBy: __webpack_require__(38),
- groupToMap: __webpack_require__(37),
- indexOf: __webpack_require__(120),
- isEmpty: __webpack_require__(121),
- isEqual: __webpack_require__(39),
- isEqualWith: __webpack_require__(122),
- map: __webpack_require__(123),
- mix: mix,
- pick: __webpack_require__(124),
- toArray: __webpack_require__(14),
- toString: __webpack_require__(8),
- uniqueId: __webpack_require__(125)
- };
- each([DOMUtil, arrayUtil, eventUtil, formatUtil, mathUtil, matrixUtil, objectUtil, pathUtil, stringUtil, typeUtil], function (collection) {
- mix(util, collection);
- });
- module.exports = util;
- /***/ }),
- /* 41 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = {
- addEventListener: __webpack_require__(42),
- createDom: __webpack_require__(43),
- getBoundingClientRect: __webpack_require__(44),
- getHeight: __webpack_require__(45),
- getOuterHeight: __webpack_require__(46),
- getOuterWidth: __webpack_require__(47),
- getRatio: __webpack_require__(48),
- getStyle: __webpack_require__(49),
- getWidth: __webpack_require__(50),
- modifyCSS: __webpack_require__(51),
- requestAnimationFrame: __webpack_require__(52)
- };
- /***/ }),
- /* 42 */
- /***/ (function(module, exports) {
- /**
- * 添加事件监听器
- * @param {Object} target DOM对象
- * @param {String} eventType 事件名
- * @param {Funtion} callback 回调函数
- * @return {Object} 返回对象
- */
- module.exports = function addEventListener(target, eventType, callback) {
- if (target) {
- if (target.addEventListener) {
- target.addEventListener(eventType, callback, false);
- return {
- remove: function remove() {
- target.removeEventListener(eventType, callback, false);
- }
- };
- } else if (target.attachEvent) {
- target.attachEvent('on' + eventType, callback);
- return {
- remove: function remove() {
- target.detachEvent('on' + eventType, callback);
- }
- };
- }
- }
- };
- /***/ }),
- /* 43 */
- /***/ (function(module, exports) {
- /**
- * 创建DOM 节点
- * @param {String} str Dom 字符串
- * @return {HTMLElement} DOM 节点
- */
- var TABLE = document.createElement('table');
- var TABLE_TR = document.createElement('tr');
- var FRAGMENT_REG = /^\s*<(\w+|!)[^>]*>/;
- var CONTAINERS = {
- tr: document.createElement('tbody'),
- tbody: TABLE,
- thead: TABLE,
- tfoot: TABLE,
- td: TABLE_TR,
- th: TABLE_TR,
- '*': document.createElement('div')
- };
- module.exports = function createDom(str) {
- var name = FRAGMENT_REG.test(str) && RegExp.$1;
- if (!(name in CONTAINERS)) {
- name = '*';
- }
- var container = CONTAINERS[name];
- str = str.replace(/(^\s*)|(\s*$)/g, '');
- container.innerHTML = '' + str;
- var dom = container.childNodes[0];
- container.removeChild(dom);
- return dom;
- };
- /***/ }),
- /* 44 */
- /***/ (function(module, exports) {
- module.exports = function getBoundingClientRect(node, defaultValue) {
- if (node && node.getBoundingClientRect) {
- var rect = node.getBoundingClientRect();
- var top = document.documentElement.clientTop;
- var left = document.documentElement.clientLeft;
- return {
- top: rect.top - top,
- bottom: rect.bottom - top,
- left: rect.left - left,
- right: rect.right - left
- };
- }
- return defaultValue || null;
- };
- /***/ }),
- /* 45 */
- /***/ (function(module, exports) {
- /**
- * 获取高度
- * @param {HTMLElement} el dom节点
- * @param {Number} defaultValue 默认值
- * @return {Number} 高度
- */
- module.exports = function getHeight(el, defaultValue) {
- var height = this.getStyle(el, 'height', defaultValue);
- if (height === 'auto') {
- height = el.offsetHeight;
- }
- return parseFloat(height);
- };
- /***/ }),
- /* 46 */
- /***/ (function(module, exports) {
- /**
- * 获取外层高度
- * @param {HTMLElement} el dom节点
- * @param {Number} defaultValue 默认值
- * @return {Number} 高度
- */
- module.exports = function getOuterHeight(el, defaultValue) {
- var height = this.getHeight(el, defaultValue);
- var bTop = parseFloat(this.getStyle(el, 'borderTopWidth')) || 0;
- var pTop = parseFloat(this.getStyle(el, 'paddingTop')) || 0;
- var pBottom = parseFloat(this.getStyle(el, 'paddingBottom')) || 0;
- var bBottom = parseFloat(this.getStyle(el, 'borderBottomWidth')) || 0;
- return height + bTop + bBottom + pTop + pBottom;
- };
- /***/ }),
- /* 47 */
- /***/ (function(module, exports) {
- /**
- * 获取外层宽度
- * @param {HTMLElement} el dom节点
- * @param {Number} defaultValue 默认值
- * @return {Number} 宽度
- */
- module.exports = function getOuterWidth(el, defaultValue) {
- var width = this.getWidth(el, defaultValue);
- var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0;
- var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')) || 0;
- var pRight = parseFloat(this.getStyle(el, 'paddingRight')) || 0;
- var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0;
- return width + bLeft + bRight + pLeft + pRight;
- };
- /***/ }),
- /* 48 */
- /***/ (function(module, exports) {
- module.exports = function getRatio() {
- return window.devicePixelRatio ? window.devicePixelRatio : 2;
- };
- /***/ }),
- /* 49 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNil = __webpack_require__(5);
- /**
- * 获取样式
- * @param {Object} dom DOM节点
- * @param {String} name 样式名
- * @param {Any} defaultValue 默认值
- * @return {String} 属性值
- */
- module.exports = function getStyle(dom, name, defaultValue) {
- try {
- if (window.getComputedStyle) {
- return window.getComputedStyle(dom, null)[name];
- }
- return dom.currentStyle[name];
- } catch (e) {
- if (!isNil(defaultValue)) {
- return defaultValue;
- }
- return null;
- }
- };
- /***/ }),
- /* 50 */
- /***/ (function(module, exports) {
- /**
- * 获取宽度
- * @param {HTMLElement} el dom节点
- * @param {Number} defaultValue 默认值
- * @return {Number} 宽度
- */
- module.exports = function getWidth(el, defaultValue) {
- var width = this.getStyle(el, 'width', defaultValue);
- if (width === 'auto') {
- width = el.offsetWidth;
- }
- return parseFloat(width);
- };
- /***/ }),
- /* 51 */
- /***/ (function(module, exports) {
- module.exports = function modifyCSS(dom, css) {
- if (dom) {
- for (var key in css) {
- if (css.hasOwnProperty(key)) {
- dom.style[key] = css[key];
- }
- }
- }
- return dom;
- };
- /***/ }),
- /* 52 */
- /***/ (function(module, exports) {
- module.exports = function requestAnimationFrame(fn) {
- var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
- return setTimeout(fn, 16);
- };
- return method(fn);
- };
- /***/ }),
- /* 53 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = {
- contains: __webpack_require__(9),
- difference: __webpack_require__(54),
- find: __webpack_require__(55),
- firstValue: __webpack_require__(56),
- flatten: __webpack_require__(57),
- flattenDeep: __webpack_require__(58),
- getRange: __webpack_require__(59),
- merge: __webpack_require__(60),
- pull: __webpack_require__(61),
- pullAt: __webpack_require__(19),
- reduce: __webpack_require__(62),
- remove: __webpack_require__(63),
- sortBy: __webpack_require__(64),
- union: __webpack_require__(65),
- uniq: __webpack_require__(20),
- valuesOfKey: __webpack_require__(66)
- };
- /***/ }),
- /* 54 */
- /***/ (function(module, exports, __webpack_require__) {
- var filter = __webpack_require__(12);
- var contains = __webpack_require__(9);
- /**
- * Flattens `array` a single level deep.
- *
- * @param {Array} arr The array to inspect.
- * @param {Array} values The values to exclude.
- * @return {Array} Returns the new array of filtered values.
- * @example
- * difference([2, 1], [2, 3]); // => [1]
- */
- var difference = function difference(arr) {
- var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- return filter(arr, function (value) {
- return !contains(values, value);
- });
- };
- module.exports = difference;
- /***/ }),
- /* 55 */
- /***/ (function(module, exports, __webpack_require__) {
- var isFunction = __webpack_require__(2);
- var isPlainObject = __webpack_require__(7);
- var isMatch = __webpack_require__(17);
- function find(arr, predicate) {
- var _predicate = void 0;
- if (isFunction(predicate)) {
- _predicate = predicate;
- }
- if (isPlainObject(predicate)) {
- _predicate = function _predicate(a) {
- return isMatch(a, predicate);
- };
- }
- if (_predicate) {
- for (var i = 0; i < arr.length; i += 1) {
- if (_predicate(arr[i])) {
- return arr[i];
- }
- }
- }
- return null;
- }
- module.exports = find;
- /***/ }),
- /* 56 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNil = __webpack_require__(5);
- var isArray = __webpack_require__(1);
- var firstValue = function firstValue(data, name) {
- var rst = null;
- for (var i = 0; i < data.length; i++) {
- var obj = data[i];
- var value = obj[name];
- if (!isNil(value)) {
- if (isArray(value)) {
- rst = value[0];
- } else {
- rst = value;
- }
- break;
- }
- }
- return rst;
- };
- module.exports = firstValue;
- /***/ }),
- /* 57 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(1);
- var each = __webpack_require__(0);
- /**
- * Flattens `array` a single level deep.
- *
- * @param {Array} arr The array to flatten.
- * @return {Array} Returns the new flattened array.
- * @example
- *
- * flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
- */
- var flatten = function flatten(arr) {
- if (!isArray(arr)) {
- return arr;
- }
- var result = [];
- each(arr, function (item) {
- if (isArray(item)) {
- each(item, function (subItem) {
- result.push(subItem);
- });
- } else {
- result.push(item);
- }
- });
- return result;
- };
- module.exports = flatten;
- /***/ }),
- /* 58 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(1);
- /**
- * Flattens `array` a single level deep.
- *
- * @param {Array} arr The array to flatten.
- * @param {Array} result The array to return.
- * @return {Array} Returns the new flattened array.
- * @example
- *
- * flattenDeep([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5]
- */
- var flattenDeep = function flattenDeep(arr) {
- var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- if (!isArray(arr)) {
- result.push(arr);
- } else {
- for (var i = 0; i < arr.length; i += 1) {
- flattenDeep(arr[i], result);
- }
- }
- return result;
- };
- module.exports = flattenDeep;
- /***/ }),
- /* 59 */
- /***/ (function(module, exports, __webpack_require__) {
- var filter = __webpack_require__(12);
- var isArray = __webpack_require__(1);
- var getRange = function getRange(values) {
- // 存在 NaN 时,min,max 判定会出问题
- values = filter(values, function (v) {
- return !isNaN(v);
- });
- if (!values.length) {
- // 如果没有数值则直接返回0
- return {
- min: 0,
- max: 0
- };
- }
- if (isArray(values[0])) {
- var tmp = [];
- for (var i = 0; i < values.length; i++) {
- tmp = tmp.concat(values[i]);
- }
- values = tmp;
- }
- var max = Math.max.apply(null, values);
- var min = Math.min.apply(null, values);
- return {
- min: min,
- max: max
- };
- };
- module.exports = getRange;
- /***/ }),
- /* 60 */
- /***/ (function(module, exports) {
- var merge = function merge(dataArray) {
- var rst = [];
- for (var i = 0; i < dataArray.length; i++) {
- rst = rst.concat(dataArray[i]);
- }
- return rst;
- };
- module.exports = merge;
- /***/ }),
- /* 61 */
- /***/ (function(module, exports) {
- var arrPrototype = Array.prototype;
- var splice = arrPrototype.splice;
- var indexOf = arrPrototype.indexOf;
- var slice = arrPrototype.slice;
- var pull = function pull(arr) {
- var values = slice.call(arguments, 1);
- for (var i = 0; i < values.length; i++) {
- var value = values[i];
- var fromIndex = -1;
- while ((fromIndex = indexOf.call(arr, value)) > -1) {
- splice.call(arr, fromIndex, 1);
- }
- }
- return arr;
- };
- module.exports = pull;
- /***/ }),
- /* 62 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(1);
- var isPlainObject = __webpack_require__(7);
- var each = __webpack_require__(0);
- var reduce = function reduce(arr, fn, init) {
- if (!isArray(arr) && !isPlainObject(arr)) {
- return arr;
- }
- var result = init;
- each(arr, function (data, i) {
- result = fn(result, data, i);
- });
- return result;
- };
- module.exports = reduce;
- /***/ }),
- /* 63 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArrayLike = __webpack_require__(3);
- var pullAt = __webpack_require__(19);
- var remove = function remove(arr, predicate) {
- /**
- * const arr = [1, 2, 3, 4]
- * const evens = remove(arr, n => n % 2 == 0)
- * console.log(arr) // => [1, 3]
- * console.log(evens) // => [2, 4]
- */
- var result = [];
- if (!isArrayLike(arr)) {
- return result;
- }
- var i = -1;
- var indexes = [];
- var length = arr.length;
- while (++i < length) {
- var value = arr[i];
- if (predicate(value, i, arr)) {
- result.push(value);
- indexes.push(i);
- }
- }
- pullAt(arr, indexes);
- return result;
- };
- module.exports = remove;
- /***/ }),
- /* 64 */
- /***/ (function(module, exports, __webpack_require__) {
- var isString = __webpack_require__(10);
- var isFunction = __webpack_require__(2);
- var isArray = __webpack_require__(1);
- function sortBy(arr, key) {
- var comparer = void 0;
- if (isFunction(key)) {
- comparer = function comparer(a, b) {
- return key(a) - key(b);
- };
- } else {
- var keys = [];
- if (isString(key)) {
- keys.push(key);
- } else if (isArray(key)) {
- keys = key;
- }
- comparer = function comparer(a, b) {
- for (var i = 0; i < keys.length; i += 1) {
- var prop = keys[i];
- if (a[prop] > b[prop]) {
- return 1;
- }
- if (a[prop] < b[prop]) {
- return -1;
- }
- }
- return 0;
- };
- }
- arr.sort(comparer);
- return arr;
- }
- module.exports = sortBy;
- /***/ }),
- /* 65 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var toArray = __webpack_require__(14);
- var uniq = __webpack_require__(20);
- var union = function union() {
- var result = [];
- var sources = toArray(arguments);
- each(sources, function (arr) {
- result = result.concat(arr);
- });
- return uniq(result);
- };
- module.exports = union;
- /***/ }),
- /* 66 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNil = __webpack_require__(5);
- var isArray = __webpack_require__(1);
- var each = __webpack_require__(0);
- module.exports = function valuesOfKey(data, name) {
- var rst = [];
- var tmpMap = {};
- for (var i = 0; i < data.length; i++) {
- var obj = data[i];
- var value = obj[name];
- if (!isNil(value)) {
- if (!isArray(value)) {
- value = [value];
- }
- each(value, function (val) {
- if (!tmpMap[val]) {
- rst.push(val);
- tmpMap[val] = true;
- }
- });
- }
- }
- return rst;
- };
- /***/ }),
- /* 67 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = {
- getWrapBehavior: __webpack_require__(68),
- wrapBehavior: __webpack_require__(69)
- };
- /***/ }),
- /* 68 */
- /***/ (function(module, exports) {
- /**
- * 获取封装的事件
- * @protected
- * @param {Object} obj 对象
- * @param {String} action 事件名称
- * @return {Function} 返回事件处理函数
- */
- function getWrapBehavior(obj, action) {
- return obj['_wrap_' + action];
- }
- module.exports = getWrapBehavior;
- /***/ }),
- /* 69 */
- /***/ (function(module, exports) {
- /**
- * 封装事件,便于使用上下文this,和便于解除事件时使用
- * @protected
- * @param {Object} obj 对象
- * @param {String} action 事件名称
- * @return {Function} 返回事件处理函数
- */
- function wrapBehavior(obj, action) {
- if (obj['_wrap_' + action]) {
- return obj['_wrap_' + action];
- }
- var method = function method(e) {
- obj[action](e);
- };
- obj['_wrap_' + action] = method;
- return method;
- }
- module.exports = wrapBehavior;
- /***/ }),
- /* 70 */
- /***/ (function(module, exports, __webpack_require__) {
- var number2color = __webpack_require__(71);
- module.exports = {
- number2color: number2color,
- numberToColor: number2color,
- parsePath: __webpack_require__(72),
- parseRadius: __webpack_require__(73)
- };
- /***/ }),
- /* 71 */
- /***/ (function(module, exports) {
- var numColorCache = {};
- module.exports = function numberToColor(num) {
- // 增加缓存
- var color = numColorCache[num];
- if (!color) {
- var str = num.toString(16);
- for (var i = str.length; i < 6; i++) {
- str = '0' + str;
- }
- color = '#' + str;
- numColorCache[num] = color;
- }
- return color;
- };
- /***/ }),
- /* 72 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(1);
- var isString = __webpack_require__(10);
- var each = __webpack_require__(0);
- var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
- var regexDot = /[^\s\,]+/ig;
- module.exports = function parsePath(path) {
- path = path || [];
- if (isArray(path)) {
- return path;
- }
- if (isString(path)) {
- path = path.match(regexTags);
- each(path, function (item, index) {
- item = item.match(regexDot);
- if (item[0].length > 1) {
- var tag = item[0].charAt(0);
- item.splice(1, 0, item[0].substr(1));
- item[0] = tag;
- }
- each(item, function (sub, i) {
- if (!isNaN(sub)) {
- item[i] = +sub;
- }
- });
- path[index] = item;
- });
- return path;
- }
- };
- /***/ }),
- /* 73 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(1);
- module.exports = function parseRadius(radius) {
- var r1 = 0,
- r2 = 0,
- r3 = 0,
- r4 = 0;
- if (isArray(radius)) {
- if (radius.length === 1) {
- r1 = r2 = r3 = r4 = radius[0];
- } else if (radius.length === 2) {
- r1 = r3 = radius[0];
- r2 = r4 = radius[1];
- } else if (radius.length === 3) {
- r1 = radius[0];
- r2 = r4 = radius[1];
- r3 = radius[2];
- } else {
- r1 = radius[0];
- r2 = radius[1];
- r3 = radius[2];
- r4 = radius[3];
- }
- } else {
- r1 = r2 = r3 = r4 = radius;
- }
- return {
- r1: r1,
- r2: r2,
- r3: r3,
- r4: r4
- };
- };
- /***/ }),
- /* 74 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNumberEqual = __webpack_require__(75);
- module.exports = {
- clamp: __webpack_require__(21),
- fixedBase: __webpack_require__(76),
- isDecimal: __webpack_require__(77),
- isEven: __webpack_require__(78),
- isInteger: __webpack_require__(79),
- isNegative: __webpack_require__(80),
- isNumberEqual: isNumberEqual,
- isOdd: __webpack_require__(81),
- isPositive: __webpack_require__(82),
- maxBy: __webpack_require__(83),
- minBy: __webpack_require__(84),
- mod: __webpack_require__(85),
- snapEqual: isNumberEqual,
- toDegree: __webpack_require__(86),
- toInt: __webpack_require__(22),
- toInteger: __webpack_require__(22),
- toRadian: __webpack_require__(87)
- };
- /***/ }),
- /* 75 */
- /***/ (function(module, exports) {
- var PRECISION = 0.00001; // numbers less than this is considered as 0
- module.exports = function isNumberEqual(a, b) {
- var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PRECISION;
- return Math.abs(a - b) < precision;
- };
- /***/ }),
- /* 76 */
- /***/ (function(module, exports) {
- var fixedBase = function fixedBase(v, base) {
- var str = base.toString();
- var index = str.indexOf('.');
- if (index === -1) {
- return Math.round(v);
- }
- var length = str.substr(index + 1).length;
- if (length > 20) {
- length = 20;
- }
- return parseFloat(v.toFixed(length));
- };
- module.exports = fixedBase;
- /***/ }),
- /* 77 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNumber = __webpack_require__(6);
- var isDecimal = function isDecimal(num) {
- return isNumber(num) && num % 1 !== 0;
- };
- module.exports = isDecimal;
- /***/ }),
- /* 78 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNumber = __webpack_require__(6);
- var isEven = function isEven(num) {
- return isNumber(num) && num % 2 === 0;
- };
- module.exports = isEven;
- /***/ }),
- /* 79 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNumber = __webpack_require__(6);
- var isInteger = Number.isInteger ? Number.isInteger : function (num) {
- return isNumber(num) && num % 1 === 0;
- };
- module.exports = isInteger;
- /***/ }),
- /* 80 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNumber = __webpack_require__(6);
- var isNagative = function isNagative(num) {
- return isNumber(num) && num < 0;
- };
- module.exports = isNagative;
- /***/ }),
- /* 81 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNumber = __webpack_require__(6);
- var isOdd = function isOdd(num) {
- return isNumber(num) && num % 2 !== 0;
- };
- module.exports = isOdd;
- /***/ }),
- /* 82 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNumber = __webpack_require__(6);
- var isPositive = function isPositive(num) {
- return isNumber(num) && num > 0;
- };
- module.exports = isPositive;
- /***/ }),
- /* 83 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(1);
- var isFunction = __webpack_require__(2);
- var each = __webpack_require__(0);
- /**
- * @param {Array} arr The array to iterate over.
- * @param {Function} [fn] The iteratee invoked per element.
- * @return {*} Returns the maximum value.
- * @example
- *
- * var objects = [{ 'n': 1 }, { 'n': 2 }];
- *
- * maxBy(objects, function(o) { return o.n; });
- * // => { 'n': 2 }
- *
- * maxBy(objects, 'n');
- * // => { 'n': 2 }
- */
- var maxBy = function maxBy(arr, fn) {
- if (!isArray(arr)) {
- return undefined;
- }
- var max = arr[0];
- var maxData = void 0;
- if (isFunction(fn)) {
- maxData = fn(arr[0]);
- } else {
- maxData = arr[0][fn];
- }
- var data = void 0;
- each(arr, function (val) {
- if (isFunction(fn)) {
- data = fn(val);
- } else {
- data = val[fn];
- }
- if (data > maxData) {
- max = val;
- maxData = data;
- }
- });
- return max;
- };
- module.exports = maxBy;
- /***/ }),
- /* 84 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(1);
- var isFunction = __webpack_require__(2);
- var each = __webpack_require__(0);
- /**
- * @param {Array} arr The array to iterate over.
- * @param {Function} [fn] The iteratee invoked per element.
- * @return {*} Returns the minimum value.
- * @example
- *
- * var objects = [{ 'n': 1 }, { 'n': 2 }];
- *
- * minBy(objects, function(o) { return o.n; });
- * // => { 'n': 1 }
- *
- * minBy(objects, 'n');
- * // => { 'n': 1 }
- */
- var minBy = function minBy(arr, fn) {
- if (!isArray(arr)) {
- return undefined;
- }
- var min = arr[0];
- var minData = void 0;
- if (isFunction(fn)) {
- minData = fn(arr[0]);
- } else {
- minData = arr[0][fn];
- }
- var data = void 0;
- each(arr, function (val) {
- if (isFunction(fn)) {
- data = fn(val);
- } else {
- data = val[fn];
- }
- if (data < minData) {
- min = val;
- minData = data;
- }
- });
- return min;
- };
- module.exports = minBy;
- /***/ }),
- /* 85 */
- /***/ (function(module, exports) {
- var mod = function mod(n, m) {
- return (n % m + m) % m;
- };
- module.exports = mod;
- /***/ }),
- /* 86 */
- /***/ (function(module, exports) {
- var DEGREE = 180 / Math.PI;
- var toDegree = function toDegree(radian) {
- return DEGREE * radian;
- };
- module.exports = toDegree;
- /***/ }),
- /* 87 */
- /***/ (function(module, exports) {
- var RADIAN = Math.PI / 180;
- var toRadian = function toRadian(degree) {
- return RADIAN * degree;
- };
- module.exports = toRadian;
- /***/ }),
- /* 88 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = {
- mat3: __webpack_require__(23),
- vec2: __webpack_require__(90),
- vec3: __webpack_require__(92),
- transform: __webpack_require__(94)
- };
- /***/ }),
- /* 89 */
- /***/ (function(module, exports, __webpack_require__) {
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.sub = exports.mul = undefined;
- exports.create = create;
- exports.fromMat4 = fromMat4;
- exports.clone = clone;
- exports.copy = copy;
- exports.fromValues = fromValues;
- exports.set = set;
- exports.identity = identity;
- exports.transpose = transpose;
- exports.invert = invert;
- exports.adjoint = adjoint;
- exports.determinant = determinant;
- exports.multiply = multiply;
- exports.translate = translate;
- exports.rotate = rotate;
- exports.scale = scale;
- exports.fromTranslation = fromTranslation;
- exports.fromRotation = fromRotation;
- exports.fromScaling = fromScaling;
- exports.fromMat2d = fromMat2d;
- exports.fromQuat = fromQuat;
- exports.normalFromMat4 = normalFromMat4;
- exports.projection = projection;
- exports.str = str;
- exports.frob = frob;
- exports.add = add;
- exports.subtract = subtract;
- exports.multiplyScalar = multiplyScalar;
- exports.multiplyScalarAndAdd = multiplyScalarAndAdd;
- exports.exactEquals = exactEquals;
- exports.equals = equals;
- var _common = __webpack_require__(15);
- var glMatrix = _interopRequireWildcard(_common);
- function _interopRequireWildcard(obj) {
- if (obj && obj.__esModule) {
- return obj;
- } else {
- var newObj = {};if (obj != null) {
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
- }
- }newObj.default = obj;return newObj;
- }
- }
- /**
- * 3x3 Matrix
- * @module mat3
- */
- /**
- * Creates a new identity mat3
- *
- * @returns {mat3} a new 3x3 matrix
- */
- function create() {
- var out = new glMatrix.ARRAY_TYPE(9);
- if (glMatrix.ARRAY_TYPE != Float32Array) {
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[5] = 0;
- out[6] = 0;
- out[7] = 0;
- }
- out[0] = 1;
- out[4] = 1;
- out[8] = 1;
- return out;
- }
- /**
- * Copies the upper-left 3x3 values into the given mat3.
- *
- * @param {mat3} out the receiving 3x3 matrix
- * @param {mat4} a the source 4x4 matrix
- * @returns {mat3} out
- */
- function fromMat4(out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[4];
- out[4] = a[5];
- out[5] = a[6];
- out[6] = a[8];
- out[7] = a[9];
- out[8] = a[10];
- return out;
- }
- /**
- * Creates a new mat3 initialized with values from an existing matrix
- *
- * @param {mat3} a matrix to clone
- * @returns {mat3} a new 3x3 matrix
- */
- function clone(a) {
- var out = new glMatrix.ARRAY_TYPE(9);
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4];
- out[5] = a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[8] = a[8];
- return out;
- }
- /**
- * Copy the values from one mat3 to another
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the source matrix
- * @returns {mat3} out
- */
- function copy(out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4];
- out[5] = a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[8] = a[8];
- return out;
- }
- /**
- * Create a new mat3 with the given values
- *
- * @param {Number} m00 Component in column 0, row 0 position (index 0)
- * @param {Number} m01 Component in column 0, row 1 position (index 1)
- * @param {Number} m02 Component in column 0, row 2 position (index 2)
- * @param {Number} m10 Component in column 1, row 0 position (index 3)
- * @param {Number} m11 Component in column 1, row 1 position (index 4)
- * @param {Number} m12 Component in column 1, row 2 position (index 5)
- * @param {Number} m20 Component in column 2, row 0 position (index 6)
- * @param {Number} m21 Component in column 2, row 1 position (index 7)
- * @param {Number} m22 Component in column 2, row 2 position (index 8)
- * @returns {mat3} A new mat3
- */
- function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
- var out = new glMatrix.ARRAY_TYPE(9);
- out[0] = m00;
- out[1] = m01;
- out[2] = m02;
- out[3] = m10;
- out[4] = m11;
- out[5] = m12;
- out[6] = m20;
- out[7] = m21;
- out[8] = m22;
- return out;
- }
- /**
- * Set the components of a mat3 to the given values
- *
- * @param {mat3} out the receiving matrix
- * @param {Number} m00 Component in column 0, row 0 position (index 0)
- * @param {Number} m01 Component in column 0, row 1 position (index 1)
- * @param {Number} m02 Component in column 0, row 2 position (index 2)
- * @param {Number} m10 Component in column 1, row 0 position (index 3)
- * @param {Number} m11 Component in column 1, row 1 position (index 4)
- * @param {Number} m12 Component in column 1, row 2 position (index 5)
- * @param {Number} m20 Component in column 2, row 0 position (index 6)
- * @param {Number} m21 Component in column 2, row 1 position (index 7)
- * @param {Number} m22 Component in column 2, row 2 position (index 8)
- * @returns {mat3} out
- */
- function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
- out[0] = m00;
- out[1] = m01;
- out[2] = m02;
- out[3] = m10;
- out[4] = m11;
- out[5] = m12;
- out[6] = m20;
- out[7] = m21;
- out[8] = m22;
- return out;
- }
- /**
- * Set a mat3 to the identity matrix
- *
- * @param {mat3} out the receiving matrix
- * @returns {mat3} out
- */
- function identity(out) {
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 1;
- out[5] = 0;
- out[6] = 0;
- out[7] = 0;
- out[8] = 1;
- return out;
- }
- /**
- * Transpose the values of a mat3
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the source matrix
- * @returns {mat3} out
- */
- function transpose(out, a) {
- // If we are transposing ourselves we can skip a few steps but have to cache some values
- if (out === a) {
- var a01 = a[1],
- a02 = a[2],
- a12 = a[5];
- out[1] = a[3];
- out[2] = a[6];
- out[3] = a01;
- out[5] = a[7];
- out[6] = a02;
- out[7] = a12;
- } else {
- out[0] = a[0];
- out[1] = a[3];
- out[2] = a[6];
- out[3] = a[1];
- out[4] = a[4];
- out[5] = a[7];
- out[6] = a[2];
- out[7] = a[5];
- out[8] = a[8];
- }
- return out;
- }
- /**
- * Inverts a mat3
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the source matrix
- * @returns {mat3} out
- */
- function invert(out, a) {
- var a00 = a[0],
- a01 = a[1],
- a02 = a[2];
- var a10 = a[3],
- a11 = a[4],
- a12 = a[5];
- var a20 = a[6],
- a21 = a[7],
- a22 = a[8];
- var b01 = a22 * a11 - a12 * a21;
- var b11 = -a22 * a10 + a12 * a20;
- var b21 = a21 * a10 - a11 * a20;
- // Calculate the determinant
- var det = a00 * b01 + a01 * b11 + a02 * b21;
- if (!det) {
- return null;
- }
- det = 1.0 / det;
- out[0] = b01 * det;
- out[1] = (-a22 * a01 + a02 * a21) * det;
- out[2] = (a12 * a01 - a02 * a11) * det;
- out[3] = b11 * det;
- out[4] = (a22 * a00 - a02 * a20) * det;
- out[5] = (-a12 * a00 + a02 * a10) * det;
- out[6] = b21 * det;
- out[7] = (-a21 * a00 + a01 * a20) * det;
- out[8] = (a11 * a00 - a01 * a10) * det;
- return out;
- }
- /**
- * Calculates the adjugate of a mat3
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the source matrix
- * @returns {mat3} out
- */
- function adjoint(out, a) {
- var a00 = a[0],
- a01 = a[1],
- a02 = a[2];
- var a10 = a[3],
- a11 = a[4],
- a12 = a[5];
- var a20 = a[6],
- a21 = a[7],
- a22 = a[8];
- out[0] = a11 * a22 - a12 * a21;
- out[1] = a02 * a21 - a01 * a22;
- out[2] = a01 * a12 - a02 * a11;
- out[3] = a12 * a20 - a10 * a22;
- out[4] = a00 * a22 - a02 * a20;
- out[5] = a02 * a10 - a00 * a12;
- out[6] = a10 * a21 - a11 * a20;
- out[7] = a01 * a20 - a00 * a21;
- out[8] = a00 * a11 - a01 * a10;
- return out;
- }
- /**
- * Calculates the determinant of a mat3
- *
- * @param {mat3} a the source matrix
- * @returns {Number} determinant of a
- */
- function determinant(a) {
- var a00 = a[0],
- a01 = a[1],
- a02 = a[2];
- var a10 = a[3],
- a11 = a[4],
- a12 = a[5];
- var a20 = a[6],
- a21 = a[7],
- a22 = a[8];
- return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
- }
- /**
- * Multiplies two mat3's
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the first operand
- * @param {mat3} b the second operand
- * @returns {mat3} out
- */
- function multiply(out, a, b) {
- var a00 = a[0],
- a01 = a[1],
- a02 = a[2];
- var a10 = a[3],
- a11 = a[4],
- a12 = a[5];
- var a20 = a[6],
- a21 = a[7],
- a22 = a[8];
- var b00 = b[0],
- b01 = b[1],
- b02 = b[2];
- var b10 = b[3],
- b11 = b[4],
- b12 = b[5];
- var b20 = b[6],
- b21 = b[7],
- b22 = b[8];
- out[0] = b00 * a00 + b01 * a10 + b02 * a20;
- out[1] = b00 * a01 + b01 * a11 + b02 * a21;
- out[2] = b00 * a02 + b01 * a12 + b02 * a22;
- out[3] = b10 * a00 + b11 * a10 + b12 * a20;
- out[4] = b10 * a01 + b11 * a11 + b12 * a21;
- out[5] = b10 * a02 + b11 * a12 + b12 * a22;
- out[6] = b20 * a00 + b21 * a10 + b22 * a20;
- out[7] = b20 * a01 + b21 * a11 + b22 * a21;
- out[8] = b20 * a02 + b21 * a12 + b22 * a22;
- return out;
- }
- /**
- * Translate a mat3 by the given vector
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the matrix to translate
- * @param {vec2} v vector to translate by
- * @returns {mat3} out
- */
- function translate(out, a, v) {
- var a00 = a[0],
- a01 = a[1],
- a02 = a[2],
- a10 = a[3],
- a11 = a[4],
- a12 = a[5],
- a20 = a[6],
- a21 = a[7],
- a22 = a[8],
- x = v[0],
- y = v[1];
- out[0] = a00;
- out[1] = a01;
- out[2] = a02;
- out[3] = a10;
- out[4] = a11;
- out[5] = a12;
- out[6] = x * a00 + y * a10 + a20;
- out[7] = x * a01 + y * a11 + a21;
- out[8] = x * a02 + y * a12 + a22;
- return out;
- }
- /**
- * Rotates a mat3 by the given angle
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the matrix to rotate
- * @param {Number} rad the angle to rotate the matrix by
- * @returns {mat3} out
- */
- function rotate(out, a, rad) {
- var a00 = a[0],
- a01 = a[1],
- a02 = a[2],
- a10 = a[3],
- a11 = a[4],
- a12 = a[5],
- a20 = a[6],
- a21 = a[7],
- a22 = a[8],
- s = Math.sin(rad),
- c = Math.cos(rad);
- out[0] = c * a00 + s * a10;
- out[1] = c * a01 + s * a11;
- out[2] = c * a02 + s * a12;
- out[3] = c * a10 - s * a00;
- out[4] = c * a11 - s * a01;
- out[5] = c * a12 - s * a02;
- out[6] = a20;
- out[7] = a21;
- out[8] = a22;
- return out;
- };
- /**
- * Scales the mat3 by the dimensions in the given vec2
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the matrix to rotate
- * @param {vec2} v the vec2 to scale the matrix by
- * @returns {mat3} out
- **/
- function scale(out, a, v) {
- var x = v[0],
- y = v[1];
- out[0] = x * a[0];
- out[1] = x * a[1];
- out[2] = x * a[2];
- out[3] = y * a[3];
- out[4] = y * a[4];
- out[5] = y * a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[8] = a[8];
- return out;
- }
- /**
- * Creates a matrix from a vector translation
- * This is equivalent to (but much faster than):
- *
- * mat3.identity(dest);
- * mat3.translate(dest, dest, vec);
- *
- * @param {mat3} out mat3 receiving operation result
- * @param {vec2} v Translation vector
- * @returns {mat3} out
- */
- function fromTranslation(out, v) {
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 1;
- out[5] = 0;
- out[6] = v[0];
- out[7] = v[1];
- out[8] = 1;
- return out;
- }
- /**
- * Creates a matrix from a given angle
- * This is equivalent to (but much faster than):
- *
- * mat3.identity(dest);
- * mat3.rotate(dest, dest, rad);
- *
- * @param {mat3} out mat3 receiving operation result
- * @param {Number} rad the angle to rotate the matrix by
- * @returns {mat3} out
- */
- function fromRotation(out, rad) {
- var s = Math.sin(rad),
- c = Math.cos(rad);
- out[0] = c;
- out[1] = s;
- out[2] = 0;
- out[3] = -s;
- out[4] = c;
- out[5] = 0;
- out[6] = 0;
- out[7] = 0;
- out[8] = 1;
- return out;
- }
- /**
- * Creates a matrix from a vector scaling
- * This is equivalent to (but much faster than):
- *
- * mat3.identity(dest);
- * mat3.scale(dest, dest, vec);
- *
- * @param {mat3} out mat3 receiving operation result
- * @param {vec2} v Scaling vector
- * @returns {mat3} out
- */
- function fromScaling(out, v) {
- out[0] = v[0];
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = v[1];
- out[5] = 0;
- out[6] = 0;
- out[7] = 0;
- out[8] = 1;
- return out;
- }
- /**
- * Copies the values from a mat2d into a mat3
- *
- * @param {mat3} out the receiving matrix
- * @param {mat2d} a the matrix to copy
- * @returns {mat3} out
- **/
- function fromMat2d(out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = 0;
- out[3] = a[2];
- out[4] = a[3];
- out[5] = 0;
- out[6] = a[4];
- out[7] = a[5];
- out[8] = 1;
- return out;
- }
- /**
- * Calculates a 3x3 matrix from the given quaternion
- *
- * @param {mat3} out mat3 receiving operation result
- * @param {quat} q Quaternion to create matrix from
- *
- * @returns {mat3} out
- */
- function fromQuat(out, q) {
- var x = q[0],
- y = q[1],
- z = q[2],
- w = q[3];
- var x2 = x + x;
- var y2 = y + y;
- var z2 = z + z;
- var xx = x * x2;
- var yx = y * x2;
- var yy = y * y2;
- var zx = z * x2;
- var zy = z * y2;
- var zz = z * z2;
- var wx = w * x2;
- var wy = w * y2;
- var wz = w * z2;
- out[0] = 1 - yy - zz;
- out[3] = yx - wz;
- out[6] = zx + wy;
- out[1] = yx + wz;
- out[4] = 1 - xx - zz;
- out[7] = zy - wx;
- out[2] = zx - wy;
- out[5] = zy + wx;
- out[8] = 1 - xx - yy;
- return out;
- }
- /**
- * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
- *
- * @param {mat3} out mat3 receiving operation result
- * @param {mat4} a Mat4 to derive the normal matrix from
- *
- * @returns {mat3} out
- */
- function normalFromMat4(out, a) {
- var a00 = a[0],
- a01 = a[1],
- a02 = a[2],
- a03 = a[3];
- var a10 = a[4],
- a11 = a[5],
- a12 = a[6],
- a13 = a[7];
- var a20 = a[8],
- a21 = a[9],
- a22 = a[10],
- a23 = a[11];
- var a30 = a[12],
- a31 = a[13],
- a32 = a[14],
- a33 = a[15];
- var b00 = a00 * a11 - a01 * a10;
- var b01 = a00 * a12 - a02 * a10;
- var b02 = a00 * a13 - a03 * a10;
- var b03 = a01 * a12 - a02 * a11;
- var b04 = a01 * a13 - a03 * a11;
- var b05 = a02 * a13 - a03 * a12;
- var b06 = a20 * a31 - a21 * a30;
- var b07 = a20 * a32 - a22 * a30;
- var b08 = a20 * a33 - a23 * a30;
- var b09 = a21 * a32 - a22 * a31;
- var b10 = a21 * a33 - a23 * a31;
- var b11 = a22 * a33 - a23 * a32;
- // Calculate the determinant
- var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
- if (!det) {
- return null;
- }
- det = 1.0 / det;
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
- out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
- out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
- out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
- out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
- out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
- out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
- out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
- out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
- return out;
- }
- /**
- * Generates a 2D projection matrix with the given bounds
- *
- * @param {mat3} out mat3 frustum matrix will be written into
- * @param {number} width Width of your gl context
- * @param {number} height Height of gl context
- * @returns {mat3} out
- */
- function projection(out, width, height) {
- out[0] = 2 / width;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = -2 / height;
- out[5] = 0;
- out[6] = -1;
- out[7] = 1;
- out[8] = 1;
- return out;
- }
- /**
- * Returns a string representation of a mat3
- *
- * @param {mat3} a matrix to represent as a string
- * @returns {String} string representation of the matrix
- */
- function str(a) {
- return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')';
- }
- /**
- * Returns Frobenius norm of a mat3
- *
- * @param {mat3} a the matrix to calculate Frobenius norm of
- * @returns {Number} Frobenius norm
- */
- function frob(a) {
- 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));
- }
- /**
- * Adds two mat3's
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the first operand
- * @param {mat3} b the second operand
- * @returns {mat3} out
- */
- function add(out, a, b) {
- out[0] = a[0] + b[0];
- out[1] = a[1] + b[1];
- out[2] = a[2] + b[2];
- out[3] = a[3] + b[3];
- out[4] = a[4] + b[4];
- out[5] = a[5] + b[5];
- out[6] = a[6] + b[6];
- out[7] = a[7] + b[7];
- out[8] = a[8] + b[8];
- return out;
- }
- /**
- * Subtracts matrix b from matrix a
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the first operand
- * @param {mat3} b the second operand
- * @returns {mat3} out
- */
- function subtract(out, a, b) {
- out[0] = a[0] - b[0];
- out[1] = a[1] - b[1];
- out[2] = a[2] - b[2];
- out[3] = a[3] - b[3];
- out[4] = a[4] - b[4];
- out[5] = a[5] - b[5];
- out[6] = a[6] - b[6];
- out[7] = a[7] - b[7];
- out[8] = a[8] - b[8];
- return out;
- }
- /**
- * Multiply each element of the matrix by a scalar.
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the matrix to scale
- * @param {Number} b amount to scale the matrix's elements by
- * @returns {mat3} out
- */
- function multiplyScalar(out, a, b) {
- out[0] = a[0] * b;
- out[1] = a[1] * b;
- out[2] = a[2] * b;
- out[3] = a[3] * b;
- out[4] = a[4] * b;
- out[5] = a[5] * b;
- out[6] = a[6] * b;
- out[7] = a[7] * b;
- out[8] = a[8] * b;
- return out;
- }
- /**
- * Adds two mat3's after multiplying each element of the second operand by a scalar value.
- *
- * @param {mat3} out the receiving vector
- * @param {mat3} a the first operand
- * @param {mat3} b the second operand
- * @param {Number} scale the amount to scale b's elements by before adding
- * @returns {mat3} out
- */
- function multiplyScalarAndAdd(out, a, b, scale) {
- out[0] = a[0] + b[0] * scale;
- out[1] = a[1] + b[1] * scale;
- out[2] = a[2] + b[2] * scale;
- out[3] = a[3] + b[3] * scale;
- out[4] = a[4] + b[4] * scale;
- out[5] = a[5] + b[5] * scale;
- out[6] = a[6] + b[6] * scale;
- out[7] = a[7] + b[7] * scale;
- out[8] = a[8] + b[8] * scale;
- return out;
- }
- /**
- * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
- *
- * @param {mat3} a The first matrix.
- * @param {mat3} b The second matrix.
- * @returns {Boolean} True if the matrices are equal, false otherwise.
- */
- function exactEquals(a, b) {
- 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];
- }
- /**
- * Returns whether or not the matrices have approximately the same elements in the same position.
- *
- * @param {mat3} a The first matrix.
- * @param {mat3} b The second matrix.
- * @returns {Boolean} True if the matrices are equal, false otherwise.
- */
- function equals(a, b) {
- var a0 = a[0],
- a1 = a[1],
- a2 = a[2],
- a3 = a[3],
- a4 = a[4],
- a5 = a[5],
- a6 = a[6],
- a7 = a[7],
- a8 = a[8];
- var b0 = b[0],
- b1 = b[1],
- b2 = b[2],
- b3 = b[3],
- b4 = b[4],
- b5 = b[5],
- b6 = b[6],
- b7 = b[7],
- b8 = b[8];
- 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));
- }
- /**
- * Alias for {@link mat3.multiply}
- * @function
- */
- var mul = exports.mul = multiply;
- /**
- * Alias for {@link mat3.subtract}
- * @function
- */
- var sub = exports.sub = subtract;
- /***/ }),
- /* 90 */
- /***/ (function(module, exports, __webpack_require__) {
- var vec2 = __webpack_require__(91);
- var clamp = __webpack_require__(21);
- vec2.angle = function (v1, v2) {
- var theta = vec2.dot(v1, v2) / (vec2.length(v1) * vec2.length(v2));
- return Math.acos(clamp(theta, -1, 1));
- };
- /**
- * 向量 v1 到 向量 v2 夹角的方向
- * @param {Array} v1 向量
- * @param {Array} v2 向量
- * @return {Boolean} >= 0 顺时针 < 0 逆时针
- */
- vec2.direction = function (v1, v2) {
- return v1[0] * v2[1] - v2[0] * v1[1];
- };
- vec2.angleTo = function (v1, v2, direct) {
- var angle = vec2.angle(v1, v2);
- var angleLargeThanPI = vec2.direction(v1, v2) >= 0;
- if (direct) {
- if (angleLargeThanPI) {
- return Math.PI * 2 - angle;
- }
- return angle;
- }
- if (angleLargeThanPI) {
- return angle;
- }
- return Math.PI * 2 - angle;
- };
- vec2.vertical = function (out, v, flag) {
- if (flag) {
- out[0] = v[1];
- out[1] = -1 * v[0];
- } else {
- out[0] = -1 * v[1];
- out[1] = v[0];
- }
- return out;
- };
- module.exports = vec2;
- /***/ }),
- /* 91 */
- /***/ (function(module, exports, __webpack_require__) {
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.forEach = exports.sqrLen = exports.sqrDist = exports.dist = exports.div = exports.mul = exports.sub = exports.len = undefined;
- exports.create = create;
- exports.clone = clone;
- exports.fromValues = fromValues;
- exports.copy = copy;
- exports.set = set;
- exports.add = add;
- exports.subtract = subtract;
- exports.multiply = multiply;
- exports.divide = divide;
- exports.ceil = ceil;
- exports.floor = floor;
- exports.min = min;
- exports.max = max;
- exports.round = round;
- exports.scale = scale;
- exports.scaleAndAdd = scaleAndAdd;
- exports.distance = distance;
- exports.squaredDistance = squaredDistance;
- exports.length = length;
- exports.squaredLength = squaredLength;
- exports.negate = negate;
- exports.inverse = inverse;
- exports.normalize = normalize;
- exports.dot = dot;
- exports.cross = cross;
- exports.lerp = lerp;
- exports.random = random;
- exports.transformMat2 = transformMat2;
- exports.transformMat2d = transformMat2d;
- exports.transformMat3 = transformMat3;
- exports.transformMat4 = transformMat4;
- exports.rotate = rotate;
- exports.angle = angle;
- exports.str = str;
- exports.exactEquals = exactEquals;
- exports.equals = equals;
- var _common = __webpack_require__(15);
- var glMatrix = _interopRequireWildcard(_common);
- function _interopRequireWildcard(obj) {
- if (obj && obj.__esModule) {
- return obj;
- } else {
- var newObj = {};if (obj != null) {
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
- }
- }newObj.default = obj;return newObj;
- }
- }
- /**
- * 2 Dimensional Vector
- * @module vec2
- */
- /**
- * Creates a new, empty vec2
- *
- * @returns {vec2} a new 2D vector
- */
- function create() {
- var out = new glMatrix.ARRAY_TYPE(2);
- if (glMatrix.ARRAY_TYPE != Float32Array) {
- out[0] = 0;
- out[1] = 0;
- }
- return out;
- }
- /**
- * Creates a new vec2 initialized with values from an existing vector
- *
- * @param {vec2} a vector to clone
- * @returns {vec2} a new 2D vector
- */
- function clone(a) {
- var out = new glMatrix.ARRAY_TYPE(2);
- out[0] = a[0];
- out[1] = a[1];
- return out;
- }
- /**
- * Creates a new vec2 initialized with the given values
- *
- * @param {Number} x X component
- * @param {Number} y Y component
- * @returns {vec2} a new 2D vector
- */
- function fromValues(x, y) {
- var out = new glMatrix.ARRAY_TYPE(2);
- out[0] = x;
- out[1] = y;
- return out;
- }
- /**
- * Copy the values from one vec2 to another
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the source vector
- * @returns {vec2} out
- */
- function copy(out, a) {
- out[0] = a[0];
- out[1] = a[1];
- return out;
- }
- /**
- * Set the components of a vec2 to the given values
- *
- * @param {vec2} out the receiving vector
- * @param {Number} x X component
- * @param {Number} y Y component
- * @returns {vec2} out
- */
- function set(out, x, y) {
- out[0] = x;
- out[1] = y;
- return out;
- }
- /**
- * Adds two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- function add(out, a, b) {
- out[0] = a[0] + b[0];
- out[1] = a[1] + b[1];
- return out;
- }
- /**
- * Subtracts vector b from vector a
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- function subtract(out, a, b) {
- out[0] = a[0] - b[0];
- out[1] = a[1] - b[1];
- return out;
- }
- /**
- * Multiplies two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- function multiply(out, a, b) {
- out[0] = a[0] * b[0];
- out[1] = a[1] * b[1];
- return out;
- }
- /**
- * Divides two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- function divide(out, a, b) {
- out[0] = a[0] / b[0];
- out[1] = a[1] / b[1];
- return out;
- }
- /**
- * Math.ceil the components of a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to ceil
- * @returns {vec2} out
- */
- function ceil(out, a) {
- out[0] = Math.ceil(a[0]);
- out[1] = Math.ceil(a[1]);
- return out;
- }
- /**
- * Math.floor the components of a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to floor
- * @returns {vec2} out
- */
- function floor(out, a) {
- out[0] = Math.floor(a[0]);
- out[1] = Math.floor(a[1]);
- return out;
- }
- /**
- * Returns the minimum of two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- function min(out, a, b) {
- out[0] = Math.min(a[0], b[0]);
- out[1] = Math.min(a[1], b[1]);
- return out;
- }
- /**
- * Returns the maximum of two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- function max(out, a, b) {
- out[0] = Math.max(a[0], b[0]);
- out[1] = Math.max(a[1], b[1]);
- return out;
- }
- /**
- * Math.round the components of a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to round
- * @returns {vec2} out
- */
- function round(out, a) {
- out[0] = Math.round(a[0]);
- out[1] = Math.round(a[1]);
- return out;
- }
- /**
- * Scales a vec2 by a scalar number
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to scale
- * @param {Number} b amount to scale the vector by
- * @returns {vec2} out
- */
- function scale(out, a, b) {
- out[0] = a[0] * b;
- out[1] = a[1] * b;
- return out;
- }
- /**
- * Adds two vec2's after scaling the second operand by a scalar value
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @param {Number} scale the amount to scale b by before adding
- * @returns {vec2} out
- */
- function scaleAndAdd(out, a, b, scale) {
- out[0] = a[0] + b[0] * scale;
- out[1] = a[1] + b[1] * scale;
- return out;
- }
- /**
- * Calculates the euclidian distance between two vec2's
- *
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {Number} distance between a and b
- */
- function distance(a, b) {
- var x = b[0] - a[0],
- y = b[1] - a[1];
- return Math.sqrt(x * x + y * y);
- }
- /**
- * Calculates the squared euclidian distance between two vec2's
- *
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {Number} squared distance between a and b
- */
- function squaredDistance(a, b) {
- var x = b[0] - a[0],
- y = b[1] - a[1];
- return x * x + y * y;
- }
- /**
- * Calculates the length of a vec2
- *
- * @param {vec2} a vector to calculate length of
- * @returns {Number} length of a
- */
- function length(a) {
- var x = a[0],
- y = a[1];
- return Math.sqrt(x * x + y * y);
- }
- /**
- * Calculates the squared length of a vec2
- *
- * @param {vec2} a vector to calculate squared length of
- * @returns {Number} squared length of a
- */
- function squaredLength(a) {
- var x = a[0],
- y = a[1];
- return x * x + y * y;
- }
- /**
- * Negates the components of a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to negate
- * @returns {vec2} out
- */
- function negate(out, a) {
- out[0] = -a[0];
- out[1] = -a[1];
- return out;
- }
- /**
- * Returns the inverse of the components of a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to invert
- * @returns {vec2} out
- */
- function inverse(out, a) {
- out[0] = 1.0 / a[0];
- out[1] = 1.0 / a[1];
- return out;
- }
- /**
- * Normalize a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to normalize
- * @returns {vec2} out
- */
- function normalize(out, a) {
- var x = a[0],
- y = a[1];
- var len = x * x + y * y;
- if (len > 0) {
- //TODO: evaluate use of glm_invsqrt here?
- len = 1 / Math.sqrt(len);
- out[0] = a[0] * len;
- out[1] = a[1] * len;
- }
- return out;
- }
- /**
- * Calculates the dot product of two vec2's
- *
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {Number} dot product of a and b
- */
- function dot(a, b) {
- return a[0] * b[0] + a[1] * b[1];
- }
- /**
- * Computes the cross product of two vec2's
- * Note that the cross product must by definition produce a 3D vector
- *
- * @param {vec3} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec3} out
- */
- function cross(out, a, b) {
- var z = a[0] * b[1] - a[1] * b[0];
- out[0] = out[1] = 0;
- out[2] = z;
- return out;
- }
- /**
- * Performs a linear interpolation between two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
- * @returns {vec2} out
- */
- function lerp(out, a, b, t) {
- var ax = a[0],
- ay = a[1];
- out[0] = ax + t * (b[0] - ax);
- out[1] = ay + t * (b[1] - ay);
- return out;
- }
- /**
- * Generates a random vector with the given scale
- *
- * @param {vec2} out the receiving vector
- * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
- * @returns {vec2} out
- */
- function random(out, scale) {
- scale = scale || 1.0;
- var r = glMatrix.RANDOM() * 2.0 * Math.PI;
- out[0] = Math.cos(r) * scale;
- out[1] = Math.sin(r) * scale;
- return out;
- }
- /**
- * Transforms the vec2 with a mat2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to transform
- * @param {mat2} m matrix to transform with
- * @returns {vec2} out
- */
- function transformMat2(out, a, m) {
- var x = a[0],
- y = a[1];
- out[0] = m[0] * x + m[2] * y;
- out[1] = m[1] * x + m[3] * y;
- return out;
- }
- /**
- * Transforms the vec2 with a mat2d
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to transform
- * @param {mat2d} m matrix to transform with
- * @returns {vec2} out
- */
- function transformMat2d(out, a, m) {
- var x = a[0],
- y = a[1];
- out[0] = m[0] * x + m[2] * y + m[4];
- out[1] = m[1] * x + m[3] * y + m[5];
- return out;
- }
- /**
- * Transforms the vec2 with a mat3
- * 3rd vector component is implicitly '1'
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to transform
- * @param {mat3} m matrix to transform with
- * @returns {vec2} out
- */
- function transformMat3(out, a, m) {
- var x = a[0],
- y = a[1];
- out[0] = m[0] * x + m[3] * y + m[6];
- out[1] = m[1] * x + m[4] * y + m[7];
- return out;
- }
- /**
- * Transforms the vec2 with a mat4
- * 3rd vector component is implicitly '0'
- * 4th vector component is implicitly '1'
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to transform
- * @param {mat4} m matrix to transform with
- * @returns {vec2} out
- */
- function transformMat4(out, a, m) {
- var x = a[0];
- var y = a[1];
- out[0] = m[0] * x + m[4] * y + m[12];
- out[1] = m[1] * x + m[5] * y + m[13];
- return out;
- }
- /**
- * Rotate a 2D vector
- * @param {vec2} out The receiving vec2
- * @param {vec2} a The vec2 point to rotate
- * @param {vec2} b The origin of the rotation
- * @param {Number} c The angle of rotation
- * @returns {vec2} out
- */
- function rotate(out, a, b, c) {
- //Translate point to the origin
- var p0 = a[0] - b[0],
- p1 = a[1] - b[1],
- sinC = Math.sin(c),
- cosC = Math.cos(c);
- //perform rotation and translate to correct position
- out[0] = p0 * cosC - p1 * sinC + b[0];
- out[1] = p0 * sinC + p1 * cosC + b[1];
- return out;
- }
- /**
- * Get the angle between two 2D vectors
- * @param {vec2} a The first operand
- * @param {vec2} b The second operand
- * @returns {Number} The angle in radians
- */
- function angle(a, b) {
- var x1 = a[0],
- y1 = a[1],
- x2 = b[0],
- y2 = b[1];
- var len1 = x1 * x1 + y1 * y1;
- if (len1 > 0) {
- //TODO: evaluate use of glm_invsqrt here?
- len1 = 1 / Math.sqrt(len1);
- }
- var len2 = x2 * x2 + y2 * y2;
- if (len2 > 0) {
- //TODO: evaluate use of glm_invsqrt here?
- len2 = 1 / Math.sqrt(len2);
- }
- var cosine = (x1 * x2 + y1 * y2) * len1 * len2;
- if (cosine > 1.0) {
- return 0;
- } else if (cosine < -1.0) {
- return Math.PI;
- } else {
- return Math.acos(cosine);
- }
- }
- /**
- * Returns a string representation of a vector
- *
- * @param {vec2} a vector to represent as a string
- * @returns {String} string representation of the vector
- */
- function str(a) {
- return 'vec2(' + a[0] + ', ' + a[1] + ')';
- }
- /**
- * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
- *
- * @param {vec2} a The first vector.
- * @param {vec2} b The second vector.
- * @returns {Boolean} True if the vectors are equal, false otherwise.
- */
- function exactEquals(a, b) {
- return a[0] === b[0] && a[1] === b[1];
- }
- /**
- * Returns whether or not the vectors have approximately the same elements in the same position.
- *
- * @param {vec2} a The first vector.
- * @param {vec2} b The second vector.
- * @returns {Boolean} True if the vectors are equal, false otherwise.
- */
- function equals(a, b) {
- var a0 = a[0],
- a1 = a[1];
- var b0 = b[0],
- b1 = b[1];
- 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));
- }
- /**
- * Alias for {@link vec2.length}
- * @function
- */
- var len = exports.len = length;
- /**
- * Alias for {@link vec2.subtract}
- * @function
- */
- var sub = exports.sub = subtract;
- /**
- * Alias for {@link vec2.multiply}
- * @function
- */
- var mul = exports.mul = multiply;
- /**
- * Alias for {@link vec2.divide}
- * @function
- */
- var div = exports.div = divide;
- /**
- * Alias for {@link vec2.distance}
- * @function
- */
- var dist = exports.dist = distance;
- /**
- * Alias for {@link vec2.squaredDistance}
- * @function
- */
- var sqrDist = exports.sqrDist = squaredDistance;
- /**
- * Alias for {@link vec2.squaredLength}
- * @function
- */
- var sqrLen = exports.sqrLen = squaredLength;
- /**
- * Perform some operation over an array of vec2s.
- *
- * @param {Array} a the array of vectors to iterate over
- * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
- * @param {Number} offset Number of elements to skip at the beginning of the array
- * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
- * @param {Function} fn Function to call for each vector in the array
- * @param {Object} [arg] additional argument to pass to fn
- * @returns {Array} a
- * @function
- */
- var forEach = exports.forEach = function () {
- var vec = create();
- return function (a, stride, offset, count, fn, arg) {
- var i = void 0,
- l = void 0;
- if (!stride) {
- stride = 2;
- }
- if (!offset) {
- offset = 0;
- }
- if (count) {
- l = Math.min(count * stride + offset, a.length);
- } else {
- l = a.length;
- }
- for (i = offset; i < l; i += stride) {
- vec[0] = a[i];vec[1] = a[i + 1];
- fn(vec, vec, arg);
- a[i] = vec[0];a[i + 1] = vec[1];
- }
- return a;
- };
- }();
- /***/ }),
- /* 92 */
- /***/ (function(module, exports, __webpack_require__) {
- var vec3 = __webpack_require__(93);
- module.exports = vec3;
- /***/ }),
- /* 93 */
- /***/ (function(module, exports, __webpack_require__) {
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.forEach = exports.sqrLen = exports.len = exports.sqrDist = exports.dist = exports.div = exports.mul = exports.sub = undefined;
- exports.create = create;
- exports.clone = clone;
- exports.length = length;
- exports.fromValues = fromValues;
- exports.copy = copy;
- exports.set = set;
- exports.add = add;
- exports.subtract = subtract;
- exports.multiply = multiply;
- exports.divide = divide;
- exports.ceil = ceil;
- exports.floor = floor;
- exports.min = min;
- exports.max = max;
- exports.round = round;
- exports.scale = scale;
- exports.scaleAndAdd = scaleAndAdd;
- exports.distance = distance;
- exports.squaredDistance = squaredDistance;
- exports.squaredLength = squaredLength;
- exports.negate = negate;
- exports.inverse = inverse;
- exports.normalize = normalize;
- exports.dot = dot;
- exports.cross = cross;
- exports.lerp = lerp;
- exports.hermite = hermite;
- exports.bezier = bezier;
- exports.random = random;
- exports.transformMat4 = transformMat4;
- exports.transformMat3 = transformMat3;
- exports.transformQuat = transformQuat;
- exports.rotateX = rotateX;
- exports.rotateY = rotateY;
- exports.rotateZ = rotateZ;
- exports.angle = angle;
- exports.str = str;
- exports.exactEquals = exactEquals;
- exports.equals = equals;
- var _common = __webpack_require__(15);
- var glMatrix = _interopRequireWildcard(_common);
- function _interopRequireWildcard(obj) {
- if (obj && obj.__esModule) {
- return obj;
- } else {
- var newObj = {};if (obj != null) {
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
- }
- }newObj.default = obj;return newObj;
- }
- }
- /**
- * 3 Dimensional Vector
- * @module vec3
- */
- /**
- * Creates a new, empty vec3
- *
- * @returns {vec3} a new 3D vector
- */
- function create() {
- var out = new glMatrix.ARRAY_TYPE(3);
- if (glMatrix.ARRAY_TYPE != Float32Array) {
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- }
- return out;
- }
- /**
- * Creates a new vec3 initialized with values from an existing vector
- *
- * @param {vec3} a vector to clone
- * @returns {vec3} a new 3D vector
- */
- function clone(a) {
- var out = new glMatrix.ARRAY_TYPE(3);
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- return out;
- }
- /**
- * Calculates the length of a vec3
- *
- * @param {vec3} a vector to calculate length of
- * @returns {Number} length of a
- */
- function length(a) {
- var x = a[0];
- var y = a[1];
- var z = a[2];
- return Math.sqrt(x * x + y * y + z * z);
- }
- /**
- * Creates a new vec3 initialized with the given values
- *
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @returns {vec3} a new 3D vector
- */
- function fromValues(x, y, z) {
- var out = new glMatrix.ARRAY_TYPE(3);
- out[0] = x;
- out[1] = y;
- out[2] = z;
- return out;
- }
- /**
- * Copy the values from one vec3 to another
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the source vector
- * @returns {vec3} out
- */
- function copy(out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- return out;
- }
- /**
- * Set the components of a vec3 to the given values
- *
- * @param {vec3} out the receiving vector
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @returns {vec3} out
- */
- function set(out, x, y, z) {
- out[0] = x;
- out[1] = y;
- out[2] = z;
- return out;
- }
- /**
- * Adds two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- function add(out, a, b) {
- out[0] = a[0] + b[0];
- out[1] = a[1] + b[1];
- out[2] = a[2] + b[2];
- return out;
- }
- /**
- * Subtracts vector b from vector a
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- function subtract(out, a, b) {
- out[0] = a[0] - b[0];
- out[1] = a[1] - b[1];
- out[2] = a[2] - b[2];
- return out;
- }
- /**
- * Multiplies two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- function multiply(out, a, b) {
- out[0] = a[0] * b[0];
- out[1] = a[1] * b[1];
- out[2] = a[2] * b[2];
- return out;
- }
- /**
- * Divides two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- function divide(out, a, b) {
- out[0] = a[0] / b[0];
- out[1] = a[1] / b[1];
- out[2] = a[2] / b[2];
- return out;
- }
- /**
- * Math.ceil the components of a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to ceil
- * @returns {vec3} out
- */
- function ceil(out, a) {
- out[0] = Math.ceil(a[0]);
- out[1] = Math.ceil(a[1]);
- out[2] = Math.ceil(a[2]);
- return out;
- }
- /**
- * Math.floor the components of a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to floor
- * @returns {vec3} out
- */
- function floor(out, a) {
- out[0] = Math.floor(a[0]);
- out[1] = Math.floor(a[1]);
- out[2] = Math.floor(a[2]);
- return out;
- }
- /**
- * Returns the minimum of two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- function min(out, a, b) {
- out[0] = Math.min(a[0], b[0]);
- out[1] = Math.min(a[1], b[1]);
- out[2] = Math.min(a[2], b[2]);
- return out;
- }
- /**
- * Returns the maximum of two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- function max(out, a, b) {
- out[0] = Math.max(a[0], b[0]);
- out[1] = Math.max(a[1], b[1]);
- out[2] = Math.max(a[2], b[2]);
- return out;
- }
- /**
- * Math.round the components of a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to round
- * @returns {vec3} out
- */
- function round(out, a) {
- out[0] = Math.round(a[0]);
- out[1] = Math.round(a[1]);
- out[2] = Math.round(a[2]);
- return out;
- }
- /**
- * Scales a vec3 by a scalar number
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the vector to scale
- * @param {Number} b amount to scale the vector by
- * @returns {vec3} out
- */
- function scale(out, a, b) {
- out[0] = a[0] * b;
- out[1] = a[1] * b;
- out[2] = a[2] * b;
- return out;
- }
- /**
- * Adds two vec3's after scaling the second operand by a scalar value
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @param {Number} scale the amount to scale b by before adding
- * @returns {vec3} out
- */
- function scaleAndAdd(out, a, b, scale) {
- out[0] = a[0] + b[0] * scale;
- out[1] = a[1] + b[1] * scale;
- out[2] = a[2] + b[2] * scale;
- return out;
- }
- /**
- * Calculates the euclidian distance between two vec3's
- *
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {Number} distance between a and b
- */
- function distance(a, b) {
- var x = b[0] - a[0];
- var y = b[1] - a[1];
- var z = b[2] - a[2];
- return Math.sqrt(x * x + y * y + z * z);
- }
- /**
- * Calculates the squared euclidian distance between two vec3's
- *
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {Number} squared distance between a and b
- */
- function squaredDistance(a, b) {
- var x = b[0] - a[0];
- var y = b[1] - a[1];
- var z = b[2] - a[2];
- return x * x + y * y + z * z;
- }
- /**
- * Calculates the squared length of a vec3
- *
- * @param {vec3} a vector to calculate squared length of
- * @returns {Number} squared length of a
- */
- function squaredLength(a) {
- var x = a[0];
- var y = a[1];
- var z = a[2];
- return x * x + y * y + z * z;
- }
- /**
- * Negates the components of a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to negate
- * @returns {vec3} out
- */
- function negate(out, a) {
- out[0] = -a[0];
- out[1] = -a[1];
- out[2] = -a[2];
- return out;
- }
- /**
- * Returns the inverse of the components of a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to invert
- * @returns {vec3} out
- */
- function inverse(out, a) {
- out[0] = 1.0 / a[0];
- out[1] = 1.0 / a[1];
- out[2] = 1.0 / a[2];
- return out;
- }
- /**
- * Normalize a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to normalize
- * @returns {vec3} out
- */
- function normalize(out, a) {
- var x = a[0];
- var y = a[1];
- var z = a[2];
- var len = x * x + y * y + z * z;
- if (len > 0) {
- //TODO: evaluate use of glm_invsqrt here?
- len = 1 / Math.sqrt(len);
- out[0] = a[0] * len;
- out[1] = a[1] * len;
- out[2] = a[2] * len;
- }
- return out;
- }
- /**
- * Calculates the dot product of two vec3's
- *
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {Number} dot product of a and b
- */
- function dot(a, b) {
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
- }
- /**
- * Computes the cross product of two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- function cross(out, a, b) {
- var ax = a[0],
- ay = a[1],
- az = a[2];
- var bx = b[0],
- by = b[1],
- bz = b[2];
- out[0] = ay * bz - az * by;
- out[1] = az * bx - ax * bz;
- out[2] = ax * by - ay * bx;
- return out;
- }
- /**
- * Performs a linear interpolation between two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
- * @returns {vec3} out
- */
- function lerp(out, a, b, t) {
- var ax = a[0];
- var ay = a[1];
- var az = a[2];
- out[0] = ax + t * (b[0] - ax);
- out[1] = ay + t * (b[1] - ay);
- out[2] = az + t * (b[2] - az);
- return out;
- }
- /**
- * Performs a hermite interpolation with two control points
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @param {vec3} c the third operand
- * @param {vec3} d the fourth operand
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
- * @returns {vec3} out
- */
- function hermite(out, a, b, c, d, t) {
- var factorTimes2 = t * t;
- var factor1 = factorTimes2 * (2 * t - 3) + 1;
- var factor2 = factorTimes2 * (t - 2) + t;
- var factor3 = factorTimes2 * (t - 1);
- var factor4 = factorTimes2 * (3 - 2 * t);
- out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
- out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
- out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
- return out;
- }
- /**
- * Performs a bezier interpolation with two control points
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @param {vec3} c the third operand
- * @param {vec3} d the fourth operand
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
- * @returns {vec3} out
- */
- function bezier(out, a, b, c, d, t) {
- var inverseFactor = 1 - t;
- var inverseFactorTimesTwo = inverseFactor * inverseFactor;
- var factorTimes2 = t * t;
- var factor1 = inverseFactorTimesTwo * inverseFactor;
- var factor2 = 3 * t * inverseFactorTimesTwo;
- var factor3 = 3 * factorTimes2 * inverseFactor;
- var factor4 = factorTimes2 * t;
- out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
- out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
- out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
- return out;
- }
- /**
- * Generates a random vector with the given scale
- *
- * @param {vec3} out the receiving vector
- * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
- * @returns {vec3} out
- */
- function random(out, scale) {
- scale = scale || 1.0;
- var r = glMatrix.RANDOM() * 2.0 * Math.PI;
- var z = glMatrix.RANDOM() * 2.0 - 1.0;
- var zScale = Math.sqrt(1.0 - z * z) * scale;
- out[0] = Math.cos(r) * zScale;
- out[1] = Math.sin(r) * zScale;
- out[2] = z * scale;
- return out;
- }
- /**
- * Transforms the vec3 with a mat4.
- * 4th vector component is implicitly '1'
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the vector to transform
- * @param {mat4} m matrix to transform with
- * @returns {vec3} out
- */
- function transformMat4(out, a, m) {
- var x = a[0],
- y = a[1],
- z = a[2];
- var w = m[3] * x + m[7] * y + m[11] * z + m[15];
- w = w || 1.0;
- out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
- out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
- out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
- return out;
- }
- /**
- * Transforms the vec3 with a mat3.
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the vector to transform
- * @param {mat3} m the 3x3 matrix to transform with
- * @returns {vec3} out
- */
- function transformMat3(out, a, m) {
- var x = a[0],
- y = a[1],
- z = a[2];
- out[0] = x * m[0] + y * m[3] + z * m[6];
- out[1] = x * m[1] + y * m[4] + z * m[7];
- out[2] = x * m[2] + y * m[5] + z * m[8];
- return out;
- }
- /**
- * Transforms the vec3 with a quat
- * Can also be used for dual quaternions. (Multiply it with the real part)
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the vector to transform
- * @param {quat} q quaternion to transform with
- * @returns {vec3} out
- */
- function transformQuat(out, a, q) {
- // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed
- var qx = q[0],
- qy = q[1],
- qz = q[2],
- qw = q[3];
- var x = a[0],
- y = a[1],
- z = a[2];
- // var qvec = [qx, qy, qz];
- // var uv = vec3.cross([], qvec, a);
- var uvx = qy * z - qz * y,
- uvy = qz * x - qx * z,
- uvz = qx * y - qy * x;
- // var uuv = vec3.cross([], qvec, uv);
- var uuvx = qy * uvz - qz * uvy,
- uuvy = qz * uvx - qx * uvz,
- uuvz = qx * uvy - qy * uvx;
- // vec3.scale(uv, uv, 2 * w);
- var w2 = qw * 2;
- uvx *= w2;
- uvy *= w2;
- uvz *= w2;
- // vec3.scale(uuv, uuv, 2);
- uuvx *= 2;
- uuvy *= 2;
- uuvz *= 2;
- // return vec3.add(out, a, vec3.add(out, uv, uuv));
- out[0] = x + uvx + uuvx;
- out[1] = y + uvy + uuvy;
- out[2] = z + uvz + uuvz;
- return out;
- }
- /**
- * Rotate a 3D vector around the x-axis
- * @param {vec3} out The receiving vec3
- * @param {vec3} a The vec3 point to rotate
- * @param {vec3} b The origin of the rotation
- * @param {Number} c The angle of rotation
- * @returns {vec3} out
- */
- function rotateX(out, a, b, c) {
- var p = [],
- r = [];
- //Translate point to the origin
- p[0] = a[0] - b[0];
- p[1] = a[1] - b[1];
- p[2] = a[2] - b[2];
- //perform rotation
- r[0] = p[0];
- r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
- r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
- //translate to correct position
- out[0] = r[0] + b[0];
- out[1] = r[1] + b[1];
- out[2] = r[2] + b[2];
- return out;
- }
- /**
- * Rotate a 3D vector around the y-axis
- * @param {vec3} out The receiving vec3
- * @param {vec3} a The vec3 point to rotate
- * @param {vec3} b The origin of the rotation
- * @param {Number} c The angle of rotation
- * @returns {vec3} out
- */
- function rotateY(out, a, b, c) {
- var p = [],
- r = [];
- //Translate point to the origin
- p[0] = a[0] - b[0];
- p[1] = a[1] - b[1];
- p[2] = a[2] - b[2];
- //perform rotation
- r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
- r[1] = p[1];
- r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
- //translate to correct position
- out[0] = r[0] + b[0];
- out[1] = r[1] + b[1];
- out[2] = r[2] + b[2];
- return out;
- }
- /**
- * Rotate a 3D vector around the z-axis
- * @param {vec3} out The receiving vec3
- * @param {vec3} a The vec3 point to rotate
- * @param {vec3} b The origin of the rotation
- * @param {Number} c The angle of rotation
- * @returns {vec3} out
- */
- function rotateZ(out, a, b, c) {
- var p = [],
- r = [];
- //Translate point to the origin
- p[0] = a[0] - b[0];
- p[1] = a[1] - b[1];
- p[2] = a[2] - b[2];
- //perform rotation
- r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
- r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
- r[2] = p[2];
- //translate to correct position
- out[0] = r[0] + b[0];
- out[1] = r[1] + b[1];
- out[2] = r[2] + b[2];
- return out;
- }
- /**
- * Get the angle between two 3D vectors
- * @param {vec3} a The first operand
- * @param {vec3} b The second operand
- * @returns {Number} The angle in radians
- */
- function angle(a, b) {
- var tempA = fromValues(a[0], a[1], a[2]);
- var tempB = fromValues(b[0], b[1], b[2]);
- normalize(tempA, tempA);
- normalize(tempB, tempB);
- var cosine = dot(tempA, tempB);
- if (cosine > 1.0) {
- return 0;
- } else if (cosine < -1.0) {
- return Math.PI;
- } else {
- return Math.acos(cosine);
- }
- }
- /**
- * Returns a string representation of a vector
- *
- * @param {vec3} a vector to represent as a string
- * @returns {String} string representation of the vector
- */
- function str(a) {
- return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
- }
- /**
- * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
- *
- * @param {vec3} a The first vector.
- * @param {vec3} b The second vector.
- * @returns {Boolean} True if the vectors are equal, false otherwise.
- */
- function exactEquals(a, b) {
- return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
- }
- /**
- * Returns whether or not the vectors have approximately the same elements in the same position.
- *
- * @param {vec3} a The first vector.
- * @param {vec3} b The second vector.
- * @returns {Boolean} True if the vectors are equal, false otherwise.
- */
- function equals(a, b) {
- var a0 = a[0],
- a1 = a[1],
- a2 = a[2];
- var b0 = b[0],
- b1 = b[1],
- b2 = b[2];
- 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));
- }
- /**
- * Alias for {@link vec3.subtract}
- * @function
- */
- var sub = exports.sub = subtract;
- /**
- * Alias for {@link vec3.multiply}
- * @function
- */
- var mul = exports.mul = multiply;
- /**
- * Alias for {@link vec3.divide}
- * @function
- */
- var div = exports.div = divide;
- /**
- * Alias for {@link vec3.distance}
- * @function
- */
- var dist = exports.dist = distance;
- /**
- * Alias for {@link vec3.squaredDistance}
- * @function
- */
- var sqrDist = exports.sqrDist = squaredDistance;
- /**
- * Alias for {@link vec3.length}
- * @function
- */
- var len = exports.len = length;
- /**
- * Alias for {@link vec3.squaredLength}
- * @function
- */
- var sqrLen = exports.sqrLen = squaredLength;
- /**
- * Perform some operation over an array of vec3s.
- *
- * @param {Array} a the array of vectors to iterate over
- * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
- * @param {Number} offset Number of elements to skip at the beginning of the array
- * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
- * @param {Function} fn Function to call for each vector in the array
- * @param {Object} [arg] additional argument to pass to fn
- * @returns {Array} a
- * @function
- */
- var forEach = exports.forEach = function () {
- var vec = create();
- return function (a, stride, offset, count, fn, arg) {
- var i = void 0,
- l = void 0;
- if (!stride) {
- stride = 3;
- }
- if (!offset) {
- offset = 0;
- }
- if (count) {
- l = Math.min(count * stride + offset, a.length);
- } else {
- l = a.length;
- }
- for (i = offset; i < l; i += stride) {
- vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];
- fn(vec, vec, arg);
- a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];
- }
- return a;
- };
- }();
- /***/ }),
- /* 94 */
- /***/ (function(module, exports, __webpack_require__) {
- var clone = __webpack_require__(24);
- var each = __webpack_require__(0);
- var mat3 = __webpack_require__(23);
- module.exports = function transform(m, ts) {
- m = clone(m);
- each(ts, function (t) {
- switch (t[0]) {
- case 't':
- mat3.translate(m, m, [t[1], t[2]]);
- break;
- case 's':
- mat3.scale(m, m, [t[1], t[2]]);
- break;
- case 'r':
- mat3.rotate(m, m, t[1]);
- break;
- case 'm':
- mat3.multiply(m, m, t[1]);
- break;
- default:
- return false;
- }
- });
- return m;
- };
- /***/ }),
- /* 95 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = {
- forIn: __webpack_require__(96),
- has: __webpack_require__(25),
- hasKey: __webpack_require__(97),
- hasValue: __webpack_require__(98),
- keys: __webpack_require__(18),
- isMatch: __webpack_require__(17),
- values: __webpack_require__(26)
- };
- /***/ }),
- /* 96 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(0);
- /***/ }),
- /* 97 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(25);
- /***/ }),
- /* 98 */
- /***/ (function(module, exports, __webpack_require__) {
- var contains = __webpack_require__(9);
- var values = __webpack_require__(26);
- module.exports = function (obj, value) {
- return contains(values(obj), value);
- };
- /***/ }),
- /* 99 */
- /***/ (function(module, exports, __webpack_require__) {
- var pathIntersection = __webpack_require__(100);
- var path2absolute = __webpack_require__(30);
- var path2curve = __webpack_require__(29);
- var catmullRom2Bezier = __webpack_require__(32);
- module.exports = {
- catmullRom2Bezier: catmullRom2Bezier,
- catmullRomToBezier: catmullRom2Bezier,
- fillPath: __webpack_require__(101),
- fillPathByDiff: __webpack_require__(102),
- formatPath: __webpack_require__(104),
- intersection: pathIntersection,
- pathIntersection: pathIntersection,
- parsePathArray: __webpack_require__(28),
- parsePathString: __webpack_require__(31),
- pathToAbsolute: path2absolute,
- path2absolute: path2absolute,
- pathTocurve: path2curve,
- path2curve: path2curve,
- rectPath: __webpack_require__(27)
- };
- /***/ }),
- /* 100 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(1);
- var rectPath = __webpack_require__(27);
- var pathTocurve = __webpack_require__(29);
- var base3 = function base3(t, p1, p2, p3, p4) {
- var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
- var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
- return t * t2 - 3 * p1 + 3 * p2;
- };
- var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
- if (z === null) {
- z = 1;
- }
- z = z > 1 ? 1 : z < 0 ? 0 : z;
- var z2 = z / 2;
- var n = 12;
- 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];
- 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];
- var sum = 0;
- for (var i = 0; i < n; i++) {
- var ct = z2 * Tvalues[i] + z2;
- var xbase = base3(ct, x1, x2, x3, x4);
- var ybase = base3(ct, y1, y2, y3, y4);
- var comb = xbase * xbase + ybase * ybase;
- sum += Cvalues[i] * Math.sqrt(comb);
- }
- return z2 * sum;
- };
- var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
- var tvalues = [];
- var bounds = [[], []];
- var a = void 0;
- var b = void 0;
- var c = void 0;
- var t = void 0;
- for (var i = 0; i < 2; ++i) {
- if (i === 0) {
- b = 6 * x0 - 12 * x1 + 6 * x2;
- a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
- c = 3 * x1 - 3 * x0;
- } else {
- b = 6 * y0 - 12 * y1 + 6 * y2;
- a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
- c = 3 * y1 - 3 * y0;
- }
- if (Math.abs(a) < 1e-12) {
- if (Math.abs(b) < 1e-12) {
- continue;
- }
- t = -c / b;
- if (t > 0 && t < 1) {
- tvalues.push(t);
- }
- continue;
- }
- var b2ac = b * b - 4 * c * a;
- var sqrtb2ac = Math.sqrt(b2ac);
- if (b2ac < 0) {
- continue;
- }
- var t1 = (-b + sqrtb2ac) / (2 * a);
- if (t1 > 0 && t1 < 1) {
- tvalues.push(t1);
- }
- var t2 = (-b - sqrtb2ac) / (2 * a);
- if (t2 > 0 && t2 < 1) {
- tvalues.push(t2);
- }
- }
- var j = tvalues.length;
- var jlen = j;
- var mt = void 0;
- while (j--) {
- t = tvalues[j];
- mt = 1 - t;
- bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
- bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
- }
- bounds[0][jlen] = x0;
- bounds[1][jlen] = y0;
- bounds[0][jlen + 1] = x3;
- bounds[1][jlen + 1] = y3;
- bounds[0].length = bounds[1].length = jlen + 2;
- return {
- min: {
- x: Math.min.apply(0, bounds[0]),
- y: Math.min.apply(0, bounds[1])
- },
- max: {
- x: Math.max.apply(0, bounds[0]),
- y: Math.max.apply(0, bounds[1])
- }
- };
- };
- var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
- 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)) {
- return;
- }
- var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
- var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
- var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
- if (!denominator) {
- return;
- }
- var px = nx / denominator;
- var py = ny / denominator;
- var px2 = +px.toFixed(2);
- var py2 = +py.toFixed(2);
- 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)) {
- return;
- }
- return {
- x: px,
- y: py
- };
- };
- var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) {
- return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
- };
- var box = function box(x, y, width, height) {
- if (x === null) {
- x = y = width = height = 0;
- }
- if (y === null) {
- y = x.y;
- width = x.width;
- height = x.height;
- x = x.x;
- }
- return {
- x: x,
- y: y,
- width: width,
- w: width,
- height: height,
- h: height,
- x2: x + width,
- y2: y + height,
- cx: x + width / 2,
- cy: y + height / 2,
- r1: Math.min(width, height) / 2,
- r2: Math.max(width, height) / 2,
- r0: Math.sqrt(width * width + height * height) / 2,
- path: rectPath(x, y, width, height),
- vb: [x, y, width, height].join(' ')
- };
- };
- var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) {
- bbox1 = box(bbox1);
- bbox2 = box(bbox2);
- 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);
- };
- var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
- if (!isArray(p1x)) {
- p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
- }
- var bbox = curveDim.apply(null, p1x);
- return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
- };
- var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
- var t1 = 1 - t;
- var t13 = Math.pow(t1, 3);
- var t12 = Math.pow(t1, 2);
- var t2 = t * t;
- var t3 = t2 * t;
- var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x;
- var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y;
- var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x);
- var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y);
- var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x);
- var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y);
- var ax = t1 * p1x + t * c1x;
- var ay = t1 * p1y + t * c1y;
- var cx = t1 * c2x + t * p2x;
- var cy = t1 * c2y + t * p2y;
- var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI;
- // (mx > nx || my < ny) && (alpha += 180);
- return {
- x: x,
- y: y,
- m: {
- x: mx,
- y: my
- },
- n: {
- x: nx,
- y: ny
- },
- start: {
- x: ax,
- y: ay
- },
- end: {
- x: cx,
- y: cy
- },
- alpha: alpha
- };
- };
- var interHelper = function interHelper(bez1, bez2, justCount) {
- var bbox1 = bezierBBox(bez1);
- var bbox2 = bezierBBox(bez2);
- if (!isBBoxIntersect(bbox1, bbox2)) {
- return justCount ? 0 : [];
- }
- var l1 = bezlen.apply(0, bez1);
- var l2 = bezlen.apply(0, bez2);
- var n1 = ~~(l1 / 8);
- var n2 = ~~(l2 / 8);
- var dots1 = [];
- var dots2 = [];
- var xy = {};
- var res = justCount ? 0 : [];
- for (var i = 0; i < n1 + 1; i++) {
- var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));
- dots1.push({
- x: d.x,
- y: d.y,
- t: i / n1
- });
- }
- for (var _i = 0; _i < n2 + 1; _i++) {
- var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
- dots2.push({
- x: _d.x,
- y: _d.y,
- t: _i / n2
- });
- }
- for (var _i2 = 0; _i2 < n1; _i2++) {
- for (var j = 0; j < n2; j++) {
- var di = dots1[_i2];
- var di1 = dots1[_i2 + 1];
- var dj = dots2[j];
- var dj1 = dots2[j + 1];
- var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x';
- var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x';
- var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
- if (is) {
- if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {
- continue;
- }
- xy[is.x.toFixed(4)] = is.y.toFixed(4);
- var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
- var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
- if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
- if (justCount) {
- res++;
- } else {
- res.push({
- x: is.x,
- y: is.y,
- t1: t1,
- t2: t2
- });
- }
- }
- }
- }
- }
- return res;
- };
- var interPathHelper = function interPathHelper(path1, path2, justCount) {
- path1 = pathTocurve(path1);
- path2 = pathTocurve(path2);
- var x1 = void 0;
- var y1 = void 0;
- var x2 = void 0;
- var y2 = void 0;
- var x1m = void 0;
- var y1m = void 0;
- var x2m = void 0;
- var y2m = void 0;
- var bez1 = void 0;
- var bez2 = void 0;
- var res = justCount ? 0 : [];
- for (var i = 0, ii = path1.length; i < ii; i++) {
- var pi = path1[i];
- if (pi[0] === 'M') {
- x1 = x1m = pi[1];
- y1 = y1m = pi[2];
- } else {
- if (pi[0] === 'C') {
- bez1 = [x1, y1].concat(pi.slice(1));
- x1 = bez1[6];
- y1 = bez1[7];
- } else {
- bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
- x1 = x1m;
- y1 = y1m;
- }
- for (var j = 0, jj = path2.length; j < jj; j++) {
- var pj = path2[j];
- if (pj[0] === 'M') {
- x2 = x2m = pj[1];
- y2 = y2m = pj[2];
- } else {
- if (pj[0] === 'C') {
- bez2 = [x2, y2].concat(pj.slice(1));
- x2 = bez2[6];
- y2 = bez2[7];
- } else {
- bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
- x2 = x2m;
- y2 = y2m;
- }
- var intr = interHelper(bez1, bez2, justCount);
- if (justCount) {
- res += intr;
- } else {
- for (var k = 0, kk = intr.length; k < kk; k++) {
- intr[k].segment1 = i;
- intr[k].segment2 = j;
- intr[k].bez1 = bez1;
- intr[k].bez2 = bez2;
- }
- res = res.concat(intr);
- }
- }
- }
- }
- }
- return res;
- };
- module.exports = function pathIntersection(path1, path2) {
- return interPathHelper(path1, path2);
- };
- /***/ }),
- /* 101 */
- /***/ (function(module, exports) {
- function decasteljau(points, t) {
- var left = [];
- var right = [];
- function recurse(points, t) {
- if (points.length === 1) {
- left.push(points[0]);
- right.push(points[0]);
- } else {
- var middlePoints = [];
- for (var i = 0; i < points.length - 1; i++) {
- if (i === 0) {
- left.push(points[0]);
- }
- if (i === points.length - 2) {
- right.push(points[i + 1]);
- }
- middlePoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]];
- }
- recurse(middlePoints, t);
- }
- }
- if (points.length) {
- recurse(points, t);
- }
- return { left: left, right: right.reverse() };
- }
- function splitCurve(start, end, count) {
- var points = [[start[1], start[2]]];
- count = count || 2;
- var segments = [];
- if (end[0] === 'A') {
- points.push(end[6]);
- points.push(end[7]);
- } else if (end[0] === 'C') {
- points.push([end[1], end[2]]);
- points.push([end[3], end[4]]);
- points.push([end[5], end[6]]);
- } else if (end[0] === 'S' || end[0] === 'Q') {
- points.push([end[1], end[2]]);
- points.push([end[3], end[4]]);
- } else {
- points.push([end[1], end[2]]);
- }
- var leftSegments = points;
- var t = 1 / count;
- for (var i = 0; i < count - 1; i++) {
- var rt = t / (1 - t * i);
- var split = decasteljau(leftSegments, rt);
- segments.push(split.left);
- leftSegments = split.right;
- }
- segments.push(leftSegments);
- var result = segments.map(function (segment) {
- var cmd = [];
- if (segment.length === 4) {
- cmd.push('C');
- cmd = cmd.concat(segment[2]);
- }
- if (segment.length >= 3) {
- if (segment.length === 3) {
- cmd.push('Q');
- }
- cmd = cmd.concat(segment[1]);
- }
- if (segment.length === 2) {
- cmd.push('L');
- }
- cmd = cmd.concat(segment[segment.length - 1]);
- return cmd;
- });
- return result;
- }
- function splitSegment(start, end, count) {
- if (count === 1) {
- return [[].concat(start)];
- }
- var segments = [];
- if (end[0] === 'L' || end[0] === 'C' || end[0] === 'Q') {
- segments = segments.concat(splitCurve(start, end, count));
- } else {
- var temp = [].concat(start);
- if (temp[0] === 'M') {
- temp[0] = 'L';
- }
- for (var i = 0; i <= count - 1; i++) {
- segments.push(temp);
- }
- }
- return segments;
- }
- module.exports = function fillPath(source, target) {
- if (source.length === 1) {
- return source;
- }
- var sourceLen = source.length - 1;
- var targetLen = target.length - 1;
- var ratio = sourceLen / targetLen;
- var segmentsToFill = [];
- if (source.length === 1 && source[0][0] === 'M') {
- for (var i = 0; i < targetLen - sourceLen; i++) {
- source.push(source[0]);
- }
- return source;
- }
- for (var _i = 0; _i < targetLen; _i++) {
- var index = Math.floor(ratio * _i);
- segmentsToFill[index] = (segmentsToFill[index] || 0) + 1;
- }
- var filled = segmentsToFill.reduce(function (filled, count, i) {
- if (i === sourceLen) {
- return filled.concat(source[sourceLen]);
- }
- return filled.concat(splitSegment(source[i], source[i + 1], count));
- }, []);
- filled.unshift(source[0]);
- if (target[targetLen] === 'Z' || target[targetLen] === 'z') {
- filled.push('Z');
- }
- return filled;
- };
- /***/ }),
- /* 102 */
- /***/ (function(module, exports, __webpack_require__) {
- var isEqual = __webpack_require__(103);
- function getMinDiff(del, add, modify) {
- var type = null;
- var min = modify;
- if (add < min) {
- min = add;
- type = 'add';
- }
- if (del < min) {
- min = del;
- type = 'del';
- }
- return {
- type: type,
- min: min
- };
- }
- /*
- * https://en.wikipedia.org/wiki/Levenshtein_distance
- * 计算两条path的编辑距离
- */
- var levenshteinDistance = function levenshteinDistance(source, target) {
- var sourceLen = source.length;
- var targetLen = target.length;
- var sourceSegment = void 0,
- targetSegment = void 0;
- var temp = 0;
- if (sourceLen === 0 || targetLen === 0) {
- return null;
- }
- var dist = [];
- for (var i = 0; i <= sourceLen; i++) {
- dist[i] = [];
- dist[i][0] = { min: i };
- }
- for (var j = 0; j <= targetLen; j++) {
- dist[0][j] = { min: j };
- }
- for (var _i = 1; _i <= sourceLen; _i++) {
- sourceSegment = source[_i - 1];
- for (var _j = 1; _j <= targetLen; _j++) {
- targetSegment = target[_j - 1];
- if (isEqual(sourceSegment, targetSegment)) {
- temp = 0;
- } else {
- temp = 1;
- }
- var del = dist[_i - 1][_j].min + 1;
- var add = dist[_i][_j - 1].min + 1;
- var modify = dist[_i - 1][_j - 1].min + temp;
- dist[_i][_j] = getMinDiff(del, add, modify);
- }
- }
- return dist;
- };
- module.exports = function fillPathByDiff(source, target) {
- var diffMatrix = levenshteinDistance(source, target);
- var sourceLen = source.length;
- var targetLen = target.length;
- var changes = [];
- var index = 1;
- var minPos = 1;
- // 如果source和target不是完全不相等
- if (diffMatrix[sourceLen][targetLen] !== sourceLen) {
- // 获取从source到target所需改动
- for (var i = 1; i <= sourceLen; i++) {
- var min = diffMatrix[i][i].min;
- minPos = i;
- for (var j = index; j <= targetLen; j++) {
- if (diffMatrix[i][j].min < min) {
- min = diffMatrix[i][j].min;
- minPos = j;
- }
- }
- index = minPos;
- if (diffMatrix[i][index].type) {
- changes.push({ index: i - 1, type: diffMatrix[i][index].type });
- }
- }
- // 对source进行增删path
- for (var _i2 = changes.length - 1; _i2 >= 0; _i2--) {
- index = changes[_i2].index;
- if (changes[_i2].type === 'add') {
- source.splice(index, 0, [].concat(source[index]));
- } else {
- source.splice(index, 1);
- }
- }
- }
- // source尾部补齐
- sourceLen = source.length;
- if (sourceLen < targetLen) {
- for (var _i3 = 0; _i3 < targetLen - sourceLen; _i3++) {
- if (source[sourceLen - 1][0] === 'z' || source[sourceLen - 1][0] === 'Z') {
- source.splice(sourceLen - 2, 0, source[sourceLen - 2]);
- } else {
- source.push(source[sourceLen - 1]);
- }
- }
- }
- return source;
- };
- /***/ }),
- /* 103 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- module.exports = function isEqual(obj1, obj2) {
- if (obj1.length !== obj2.length) {
- return false;
- }
- var result = true;
- each(obj1, function (item, i) {
- if (item !== obj2[i]) {
- result = false;
- return false;
- }
- });
- return result;
- };
- /***/ }),
- /* 104 */
- /***/ (function(module, exports) {
- /*
- * 抽取pathSegment中的关键点
- * M,L,A,Q,H,V一个端点
- * Q, S抽取一个端点,一个控制点
- * C抽取一个端点,两个控制点
- */
- function _getSegmentPoints(segment) {
- var points = [];
- switch (segment[0]) {
- case 'M':
- points.push([segment[1], segment[2]]);
- break;
- case 'L':
- points.push([segment[1], segment[2]]);
- break;
- case 'A':
- points.push([segment[6], segment[7]]);
- break;
- case 'Q':
- points.push([segment[3], segment[4]]);
- points.push([segment[1], segment[2]]);
- break;
- case 'T':
- points.push([segment[1], segment[2]]);
- break;
- case 'C':
- points.push([segment[5], segment[6]]);
- points.push([segment[1], segment[2]]);
- points.push([segment[3], segment[4]]);
- break;
- case 'S':
- points.push([segment[3], segment[4]]);
- points.push([segment[1], segment[2]]);
- break;
- case 'H':
- points.push([segment[1], segment[1]]);
- break;
- case 'V':
- points.push([segment[1], segment[1]]);
- break;
- default:
- }
- return points;
- }
- // 将两个点均分成count个点
- function _splitPoints(points, former, count) {
- var result = [].concat(points);
- var index = void 0;
- var t = 1 / (count + 1);
- var formerEnd = _getSegmentPoints(former)[0];
- for (var i = 1; i <= count; i++) {
- t *= i;
- index = Math.floor(points.length * t);
- if (index === 0) {
- result.unshift([formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);
- } else {
- result.splice(index, 0, [formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);
- }
- }
- return result;
- }
- module.exports = function formatPath(fromPath, toPath) {
- if (fromPath.length <= 1) {
- return fromPath;
- }
- var points = void 0;
- for (var i = 0; i < toPath.length; i++) {
- if (fromPath[i][0] !== toPath[i][0]) {
- // 获取fromPath的pathSegment的端点,根据toPath的指令对其改造
- points = _getSegmentPoints(fromPath[i]);
- switch (toPath[i][0]) {
- case 'M':
- fromPath[i] = ['M'].concat(points[0]);
- break;
- case 'L':
- fromPath[i] = ['L'].concat(points[0]);
- break;
- case 'A':
- fromPath[i] = [].concat(toPath[i]);
- fromPath[i][6] = points[0][0];
- fromPath[i][7] = points[0][1];
- break;
- case 'Q':
- if (points.length < 2) {
- if (i > 0) {
- points = _splitPoints(points, fromPath[i - 1], 1);
- } else {
- fromPath[i] = toPath[i];
- break;
- }
- }
- fromPath[i] = ['Q'].concat(points.reduce(function (arr, i) {
- return arr.concat(i);
- }, []));
- break;
- case 'T':
- fromPath[i] = ['T'].concat(points[0]);
- break;
- case 'C':
- if (points.length < 3) {
- if (i > 0) {
- points = _splitPoints(points, fromPath[i - 1], 2);
- } else {
- fromPath[i] = toPath[i];
- break;
- }
- }
- fromPath[i] = ['C'].concat(points.reduce(function (arr, i) {
- return arr.concat(i);
- }, []));
- break;
- case 'S':
- if (points.length < 2) {
- if (i > 0) {
- points = _splitPoints(points, fromPath[i - 1], 1);
- } else {
- fromPath[i] = toPath[i];
- break;
- }
- }
- fromPath[i] = ['S'].concat(points.reduce(function (arr, i) {
- return arr.concat(i);
- }, []));
- break;
- default:
- fromPath[i] = toPath[i];
- }
- }
- }
- return fromPath;
- };
- /***/ }),
- /* 105 */
- /***/ (function(module, exports, __webpack_require__) {
- var strUtil = {
- lc: __webpack_require__(106),
- lowerCase: __webpack_require__(33),
- lowerFirst: __webpack_require__(107),
- substitute: __webpack_require__(108),
- uc: __webpack_require__(109),
- upperCase: __webpack_require__(34),
- upperFirst: __webpack_require__(110)
- };
- module.exports = strUtil;
- /***/ }),
- /* 106 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(33);
- /***/ }),
- /* 107 */
- /***/ (function(module, exports, __webpack_require__) {
- var toString = __webpack_require__(8);
- var lowerFirst = function lowerFirst(value) {
- var str = toString(value);
- return str.charAt(0).toLowerCase() + str.substring(1);
- };
- module.exports = lowerFirst;
- /***/ }),
- /* 108 */
- /***/ (function(module, exports) {
- var substitute = function substitute(str, o) {
- if (!str || !o) {
- return str;
- }
- return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
- if (match.charAt(0) === '\\') {
- return match.slice(1);
- }
- return o[name] === undefined ? '' : o[name];
- });
- };
- module.exports = substitute;
- /***/ }),
- /* 109 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(34);
- /***/ }),
- /* 110 */
- /***/ (function(module, exports, __webpack_require__) {
- var toString = __webpack_require__(8);
- var upperFirst = function upperFirst(value) {
- var str = toString(value);
- return str.charAt(0).toUpperCase() + str.substring(1);
- };
- module.exports = upperFirst;
- /***/ }),
- /* 111 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(4);
- var checkType = {
- getType: __webpack_require__(35),
- isArray: __webpack_require__(1),
- isArrayLike: __webpack_require__(3),
- isBoolean: __webpack_require__(112),
- isFunction: __webpack_require__(2),
- isNil: __webpack_require__(5),
- isNull: __webpack_require__(113),
- isNumber: __webpack_require__(6),
- isObject: __webpack_require__(16),
- isObjectLike: __webpack_require__(13),
- isPlainObject: __webpack_require__(7),
- isPrototype: __webpack_require__(36),
- isType: isType,
- isUndefined: __webpack_require__(114),
- isString: __webpack_require__(10),
- isRegExp: __webpack_require__(115)
- };
- ['Arguments', 'Date', 'Error'].forEach(function (type) {
- checkType['is' + type] = function (value) {
- return isType(value, type);
- };
- });
- module.exports = checkType;
- /***/ }),
- /* 112 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * 是否是布尔类型
- *
- * @param {Object} value 测试的值
- * @return {Boolean}
- */
- var isType = __webpack_require__(4);
- var isBoolean = function isBoolean(value) {
- return isType(value, 'Boolean');
- };
- module.exports = isBoolean;
- /***/ }),
- /* 113 */
- /***/ (function(module, exports) {
- var isNull = function isNull(value) {
- return value === null;
- };
- module.exports = isNull;
- /***/ }),
- /* 114 */
- /***/ (function(module, exports) {
- var isUndefined = function isUndefined(value) {
- return value === undefined;
- };
- module.exports = isUndefined;
- /***/ }),
- /* 115 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(4);
- var isRegExp = function isRegExp(str) {
- return isType(str, 'RegExp');
- };
- module.exports = isRegExp;
- /***/ }),
- /* 116 */
- /***/ (function(module, exports, __webpack_require__) {
- var isFunction = __webpack_require__(2);
- var toArray = __webpack_require__(14);
- var mix = __webpack_require__(11);
- var augment = function augment(c) {
- var args = toArray(arguments);
- for (var i = 1; i < args.length; i++) {
- var obj = args[i];
- if (isFunction(obj)) {
- obj = obj.prototype;
- }
- mix(c.prototype, obj);
- }
- };
- module.exports = augment;
- /***/ }),
- /* 117 */
- /***/ (function(module, exports, __webpack_require__) {
- var isPlainObject = __webpack_require__(7);
- var isArray = __webpack_require__(1);
- var MAX_MIX_LEVEL = 5;
- function _deepMix(dist, src, level, maxLevel) {
- level = level || 0;
- maxLevel = maxLevel || MAX_MIX_LEVEL;
- for (var key in src) {
- if (src.hasOwnProperty(key)) {
- var value = src[key];
- if (value !== null && isPlainObject(value)) {
- if (!isPlainObject(dist[key])) {
- dist[key] = {};
- }
- if (level < maxLevel) {
- _deepMix(dist[key], value, level + 1, maxLevel);
- } else {
- dist[key] = src[key];
- }
- } else if (isArray(value)) {
- dist[key] = [];
- dist[key] = dist[key].concat(value);
- } else if (value !== undefined) {
- dist[key] = value;
- }
- }
- }
- }
- var deepMix = function deepMix() {
- var args = new Array(arguments.length);
- var length = args.length;
- for (var i = 0; i < length; i++) {
- args[i] = arguments[i];
- }
- var rst = args[0];
- for (var _i = 1; _i < length; _i++) {
- _deepMix(rst, args[_i]);
- }
- return rst;
- };
- module.exports = deepMix;
- /***/ }),
- /* 118 */
- /***/ (function(module, exports, __webpack_require__) {
- var isFunction = __webpack_require__(2);
- var mix = __webpack_require__(11);
- var extend = function extend(subclass, superclass, overrides, staticOverrides) {
- // 如果只提供父类构造函数,则自动生成子类构造函数
- if (!isFunction(superclass)) {
- overrides = superclass;
- superclass = subclass;
- subclass = function subclass() {};
- }
- var create = Object.create ? function (proto, c) {
- return Object.create(proto, {
- constructor: {
- value: c
- }
- });
- } : function (proto, c) {
- function Tmp() {}
- Tmp.prototype = proto;
- var o = new Tmp();
- o.constructor = c;
- return o;
- };
- var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
- subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype
- subclass.superclass = create(superclass.prototype, superclass);
- mix(superObj, overrides);
- mix(subclass, staticOverrides);
- return subclass;
- };
- module.exports = extend;
- /***/ }),
- /* 119 */
- /***/ (function(module, exports, __webpack_require__) {
- var groupToMap = __webpack_require__(37);
- var group = function group(data, condition) {
- if (!condition) {
- return [data];
- }
- var groups = groupToMap(data, condition);
- var array = [];
- for (var i in groups) {
- array.push(groups[i]);
- }
- return array;
- };
- module.exports = group;
- /***/ }),
- /* 120 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArrayLike = __webpack_require__(3);
- var indexOf = function indexOf(arr, obj) {
- if (!isArrayLike(arr)) {
- return -1;
- }
- var m = Array.prototype.indexOf;
- if (m) {
- return m.call(arr, obj);
- }
- var index = -1;
- for (var i = 0; i < arr.length; i++) {
- if (arr[i] === obj) {
- index = i;
- break;
- }
- }
- return index;
- };
- module.exports = indexOf;
- /***/ }),
- /* 121 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNil = __webpack_require__(5);
- var isArrayLike = __webpack_require__(3);
- var getType = __webpack_require__(35);
- var isPrototype = __webpack_require__(36);
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- function isEmpty(value) {
- /**
- * isEmpty(null) => true
- * isEmpty() => true
- * isEmpty(true) => true
- * isEmpty(1) => true
- * isEmpty([1, 2, 3]) => false
- * isEmpty('abc') => false
- * isEmpty({ a: 1 }) => false
- */
- if (isNil(value)) {
- return true;
- }
- if (isArrayLike(value)) {
- return !value.length;
- }
- var type = getType(value);
- if (type === 'Map' || type === 'Set') {
- return !value.size;
- }
- if (isPrototype(value)) {
- return !Object.keys(value).length;
- }
- for (var key in value) {
- if (hasOwnProperty.call(value, key)) {
- return false;
- }
- }
- return true;
- }
- module.exports = isEmpty;
- /***/ }),
- /* 122 */
- /***/ (function(module, exports, __webpack_require__) {
- var isFunction = __webpack_require__(2);
- var isEqual = __webpack_require__(39);
- /**
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @param {Function} [fn] The function to customize comparisons.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- * @example
- *
- * function isGreeting(value) {
- * return /^h(?:i|ello)$/.test(value);
- * }
- *
- * function customizer(objValue, othValue) {
- * if (isGreeting(objValue) && isGreeting(othValue)) {
- * return true;
- * }
- * }
- *
- * var array = ['hello', 'goodbye'];
- * var other = ['hi', 'goodbye'];
- *
- * isEqualWith(array, other, customizer); // => true
- */
- var isEqualWith = function isEqualWith(value, other, fn) {
- if (!isFunction(fn)) {
- return isEqual(value, other);
- }
- return !!fn(value, other);
- };
- module.exports = isEqualWith;
- /***/ }),
- /* 123 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var isArrayLike = __webpack_require__(3);
- var map = function map(arr, func) {
- if (!isArrayLike(arr)) {
- return arr;
- }
- var result = [];
- each(arr, function (value, index) {
- result.push(func(value, index));
- });
- return result;
- };
- module.exports = map;
- /***/ }),
- /* 124 */
- /***/ (function(module, exports, __webpack_require__) {
- var each = __webpack_require__(0);
- var isPlaineObject = __webpack_require__(7);
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- /**
- * Creates an object composed of the picked `object` properties.
- *
- * @param {Object} object The source object.
- * @param {...(string|string[])} [paths] The property paths to pick.
- * @returns {Object} Returns the new object.
- * @example
- *
- * var object = { 'a': 1, 'b': '2', 'c': 3 };
- * pick(object, ['a', 'c']); // => { 'a': 1, 'c': 3 }
- */
- var pick = function pick(object, keys) {
- if (object === null || !isPlaineObject(object)) {
- return {};
- }
- var result = {};
- each(keys, function (key) {
- if (hasOwnProperty.call(object, key)) {
- result[key] = object[key];
- }
- });
- return result;
- };
- module.exports = pick;
- /***/ }),
- /* 125 */
- /***/ (function(module, exports) {
- var uniqueId = function () {
- var map = {};
- return function (prefix) {
- prefix = prefix || 'g';
- if (!map[prefix]) {
- map[prefix] = 1;
- } else {
- map[prefix] += 1;
- }
- return prefix + map[prefix];
- };
- }();
- module.exports = uniqueId;
- /***/ })
- /******/ ]);
- });
|