spine-all.js 490 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. var spine;
  15. (function (spine) {
  16. var Animation = (function () {
  17. function Animation(name, timelines, duration) {
  18. if (name == null)
  19. throw new Error("name cannot be null.");
  20. if (timelines == null)
  21. throw new Error("timelines cannot be null.");
  22. this.name = name;
  23. this.timelines = timelines;
  24. this.timelineIds = [];
  25. for (var i = 0; i < timelines.length; i++)
  26. this.timelineIds[timelines[i].getPropertyId()] = true;
  27. this.duration = duration;
  28. }
  29. Animation.prototype.hasTimeline = function (id) {
  30. return this.timelineIds[id] == true;
  31. };
  32. Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
  33. if (skeleton == null)
  34. throw new Error("skeleton cannot be null.");
  35. if (loop && this.duration != 0) {
  36. time %= this.duration;
  37. if (lastTime > 0)
  38. lastTime %= this.duration;
  39. }
  40. var timelines = this.timelines;
  41. for (var i = 0, n = timelines.length; i < n; i++)
  42. timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
  43. };
  44. Animation.binarySearch = function (values, target, step) {
  45. if (step === void 0) { step = 1; }
  46. var low = 0;
  47. var high = values.length / step - 2;
  48. if (high == 0)
  49. return step;
  50. var current = high >>> 1;
  51. while (true) {
  52. if (values[(current + 1) * step] <= target)
  53. low = current + 1;
  54. else
  55. high = current;
  56. if (low == high)
  57. return (low + 1) * step;
  58. current = (low + high) >>> 1;
  59. }
  60. };
  61. Animation.linearSearch = function (values, target, step) {
  62. for (var i = 0, last = values.length - step; i <= last; i += step)
  63. if (values[i] > target)
  64. return i;
  65. return -1;
  66. };
  67. return Animation;
  68. }());
  69. spine.Animation = Animation;
  70. var MixBlend;
  71. (function (MixBlend) {
  72. MixBlend[MixBlend["setup"] = 0] = "setup";
  73. MixBlend[MixBlend["first"] = 1] = "first";
  74. MixBlend[MixBlend["replace"] = 2] = "replace";
  75. MixBlend[MixBlend["add"] = 3] = "add";
  76. })(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
  77. var MixDirection;
  78. (function (MixDirection) {
  79. MixDirection[MixDirection["mixIn"] = 0] = "mixIn";
  80. MixDirection[MixDirection["mixOut"] = 1] = "mixOut";
  81. })(MixDirection = spine.MixDirection || (spine.MixDirection = {}));
  82. var TimelineType;
  83. (function (TimelineType) {
  84. TimelineType[TimelineType["rotate"] = 0] = "rotate";
  85. TimelineType[TimelineType["translate"] = 1] = "translate";
  86. TimelineType[TimelineType["scale"] = 2] = "scale";
  87. TimelineType[TimelineType["shear"] = 3] = "shear";
  88. TimelineType[TimelineType["attachment"] = 4] = "attachment";
  89. TimelineType[TimelineType["color"] = 5] = "color";
  90. TimelineType[TimelineType["deform"] = 6] = "deform";
  91. TimelineType[TimelineType["event"] = 7] = "event";
  92. TimelineType[TimelineType["drawOrder"] = 8] = "drawOrder";
  93. TimelineType[TimelineType["ikConstraint"] = 9] = "ikConstraint";
  94. TimelineType[TimelineType["transformConstraint"] = 10] = "transformConstraint";
  95. TimelineType[TimelineType["pathConstraintPosition"] = 11] = "pathConstraintPosition";
  96. TimelineType[TimelineType["pathConstraintSpacing"] = 12] = "pathConstraintSpacing";
  97. TimelineType[TimelineType["pathConstraintMix"] = 13] = "pathConstraintMix";
  98. TimelineType[TimelineType["twoColor"] = 14] = "twoColor";
  99. })(TimelineType = spine.TimelineType || (spine.TimelineType = {}));
  100. var CurveTimeline = (function () {
  101. function CurveTimeline(frameCount) {
  102. if (frameCount <= 0)
  103. throw new Error("frameCount must be > 0: " + frameCount);
  104. this.curves = spine.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);
  105. }
  106. CurveTimeline.prototype.getFrameCount = function () {
  107. return this.curves.length / CurveTimeline.BEZIER_SIZE + 1;
  108. };
  109. CurveTimeline.prototype.setLinear = function (frameIndex) {
  110. this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR;
  111. };
  112. CurveTimeline.prototype.setStepped = function (frameIndex) {
  113. this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED;
  114. };
  115. CurveTimeline.prototype.getCurveType = function (frameIndex) {
  116. var index = frameIndex * CurveTimeline.BEZIER_SIZE;
  117. if (index == this.curves.length)
  118. return CurveTimeline.LINEAR;
  119. var type = this.curves[index];
  120. if (type == CurveTimeline.LINEAR)
  121. return CurveTimeline.LINEAR;
  122. if (type == CurveTimeline.STEPPED)
  123. return CurveTimeline.STEPPED;
  124. return CurveTimeline.BEZIER;
  125. };
  126. CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) {
  127. var tmpx = (-cx1 * 2 + cx2) * 0.03, tmpy = (-cy1 * 2 + cy2) * 0.03;
  128. var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006;
  129. var ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy;
  130. var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667;
  131. var i = frameIndex * CurveTimeline.BEZIER_SIZE;
  132. var curves = this.curves;
  133. curves[i++] = CurveTimeline.BEZIER;
  134. var x = dfx, y = dfy;
  135. for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
  136. curves[i] = x;
  137. curves[i + 1] = y;
  138. dfx += ddfx;
  139. dfy += ddfy;
  140. ddfx += dddfx;
  141. ddfy += dddfy;
  142. x += dfx;
  143. y += dfy;
  144. }
  145. };
  146. CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) {
  147. percent = spine.MathUtils.clamp(percent, 0, 1);
  148. var curves = this.curves;
  149. var i = frameIndex * CurveTimeline.BEZIER_SIZE;
  150. var type = curves[i];
  151. if (type == CurveTimeline.LINEAR)
  152. return percent;
  153. if (type == CurveTimeline.STEPPED)
  154. return 0;
  155. i++;
  156. var x = 0;
  157. for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
  158. x = curves[i];
  159. if (x >= percent) {
  160. var prevX = void 0, prevY = void 0;
  161. if (i == start) {
  162. prevX = 0;
  163. prevY = 0;
  164. }
  165. else {
  166. prevX = curves[i - 2];
  167. prevY = curves[i - 1];
  168. }
  169. return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX);
  170. }
  171. }
  172. var y = curves[i - 1];
  173. return y + (1 - y) * (percent - x) / (1 - x);
  174. };
  175. CurveTimeline.LINEAR = 0;
  176. CurveTimeline.STEPPED = 1;
  177. CurveTimeline.BEZIER = 2;
  178. CurveTimeline.BEZIER_SIZE = 10 * 2 - 1;
  179. return CurveTimeline;
  180. }());
  181. spine.CurveTimeline = CurveTimeline;
  182. var RotateTimeline = (function (_super) {
  183. __extends(RotateTimeline, _super);
  184. function RotateTimeline(frameCount) {
  185. var _this = _super.call(this, frameCount) || this;
  186. _this.frames = spine.Utils.newFloatArray(frameCount << 1);
  187. return _this;
  188. }
  189. RotateTimeline.prototype.getPropertyId = function () {
  190. return (TimelineType.rotate << 24) + this.boneIndex;
  191. };
  192. RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) {
  193. frameIndex <<= 1;
  194. this.frames[frameIndex] = time;
  195. this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
  196. };
  197. RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  198. var frames = this.frames;
  199. var bone = skeleton.bones[this.boneIndex];
  200. if (!bone.active)
  201. return;
  202. if (time < frames[0]) {
  203. switch (blend) {
  204. case MixBlend.setup:
  205. bone.rotation = bone.data.rotation;
  206. return;
  207. case MixBlend.first:
  208. var r_1 = bone.data.rotation - bone.rotation;
  209. bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
  210. }
  211. return;
  212. }
  213. if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
  214. var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION];
  215. switch (blend) {
  216. case MixBlend.setup:
  217. bone.rotation = bone.data.rotation + r_2 * alpha;
  218. break;
  219. case MixBlend.first:
  220. case MixBlend.replace:
  221. r_2 += bone.data.rotation - bone.rotation;
  222. r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
  223. case MixBlend.add:
  224. bone.rotation += r_2 * alpha;
  225. }
  226. return;
  227. }
  228. var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES);
  229. var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
  230. var frameTime = frames[frame];
  231. var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
  232. var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
  233. r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
  234. switch (blend) {
  235. case MixBlend.setup:
  236. bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
  237. break;
  238. case MixBlend.first:
  239. case MixBlend.replace:
  240. r += bone.data.rotation - bone.rotation;
  241. case MixBlend.add:
  242. bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
  243. }
  244. };
  245. RotateTimeline.ENTRIES = 2;
  246. RotateTimeline.PREV_TIME = -2;
  247. RotateTimeline.PREV_ROTATION = -1;
  248. RotateTimeline.ROTATION = 1;
  249. return RotateTimeline;
  250. }(CurveTimeline));
  251. spine.RotateTimeline = RotateTimeline;
  252. var TranslateTimeline = (function (_super) {
  253. __extends(TranslateTimeline, _super);
  254. function TranslateTimeline(frameCount) {
  255. var _this = _super.call(this, frameCount) || this;
  256. _this.frames = spine.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES);
  257. return _this;
  258. }
  259. TranslateTimeline.prototype.getPropertyId = function () {
  260. return (TimelineType.translate << 24) + this.boneIndex;
  261. };
  262. TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) {
  263. frameIndex *= TranslateTimeline.ENTRIES;
  264. this.frames[frameIndex] = time;
  265. this.frames[frameIndex + TranslateTimeline.X] = x;
  266. this.frames[frameIndex + TranslateTimeline.Y] = y;
  267. };
  268. TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  269. var frames = this.frames;
  270. var bone = skeleton.bones[this.boneIndex];
  271. if (!bone.active)
  272. return;
  273. if (time < frames[0]) {
  274. switch (blend) {
  275. case MixBlend.setup:
  276. bone.x = bone.data.x;
  277. bone.y = bone.data.y;
  278. return;
  279. case MixBlend.first:
  280. bone.x += (bone.data.x - bone.x) * alpha;
  281. bone.y += (bone.data.y - bone.y) * alpha;
  282. }
  283. return;
  284. }
  285. var x = 0, y = 0;
  286. if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
  287. x = frames[frames.length + TranslateTimeline.PREV_X];
  288. y = frames[frames.length + TranslateTimeline.PREV_Y];
  289. }
  290. else {
  291. var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES);
  292. x = frames[frame + TranslateTimeline.PREV_X];
  293. y = frames[frame + TranslateTimeline.PREV_Y];
  294. var frameTime = frames[frame];
  295. var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime));
  296. x += (frames[frame + TranslateTimeline.X] - x) * percent;
  297. y += (frames[frame + TranslateTimeline.Y] - y) * percent;
  298. }
  299. switch (blend) {
  300. case MixBlend.setup:
  301. bone.x = bone.data.x + x * alpha;
  302. bone.y = bone.data.y + y * alpha;
  303. break;
  304. case MixBlend.first:
  305. case MixBlend.replace:
  306. bone.x += (bone.data.x + x - bone.x) * alpha;
  307. bone.y += (bone.data.y + y - bone.y) * alpha;
  308. break;
  309. case MixBlend.add:
  310. bone.x += x * alpha;
  311. bone.y += y * alpha;
  312. }
  313. };
  314. TranslateTimeline.ENTRIES = 3;
  315. TranslateTimeline.PREV_TIME = -3;
  316. TranslateTimeline.PREV_X = -2;
  317. TranslateTimeline.PREV_Y = -1;
  318. TranslateTimeline.X = 1;
  319. TranslateTimeline.Y = 2;
  320. return TranslateTimeline;
  321. }(CurveTimeline));
  322. spine.TranslateTimeline = TranslateTimeline;
  323. var ScaleTimeline = (function (_super) {
  324. __extends(ScaleTimeline, _super);
  325. function ScaleTimeline(frameCount) {
  326. return _super.call(this, frameCount) || this;
  327. }
  328. ScaleTimeline.prototype.getPropertyId = function () {
  329. return (TimelineType.scale << 24) + this.boneIndex;
  330. };
  331. ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  332. var frames = this.frames;
  333. var bone = skeleton.bones[this.boneIndex];
  334. if (!bone.active)
  335. return;
  336. if (time < frames[0]) {
  337. switch (blend) {
  338. case MixBlend.setup:
  339. bone.scaleX = bone.data.scaleX;
  340. bone.scaleY = bone.data.scaleY;
  341. return;
  342. case MixBlend.first:
  343. bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
  344. bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
  345. }
  346. return;
  347. }
  348. var x = 0, y = 0;
  349. if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
  350. x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
  351. y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY;
  352. }
  353. else {
  354. var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES);
  355. x = frames[frame + ScaleTimeline.PREV_X];
  356. y = frames[frame + ScaleTimeline.PREV_Y];
  357. var frameTime = frames[frame];
  358. var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime));
  359. x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX;
  360. y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
  361. }
  362. if (alpha == 1) {
  363. if (blend == MixBlend.add) {
  364. bone.scaleX += x - bone.data.scaleX;
  365. bone.scaleY += y - bone.data.scaleY;
  366. }
  367. else {
  368. bone.scaleX = x;
  369. bone.scaleY = y;
  370. }
  371. }
  372. else {
  373. var bx = 0, by = 0;
  374. if (direction == MixDirection.mixOut) {
  375. switch (blend) {
  376. case MixBlend.setup:
  377. bx = bone.data.scaleX;
  378. by = bone.data.scaleY;
  379. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
  380. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
  381. break;
  382. case MixBlend.first:
  383. case MixBlend.replace:
  384. bx = bone.scaleX;
  385. by = bone.scaleY;
  386. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
  387. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
  388. break;
  389. case MixBlend.add:
  390. bx = bone.scaleX;
  391. by = bone.scaleY;
  392. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
  393. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
  394. }
  395. }
  396. else {
  397. switch (blend) {
  398. case MixBlend.setup:
  399. bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
  400. by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
  401. bone.scaleX = bx + (x - bx) * alpha;
  402. bone.scaleY = by + (y - by) * alpha;
  403. break;
  404. case MixBlend.first:
  405. case MixBlend.replace:
  406. bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
  407. by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
  408. bone.scaleX = bx + (x - bx) * alpha;
  409. bone.scaleY = by + (y - by) * alpha;
  410. break;
  411. case MixBlend.add:
  412. bx = spine.MathUtils.signum(x);
  413. by = spine.MathUtils.signum(y);
  414. bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
  415. bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
  416. }
  417. }
  418. }
  419. };
  420. return ScaleTimeline;
  421. }(TranslateTimeline));
  422. spine.ScaleTimeline = ScaleTimeline;
  423. var ShearTimeline = (function (_super) {
  424. __extends(ShearTimeline, _super);
  425. function ShearTimeline(frameCount) {
  426. return _super.call(this, frameCount) || this;
  427. }
  428. ShearTimeline.prototype.getPropertyId = function () {
  429. return (TimelineType.shear << 24) + this.boneIndex;
  430. };
  431. ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  432. var frames = this.frames;
  433. var bone = skeleton.bones[this.boneIndex];
  434. if (!bone.active)
  435. return;
  436. if (time < frames[0]) {
  437. switch (blend) {
  438. case MixBlend.setup:
  439. bone.shearX = bone.data.shearX;
  440. bone.shearY = bone.data.shearY;
  441. return;
  442. case MixBlend.first:
  443. bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
  444. bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
  445. }
  446. return;
  447. }
  448. var x = 0, y = 0;
  449. if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
  450. x = frames[frames.length + ShearTimeline.PREV_X];
  451. y = frames[frames.length + ShearTimeline.PREV_Y];
  452. }
  453. else {
  454. var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES);
  455. x = frames[frame + ShearTimeline.PREV_X];
  456. y = frames[frame + ShearTimeline.PREV_Y];
  457. var frameTime = frames[frame];
  458. var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime));
  459. x = x + (frames[frame + ShearTimeline.X] - x) * percent;
  460. y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
  461. }
  462. switch (blend) {
  463. case MixBlend.setup:
  464. bone.shearX = bone.data.shearX + x * alpha;
  465. bone.shearY = bone.data.shearY + y * alpha;
  466. break;
  467. case MixBlend.first:
  468. case MixBlend.replace:
  469. bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
  470. bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
  471. break;
  472. case MixBlend.add:
  473. bone.shearX += x * alpha;
  474. bone.shearY += y * alpha;
  475. }
  476. };
  477. return ShearTimeline;
  478. }(TranslateTimeline));
  479. spine.ShearTimeline = ShearTimeline;
  480. var ColorTimeline = (function (_super) {
  481. __extends(ColorTimeline, _super);
  482. function ColorTimeline(frameCount) {
  483. var _this = _super.call(this, frameCount) || this;
  484. _this.frames = spine.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES);
  485. return _this;
  486. }
  487. ColorTimeline.prototype.getPropertyId = function () {
  488. return (TimelineType.color << 24) + this.slotIndex;
  489. };
  490. ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) {
  491. frameIndex *= ColorTimeline.ENTRIES;
  492. this.frames[frameIndex] = time;
  493. this.frames[frameIndex + ColorTimeline.R] = r;
  494. this.frames[frameIndex + ColorTimeline.G] = g;
  495. this.frames[frameIndex + ColorTimeline.B] = b;
  496. this.frames[frameIndex + ColorTimeline.A] = a;
  497. };
  498. ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  499. var slot = skeleton.slots[this.slotIndex];
  500. if (!slot.bone.active)
  501. return;
  502. var frames = this.frames;
  503. if (time < frames[0]) {
  504. switch (blend) {
  505. case MixBlend.setup:
  506. slot.color.setFromColor(slot.data.color);
  507. return;
  508. case MixBlend.first:
  509. var color = slot.color, setup = slot.data.color;
  510. color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
  511. }
  512. return;
  513. }
  514. var r = 0, g = 0, b = 0, a = 0;
  515. if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
  516. var i = frames.length;
  517. r = frames[i + ColorTimeline.PREV_R];
  518. g = frames[i + ColorTimeline.PREV_G];
  519. b = frames[i + ColorTimeline.PREV_B];
  520. a = frames[i + ColorTimeline.PREV_A];
  521. }
  522. else {
  523. var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES);
  524. r = frames[frame + ColorTimeline.PREV_R];
  525. g = frames[frame + ColorTimeline.PREV_G];
  526. b = frames[frame + ColorTimeline.PREV_B];
  527. a = frames[frame + ColorTimeline.PREV_A];
  528. var frameTime = frames[frame];
  529. var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime));
  530. r += (frames[frame + ColorTimeline.R] - r) * percent;
  531. g += (frames[frame + ColorTimeline.G] - g) * percent;
  532. b += (frames[frame + ColorTimeline.B] - b) * percent;
  533. a += (frames[frame + ColorTimeline.A] - a) * percent;
  534. }
  535. if (alpha == 1)
  536. slot.color.set(r, g, b, a);
  537. else {
  538. var color = slot.color;
  539. if (blend == MixBlend.setup)
  540. color.setFromColor(slot.data.color);
  541. color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
  542. }
  543. };
  544. ColorTimeline.ENTRIES = 5;
  545. ColorTimeline.PREV_TIME = -5;
  546. ColorTimeline.PREV_R = -4;
  547. ColorTimeline.PREV_G = -3;
  548. ColorTimeline.PREV_B = -2;
  549. ColorTimeline.PREV_A = -1;
  550. ColorTimeline.R = 1;
  551. ColorTimeline.G = 2;
  552. ColorTimeline.B = 3;
  553. ColorTimeline.A = 4;
  554. return ColorTimeline;
  555. }(CurveTimeline));
  556. spine.ColorTimeline = ColorTimeline;
  557. var TwoColorTimeline = (function (_super) {
  558. __extends(TwoColorTimeline, _super);
  559. function TwoColorTimeline(frameCount) {
  560. var _this = _super.call(this, frameCount) || this;
  561. _this.frames = spine.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES);
  562. return _this;
  563. }
  564. TwoColorTimeline.prototype.getPropertyId = function () {
  565. return (TimelineType.twoColor << 24) + this.slotIndex;
  566. };
  567. TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) {
  568. frameIndex *= TwoColorTimeline.ENTRIES;
  569. this.frames[frameIndex] = time;
  570. this.frames[frameIndex + TwoColorTimeline.R] = r;
  571. this.frames[frameIndex + TwoColorTimeline.G] = g;
  572. this.frames[frameIndex + TwoColorTimeline.B] = b;
  573. this.frames[frameIndex + TwoColorTimeline.A] = a;
  574. this.frames[frameIndex + TwoColorTimeline.R2] = r2;
  575. this.frames[frameIndex + TwoColorTimeline.G2] = g2;
  576. this.frames[frameIndex + TwoColorTimeline.B2] = b2;
  577. };
  578. TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  579. var slot = skeleton.slots[this.slotIndex];
  580. if (!slot.bone.active)
  581. return;
  582. var frames = this.frames;
  583. if (time < frames[0]) {
  584. switch (blend) {
  585. case MixBlend.setup:
  586. slot.color.setFromColor(slot.data.color);
  587. slot.darkColor.setFromColor(slot.data.darkColor);
  588. return;
  589. case MixBlend.first:
  590. var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
  591. light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
  592. dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
  593. }
  594. return;
  595. }
  596. var r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0;
  597. if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) {
  598. var i = frames.length;
  599. r = frames[i + TwoColorTimeline.PREV_R];
  600. g = frames[i + TwoColorTimeline.PREV_G];
  601. b = frames[i + TwoColorTimeline.PREV_B];
  602. a = frames[i + TwoColorTimeline.PREV_A];
  603. r2 = frames[i + TwoColorTimeline.PREV_R2];
  604. g2 = frames[i + TwoColorTimeline.PREV_G2];
  605. b2 = frames[i + TwoColorTimeline.PREV_B2];
  606. }
  607. else {
  608. var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES);
  609. r = frames[frame + TwoColorTimeline.PREV_R];
  610. g = frames[frame + TwoColorTimeline.PREV_G];
  611. b = frames[frame + TwoColorTimeline.PREV_B];
  612. a = frames[frame + TwoColorTimeline.PREV_A];
  613. r2 = frames[frame + TwoColorTimeline.PREV_R2];
  614. g2 = frames[frame + TwoColorTimeline.PREV_G2];
  615. b2 = frames[frame + TwoColorTimeline.PREV_B2];
  616. var frameTime = frames[frame];
  617. var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime));
  618. r += (frames[frame + TwoColorTimeline.R] - r) * percent;
  619. g += (frames[frame + TwoColorTimeline.G] - g) * percent;
  620. b += (frames[frame + TwoColorTimeline.B] - b) * percent;
  621. a += (frames[frame + TwoColorTimeline.A] - a) * percent;
  622. r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent;
  623. g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent;
  624. b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent;
  625. }
  626. if (alpha == 1) {
  627. slot.color.set(r, g, b, a);
  628. slot.darkColor.set(r2, g2, b2, 1);
  629. }
  630. else {
  631. var light = slot.color, dark = slot.darkColor;
  632. if (blend == MixBlend.setup) {
  633. light.setFromColor(slot.data.color);
  634. dark.setFromColor(slot.data.darkColor);
  635. }
  636. light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha);
  637. dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0);
  638. }
  639. };
  640. TwoColorTimeline.ENTRIES = 8;
  641. TwoColorTimeline.PREV_TIME = -8;
  642. TwoColorTimeline.PREV_R = -7;
  643. TwoColorTimeline.PREV_G = -6;
  644. TwoColorTimeline.PREV_B = -5;
  645. TwoColorTimeline.PREV_A = -4;
  646. TwoColorTimeline.PREV_R2 = -3;
  647. TwoColorTimeline.PREV_G2 = -2;
  648. TwoColorTimeline.PREV_B2 = -1;
  649. TwoColorTimeline.R = 1;
  650. TwoColorTimeline.G = 2;
  651. TwoColorTimeline.B = 3;
  652. TwoColorTimeline.A = 4;
  653. TwoColorTimeline.R2 = 5;
  654. TwoColorTimeline.G2 = 6;
  655. TwoColorTimeline.B2 = 7;
  656. return TwoColorTimeline;
  657. }(CurveTimeline));
  658. spine.TwoColorTimeline = TwoColorTimeline;
  659. var AttachmentTimeline = (function () {
  660. function AttachmentTimeline(frameCount) {
  661. this.frames = spine.Utils.newFloatArray(frameCount);
  662. this.attachmentNames = new Array(frameCount);
  663. }
  664. AttachmentTimeline.prototype.getPropertyId = function () {
  665. return (TimelineType.attachment << 24) + this.slotIndex;
  666. };
  667. AttachmentTimeline.prototype.getFrameCount = function () {
  668. return this.frames.length;
  669. };
  670. AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) {
  671. this.frames[frameIndex] = time;
  672. this.attachmentNames[frameIndex] = attachmentName;
  673. };
  674. AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  675. var slot = skeleton.slots[this.slotIndex];
  676. if (!slot.bone.active)
  677. return;
  678. if (direction == MixDirection.mixOut) {
  679. if (blend == MixBlend.setup)
  680. this.setAttachment(skeleton, slot, slot.data.attachmentName);
  681. return;
  682. }
  683. var frames = this.frames;
  684. if (time < frames[0]) {
  685. if (blend == MixBlend.setup || blend == MixBlend.first)
  686. this.setAttachment(skeleton, slot, slot.data.attachmentName);
  687. return;
  688. }
  689. var frameIndex = 0;
  690. if (time >= frames[frames.length - 1])
  691. frameIndex = frames.length - 1;
  692. else
  693. frameIndex = Animation.binarySearch(frames, time, 1) - 1;
  694. var attachmentName = this.attachmentNames[frameIndex];
  695. skeleton.slots[this.slotIndex]
  696. .setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
  697. };
  698. AttachmentTimeline.prototype.setAttachment = function (skeleton, slot, attachmentName) {
  699. slot.attachment = attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName);
  700. };
  701. return AttachmentTimeline;
  702. }());
  703. spine.AttachmentTimeline = AttachmentTimeline;
  704. var zeros = null;
  705. var DeformTimeline = (function (_super) {
  706. __extends(DeformTimeline, _super);
  707. function DeformTimeline(frameCount) {
  708. var _this = _super.call(this, frameCount) || this;
  709. _this.frames = spine.Utils.newFloatArray(frameCount);
  710. _this.frameVertices = new Array(frameCount);
  711. if (zeros == null)
  712. zeros = spine.Utils.newFloatArray(64);
  713. return _this;
  714. }
  715. DeformTimeline.prototype.getPropertyId = function () {
  716. return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
  717. };
  718. DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
  719. this.frames[frameIndex] = time;
  720. this.frameVertices[frameIndex] = vertices;
  721. };
  722. DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  723. var slot = skeleton.slots[this.slotIndex];
  724. if (!slot.bone.active)
  725. return;
  726. var slotAttachment = slot.getAttachment();
  727. if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment))
  728. return;
  729. var deformArray = slot.deform;
  730. if (deformArray.length == 0)
  731. blend = MixBlend.setup;
  732. var frameVertices = this.frameVertices;
  733. var vertexCount = frameVertices[0].length;
  734. var frames = this.frames;
  735. if (time < frames[0]) {
  736. var vertexAttachment = slotAttachment;
  737. switch (blend) {
  738. case MixBlend.setup:
  739. deformArray.length = 0;
  740. return;
  741. case MixBlend.first:
  742. if (alpha == 1) {
  743. deformArray.length = 0;
  744. break;
  745. }
  746. var deform_1 = spine.Utils.setArraySize(deformArray, vertexCount);
  747. if (vertexAttachment.bones == null) {
  748. var setupVertices = vertexAttachment.vertices;
  749. for (var i = 0; i < vertexCount; i++)
  750. deform_1[i] += (setupVertices[i] - deform_1[i]) * alpha;
  751. }
  752. else {
  753. alpha = 1 - alpha;
  754. for (var i = 0; i < vertexCount; i++)
  755. deform_1[i] *= alpha;
  756. }
  757. }
  758. return;
  759. }
  760. var deform = spine.Utils.setArraySize(deformArray, vertexCount);
  761. if (time >= frames[frames.length - 1]) {
  762. var lastVertices = frameVertices[frames.length - 1];
  763. if (alpha == 1) {
  764. if (blend == MixBlend.add) {
  765. var vertexAttachment = slotAttachment;
  766. if (vertexAttachment.bones == null) {
  767. var setupVertices = vertexAttachment.vertices;
  768. for (var i_1 = 0; i_1 < vertexCount; i_1++) {
  769. deform[i_1] += lastVertices[i_1] - setupVertices[i_1];
  770. }
  771. }
  772. else {
  773. for (var i_2 = 0; i_2 < vertexCount; i_2++)
  774. deform[i_2] += lastVertices[i_2];
  775. }
  776. }
  777. else {
  778. spine.Utils.arrayCopy(lastVertices, 0, deform, 0, vertexCount);
  779. }
  780. }
  781. else {
  782. switch (blend) {
  783. case MixBlend.setup: {
  784. var vertexAttachment_1 = slotAttachment;
  785. if (vertexAttachment_1.bones == null) {
  786. var setupVertices = vertexAttachment_1.vertices;
  787. for (var i_3 = 0; i_3 < vertexCount; i_3++) {
  788. var setup = setupVertices[i_3];
  789. deform[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
  790. }
  791. }
  792. else {
  793. for (var i_4 = 0; i_4 < vertexCount; i_4++)
  794. deform[i_4] = lastVertices[i_4] * alpha;
  795. }
  796. break;
  797. }
  798. case MixBlend.first:
  799. case MixBlend.replace:
  800. for (var i_5 = 0; i_5 < vertexCount; i_5++)
  801. deform[i_5] += (lastVertices[i_5] - deform[i_5]) * alpha;
  802. break;
  803. case MixBlend.add:
  804. var vertexAttachment = slotAttachment;
  805. if (vertexAttachment.bones == null) {
  806. var setupVertices = vertexAttachment.vertices;
  807. for (var i_6 = 0; i_6 < vertexCount; i_6++) {
  808. deform[i_6] += (lastVertices[i_6] - setupVertices[i_6]) * alpha;
  809. }
  810. }
  811. else {
  812. for (var i_7 = 0; i_7 < vertexCount; i_7++)
  813. deform[i_7] += lastVertices[i_7] * alpha;
  814. }
  815. }
  816. }
  817. return;
  818. }
  819. var frame = Animation.binarySearch(frames, time);
  820. var prevVertices = frameVertices[frame - 1];
  821. var nextVertices = frameVertices[frame];
  822. var frameTime = frames[frame];
  823. var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
  824. if (alpha == 1) {
  825. if (blend == MixBlend.add) {
  826. var vertexAttachment = slotAttachment;
  827. if (vertexAttachment.bones == null) {
  828. var setupVertices = vertexAttachment.vertices;
  829. for (var i_8 = 0; i_8 < vertexCount; i_8++) {
  830. var prev = prevVertices[i_8];
  831. deform[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices[i_8];
  832. }
  833. }
  834. else {
  835. for (var i_9 = 0; i_9 < vertexCount; i_9++) {
  836. var prev = prevVertices[i_9];
  837. deform[i_9] += prev + (nextVertices[i_9] - prev) * percent;
  838. }
  839. }
  840. }
  841. else {
  842. for (var i_10 = 0; i_10 < vertexCount; i_10++) {
  843. var prev = prevVertices[i_10];
  844. deform[i_10] = prev + (nextVertices[i_10] - prev) * percent;
  845. }
  846. }
  847. }
  848. else {
  849. switch (blend) {
  850. case MixBlend.setup: {
  851. var vertexAttachment_2 = slotAttachment;
  852. if (vertexAttachment_2.bones == null) {
  853. var setupVertices = vertexAttachment_2.vertices;
  854. for (var i_11 = 0; i_11 < vertexCount; i_11++) {
  855. var prev = prevVertices[i_11], setup = setupVertices[i_11];
  856. deform[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
  857. }
  858. }
  859. else {
  860. for (var i_12 = 0; i_12 < vertexCount; i_12++) {
  861. var prev = prevVertices[i_12];
  862. deform[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
  863. }
  864. }
  865. break;
  866. }
  867. case MixBlend.first:
  868. case MixBlend.replace:
  869. for (var i_13 = 0; i_13 < vertexCount; i_13++) {
  870. var prev = prevVertices[i_13];
  871. deform[i_13] += (prev + (nextVertices[i_13] - prev) * percent - deform[i_13]) * alpha;
  872. }
  873. break;
  874. case MixBlend.add:
  875. var vertexAttachment = slotAttachment;
  876. if (vertexAttachment.bones == null) {
  877. var setupVertices = vertexAttachment.vertices;
  878. for (var i_14 = 0; i_14 < vertexCount; i_14++) {
  879. var prev = prevVertices[i_14];
  880. deform[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices[i_14]) * alpha;
  881. }
  882. }
  883. else {
  884. for (var i_15 = 0; i_15 < vertexCount; i_15++) {
  885. var prev = prevVertices[i_15];
  886. deform[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
  887. }
  888. }
  889. }
  890. }
  891. };
  892. return DeformTimeline;
  893. }(CurveTimeline));
  894. spine.DeformTimeline = DeformTimeline;
  895. var EventTimeline = (function () {
  896. function EventTimeline(frameCount) {
  897. this.frames = spine.Utils.newFloatArray(frameCount);
  898. this.events = new Array(frameCount);
  899. }
  900. EventTimeline.prototype.getPropertyId = function () {
  901. return TimelineType.event << 24;
  902. };
  903. EventTimeline.prototype.getFrameCount = function () {
  904. return this.frames.length;
  905. };
  906. EventTimeline.prototype.setFrame = function (frameIndex, event) {
  907. this.frames[frameIndex] = event.time;
  908. this.events[frameIndex] = event;
  909. };
  910. EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  911. if (firedEvents == null)
  912. return;
  913. var frames = this.frames;
  914. var frameCount = this.frames.length;
  915. if (lastTime > time) {
  916. this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
  917. lastTime = -1;
  918. }
  919. else if (lastTime >= frames[frameCount - 1])
  920. return;
  921. if (time < frames[0])
  922. return;
  923. var frame = 0;
  924. if (lastTime < frames[0])
  925. frame = 0;
  926. else {
  927. frame = Animation.binarySearch(frames, lastTime);
  928. var frameTime = frames[frame];
  929. while (frame > 0) {
  930. if (frames[frame - 1] != frameTime)
  931. break;
  932. frame--;
  933. }
  934. }
  935. for (; frame < frameCount && time >= frames[frame]; frame++)
  936. firedEvents.push(this.events[frame]);
  937. };
  938. return EventTimeline;
  939. }());
  940. spine.EventTimeline = EventTimeline;
  941. var DrawOrderTimeline = (function () {
  942. function DrawOrderTimeline(frameCount) {
  943. this.frames = spine.Utils.newFloatArray(frameCount);
  944. this.drawOrders = new Array(frameCount);
  945. }
  946. DrawOrderTimeline.prototype.getPropertyId = function () {
  947. return TimelineType.drawOrder << 24;
  948. };
  949. DrawOrderTimeline.prototype.getFrameCount = function () {
  950. return this.frames.length;
  951. };
  952. DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
  953. this.frames[frameIndex] = time;
  954. this.drawOrders[frameIndex] = drawOrder;
  955. };
  956. DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  957. var drawOrder = skeleton.drawOrder;
  958. var slots = skeleton.slots;
  959. if (direction == MixDirection.mixOut) {
  960. if (blend == MixBlend.setup)
  961. spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
  962. return;
  963. }
  964. var frames = this.frames;
  965. if (time < frames[0]) {
  966. if (blend == MixBlend.setup || blend == MixBlend.first)
  967. spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
  968. return;
  969. }
  970. var frame = 0;
  971. if (time >= frames[frames.length - 1])
  972. frame = frames.length - 1;
  973. else
  974. frame = Animation.binarySearch(frames, time) - 1;
  975. var drawOrderToSetupIndex = this.drawOrders[frame];
  976. if (drawOrderToSetupIndex == null)
  977. spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
  978. else {
  979. for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
  980. drawOrder[i] = slots[drawOrderToSetupIndex[i]];
  981. }
  982. };
  983. return DrawOrderTimeline;
  984. }());
  985. spine.DrawOrderTimeline = DrawOrderTimeline;
  986. var IkConstraintTimeline = (function (_super) {
  987. __extends(IkConstraintTimeline, _super);
  988. function IkConstraintTimeline(frameCount) {
  989. var _this = _super.call(this, frameCount) || this;
  990. _this.frames = spine.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES);
  991. return _this;
  992. }
  993. IkConstraintTimeline.prototype.getPropertyId = function () {
  994. return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex;
  995. };
  996. IkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, softness, bendDirection, compress, stretch) {
  997. frameIndex *= IkConstraintTimeline.ENTRIES;
  998. this.frames[frameIndex] = time;
  999. this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
  1000. this.frames[frameIndex + IkConstraintTimeline.SOFTNESS] = softness;
  1001. this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
  1002. this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress ? 1 : 0;
  1003. this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch ? 1 : 0;
  1004. };
  1005. IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1006. var frames = this.frames;
  1007. var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
  1008. if (!constraint.active)
  1009. return;
  1010. if (time < frames[0]) {
  1011. switch (blend) {
  1012. case MixBlend.setup:
  1013. constraint.mix = constraint.data.mix;
  1014. constraint.softness = constraint.data.softness;
  1015. constraint.bendDirection = constraint.data.bendDirection;
  1016. constraint.compress = constraint.data.compress;
  1017. constraint.stretch = constraint.data.stretch;
  1018. return;
  1019. case MixBlend.first:
  1020. constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
  1021. constraint.softness += (constraint.data.softness - constraint.softness) * alpha;
  1022. constraint.bendDirection = constraint.data.bendDirection;
  1023. constraint.compress = constraint.data.compress;
  1024. constraint.stretch = constraint.data.stretch;
  1025. }
  1026. return;
  1027. }
  1028. if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
  1029. if (blend == MixBlend.setup) {
  1030. constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
  1031. constraint.softness = constraint.data.softness
  1032. + (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.data.softness) * alpha;
  1033. if (direction == MixDirection.mixOut) {
  1034. constraint.bendDirection = constraint.data.bendDirection;
  1035. constraint.compress = constraint.data.compress;
  1036. constraint.stretch = constraint.data.stretch;
  1037. }
  1038. else {
  1039. constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1040. constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1041. constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0;
  1042. }
  1043. }
  1044. else {
  1045. constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
  1046. constraint.softness += (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.softness) * alpha;
  1047. if (direction == MixDirection.mixIn) {
  1048. constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1049. constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1050. constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0;
  1051. }
  1052. }
  1053. return;
  1054. }
  1055. var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES);
  1056. var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
  1057. var softness = frames[frame + IkConstraintTimeline.PREV_SOFTNESS];
  1058. var frameTime = frames[frame];
  1059. var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
  1060. if (blend == MixBlend.setup) {
  1061. constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
  1062. constraint.softness = constraint.data.softness
  1063. + (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.data.softness) * alpha;
  1064. if (direction == MixDirection.mixOut) {
  1065. constraint.bendDirection = constraint.data.bendDirection;
  1066. constraint.compress = constraint.data.compress;
  1067. constraint.stretch = constraint.data.stretch;
  1068. }
  1069. else {
  1070. constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1071. constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1072. constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0;
  1073. }
  1074. }
  1075. else {
  1076. constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
  1077. constraint.softness += (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.softness) * alpha;
  1078. if (direction == MixDirection.mixIn) {
  1079. constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1080. constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1081. constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0;
  1082. }
  1083. }
  1084. };
  1085. IkConstraintTimeline.ENTRIES = 6;
  1086. IkConstraintTimeline.PREV_TIME = -6;
  1087. IkConstraintTimeline.PREV_MIX = -5;
  1088. IkConstraintTimeline.PREV_SOFTNESS = -4;
  1089. IkConstraintTimeline.PREV_BEND_DIRECTION = -3;
  1090. IkConstraintTimeline.PREV_COMPRESS = -2;
  1091. IkConstraintTimeline.PREV_STRETCH = -1;
  1092. IkConstraintTimeline.MIX = 1;
  1093. IkConstraintTimeline.SOFTNESS = 2;
  1094. IkConstraintTimeline.BEND_DIRECTION = 3;
  1095. IkConstraintTimeline.COMPRESS = 4;
  1096. IkConstraintTimeline.STRETCH = 5;
  1097. return IkConstraintTimeline;
  1098. }(CurveTimeline));
  1099. spine.IkConstraintTimeline = IkConstraintTimeline;
  1100. var TransformConstraintTimeline = (function (_super) {
  1101. __extends(TransformConstraintTimeline, _super);
  1102. function TransformConstraintTimeline(frameCount) {
  1103. var _this = _super.call(this, frameCount) || this;
  1104. _this.frames = spine.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES);
  1105. return _this;
  1106. }
  1107. TransformConstraintTimeline.prototype.getPropertyId = function () {
  1108. return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex;
  1109. };
  1110. TransformConstraintTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) {
  1111. frameIndex *= TransformConstraintTimeline.ENTRIES;
  1112. this.frames[frameIndex] = time;
  1113. this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix;
  1114. this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix;
  1115. this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
  1116. this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
  1117. };
  1118. TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1119. var frames = this.frames;
  1120. var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
  1121. if (!constraint.active)
  1122. return;
  1123. if (time < frames[0]) {
  1124. var data = constraint.data;
  1125. switch (blend) {
  1126. case MixBlend.setup:
  1127. constraint.rotateMix = data.rotateMix;
  1128. constraint.translateMix = data.translateMix;
  1129. constraint.scaleMix = data.scaleMix;
  1130. constraint.shearMix = data.shearMix;
  1131. return;
  1132. case MixBlend.first:
  1133. constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
  1134. constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
  1135. constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
  1136. constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
  1137. }
  1138. return;
  1139. }
  1140. var rotate = 0, translate = 0, scale = 0, shear = 0;
  1141. if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
  1142. var i = frames.length;
  1143. rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE];
  1144. translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE];
  1145. scale = frames[i + TransformConstraintTimeline.PREV_SCALE];
  1146. shear = frames[i + TransformConstraintTimeline.PREV_SHEAR];
  1147. }
  1148. else {
  1149. var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES);
  1150. rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE];
  1151. translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE];
  1152. scale = frames[frame + TransformConstraintTimeline.PREV_SCALE];
  1153. shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR];
  1154. var frameTime = frames[frame];
  1155. var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime));
  1156. rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent;
  1157. translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent;
  1158. scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
  1159. shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
  1160. }
  1161. if (blend == MixBlend.setup) {
  1162. var data = constraint.data;
  1163. constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
  1164. constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
  1165. constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;
  1166. constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha;
  1167. }
  1168. else {
  1169. constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
  1170. constraint.translateMix += (translate - constraint.translateMix) * alpha;
  1171. constraint.scaleMix += (scale - constraint.scaleMix) * alpha;
  1172. constraint.shearMix += (shear - constraint.shearMix) * alpha;
  1173. }
  1174. };
  1175. TransformConstraintTimeline.ENTRIES = 5;
  1176. TransformConstraintTimeline.PREV_TIME = -5;
  1177. TransformConstraintTimeline.PREV_ROTATE = -4;
  1178. TransformConstraintTimeline.PREV_TRANSLATE = -3;
  1179. TransformConstraintTimeline.PREV_SCALE = -2;
  1180. TransformConstraintTimeline.PREV_SHEAR = -1;
  1181. TransformConstraintTimeline.ROTATE = 1;
  1182. TransformConstraintTimeline.TRANSLATE = 2;
  1183. TransformConstraintTimeline.SCALE = 3;
  1184. TransformConstraintTimeline.SHEAR = 4;
  1185. return TransformConstraintTimeline;
  1186. }(CurveTimeline));
  1187. spine.TransformConstraintTimeline = TransformConstraintTimeline;
  1188. var PathConstraintPositionTimeline = (function (_super) {
  1189. __extends(PathConstraintPositionTimeline, _super);
  1190. function PathConstraintPositionTimeline(frameCount) {
  1191. var _this = _super.call(this, frameCount) || this;
  1192. _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES);
  1193. return _this;
  1194. }
  1195. PathConstraintPositionTimeline.prototype.getPropertyId = function () {
  1196. return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex;
  1197. };
  1198. PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) {
  1199. frameIndex *= PathConstraintPositionTimeline.ENTRIES;
  1200. this.frames[frameIndex] = time;
  1201. this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
  1202. };
  1203. PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1204. var frames = this.frames;
  1205. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1206. if (!constraint.active)
  1207. return;
  1208. if (time < frames[0]) {
  1209. switch (blend) {
  1210. case MixBlend.setup:
  1211. constraint.position = constraint.data.position;
  1212. return;
  1213. case MixBlend.first:
  1214. constraint.position += (constraint.data.position - constraint.position) * alpha;
  1215. }
  1216. return;
  1217. }
  1218. var position = 0;
  1219. if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
  1220. position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
  1221. else {
  1222. var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES);
  1223. position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE];
  1224. var frameTime = frames[frame];
  1225. var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
  1226. position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
  1227. }
  1228. if (blend == MixBlend.setup)
  1229. constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
  1230. else
  1231. constraint.position += (position - constraint.position) * alpha;
  1232. };
  1233. PathConstraintPositionTimeline.ENTRIES = 2;
  1234. PathConstraintPositionTimeline.PREV_TIME = -2;
  1235. PathConstraintPositionTimeline.PREV_VALUE = -1;
  1236. PathConstraintPositionTimeline.VALUE = 1;
  1237. return PathConstraintPositionTimeline;
  1238. }(CurveTimeline));
  1239. spine.PathConstraintPositionTimeline = PathConstraintPositionTimeline;
  1240. var PathConstraintSpacingTimeline = (function (_super) {
  1241. __extends(PathConstraintSpacingTimeline, _super);
  1242. function PathConstraintSpacingTimeline(frameCount) {
  1243. return _super.call(this, frameCount) || this;
  1244. }
  1245. PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
  1246. return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
  1247. };
  1248. PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1249. var frames = this.frames;
  1250. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1251. if (!constraint.active)
  1252. return;
  1253. if (time < frames[0]) {
  1254. switch (blend) {
  1255. case MixBlend.setup:
  1256. constraint.spacing = constraint.data.spacing;
  1257. return;
  1258. case MixBlend.first:
  1259. constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
  1260. }
  1261. return;
  1262. }
  1263. var spacing = 0;
  1264. if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
  1265. spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
  1266. else {
  1267. var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES);
  1268. spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE];
  1269. var frameTime = frames[frame];
  1270. var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
  1271. spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
  1272. }
  1273. if (blend == MixBlend.setup)
  1274. constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
  1275. else
  1276. constraint.spacing += (spacing - constraint.spacing) * alpha;
  1277. };
  1278. return PathConstraintSpacingTimeline;
  1279. }(PathConstraintPositionTimeline));
  1280. spine.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline;
  1281. var PathConstraintMixTimeline = (function (_super) {
  1282. __extends(PathConstraintMixTimeline, _super);
  1283. function PathConstraintMixTimeline(frameCount) {
  1284. var _this = _super.call(this, frameCount) || this;
  1285. _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES);
  1286. return _this;
  1287. }
  1288. PathConstraintMixTimeline.prototype.getPropertyId = function () {
  1289. return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex;
  1290. };
  1291. PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) {
  1292. frameIndex *= PathConstraintMixTimeline.ENTRIES;
  1293. this.frames[frameIndex] = time;
  1294. this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
  1295. this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
  1296. };
  1297. PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1298. var frames = this.frames;
  1299. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1300. if (!constraint.active)
  1301. return;
  1302. if (time < frames[0]) {
  1303. switch (blend) {
  1304. case MixBlend.setup:
  1305. constraint.rotateMix = constraint.data.rotateMix;
  1306. constraint.translateMix = constraint.data.translateMix;
  1307. return;
  1308. case MixBlend.first:
  1309. constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
  1310. constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
  1311. }
  1312. return;
  1313. }
  1314. var rotate = 0, translate = 0;
  1315. if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
  1316. rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
  1317. translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE];
  1318. }
  1319. else {
  1320. var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES);
  1321. rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE];
  1322. translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE];
  1323. var frameTime = frames[frame];
  1324. var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime));
  1325. rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
  1326. translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
  1327. }
  1328. if (blend == MixBlend.setup) {
  1329. constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
  1330. constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
  1331. }
  1332. else {
  1333. constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
  1334. constraint.translateMix += (translate - constraint.translateMix) * alpha;
  1335. }
  1336. };
  1337. PathConstraintMixTimeline.ENTRIES = 3;
  1338. PathConstraintMixTimeline.PREV_TIME = -3;
  1339. PathConstraintMixTimeline.PREV_ROTATE = -2;
  1340. PathConstraintMixTimeline.PREV_TRANSLATE = -1;
  1341. PathConstraintMixTimeline.ROTATE = 1;
  1342. PathConstraintMixTimeline.TRANSLATE = 2;
  1343. return PathConstraintMixTimeline;
  1344. }(CurveTimeline));
  1345. spine.PathConstraintMixTimeline = PathConstraintMixTimeline;
  1346. })(spine || (spine = {}));
  1347. var spine;
  1348. (function (spine) {
  1349. var AnimationState = (function () {
  1350. function AnimationState(data) {
  1351. this.tracks = new Array();
  1352. this.timeScale = 1;
  1353. this.unkeyedState = 0;
  1354. this.events = new Array();
  1355. this.listeners = new Array();
  1356. this.queue = new EventQueue(this);
  1357. this.propertyIDs = new spine.IntSet();
  1358. this.animationsChanged = false;
  1359. this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
  1360. this.data = data;
  1361. }
  1362. AnimationState.prototype.update = function (delta) {
  1363. delta *= this.timeScale;
  1364. var tracks = this.tracks;
  1365. for (var i = 0, n = tracks.length; i < n; i++) {
  1366. var current = tracks[i];
  1367. if (current == null)
  1368. continue;
  1369. current.animationLast = current.nextAnimationLast;
  1370. current.trackLast = current.nextTrackLast;
  1371. var currentDelta = delta * current.timeScale;
  1372. if (current.delay > 0) {
  1373. current.delay -= currentDelta;
  1374. if (current.delay > 0)
  1375. continue;
  1376. currentDelta = -current.delay;
  1377. current.delay = 0;
  1378. }
  1379. var next = current.next;
  1380. if (next != null) {
  1381. var nextTime = current.trackLast - next.delay;
  1382. if (nextTime >= 0) {
  1383. next.delay = 0;
  1384. next.trackTime += current.timeScale == 0 ? 0 : (nextTime / current.timeScale + delta) * next.timeScale;
  1385. current.trackTime += currentDelta;
  1386. this.setCurrent(i, next, true);
  1387. while (next.mixingFrom != null) {
  1388. next.mixTime += delta;
  1389. next = next.mixingFrom;
  1390. }
  1391. continue;
  1392. }
  1393. }
  1394. else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) {
  1395. tracks[i] = null;
  1396. this.queue.end(current);
  1397. this.disposeNext(current);
  1398. continue;
  1399. }
  1400. if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) {
  1401. var from = current.mixingFrom;
  1402. current.mixingFrom = null;
  1403. if (from != null)
  1404. from.mixingTo = null;
  1405. while (from != null) {
  1406. this.queue.end(from);
  1407. from = from.mixingFrom;
  1408. }
  1409. }
  1410. current.trackTime += currentDelta;
  1411. }
  1412. this.queue.drain();
  1413. };
  1414. AnimationState.prototype.updateMixingFrom = function (to, delta) {
  1415. var from = to.mixingFrom;
  1416. if (from == null)
  1417. return true;
  1418. var finished = this.updateMixingFrom(from, delta);
  1419. from.animationLast = from.nextAnimationLast;
  1420. from.trackLast = from.nextTrackLast;
  1421. if (to.mixTime > 0 && to.mixTime >= to.mixDuration) {
  1422. if (from.totalAlpha == 0 || to.mixDuration == 0) {
  1423. to.mixingFrom = from.mixingFrom;
  1424. if (from.mixingFrom != null)
  1425. from.mixingFrom.mixingTo = to;
  1426. to.interruptAlpha = from.interruptAlpha;
  1427. this.queue.end(from);
  1428. }
  1429. return finished;
  1430. }
  1431. from.trackTime += delta * from.timeScale;
  1432. to.mixTime += delta;
  1433. return false;
  1434. };
  1435. AnimationState.prototype.apply = function (skeleton) {
  1436. if (skeleton == null)
  1437. throw new Error("skeleton cannot be null.");
  1438. if (this.animationsChanged)
  1439. this._animationsChanged();
  1440. var events = this.events;
  1441. var tracks = this.tracks;
  1442. var applied = false;
  1443. for (var i_16 = 0, n_1 = tracks.length; i_16 < n_1; i_16++) {
  1444. var current = tracks[i_16];
  1445. if (current == null || current.delay > 0)
  1446. continue;
  1447. applied = true;
  1448. var blend = i_16 == 0 ? spine.MixBlend.first : current.mixBlend;
  1449. var mix = current.alpha;
  1450. if (current.mixingFrom != null)
  1451. mix *= this.applyMixingFrom(current, skeleton, blend);
  1452. else if (current.trackTime >= current.trackEnd && current.next == null)
  1453. mix = 0;
  1454. var animationLast = current.animationLast, animationTime = current.getAnimationTime();
  1455. var timelineCount = current.animation.timelines.length;
  1456. var timelines = current.animation.timelines;
  1457. if ((i_16 == 0 && mix == 1) || blend == spine.MixBlend.add) {
  1458. for (var ii = 0; ii < timelineCount; ii++) {
  1459. spine.Utils.webkit602BugfixHelper(mix, blend);
  1460. var timeline = timelines[ii];
  1461. if (timeline instanceof spine.AttachmentTimeline)
  1462. this.applyAttachmentTimeline(timeline, skeleton, animationTime, blend, true);
  1463. else
  1464. timeline.apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection.mixIn);
  1465. }
  1466. }
  1467. else {
  1468. var timelineMode = current.timelineMode;
  1469. var firstFrame = current.timelinesRotation.length == 0;
  1470. if (firstFrame)
  1471. spine.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null);
  1472. var timelinesRotation = current.timelinesRotation;
  1473. for (var ii = 0; ii < timelineCount; ii++) {
  1474. var timeline_1 = timelines[ii];
  1475. var timelineBlend = timelineMode[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
  1476. if (timeline_1 instanceof spine.RotateTimeline) {
  1477. this.applyRotateTimeline(timeline_1, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
  1478. }
  1479. else if (timeline_1 instanceof spine.AttachmentTimeline) {
  1480. this.applyAttachmentTimeline(timeline_1, skeleton, animationTime, blend, true);
  1481. }
  1482. else {
  1483. spine.Utils.webkit602BugfixHelper(mix, blend);
  1484. timeline_1.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection.mixIn);
  1485. }
  1486. }
  1487. }
  1488. this.queueEvents(current, animationTime);
  1489. events.length = 0;
  1490. current.nextAnimationLast = animationTime;
  1491. current.nextTrackLast = current.trackTime;
  1492. }
  1493. var setupState = this.unkeyedState + AnimationState.SETUP;
  1494. var slots = skeleton.slots;
  1495. for (var i = 0, n = skeleton.slots.length; i < n; i++) {
  1496. var slot = slots[i];
  1497. if (slot.attachmentState == setupState) {
  1498. var attachmentName = slot.data.attachmentName;
  1499. slot.attachment = (attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName));
  1500. }
  1501. }
  1502. this.unkeyedState += 2;
  1503. this.queue.drain();
  1504. return applied;
  1505. };
  1506. AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
  1507. var from = to.mixingFrom;
  1508. if (from.mixingFrom != null)
  1509. this.applyMixingFrom(from, skeleton, blend);
  1510. var mix = 0;
  1511. if (to.mixDuration == 0) {
  1512. mix = 1;
  1513. if (blend == spine.MixBlend.first)
  1514. blend = spine.MixBlend.setup;
  1515. }
  1516. else {
  1517. mix = to.mixTime / to.mixDuration;
  1518. if (mix > 1)
  1519. mix = 1;
  1520. if (blend != spine.MixBlend.first)
  1521. blend = from.mixBlend;
  1522. }
  1523. var events = mix < from.eventThreshold ? this.events : null;
  1524. var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
  1525. var animationLast = from.animationLast, animationTime = from.getAnimationTime();
  1526. var timelineCount = from.animation.timelines.length;
  1527. var timelines = from.animation.timelines;
  1528. var alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix);
  1529. if (blend == spine.MixBlend.add) {
  1530. for (var i = 0; i < timelineCount; i++)
  1531. timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.mixOut);
  1532. }
  1533. else {
  1534. var timelineMode = from.timelineMode;
  1535. var timelineHoldMix = from.timelineHoldMix;
  1536. var firstFrame = from.timelinesRotation.length == 0;
  1537. if (firstFrame)
  1538. spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
  1539. var timelinesRotation = from.timelinesRotation;
  1540. from.totalAlpha = 0;
  1541. for (var i = 0; i < timelineCount; i++) {
  1542. var timeline = timelines[i];
  1543. var direction = spine.MixDirection.mixOut;
  1544. var timelineBlend = void 0;
  1545. var alpha = 0;
  1546. switch (timelineMode[i]) {
  1547. case AnimationState.SUBSEQUENT:
  1548. if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
  1549. continue;
  1550. timelineBlend = blend;
  1551. alpha = alphaMix;
  1552. break;
  1553. case AnimationState.FIRST:
  1554. timelineBlend = spine.MixBlend.setup;
  1555. alpha = alphaMix;
  1556. break;
  1557. case AnimationState.HOLD_SUBSEQUENT:
  1558. timelineBlend = blend;
  1559. alpha = alphaHold;
  1560. break;
  1561. case AnimationState.HOLD_FIRST:
  1562. timelineBlend = spine.MixBlend.setup;
  1563. alpha = alphaHold;
  1564. break;
  1565. default:
  1566. timelineBlend = spine.MixBlend.setup;
  1567. var holdMix = timelineHoldMix[i];
  1568. alpha = alphaHold * Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration);
  1569. break;
  1570. }
  1571. from.totalAlpha += alpha;
  1572. if (timeline instanceof spine.RotateTimeline)
  1573. this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
  1574. else if (timeline instanceof spine.AttachmentTimeline)
  1575. this.applyAttachmentTimeline(timeline, skeleton, animationTime, timelineBlend, attachments);
  1576. else {
  1577. spine.Utils.webkit602BugfixHelper(alpha, blend);
  1578. if (drawOrder && timeline instanceof spine.DrawOrderTimeline && timelineBlend == spine.MixBlend.setup)
  1579. direction = spine.MixDirection.mixIn;
  1580. timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction);
  1581. }
  1582. }
  1583. }
  1584. if (to.mixDuration > 0)
  1585. this.queueEvents(from, animationTime);
  1586. this.events.length = 0;
  1587. from.nextAnimationLast = animationTime;
  1588. from.nextTrackLast = from.trackTime;
  1589. return mix;
  1590. };
  1591. AnimationState.prototype.applyAttachmentTimeline = function (timeline, skeleton, time, blend, attachments) {
  1592. var slot = skeleton.slots[timeline.slotIndex];
  1593. if (!slot.bone.active)
  1594. return;
  1595. var frames = timeline.frames;
  1596. if (time < frames[0]) {
  1597. if (blend == spine.MixBlend.setup || blend == spine.MixBlend.first)
  1598. this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments);
  1599. }
  1600. else {
  1601. var frameIndex;
  1602. if (time >= frames[frames.length - 1])
  1603. frameIndex = frames.length - 1;
  1604. else
  1605. frameIndex = spine.Animation.binarySearch(frames, time) - 1;
  1606. this.setAttachment(skeleton, slot, timeline.attachmentNames[frameIndex], attachments);
  1607. }
  1608. if (slot.attachmentState <= this.unkeyedState)
  1609. slot.attachmentState = this.unkeyedState + AnimationState.SETUP;
  1610. };
  1611. AnimationState.prototype.setAttachment = function (skeleton, slot, attachmentName, attachments) {
  1612. slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName));
  1613. if (attachments)
  1614. slot.attachmentState = this.unkeyedState + AnimationState.CURRENT;
  1615. };
  1616. AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
  1617. if (firstFrame)
  1618. timelinesRotation[i] = 0;
  1619. if (alpha == 1) {
  1620. timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection.mixIn);
  1621. return;
  1622. }
  1623. var rotateTimeline = timeline;
  1624. var frames = rotateTimeline.frames;
  1625. var bone = skeleton.bones[rotateTimeline.boneIndex];
  1626. if (!bone.active)
  1627. return;
  1628. var r1 = 0, r2 = 0;
  1629. if (time < frames[0]) {
  1630. switch (blend) {
  1631. case spine.MixBlend.setup:
  1632. bone.rotation = bone.data.rotation;
  1633. default:
  1634. return;
  1635. case spine.MixBlend.first:
  1636. r1 = bone.rotation;
  1637. r2 = bone.data.rotation;
  1638. }
  1639. }
  1640. else {
  1641. r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
  1642. if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
  1643. r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
  1644. else {
  1645. var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
  1646. var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
  1647. var frameTime = frames[frame];
  1648. var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
  1649. r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
  1650. r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
  1651. r2 = prevRotation + r2 * percent + bone.data.rotation;
  1652. r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
  1653. }
  1654. }
  1655. var total = 0, diff = r2 - r1;
  1656. diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
  1657. if (diff == 0) {
  1658. total = timelinesRotation[i];
  1659. }
  1660. else {
  1661. var lastTotal = 0, lastDiff = 0;
  1662. if (firstFrame) {
  1663. lastTotal = 0;
  1664. lastDiff = diff;
  1665. }
  1666. else {
  1667. lastTotal = timelinesRotation[i];
  1668. lastDiff = timelinesRotation[i + 1];
  1669. }
  1670. var current = diff > 0, dir = lastTotal >= 0;
  1671. if (spine.MathUtils.signum(lastDiff) != spine.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) {
  1672. if (Math.abs(lastTotal) > 180)
  1673. lastTotal += 360 * spine.MathUtils.signum(lastTotal);
  1674. dir = current;
  1675. }
  1676. total = diff + lastTotal - lastTotal % 360;
  1677. if (dir != current)
  1678. total += 360 * spine.MathUtils.signum(lastTotal);
  1679. timelinesRotation[i] = total;
  1680. }
  1681. timelinesRotation[i + 1] = diff;
  1682. r1 += total * alpha;
  1683. bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360;
  1684. };
  1685. AnimationState.prototype.queueEvents = function (entry, animationTime) {
  1686. var animationStart = entry.animationStart, animationEnd = entry.animationEnd;
  1687. var duration = animationEnd - animationStart;
  1688. var trackLastWrapped = entry.trackLast % duration;
  1689. var events = this.events;
  1690. var i = 0, n = events.length;
  1691. for (; i < n; i++) {
  1692. var event_1 = events[i];
  1693. if (event_1.time < trackLastWrapped)
  1694. break;
  1695. if (event_1.time > animationEnd)
  1696. continue;
  1697. this.queue.event(entry, event_1);
  1698. }
  1699. var complete = false;
  1700. if (entry.loop)
  1701. complete = duration == 0 || trackLastWrapped > entry.trackTime % duration;
  1702. else
  1703. complete = animationTime >= animationEnd && entry.animationLast < animationEnd;
  1704. if (complete)
  1705. this.queue.complete(entry);
  1706. for (; i < n; i++) {
  1707. var event_2 = events[i];
  1708. if (event_2.time < animationStart)
  1709. continue;
  1710. this.queue.event(entry, events[i]);
  1711. }
  1712. };
  1713. AnimationState.prototype.clearTracks = function () {
  1714. var oldDrainDisabled = this.queue.drainDisabled;
  1715. this.queue.drainDisabled = true;
  1716. for (var i = 0, n = this.tracks.length; i < n; i++)
  1717. this.clearTrack(i);
  1718. this.tracks.length = 0;
  1719. this.queue.drainDisabled = oldDrainDisabled;
  1720. this.queue.drain();
  1721. };
  1722. AnimationState.prototype.clearTrack = function (trackIndex) {
  1723. if (trackIndex >= this.tracks.length)
  1724. return;
  1725. var current = this.tracks[trackIndex];
  1726. if (current == null)
  1727. return;
  1728. this.queue.end(current);
  1729. this.disposeNext(current);
  1730. var entry = current;
  1731. while (true) {
  1732. var from = entry.mixingFrom;
  1733. if (from == null)
  1734. break;
  1735. this.queue.end(from);
  1736. entry.mixingFrom = null;
  1737. entry.mixingTo = null;
  1738. entry = from;
  1739. }
  1740. this.tracks[current.trackIndex] = null;
  1741. this.queue.drain();
  1742. };
  1743. AnimationState.prototype.setCurrent = function (index, current, interrupt) {
  1744. var from = this.expandToIndex(index);
  1745. this.tracks[index] = current;
  1746. if (from != null) {
  1747. if (interrupt)
  1748. this.queue.interrupt(from);
  1749. current.mixingFrom = from;
  1750. from.mixingTo = current;
  1751. current.mixTime = 0;
  1752. if (from.mixingFrom != null && from.mixDuration > 0)
  1753. current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration);
  1754. from.timelinesRotation.length = 0;
  1755. }
  1756. this.queue.start(current);
  1757. };
  1758. AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) {
  1759. var animation = this.data.skeletonData.findAnimation(animationName);
  1760. if (animation == null)
  1761. throw new Error("Animation not found: " + animationName);
  1762. return this.setAnimationWith(trackIndex, animation, loop);
  1763. };
  1764. AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) {
  1765. if (animation == null)
  1766. throw new Error("animation cannot be null.");
  1767. var interrupt = true;
  1768. var current = this.expandToIndex(trackIndex);
  1769. if (current != null) {
  1770. if (current.nextTrackLast == -1) {
  1771. this.tracks[trackIndex] = current.mixingFrom;
  1772. this.queue.interrupt(current);
  1773. this.queue.end(current);
  1774. this.disposeNext(current);
  1775. current = current.mixingFrom;
  1776. interrupt = false;
  1777. }
  1778. else
  1779. this.disposeNext(current);
  1780. }
  1781. var entry = this.trackEntry(trackIndex, animation, loop, current);
  1782. this.setCurrent(trackIndex, entry, interrupt);
  1783. this.queue.drain();
  1784. return entry;
  1785. };
  1786. AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) {
  1787. var animation = this.data.skeletonData.findAnimation(animationName);
  1788. if (animation == null)
  1789. throw new Error("Animation not found: " + animationName);
  1790. return this.addAnimationWith(trackIndex, animation, loop, delay);
  1791. };
  1792. AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) {
  1793. if (animation == null)
  1794. throw new Error("animation cannot be null.");
  1795. var last = this.expandToIndex(trackIndex);
  1796. if (last != null) {
  1797. while (last.next != null)
  1798. last = last.next;
  1799. }
  1800. var entry = this.trackEntry(trackIndex, animation, loop, last);
  1801. if (last == null) {
  1802. this.setCurrent(trackIndex, entry, true);
  1803. this.queue.drain();
  1804. }
  1805. else {
  1806. last.next = entry;
  1807. if (delay <= 0) {
  1808. var duration = last.animationEnd - last.animationStart;
  1809. if (duration != 0) {
  1810. if (last.loop)
  1811. delay += duration * (1 + ((last.trackTime / duration) | 0));
  1812. else
  1813. delay += Math.max(duration, last.trackTime);
  1814. delay -= this.data.getMix(last.animation, animation);
  1815. }
  1816. else
  1817. delay = last.trackTime;
  1818. }
  1819. }
  1820. entry.delay = delay;
  1821. return entry;
  1822. };
  1823. AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) {
  1824. var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false);
  1825. entry.mixDuration = mixDuration;
  1826. entry.trackEnd = mixDuration;
  1827. return entry;
  1828. };
  1829. AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) {
  1830. if (delay <= 0)
  1831. delay -= mixDuration;
  1832. var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay);
  1833. entry.mixDuration = mixDuration;
  1834. entry.trackEnd = mixDuration;
  1835. return entry;
  1836. };
  1837. AnimationState.prototype.setEmptyAnimations = function (mixDuration) {
  1838. var oldDrainDisabled = this.queue.drainDisabled;
  1839. this.queue.drainDisabled = true;
  1840. for (var i = 0, n = this.tracks.length; i < n; i++) {
  1841. var current = this.tracks[i];
  1842. if (current != null)
  1843. this.setEmptyAnimation(current.trackIndex, mixDuration);
  1844. }
  1845. this.queue.drainDisabled = oldDrainDisabled;
  1846. this.queue.drain();
  1847. };
  1848. AnimationState.prototype.expandToIndex = function (index) {
  1849. if (index < this.tracks.length)
  1850. return this.tracks[index];
  1851. spine.Utils.ensureArrayCapacity(this.tracks, index + 1, null);
  1852. this.tracks.length = index + 1;
  1853. return null;
  1854. };
  1855. AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) {
  1856. var entry = this.trackEntryPool.obtain();
  1857. entry.trackIndex = trackIndex;
  1858. entry.animation = animation;
  1859. entry.loop = loop;
  1860. entry.holdPrevious = false;
  1861. entry.eventThreshold = 0;
  1862. entry.attachmentThreshold = 0;
  1863. entry.drawOrderThreshold = 0;
  1864. entry.animationStart = 0;
  1865. entry.animationEnd = animation.duration;
  1866. entry.animationLast = -1;
  1867. entry.nextAnimationLast = -1;
  1868. entry.delay = 0;
  1869. entry.trackTime = 0;
  1870. entry.trackLast = -1;
  1871. entry.nextTrackLast = -1;
  1872. entry.trackEnd = Number.MAX_VALUE;
  1873. entry.timeScale = 1;
  1874. entry.alpha = 1;
  1875. entry.interruptAlpha = 1;
  1876. entry.mixTime = 0;
  1877. entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation);
  1878. entry.mixBlend = spine.MixBlend.replace;
  1879. return entry;
  1880. };
  1881. AnimationState.prototype.disposeNext = function (entry) {
  1882. var next = entry.next;
  1883. while (next != null) {
  1884. this.queue.dispose(next);
  1885. next = next.next;
  1886. }
  1887. entry.next = null;
  1888. };
  1889. AnimationState.prototype._animationsChanged = function () {
  1890. this.animationsChanged = false;
  1891. this.propertyIDs.clear();
  1892. for (var i = 0, n = this.tracks.length; i < n; i++) {
  1893. var entry = this.tracks[i];
  1894. if (entry == null)
  1895. continue;
  1896. while (entry.mixingFrom != null)
  1897. entry = entry.mixingFrom;
  1898. do {
  1899. if (entry.mixingFrom == null || entry.mixBlend != spine.MixBlend.add)
  1900. this.computeHold(entry);
  1901. entry = entry.mixingTo;
  1902. } while (entry != null);
  1903. }
  1904. };
  1905. AnimationState.prototype.computeHold = function (entry) {
  1906. var to = entry.mixingTo;
  1907. var timelines = entry.animation.timelines;
  1908. var timelinesCount = entry.animation.timelines.length;
  1909. var timelineMode = spine.Utils.setArraySize(entry.timelineMode, timelinesCount);
  1910. entry.timelineHoldMix.length = 0;
  1911. var timelineDipMix = spine.Utils.setArraySize(entry.timelineHoldMix, timelinesCount);
  1912. var propertyIDs = this.propertyIDs;
  1913. if (to != null && to.holdPrevious) {
  1914. for (var i = 0; i < timelinesCount; i++) {
  1915. timelineMode[i] = propertyIDs.add(timelines[i].getPropertyId()) ? AnimationState.HOLD_FIRST : AnimationState.HOLD_SUBSEQUENT;
  1916. }
  1917. return;
  1918. }
  1919. outer: for (var i = 0; i < timelinesCount; i++) {
  1920. var timeline = timelines[i];
  1921. var id = timeline.getPropertyId();
  1922. if (!propertyIDs.add(id))
  1923. timelineMode[i] = AnimationState.SUBSEQUENT;
  1924. else if (to == null || timeline instanceof spine.AttachmentTimeline || timeline instanceof spine.DrawOrderTimeline
  1925. || timeline instanceof spine.EventTimeline || !to.animation.hasTimeline(id)) {
  1926. timelineMode[i] = AnimationState.FIRST;
  1927. }
  1928. else {
  1929. for (var next = to.mixingTo; next != null; next = next.mixingTo) {
  1930. if (next.animation.hasTimeline(id))
  1931. continue;
  1932. if (entry.mixDuration > 0) {
  1933. timelineMode[i] = AnimationState.HOLD_MIX;
  1934. timelineDipMix[i] = next;
  1935. continue outer;
  1936. }
  1937. break;
  1938. }
  1939. timelineMode[i] = AnimationState.HOLD_FIRST;
  1940. }
  1941. }
  1942. };
  1943. AnimationState.prototype.getCurrent = function (trackIndex) {
  1944. if (trackIndex >= this.tracks.length)
  1945. return null;
  1946. return this.tracks[trackIndex];
  1947. };
  1948. AnimationState.prototype.addListener = function (listener) {
  1949. if (listener == null)
  1950. throw new Error("listener cannot be null.");
  1951. this.listeners.push(listener);
  1952. };
  1953. AnimationState.prototype.removeListener = function (listener) {
  1954. var index = this.listeners.indexOf(listener);
  1955. if (index >= 0)
  1956. this.listeners.splice(index, 1);
  1957. };
  1958. AnimationState.prototype.clearListeners = function () {
  1959. this.listeners.length = 0;
  1960. };
  1961. AnimationState.prototype.clearListenerNotifications = function () {
  1962. this.queue.clear();
  1963. };
  1964. AnimationState.emptyAnimation = new spine.Animation("<empty>", [], 0);
  1965. AnimationState.SUBSEQUENT = 0;
  1966. AnimationState.FIRST = 1;
  1967. AnimationState.HOLD_SUBSEQUENT = 2;
  1968. AnimationState.HOLD_FIRST = 3;
  1969. AnimationState.HOLD_MIX = 4;
  1970. AnimationState.SETUP = 1;
  1971. AnimationState.CURRENT = 2;
  1972. return AnimationState;
  1973. }());
  1974. spine.AnimationState = AnimationState;
  1975. var TrackEntry = (function () {
  1976. function TrackEntry() {
  1977. this.mixBlend = spine.MixBlend.replace;
  1978. this.timelineMode = new Array();
  1979. this.timelineHoldMix = new Array();
  1980. this.timelinesRotation = new Array();
  1981. }
  1982. TrackEntry.prototype.reset = function () {
  1983. this.next = null;
  1984. this.mixingFrom = null;
  1985. this.mixingTo = null;
  1986. this.animation = null;
  1987. this.listener = null;
  1988. this.timelineMode.length = 0;
  1989. this.timelineHoldMix.length = 0;
  1990. this.timelinesRotation.length = 0;
  1991. };
  1992. TrackEntry.prototype.getAnimationTime = function () {
  1993. if (this.loop) {
  1994. var duration = this.animationEnd - this.animationStart;
  1995. if (duration == 0)
  1996. return this.animationStart;
  1997. return (this.trackTime % duration) + this.animationStart;
  1998. }
  1999. return Math.min(this.trackTime + this.animationStart, this.animationEnd);
  2000. };
  2001. TrackEntry.prototype.setAnimationLast = function (animationLast) {
  2002. this.animationLast = animationLast;
  2003. this.nextAnimationLast = animationLast;
  2004. };
  2005. TrackEntry.prototype.isComplete = function () {
  2006. return this.trackTime >= this.animationEnd - this.animationStart;
  2007. };
  2008. TrackEntry.prototype.resetRotationDirections = function () {
  2009. this.timelinesRotation.length = 0;
  2010. };
  2011. return TrackEntry;
  2012. }());
  2013. spine.TrackEntry = TrackEntry;
  2014. var EventQueue = (function () {
  2015. function EventQueue(animState) {
  2016. this.objects = [];
  2017. this.drainDisabled = false;
  2018. this.animState = animState;
  2019. }
  2020. EventQueue.prototype.start = function (entry) {
  2021. this.objects.push(EventType.start);
  2022. this.objects.push(entry);
  2023. this.animState.animationsChanged = true;
  2024. };
  2025. EventQueue.prototype.interrupt = function (entry) {
  2026. this.objects.push(EventType.interrupt);
  2027. this.objects.push(entry);
  2028. };
  2029. EventQueue.prototype.end = function (entry) {
  2030. this.objects.push(EventType.end);
  2031. this.objects.push(entry);
  2032. this.animState.animationsChanged = true;
  2033. };
  2034. EventQueue.prototype.dispose = function (entry) {
  2035. this.objects.push(EventType.dispose);
  2036. this.objects.push(entry);
  2037. };
  2038. EventQueue.prototype.complete = function (entry) {
  2039. this.objects.push(EventType.complete);
  2040. this.objects.push(entry);
  2041. };
  2042. EventQueue.prototype.event = function (entry, event) {
  2043. this.objects.push(EventType.event);
  2044. this.objects.push(entry);
  2045. this.objects.push(event);
  2046. };
  2047. EventQueue.prototype.drain = function () {
  2048. if (this.drainDisabled)
  2049. return;
  2050. this.drainDisabled = true;
  2051. var objects = this.objects;
  2052. var listeners = this.animState.listeners;
  2053. for (var i = 0; i < objects.length; i += 2) {
  2054. var type = objects[i];
  2055. var entry = objects[i + 1];
  2056. switch (type) {
  2057. case EventType.start:
  2058. if (entry.listener != null && entry.listener.start)
  2059. entry.listener.start(entry);
  2060. for (var ii = 0; ii < listeners.length; ii++)
  2061. if (listeners[ii].start)
  2062. listeners[ii].start(entry);
  2063. break;
  2064. case EventType.interrupt:
  2065. if (entry.listener != null && entry.listener.interrupt)
  2066. entry.listener.interrupt(entry);
  2067. for (var ii = 0; ii < listeners.length; ii++)
  2068. if (listeners[ii].interrupt)
  2069. listeners[ii].interrupt(entry);
  2070. break;
  2071. case EventType.end:
  2072. if (entry.listener != null && entry.listener.end)
  2073. entry.listener.end(entry);
  2074. for (var ii = 0; ii < listeners.length; ii++)
  2075. if (listeners[ii].end)
  2076. listeners[ii].end(entry);
  2077. case EventType.dispose:
  2078. if (entry.listener != null && entry.listener.dispose)
  2079. entry.listener.dispose(entry);
  2080. for (var ii = 0; ii < listeners.length; ii++)
  2081. if (listeners[ii].dispose)
  2082. listeners[ii].dispose(entry);
  2083. this.animState.trackEntryPool.free(entry);
  2084. break;
  2085. case EventType.complete:
  2086. if (entry.listener != null && entry.listener.complete)
  2087. entry.listener.complete(entry);
  2088. for (var ii = 0; ii < listeners.length; ii++)
  2089. if (listeners[ii].complete)
  2090. listeners[ii].complete(entry);
  2091. break;
  2092. case EventType.event:
  2093. var event_3 = objects[i++ + 2];
  2094. if (entry.listener != null && entry.listener.event)
  2095. entry.listener.event(entry, event_3);
  2096. for (var ii = 0; ii < listeners.length; ii++)
  2097. if (listeners[ii].event)
  2098. listeners[ii].event(entry, event_3);
  2099. break;
  2100. }
  2101. }
  2102. this.clear();
  2103. this.drainDisabled = false;
  2104. };
  2105. EventQueue.prototype.clear = function () {
  2106. this.objects.length = 0;
  2107. };
  2108. return EventQueue;
  2109. }());
  2110. spine.EventQueue = EventQueue;
  2111. var EventType;
  2112. (function (EventType) {
  2113. EventType[EventType["start"] = 0] = "start";
  2114. EventType[EventType["interrupt"] = 1] = "interrupt";
  2115. EventType[EventType["end"] = 2] = "end";
  2116. EventType[EventType["dispose"] = 3] = "dispose";
  2117. EventType[EventType["complete"] = 4] = "complete";
  2118. EventType[EventType["event"] = 5] = "event";
  2119. })(EventType = spine.EventType || (spine.EventType = {}));
  2120. var AnimationStateAdapter = (function () {
  2121. function AnimationStateAdapter() {
  2122. }
  2123. AnimationStateAdapter.prototype.start = function (entry) {
  2124. };
  2125. AnimationStateAdapter.prototype.interrupt = function (entry) {
  2126. };
  2127. AnimationStateAdapter.prototype.end = function (entry) {
  2128. };
  2129. AnimationStateAdapter.prototype.dispose = function (entry) {
  2130. };
  2131. AnimationStateAdapter.prototype.complete = function (entry) {
  2132. };
  2133. AnimationStateAdapter.prototype.event = function (entry, event) {
  2134. };
  2135. return AnimationStateAdapter;
  2136. }());
  2137. spine.AnimationStateAdapter = AnimationStateAdapter;
  2138. })(spine || (spine = {}));
  2139. var spine;
  2140. (function (spine) {
  2141. var AnimationStateData = (function () {
  2142. function AnimationStateData(skeletonData) {
  2143. this.animationToMixTime = {};
  2144. this.defaultMix = 0;
  2145. if (skeletonData == null)
  2146. throw new Error("skeletonData cannot be null.");
  2147. this.skeletonData = skeletonData;
  2148. }
  2149. AnimationStateData.prototype.setMix = function (fromName, toName, duration) {
  2150. var from = this.skeletonData.findAnimation(fromName);
  2151. if (from == null)
  2152. throw new Error("Animation not found: " + fromName);
  2153. var to = this.skeletonData.findAnimation(toName);
  2154. if (to == null)
  2155. throw new Error("Animation not found: " + toName);
  2156. this.setMixWith(from, to, duration);
  2157. };
  2158. AnimationStateData.prototype.setMixWith = function (from, to, duration) {
  2159. if (from == null)
  2160. throw new Error("from cannot be null.");
  2161. if (to == null)
  2162. throw new Error("to cannot be null.");
  2163. var key = from.name + "." + to.name;
  2164. this.animationToMixTime[key] = duration;
  2165. };
  2166. AnimationStateData.prototype.getMix = function (from, to) {
  2167. var key = from.name + "." + to.name;
  2168. var value = this.animationToMixTime[key];
  2169. return value === undefined ? this.defaultMix : value;
  2170. };
  2171. return AnimationStateData;
  2172. }());
  2173. spine.AnimationStateData = AnimationStateData;
  2174. })(spine || (spine = {}));
  2175. var spine;
  2176. (function (spine) {
  2177. var AssetManager = (function () {
  2178. function AssetManager(textureLoader, pathPrefix) {
  2179. if (pathPrefix === void 0) { pathPrefix = ""; }
  2180. this.assets = {};
  2181. this.errors = {};
  2182. this.toLoad = 0;
  2183. this.loaded = 0;
  2184. this.rawDataUris = {};
  2185. this.textureLoader = textureLoader;
  2186. this.pathPrefix = pathPrefix;
  2187. }
  2188. AssetManager.prototype.downloadText = function (url, success, error) {
  2189. var request = new XMLHttpRequest();
  2190. request.overrideMimeType("text/html");
  2191. if (this.rawDataUris[url])
  2192. url = this.rawDataUris[url];
  2193. request.open("GET", url, true);
  2194. request.onload = function () {
  2195. if (request.status == 200) {
  2196. success(request.responseText);
  2197. }
  2198. else {
  2199. error(request.status, request.responseText);
  2200. }
  2201. };
  2202. request.onerror = function () {
  2203. error(request.status, request.responseText);
  2204. };
  2205. request.send();
  2206. };
  2207. AssetManager.prototype.downloadBinary = function (url, success, error) {
  2208. var request = new XMLHttpRequest();
  2209. if (this.rawDataUris[url])
  2210. url = this.rawDataUris[url];
  2211. request.open("GET", url, true);
  2212. request.responseType = "arraybuffer";
  2213. request.onload = function () {
  2214. if (request.status == 200) {
  2215. success(new Uint8Array(request.response));
  2216. }
  2217. else {
  2218. error(request.status, request.responseText);
  2219. }
  2220. };
  2221. request.onerror = function () {
  2222. error(request.status, request.responseText);
  2223. };
  2224. request.send();
  2225. };
  2226. AssetManager.prototype.setRawDataURI = function (path, data) {
  2227. this.rawDataUris[this.pathPrefix + path] = data;
  2228. };
  2229. AssetManager.prototype.loadBinary = function (path, success, error) {
  2230. var _this = this;
  2231. if (success === void 0) { success = null; }
  2232. if (error === void 0) { error = null; }
  2233. path = this.pathPrefix + path;
  2234. this.toLoad++;
  2235. this.downloadBinary(path, function (data) {
  2236. _this.assets[path] = data;
  2237. if (success)
  2238. success(path, data);
  2239. _this.toLoad--;
  2240. _this.loaded++;
  2241. }, function (state, responseText) {
  2242. _this.errors[path] = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
  2243. if (error)
  2244. error(path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
  2245. _this.toLoad--;
  2246. _this.loaded++;
  2247. });
  2248. };
  2249. AssetManager.prototype.loadText = function (path, success, error) {
  2250. var _this = this;
  2251. if (success === void 0) { success = null; }
  2252. if (error === void 0) { error = null; }
  2253. path = this.pathPrefix + path;
  2254. this.toLoad++;
  2255. this.downloadText(path, function (data) {
  2256. _this.assets[path] = data;
  2257. if (success)
  2258. success(path, data);
  2259. _this.toLoad--;
  2260. _this.loaded++;
  2261. }, function (state, responseText) {
  2262. _this.errors[path] = "Couldn't load text " + path + ": status " + status + ", " + responseText;
  2263. if (error)
  2264. error(path, "Couldn't load text " + path + ": status " + status + ", " + responseText);
  2265. _this.toLoad--;
  2266. _this.loaded++;
  2267. });
  2268. };
  2269. AssetManager.prototype.loadTexture = function (path, success, error) {
  2270. var _this = this;
  2271. if (success === void 0) { success = null; }
  2272. if (error === void 0) { error = null; }
  2273. path = this.pathPrefix + path;
  2274. var storagePath = path;
  2275. this.toLoad++;
  2276. var img = new Image();
  2277. img.crossOrigin = "anonymous";
  2278. img.onload = function (ev) {
  2279. var texture = _this.textureLoader(img);
  2280. _this.assets[storagePath] = texture;
  2281. _this.toLoad--;
  2282. _this.loaded++;
  2283. if (success)
  2284. success(path, img);
  2285. };
  2286. img.onerror = function (ev) {
  2287. _this.errors[path] = "Couldn't load image " + path;
  2288. _this.toLoad--;
  2289. _this.loaded++;
  2290. if (error)
  2291. error(path, "Couldn't load image " + path);
  2292. };
  2293. if (this.rawDataUris[path])
  2294. path = this.rawDataUris[path];
  2295. img.src = path;
  2296. };
  2297. AssetManager.prototype.loadTextureAtlas = function (path, success, error) {
  2298. var _this = this;
  2299. if (success === void 0) { success = null; }
  2300. if (error === void 0) { error = null; }
  2301. var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
  2302. path = this.pathPrefix + path;
  2303. this.toLoad++;
  2304. this.downloadText(path, function (atlasData) {
  2305. var pagesLoaded = { count: 0 };
  2306. var atlasPages = new Array();
  2307. try {
  2308. var atlas = new spine.TextureAtlas(atlasData, function (path) {
  2309. atlasPages.push(parent == "" ? path : parent + "/" + path);
  2310. var image = document.createElement("img");
  2311. image.width = 16;
  2312. image.height = 16;
  2313. return new spine.FakeTexture(image);
  2314. });
  2315. }
  2316. catch (e) {
  2317. var ex = e;
  2318. _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message;
  2319. if (error)
  2320. error(path, "Couldn't load texture atlas " + path + ": " + ex.message);
  2321. _this.toLoad--;
  2322. _this.loaded++;
  2323. return;
  2324. }
  2325. var _loop_1 = function (atlasPage) {
  2326. var pageLoadError = false;
  2327. _this.loadTexture(atlasPage, function (imagePath, image) {
  2328. pagesLoaded.count++;
  2329. if (pagesLoaded.count == atlasPages.length) {
  2330. if (!pageLoadError) {
  2331. try {
  2332. var atlas = new spine.TextureAtlas(atlasData, function (path) {
  2333. return _this.get(parent == "" ? path : parent + "/" + path);
  2334. });
  2335. _this.assets[path] = atlas;
  2336. if (success)
  2337. success(path, atlas);
  2338. _this.toLoad--;
  2339. _this.loaded++;
  2340. }
  2341. catch (e) {
  2342. var ex = e;
  2343. _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message;
  2344. if (error)
  2345. error(path, "Couldn't load texture atlas " + path + ": " + ex.message);
  2346. _this.toLoad--;
  2347. _this.loaded++;
  2348. }
  2349. }
  2350. else {
  2351. _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path;
  2352. if (error)
  2353. error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path);
  2354. _this.toLoad--;
  2355. _this.loaded++;
  2356. }
  2357. }
  2358. }, function (imagePath, errorMessage) {
  2359. pageLoadError = true;
  2360. pagesLoaded.count++;
  2361. if (pagesLoaded.count == atlasPages.length) {
  2362. _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path;
  2363. if (error)
  2364. error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path);
  2365. _this.toLoad--;
  2366. _this.loaded++;
  2367. }
  2368. });
  2369. };
  2370. for (var _i = 0, atlasPages_1 = atlasPages; _i < atlasPages_1.length; _i++) {
  2371. var atlasPage = atlasPages_1[_i];
  2372. _loop_1(atlasPage);
  2373. }
  2374. }, function (state, responseText) {
  2375. _this.errors[path] = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
  2376. if (error)
  2377. error(path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText);
  2378. _this.toLoad--;
  2379. _this.loaded++;
  2380. });
  2381. };
  2382. AssetManager.prototype.get = function (path) {
  2383. path = this.pathPrefix + path;
  2384. return this.assets[path];
  2385. };
  2386. AssetManager.prototype.remove = function (path) {
  2387. path = this.pathPrefix + path;
  2388. var asset = this.assets[path];
  2389. if (asset.dispose)
  2390. asset.dispose();
  2391. this.assets[path] = null;
  2392. };
  2393. AssetManager.prototype.removeAll = function () {
  2394. for (var key in this.assets) {
  2395. var asset = this.assets[key];
  2396. if (asset.dispose)
  2397. asset.dispose();
  2398. }
  2399. this.assets = {};
  2400. };
  2401. AssetManager.prototype.isLoadingComplete = function () {
  2402. return this.toLoad == 0;
  2403. };
  2404. AssetManager.prototype.getToLoad = function () {
  2405. return this.toLoad;
  2406. };
  2407. AssetManager.prototype.getLoaded = function () {
  2408. return this.loaded;
  2409. };
  2410. AssetManager.prototype.dispose = function () {
  2411. this.removeAll();
  2412. };
  2413. AssetManager.prototype.hasErrors = function () {
  2414. return Object.keys(this.errors).length > 0;
  2415. };
  2416. AssetManager.prototype.getErrors = function () {
  2417. return this.errors;
  2418. };
  2419. return AssetManager;
  2420. }());
  2421. spine.AssetManager = AssetManager;
  2422. })(spine || (spine = {}));
  2423. var spine;
  2424. (function (spine) {
  2425. var AtlasAttachmentLoader = (function () {
  2426. function AtlasAttachmentLoader(atlas) {
  2427. this.atlas = atlas;
  2428. }
  2429. AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) {
  2430. var region = this.atlas.findRegion(path);
  2431. if (region == null)
  2432. throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")");
  2433. region.renderObject = region;
  2434. var attachment = new spine.RegionAttachment(name);
  2435. attachment.setRegion(region);
  2436. return attachment;
  2437. };
  2438. AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) {
  2439. var region = this.atlas.findRegion(path);
  2440. if (region == null)
  2441. throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
  2442. region.renderObject = region;
  2443. var attachment = new spine.MeshAttachment(name);
  2444. attachment.region = region;
  2445. return attachment;
  2446. };
  2447. AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) {
  2448. return new spine.BoundingBoxAttachment(name);
  2449. };
  2450. AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) {
  2451. return new spine.PathAttachment(name);
  2452. };
  2453. AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) {
  2454. return new spine.PointAttachment(name);
  2455. };
  2456. AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) {
  2457. return new spine.ClippingAttachment(name);
  2458. };
  2459. return AtlasAttachmentLoader;
  2460. }());
  2461. spine.AtlasAttachmentLoader = AtlasAttachmentLoader;
  2462. })(spine || (spine = {}));
  2463. var spine;
  2464. (function (spine) {
  2465. var BlendMode;
  2466. (function (BlendMode) {
  2467. BlendMode[BlendMode["Normal"] = 0] = "Normal";
  2468. BlendMode[BlendMode["Additive"] = 1] = "Additive";
  2469. BlendMode[BlendMode["Multiply"] = 2] = "Multiply";
  2470. BlendMode[BlendMode["Screen"] = 3] = "Screen";
  2471. })(BlendMode = spine.BlendMode || (spine.BlendMode = {}));
  2472. })(spine || (spine = {}));
  2473. var spine;
  2474. (function (spine) {
  2475. var Bone = (function () {
  2476. function Bone(data, skeleton, parent) {
  2477. this.children = new Array();
  2478. this.x = 0;
  2479. this.y = 0;
  2480. this.rotation = 0;
  2481. this.scaleX = 0;
  2482. this.scaleY = 0;
  2483. this.shearX = 0;
  2484. this.shearY = 0;
  2485. this.ax = 0;
  2486. this.ay = 0;
  2487. this.arotation = 0;
  2488. this.ascaleX = 0;
  2489. this.ascaleY = 0;
  2490. this.ashearX = 0;
  2491. this.ashearY = 0;
  2492. this.appliedValid = false;
  2493. this.a = 0;
  2494. this.b = 0;
  2495. this.c = 0;
  2496. this.d = 0;
  2497. this.worldY = 0;
  2498. this.worldX = 0;
  2499. this.sorted = false;
  2500. this.active = false;
  2501. if (data == null)
  2502. throw new Error("data cannot be null.");
  2503. if (skeleton == null)
  2504. throw new Error("skeleton cannot be null.");
  2505. this.data = data;
  2506. this.skeleton = skeleton;
  2507. this.parent = parent;
  2508. this.setToSetupPose();
  2509. }
  2510. Bone.prototype.isActive = function () {
  2511. return this.active;
  2512. };
  2513. Bone.prototype.update = function () {
  2514. this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);
  2515. };
  2516. Bone.prototype.updateWorldTransform = function () {
  2517. this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);
  2518. };
  2519. Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) {
  2520. this.ax = x;
  2521. this.ay = y;
  2522. this.arotation = rotation;
  2523. this.ascaleX = scaleX;
  2524. this.ascaleY = scaleY;
  2525. this.ashearX = shearX;
  2526. this.ashearY = shearY;
  2527. this.appliedValid = true;
  2528. var parent = this.parent;
  2529. if (parent == null) {
  2530. var skeleton = this.skeleton;
  2531. var rotationY = rotation + 90 + shearY;
  2532. var sx = skeleton.scaleX;
  2533. var sy = skeleton.scaleY;
  2534. this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
  2535. this.b = spine.MathUtils.cosDeg(rotationY) * scaleY * sx;
  2536. this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX * sy;
  2537. this.d = spine.MathUtils.sinDeg(rotationY) * scaleY * sy;
  2538. this.worldX = x * sx + skeleton.x;
  2539. this.worldY = y * sy + skeleton.y;
  2540. return;
  2541. }
  2542. var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
  2543. this.worldX = pa * x + pb * y + parent.worldX;
  2544. this.worldY = pc * x + pd * y + parent.worldY;
  2545. switch (this.data.transformMode) {
  2546. case spine.TransformMode.Normal: {
  2547. var rotationY = rotation + 90 + shearY;
  2548. var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;
  2549. var lb = spine.MathUtils.cosDeg(rotationY) * scaleY;
  2550. var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;
  2551. var ld = spine.MathUtils.sinDeg(rotationY) * scaleY;
  2552. this.a = pa * la + pb * lc;
  2553. this.b = pa * lb + pb * ld;
  2554. this.c = pc * la + pd * lc;
  2555. this.d = pc * lb + pd * ld;
  2556. return;
  2557. }
  2558. case spine.TransformMode.OnlyTranslation: {
  2559. var rotationY = rotation + 90 + shearY;
  2560. this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;
  2561. this.b = spine.MathUtils.cosDeg(rotationY) * scaleY;
  2562. this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;
  2563. this.d = spine.MathUtils.sinDeg(rotationY) * scaleY;
  2564. break;
  2565. }
  2566. case spine.TransformMode.NoRotationOrReflection: {
  2567. var s = pa * pa + pc * pc;
  2568. var prx = 0;
  2569. if (s > 0.0001) {
  2570. s = Math.abs(pa * pd - pb * pc) / s;
  2571. pa /= this.skeleton.scaleX;
  2572. pc /= this.skeleton.scaleY;
  2573. pb = pc * s;
  2574. pd = pa * s;
  2575. prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
  2576. }
  2577. else {
  2578. pa = 0;
  2579. pc = 0;
  2580. prx = 90 - Math.atan2(pd, pb) * spine.MathUtils.radDeg;
  2581. }
  2582. var rx = rotation + shearX - prx;
  2583. var ry = rotation + shearY - prx + 90;
  2584. var la = spine.MathUtils.cosDeg(rx) * scaleX;
  2585. var lb = spine.MathUtils.cosDeg(ry) * scaleY;
  2586. var lc = spine.MathUtils.sinDeg(rx) * scaleX;
  2587. var ld = spine.MathUtils.sinDeg(ry) * scaleY;
  2588. this.a = pa * la - pb * lc;
  2589. this.b = pa * lb - pb * ld;
  2590. this.c = pc * la + pd * lc;
  2591. this.d = pc * lb + pd * ld;
  2592. break;
  2593. }
  2594. case spine.TransformMode.NoScale:
  2595. case spine.TransformMode.NoScaleOrReflection: {
  2596. var cos = spine.MathUtils.cosDeg(rotation);
  2597. var sin = spine.MathUtils.sinDeg(rotation);
  2598. var za = (pa * cos + pb * sin) / this.skeleton.scaleX;
  2599. var zc = (pc * cos + pd * sin) / this.skeleton.scaleY;
  2600. var s = Math.sqrt(za * za + zc * zc);
  2601. if (s > 0.00001)
  2602. s = 1 / s;
  2603. za *= s;
  2604. zc *= s;
  2605. s = Math.sqrt(za * za + zc * zc);
  2606. if (this.data.transformMode == spine.TransformMode.NoScale
  2607. && (pa * pd - pb * pc < 0) != (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0))
  2608. s = -s;
  2609. var r = Math.PI / 2 + Math.atan2(zc, za);
  2610. var zb = Math.cos(r) * s;
  2611. var zd = Math.sin(r) * s;
  2612. var la = spine.MathUtils.cosDeg(shearX) * scaleX;
  2613. var lb = spine.MathUtils.cosDeg(90 + shearY) * scaleY;
  2614. var lc = spine.MathUtils.sinDeg(shearX) * scaleX;
  2615. var ld = spine.MathUtils.sinDeg(90 + shearY) * scaleY;
  2616. this.a = za * la + zb * lc;
  2617. this.b = za * lb + zb * ld;
  2618. this.c = zc * la + zd * lc;
  2619. this.d = zc * lb + zd * ld;
  2620. break;
  2621. }
  2622. }
  2623. this.a *= this.skeleton.scaleX;
  2624. this.b *= this.skeleton.scaleX;
  2625. this.c *= this.skeleton.scaleY;
  2626. this.d *= this.skeleton.scaleY;
  2627. };
  2628. Bone.prototype.setToSetupPose = function () {
  2629. var data = this.data;
  2630. this.x = data.x;
  2631. this.y = data.y;
  2632. this.rotation = data.rotation;
  2633. this.scaleX = data.scaleX;
  2634. this.scaleY = data.scaleY;
  2635. this.shearX = data.shearX;
  2636. this.shearY = data.shearY;
  2637. };
  2638. Bone.prototype.getWorldRotationX = function () {
  2639. return Math.atan2(this.c, this.a) * spine.MathUtils.radDeg;
  2640. };
  2641. Bone.prototype.getWorldRotationY = function () {
  2642. return Math.atan2(this.d, this.b) * spine.MathUtils.radDeg;
  2643. };
  2644. Bone.prototype.getWorldScaleX = function () {
  2645. return Math.sqrt(this.a * this.a + this.c * this.c);
  2646. };
  2647. Bone.prototype.getWorldScaleY = function () {
  2648. return Math.sqrt(this.b * this.b + this.d * this.d);
  2649. };
  2650. Bone.prototype.updateAppliedTransform = function () {
  2651. this.appliedValid = true;
  2652. var parent = this.parent;
  2653. if (parent == null) {
  2654. this.ax = this.worldX;
  2655. this.ay = this.worldY;
  2656. this.arotation = Math.atan2(this.c, this.a) * spine.MathUtils.radDeg;
  2657. this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c);
  2658. this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d);
  2659. this.ashearX = 0;
  2660. this.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * spine.MathUtils.radDeg;
  2661. return;
  2662. }
  2663. var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
  2664. var pid = 1 / (pa * pd - pb * pc);
  2665. var dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY;
  2666. this.ax = (dx * pd * pid - dy * pb * pid);
  2667. this.ay = (dy * pa * pid - dx * pc * pid);
  2668. var ia = pid * pd;
  2669. var id = pid * pa;
  2670. var ib = pid * pb;
  2671. var ic = pid * pc;
  2672. var ra = ia * this.a - ib * this.c;
  2673. var rb = ia * this.b - ib * this.d;
  2674. var rc = id * this.c - ic * this.a;
  2675. var rd = id * this.d - ic * this.b;
  2676. this.ashearX = 0;
  2677. this.ascaleX = Math.sqrt(ra * ra + rc * rc);
  2678. if (this.ascaleX > 0.0001) {
  2679. var det = ra * rd - rb * rc;
  2680. this.ascaleY = det / this.ascaleX;
  2681. this.ashearY = Math.atan2(ra * rb + rc * rd, det) * spine.MathUtils.radDeg;
  2682. this.arotation = Math.atan2(rc, ra) * spine.MathUtils.radDeg;
  2683. }
  2684. else {
  2685. this.ascaleX = 0;
  2686. this.ascaleY = Math.sqrt(rb * rb + rd * rd);
  2687. this.ashearY = 0;
  2688. this.arotation = 90 - Math.atan2(rd, rb) * spine.MathUtils.radDeg;
  2689. }
  2690. };
  2691. Bone.prototype.worldToLocal = function (world) {
  2692. var a = this.a, b = this.b, c = this.c, d = this.d;
  2693. var invDet = 1 / (a * d - b * c);
  2694. var x = world.x - this.worldX, y = world.y - this.worldY;
  2695. world.x = (x * d * invDet - y * b * invDet);
  2696. world.y = (y * a * invDet - x * c * invDet);
  2697. return world;
  2698. };
  2699. Bone.prototype.localToWorld = function (local) {
  2700. var x = local.x, y = local.y;
  2701. local.x = x * this.a + y * this.b + this.worldX;
  2702. local.y = x * this.c + y * this.d + this.worldY;
  2703. return local;
  2704. };
  2705. Bone.prototype.worldToLocalRotation = function (worldRotation) {
  2706. var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
  2707. return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
  2708. };
  2709. Bone.prototype.localToWorldRotation = function (localRotation) {
  2710. localRotation -= this.rotation - this.shearX;
  2711. var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
  2712. return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
  2713. };
  2714. Bone.prototype.rotateWorld = function (degrees) {
  2715. var a = this.a, b = this.b, c = this.c, d = this.d;
  2716. var cos = spine.MathUtils.cosDeg(degrees), sin = spine.MathUtils.sinDeg(degrees);
  2717. this.a = cos * a - sin * c;
  2718. this.b = cos * b - sin * d;
  2719. this.c = sin * a + cos * c;
  2720. this.d = sin * b + cos * d;
  2721. this.appliedValid = false;
  2722. };
  2723. return Bone;
  2724. }());
  2725. spine.Bone = Bone;
  2726. })(spine || (spine = {}));
  2727. var spine;
  2728. (function (spine) {
  2729. var BoneData = (function () {
  2730. function BoneData(index, name, parent) {
  2731. this.x = 0;
  2732. this.y = 0;
  2733. this.rotation = 0;
  2734. this.scaleX = 1;
  2735. this.scaleY = 1;
  2736. this.shearX = 0;
  2737. this.shearY = 0;
  2738. this.transformMode = TransformMode.Normal;
  2739. this.skinRequired = false;
  2740. this.color = new spine.Color();
  2741. if (index < 0)
  2742. throw new Error("index must be >= 0.");
  2743. if (name == null)
  2744. throw new Error("name cannot be null.");
  2745. this.index = index;
  2746. this.name = name;
  2747. this.parent = parent;
  2748. }
  2749. return BoneData;
  2750. }());
  2751. spine.BoneData = BoneData;
  2752. var TransformMode;
  2753. (function (TransformMode) {
  2754. TransformMode[TransformMode["Normal"] = 0] = "Normal";
  2755. TransformMode[TransformMode["OnlyTranslation"] = 1] = "OnlyTranslation";
  2756. TransformMode[TransformMode["NoRotationOrReflection"] = 2] = "NoRotationOrReflection";
  2757. TransformMode[TransformMode["NoScale"] = 3] = "NoScale";
  2758. TransformMode[TransformMode["NoScaleOrReflection"] = 4] = "NoScaleOrReflection";
  2759. })(TransformMode = spine.TransformMode || (spine.TransformMode = {}));
  2760. })(spine || (spine = {}));
  2761. var spine;
  2762. (function (spine) {
  2763. var ConstraintData = (function () {
  2764. function ConstraintData(name, order, skinRequired) {
  2765. this.name = name;
  2766. this.order = order;
  2767. this.skinRequired = skinRequired;
  2768. }
  2769. return ConstraintData;
  2770. }());
  2771. spine.ConstraintData = ConstraintData;
  2772. })(spine || (spine = {}));
  2773. var spine;
  2774. (function (spine) {
  2775. var Event = (function () {
  2776. function Event(time, data) {
  2777. if (data == null)
  2778. throw new Error("data cannot be null.");
  2779. this.time = time;
  2780. this.data = data;
  2781. }
  2782. return Event;
  2783. }());
  2784. spine.Event = Event;
  2785. })(spine || (spine = {}));
  2786. var spine;
  2787. (function (spine) {
  2788. var EventData = (function () {
  2789. function EventData(name) {
  2790. this.name = name;
  2791. }
  2792. return EventData;
  2793. }());
  2794. spine.EventData = EventData;
  2795. })(spine || (spine = {}));
  2796. var spine;
  2797. (function (spine) {
  2798. var IkConstraint = (function () {
  2799. function IkConstraint(data, skeleton) {
  2800. this.bendDirection = 0;
  2801. this.compress = false;
  2802. this.stretch = false;
  2803. this.mix = 1;
  2804. this.softness = 0;
  2805. this.active = false;
  2806. if (data == null)
  2807. throw new Error("data cannot be null.");
  2808. if (skeleton == null)
  2809. throw new Error("skeleton cannot be null.");
  2810. this.data = data;
  2811. this.mix = data.mix;
  2812. this.softness = data.softness;
  2813. this.bendDirection = data.bendDirection;
  2814. this.compress = data.compress;
  2815. this.stretch = data.stretch;
  2816. this.bones = new Array();
  2817. for (var i = 0; i < data.bones.length; i++)
  2818. this.bones.push(skeleton.findBone(data.bones[i].name));
  2819. this.target = skeleton.findBone(data.target.name);
  2820. }
  2821. IkConstraint.prototype.isActive = function () {
  2822. return this.active;
  2823. };
  2824. IkConstraint.prototype.apply = function () {
  2825. this.update();
  2826. };
  2827. IkConstraint.prototype.update = function () {
  2828. var target = this.target;
  2829. var bones = this.bones;
  2830. switch (bones.length) {
  2831. case 1:
  2832. this.apply1(bones[0], target.worldX, target.worldY, this.compress, this.stretch, this.data.uniform, this.mix);
  2833. break;
  2834. case 2:
  2835. this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.stretch, this.softness, this.mix);
  2836. break;
  2837. }
  2838. };
  2839. IkConstraint.prototype.apply1 = function (bone, targetX, targetY, compress, stretch, uniform, alpha) {
  2840. if (!bone.appliedValid)
  2841. bone.updateAppliedTransform();
  2842. var p = bone.parent;
  2843. var pa = p.a, pb = p.b, pc = p.c, pd = p.d;
  2844. var rotationIK = -bone.ashearX - bone.arotation, tx = 0, ty = 0;
  2845. switch (bone.data.transformMode) {
  2846. case spine.TransformMode.OnlyTranslation:
  2847. tx = targetX - bone.worldX;
  2848. ty = targetY - bone.worldY;
  2849. break;
  2850. case spine.TransformMode.NoRotationOrReflection:
  2851. var s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
  2852. var sa = pa / bone.skeleton.scaleX;
  2853. var sc = pc / bone.skeleton.scaleY;
  2854. pb = -sc * s * bone.skeleton.scaleX;
  2855. pd = sa * s * bone.skeleton.scaleY;
  2856. rotationIK += Math.atan2(sc, sa) * spine.MathUtils.radDeg;
  2857. default:
  2858. var x = targetX - p.worldX, y = targetY - p.worldY;
  2859. var d = pa * pd - pb * pc;
  2860. tx = (x * pd - y * pb) / d - bone.ax;
  2861. ty = (y * pa - x * pc) / d - bone.ay;
  2862. }
  2863. rotationIK += Math.atan2(ty, tx) * spine.MathUtils.radDeg;
  2864. if (bone.ascaleX < 0)
  2865. rotationIK += 180;
  2866. if (rotationIK > 180)
  2867. rotationIK -= 360;
  2868. else if (rotationIK < -180)
  2869. rotationIK += 360;
  2870. var sx = bone.ascaleX, sy = bone.ascaleY;
  2871. if (compress || stretch) {
  2872. switch (bone.data.transformMode) {
  2873. case spine.TransformMode.NoScale:
  2874. case spine.TransformMode.NoScaleOrReflection:
  2875. tx = targetX - bone.worldX;
  2876. ty = targetY - bone.worldY;
  2877. }
  2878. var b = bone.data.length * sx, dd = Math.sqrt(tx * tx + ty * ty);
  2879. if ((compress && dd < b) || (stretch && dd > b) && b > 0.0001) {
  2880. var s = (dd / b - 1) * alpha + 1;
  2881. sx *= s;
  2882. if (uniform)
  2883. sy *= s;
  2884. }
  2885. }
  2886. bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, sx, sy, bone.ashearX, bone.ashearY);
  2887. };
  2888. IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, stretch, softness, alpha) {
  2889. if (alpha == 0) {
  2890. child.updateWorldTransform();
  2891. return;
  2892. }
  2893. if (!parent.appliedValid)
  2894. parent.updateAppliedTransform();
  2895. if (!child.appliedValid)
  2896. child.updateAppliedTransform();
  2897. var px = parent.ax, py = parent.ay, psx = parent.ascaleX, sx = psx, psy = parent.ascaleY, csx = child.ascaleX;
  2898. var os1 = 0, os2 = 0, s2 = 0;
  2899. if (psx < 0) {
  2900. psx = -psx;
  2901. os1 = 180;
  2902. s2 = -1;
  2903. }
  2904. else {
  2905. os1 = 0;
  2906. s2 = 1;
  2907. }
  2908. if (psy < 0) {
  2909. psy = -psy;
  2910. s2 = -s2;
  2911. }
  2912. if (csx < 0) {
  2913. csx = -csx;
  2914. os2 = 180;
  2915. }
  2916. else
  2917. os2 = 0;
  2918. var cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d;
  2919. var u = Math.abs(psx - psy) <= 0.0001;
  2920. if (!u) {
  2921. cy = 0;
  2922. cwx = a * cx + parent.worldX;
  2923. cwy = c * cx + parent.worldY;
  2924. }
  2925. else {
  2926. cy = child.ay;
  2927. cwx = a * cx + b * cy + parent.worldX;
  2928. cwy = c * cx + d * cy + parent.worldY;
  2929. }
  2930. var pp = parent.parent;
  2931. a = pp.a;
  2932. b = pp.b;
  2933. c = pp.c;
  2934. d = pp.d;
  2935. var id = 1 / (a * d - b * c), x = cwx - pp.worldX, y = cwy - pp.worldY;
  2936. var dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
  2937. var l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
  2938. if (l1 < 0.0001) {
  2939. this.apply1(parent, targetX, targetY, false, stretch, false, alpha);
  2940. child.updateWorldTransformWith(cx, cy, 0, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY);
  2941. return;
  2942. }
  2943. x = targetX - pp.worldX;
  2944. y = targetY - pp.worldY;
  2945. var tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py;
  2946. var dd = tx * tx + ty * ty;
  2947. if (softness != 0) {
  2948. softness *= psx * (csx + 1) / 2;
  2949. var td = Math.sqrt(dd), sd = td - l1 - l2 * psx + softness;
  2950. if (sd > 0) {
  2951. var p = Math.min(1, sd / (softness * 2)) - 1;
  2952. p = (sd - softness * (1 - p * p)) / td;
  2953. tx -= p * tx;
  2954. ty -= p * ty;
  2955. dd = tx * tx + ty * ty;
  2956. }
  2957. }
  2958. outer: if (u) {
  2959. l2 *= psx;
  2960. var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2);
  2961. if (cos < -1)
  2962. cos = -1;
  2963. else if (cos > 1) {
  2964. cos = 1;
  2965. if (stretch)
  2966. sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1;
  2967. }
  2968. a2 = Math.acos(cos) * bendDir;
  2969. a = l1 + l2 * cos;
  2970. b = l2 * Math.sin(a2);
  2971. a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b);
  2972. }
  2973. else {
  2974. a = psx * l2;
  2975. b = psy * l2;
  2976. var aa = a * a, bb = b * b, ta = Math.atan2(ty, tx);
  2977. c = bb * l1 * l1 + aa * dd - aa * bb;
  2978. var c1 = -2 * bb * l1, c2 = bb - aa;
  2979. d = c1 * c1 - 4 * c2 * c;
  2980. if (d >= 0) {
  2981. var q = Math.sqrt(d);
  2982. if (c1 < 0)
  2983. q = -q;
  2984. q = -(c1 + q) / 2;
  2985. var r0 = q / c2, r1 = c / q;
  2986. var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
  2987. if (r * r <= dd) {
  2988. y = Math.sqrt(dd - r * r) * bendDir;
  2989. a1 = ta - Math.atan2(y, r);
  2990. a2 = Math.atan2(y / psy, (r - l1) / psx);
  2991. break outer;
  2992. }
  2993. }
  2994. var minAngle = spine.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0;
  2995. var maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0;
  2996. c = -a * l1 / (aa - bb);
  2997. if (c >= -1 && c <= 1) {
  2998. c = Math.acos(c);
  2999. x = a * Math.cos(c) + l1;
  3000. y = b * Math.sin(c);
  3001. d = x * x + y * y;
  3002. if (d < minDist) {
  3003. minAngle = c;
  3004. minDist = d;
  3005. minX = x;
  3006. minY = y;
  3007. }
  3008. if (d > maxDist) {
  3009. maxAngle = c;
  3010. maxDist = d;
  3011. maxX = x;
  3012. maxY = y;
  3013. }
  3014. }
  3015. if (dd <= (minDist + maxDist) / 2) {
  3016. a1 = ta - Math.atan2(minY * bendDir, minX);
  3017. a2 = minAngle * bendDir;
  3018. }
  3019. else {
  3020. a1 = ta - Math.atan2(maxY * bendDir, maxX);
  3021. a2 = maxAngle * bendDir;
  3022. }
  3023. }
  3024. var os = Math.atan2(cy, cx) * s2;
  3025. var rotation = parent.arotation;
  3026. a1 = (a1 - os) * spine.MathUtils.radDeg + os1 - rotation;
  3027. if (a1 > 180)
  3028. a1 -= 360;
  3029. else if (a1 < -180)
  3030. a1 += 360;
  3031. parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0);
  3032. rotation = child.arotation;
  3033. a2 = ((a2 + os) * spine.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation;
  3034. if (a2 > 180)
  3035. a2 -= 360;
  3036. else if (a2 < -180)
  3037. a2 += 360;
  3038. child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY);
  3039. };
  3040. return IkConstraint;
  3041. }());
  3042. spine.IkConstraint = IkConstraint;
  3043. })(spine || (spine = {}));
  3044. var spine;
  3045. (function (spine) {
  3046. var IkConstraintData = (function (_super) {
  3047. __extends(IkConstraintData, _super);
  3048. function IkConstraintData(name) {
  3049. var _this = _super.call(this, name, 0, false) || this;
  3050. _this.bones = new Array();
  3051. _this.bendDirection = 1;
  3052. _this.compress = false;
  3053. _this.stretch = false;
  3054. _this.uniform = false;
  3055. _this.mix = 1;
  3056. _this.softness = 0;
  3057. return _this;
  3058. }
  3059. return IkConstraintData;
  3060. }(spine.ConstraintData));
  3061. spine.IkConstraintData = IkConstraintData;
  3062. })(spine || (spine = {}));
  3063. var spine;
  3064. (function (spine) {
  3065. var PathConstraint = (function () {
  3066. function PathConstraint(data, skeleton) {
  3067. this.position = 0;
  3068. this.spacing = 0;
  3069. this.rotateMix = 0;
  3070. this.translateMix = 0;
  3071. this.spaces = new Array();
  3072. this.positions = new Array();
  3073. this.world = new Array();
  3074. this.curves = new Array();
  3075. this.lengths = new Array();
  3076. this.segments = new Array();
  3077. this.active = false;
  3078. if (data == null)
  3079. throw new Error("data cannot be null.");
  3080. if (skeleton == null)
  3081. throw new Error("skeleton cannot be null.");
  3082. this.data = data;
  3083. this.bones = new Array();
  3084. for (var i = 0, n = data.bones.length; i < n; i++)
  3085. this.bones.push(skeleton.findBone(data.bones[i].name));
  3086. this.target = skeleton.findSlot(data.target.name);
  3087. this.position = data.position;
  3088. this.spacing = data.spacing;
  3089. this.rotateMix = data.rotateMix;
  3090. this.translateMix = data.translateMix;
  3091. }
  3092. PathConstraint.prototype.isActive = function () {
  3093. return this.active;
  3094. };
  3095. PathConstraint.prototype.apply = function () {
  3096. this.update();
  3097. };
  3098. PathConstraint.prototype.update = function () {
  3099. var attachment = this.target.getAttachment();
  3100. if (!(attachment instanceof spine.PathAttachment))
  3101. return;
  3102. var rotateMix = this.rotateMix, translateMix = this.translateMix;
  3103. var translate = translateMix > 0, rotate = rotateMix > 0;
  3104. if (!translate && !rotate)
  3105. return;
  3106. var data = this.data;
  3107. var percentSpacing = data.spacingMode == spine.SpacingMode.Percent;
  3108. var rotateMode = data.rotateMode;
  3109. var tangents = rotateMode == spine.RotateMode.Tangent, scale = rotateMode == spine.RotateMode.ChainScale;
  3110. var boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1;
  3111. var bones = this.bones;
  3112. var spaces = spine.Utils.setArraySize(this.spaces, spacesCount), lengths = null;
  3113. var spacing = this.spacing;
  3114. if (scale || !percentSpacing) {
  3115. if (scale)
  3116. lengths = spine.Utils.setArraySize(this.lengths, boneCount);
  3117. var lengthSpacing = data.spacingMode == spine.SpacingMode.Length;
  3118. for (var i = 0, n = spacesCount - 1; i < n;) {
  3119. var bone = bones[i];
  3120. var setupLength = bone.data.length;
  3121. if (setupLength < PathConstraint.epsilon) {
  3122. if (scale)
  3123. lengths[i] = 0;
  3124. spaces[++i] = 0;
  3125. }
  3126. else if (percentSpacing) {
  3127. if (scale) {
  3128. var x = setupLength * bone.a, y = setupLength * bone.c;
  3129. var length_1 = Math.sqrt(x * x + y * y);
  3130. lengths[i] = length_1;
  3131. }
  3132. spaces[++i] = spacing;
  3133. }
  3134. else {
  3135. var x = setupLength * bone.a, y = setupLength * bone.c;
  3136. var length_2 = Math.sqrt(x * x + y * y);
  3137. if (scale)
  3138. lengths[i] = length_2;
  3139. spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_2 / setupLength;
  3140. }
  3141. }
  3142. }
  3143. else {
  3144. for (var i = 1; i < spacesCount; i++)
  3145. spaces[i] = spacing;
  3146. }
  3147. var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, percentSpacing);
  3148. var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
  3149. var tip = false;
  3150. if (offsetRotation == 0)
  3151. tip = rotateMode == spine.RotateMode.Chain;
  3152. else {
  3153. tip = false;
  3154. var p = this.target.bone;
  3155. offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  3156. }
  3157. for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
  3158. var bone = bones[i];
  3159. bone.worldX += (boneX - bone.worldX) * translateMix;
  3160. bone.worldY += (boneY - bone.worldY) * translateMix;
  3161. var x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY;
  3162. if (scale) {
  3163. var length_3 = lengths[i];
  3164. if (length_3 != 0) {
  3165. var s = (Math.sqrt(dx * dx + dy * dy) / length_3 - 1) * rotateMix + 1;
  3166. bone.a *= s;
  3167. bone.c *= s;
  3168. }
  3169. }
  3170. boneX = x;
  3171. boneY = y;
  3172. if (rotate) {
  3173. var a = bone.a, b = bone.b, c = bone.c, d = bone.d, r = 0, cos = 0, sin = 0;
  3174. if (tangents)
  3175. r = positions[p - 1];
  3176. else if (spaces[i + 1] == 0)
  3177. r = positions[p + 2];
  3178. else
  3179. r = Math.atan2(dy, dx);
  3180. r -= Math.atan2(c, a);
  3181. if (tip) {
  3182. cos = Math.cos(r);
  3183. sin = Math.sin(r);
  3184. var length_4 = bone.data.length;
  3185. boneX += (length_4 * (cos * a - sin * c) - dx) * rotateMix;
  3186. boneY += (length_4 * (sin * a + cos * c) - dy) * rotateMix;
  3187. }
  3188. else {
  3189. r += offsetRotation;
  3190. }
  3191. if (r > spine.MathUtils.PI)
  3192. r -= spine.MathUtils.PI2;
  3193. else if (r < -spine.MathUtils.PI)
  3194. r += spine.MathUtils.PI2;
  3195. r *= rotateMix;
  3196. cos = Math.cos(r);
  3197. sin = Math.sin(r);
  3198. bone.a = cos * a - sin * c;
  3199. bone.b = cos * b - sin * d;
  3200. bone.c = sin * a + cos * c;
  3201. bone.d = sin * b + cos * d;
  3202. }
  3203. bone.appliedValid = false;
  3204. }
  3205. };
  3206. PathConstraint.prototype.computeWorldPositions = function (path, spacesCount, tangents, percentPosition, percentSpacing) {
  3207. var target = this.target;
  3208. var position = this.position;
  3209. var spaces = this.spaces, out = spine.Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null;
  3210. var closed = path.closed;
  3211. var verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE;
  3212. if (!path.constantSpeed) {
  3213. var lengths = path.lengths;
  3214. curveCount -= closed ? 1 : 2;
  3215. var pathLength_1 = lengths[curveCount];
  3216. if (percentPosition)
  3217. position *= pathLength_1;
  3218. if (percentSpacing) {
  3219. for (var i = 1; i < spacesCount; i++)
  3220. spaces[i] *= pathLength_1;
  3221. }
  3222. world = spine.Utils.setArraySize(this.world, 8);
  3223. for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) {
  3224. var space = spaces[i];
  3225. position += space;
  3226. var p = position;
  3227. if (closed) {
  3228. p %= pathLength_1;
  3229. if (p < 0)
  3230. p += pathLength_1;
  3231. curve = 0;
  3232. }
  3233. else if (p < 0) {
  3234. if (prevCurve != PathConstraint.BEFORE) {
  3235. prevCurve = PathConstraint.BEFORE;
  3236. path.computeWorldVertices(target, 2, 4, world, 0, 2);
  3237. }
  3238. this.addBeforePosition(p, world, 0, out, o);
  3239. continue;
  3240. }
  3241. else if (p > pathLength_1) {
  3242. if (prevCurve != PathConstraint.AFTER) {
  3243. prevCurve = PathConstraint.AFTER;
  3244. path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2);
  3245. }
  3246. this.addAfterPosition(p - pathLength_1, world, 0, out, o);
  3247. continue;
  3248. }
  3249. for (;; curve++) {
  3250. var length_5 = lengths[curve];
  3251. if (p > length_5)
  3252. continue;
  3253. if (curve == 0)
  3254. p /= length_5;
  3255. else {
  3256. var prev = lengths[curve - 1];
  3257. p = (p - prev) / (length_5 - prev);
  3258. }
  3259. break;
  3260. }
  3261. if (curve != prevCurve) {
  3262. prevCurve = curve;
  3263. if (closed && curve == curveCount) {
  3264. path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2);
  3265. path.computeWorldVertices(target, 0, 4, world, 4, 2);
  3266. }
  3267. else
  3268. path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2);
  3269. }
  3270. this.addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, tangents || (i > 0 && space == 0));
  3271. }
  3272. return out;
  3273. }
  3274. if (closed) {
  3275. verticesLength += 2;
  3276. world = spine.Utils.setArraySize(this.world, verticesLength);
  3277. path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);
  3278. path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);
  3279. world[verticesLength - 2] = world[0];
  3280. world[verticesLength - 1] = world[1];
  3281. }
  3282. else {
  3283. curveCount--;
  3284. verticesLength -= 4;
  3285. world = spine.Utils.setArraySize(this.world, verticesLength);
  3286. path.computeWorldVertices(target, 2, verticesLength, world, 0, 2);
  3287. }
  3288. var curves = spine.Utils.setArraySize(this.curves, curveCount);
  3289. var pathLength = 0;
  3290. var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;
  3291. var tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0;
  3292. for (var i = 0, w = 2; i < curveCount; i++, w += 6) {
  3293. cx1 = world[w];
  3294. cy1 = world[w + 1];
  3295. cx2 = world[w + 2];
  3296. cy2 = world[w + 3];
  3297. x2 = world[w + 4];
  3298. y2 = world[w + 5];
  3299. tmpx = (x1 - cx1 * 2 + cx2) * 0.1875;
  3300. tmpy = (y1 - cy1 * 2 + cy2) * 0.1875;
  3301. dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375;
  3302. dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375;
  3303. ddfx = tmpx * 2 + dddfx;
  3304. ddfy = tmpy * 2 + dddfy;
  3305. dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667;
  3306. dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667;
  3307. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3308. dfx += ddfx;
  3309. dfy += ddfy;
  3310. ddfx += dddfx;
  3311. ddfy += dddfy;
  3312. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3313. dfx += ddfx;
  3314. dfy += ddfy;
  3315. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3316. dfx += ddfx + dddfx;
  3317. dfy += ddfy + dddfy;
  3318. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3319. curves[i] = pathLength;
  3320. x1 = x2;
  3321. y1 = y2;
  3322. }
  3323. if (percentPosition)
  3324. position *= pathLength;
  3325. else
  3326. position *= pathLength / path.lengths[curveCount - 1];
  3327. if (percentSpacing) {
  3328. for (var i = 1; i < spacesCount; i++)
  3329. spaces[i] *= pathLength;
  3330. }
  3331. var segments = this.segments;
  3332. var curveLength = 0;
  3333. for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) {
  3334. var space = spaces[i];
  3335. position += space;
  3336. var p = position;
  3337. if (closed) {
  3338. p %= pathLength;
  3339. if (p < 0)
  3340. p += pathLength;
  3341. curve = 0;
  3342. }
  3343. else if (p < 0) {
  3344. this.addBeforePosition(p, world, 0, out, o);
  3345. continue;
  3346. }
  3347. else if (p > pathLength) {
  3348. this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o);
  3349. continue;
  3350. }
  3351. for (;; curve++) {
  3352. var length_6 = curves[curve];
  3353. if (p > length_6)
  3354. continue;
  3355. if (curve == 0)
  3356. p /= length_6;
  3357. else {
  3358. var prev = curves[curve - 1];
  3359. p = (p - prev) / (length_6 - prev);
  3360. }
  3361. break;
  3362. }
  3363. if (curve != prevCurve) {
  3364. prevCurve = curve;
  3365. var ii = curve * 6;
  3366. x1 = world[ii];
  3367. y1 = world[ii + 1];
  3368. cx1 = world[ii + 2];
  3369. cy1 = world[ii + 3];
  3370. cx2 = world[ii + 4];
  3371. cy2 = world[ii + 5];
  3372. x2 = world[ii + 6];
  3373. y2 = world[ii + 7];
  3374. tmpx = (x1 - cx1 * 2 + cx2) * 0.03;
  3375. tmpy = (y1 - cy1 * 2 + cy2) * 0.03;
  3376. dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006;
  3377. dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006;
  3378. ddfx = tmpx * 2 + dddfx;
  3379. ddfy = tmpy * 2 + dddfy;
  3380. dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667;
  3381. dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667;
  3382. curveLength = Math.sqrt(dfx * dfx + dfy * dfy);
  3383. segments[0] = curveLength;
  3384. for (ii = 1; ii < 8; ii++) {
  3385. dfx += ddfx;
  3386. dfy += ddfy;
  3387. ddfx += dddfx;
  3388. ddfy += dddfy;
  3389. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3390. segments[ii] = curveLength;
  3391. }
  3392. dfx += ddfx;
  3393. dfy += ddfy;
  3394. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3395. segments[8] = curveLength;
  3396. dfx += ddfx + dddfx;
  3397. dfy += ddfy + dddfy;
  3398. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3399. segments[9] = curveLength;
  3400. segment = 0;
  3401. }
  3402. p *= curveLength;
  3403. for (;; segment++) {
  3404. var length_7 = segments[segment];
  3405. if (p > length_7)
  3406. continue;
  3407. if (segment == 0)
  3408. p /= length_7;
  3409. else {
  3410. var prev = segments[segment - 1];
  3411. p = segment + (p - prev) / (length_7 - prev);
  3412. }
  3413. break;
  3414. }
  3415. this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0));
  3416. }
  3417. return out;
  3418. };
  3419. PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) {
  3420. var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx);
  3421. out[o] = x1 + p * Math.cos(r);
  3422. out[o + 1] = y1 + p * Math.sin(r);
  3423. out[o + 2] = r;
  3424. };
  3425. PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) {
  3426. var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx);
  3427. out[o] = x1 + p * Math.cos(r);
  3428. out[o + 1] = y1 + p * Math.sin(r);
  3429. out[o + 2] = r;
  3430. };
  3431. PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) {
  3432. if (p == 0 || isNaN(p)) {
  3433. out[o] = x1;
  3434. out[o + 1] = y1;
  3435. out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1);
  3436. return;
  3437. }
  3438. var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;
  3439. var ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;
  3440. var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
  3441. out[o] = x;
  3442. out[o + 1] = y;
  3443. if (tangents) {
  3444. if (p < 0.001)
  3445. out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1);
  3446. else
  3447. out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
  3448. }
  3449. };
  3450. PathConstraint.NONE = -1;
  3451. PathConstraint.BEFORE = -2;
  3452. PathConstraint.AFTER = -3;
  3453. PathConstraint.epsilon = 0.00001;
  3454. return PathConstraint;
  3455. }());
  3456. spine.PathConstraint = PathConstraint;
  3457. })(spine || (spine = {}));
  3458. var spine;
  3459. (function (spine) {
  3460. var PathConstraintData = (function (_super) {
  3461. __extends(PathConstraintData, _super);
  3462. function PathConstraintData(name) {
  3463. var _this = _super.call(this, name, 0, false) || this;
  3464. _this.bones = new Array();
  3465. return _this;
  3466. }
  3467. return PathConstraintData;
  3468. }(spine.ConstraintData));
  3469. spine.PathConstraintData = PathConstraintData;
  3470. var PositionMode;
  3471. (function (PositionMode) {
  3472. PositionMode[PositionMode["Fixed"] = 0] = "Fixed";
  3473. PositionMode[PositionMode["Percent"] = 1] = "Percent";
  3474. })(PositionMode = spine.PositionMode || (spine.PositionMode = {}));
  3475. var SpacingMode;
  3476. (function (SpacingMode) {
  3477. SpacingMode[SpacingMode["Length"] = 0] = "Length";
  3478. SpacingMode[SpacingMode["Fixed"] = 1] = "Fixed";
  3479. SpacingMode[SpacingMode["Percent"] = 2] = "Percent";
  3480. })(SpacingMode = spine.SpacingMode || (spine.SpacingMode = {}));
  3481. var RotateMode;
  3482. (function (RotateMode) {
  3483. RotateMode[RotateMode["Tangent"] = 0] = "Tangent";
  3484. RotateMode[RotateMode["Chain"] = 1] = "Chain";
  3485. RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
  3486. })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
  3487. })(spine || (spine = {}));
  3488. var spine;
  3489. (function (spine) {
  3490. var Assets = (function () {
  3491. function Assets(clientId) {
  3492. this.toLoad = new Array();
  3493. this.assets = {};
  3494. this.clientId = clientId;
  3495. }
  3496. Assets.prototype.loaded = function () {
  3497. var i = 0;
  3498. for (var v in this.assets)
  3499. i++;
  3500. return i;
  3501. };
  3502. return Assets;
  3503. }());
  3504. var SharedAssetManager = (function () {
  3505. function SharedAssetManager(pathPrefix) {
  3506. if (pathPrefix === void 0) { pathPrefix = ""; }
  3507. this.clientAssets = {};
  3508. this.queuedAssets = {};
  3509. this.rawAssets = {};
  3510. this.errors = {};
  3511. this.pathPrefix = pathPrefix;
  3512. }
  3513. SharedAssetManager.prototype.queueAsset = function (clientId, textureLoader, path) {
  3514. var clientAssets = this.clientAssets[clientId];
  3515. if (clientAssets === null || clientAssets === undefined) {
  3516. clientAssets = new Assets(clientId);
  3517. this.clientAssets[clientId] = clientAssets;
  3518. }
  3519. if (textureLoader !== null)
  3520. clientAssets.textureLoader = textureLoader;
  3521. clientAssets.toLoad.push(path);
  3522. if (this.queuedAssets[path] === path) {
  3523. return false;
  3524. }
  3525. else {
  3526. this.queuedAssets[path] = path;
  3527. return true;
  3528. }
  3529. };
  3530. SharedAssetManager.prototype.loadText = function (clientId, path) {
  3531. var _this = this;
  3532. path = this.pathPrefix + path;
  3533. if (!this.queueAsset(clientId, null, path))
  3534. return;
  3535. var request = new XMLHttpRequest();
  3536. request.overrideMimeType("text/html");
  3537. request.onreadystatechange = function () {
  3538. if (request.readyState == XMLHttpRequest.DONE) {
  3539. if (request.status >= 200 && request.status < 300) {
  3540. _this.rawAssets[path] = request.responseText;
  3541. }
  3542. else {
  3543. _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
  3544. }
  3545. }
  3546. };
  3547. request.open("GET", path, true);
  3548. request.send();
  3549. };
  3550. SharedAssetManager.prototype.loadJson = function (clientId, path) {
  3551. var _this = this;
  3552. path = this.pathPrefix + path;
  3553. if (!this.queueAsset(clientId, null, path))
  3554. return;
  3555. var request = new XMLHttpRequest();
  3556. request.overrideMimeType("text/html");
  3557. request.onreadystatechange = function () {
  3558. if (request.readyState == XMLHttpRequest.DONE) {
  3559. if (request.status >= 200 && request.status < 300) {
  3560. _this.rawAssets[path] = JSON.parse(request.responseText);
  3561. }
  3562. else {
  3563. _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
  3564. }
  3565. }
  3566. };
  3567. request.open("GET", path, true);
  3568. request.send();
  3569. };
  3570. SharedAssetManager.prototype.loadTexture = function (clientId, textureLoader, path) {
  3571. var _this = this;
  3572. path = this.pathPrefix + path;
  3573. if (!this.queueAsset(clientId, textureLoader, path))
  3574. return;
  3575. var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
  3576. var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
  3577. if (isWebWorker) {
  3578. var options = { mode: "cors" };
  3579. fetch(path, options).then(function (response) {
  3580. if (!response.ok) {
  3581. _this.errors[path] = "Couldn't load image " + path;
  3582. }
  3583. return response.blob();
  3584. }).then(function (blob) {
  3585. return createImageBitmap(blob, {
  3586. premultiplyAlpha: 'none',
  3587. colorSpaceConversion: 'none'
  3588. });
  3589. }).then(function (bitmap) {
  3590. _this.rawAssets[path] = bitmap;
  3591. });
  3592. }
  3593. else {
  3594. var img_1 = new Image();
  3595. img_1.crossOrigin = "anonymous";
  3596. img_1.onload = function (ev) {
  3597. _this.rawAssets[path] = img_1;
  3598. };
  3599. img_1.onerror = function (ev) {
  3600. _this.errors[path] = "Couldn't load image " + path;
  3601. };
  3602. img_1.src = path;
  3603. }
  3604. };
  3605. SharedAssetManager.prototype.get = function (clientId, path) {
  3606. path = this.pathPrefix + path;
  3607. var clientAssets = this.clientAssets[clientId];
  3608. if (clientAssets === null || clientAssets === undefined)
  3609. return true;
  3610. return clientAssets.assets[path];
  3611. };
  3612. SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
  3613. var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
  3614. var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
  3615. for (var i = 0; i < clientAssets.toLoad.length; i++) {
  3616. var path = clientAssets.toLoad[i];
  3617. var asset = clientAssets.assets[path];
  3618. if (asset === null || asset === undefined) {
  3619. var rawAsset = this.rawAssets[path];
  3620. if (rawAsset === null || rawAsset === undefined)
  3621. continue;
  3622. if (isWebWorker) {
  3623. if (rawAsset instanceof ImageBitmap) {
  3624. clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
  3625. }
  3626. else {
  3627. clientAssets.assets[path] = rawAsset;
  3628. }
  3629. }
  3630. else {
  3631. if (rawAsset instanceof HTMLImageElement) {
  3632. clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
  3633. }
  3634. else {
  3635. clientAssets.assets[path] = rawAsset;
  3636. }
  3637. }
  3638. }
  3639. }
  3640. };
  3641. SharedAssetManager.prototype.isLoadingComplete = function (clientId) {
  3642. var clientAssets = this.clientAssets[clientId];
  3643. if (clientAssets === null || clientAssets === undefined)
  3644. return true;
  3645. this.updateClientAssets(clientAssets);
  3646. return clientAssets.toLoad.length == clientAssets.loaded();
  3647. };
  3648. SharedAssetManager.prototype.dispose = function () {
  3649. };
  3650. SharedAssetManager.prototype.hasErrors = function () {
  3651. return Object.keys(this.errors).length > 0;
  3652. };
  3653. SharedAssetManager.prototype.getErrors = function () {
  3654. return this.errors;
  3655. };
  3656. return SharedAssetManager;
  3657. }());
  3658. spine.SharedAssetManager = SharedAssetManager;
  3659. })(spine || (spine = {}));
  3660. var spine;
  3661. (function (spine) {
  3662. var Skeleton = (function () {
  3663. function Skeleton(data) {
  3664. this._updateCache = new Array();
  3665. this.updateCacheReset = new Array();
  3666. this.time = 0;
  3667. this.scaleX = 1;
  3668. this.scaleY = 1;
  3669. this.x = 0;
  3670. this.y = 0;
  3671. if (data == null)
  3672. throw new Error("data cannot be null.");
  3673. this.data = data;
  3674. this.bones = new Array();
  3675. for (var i = 0; i < data.bones.length; i++) {
  3676. var boneData = data.bones[i];
  3677. var bone = void 0;
  3678. if (boneData.parent == null)
  3679. bone = new spine.Bone(boneData, this, null);
  3680. else {
  3681. var parent_1 = this.bones[boneData.parent.index];
  3682. bone = new spine.Bone(boneData, this, parent_1);
  3683. parent_1.children.push(bone);
  3684. }
  3685. this.bones.push(bone);
  3686. }
  3687. this.slots = new Array();
  3688. this.drawOrder = new Array();
  3689. for (var i = 0; i < data.slots.length; i++) {
  3690. var slotData = data.slots[i];
  3691. var bone = this.bones[slotData.boneData.index];
  3692. var slot = new spine.Slot(slotData, bone);
  3693. this.slots.push(slot);
  3694. this.drawOrder.push(slot);
  3695. }
  3696. this.ikConstraints = new Array();
  3697. for (var i = 0; i < data.ikConstraints.length; i++) {
  3698. var ikConstraintData = data.ikConstraints[i];
  3699. this.ikConstraints.push(new spine.IkConstraint(ikConstraintData, this));
  3700. }
  3701. this.transformConstraints = new Array();
  3702. for (var i = 0; i < data.transformConstraints.length; i++) {
  3703. var transformConstraintData = data.transformConstraints[i];
  3704. this.transformConstraints.push(new spine.TransformConstraint(transformConstraintData, this));
  3705. }
  3706. this.pathConstraints = new Array();
  3707. for (var i = 0; i < data.pathConstraints.length; i++) {
  3708. var pathConstraintData = data.pathConstraints[i];
  3709. this.pathConstraints.push(new spine.PathConstraint(pathConstraintData, this));
  3710. }
  3711. this.color = new spine.Color(1, 1, 1, 1);
  3712. this.updateCache();
  3713. }
  3714. Skeleton.prototype.updateCache = function () {
  3715. var updateCache = this._updateCache;
  3716. updateCache.length = 0;
  3717. this.updateCacheReset.length = 0;
  3718. var bones = this.bones;
  3719. for (var i = 0, n = bones.length; i < n; i++) {
  3720. var bone = bones[i];
  3721. bone.sorted = bone.data.skinRequired;
  3722. bone.active = !bone.sorted;
  3723. }
  3724. if (this.skin != null) {
  3725. var skinBones = this.skin.bones;
  3726. for (var i = 0, n = this.skin.bones.length; i < n; i++) {
  3727. var bone = this.bones[skinBones[i].index];
  3728. do {
  3729. bone.sorted = false;
  3730. bone.active = true;
  3731. bone = bone.parent;
  3732. } while (bone != null);
  3733. }
  3734. }
  3735. var ikConstraints = this.ikConstraints;
  3736. var transformConstraints = this.transformConstraints;
  3737. var pathConstraints = this.pathConstraints;
  3738. var ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length;
  3739. var constraintCount = ikCount + transformCount + pathCount;
  3740. outer: for (var i = 0; i < constraintCount; i++) {
  3741. for (var ii = 0; ii < ikCount; ii++) {
  3742. var constraint = ikConstraints[ii];
  3743. if (constraint.data.order == i) {
  3744. this.sortIkConstraint(constraint);
  3745. continue outer;
  3746. }
  3747. }
  3748. for (var ii = 0; ii < transformCount; ii++) {
  3749. var constraint = transformConstraints[ii];
  3750. if (constraint.data.order == i) {
  3751. this.sortTransformConstraint(constraint);
  3752. continue outer;
  3753. }
  3754. }
  3755. for (var ii = 0; ii < pathCount; ii++) {
  3756. var constraint = pathConstraints[ii];
  3757. if (constraint.data.order == i) {
  3758. this.sortPathConstraint(constraint);
  3759. continue outer;
  3760. }
  3761. }
  3762. }
  3763. for (var i = 0, n = bones.length; i < n; i++)
  3764. this.sortBone(bones[i]);
  3765. };
  3766. Skeleton.prototype.sortIkConstraint = function (constraint) {
  3767. constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || (this.skin != null && spine.Utils.contains(this.skin.constraints, constraint.data, true)));
  3768. if (!constraint.active)
  3769. return;
  3770. var target = constraint.target;
  3771. this.sortBone(target);
  3772. var constrained = constraint.bones;
  3773. var parent = constrained[0];
  3774. this.sortBone(parent);
  3775. if (constrained.length > 1) {
  3776. var child = constrained[constrained.length - 1];
  3777. if (!(this._updateCache.indexOf(child) > -1))
  3778. this.updateCacheReset.push(child);
  3779. }
  3780. this._updateCache.push(constraint);
  3781. this.sortReset(parent.children);
  3782. constrained[constrained.length - 1].sorted = true;
  3783. };
  3784. Skeleton.prototype.sortPathConstraint = function (constraint) {
  3785. constraint.active = constraint.target.bone.isActive() && (!constraint.data.skinRequired || (this.skin != null && spine.Utils.contains(this.skin.constraints, constraint.data, true)));
  3786. if (!constraint.active)
  3787. return;
  3788. var slot = constraint.target;
  3789. var slotIndex = slot.data.index;
  3790. var slotBone = slot.bone;
  3791. if (this.skin != null)
  3792. this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone);
  3793. if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin)
  3794. this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone);
  3795. for (var i = 0, n = this.data.skins.length; i < n; i++)
  3796. this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone);
  3797. var attachment = slot.getAttachment();
  3798. if (attachment instanceof spine.PathAttachment)
  3799. this.sortPathConstraintAttachmentWith(attachment, slotBone);
  3800. var constrained = constraint.bones;
  3801. var boneCount = constrained.length;
  3802. for (var i = 0; i < boneCount; i++)
  3803. this.sortBone(constrained[i]);
  3804. this._updateCache.push(constraint);
  3805. for (var i = 0; i < boneCount; i++)
  3806. this.sortReset(constrained[i].children);
  3807. for (var i = 0; i < boneCount; i++)
  3808. constrained[i].sorted = true;
  3809. };
  3810. Skeleton.prototype.sortTransformConstraint = function (constraint) {
  3811. constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || (this.skin != null && spine.Utils.contains(this.skin.constraints, constraint.data, true)));
  3812. if (!constraint.active)
  3813. return;
  3814. this.sortBone(constraint.target);
  3815. var constrained = constraint.bones;
  3816. var boneCount = constrained.length;
  3817. if (constraint.data.local) {
  3818. for (var i = 0; i < boneCount; i++) {
  3819. var child = constrained[i];
  3820. this.sortBone(child.parent);
  3821. if (!(this._updateCache.indexOf(child) > -1))
  3822. this.updateCacheReset.push(child);
  3823. }
  3824. }
  3825. else {
  3826. for (var i = 0; i < boneCount; i++) {
  3827. this.sortBone(constrained[i]);
  3828. }
  3829. }
  3830. this._updateCache.push(constraint);
  3831. for (var ii = 0; ii < boneCount; ii++)
  3832. this.sortReset(constrained[ii].children);
  3833. for (var ii = 0; ii < boneCount; ii++)
  3834. constrained[ii].sorted = true;
  3835. };
  3836. Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) {
  3837. var attachments = skin.attachments[slotIndex];
  3838. if (!attachments)
  3839. return;
  3840. for (var key in attachments) {
  3841. this.sortPathConstraintAttachmentWith(attachments[key], slotBone);
  3842. }
  3843. };
  3844. Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) {
  3845. if (!(attachment instanceof spine.PathAttachment))
  3846. return;
  3847. var pathBones = attachment.bones;
  3848. if (pathBones == null)
  3849. this.sortBone(slotBone);
  3850. else {
  3851. var bones = this.bones;
  3852. var i = 0;
  3853. while (i < pathBones.length) {
  3854. var boneCount = pathBones[i++];
  3855. for (var n = i + boneCount; i < n; i++) {
  3856. var boneIndex = pathBones[i];
  3857. this.sortBone(bones[boneIndex]);
  3858. }
  3859. }
  3860. }
  3861. };
  3862. Skeleton.prototype.sortBone = function (bone) {
  3863. if (bone.sorted)
  3864. return;
  3865. var parent = bone.parent;
  3866. if (parent != null)
  3867. this.sortBone(parent);
  3868. bone.sorted = true;
  3869. this._updateCache.push(bone);
  3870. };
  3871. Skeleton.prototype.sortReset = function (bones) {
  3872. for (var i = 0, n = bones.length; i < n; i++) {
  3873. var bone = bones[i];
  3874. if (!bone.active)
  3875. continue;
  3876. if (bone.sorted)
  3877. this.sortReset(bone.children);
  3878. bone.sorted = false;
  3879. }
  3880. };
  3881. Skeleton.prototype.updateWorldTransform = function () {
  3882. var updateCacheReset = this.updateCacheReset;
  3883. for (var i = 0, n = updateCacheReset.length; i < n; i++) {
  3884. var bone = updateCacheReset[i];
  3885. bone.ax = bone.x;
  3886. bone.ay = bone.y;
  3887. bone.arotation = bone.rotation;
  3888. bone.ascaleX = bone.scaleX;
  3889. bone.ascaleY = bone.scaleY;
  3890. bone.ashearX = bone.shearX;
  3891. bone.ashearY = bone.shearY;
  3892. bone.appliedValid = true;
  3893. }
  3894. var updateCache = this._updateCache;
  3895. for (var i = 0, n = updateCache.length; i < n; i++)
  3896. updateCache[i].update();
  3897. };
  3898. Skeleton.prototype.setToSetupPose = function () {
  3899. this.setBonesToSetupPose();
  3900. this.setSlotsToSetupPose();
  3901. };
  3902. Skeleton.prototype.setBonesToSetupPose = function () {
  3903. var bones = this.bones;
  3904. for (var i = 0, n = bones.length; i < n; i++)
  3905. bones[i].setToSetupPose();
  3906. var ikConstraints = this.ikConstraints;
  3907. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  3908. var constraint = ikConstraints[i];
  3909. constraint.mix = constraint.data.mix;
  3910. constraint.softness = constraint.data.softness;
  3911. constraint.bendDirection = constraint.data.bendDirection;
  3912. constraint.compress = constraint.data.compress;
  3913. constraint.stretch = constraint.data.stretch;
  3914. }
  3915. var transformConstraints = this.transformConstraints;
  3916. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  3917. var constraint = transformConstraints[i];
  3918. var data = constraint.data;
  3919. constraint.rotateMix = data.rotateMix;
  3920. constraint.translateMix = data.translateMix;
  3921. constraint.scaleMix = data.scaleMix;
  3922. constraint.shearMix = data.shearMix;
  3923. }
  3924. var pathConstraints = this.pathConstraints;
  3925. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  3926. var constraint = pathConstraints[i];
  3927. var data = constraint.data;
  3928. constraint.position = data.position;
  3929. constraint.spacing = data.spacing;
  3930. constraint.rotateMix = data.rotateMix;
  3931. constraint.translateMix = data.translateMix;
  3932. }
  3933. };
  3934. Skeleton.prototype.setSlotsToSetupPose = function () {
  3935. var slots = this.slots;
  3936. spine.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length);
  3937. for (var i = 0, n = slots.length; i < n; i++)
  3938. slots[i].setToSetupPose();
  3939. };
  3940. Skeleton.prototype.getRootBone = function () {
  3941. if (this.bones.length == 0)
  3942. return null;
  3943. return this.bones[0];
  3944. };
  3945. Skeleton.prototype.findBone = function (boneName) {
  3946. if (boneName == null)
  3947. throw new Error("boneName cannot be null.");
  3948. var bones = this.bones;
  3949. for (var i = 0, n = bones.length; i < n; i++) {
  3950. var bone = bones[i];
  3951. if (bone.data.name == boneName)
  3952. return bone;
  3953. }
  3954. return null;
  3955. };
  3956. Skeleton.prototype.findBoneIndex = function (boneName) {
  3957. if (boneName == null)
  3958. throw new Error("boneName cannot be null.");
  3959. var bones = this.bones;
  3960. for (var i = 0, n = bones.length; i < n; i++)
  3961. if (bones[i].data.name == boneName)
  3962. return i;
  3963. return -1;
  3964. };
  3965. Skeleton.prototype.findSlot = function (slotName) {
  3966. if (slotName == null)
  3967. throw new Error("slotName cannot be null.");
  3968. var slots = this.slots;
  3969. for (var i = 0, n = slots.length; i < n; i++) {
  3970. var slot = slots[i];
  3971. if (slot.data.name == slotName)
  3972. return slot;
  3973. }
  3974. return null;
  3975. };
  3976. Skeleton.prototype.findSlotIndex = function (slotName) {
  3977. if (slotName == null)
  3978. throw new Error("slotName cannot be null.");
  3979. var slots = this.slots;
  3980. for (var i = 0, n = slots.length; i < n; i++)
  3981. if (slots[i].data.name == slotName)
  3982. return i;
  3983. return -1;
  3984. };
  3985. Skeleton.prototype.setSkinByName = function (skinName) {
  3986. var skin = this.data.findSkin(skinName);
  3987. if (skin == null)
  3988. throw new Error("Skin not found: " + skinName);
  3989. this.setSkin(skin);
  3990. };
  3991. Skeleton.prototype.setSkin = function (newSkin) {
  3992. if (newSkin == this.skin)
  3993. return;
  3994. if (newSkin != null) {
  3995. if (this.skin != null)
  3996. newSkin.attachAll(this, this.skin);
  3997. else {
  3998. var slots = this.slots;
  3999. for (var i = 0, n = slots.length; i < n; i++) {
  4000. var slot = slots[i];
  4001. var name_1 = slot.data.attachmentName;
  4002. if (name_1 != null) {
  4003. var attachment = newSkin.getAttachment(i, name_1);
  4004. if (attachment != null)
  4005. slot.setAttachment(attachment);
  4006. }
  4007. }
  4008. }
  4009. }
  4010. this.skin = newSkin;
  4011. this.updateCache();
  4012. };
  4013. Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) {
  4014. return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName);
  4015. };
  4016. Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) {
  4017. if (attachmentName == null)
  4018. throw new Error("attachmentName cannot be null.");
  4019. if (this.skin != null) {
  4020. var attachment = this.skin.getAttachment(slotIndex, attachmentName);
  4021. if (attachment != null)
  4022. return attachment;
  4023. }
  4024. if (this.data.defaultSkin != null)
  4025. return this.data.defaultSkin.getAttachment(slotIndex, attachmentName);
  4026. return null;
  4027. };
  4028. Skeleton.prototype.setAttachment = function (slotName, attachmentName) {
  4029. if (slotName == null)
  4030. throw new Error("slotName cannot be null.");
  4031. var slots = this.slots;
  4032. for (var i = 0, n = slots.length; i < n; i++) {
  4033. var slot = slots[i];
  4034. if (slot.data.name == slotName) {
  4035. var attachment = null;
  4036. if (attachmentName != null) {
  4037. attachment = this.getAttachment(i, attachmentName);
  4038. if (attachment == null)
  4039. throw new Error("Attachment not found: " + attachmentName + ", for slot: " + slotName);
  4040. }
  4041. slot.setAttachment(attachment);
  4042. return;
  4043. }
  4044. }
  4045. throw new Error("Slot not found: " + slotName);
  4046. };
  4047. Skeleton.prototype.findIkConstraint = function (constraintName) {
  4048. if (constraintName == null)
  4049. throw new Error("constraintName cannot be null.");
  4050. var ikConstraints = this.ikConstraints;
  4051. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  4052. var ikConstraint = ikConstraints[i];
  4053. if (ikConstraint.data.name == constraintName)
  4054. return ikConstraint;
  4055. }
  4056. return null;
  4057. };
  4058. Skeleton.prototype.findTransformConstraint = function (constraintName) {
  4059. if (constraintName == null)
  4060. throw new Error("constraintName cannot be null.");
  4061. var transformConstraints = this.transformConstraints;
  4062. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  4063. var constraint = transformConstraints[i];
  4064. if (constraint.data.name == constraintName)
  4065. return constraint;
  4066. }
  4067. return null;
  4068. };
  4069. Skeleton.prototype.findPathConstraint = function (constraintName) {
  4070. if (constraintName == null)
  4071. throw new Error("constraintName cannot be null.");
  4072. var pathConstraints = this.pathConstraints;
  4073. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  4074. var constraint = pathConstraints[i];
  4075. if (constraint.data.name == constraintName)
  4076. return constraint;
  4077. }
  4078. return null;
  4079. };
  4080. Skeleton.prototype.getBounds = function (offset, size, temp) {
  4081. if (temp === void 0) { temp = new Array(2); }
  4082. if (offset == null)
  4083. throw new Error("offset cannot be null.");
  4084. if (size == null)
  4085. throw new Error("size cannot be null.");
  4086. var drawOrder = this.drawOrder;
  4087. var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;
  4088. for (var i = 0, n = drawOrder.length; i < n; i++) {
  4089. var slot = drawOrder[i];
  4090. if (!slot.bone.active)
  4091. continue;
  4092. var verticesLength = 0;
  4093. var vertices = null;
  4094. var attachment = slot.getAttachment();
  4095. if (attachment instanceof spine.RegionAttachment) {
  4096. verticesLength = 8;
  4097. vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
  4098. attachment.computeWorldVertices(slot.bone, vertices, 0, 2);
  4099. }
  4100. else if (attachment instanceof spine.MeshAttachment) {
  4101. var mesh = attachment;
  4102. verticesLength = mesh.worldVerticesLength;
  4103. vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
  4104. mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
  4105. }
  4106. if (vertices != null) {
  4107. for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
  4108. var x = vertices[ii], y = vertices[ii + 1];
  4109. minX = Math.min(minX, x);
  4110. minY = Math.min(minY, y);
  4111. maxX = Math.max(maxX, x);
  4112. maxY = Math.max(maxY, y);
  4113. }
  4114. }
  4115. }
  4116. offset.set(minX, minY);
  4117. size.set(maxX - minX, maxY - minY);
  4118. };
  4119. Skeleton.prototype.update = function (delta) {
  4120. this.time += delta;
  4121. };
  4122. return Skeleton;
  4123. }());
  4124. spine.Skeleton = Skeleton;
  4125. })(spine || (spine = {}));
  4126. var spine;
  4127. (function (spine) {
  4128. var SkeletonBinary = (function () {
  4129. function SkeletonBinary(attachmentLoader) {
  4130. this.scale = 1;
  4131. this.linkedMeshes = new Array();
  4132. this.attachmentLoader = attachmentLoader;
  4133. }
  4134. SkeletonBinary.prototype.readSkeletonData = function (binary) {
  4135. var scale = this.scale;
  4136. var skeletonData = new spine.SkeletonData();
  4137. skeletonData.name = "";
  4138. var input = new BinaryInput(binary);
  4139. skeletonData.hash = input.readString();
  4140. skeletonData.version = input.readString();
  4141. if ("3.8.75" == skeletonData.version)
  4142. throw new Error("Unsupported skeleton data, please export with a newer version of Spine.");
  4143. skeletonData.x = input.readFloat();
  4144. skeletonData.y = input.readFloat();
  4145. skeletonData.width = input.readFloat();
  4146. skeletonData.height = input.readFloat();
  4147. var nonessential = input.readBoolean();
  4148. if (nonessential) {
  4149. skeletonData.fps = input.readFloat();
  4150. skeletonData.imagesPath = input.readString();
  4151. skeletonData.audioPath = input.readString();
  4152. }
  4153. var n = 0;
  4154. n = input.readInt(true);
  4155. for (var i = 0; i < n; i++)
  4156. input.strings.push(input.readString());
  4157. n = input.readInt(true);
  4158. for (var i = 0; i < n; i++) {
  4159. var name_2 = input.readString();
  4160. var parent_2 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
  4161. var data = new spine.BoneData(i, name_2, parent_2);
  4162. data.rotation = input.readFloat();
  4163. data.x = input.readFloat() * scale;
  4164. data.y = input.readFloat() * scale;
  4165. data.scaleX = input.readFloat();
  4166. data.scaleY = input.readFloat();
  4167. data.shearX = input.readFloat();
  4168. data.shearY = input.readFloat();
  4169. data.length = input.readFloat() * scale;
  4170. data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)];
  4171. data.skinRequired = input.readBoolean();
  4172. if (nonessential)
  4173. spine.Color.rgba8888ToColor(data.color, input.readInt32());
  4174. skeletonData.bones.push(data);
  4175. }
  4176. n = input.readInt(true);
  4177. for (var i = 0; i < n; i++) {
  4178. var slotName = input.readString();
  4179. var boneData = skeletonData.bones[input.readInt(true)];
  4180. var data = new spine.SlotData(i, slotName, boneData);
  4181. spine.Color.rgba8888ToColor(data.color, input.readInt32());
  4182. var darkColor = input.readInt32();
  4183. if (darkColor != -1)
  4184. spine.Color.rgb888ToColor(data.darkColor = new spine.Color(), darkColor);
  4185. data.attachmentName = input.readStringRef();
  4186. data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
  4187. skeletonData.slots.push(data);
  4188. }
  4189. n = input.readInt(true);
  4190. for (var i = 0, nn = void 0; i < n; i++) {
  4191. var data = new spine.IkConstraintData(input.readString());
  4192. data.order = input.readInt(true);
  4193. data.skinRequired = input.readBoolean();
  4194. nn = input.readInt(true);
  4195. for (var ii = 0; ii < nn; ii++)
  4196. data.bones.push(skeletonData.bones[input.readInt(true)]);
  4197. data.target = skeletonData.bones[input.readInt(true)];
  4198. data.mix = input.readFloat();
  4199. data.softness = input.readFloat() * scale;
  4200. data.bendDirection = input.readByte();
  4201. data.compress = input.readBoolean();
  4202. data.stretch = input.readBoolean();
  4203. data.uniform = input.readBoolean();
  4204. skeletonData.ikConstraints.push(data);
  4205. }
  4206. n = input.readInt(true);
  4207. for (var i = 0, nn = void 0; i < n; i++) {
  4208. var data = new spine.TransformConstraintData(input.readString());
  4209. data.order = input.readInt(true);
  4210. data.skinRequired = input.readBoolean();
  4211. nn = input.readInt(true);
  4212. for (var ii = 0; ii < nn; ii++)
  4213. data.bones.push(skeletonData.bones[input.readInt(true)]);
  4214. data.target = skeletonData.bones[input.readInt(true)];
  4215. data.local = input.readBoolean();
  4216. data.relative = input.readBoolean();
  4217. data.offsetRotation = input.readFloat();
  4218. data.offsetX = input.readFloat() * scale;
  4219. data.offsetY = input.readFloat() * scale;
  4220. data.offsetScaleX = input.readFloat();
  4221. data.offsetScaleY = input.readFloat();
  4222. data.offsetShearY = input.readFloat();
  4223. data.rotateMix = input.readFloat();
  4224. data.translateMix = input.readFloat();
  4225. data.scaleMix = input.readFloat();
  4226. data.shearMix = input.readFloat();
  4227. skeletonData.transformConstraints.push(data);
  4228. }
  4229. n = input.readInt(true);
  4230. for (var i = 0, nn = void 0; i < n; i++) {
  4231. var data = new spine.PathConstraintData(input.readString());
  4232. data.order = input.readInt(true);
  4233. data.skinRequired = input.readBoolean();
  4234. nn = input.readInt(true);
  4235. for (var ii = 0; ii < nn; ii++)
  4236. data.bones.push(skeletonData.bones[input.readInt(true)]);
  4237. data.target = skeletonData.slots[input.readInt(true)];
  4238. data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)];
  4239. data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
  4240. data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
  4241. data.offsetRotation = input.readFloat();
  4242. data.position = input.readFloat();
  4243. if (data.positionMode == spine.PositionMode.Fixed)
  4244. data.position *= scale;
  4245. data.spacing = input.readFloat();
  4246. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  4247. data.spacing *= scale;
  4248. data.rotateMix = input.readFloat();
  4249. data.translateMix = input.readFloat();
  4250. skeletonData.pathConstraints.push(data);
  4251. }
  4252. var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
  4253. if (defaultSkin != null) {
  4254. skeletonData.defaultSkin = defaultSkin;
  4255. skeletonData.skins.push(defaultSkin);
  4256. }
  4257. {
  4258. var i = skeletonData.skins.length;
  4259. spine.Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
  4260. for (; i < n; i++)
  4261. skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
  4262. }
  4263. n = this.linkedMeshes.length;
  4264. for (var i = 0; i < n; i++) {
  4265. var linkedMesh = this.linkedMeshes[i];
  4266. var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
  4267. if (skin == null)
  4268. throw new Error("Skin not found: " + linkedMesh.skin);
  4269. var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
  4270. if (parent_3 == null)
  4271. throw new Error("Parent mesh not found: " + linkedMesh.parent);
  4272. linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
  4273. linkedMesh.mesh.setParentMesh(parent_3);
  4274. linkedMesh.mesh.updateUVs();
  4275. }
  4276. this.linkedMeshes.length = 0;
  4277. n = input.readInt(true);
  4278. for (var i = 0; i < n; i++) {
  4279. var data = new spine.EventData(input.readStringRef());
  4280. data.intValue = input.readInt(false);
  4281. data.floatValue = input.readFloat();
  4282. data.stringValue = input.readString();
  4283. data.audioPath = input.readString();
  4284. if (data.audioPath != null) {
  4285. data.volume = input.readFloat();
  4286. data.balance = input.readFloat();
  4287. }
  4288. skeletonData.events.push(data);
  4289. }
  4290. n = input.readInt(true);
  4291. for (var i = 0; i < n; i++)
  4292. skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
  4293. return skeletonData;
  4294. };
  4295. SkeletonBinary.prototype.readSkin = function (input, skeletonData, defaultSkin, nonessential) {
  4296. var skin = null;
  4297. var slotCount = 0;
  4298. if (defaultSkin) {
  4299. slotCount = input.readInt(true);
  4300. if (slotCount == 0)
  4301. return null;
  4302. skin = new spine.Skin("default");
  4303. }
  4304. else {
  4305. skin = new spine.Skin(input.readStringRef());
  4306. skin.bones.length = input.readInt(true);
  4307. for (var i = 0, n = skin.bones.length; i < n; i++)
  4308. skin.bones[i] = skeletonData.bones[input.readInt(true)];
  4309. for (var i = 0, n = input.readInt(true); i < n; i++)
  4310. skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]);
  4311. for (var i = 0, n = input.readInt(true); i < n; i++)
  4312. skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]);
  4313. for (var i = 0, n = input.readInt(true); i < n; i++)
  4314. skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]);
  4315. slotCount = input.readInt(true);
  4316. }
  4317. for (var i = 0; i < slotCount; i++) {
  4318. var slotIndex = input.readInt(true);
  4319. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4320. var name_3 = input.readStringRef();
  4321. var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential);
  4322. if (attachment != null)
  4323. skin.setAttachment(slotIndex, name_3, attachment);
  4324. }
  4325. }
  4326. return skin;
  4327. };
  4328. SkeletonBinary.prototype.readAttachment = function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) {
  4329. var scale = this.scale;
  4330. var name = input.readStringRef();
  4331. if (name == null)
  4332. name = attachmentName;
  4333. var typeIndex = input.readByte();
  4334. var type = SkeletonBinary.AttachmentTypeValues[typeIndex];
  4335. switch (type) {
  4336. case spine.AttachmentType.Region: {
  4337. var path = input.readStringRef();
  4338. var rotation = input.readFloat();
  4339. var x = input.readFloat();
  4340. var y = input.readFloat();
  4341. var scaleX = input.readFloat();
  4342. var scaleY = input.readFloat();
  4343. var width = input.readFloat();
  4344. var height = input.readFloat();
  4345. var color = input.readInt32();
  4346. if (path == null)
  4347. path = name;
  4348. var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
  4349. if (region == null)
  4350. return null;
  4351. region.path = path;
  4352. region.x = x * scale;
  4353. region.y = y * scale;
  4354. region.scaleX = scaleX;
  4355. region.scaleY = scaleY;
  4356. region.rotation = rotation;
  4357. region.width = width * scale;
  4358. region.height = height * scale;
  4359. spine.Color.rgba8888ToColor(region.color, color);
  4360. region.updateOffset();
  4361. return region;
  4362. }
  4363. case spine.AttachmentType.BoundingBox: {
  4364. var vertexCount = input.readInt(true);
  4365. var vertices = this.readVertices(input, vertexCount);
  4366. var color = nonessential ? input.readInt32() : 0;
  4367. var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
  4368. if (box == null)
  4369. return null;
  4370. box.worldVerticesLength = vertexCount << 1;
  4371. box.vertices = vertices.vertices;
  4372. box.bones = vertices.bones;
  4373. if (nonessential)
  4374. spine.Color.rgba8888ToColor(box.color, color);
  4375. return box;
  4376. }
  4377. case spine.AttachmentType.Mesh: {
  4378. var path = input.readStringRef();
  4379. var color = input.readInt32();
  4380. var vertexCount = input.readInt(true);
  4381. var uvs = this.readFloatArray(input, vertexCount << 1, 1);
  4382. var triangles = this.readShortArray(input);
  4383. var vertices = this.readVertices(input, vertexCount);
  4384. var hullLength = input.readInt(true);
  4385. var edges = null;
  4386. var width = 0, height = 0;
  4387. if (nonessential) {
  4388. edges = this.readShortArray(input);
  4389. width = input.readFloat();
  4390. height = input.readFloat();
  4391. }
  4392. if (path == null)
  4393. path = name;
  4394. var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
  4395. if (mesh == null)
  4396. return null;
  4397. mesh.path = path;
  4398. spine.Color.rgba8888ToColor(mesh.color, color);
  4399. mesh.bones = vertices.bones;
  4400. mesh.vertices = vertices.vertices;
  4401. mesh.worldVerticesLength = vertexCount << 1;
  4402. mesh.triangles = triangles;
  4403. mesh.regionUVs = uvs;
  4404. mesh.updateUVs();
  4405. mesh.hullLength = hullLength << 1;
  4406. if (nonessential) {
  4407. mesh.edges = edges;
  4408. mesh.width = width * scale;
  4409. mesh.height = height * scale;
  4410. }
  4411. return mesh;
  4412. }
  4413. case spine.AttachmentType.LinkedMesh: {
  4414. var path = input.readStringRef();
  4415. var color = input.readInt32();
  4416. var skinName = input.readStringRef();
  4417. var parent_4 = input.readStringRef();
  4418. var inheritDeform = input.readBoolean();
  4419. var width = 0, height = 0;
  4420. if (nonessential) {
  4421. width = input.readFloat();
  4422. height = input.readFloat();
  4423. }
  4424. if (path == null)
  4425. path = name;
  4426. var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
  4427. if (mesh == null)
  4428. return null;
  4429. mesh.path = path;
  4430. spine.Color.rgba8888ToColor(mesh.color, color);
  4431. if (nonessential) {
  4432. mesh.width = width * scale;
  4433. mesh.height = height * scale;
  4434. }
  4435. this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform));
  4436. return mesh;
  4437. }
  4438. case spine.AttachmentType.Path: {
  4439. var closed_1 = input.readBoolean();
  4440. var constantSpeed = input.readBoolean();
  4441. var vertexCount = input.readInt(true);
  4442. var vertices = this.readVertices(input, vertexCount);
  4443. var lengths = spine.Utils.newArray(vertexCount / 3, 0);
  4444. for (var i = 0, n = lengths.length; i < n; i++)
  4445. lengths[i] = input.readFloat() * scale;
  4446. var color = nonessential ? input.readInt32() : 0;
  4447. var path = this.attachmentLoader.newPathAttachment(skin, name);
  4448. if (path == null)
  4449. return null;
  4450. path.closed = closed_1;
  4451. path.constantSpeed = constantSpeed;
  4452. path.worldVerticesLength = vertexCount << 1;
  4453. path.vertices = vertices.vertices;
  4454. path.bones = vertices.bones;
  4455. path.lengths = lengths;
  4456. if (nonessential)
  4457. spine.Color.rgba8888ToColor(path.color, color);
  4458. return path;
  4459. }
  4460. case spine.AttachmentType.Point: {
  4461. var rotation = input.readFloat();
  4462. var x = input.readFloat();
  4463. var y = input.readFloat();
  4464. var color = nonessential ? input.readInt32() : 0;
  4465. var point = this.attachmentLoader.newPointAttachment(skin, name);
  4466. if (point == null)
  4467. return null;
  4468. point.x = x * scale;
  4469. point.y = y * scale;
  4470. point.rotation = rotation;
  4471. if (nonessential)
  4472. spine.Color.rgba8888ToColor(point.color, color);
  4473. return point;
  4474. }
  4475. case spine.AttachmentType.Clipping: {
  4476. var endSlotIndex = input.readInt(true);
  4477. var vertexCount = input.readInt(true);
  4478. var vertices = this.readVertices(input, vertexCount);
  4479. var color = nonessential ? input.readInt32() : 0;
  4480. var clip = this.attachmentLoader.newClippingAttachment(skin, name);
  4481. if (clip == null)
  4482. return null;
  4483. clip.endSlot = skeletonData.slots[endSlotIndex];
  4484. clip.worldVerticesLength = vertexCount << 1;
  4485. clip.vertices = vertices.vertices;
  4486. clip.bones = vertices.bones;
  4487. if (nonessential)
  4488. spine.Color.rgba8888ToColor(clip.color, color);
  4489. return clip;
  4490. }
  4491. }
  4492. return null;
  4493. };
  4494. SkeletonBinary.prototype.readVertices = function (input, vertexCount) {
  4495. var verticesLength = vertexCount << 1;
  4496. var vertices = new Vertices();
  4497. var scale = this.scale;
  4498. if (!input.readBoolean()) {
  4499. vertices.vertices = this.readFloatArray(input, verticesLength, scale);
  4500. return vertices;
  4501. }
  4502. var weights = new Array();
  4503. var bonesArray = new Array();
  4504. for (var i = 0; i < vertexCount; i++) {
  4505. var boneCount = input.readInt(true);
  4506. bonesArray.push(boneCount);
  4507. for (var ii = 0; ii < boneCount; ii++) {
  4508. bonesArray.push(input.readInt(true));
  4509. weights.push(input.readFloat() * scale);
  4510. weights.push(input.readFloat() * scale);
  4511. weights.push(input.readFloat());
  4512. }
  4513. }
  4514. vertices.vertices = spine.Utils.toFloatArray(weights);
  4515. vertices.bones = bonesArray;
  4516. return vertices;
  4517. };
  4518. SkeletonBinary.prototype.readFloatArray = function (input, n, scale) {
  4519. var array = new Array(n);
  4520. if (scale == 1) {
  4521. for (var i = 0; i < n; i++)
  4522. array[i] = input.readFloat();
  4523. }
  4524. else {
  4525. for (var i = 0; i < n; i++)
  4526. array[i] = input.readFloat() * scale;
  4527. }
  4528. return array;
  4529. };
  4530. SkeletonBinary.prototype.readShortArray = function (input) {
  4531. var n = input.readInt(true);
  4532. var array = new Array(n);
  4533. for (var i = 0; i < n; i++)
  4534. array[i] = input.readShort();
  4535. return array;
  4536. };
  4537. SkeletonBinary.prototype.readAnimation = function (input, name, skeletonData) {
  4538. var timelines = new Array();
  4539. var scale = this.scale;
  4540. var duration = 0;
  4541. var tempColor1 = new spine.Color();
  4542. var tempColor2 = new spine.Color();
  4543. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4544. var slotIndex = input.readInt(true);
  4545. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4546. var timelineType = input.readByte();
  4547. var frameCount = input.readInt(true);
  4548. switch (timelineType) {
  4549. case SkeletonBinary.SLOT_ATTACHMENT: {
  4550. var timeline = new spine.AttachmentTimeline(frameCount);
  4551. timeline.slotIndex = slotIndex;
  4552. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++)
  4553. timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef());
  4554. timelines.push(timeline);
  4555. duration = Math.max(duration, timeline.frames[frameCount - 1]);
  4556. break;
  4557. }
  4558. case SkeletonBinary.SLOT_COLOR: {
  4559. var timeline = new spine.ColorTimeline(frameCount);
  4560. timeline.slotIndex = slotIndex;
  4561. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4562. var time = input.readFloat();
  4563. spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
  4564. timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
  4565. if (frameIndex < frameCount - 1)
  4566. this.readCurve(input, frameIndex, timeline);
  4567. }
  4568. timelines.push(timeline);
  4569. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.ColorTimeline.ENTRIES]);
  4570. break;
  4571. }
  4572. case SkeletonBinary.SLOT_TWO_COLOR: {
  4573. var timeline = new spine.TwoColorTimeline(frameCount);
  4574. timeline.slotIndex = slotIndex;
  4575. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4576. var time = input.readFloat();
  4577. spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
  4578. spine.Color.rgb888ToColor(tempColor2, input.readInt32());
  4579. timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
  4580. if (frameIndex < frameCount - 1)
  4581. this.readCurve(input, frameIndex, timeline);
  4582. }
  4583. timelines.push(timeline);
  4584. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TwoColorTimeline.ENTRIES]);
  4585. break;
  4586. }
  4587. }
  4588. }
  4589. }
  4590. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4591. var boneIndex = input.readInt(true);
  4592. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4593. var timelineType = input.readByte();
  4594. var frameCount = input.readInt(true);
  4595. switch (timelineType) {
  4596. case SkeletonBinary.BONE_ROTATE: {
  4597. var timeline = new spine.RotateTimeline(frameCount);
  4598. timeline.boneIndex = boneIndex;
  4599. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4600. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
  4601. if (frameIndex < frameCount - 1)
  4602. this.readCurve(input, frameIndex, timeline);
  4603. }
  4604. timelines.push(timeline);
  4605. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.RotateTimeline.ENTRIES]);
  4606. break;
  4607. }
  4608. case SkeletonBinary.BONE_TRANSLATE:
  4609. case SkeletonBinary.BONE_SCALE:
  4610. case SkeletonBinary.BONE_SHEAR: {
  4611. var timeline = void 0;
  4612. var timelineScale = 1;
  4613. if (timelineType == SkeletonBinary.BONE_SCALE)
  4614. timeline = new spine.ScaleTimeline(frameCount);
  4615. else if (timelineType == SkeletonBinary.BONE_SHEAR)
  4616. timeline = new spine.ShearTimeline(frameCount);
  4617. else {
  4618. timeline = new spine.TranslateTimeline(frameCount);
  4619. timelineScale = scale;
  4620. }
  4621. timeline.boneIndex = boneIndex;
  4622. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4623. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
  4624. if (frameIndex < frameCount - 1)
  4625. this.readCurve(input, frameIndex, timeline);
  4626. }
  4627. timelines.push(timeline);
  4628. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TranslateTimeline.ENTRIES]);
  4629. break;
  4630. }
  4631. }
  4632. }
  4633. }
  4634. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4635. var index = input.readInt(true);
  4636. var frameCount = input.readInt(true);
  4637. var timeline = new spine.IkConstraintTimeline(frameCount);
  4638. timeline.ikConstraintIndex = index;
  4639. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4640. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat() * scale, input.readByte(), input.readBoolean(), input.readBoolean());
  4641. if (frameIndex < frameCount - 1)
  4642. this.readCurve(input, frameIndex, timeline);
  4643. }
  4644. timelines.push(timeline);
  4645. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.IkConstraintTimeline.ENTRIES]);
  4646. }
  4647. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4648. var index = input.readInt(true);
  4649. var frameCount = input.readInt(true);
  4650. var timeline = new spine.TransformConstraintTimeline(frameCount);
  4651. timeline.transformConstraintIndex = index;
  4652. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4653. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
  4654. if (frameIndex < frameCount - 1)
  4655. this.readCurve(input, frameIndex, timeline);
  4656. }
  4657. timelines.push(timeline);
  4658. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TransformConstraintTimeline.ENTRIES]);
  4659. }
  4660. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4661. var index = input.readInt(true);
  4662. var data = skeletonData.pathConstraints[index];
  4663. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4664. var timelineType = input.readByte();
  4665. var frameCount = input.readInt(true);
  4666. switch (timelineType) {
  4667. case SkeletonBinary.PATH_POSITION:
  4668. case SkeletonBinary.PATH_SPACING: {
  4669. var timeline = void 0;
  4670. var timelineScale = 1;
  4671. if (timelineType == SkeletonBinary.PATH_SPACING) {
  4672. timeline = new spine.PathConstraintSpacingTimeline(frameCount);
  4673. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  4674. timelineScale = scale;
  4675. }
  4676. else {
  4677. timeline = new spine.PathConstraintPositionTimeline(frameCount);
  4678. if (data.positionMode == spine.PositionMode.Fixed)
  4679. timelineScale = scale;
  4680. }
  4681. timeline.pathConstraintIndex = index;
  4682. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4683. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
  4684. if (frameIndex < frameCount - 1)
  4685. this.readCurve(input, frameIndex, timeline);
  4686. }
  4687. timelines.push(timeline);
  4688. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
  4689. break;
  4690. }
  4691. case SkeletonBinary.PATH_MIX: {
  4692. var timeline = new spine.PathConstraintMixTimeline(frameCount);
  4693. timeline.pathConstraintIndex = index;
  4694. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4695. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
  4696. if (frameIndex < frameCount - 1)
  4697. this.readCurve(input, frameIndex, timeline);
  4698. }
  4699. timelines.push(timeline);
  4700. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
  4701. break;
  4702. }
  4703. }
  4704. }
  4705. }
  4706. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4707. var skin = skeletonData.skins[input.readInt(true)];
  4708. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4709. var slotIndex = input.readInt(true);
  4710. for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
  4711. var attachment = skin.getAttachment(slotIndex, input.readStringRef());
  4712. var weighted = attachment.bones != null;
  4713. var vertices = attachment.vertices;
  4714. var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
  4715. var frameCount = input.readInt(true);
  4716. var timeline = new spine.DeformTimeline(frameCount);
  4717. timeline.slotIndex = slotIndex;
  4718. timeline.attachment = attachment;
  4719. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4720. var time = input.readFloat();
  4721. var deform = void 0;
  4722. var end = input.readInt(true);
  4723. if (end == 0)
  4724. deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
  4725. else {
  4726. deform = spine.Utils.newFloatArray(deformLength);
  4727. var start = input.readInt(true);
  4728. end += start;
  4729. if (scale == 1) {
  4730. for (var v = start; v < end; v++)
  4731. deform[v] = input.readFloat();
  4732. }
  4733. else {
  4734. for (var v = start; v < end; v++)
  4735. deform[v] = input.readFloat() * scale;
  4736. }
  4737. if (!weighted) {
  4738. for (var v = 0, vn = deform.length; v < vn; v++)
  4739. deform[v] += vertices[v];
  4740. }
  4741. }
  4742. timeline.setFrame(frameIndex, time, deform);
  4743. if (frameIndex < frameCount - 1)
  4744. this.readCurve(input, frameIndex, timeline);
  4745. }
  4746. timelines.push(timeline);
  4747. duration = Math.max(duration, timeline.frames[frameCount - 1]);
  4748. }
  4749. }
  4750. }
  4751. var drawOrderCount = input.readInt(true);
  4752. if (drawOrderCount > 0) {
  4753. var timeline = new spine.DrawOrderTimeline(drawOrderCount);
  4754. var slotCount = skeletonData.slots.length;
  4755. for (var i = 0; i < drawOrderCount; i++) {
  4756. var time = input.readFloat();
  4757. var offsetCount = input.readInt(true);
  4758. var drawOrder = spine.Utils.newArray(slotCount, 0);
  4759. for (var ii = slotCount - 1; ii >= 0; ii--)
  4760. drawOrder[ii] = -1;
  4761. var unchanged = spine.Utils.newArray(slotCount - offsetCount, 0);
  4762. var originalIndex = 0, unchangedIndex = 0;
  4763. for (var ii = 0; ii < offsetCount; ii++) {
  4764. var slotIndex = input.readInt(true);
  4765. while (originalIndex != slotIndex)
  4766. unchanged[unchangedIndex++] = originalIndex++;
  4767. drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
  4768. }
  4769. while (originalIndex < slotCount)
  4770. unchanged[unchangedIndex++] = originalIndex++;
  4771. for (var ii = slotCount - 1; ii >= 0; ii--)
  4772. if (drawOrder[ii] == -1)
  4773. drawOrder[ii] = unchanged[--unchangedIndex];
  4774. timeline.setFrame(i, time, drawOrder);
  4775. }
  4776. timelines.push(timeline);
  4777. duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
  4778. }
  4779. var eventCount = input.readInt(true);
  4780. if (eventCount > 0) {
  4781. var timeline = new spine.EventTimeline(eventCount);
  4782. for (var i = 0; i < eventCount; i++) {
  4783. var time = input.readFloat();
  4784. var eventData = skeletonData.events[input.readInt(true)];
  4785. var event_4 = new spine.Event(time, eventData);
  4786. event_4.intValue = input.readInt(false);
  4787. event_4.floatValue = input.readFloat();
  4788. event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue;
  4789. if (event_4.data.audioPath != null) {
  4790. event_4.volume = input.readFloat();
  4791. event_4.balance = input.readFloat();
  4792. }
  4793. timeline.setFrame(i, event_4);
  4794. }
  4795. timelines.push(timeline);
  4796. duration = Math.max(duration, timeline.frames[eventCount - 1]);
  4797. }
  4798. return new spine.Animation(name, timelines, duration);
  4799. };
  4800. SkeletonBinary.prototype.readCurve = function (input, frameIndex, timeline) {
  4801. switch (input.readByte()) {
  4802. case SkeletonBinary.CURVE_STEPPED:
  4803. timeline.setStepped(frameIndex);
  4804. break;
  4805. case SkeletonBinary.CURVE_BEZIER:
  4806. this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
  4807. break;
  4808. }
  4809. };
  4810. SkeletonBinary.prototype.setCurve = function (timeline, frameIndex, cx1, cy1, cx2, cy2) {
  4811. timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2);
  4812. };
  4813. SkeletonBinary.AttachmentTypeValues = [0, 1, 2, 3, 4, 5, 6];
  4814. SkeletonBinary.TransformModeValues = [spine.TransformMode.Normal, spine.TransformMode.OnlyTranslation, spine.TransformMode.NoRotationOrReflection, spine.TransformMode.NoScale, spine.TransformMode.NoScaleOrReflection];
  4815. SkeletonBinary.PositionModeValues = [spine.PositionMode.Fixed, spine.PositionMode.Percent];
  4816. SkeletonBinary.SpacingModeValues = [spine.SpacingMode.Length, spine.SpacingMode.Fixed, spine.SpacingMode.Percent];
  4817. SkeletonBinary.RotateModeValues = [spine.RotateMode.Tangent, spine.RotateMode.Chain, spine.RotateMode.ChainScale];
  4818. SkeletonBinary.BlendModeValues = [spine.BlendMode.Normal, spine.BlendMode.Additive, spine.BlendMode.Multiply, spine.BlendMode.Screen];
  4819. SkeletonBinary.BONE_ROTATE = 0;
  4820. SkeletonBinary.BONE_TRANSLATE = 1;
  4821. SkeletonBinary.BONE_SCALE = 2;
  4822. SkeletonBinary.BONE_SHEAR = 3;
  4823. SkeletonBinary.SLOT_ATTACHMENT = 0;
  4824. SkeletonBinary.SLOT_COLOR = 1;
  4825. SkeletonBinary.SLOT_TWO_COLOR = 2;
  4826. SkeletonBinary.PATH_POSITION = 0;
  4827. SkeletonBinary.PATH_SPACING = 1;
  4828. SkeletonBinary.PATH_MIX = 2;
  4829. SkeletonBinary.CURVE_LINEAR = 0;
  4830. SkeletonBinary.CURVE_STEPPED = 1;
  4831. SkeletonBinary.CURVE_BEZIER = 2;
  4832. return SkeletonBinary;
  4833. }());
  4834. spine.SkeletonBinary = SkeletonBinary;
  4835. var BinaryInput = (function () {
  4836. function BinaryInput(data, strings, index, buffer) {
  4837. if (strings === void 0) { strings = new Array(); }
  4838. if (index === void 0) { index = 0; }
  4839. if (buffer === void 0) { buffer = new DataView(data.buffer); }
  4840. this.strings = strings;
  4841. this.index = index;
  4842. this.buffer = buffer;
  4843. }
  4844. BinaryInput.prototype.readByte = function () {
  4845. return this.buffer.getInt8(this.index++);
  4846. };
  4847. BinaryInput.prototype.readShort = function () {
  4848. var value = this.buffer.getInt16(this.index);
  4849. this.index += 2;
  4850. return value;
  4851. };
  4852. BinaryInput.prototype.readInt32 = function () {
  4853. var value = this.buffer.getInt32(this.index);
  4854. this.index += 4;
  4855. return value;
  4856. };
  4857. BinaryInput.prototype.readInt = function (optimizePositive) {
  4858. var b = this.readByte();
  4859. var result = b & 0x7F;
  4860. if ((b & 0x80) != 0) {
  4861. b = this.readByte();
  4862. result |= (b & 0x7F) << 7;
  4863. if ((b & 0x80) != 0) {
  4864. b = this.readByte();
  4865. result |= (b & 0x7F) << 14;
  4866. if ((b & 0x80) != 0) {
  4867. b = this.readByte();
  4868. result |= (b & 0x7F) << 21;
  4869. if ((b & 0x80) != 0) {
  4870. b = this.readByte();
  4871. result |= (b & 0x7F) << 28;
  4872. }
  4873. }
  4874. }
  4875. }
  4876. return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
  4877. };
  4878. BinaryInput.prototype.readStringRef = function () {
  4879. var index = this.readInt(true);
  4880. return index == 0 ? null : this.strings[index - 1];
  4881. };
  4882. BinaryInput.prototype.readString = function () {
  4883. var byteCount = this.readInt(true);
  4884. switch (byteCount) {
  4885. case 0:
  4886. return null;
  4887. case 1:
  4888. return "";
  4889. }
  4890. byteCount--;
  4891. var chars = "";
  4892. var charCount = 0;
  4893. for (var i = 0; i < byteCount;) {
  4894. var b = this.readByte();
  4895. switch (b >> 4) {
  4896. case 12:
  4897. case 13:
  4898. chars += String.fromCharCode(((b & 0x1F) << 6 | this.readByte() & 0x3F));
  4899. i += 2;
  4900. break;
  4901. case 14:
  4902. chars += String.fromCharCode(((b & 0x0F) << 12 | (this.readByte() & 0x3F) << 6 | this.readByte() & 0x3F));
  4903. i += 3;
  4904. break;
  4905. default:
  4906. chars += String.fromCharCode(b);
  4907. i++;
  4908. }
  4909. }
  4910. return chars;
  4911. };
  4912. BinaryInput.prototype.readFloat = function () {
  4913. var value = this.buffer.getFloat32(this.index);
  4914. this.index += 4;
  4915. return value;
  4916. };
  4917. BinaryInput.prototype.readBoolean = function () {
  4918. return this.readByte() != 0;
  4919. };
  4920. return BinaryInput;
  4921. }());
  4922. var LinkedMesh = (function () {
  4923. function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
  4924. this.mesh = mesh;
  4925. this.skin = skin;
  4926. this.slotIndex = slotIndex;
  4927. this.parent = parent;
  4928. this.inheritDeform = inheritDeform;
  4929. }
  4930. return LinkedMesh;
  4931. }());
  4932. var Vertices = (function () {
  4933. function Vertices(bones, vertices) {
  4934. if (bones === void 0) { bones = null; }
  4935. if (vertices === void 0) { vertices = null; }
  4936. this.bones = bones;
  4937. this.vertices = vertices;
  4938. }
  4939. return Vertices;
  4940. }());
  4941. })(spine || (spine = {}));
  4942. var spine;
  4943. (function (spine) {
  4944. var SkeletonBounds = (function () {
  4945. function SkeletonBounds() {
  4946. this.minX = 0;
  4947. this.minY = 0;
  4948. this.maxX = 0;
  4949. this.maxY = 0;
  4950. this.boundingBoxes = new Array();
  4951. this.polygons = new Array();
  4952. this.polygonPool = new spine.Pool(function () {
  4953. return spine.Utils.newFloatArray(16);
  4954. });
  4955. }
  4956. SkeletonBounds.prototype.update = function (skeleton, updateAabb) {
  4957. if (skeleton == null)
  4958. throw new Error("skeleton cannot be null.");
  4959. var boundingBoxes = this.boundingBoxes;
  4960. var polygons = this.polygons;
  4961. var polygonPool = this.polygonPool;
  4962. var slots = skeleton.slots;
  4963. var slotCount = slots.length;
  4964. boundingBoxes.length = 0;
  4965. polygonPool.freeAll(polygons);
  4966. polygons.length = 0;
  4967. for (var i = 0; i < slotCount; i++) {
  4968. var slot = slots[i];
  4969. if (!slot.bone.active)
  4970. continue;
  4971. var attachment = slot.getAttachment();
  4972. if (attachment instanceof spine.BoundingBoxAttachment) {
  4973. var boundingBox = attachment;
  4974. boundingBoxes.push(boundingBox);
  4975. var polygon = polygonPool.obtain();
  4976. if (polygon.length != boundingBox.worldVerticesLength) {
  4977. polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength);
  4978. }
  4979. polygons.push(polygon);
  4980. boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2);
  4981. }
  4982. }
  4983. if (updateAabb) {
  4984. this.aabbCompute();
  4985. }
  4986. else {
  4987. this.minX = Number.POSITIVE_INFINITY;
  4988. this.minY = Number.POSITIVE_INFINITY;
  4989. this.maxX = Number.NEGATIVE_INFINITY;
  4990. this.maxY = Number.NEGATIVE_INFINITY;
  4991. }
  4992. };
  4993. SkeletonBounds.prototype.aabbCompute = function () {
  4994. var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;
  4995. var polygons = this.polygons;
  4996. for (var i = 0, n = polygons.length; i < n; i++) {
  4997. var polygon = polygons[i];
  4998. var vertices = polygon;
  4999. for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) {
  5000. var x = vertices[ii];
  5001. var y = vertices[ii + 1];
  5002. minX = Math.min(minX, x);
  5003. minY = Math.min(minY, y);
  5004. maxX = Math.max(maxX, x);
  5005. maxY = Math.max(maxY, y);
  5006. }
  5007. }
  5008. this.minX = minX;
  5009. this.minY = minY;
  5010. this.maxX = maxX;
  5011. this.maxY = maxY;
  5012. };
  5013. SkeletonBounds.prototype.aabbContainsPoint = function (x, y) {
  5014. return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY;
  5015. };
  5016. SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) {
  5017. var minX = this.minX;
  5018. var minY = this.minY;
  5019. var maxX = this.maxX;
  5020. var maxY = this.maxY;
  5021. if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY))
  5022. return false;
  5023. var m = (y2 - y1) / (x2 - x1);
  5024. var y = m * (minX - x1) + y1;
  5025. if (y > minY && y < maxY)
  5026. return true;
  5027. y = m * (maxX - x1) + y1;
  5028. if (y > minY && y < maxY)
  5029. return true;
  5030. var x = (minY - y1) / m + x1;
  5031. if (x > minX && x < maxX)
  5032. return true;
  5033. x = (maxY - y1) / m + x1;
  5034. if (x > minX && x < maxX)
  5035. return true;
  5036. return false;
  5037. };
  5038. SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) {
  5039. return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY;
  5040. };
  5041. SkeletonBounds.prototype.containsPoint = function (x, y) {
  5042. var polygons = this.polygons;
  5043. for (var i = 0, n = polygons.length; i < n; i++)
  5044. if (this.containsPointPolygon(polygons[i], x, y))
  5045. return this.boundingBoxes[i];
  5046. return null;
  5047. };
  5048. SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) {
  5049. var vertices = polygon;
  5050. var nn = polygon.length;
  5051. var prevIndex = nn - 2;
  5052. var inside = false;
  5053. for (var ii = 0; ii < nn; ii += 2) {
  5054. var vertexY = vertices[ii + 1];
  5055. var prevY = vertices[prevIndex + 1];
  5056. if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) {
  5057. var vertexX = vertices[ii];
  5058. if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x)
  5059. inside = !inside;
  5060. }
  5061. prevIndex = ii;
  5062. }
  5063. return inside;
  5064. };
  5065. SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) {
  5066. var polygons = this.polygons;
  5067. for (var i = 0, n = polygons.length; i < n; i++)
  5068. if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2))
  5069. return this.boundingBoxes[i];
  5070. return null;
  5071. };
  5072. SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) {
  5073. var vertices = polygon;
  5074. var nn = polygon.length;
  5075. var width12 = x1 - x2, height12 = y1 - y2;
  5076. var det1 = x1 * y2 - y1 * x2;
  5077. var x3 = vertices[nn - 2], y3 = vertices[nn - 1];
  5078. for (var ii = 0; ii < nn; ii += 2) {
  5079. var x4 = vertices[ii], y4 = vertices[ii + 1];
  5080. var det2 = x3 * y4 - y3 * x4;
  5081. var width34 = x3 - x4, height34 = y3 - y4;
  5082. var det3 = width12 * height34 - height12 * width34;
  5083. var x = (det1 * width34 - width12 * det2) / det3;
  5084. if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {
  5085. var y = (det1 * height34 - height12 * det2) / det3;
  5086. if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1)))
  5087. return true;
  5088. }
  5089. x3 = x4;
  5090. y3 = y4;
  5091. }
  5092. return false;
  5093. };
  5094. SkeletonBounds.prototype.getPolygon = function (boundingBox) {
  5095. if (boundingBox == null)
  5096. throw new Error("boundingBox cannot be null.");
  5097. var index = this.boundingBoxes.indexOf(boundingBox);
  5098. return index == -1 ? null : this.polygons[index];
  5099. };
  5100. SkeletonBounds.prototype.getWidth = function () {
  5101. return this.maxX - this.minX;
  5102. };
  5103. SkeletonBounds.prototype.getHeight = function () {
  5104. return this.maxY - this.minY;
  5105. };
  5106. return SkeletonBounds;
  5107. }());
  5108. spine.SkeletonBounds = SkeletonBounds;
  5109. })(spine || (spine = {}));
  5110. var spine;
  5111. (function (spine) {
  5112. var SkeletonClipping = (function () {
  5113. function SkeletonClipping() {
  5114. this.triangulator = new spine.Triangulator();
  5115. this.clippingPolygon = new Array();
  5116. this.clipOutput = new Array();
  5117. this.clippedVertices = new Array();
  5118. this.clippedTriangles = new Array();
  5119. this.scratch = new Array();
  5120. }
  5121. SkeletonClipping.prototype.clipStart = function (slot, clip) {
  5122. if (this.clipAttachment != null)
  5123. return 0;
  5124. this.clipAttachment = clip;
  5125. var n = clip.worldVerticesLength;
  5126. var vertices = spine.Utils.setArraySize(this.clippingPolygon, n);
  5127. clip.computeWorldVertices(slot, 0, n, vertices, 0, 2);
  5128. var clippingPolygon = this.clippingPolygon;
  5129. SkeletonClipping.makeClockwise(clippingPolygon);
  5130. var clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon));
  5131. for (var i = 0, n_2 = clippingPolygons.length; i < n_2; i++) {
  5132. var polygon = clippingPolygons[i];
  5133. SkeletonClipping.makeClockwise(polygon);
  5134. polygon.push(polygon[0]);
  5135. polygon.push(polygon[1]);
  5136. }
  5137. return clippingPolygons.length;
  5138. };
  5139. SkeletonClipping.prototype.clipEndWithSlot = function (slot) {
  5140. if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data)
  5141. this.clipEnd();
  5142. };
  5143. SkeletonClipping.prototype.clipEnd = function () {
  5144. if (this.clipAttachment == null)
  5145. return;
  5146. this.clipAttachment = null;
  5147. this.clippingPolygons = null;
  5148. this.clippedVertices.length = 0;
  5149. this.clippedTriangles.length = 0;
  5150. this.clippingPolygon.length = 0;
  5151. };
  5152. SkeletonClipping.prototype.isClipping = function () {
  5153. return this.clipAttachment != null;
  5154. };
  5155. SkeletonClipping.prototype.clipTriangles = function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) {
  5156. var clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
  5157. var clippedTriangles = this.clippedTriangles;
  5158. var polygons = this.clippingPolygons;
  5159. var polygonsCount = this.clippingPolygons.length;
  5160. var vertexSize = twoColor ? 12 : 8;
  5161. var index = 0;
  5162. clippedVertices.length = 0;
  5163. clippedTriangles.length = 0;
  5164. outer: for (var i = 0; i < trianglesLength; i += 3) {
  5165. var vertexOffset = triangles[i] << 1;
  5166. var x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
  5167. var u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
  5168. vertexOffset = triangles[i + 1] << 1;
  5169. var x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
  5170. var u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];
  5171. vertexOffset = triangles[i + 2] << 1;
  5172. var x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
  5173. var u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
  5174. for (var p = 0; p < polygonsCount; p++) {
  5175. var s = clippedVertices.length;
  5176. if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {
  5177. var clipOutputLength = clipOutput.length;
  5178. if (clipOutputLength == 0)
  5179. continue;
  5180. var d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
  5181. var d = 1 / (d0 * d2 + d1 * (y1 - y3));
  5182. var clipOutputCount = clipOutputLength >> 1;
  5183. var clipOutputItems = this.clipOutput;
  5184. var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize);
  5185. for (var ii = 0; ii < clipOutputLength; ii += 2) {
  5186. var x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
  5187. clippedVerticesItems[s] = x;
  5188. clippedVerticesItems[s + 1] = y;
  5189. clippedVerticesItems[s + 2] = light.r;
  5190. clippedVerticesItems[s + 3] = light.g;
  5191. clippedVerticesItems[s + 4] = light.b;
  5192. clippedVerticesItems[s + 5] = light.a;
  5193. var c0 = x - x3, c1 = y - y3;
  5194. var a = (d0 * c0 + d1 * c1) * d;
  5195. var b = (d4 * c0 + d2 * c1) * d;
  5196. var c = 1 - a - b;
  5197. clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c;
  5198. clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
  5199. if (twoColor) {
  5200. clippedVerticesItems[s + 8] = dark.r;
  5201. clippedVerticesItems[s + 9] = dark.g;
  5202. clippedVerticesItems[s + 10] = dark.b;
  5203. clippedVerticesItems[s + 11] = dark.a;
  5204. }
  5205. s += vertexSize;
  5206. }
  5207. s = clippedTriangles.length;
  5208. var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2));
  5209. clipOutputCount--;
  5210. for (var ii = 1; ii < clipOutputCount; ii++) {
  5211. clippedTrianglesItems[s] = index;
  5212. clippedTrianglesItems[s + 1] = (index + ii);
  5213. clippedTrianglesItems[s + 2] = (index + ii + 1);
  5214. s += 3;
  5215. }
  5216. index += clipOutputCount + 1;
  5217. }
  5218. else {
  5219. var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + 3 * vertexSize);
  5220. clippedVerticesItems[s] = x1;
  5221. clippedVerticesItems[s + 1] = y1;
  5222. clippedVerticesItems[s + 2] = light.r;
  5223. clippedVerticesItems[s + 3] = light.g;
  5224. clippedVerticesItems[s + 4] = light.b;
  5225. clippedVerticesItems[s + 5] = light.a;
  5226. if (!twoColor) {
  5227. clippedVerticesItems[s + 6] = u1;
  5228. clippedVerticesItems[s + 7] = v1;
  5229. clippedVerticesItems[s + 8] = x2;
  5230. clippedVerticesItems[s + 9] = y2;
  5231. clippedVerticesItems[s + 10] = light.r;
  5232. clippedVerticesItems[s + 11] = light.g;
  5233. clippedVerticesItems[s + 12] = light.b;
  5234. clippedVerticesItems[s + 13] = light.a;
  5235. clippedVerticesItems[s + 14] = u2;
  5236. clippedVerticesItems[s + 15] = v2;
  5237. clippedVerticesItems[s + 16] = x3;
  5238. clippedVerticesItems[s + 17] = y3;
  5239. clippedVerticesItems[s + 18] = light.r;
  5240. clippedVerticesItems[s + 19] = light.g;
  5241. clippedVerticesItems[s + 20] = light.b;
  5242. clippedVerticesItems[s + 21] = light.a;
  5243. clippedVerticesItems[s + 22] = u3;
  5244. clippedVerticesItems[s + 23] = v3;
  5245. }
  5246. else {
  5247. clippedVerticesItems[s + 6] = u1;
  5248. clippedVerticesItems[s + 7] = v1;
  5249. clippedVerticesItems[s + 8] = dark.r;
  5250. clippedVerticesItems[s + 9] = dark.g;
  5251. clippedVerticesItems[s + 10] = dark.b;
  5252. clippedVerticesItems[s + 11] = dark.a;
  5253. clippedVerticesItems[s + 12] = x2;
  5254. clippedVerticesItems[s + 13] = y2;
  5255. clippedVerticesItems[s + 14] = light.r;
  5256. clippedVerticesItems[s + 15] = light.g;
  5257. clippedVerticesItems[s + 16] = light.b;
  5258. clippedVerticesItems[s + 17] = light.a;
  5259. clippedVerticesItems[s + 18] = u2;
  5260. clippedVerticesItems[s + 19] = v2;
  5261. clippedVerticesItems[s + 20] = dark.r;
  5262. clippedVerticesItems[s + 21] = dark.g;
  5263. clippedVerticesItems[s + 22] = dark.b;
  5264. clippedVerticesItems[s + 23] = dark.a;
  5265. clippedVerticesItems[s + 24] = x3;
  5266. clippedVerticesItems[s + 25] = y3;
  5267. clippedVerticesItems[s + 26] = light.r;
  5268. clippedVerticesItems[s + 27] = light.g;
  5269. clippedVerticesItems[s + 28] = light.b;
  5270. clippedVerticesItems[s + 29] = light.a;
  5271. clippedVerticesItems[s + 30] = u3;
  5272. clippedVerticesItems[s + 31] = v3;
  5273. clippedVerticesItems[s + 32] = dark.r;
  5274. clippedVerticesItems[s + 33] = dark.g;
  5275. clippedVerticesItems[s + 34] = dark.b;
  5276. clippedVerticesItems[s + 35] = dark.a;
  5277. }
  5278. s = clippedTriangles.length;
  5279. var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3);
  5280. clippedTrianglesItems[s] = index;
  5281. clippedTrianglesItems[s + 1] = (index + 1);
  5282. clippedTrianglesItems[s + 2] = (index + 2);
  5283. index += 3;
  5284. continue outer;
  5285. }
  5286. }
  5287. }
  5288. };
  5289. SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) {
  5290. var originalOutput = output;
  5291. var clipped = false;
  5292. var input = null;
  5293. if (clippingArea.length % 4 >= 2) {
  5294. input = output;
  5295. output = this.scratch;
  5296. }
  5297. else
  5298. input = this.scratch;
  5299. input.length = 0;
  5300. input.push(x1);
  5301. input.push(y1);
  5302. input.push(x2);
  5303. input.push(y2);
  5304. input.push(x3);
  5305. input.push(y3);
  5306. input.push(x1);
  5307. input.push(y1);
  5308. output.length = 0;
  5309. var clippingVertices = clippingArea;
  5310. var clippingVerticesLast = clippingArea.length - 4;
  5311. for (var i = 0;; i += 2) {
  5312. var edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1];
  5313. var edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3];
  5314. var deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
  5315. var inputVertices = input;
  5316. var inputVerticesLength = input.length - 2, outputStart = output.length;
  5317. for (var ii = 0; ii < inputVerticesLength; ii += 2) {
  5318. var inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
  5319. var inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
  5320. var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0;
  5321. if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) {
  5322. if (side2) {
  5323. output.push(inputX2);
  5324. output.push(inputY2);
  5325. continue;
  5326. }
  5327. var c0 = inputY2 - inputY, c2 = inputX2 - inputX;
  5328. var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
  5329. if (Math.abs(s) > 0.000001) {
  5330. var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s;
  5331. output.push(edgeX + (edgeX2 - edgeX) * ua);
  5332. output.push(edgeY + (edgeY2 - edgeY) * ua);
  5333. }
  5334. else {
  5335. output.push(edgeX);
  5336. output.push(edgeY);
  5337. }
  5338. }
  5339. else if (side2) {
  5340. var c0 = inputY2 - inputY, c2 = inputX2 - inputX;
  5341. var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
  5342. if (Math.abs(s) > 0.000001) {
  5343. var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s;
  5344. output.push(edgeX + (edgeX2 - edgeX) * ua);
  5345. output.push(edgeY + (edgeY2 - edgeY) * ua);
  5346. }
  5347. else {
  5348. output.push(edgeX);
  5349. output.push(edgeY);
  5350. }
  5351. output.push(inputX2);
  5352. output.push(inputY2);
  5353. }
  5354. clipped = true;
  5355. }
  5356. if (outputStart == output.length) {
  5357. originalOutput.length = 0;
  5358. return true;
  5359. }
  5360. output.push(output[0]);
  5361. output.push(output[1]);
  5362. if (i == clippingVerticesLast)
  5363. break;
  5364. var temp = output;
  5365. output = input;
  5366. output.length = 0;
  5367. input = temp;
  5368. }
  5369. if (originalOutput != output) {
  5370. originalOutput.length = 0;
  5371. for (var i = 0, n = output.length - 2; i < n; i++)
  5372. originalOutput[i] = output[i];
  5373. }
  5374. else
  5375. originalOutput.length = originalOutput.length - 2;
  5376. return clipped;
  5377. };
  5378. SkeletonClipping.makeClockwise = function (polygon) {
  5379. var vertices = polygon;
  5380. var verticeslength = polygon.length;
  5381. var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0;
  5382. for (var i = 0, n = verticeslength - 3; i < n; i += 2) {
  5383. p1x = vertices[i];
  5384. p1y = vertices[i + 1];
  5385. p2x = vertices[i + 2];
  5386. p2y = vertices[i + 3];
  5387. area += p1x * p2y - p2x * p1y;
  5388. }
  5389. if (area < 0)
  5390. return;
  5391. for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) {
  5392. var x = vertices[i], y = vertices[i + 1];
  5393. var other = lastX - i;
  5394. vertices[i] = vertices[other];
  5395. vertices[i + 1] = vertices[other + 1];
  5396. vertices[other] = x;
  5397. vertices[other + 1] = y;
  5398. }
  5399. };
  5400. return SkeletonClipping;
  5401. }());
  5402. spine.SkeletonClipping = SkeletonClipping;
  5403. })(spine || (spine = {}));
  5404. var spine;
  5405. (function (spine) {
  5406. var SkeletonData = (function () {
  5407. function SkeletonData() {
  5408. this.bones = new Array();
  5409. this.slots = new Array();
  5410. this.skins = new Array();
  5411. this.events = new Array();
  5412. this.animations = new Array();
  5413. this.ikConstraints = new Array();
  5414. this.transformConstraints = new Array();
  5415. this.pathConstraints = new Array();
  5416. this.fps = 0;
  5417. }
  5418. SkeletonData.prototype.findBone = function (boneName) {
  5419. if (boneName == null)
  5420. throw new Error("boneName cannot be null.");
  5421. var bones = this.bones;
  5422. for (var i = 0, n = bones.length; i < n; i++) {
  5423. var bone = bones[i];
  5424. if (bone.name == boneName)
  5425. return bone;
  5426. }
  5427. return null;
  5428. };
  5429. SkeletonData.prototype.findBoneIndex = function (boneName) {
  5430. if (boneName == null)
  5431. throw new Error("boneName cannot be null.");
  5432. var bones = this.bones;
  5433. for (var i = 0, n = bones.length; i < n; i++)
  5434. if (bones[i].name == boneName)
  5435. return i;
  5436. return -1;
  5437. };
  5438. SkeletonData.prototype.findSlot = function (slotName) {
  5439. if (slotName == null)
  5440. throw new Error("slotName cannot be null.");
  5441. var slots = this.slots;
  5442. for (var i = 0, n = slots.length; i < n; i++) {
  5443. var slot = slots[i];
  5444. if (slot.name == slotName)
  5445. return slot;
  5446. }
  5447. return null;
  5448. };
  5449. SkeletonData.prototype.findSlotIndex = function (slotName) {
  5450. if (slotName == null)
  5451. throw new Error("slotName cannot be null.");
  5452. var slots = this.slots;
  5453. for (var i = 0, n = slots.length; i < n; i++)
  5454. if (slots[i].name == slotName)
  5455. return i;
  5456. return -1;
  5457. };
  5458. SkeletonData.prototype.findSkin = function (skinName) {
  5459. if (skinName == null)
  5460. throw new Error("skinName cannot be null.");
  5461. var skins = this.skins;
  5462. for (var i = 0, n = skins.length; i < n; i++) {
  5463. var skin = skins[i];
  5464. if (skin.name == skinName)
  5465. return skin;
  5466. }
  5467. return null;
  5468. };
  5469. SkeletonData.prototype.findEvent = function (eventDataName) {
  5470. if (eventDataName == null)
  5471. throw new Error("eventDataName cannot be null.");
  5472. var events = this.events;
  5473. for (var i = 0, n = events.length; i < n; i++) {
  5474. var event_5 = events[i];
  5475. if (event_5.name == eventDataName)
  5476. return event_5;
  5477. }
  5478. return null;
  5479. };
  5480. SkeletonData.prototype.findAnimation = function (animationName) {
  5481. if (animationName == null)
  5482. throw new Error("animationName cannot be null.");
  5483. var animations = this.animations;
  5484. for (var i = 0, n = animations.length; i < n; i++) {
  5485. var animation = animations[i];
  5486. if (animation.name == animationName)
  5487. return animation;
  5488. }
  5489. return null;
  5490. };
  5491. SkeletonData.prototype.findIkConstraint = function (constraintName) {
  5492. if (constraintName == null)
  5493. throw new Error("constraintName cannot be null.");
  5494. var ikConstraints = this.ikConstraints;
  5495. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  5496. var constraint = ikConstraints[i];
  5497. if (constraint.name == constraintName)
  5498. return constraint;
  5499. }
  5500. return null;
  5501. };
  5502. SkeletonData.prototype.findTransformConstraint = function (constraintName) {
  5503. if (constraintName == null)
  5504. throw new Error("constraintName cannot be null.");
  5505. var transformConstraints = this.transformConstraints;
  5506. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  5507. var constraint = transformConstraints[i];
  5508. if (constraint.name == constraintName)
  5509. return constraint;
  5510. }
  5511. return null;
  5512. };
  5513. SkeletonData.prototype.findPathConstraint = function (constraintName) {
  5514. if (constraintName == null)
  5515. throw new Error("constraintName cannot be null.");
  5516. var pathConstraints = this.pathConstraints;
  5517. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  5518. var constraint = pathConstraints[i];
  5519. if (constraint.name == constraintName)
  5520. return constraint;
  5521. }
  5522. return null;
  5523. };
  5524. SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) {
  5525. if (pathConstraintName == null)
  5526. throw new Error("pathConstraintName cannot be null.");
  5527. var pathConstraints = this.pathConstraints;
  5528. for (var i = 0, n = pathConstraints.length; i < n; i++)
  5529. if (pathConstraints[i].name == pathConstraintName)
  5530. return i;
  5531. return -1;
  5532. };
  5533. return SkeletonData;
  5534. }());
  5535. spine.SkeletonData = SkeletonData;
  5536. })(spine || (spine = {}));
  5537. var spine;
  5538. (function (spine) {
  5539. var SkeletonJson = (function () {
  5540. function SkeletonJson(attachmentLoader) {
  5541. this.scale = 1;
  5542. this.linkedMeshes = new Array();
  5543. this.attachmentLoader = attachmentLoader;
  5544. }
  5545. SkeletonJson.prototype.readSkeletonData = function (json) {
  5546. var scale = this.scale;
  5547. var skeletonData = new spine.SkeletonData();
  5548. var root = typeof (json) === "string" ? JSON.parse(json) : json;
  5549. var skeletonMap = root.skeleton;
  5550. if (skeletonMap != null) {
  5551. skeletonData.hash = skeletonMap.hash;
  5552. skeletonData.version = skeletonMap.spine;
  5553. if ("3.8.75" == skeletonData.version)
  5554. throw new Error("Unsupported skeleton data, please export with a newer version of Spine.");
  5555. skeletonData.x = skeletonMap.x;
  5556. skeletonData.y = skeletonMap.y;
  5557. skeletonData.width = skeletonMap.width;
  5558. skeletonData.height = skeletonMap.height;
  5559. skeletonData.fps = skeletonMap.fps;
  5560. skeletonData.imagesPath = skeletonMap.images;
  5561. }
  5562. if (root.bones) {
  5563. for (var i = 0; i < root.bones.length; i++) {
  5564. var boneMap = root.bones[i];
  5565. var parent_5 = null;
  5566. var parentName = this.getValue(boneMap, "parent", null);
  5567. if (parentName != null) {
  5568. parent_5 = skeletonData.findBone(parentName);
  5569. if (parent_5 == null)
  5570. throw new Error("Parent bone not found: " + parentName);
  5571. }
  5572. var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_5);
  5573. data.length = this.getValue(boneMap, "length", 0) * scale;
  5574. data.x = this.getValue(boneMap, "x", 0) * scale;
  5575. data.y = this.getValue(boneMap, "y", 0) * scale;
  5576. data.rotation = this.getValue(boneMap, "rotation", 0);
  5577. data.scaleX = this.getValue(boneMap, "scaleX", 1);
  5578. data.scaleY = this.getValue(boneMap, "scaleY", 1);
  5579. data.shearX = this.getValue(boneMap, "shearX", 0);
  5580. data.shearY = this.getValue(boneMap, "shearY", 0);
  5581. data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal"));
  5582. data.skinRequired = this.getValue(boneMap, "skin", false);
  5583. skeletonData.bones.push(data);
  5584. }
  5585. }
  5586. if (root.slots) {
  5587. for (var i = 0; i < root.slots.length; i++) {
  5588. var slotMap = root.slots[i];
  5589. var slotName = slotMap.name;
  5590. var boneName = slotMap.bone;
  5591. var boneData = skeletonData.findBone(boneName);
  5592. if (boneData == null)
  5593. throw new Error("Slot bone not found: " + boneName);
  5594. var data = new spine.SlotData(skeletonData.slots.length, slotName, boneData);
  5595. var color = this.getValue(slotMap, "color", null);
  5596. if (color != null)
  5597. data.color.setFromString(color);
  5598. var dark = this.getValue(slotMap, "dark", null);
  5599. if (dark != null) {
  5600. data.darkColor = new spine.Color(1, 1, 1, 1);
  5601. data.darkColor.setFromString(dark);
  5602. }
  5603. data.attachmentName = this.getValue(slotMap, "attachment", null);
  5604. data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal"));
  5605. skeletonData.slots.push(data);
  5606. }
  5607. }
  5608. if (root.ik) {
  5609. for (var i = 0; i < root.ik.length; i++) {
  5610. var constraintMap = root.ik[i];
  5611. var data = new spine.IkConstraintData(constraintMap.name);
  5612. data.order = this.getValue(constraintMap, "order", 0);
  5613. data.skinRequired = this.getValue(constraintMap, "skin", false);
  5614. for (var j = 0; j < constraintMap.bones.length; j++) {
  5615. var boneName = constraintMap.bones[j];
  5616. var bone = skeletonData.findBone(boneName);
  5617. if (bone == null)
  5618. throw new Error("IK bone not found: " + boneName);
  5619. data.bones.push(bone);
  5620. }
  5621. var targetName = constraintMap.target;
  5622. data.target = skeletonData.findBone(targetName);
  5623. if (data.target == null)
  5624. throw new Error("IK target bone not found: " + targetName);
  5625. data.mix = this.getValue(constraintMap, "mix", 1);
  5626. data.softness = this.getValue(constraintMap, "softness", 0) * scale;
  5627. data.bendDirection = this.getValue(constraintMap, "bendPositive", true) ? 1 : -1;
  5628. data.compress = this.getValue(constraintMap, "compress", false);
  5629. data.stretch = this.getValue(constraintMap, "stretch", false);
  5630. data.uniform = this.getValue(constraintMap, "uniform", false);
  5631. skeletonData.ikConstraints.push(data);
  5632. }
  5633. }
  5634. if (root.transform) {
  5635. for (var i = 0; i < root.transform.length; i++) {
  5636. var constraintMap = root.transform[i];
  5637. var data = new spine.TransformConstraintData(constraintMap.name);
  5638. data.order = this.getValue(constraintMap, "order", 0);
  5639. data.skinRequired = this.getValue(constraintMap, "skin", false);
  5640. for (var j = 0; j < constraintMap.bones.length; j++) {
  5641. var boneName = constraintMap.bones[j];
  5642. var bone = skeletonData.findBone(boneName);
  5643. if (bone == null)
  5644. throw new Error("Transform constraint bone not found: " + boneName);
  5645. data.bones.push(bone);
  5646. }
  5647. var targetName = constraintMap.target;
  5648. data.target = skeletonData.findBone(targetName);
  5649. if (data.target == null)
  5650. throw new Error("Transform constraint target bone not found: " + targetName);
  5651. data.local = this.getValue(constraintMap, "local", false);
  5652. data.relative = this.getValue(constraintMap, "relative", false);
  5653. data.offsetRotation = this.getValue(constraintMap, "rotation", 0);
  5654. data.offsetX = this.getValue(constraintMap, "x", 0) * scale;
  5655. data.offsetY = this.getValue(constraintMap, "y", 0) * scale;
  5656. data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0);
  5657. data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0);
  5658. data.offsetShearY = this.getValue(constraintMap, "shearY", 0);
  5659. data.rotateMix = this.getValue(constraintMap, "rotateMix", 1);
  5660. data.translateMix = this.getValue(constraintMap, "translateMix", 1);
  5661. data.scaleMix = this.getValue(constraintMap, "scaleMix", 1);
  5662. data.shearMix = this.getValue(constraintMap, "shearMix", 1);
  5663. skeletonData.transformConstraints.push(data);
  5664. }
  5665. }
  5666. if (root.path) {
  5667. for (var i = 0; i < root.path.length; i++) {
  5668. var constraintMap = root.path[i];
  5669. var data = new spine.PathConstraintData(constraintMap.name);
  5670. data.order = this.getValue(constraintMap, "order", 0);
  5671. data.skinRequired = this.getValue(constraintMap, "skin", false);
  5672. for (var j = 0; j < constraintMap.bones.length; j++) {
  5673. var boneName = constraintMap.bones[j];
  5674. var bone = skeletonData.findBone(boneName);
  5675. if (bone == null)
  5676. throw new Error("Transform constraint bone not found: " + boneName);
  5677. data.bones.push(bone);
  5678. }
  5679. var targetName = constraintMap.target;
  5680. data.target = skeletonData.findSlot(targetName);
  5681. if (data.target == null)
  5682. throw new Error("Path target slot not found: " + targetName);
  5683. data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent"));
  5684. data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length"));
  5685. data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent"));
  5686. data.offsetRotation = this.getValue(constraintMap, "rotation", 0);
  5687. data.position = this.getValue(constraintMap, "position", 0);
  5688. if (data.positionMode == spine.PositionMode.Fixed)
  5689. data.position *= scale;
  5690. data.spacing = this.getValue(constraintMap, "spacing", 0);
  5691. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  5692. data.spacing *= scale;
  5693. data.rotateMix = this.getValue(constraintMap, "rotateMix", 1);
  5694. data.translateMix = this.getValue(constraintMap, "translateMix", 1);
  5695. skeletonData.pathConstraints.push(data);
  5696. }
  5697. }
  5698. if (root.skins) {
  5699. for (var i = 0; i < root.skins.length; i++) {
  5700. var skinMap = root.skins[i];
  5701. var skin = new spine.Skin(skinMap.name);
  5702. if (skinMap.bones) {
  5703. for (var ii = 0; ii < skinMap.bones.length; ii++) {
  5704. var bone = skeletonData.findBone(skinMap.bones[ii]);
  5705. if (bone == null)
  5706. throw new Error("Skin bone not found: " + skinMap.bones[i]);
  5707. skin.bones.push(bone);
  5708. }
  5709. }
  5710. if (skinMap.ik) {
  5711. for (var ii = 0; ii < skinMap.ik.length; ii++) {
  5712. var constraint = skeletonData.findIkConstraint(skinMap.ik[ii]);
  5713. if (constraint == null)
  5714. throw new Error("Skin IK constraint not found: " + skinMap.ik[i]);
  5715. skin.constraints.push(constraint);
  5716. }
  5717. }
  5718. if (skinMap.transform) {
  5719. for (var ii = 0; ii < skinMap.transform.length; ii++) {
  5720. var constraint = skeletonData.findTransformConstraint(skinMap.transform[ii]);
  5721. if (constraint == null)
  5722. throw new Error("Skin transform constraint not found: " + skinMap.transform[i]);
  5723. skin.constraints.push(constraint);
  5724. }
  5725. }
  5726. if (skinMap.path) {
  5727. for (var ii = 0; ii < skinMap.path.length; ii++) {
  5728. var constraint = skeletonData.findPathConstraint(skinMap.path[ii]);
  5729. if (constraint == null)
  5730. throw new Error("Skin path constraint not found: " + skinMap.path[i]);
  5731. skin.constraints.push(constraint);
  5732. }
  5733. }
  5734. for (var slotName in skinMap.attachments) {
  5735. var slot = skeletonData.findSlot(slotName);
  5736. if (slot == null)
  5737. throw new Error("Slot not found: " + slotName);
  5738. var slotMap = skinMap.attachments[slotName];
  5739. for (var entryName in slotMap) {
  5740. var attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData);
  5741. if (attachment != null)
  5742. skin.setAttachment(slot.index, entryName, attachment);
  5743. }
  5744. }
  5745. skeletonData.skins.push(skin);
  5746. if (skin.name == "default")
  5747. skeletonData.defaultSkin = skin;
  5748. }
  5749. }
  5750. for (var i = 0, n = this.linkedMeshes.length; i < n; i++) {
  5751. var linkedMesh = this.linkedMeshes[i];
  5752. var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
  5753. if (skin == null)
  5754. throw new Error("Skin not found: " + linkedMesh.skin);
  5755. var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
  5756. if (parent_6 == null)
  5757. throw new Error("Parent mesh not found: " + linkedMesh.parent);
  5758. linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh;
  5759. linkedMesh.mesh.setParentMesh(parent_6);
  5760. linkedMesh.mesh.updateUVs();
  5761. }
  5762. this.linkedMeshes.length = 0;
  5763. if (root.events) {
  5764. for (var eventName in root.events) {
  5765. var eventMap = root.events[eventName];
  5766. var data = new spine.EventData(eventName);
  5767. data.intValue = this.getValue(eventMap, "int", 0);
  5768. data.floatValue = this.getValue(eventMap, "float", 0);
  5769. data.stringValue = this.getValue(eventMap, "string", "");
  5770. data.audioPath = this.getValue(eventMap, "audio", null);
  5771. if (data.audioPath != null) {
  5772. data.volume = this.getValue(eventMap, "volume", 1);
  5773. data.balance = this.getValue(eventMap, "balance", 0);
  5774. }
  5775. skeletonData.events.push(data);
  5776. }
  5777. }
  5778. if (root.animations) {
  5779. for (var animationName in root.animations) {
  5780. var animationMap = root.animations[animationName];
  5781. this.readAnimation(animationMap, animationName, skeletonData);
  5782. }
  5783. }
  5784. return skeletonData;
  5785. };
  5786. SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) {
  5787. var scale = this.scale;
  5788. name = this.getValue(map, "name", name);
  5789. var type = this.getValue(map, "type", "region");
  5790. switch (type) {
  5791. case "region": {
  5792. var path = this.getValue(map, "path", name);
  5793. var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
  5794. if (region == null)
  5795. return null;
  5796. region.path = path;
  5797. region.x = this.getValue(map, "x", 0) * scale;
  5798. region.y = this.getValue(map, "y", 0) * scale;
  5799. region.scaleX = this.getValue(map, "scaleX", 1);
  5800. region.scaleY = this.getValue(map, "scaleY", 1);
  5801. region.rotation = this.getValue(map, "rotation", 0);
  5802. region.width = map.width * scale;
  5803. region.height = map.height * scale;
  5804. var color = this.getValue(map, "color", null);
  5805. if (color != null)
  5806. region.color.setFromString(color);
  5807. region.updateOffset();
  5808. return region;
  5809. }
  5810. case "boundingbox": {
  5811. var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
  5812. if (box == null)
  5813. return null;
  5814. this.readVertices(map, box, map.vertexCount << 1);
  5815. var color = this.getValue(map, "color", null);
  5816. if (color != null)
  5817. box.color.setFromString(color);
  5818. return box;
  5819. }
  5820. case "mesh":
  5821. case "linkedmesh": {
  5822. var path = this.getValue(map, "path", name);
  5823. var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
  5824. if (mesh == null)
  5825. return null;
  5826. mesh.path = path;
  5827. var color = this.getValue(map, "color", null);
  5828. if (color != null)
  5829. mesh.color.setFromString(color);
  5830. mesh.width = this.getValue(map, "width", 0) * scale;
  5831. mesh.height = this.getValue(map, "height", 0) * scale;
  5832. var parent_7 = this.getValue(map, "parent", null);
  5833. if (parent_7 != null) {
  5834. this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_7, this.getValue(map, "deform", true)));
  5835. return mesh;
  5836. }
  5837. var uvs = map.uvs;
  5838. this.readVertices(map, mesh, uvs.length);
  5839. mesh.triangles = map.triangles;
  5840. mesh.regionUVs = uvs;
  5841. mesh.updateUVs();
  5842. mesh.edges = this.getValue(map, "edges", null);
  5843. mesh.hullLength = this.getValue(map, "hull", 0) * 2;
  5844. return mesh;
  5845. }
  5846. case "path": {
  5847. var path = this.attachmentLoader.newPathAttachment(skin, name);
  5848. if (path == null)
  5849. return null;
  5850. path.closed = this.getValue(map, "closed", false);
  5851. path.constantSpeed = this.getValue(map, "constantSpeed", true);
  5852. var vertexCount = map.vertexCount;
  5853. this.readVertices(map, path, vertexCount << 1);
  5854. var lengths = spine.Utils.newArray(vertexCount / 3, 0);
  5855. for (var i = 0; i < map.lengths.length; i++)
  5856. lengths[i] = map.lengths[i] * scale;
  5857. path.lengths = lengths;
  5858. var color = this.getValue(map, "color", null);
  5859. if (color != null)
  5860. path.color.setFromString(color);
  5861. return path;
  5862. }
  5863. case "point": {
  5864. var point = this.attachmentLoader.newPointAttachment(skin, name);
  5865. if (point == null)
  5866. return null;
  5867. point.x = this.getValue(map, "x", 0) * scale;
  5868. point.y = this.getValue(map, "y", 0) * scale;
  5869. point.rotation = this.getValue(map, "rotation", 0);
  5870. var color = this.getValue(map, "color", null);
  5871. if (color != null)
  5872. point.color.setFromString(color);
  5873. return point;
  5874. }
  5875. case "clipping": {
  5876. var clip = this.attachmentLoader.newClippingAttachment(skin, name);
  5877. if (clip == null)
  5878. return null;
  5879. var end = this.getValue(map, "end", null);
  5880. if (end != null) {
  5881. var slot = skeletonData.findSlot(end);
  5882. if (slot == null)
  5883. throw new Error("Clipping end slot not found: " + end);
  5884. clip.endSlot = slot;
  5885. }
  5886. var vertexCount = map.vertexCount;
  5887. this.readVertices(map, clip, vertexCount << 1);
  5888. var color = this.getValue(map, "color", null);
  5889. if (color != null)
  5890. clip.color.setFromString(color);
  5891. return clip;
  5892. }
  5893. }
  5894. return null;
  5895. };
  5896. SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) {
  5897. var scale = this.scale;
  5898. attachment.worldVerticesLength = verticesLength;
  5899. var vertices = map.vertices;
  5900. if (verticesLength == vertices.length) {
  5901. var scaledVertices = spine.Utils.toFloatArray(vertices);
  5902. if (scale != 1) {
  5903. for (var i = 0, n = vertices.length; i < n; i++)
  5904. scaledVertices[i] *= scale;
  5905. }
  5906. attachment.vertices = scaledVertices;
  5907. return;
  5908. }
  5909. var weights = new Array();
  5910. var bones = new Array();
  5911. for (var i = 0, n = vertices.length; i < n;) {
  5912. var boneCount = vertices[i++];
  5913. bones.push(boneCount);
  5914. for (var nn = i + boneCount * 4; i < nn; i += 4) {
  5915. bones.push(vertices[i]);
  5916. weights.push(vertices[i + 1] * scale);
  5917. weights.push(vertices[i + 2] * scale);
  5918. weights.push(vertices[i + 3]);
  5919. }
  5920. }
  5921. attachment.bones = bones;
  5922. attachment.vertices = spine.Utils.toFloatArray(weights);
  5923. };
  5924. SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) {
  5925. var scale = this.scale;
  5926. var timelines = new Array();
  5927. var duration = 0;
  5928. if (map.slots) {
  5929. for (var slotName in map.slots) {
  5930. var slotMap = map.slots[slotName];
  5931. var slotIndex = skeletonData.findSlotIndex(slotName);
  5932. if (slotIndex == -1)
  5933. throw new Error("Slot not found: " + slotName);
  5934. for (var timelineName in slotMap) {
  5935. var timelineMap = slotMap[timelineName];
  5936. if (timelineName == "attachment") {
  5937. var timeline = new spine.AttachmentTimeline(timelineMap.length);
  5938. timeline.slotIndex = slotIndex;
  5939. var frameIndex = 0;
  5940. for (var i = 0; i < timelineMap.length; i++) {
  5941. var valueMap = timelineMap[i];
  5942. timeline.setFrame(frameIndex++, this.getValue(valueMap, "time", 0), valueMap.name);
  5943. }
  5944. timelines.push(timeline);
  5945. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  5946. }
  5947. else if (timelineName == "color") {
  5948. var timeline = new spine.ColorTimeline(timelineMap.length);
  5949. timeline.slotIndex = slotIndex;
  5950. var frameIndex = 0;
  5951. for (var i = 0; i < timelineMap.length; i++) {
  5952. var valueMap = timelineMap[i];
  5953. var color = new spine.Color();
  5954. color.setFromString(valueMap.color);
  5955. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), color.r, color.g, color.b, color.a);
  5956. this.readCurve(valueMap, timeline, frameIndex);
  5957. frameIndex++;
  5958. }
  5959. timelines.push(timeline);
  5960. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.ColorTimeline.ENTRIES]);
  5961. }
  5962. else if (timelineName == "twoColor") {
  5963. var timeline = new spine.TwoColorTimeline(timelineMap.length);
  5964. timeline.slotIndex = slotIndex;
  5965. var frameIndex = 0;
  5966. for (var i = 0; i < timelineMap.length; i++) {
  5967. var valueMap = timelineMap[i];
  5968. var light = new spine.Color();
  5969. var dark = new spine.Color();
  5970. light.setFromString(valueMap.light);
  5971. dark.setFromString(valueMap.dark);
  5972. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b);
  5973. this.readCurve(valueMap, timeline, frameIndex);
  5974. frameIndex++;
  5975. }
  5976. timelines.push(timeline);
  5977. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TwoColorTimeline.ENTRIES]);
  5978. }
  5979. else
  5980. throw new Error("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")");
  5981. }
  5982. }
  5983. }
  5984. if (map.bones) {
  5985. for (var boneName in map.bones) {
  5986. var boneMap = map.bones[boneName];
  5987. var boneIndex = skeletonData.findBoneIndex(boneName);
  5988. if (boneIndex == -1)
  5989. throw new Error("Bone not found: " + boneName);
  5990. for (var timelineName in boneMap) {
  5991. var timelineMap = boneMap[timelineName];
  5992. if (timelineName === "rotate") {
  5993. var timeline = new spine.RotateTimeline(timelineMap.length);
  5994. timeline.boneIndex = boneIndex;
  5995. var frameIndex = 0;
  5996. for (var i = 0; i < timelineMap.length; i++) {
  5997. var valueMap = timelineMap[i];
  5998. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "angle", 0));
  5999. this.readCurve(valueMap, timeline, frameIndex);
  6000. frameIndex++;
  6001. }
  6002. timelines.push(timeline);
  6003. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.RotateTimeline.ENTRIES]);
  6004. }
  6005. else if (timelineName === "translate" || timelineName === "scale" || timelineName === "shear") {
  6006. var timeline = null;
  6007. var timelineScale = 1, defaultValue = 0;
  6008. if (timelineName === "scale") {
  6009. timeline = new spine.ScaleTimeline(timelineMap.length);
  6010. defaultValue = 1;
  6011. }
  6012. else if (timelineName === "shear")
  6013. timeline = new spine.ShearTimeline(timelineMap.length);
  6014. else {
  6015. timeline = new spine.TranslateTimeline(timelineMap.length);
  6016. timelineScale = scale;
  6017. }
  6018. timeline.boneIndex = boneIndex;
  6019. var frameIndex = 0;
  6020. for (var i = 0; i < timelineMap.length; i++) {
  6021. var valueMap = timelineMap[i];
  6022. var x = this.getValue(valueMap, "x", defaultValue), y = this.getValue(valueMap, "y", defaultValue);
  6023. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), x * timelineScale, y * timelineScale);
  6024. this.readCurve(valueMap, timeline, frameIndex);
  6025. frameIndex++;
  6026. }
  6027. timelines.push(timeline);
  6028. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TranslateTimeline.ENTRIES]);
  6029. }
  6030. else
  6031. throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
  6032. }
  6033. }
  6034. }
  6035. if (map.ik) {
  6036. for (var constraintName in map.ik) {
  6037. var constraintMap = map.ik[constraintName];
  6038. var constraint = skeletonData.findIkConstraint(constraintName);
  6039. var timeline = new spine.IkConstraintTimeline(constraintMap.length);
  6040. timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint);
  6041. var frameIndex = 0;
  6042. for (var i = 0; i < constraintMap.length; i++) {
  6043. var valueMap = constraintMap[i];
  6044. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "softness", 0) * scale, this.getValue(valueMap, "bendPositive", true) ? 1 : -1, this.getValue(valueMap, "compress", false), this.getValue(valueMap, "stretch", false));
  6045. this.readCurve(valueMap, timeline, frameIndex);
  6046. frameIndex++;
  6047. }
  6048. timelines.push(timeline);
  6049. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.IkConstraintTimeline.ENTRIES]);
  6050. }
  6051. }
  6052. if (map.transform) {
  6053. for (var constraintName in map.transform) {
  6054. var constraintMap = map.transform[constraintName];
  6055. var constraint = skeletonData.findTransformConstraint(constraintName);
  6056. var timeline = new spine.TransformConstraintTimeline(constraintMap.length);
  6057. timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint);
  6058. var frameIndex = 0;
  6059. for (var i = 0; i < constraintMap.length; i++) {
  6060. var valueMap = constraintMap[i];
  6061. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1));
  6062. this.readCurve(valueMap, timeline, frameIndex);
  6063. frameIndex++;
  6064. }
  6065. timelines.push(timeline);
  6066. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TransformConstraintTimeline.ENTRIES]);
  6067. }
  6068. }
  6069. if (map.path) {
  6070. for (var constraintName in map.path) {
  6071. var constraintMap = map.path[constraintName];
  6072. var index = skeletonData.findPathConstraintIndex(constraintName);
  6073. if (index == -1)
  6074. throw new Error("Path constraint not found: " + constraintName);
  6075. var data = skeletonData.pathConstraints[index];
  6076. for (var timelineName in constraintMap) {
  6077. var timelineMap = constraintMap[timelineName];
  6078. if (timelineName === "position" || timelineName === "spacing") {
  6079. var timeline = null;
  6080. var timelineScale = 1;
  6081. if (timelineName === "spacing") {
  6082. timeline = new spine.PathConstraintSpacingTimeline(timelineMap.length);
  6083. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  6084. timelineScale = scale;
  6085. }
  6086. else {
  6087. timeline = new spine.PathConstraintPositionTimeline(timelineMap.length);
  6088. if (data.positionMode == spine.PositionMode.Fixed)
  6089. timelineScale = scale;
  6090. }
  6091. timeline.pathConstraintIndex = index;
  6092. var frameIndex = 0;
  6093. for (var i = 0; i < timelineMap.length; i++) {
  6094. var valueMap = timelineMap[i];
  6095. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, timelineName, 0) * timelineScale);
  6096. this.readCurve(valueMap, timeline, frameIndex);
  6097. frameIndex++;
  6098. }
  6099. timelines.push(timeline);
  6100. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
  6101. }
  6102. else if (timelineName === "mix") {
  6103. var timeline = new spine.PathConstraintMixTimeline(timelineMap.length);
  6104. timeline.pathConstraintIndex = index;
  6105. var frameIndex = 0;
  6106. for (var i = 0; i < timelineMap.length; i++) {
  6107. var valueMap = timelineMap[i];
  6108. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1));
  6109. this.readCurve(valueMap, timeline, frameIndex);
  6110. frameIndex++;
  6111. }
  6112. timelines.push(timeline);
  6113. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
  6114. }
  6115. }
  6116. }
  6117. }
  6118. if (map.deform) {
  6119. for (var deformName in map.deform) {
  6120. var deformMap = map.deform[deformName];
  6121. var skin = skeletonData.findSkin(deformName);
  6122. if (skin == null)
  6123. throw new Error("Skin not found: " + deformName);
  6124. for (var slotName in deformMap) {
  6125. var slotMap = deformMap[slotName];
  6126. var slotIndex = skeletonData.findSlotIndex(slotName);
  6127. if (slotIndex == -1)
  6128. throw new Error("Slot not found: " + slotMap.name);
  6129. for (var timelineName in slotMap) {
  6130. var timelineMap = slotMap[timelineName];
  6131. var attachment = skin.getAttachment(slotIndex, timelineName);
  6132. if (attachment == null)
  6133. throw new Error("Deform attachment not found: " + timelineMap.name);
  6134. var weighted = attachment.bones != null;
  6135. var vertices = attachment.vertices;
  6136. var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
  6137. var timeline = new spine.DeformTimeline(timelineMap.length);
  6138. timeline.slotIndex = slotIndex;
  6139. timeline.attachment = attachment;
  6140. var frameIndex = 0;
  6141. for (var j = 0; j < timelineMap.length; j++) {
  6142. var valueMap = timelineMap[j];
  6143. var deform = void 0;
  6144. var verticesValue = this.getValue(valueMap, "vertices", null);
  6145. if (verticesValue == null)
  6146. deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
  6147. else {
  6148. deform = spine.Utils.newFloatArray(deformLength);
  6149. var start = this.getValue(valueMap, "offset", 0);
  6150. spine.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length);
  6151. if (scale != 1) {
  6152. for (var i = start, n = i + verticesValue.length; i < n; i++)
  6153. deform[i] *= scale;
  6154. }
  6155. if (!weighted) {
  6156. for (var i = 0; i < deformLength; i++)
  6157. deform[i] += vertices[i];
  6158. }
  6159. }
  6160. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), deform);
  6161. this.readCurve(valueMap, timeline, frameIndex);
  6162. frameIndex++;
  6163. }
  6164. timelines.push(timeline);
  6165. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  6166. }
  6167. }
  6168. }
  6169. }
  6170. var drawOrderNode = map.drawOrder;
  6171. if (drawOrderNode == null)
  6172. drawOrderNode = map.draworder;
  6173. if (drawOrderNode != null) {
  6174. var timeline = new spine.DrawOrderTimeline(drawOrderNode.length);
  6175. var slotCount = skeletonData.slots.length;
  6176. var frameIndex = 0;
  6177. for (var j = 0; j < drawOrderNode.length; j++) {
  6178. var drawOrderMap = drawOrderNode[j];
  6179. var drawOrder = null;
  6180. var offsets = this.getValue(drawOrderMap, "offsets", null);
  6181. if (offsets != null) {
  6182. drawOrder = spine.Utils.newArray(slotCount, -1);
  6183. var unchanged = spine.Utils.newArray(slotCount - offsets.length, 0);
  6184. var originalIndex = 0, unchangedIndex = 0;
  6185. for (var i = 0; i < offsets.length; i++) {
  6186. var offsetMap = offsets[i];
  6187. var slotIndex = skeletonData.findSlotIndex(offsetMap.slot);
  6188. if (slotIndex == -1)
  6189. throw new Error("Slot not found: " + offsetMap.slot);
  6190. while (originalIndex != slotIndex)
  6191. unchanged[unchangedIndex++] = originalIndex++;
  6192. drawOrder[originalIndex + offsetMap.offset] = originalIndex++;
  6193. }
  6194. while (originalIndex < slotCount)
  6195. unchanged[unchangedIndex++] = originalIndex++;
  6196. for (var i = slotCount - 1; i >= 0; i--)
  6197. if (drawOrder[i] == -1)
  6198. drawOrder[i] = unchanged[--unchangedIndex];
  6199. }
  6200. timeline.setFrame(frameIndex++, this.getValue(drawOrderMap, "time", 0), drawOrder);
  6201. }
  6202. timelines.push(timeline);
  6203. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  6204. }
  6205. if (map.events) {
  6206. var timeline = new spine.EventTimeline(map.events.length);
  6207. var frameIndex = 0;
  6208. for (var i = 0; i < map.events.length; i++) {
  6209. var eventMap = map.events[i];
  6210. var eventData = skeletonData.findEvent(eventMap.name);
  6211. if (eventData == null)
  6212. throw new Error("Event not found: " + eventMap.name);
  6213. var event_6 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
  6214. event_6.intValue = this.getValue(eventMap, "int", eventData.intValue);
  6215. event_6.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
  6216. event_6.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
  6217. if (event_6.data.audioPath != null) {
  6218. event_6.volume = this.getValue(eventMap, "volume", 1);
  6219. event_6.balance = this.getValue(eventMap, "balance", 0);
  6220. }
  6221. timeline.setFrame(frameIndex++, event_6);
  6222. }
  6223. timelines.push(timeline);
  6224. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  6225. }
  6226. if (isNaN(duration)) {
  6227. throw new Error("Error while parsing animation, duration is NaN");
  6228. }
  6229. skeletonData.animations.push(new spine.Animation(name, timelines, duration));
  6230. };
  6231. SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) {
  6232. if (!map.hasOwnProperty("curve"))
  6233. return;
  6234. if (map.curve == "stepped")
  6235. timeline.setStepped(frameIndex);
  6236. else {
  6237. var curve = map.curve;
  6238. timeline.setCurve(frameIndex, curve, this.getValue(map, "c2", 0), this.getValue(map, "c3", 1), this.getValue(map, "c4", 1));
  6239. }
  6240. };
  6241. SkeletonJson.prototype.getValue = function (map, prop, defaultValue) {
  6242. return map[prop] !== undefined ? map[prop] : defaultValue;
  6243. };
  6244. SkeletonJson.blendModeFromString = function (str) {
  6245. str = str.toLowerCase();
  6246. if (str == "normal")
  6247. return spine.BlendMode.Normal;
  6248. if (str == "additive")
  6249. return spine.BlendMode.Additive;
  6250. if (str == "multiply")
  6251. return spine.BlendMode.Multiply;
  6252. if (str == "screen")
  6253. return spine.BlendMode.Screen;
  6254. throw new Error("Unknown blend mode: " + str);
  6255. };
  6256. SkeletonJson.positionModeFromString = function (str) {
  6257. str = str.toLowerCase();
  6258. if (str == "fixed")
  6259. return spine.PositionMode.Fixed;
  6260. if (str == "percent")
  6261. return spine.PositionMode.Percent;
  6262. throw new Error("Unknown position mode: " + str);
  6263. };
  6264. SkeletonJson.spacingModeFromString = function (str) {
  6265. str = str.toLowerCase();
  6266. if (str == "length")
  6267. return spine.SpacingMode.Length;
  6268. if (str == "fixed")
  6269. return spine.SpacingMode.Fixed;
  6270. if (str == "percent")
  6271. return spine.SpacingMode.Percent;
  6272. throw new Error("Unknown position mode: " + str);
  6273. };
  6274. SkeletonJson.rotateModeFromString = function (str) {
  6275. str = str.toLowerCase();
  6276. if (str == "tangent")
  6277. return spine.RotateMode.Tangent;
  6278. if (str == "chain")
  6279. return spine.RotateMode.Chain;
  6280. if (str == "chainscale")
  6281. return spine.RotateMode.ChainScale;
  6282. throw new Error("Unknown rotate mode: " + str);
  6283. };
  6284. SkeletonJson.transformModeFromString = function (str) {
  6285. str = str.toLowerCase();
  6286. if (str == "normal")
  6287. return spine.TransformMode.Normal;
  6288. if (str == "onlytranslation")
  6289. return spine.TransformMode.OnlyTranslation;
  6290. if (str == "norotationorreflection")
  6291. return spine.TransformMode.NoRotationOrReflection;
  6292. if (str == "noscale")
  6293. return spine.TransformMode.NoScale;
  6294. if (str == "noscaleorreflection")
  6295. return spine.TransformMode.NoScaleOrReflection;
  6296. throw new Error("Unknown transform mode: " + str);
  6297. };
  6298. return SkeletonJson;
  6299. }());
  6300. spine.SkeletonJson = SkeletonJson;
  6301. var LinkedMesh = (function () {
  6302. function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
  6303. this.mesh = mesh;
  6304. this.skin = skin;
  6305. this.slotIndex = slotIndex;
  6306. this.parent = parent;
  6307. this.inheritDeform = inheritDeform;
  6308. }
  6309. return LinkedMesh;
  6310. }());
  6311. })(spine || (spine = {}));
  6312. var spine;
  6313. (function (spine) {
  6314. var SkinEntry = (function () {
  6315. function SkinEntry(slotIndex, name, attachment) {
  6316. this.slotIndex = slotIndex;
  6317. this.name = name;
  6318. this.attachment = attachment;
  6319. }
  6320. return SkinEntry;
  6321. }());
  6322. spine.SkinEntry = SkinEntry;
  6323. var Skin = (function () {
  6324. function Skin(name) {
  6325. this.attachments = new Array();
  6326. this.bones = Array();
  6327. this.constraints = new Array();
  6328. if (name == null)
  6329. throw new Error("name cannot be null.");
  6330. this.name = name;
  6331. }
  6332. Skin.prototype.setAttachment = function (slotIndex, name, attachment) {
  6333. if (attachment == null)
  6334. throw new Error("attachment cannot be null.");
  6335. var attachments = this.attachments;
  6336. if (slotIndex >= attachments.length)
  6337. attachments.length = slotIndex + 1;
  6338. if (!attachments[slotIndex])
  6339. attachments[slotIndex] = {};
  6340. attachments[slotIndex][name] = attachment;
  6341. };
  6342. Skin.prototype.addSkin = function (skin) {
  6343. for (var i = 0; i < skin.bones.length; i++) {
  6344. var bone = skin.bones[i];
  6345. var contained = false;
  6346. for (var j = 0; j < this.bones.length; j++) {
  6347. if (this.bones[j] == bone) {
  6348. contained = true;
  6349. break;
  6350. }
  6351. }
  6352. if (!contained)
  6353. this.bones.push(bone);
  6354. }
  6355. for (var i = 0; i < skin.constraints.length; i++) {
  6356. var constraint = skin.constraints[i];
  6357. var contained = false;
  6358. for (var j = 0; j < this.constraints.length; j++) {
  6359. if (this.constraints[j] == constraint) {
  6360. contained = true;
  6361. break;
  6362. }
  6363. }
  6364. if (!contained)
  6365. this.constraints.push(constraint);
  6366. }
  6367. var attachments = skin.getAttachments();
  6368. for (var i = 0; i < attachments.length; i++) {
  6369. var attachment = attachments[i];
  6370. this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
  6371. }
  6372. };
  6373. Skin.prototype.copySkin = function (skin) {
  6374. for (var i = 0; i < skin.bones.length; i++) {
  6375. var bone = skin.bones[i];
  6376. var contained = false;
  6377. for (var j = 0; j < this.bones.length; j++) {
  6378. if (this.bones[j] == bone) {
  6379. contained = true;
  6380. break;
  6381. }
  6382. }
  6383. if (!contained)
  6384. this.bones.push(bone);
  6385. }
  6386. for (var i = 0; i < skin.constraints.length; i++) {
  6387. var constraint = skin.constraints[i];
  6388. var contained = false;
  6389. for (var j = 0; j < this.constraints.length; j++) {
  6390. if (this.constraints[j] == constraint) {
  6391. contained = true;
  6392. break;
  6393. }
  6394. }
  6395. if (!contained)
  6396. this.constraints.push(constraint);
  6397. }
  6398. var attachments = skin.getAttachments();
  6399. for (var i = 0; i < attachments.length; i++) {
  6400. var attachment = attachments[i];
  6401. if (attachment.attachment == null)
  6402. continue;
  6403. if (attachment.attachment instanceof spine.MeshAttachment) {
  6404. attachment.attachment = attachment.attachment.newLinkedMesh();
  6405. this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
  6406. }
  6407. else {
  6408. attachment.attachment = attachment.attachment.copy();
  6409. this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
  6410. }
  6411. }
  6412. };
  6413. Skin.prototype.getAttachment = function (slotIndex, name) {
  6414. var dictionary = this.attachments[slotIndex];
  6415. return dictionary ? dictionary[name] : null;
  6416. };
  6417. Skin.prototype.removeAttachment = function (slotIndex, name) {
  6418. var dictionary = this.attachments[slotIndex];
  6419. if (dictionary)
  6420. dictionary[name] = null;
  6421. };
  6422. Skin.prototype.getAttachments = function () {
  6423. var entries = new Array();
  6424. for (var i = 0; i < this.attachments.length; i++) {
  6425. var slotAttachments = this.attachments[i];
  6426. if (slotAttachments) {
  6427. for (var name_4 in slotAttachments) {
  6428. var attachment = slotAttachments[name_4];
  6429. if (attachment)
  6430. entries.push(new SkinEntry(i, name_4, attachment));
  6431. }
  6432. }
  6433. }
  6434. return entries;
  6435. };
  6436. Skin.prototype.getAttachmentsForSlot = function (slotIndex, attachments) {
  6437. var slotAttachments = this.attachments[slotIndex];
  6438. if (slotAttachments) {
  6439. for (var name_5 in slotAttachments) {
  6440. var attachment = slotAttachments[name_5];
  6441. if (attachment)
  6442. attachments.push(new SkinEntry(slotIndex, name_5, attachment));
  6443. }
  6444. }
  6445. };
  6446. Skin.prototype.clear = function () {
  6447. this.attachments.length = 0;
  6448. this.bones.length = 0;
  6449. this.constraints.length = 0;
  6450. };
  6451. Skin.prototype.attachAll = function (skeleton, oldSkin) {
  6452. var slotIndex = 0;
  6453. for (var i = 0; i < skeleton.slots.length; i++) {
  6454. var slot = skeleton.slots[i];
  6455. var slotAttachment = slot.getAttachment();
  6456. if (slotAttachment && slotIndex < oldSkin.attachments.length) {
  6457. var dictionary = oldSkin.attachments[slotIndex];
  6458. for (var key in dictionary) {
  6459. var skinAttachment = dictionary[key];
  6460. if (slotAttachment == skinAttachment) {
  6461. var attachment = this.getAttachment(slotIndex, key);
  6462. if (attachment != null)
  6463. slot.setAttachment(attachment);
  6464. break;
  6465. }
  6466. }
  6467. }
  6468. slotIndex++;
  6469. }
  6470. };
  6471. return Skin;
  6472. }());
  6473. spine.Skin = Skin;
  6474. })(spine || (spine = {}));
  6475. var spine;
  6476. (function (spine) {
  6477. var Slot = (function () {
  6478. function Slot(data, bone) {
  6479. this.deform = new Array();
  6480. if (data == null)
  6481. throw new Error("data cannot be null.");
  6482. if (bone == null)
  6483. throw new Error("bone cannot be null.");
  6484. this.data = data;
  6485. this.bone = bone;
  6486. this.color = new spine.Color();
  6487. this.darkColor = data.darkColor == null ? null : new spine.Color();
  6488. this.setToSetupPose();
  6489. }
  6490. Slot.prototype.getSkeleton = function () {
  6491. return this.bone.skeleton;
  6492. };
  6493. Slot.prototype.getAttachment = function () {
  6494. return this.attachment;
  6495. };
  6496. Slot.prototype.setAttachment = function (attachment) {
  6497. if (this.attachment == attachment)
  6498. return;
  6499. this.attachment = attachment;
  6500. this.attachmentTime = this.bone.skeleton.time;
  6501. this.deform.length = 0;
  6502. };
  6503. Slot.prototype.setAttachmentTime = function (time) {
  6504. this.attachmentTime = this.bone.skeleton.time - time;
  6505. };
  6506. Slot.prototype.getAttachmentTime = function () {
  6507. return this.bone.skeleton.time - this.attachmentTime;
  6508. };
  6509. Slot.prototype.setToSetupPose = function () {
  6510. this.color.setFromColor(this.data.color);
  6511. if (this.darkColor != null)
  6512. this.darkColor.setFromColor(this.data.darkColor);
  6513. if (this.data.attachmentName == null)
  6514. this.attachment = null;
  6515. else {
  6516. this.attachment = null;
  6517. this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName));
  6518. }
  6519. };
  6520. return Slot;
  6521. }());
  6522. spine.Slot = Slot;
  6523. })(spine || (spine = {}));
  6524. var spine;
  6525. (function (spine) {
  6526. var SlotData = (function () {
  6527. function SlotData(index, name, boneData) {
  6528. this.color = new spine.Color(1, 1, 1, 1);
  6529. if (index < 0)
  6530. throw new Error("index must be >= 0.");
  6531. if (name == null)
  6532. throw new Error("name cannot be null.");
  6533. if (boneData == null)
  6534. throw new Error("boneData cannot be null.");
  6535. this.index = index;
  6536. this.name = name;
  6537. this.boneData = boneData;
  6538. }
  6539. return SlotData;
  6540. }());
  6541. spine.SlotData = SlotData;
  6542. })(spine || (spine = {}));
  6543. var spine;
  6544. (function (spine) {
  6545. var Texture = (function () {
  6546. function Texture(image) {
  6547. this._image = image;
  6548. }
  6549. Texture.prototype.getImage = function () {
  6550. return this._image;
  6551. };
  6552. Texture.filterFromString = function (text) {
  6553. switch (text.toLowerCase()) {
  6554. case "nearest": return TextureFilter.Nearest;
  6555. case "linear": return TextureFilter.Linear;
  6556. case "mipmap": return TextureFilter.MipMap;
  6557. case "mipmapnearestnearest": return TextureFilter.MipMapNearestNearest;
  6558. case "mipmaplinearnearest": return TextureFilter.MipMapLinearNearest;
  6559. case "mipmapnearestlinear": return TextureFilter.MipMapNearestLinear;
  6560. case "mipmaplinearlinear": return TextureFilter.MipMapLinearLinear;
  6561. default: throw new Error("Unknown texture filter " + text);
  6562. }
  6563. };
  6564. Texture.wrapFromString = function (text) {
  6565. switch (text.toLowerCase()) {
  6566. case "mirroredtepeat": return TextureWrap.MirroredRepeat;
  6567. case "clamptoedge": return TextureWrap.ClampToEdge;
  6568. case "repeat": return TextureWrap.Repeat;
  6569. default: throw new Error("Unknown texture wrap " + text);
  6570. }
  6571. };
  6572. return Texture;
  6573. }());
  6574. spine.Texture = Texture;
  6575. var TextureFilter;
  6576. (function (TextureFilter) {
  6577. TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest";
  6578. TextureFilter[TextureFilter["Linear"] = 9729] = "Linear";
  6579. TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap";
  6580. TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest";
  6581. TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest";
  6582. TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear";
  6583. TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear";
  6584. })(TextureFilter = spine.TextureFilter || (spine.TextureFilter = {}));
  6585. var TextureWrap;
  6586. (function (TextureWrap) {
  6587. TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat";
  6588. TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge";
  6589. TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat";
  6590. })(TextureWrap = spine.TextureWrap || (spine.TextureWrap = {}));
  6591. var TextureRegion = (function () {
  6592. function TextureRegion() {
  6593. this.u = 0;
  6594. this.v = 0;
  6595. this.u2 = 0;
  6596. this.v2 = 0;
  6597. this.width = 0;
  6598. this.height = 0;
  6599. this.rotate = false;
  6600. this.offsetX = 0;
  6601. this.offsetY = 0;
  6602. this.originalWidth = 0;
  6603. this.originalHeight = 0;
  6604. }
  6605. return TextureRegion;
  6606. }());
  6607. spine.TextureRegion = TextureRegion;
  6608. var FakeTexture = (function (_super) {
  6609. __extends(FakeTexture, _super);
  6610. function FakeTexture() {
  6611. return _super !== null && _super.apply(this, arguments) || this;
  6612. }
  6613. FakeTexture.prototype.setFilters = function (minFilter, magFilter) { };
  6614. FakeTexture.prototype.setWraps = function (uWrap, vWrap) { };
  6615. FakeTexture.prototype.dispose = function () { };
  6616. return FakeTexture;
  6617. }(Texture));
  6618. spine.FakeTexture = FakeTexture;
  6619. })(spine || (spine = {}));
  6620. var spine;
  6621. (function (spine) {
  6622. var TextureAtlas = (function () {
  6623. function TextureAtlas(atlasText, textureLoader) {
  6624. this.pages = new Array();
  6625. this.regions = new Array();
  6626. this.load(atlasText, textureLoader);
  6627. }
  6628. TextureAtlas.prototype.load = function (atlasText, textureLoader) {
  6629. if (textureLoader == null)
  6630. throw new Error("textureLoader cannot be null.");
  6631. var reader = new TextureAtlasReader(atlasText);
  6632. var tuple = new Array(4);
  6633. var page = null;
  6634. while (true) {
  6635. var line = reader.readLine();
  6636. if (line == null)
  6637. break;
  6638. line = line.trim();
  6639. if (line.length == 0)
  6640. page = null;
  6641. else if (!page) {
  6642. page = new TextureAtlasPage();
  6643. page.name = line;
  6644. if (reader.readTuple(tuple) == 2) {
  6645. page.width = parseInt(tuple[0]);
  6646. page.height = parseInt(tuple[1]);
  6647. reader.readTuple(tuple);
  6648. }
  6649. reader.readTuple(tuple);
  6650. page.minFilter = spine.Texture.filterFromString(tuple[0]);
  6651. page.magFilter = spine.Texture.filterFromString(tuple[1]);
  6652. var direction = reader.readValue();
  6653. page.uWrap = spine.TextureWrap.ClampToEdge;
  6654. page.vWrap = spine.TextureWrap.ClampToEdge;
  6655. if (direction == "x")
  6656. page.uWrap = spine.TextureWrap.Repeat;
  6657. else if (direction == "y")
  6658. page.vWrap = spine.TextureWrap.Repeat;
  6659. else if (direction == "xy")
  6660. page.uWrap = page.vWrap = spine.TextureWrap.Repeat;
  6661. page.texture = textureLoader(line);
  6662. page.texture.setFilters(page.minFilter, page.magFilter);
  6663. page.texture.setWraps(page.uWrap, page.vWrap);
  6664. page.width = page.texture.getImage().width;
  6665. page.height = page.texture.getImage().height;
  6666. this.pages.push(page);
  6667. }
  6668. else {
  6669. var region = new TextureAtlasRegion();
  6670. region.name = line;
  6671. region.page = page;
  6672. var rotateValue = reader.readValue();
  6673. if (rotateValue.toLocaleLowerCase() == "true") {
  6674. region.degrees = 90;
  6675. }
  6676. else if (rotateValue.toLocaleLowerCase() == "false") {
  6677. region.degrees = 0;
  6678. }
  6679. else {
  6680. region.degrees = parseFloat(rotateValue);
  6681. }
  6682. region.rotate = region.degrees == 90;
  6683. reader.readTuple(tuple);
  6684. var x = parseInt(tuple[0]);
  6685. var y = parseInt(tuple[1]);
  6686. reader.readTuple(tuple);
  6687. var width = parseInt(tuple[0]);
  6688. var height = parseInt(tuple[1]);
  6689. region.u = x / page.width;
  6690. region.v = y / page.height;
  6691. if (region.rotate) {
  6692. region.u2 = (x + height) / page.width;
  6693. region.v2 = (y + width) / page.height;
  6694. }
  6695. else {
  6696. region.u2 = (x + width) / page.width;
  6697. region.v2 = (y + height) / page.height;
  6698. }
  6699. region.x = x;
  6700. region.y = y;
  6701. region.width = Math.abs(width);
  6702. region.height = Math.abs(height);
  6703. if (reader.readTuple(tuple) == 4) {
  6704. if (reader.readTuple(tuple) == 4) {
  6705. reader.readTuple(tuple);
  6706. }
  6707. }
  6708. region.originalWidth = parseInt(tuple[0]);
  6709. region.originalHeight = parseInt(tuple[1]);
  6710. reader.readTuple(tuple);
  6711. region.offsetX = parseInt(tuple[0]);
  6712. region.offsetY = parseInt(tuple[1]);
  6713. region.index = parseInt(reader.readValue());
  6714. region.texture = page.texture;
  6715. this.regions.push(region);
  6716. }
  6717. }
  6718. };
  6719. TextureAtlas.prototype.findRegion = function (name) {
  6720. for (var i = 0; i < this.regions.length; i++) {
  6721. if (this.regions[i].name == name) {
  6722. return this.regions[i];
  6723. }
  6724. }
  6725. return null;
  6726. };
  6727. TextureAtlas.prototype.dispose = function () {
  6728. for (var i = 0; i < this.pages.length; i++) {
  6729. this.pages[i].texture.dispose();
  6730. }
  6731. };
  6732. return TextureAtlas;
  6733. }());
  6734. spine.TextureAtlas = TextureAtlas;
  6735. var TextureAtlasReader = (function () {
  6736. function TextureAtlasReader(text) {
  6737. this.index = 0;
  6738. this.lines = text.split(/\r\n|\r|\n/);
  6739. }
  6740. TextureAtlasReader.prototype.readLine = function () {
  6741. if (this.index >= this.lines.length)
  6742. return null;
  6743. return this.lines[this.index++];
  6744. };
  6745. TextureAtlasReader.prototype.readValue = function () {
  6746. var line = this.readLine();
  6747. var colon = line.indexOf(":");
  6748. if (colon == -1)
  6749. throw new Error("Invalid line: " + line);
  6750. return line.substring(colon + 1).trim();
  6751. };
  6752. TextureAtlasReader.prototype.readTuple = function (tuple) {
  6753. var line = this.readLine();
  6754. var colon = line.indexOf(":");
  6755. if (colon == -1)
  6756. throw new Error("Invalid line: " + line);
  6757. var i = 0, lastMatch = colon + 1;
  6758. for (; i < 3; i++) {
  6759. var comma = line.indexOf(",", lastMatch);
  6760. if (comma == -1)
  6761. break;
  6762. tuple[i] = line.substr(lastMatch, comma - lastMatch).trim();
  6763. lastMatch = comma + 1;
  6764. }
  6765. tuple[i] = line.substring(lastMatch).trim();
  6766. return i + 1;
  6767. };
  6768. return TextureAtlasReader;
  6769. }());
  6770. var TextureAtlasPage = (function () {
  6771. function TextureAtlasPage() {
  6772. }
  6773. return TextureAtlasPage;
  6774. }());
  6775. spine.TextureAtlasPage = TextureAtlasPage;
  6776. var TextureAtlasRegion = (function (_super) {
  6777. __extends(TextureAtlasRegion, _super);
  6778. function TextureAtlasRegion() {
  6779. return _super !== null && _super.apply(this, arguments) || this;
  6780. }
  6781. return TextureAtlasRegion;
  6782. }(spine.TextureRegion));
  6783. spine.TextureAtlasRegion = TextureAtlasRegion;
  6784. })(spine || (spine = {}));
  6785. var spine;
  6786. (function (spine) {
  6787. var TransformConstraint = (function () {
  6788. function TransformConstraint(data, skeleton) {
  6789. this.rotateMix = 0;
  6790. this.translateMix = 0;
  6791. this.scaleMix = 0;
  6792. this.shearMix = 0;
  6793. this.temp = new spine.Vector2();
  6794. this.active = false;
  6795. if (data == null)
  6796. throw new Error("data cannot be null.");
  6797. if (skeleton == null)
  6798. throw new Error("skeleton cannot be null.");
  6799. this.data = data;
  6800. this.rotateMix = data.rotateMix;
  6801. this.translateMix = data.translateMix;
  6802. this.scaleMix = data.scaleMix;
  6803. this.shearMix = data.shearMix;
  6804. this.bones = new Array();
  6805. for (var i = 0; i < data.bones.length; i++)
  6806. this.bones.push(skeleton.findBone(data.bones[i].name));
  6807. this.target = skeleton.findBone(data.target.name);
  6808. }
  6809. TransformConstraint.prototype.isActive = function () {
  6810. return this.active;
  6811. };
  6812. TransformConstraint.prototype.apply = function () {
  6813. this.update();
  6814. };
  6815. TransformConstraint.prototype.update = function () {
  6816. if (this.data.local) {
  6817. if (this.data.relative)
  6818. this.applyRelativeLocal();
  6819. else
  6820. this.applyAbsoluteLocal();
  6821. }
  6822. else {
  6823. if (this.data.relative)
  6824. this.applyRelativeWorld();
  6825. else
  6826. this.applyAbsoluteWorld();
  6827. }
  6828. };
  6829. TransformConstraint.prototype.applyAbsoluteWorld = function () {
  6830. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  6831. var target = this.target;
  6832. var ta = target.a, tb = target.b, tc = target.c, td = target.d;
  6833. var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  6834. var offsetRotation = this.data.offsetRotation * degRadReflect;
  6835. var offsetShearY = this.data.offsetShearY * degRadReflect;
  6836. var bones = this.bones;
  6837. for (var i = 0, n = bones.length; i < n; i++) {
  6838. var bone = bones[i];
  6839. var modified = false;
  6840. if (rotateMix != 0) {
  6841. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  6842. var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
  6843. if (r > spine.MathUtils.PI)
  6844. r -= spine.MathUtils.PI2;
  6845. else if (r < -spine.MathUtils.PI)
  6846. r += spine.MathUtils.PI2;
  6847. r *= rotateMix;
  6848. var cos = Math.cos(r), sin = Math.sin(r);
  6849. bone.a = cos * a - sin * c;
  6850. bone.b = cos * b - sin * d;
  6851. bone.c = sin * a + cos * c;
  6852. bone.d = sin * b + cos * d;
  6853. modified = true;
  6854. }
  6855. if (translateMix != 0) {
  6856. var temp = this.temp;
  6857. target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));
  6858. bone.worldX += (temp.x - bone.worldX) * translateMix;
  6859. bone.worldY += (temp.y - bone.worldY) * translateMix;
  6860. modified = true;
  6861. }
  6862. if (scaleMix > 0) {
  6863. var s = Math.sqrt(bone.a * bone.a + bone.c * bone.c);
  6864. var ts = Math.sqrt(ta * ta + tc * tc);
  6865. if (s > 0.00001)
  6866. s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s;
  6867. bone.a *= s;
  6868. bone.c *= s;
  6869. s = Math.sqrt(bone.b * bone.b + bone.d * bone.d);
  6870. ts = Math.sqrt(tb * tb + td * td);
  6871. if (s > 0.00001)
  6872. s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s;
  6873. bone.b *= s;
  6874. bone.d *= s;
  6875. modified = true;
  6876. }
  6877. if (shearMix > 0) {
  6878. var b = bone.b, d = bone.d;
  6879. var by = Math.atan2(d, b);
  6880. var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(bone.c, bone.a));
  6881. if (r > spine.MathUtils.PI)
  6882. r -= spine.MathUtils.PI2;
  6883. else if (r < -spine.MathUtils.PI)
  6884. r += spine.MathUtils.PI2;
  6885. r = by + (r + offsetShearY) * shearMix;
  6886. var s = Math.sqrt(b * b + d * d);
  6887. bone.b = Math.cos(r) * s;
  6888. bone.d = Math.sin(r) * s;
  6889. modified = true;
  6890. }
  6891. if (modified)
  6892. bone.appliedValid = false;
  6893. }
  6894. };
  6895. TransformConstraint.prototype.applyRelativeWorld = function () {
  6896. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  6897. var target = this.target;
  6898. var ta = target.a, tb = target.b, tc = target.c, td = target.d;
  6899. var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  6900. var offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect;
  6901. var bones = this.bones;
  6902. for (var i = 0, n = bones.length; i < n; i++) {
  6903. var bone = bones[i];
  6904. var modified = false;
  6905. if (rotateMix != 0) {
  6906. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  6907. var r = Math.atan2(tc, ta) + offsetRotation;
  6908. if (r > spine.MathUtils.PI)
  6909. r -= spine.MathUtils.PI2;
  6910. else if (r < -spine.MathUtils.PI)
  6911. r += spine.MathUtils.PI2;
  6912. r *= rotateMix;
  6913. var cos = Math.cos(r), sin = Math.sin(r);
  6914. bone.a = cos * a - sin * c;
  6915. bone.b = cos * b - sin * d;
  6916. bone.c = sin * a + cos * c;
  6917. bone.d = sin * b + cos * d;
  6918. modified = true;
  6919. }
  6920. if (translateMix != 0) {
  6921. var temp = this.temp;
  6922. target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));
  6923. bone.worldX += temp.x * translateMix;
  6924. bone.worldY += temp.y * translateMix;
  6925. modified = true;
  6926. }
  6927. if (scaleMix > 0) {
  6928. var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1;
  6929. bone.a *= s;
  6930. bone.c *= s;
  6931. s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1;
  6932. bone.b *= s;
  6933. bone.d *= s;
  6934. modified = true;
  6935. }
  6936. if (shearMix > 0) {
  6937. var r = Math.atan2(td, tb) - Math.atan2(tc, ta);
  6938. if (r > spine.MathUtils.PI)
  6939. r -= spine.MathUtils.PI2;
  6940. else if (r < -spine.MathUtils.PI)
  6941. r += spine.MathUtils.PI2;
  6942. var b = bone.b, d = bone.d;
  6943. r = Math.atan2(d, b) + (r - spine.MathUtils.PI / 2 + offsetShearY) * shearMix;
  6944. var s = Math.sqrt(b * b + d * d);
  6945. bone.b = Math.cos(r) * s;
  6946. bone.d = Math.sin(r) * s;
  6947. modified = true;
  6948. }
  6949. if (modified)
  6950. bone.appliedValid = false;
  6951. }
  6952. };
  6953. TransformConstraint.prototype.applyAbsoluteLocal = function () {
  6954. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  6955. var target = this.target;
  6956. if (!target.appliedValid)
  6957. target.updateAppliedTransform();
  6958. var bones = this.bones;
  6959. for (var i = 0, n = bones.length; i < n; i++) {
  6960. var bone = bones[i];
  6961. if (!bone.appliedValid)
  6962. bone.updateAppliedTransform();
  6963. var rotation = bone.arotation;
  6964. if (rotateMix != 0) {
  6965. var r = target.arotation - rotation + this.data.offsetRotation;
  6966. r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
  6967. rotation += r * rotateMix;
  6968. }
  6969. var x = bone.ax, y = bone.ay;
  6970. if (translateMix != 0) {
  6971. x += (target.ax - x + this.data.offsetX) * translateMix;
  6972. y += (target.ay - y + this.data.offsetY) * translateMix;
  6973. }
  6974. var scaleX = bone.ascaleX, scaleY = bone.ascaleY;
  6975. if (scaleMix != 0) {
  6976. if (scaleX > 0.00001)
  6977. scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX;
  6978. if (scaleY > 0.00001)
  6979. scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY;
  6980. }
  6981. var shearY = bone.ashearY;
  6982. if (shearMix != 0) {
  6983. var r = target.ashearY - shearY + this.data.offsetShearY;
  6984. r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
  6985. bone.shearY += r * shearMix;
  6986. }
  6987. bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
  6988. }
  6989. };
  6990. TransformConstraint.prototype.applyRelativeLocal = function () {
  6991. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  6992. var target = this.target;
  6993. if (!target.appliedValid)
  6994. target.updateAppliedTransform();
  6995. var bones = this.bones;
  6996. for (var i = 0, n = bones.length; i < n; i++) {
  6997. var bone = bones[i];
  6998. if (!bone.appliedValid)
  6999. bone.updateAppliedTransform();
  7000. var rotation = bone.arotation;
  7001. if (rotateMix != 0)
  7002. rotation += (target.arotation + this.data.offsetRotation) * rotateMix;
  7003. var x = bone.ax, y = bone.ay;
  7004. if (translateMix != 0) {
  7005. x += (target.ax + this.data.offsetX) * translateMix;
  7006. y += (target.ay + this.data.offsetY) * translateMix;
  7007. }
  7008. var scaleX = bone.ascaleX, scaleY = bone.ascaleY;
  7009. if (scaleMix != 0) {
  7010. if (scaleX > 0.00001)
  7011. scaleX *= ((target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix) + 1;
  7012. if (scaleY > 0.00001)
  7013. scaleY *= ((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1;
  7014. }
  7015. var shearY = bone.ashearY;
  7016. if (shearMix != 0)
  7017. shearY += (target.ashearY + this.data.offsetShearY) * shearMix;
  7018. bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
  7019. }
  7020. };
  7021. return TransformConstraint;
  7022. }());
  7023. spine.TransformConstraint = TransformConstraint;
  7024. })(spine || (spine = {}));
  7025. var spine;
  7026. (function (spine) {
  7027. var TransformConstraintData = (function (_super) {
  7028. __extends(TransformConstraintData, _super);
  7029. function TransformConstraintData(name) {
  7030. var _this = _super.call(this, name, 0, false) || this;
  7031. _this.bones = new Array();
  7032. _this.rotateMix = 0;
  7033. _this.translateMix = 0;
  7034. _this.scaleMix = 0;
  7035. _this.shearMix = 0;
  7036. _this.offsetRotation = 0;
  7037. _this.offsetX = 0;
  7038. _this.offsetY = 0;
  7039. _this.offsetScaleX = 0;
  7040. _this.offsetScaleY = 0;
  7041. _this.offsetShearY = 0;
  7042. _this.relative = false;
  7043. _this.local = false;
  7044. return _this;
  7045. }
  7046. return TransformConstraintData;
  7047. }(spine.ConstraintData));
  7048. spine.TransformConstraintData = TransformConstraintData;
  7049. })(spine || (spine = {}));
  7050. var spine;
  7051. (function (spine) {
  7052. var Triangulator = (function () {
  7053. function Triangulator() {
  7054. this.convexPolygons = new Array();
  7055. this.convexPolygonsIndices = new Array();
  7056. this.indicesArray = new Array();
  7057. this.isConcaveArray = new Array();
  7058. this.triangles = new Array();
  7059. this.polygonPool = new spine.Pool(function () {
  7060. return new Array();
  7061. });
  7062. this.polygonIndicesPool = new spine.Pool(function () {
  7063. return new Array();
  7064. });
  7065. }
  7066. Triangulator.prototype.triangulate = function (verticesArray) {
  7067. var vertices = verticesArray;
  7068. var vertexCount = verticesArray.length >> 1;
  7069. var indices = this.indicesArray;
  7070. indices.length = 0;
  7071. for (var i = 0; i < vertexCount; i++)
  7072. indices[i] = i;
  7073. var isConcave = this.isConcaveArray;
  7074. isConcave.length = 0;
  7075. for (var i = 0, n = vertexCount; i < n; ++i)
  7076. isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices);
  7077. var triangles = this.triangles;
  7078. triangles.length = 0;
  7079. while (vertexCount > 3) {
  7080. var previous = vertexCount - 1, i = 0, next = 1;
  7081. while (true) {
  7082. outer: if (!isConcave[i]) {
  7083. var p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1;
  7084. var p1x = vertices[p1], p1y = vertices[p1 + 1];
  7085. var p2x = vertices[p2], p2y = vertices[p2 + 1];
  7086. var p3x = vertices[p3], p3y = vertices[p3 + 1];
  7087. for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) {
  7088. if (!isConcave[ii])
  7089. continue;
  7090. var v = indices[ii] << 1;
  7091. var vx = vertices[v], vy = vertices[v + 1];
  7092. if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) {
  7093. if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) {
  7094. if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy))
  7095. break outer;
  7096. }
  7097. }
  7098. }
  7099. break;
  7100. }
  7101. if (next == 0) {
  7102. do {
  7103. if (!isConcave[i])
  7104. break;
  7105. i--;
  7106. } while (i > 0);
  7107. break;
  7108. }
  7109. previous = i;
  7110. i = next;
  7111. next = (next + 1) % vertexCount;
  7112. }
  7113. triangles.push(indices[(vertexCount + i - 1) % vertexCount]);
  7114. triangles.push(indices[i]);
  7115. triangles.push(indices[(i + 1) % vertexCount]);
  7116. indices.splice(i, 1);
  7117. isConcave.splice(i, 1);
  7118. vertexCount--;
  7119. var previousIndex = (vertexCount + i - 1) % vertexCount;
  7120. var nextIndex = i == vertexCount ? 0 : i;
  7121. isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices);
  7122. isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices);
  7123. }
  7124. if (vertexCount == 3) {
  7125. triangles.push(indices[2]);
  7126. triangles.push(indices[0]);
  7127. triangles.push(indices[1]);
  7128. }
  7129. return triangles;
  7130. };
  7131. Triangulator.prototype.decompose = function (verticesArray, triangles) {
  7132. var vertices = verticesArray;
  7133. var convexPolygons = this.convexPolygons;
  7134. this.polygonPool.freeAll(convexPolygons);
  7135. convexPolygons.length = 0;
  7136. var convexPolygonsIndices = this.convexPolygonsIndices;
  7137. this.polygonIndicesPool.freeAll(convexPolygonsIndices);
  7138. convexPolygonsIndices.length = 0;
  7139. var polygonIndices = this.polygonIndicesPool.obtain();
  7140. polygonIndices.length = 0;
  7141. var polygon = this.polygonPool.obtain();
  7142. polygon.length = 0;
  7143. var fanBaseIndex = -1, lastWinding = 0;
  7144. for (var i = 0, n = triangles.length; i < n; i += 3) {
  7145. var t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1;
  7146. var x1 = vertices[t1], y1 = vertices[t1 + 1];
  7147. var x2 = vertices[t2], y2 = vertices[t2 + 1];
  7148. var x3 = vertices[t3], y3 = vertices[t3 + 1];
  7149. var merged = false;
  7150. if (fanBaseIndex == t1) {
  7151. var o = polygon.length - 4;
  7152. var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3);
  7153. var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]);
  7154. if (winding1 == lastWinding && winding2 == lastWinding) {
  7155. polygon.push(x3);
  7156. polygon.push(y3);
  7157. polygonIndices.push(t3);
  7158. merged = true;
  7159. }
  7160. }
  7161. if (!merged) {
  7162. if (polygon.length > 0) {
  7163. convexPolygons.push(polygon);
  7164. convexPolygonsIndices.push(polygonIndices);
  7165. }
  7166. else {
  7167. this.polygonPool.free(polygon);
  7168. this.polygonIndicesPool.free(polygonIndices);
  7169. }
  7170. polygon = this.polygonPool.obtain();
  7171. polygon.length = 0;
  7172. polygon.push(x1);
  7173. polygon.push(y1);
  7174. polygon.push(x2);
  7175. polygon.push(y2);
  7176. polygon.push(x3);
  7177. polygon.push(y3);
  7178. polygonIndices = this.polygonIndicesPool.obtain();
  7179. polygonIndices.length = 0;
  7180. polygonIndices.push(t1);
  7181. polygonIndices.push(t2);
  7182. polygonIndices.push(t3);
  7183. lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3);
  7184. fanBaseIndex = t1;
  7185. }
  7186. }
  7187. if (polygon.length > 0) {
  7188. convexPolygons.push(polygon);
  7189. convexPolygonsIndices.push(polygonIndices);
  7190. }
  7191. for (var i = 0, n = convexPolygons.length; i < n; i++) {
  7192. polygonIndices = convexPolygonsIndices[i];
  7193. if (polygonIndices.length == 0)
  7194. continue;
  7195. var firstIndex = polygonIndices[0];
  7196. var lastIndex = polygonIndices[polygonIndices.length - 1];
  7197. polygon = convexPolygons[i];
  7198. var o = polygon.length - 4;
  7199. var prevPrevX = polygon[o], prevPrevY = polygon[o + 1];
  7200. var prevX = polygon[o + 2], prevY = polygon[o + 3];
  7201. var firstX = polygon[0], firstY = polygon[1];
  7202. var secondX = polygon[2], secondY = polygon[3];
  7203. var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY);
  7204. for (var ii = 0; ii < n; ii++) {
  7205. if (ii == i)
  7206. continue;
  7207. var otherIndices = convexPolygonsIndices[ii];
  7208. if (otherIndices.length != 3)
  7209. continue;
  7210. var otherFirstIndex = otherIndices[0];
  7211. var otherSecondIndex = otherIndices[1];
  7212. var otherLastIndex = otherIndices[2];
  7213. var otherPoly = convexPolygons[ii];
  7214. var x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1];
  7215. if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex)
  7216. continue;
  7217. var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3);
  7218. var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY);
  7219. if (winding1 == winding && winding2 == winding) {
  7220. otherPoly.length = 0;
  7221. otherIndices.length = 0;
  7222. polygon.push(x3);
  7223. polygon.push(y3);
  7224. polygonIndices.push(otherLastIndex);
  7225. prevPrevX = prevX;
  7226. prevPrevY = prevY;
  7227. prevX = x3;
  7228. prevY = y3;
  7229. ii = 0;
  7230. }
  7231. }
  7232. }
  7233. for (var i = convexPolygons.length - 1; i >= 0; i--) {
  7234. polygon = convexPolygons[i];
  7235. if (polygon.length == 0) {
  7236. convexPolygons.splice(i, 1);
  7237. this.polygonPool.free(polygon);
  7238. polygonIndices = convexPolygonsIndices[i];
  7239. convexPolygonsIndices.splice(i, 1);
  7240. this.polygonIndicesPool.free(polygonIndices);
  7241. }
  7242. }
  7243. return convexPolygons;
  7244. };
  7245. Triangulator.isConcave = function (index, vertexCount, vertices, indices) {
  7246. var previous = indices[(vertexCount + index - 1) % vertexCount] << 1;
  7247. var current = indices[index] << 1;
  7248. var next = indices[(index + 1) % vertexCount] << 1;
  7249. return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]);
  7250. };
  7251. Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) {
  7252. return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0;
  7253. };
  7254. Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) {
  7255. var px = p2x - p1x, py = p2y - p1y;
  7256. return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1;
  7257. };
  7258. return Triangulator;
  7259. }());
  7260. spine.Triangulator = Triangulator;
  7261. })(spine || (spine = {}));
  7262. var spine;
  7263. (function (spine) {
  7264. var IntSet = (function () {
  7265. function IntSet() {
  7266. this.array = new Array();
  7267. }
  7268. IntSet.prototype.add = function (value) {
  7269. var contains = this.contains(value);
  7270. this.array[value | 0] = value | 0;
  7271. return !contains;
  7272. };
  7273. IntSet.prototype.contains = function (value) {
  7274. return this.array[value | 0] != undefined;
  7275. };
  7276. IntSet.prototype.remove = function (value) {
  7277. this.array[value | 0] = undefined;
  7278. };
  7279. IntSet.prototype.clear = function () {
  7280. this.array.length = 0;
  7281. };
  7282. return IntSet;
  7283. }());
  7284. spine.IntSet = IntSet;
  7285. var Color = (function () {
  7286. function Color(r, g, b, a) {
  7287. if (r === void 0) { r = 0; }
  7288. if (g === void 0) { g = 0; }
  7289. if (b === void 0) { b = 0; }
  7290. if (a === void 0) { a = 0; }
  7291. this.r = r;
  7292. this.g = g;
  7293. this.b = b;
  7294. this.a = a;
  7295. }
  7296. Color.prototype.set = function (r, g, b, a) {
  7297. this.r = r;
  7298. this.g = g;
  7299. this.b = b;
  7300. this.a = a;
  7301. this.clamp();
  7302. return this;
  7303. };
  7304. Color.prototype.setFromColor = function (c) {
  7305. this.r = c.r;
  7306. this.g = c.g;
  7307. this.b = c.b;
  7308. this.a = c.a;
  7309. return this;
  7310. };
  7311. Color.prototype.setFromString = function (hex) {
  7312. hex = hex.charAt(0) == '#' ? hex.substr(1) : hex;
  7313. this.r = parseInt(hex.substr(0, 2), 16) / 255.0;
  7314. this.g = parseInt(hex.substr(2, 2), 16) / 255.0;
  7315. this.b = parseInt(hex.substr(4, 2), 16) / 255.0;
  7316. this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0;
  7317. return this;
  7318. };
  7319. Color.prototype.add = function (r, g, b, a) {
  7320. this.r += r;
  7321. this.g += g;
  7322. this.b += b;
  7323. this.a += a;
  7324. this.clamp();
  7325. return this;
  7326. };
  7327. Color.prototype.clamp = function () {
  7328. if (this.r < 0)
  7329. this.r = 0;
  7330. else if (this.r > 1)
  7331. this.r = 1;
  7332. if (this.g < 0)
  7333. this.g = 0;
  7334. else if (this.g > 1)
  7335. this.g = 1;
  7336. if (this.b < 0)
  7337. this.b = 0;
  7338. else if (this.b > 1)
  7339. this.b = 1;
  7340. if (this.a < 0)
  7341. this.a = 0;
  7342. else if (this.a > 1)
  7343. this.a = 1;
  7344. return this;
  7345. };
  7346. Color.rgba8888ToColor = function (color, value) {
  7347. color.r = ((value & 0xff000000) >>> 24) / 255;
  7348. color.g = ((value & 0x00ff0000) >>> 16) / 255;
  7349. color.b = ((value & 0x0000ff00) >>> 8) / 255;
  7350. color.a = ((value & 0x000000ff)) / 255;
  7351. };
  7352. Color.rgb888ToColor = function (color, value) {
  7353. color.r = ((value & 0x00ff0000) >>> 16) / 255;
  7354. color.g = ((value & 0x0000ff00) >>> 8) / 255;
  7355. color.b = ((value & 0x000000ff)) / 255;
  7356. };
  7357. Color.WHITE = new Color(1, 1, 1, 1);
  7358. Color.RED = new Color(1, 0, 0, 1);
  7359. Color.GREEN = new Color(0, 1, 0, 1);
  7360. Color.BLUE = new Color(0, 0, 1, 1);
  7361. Color.MAGENTA = new Color(1, 0, 1, 1);
  7362. return Color;
  7363. }());
  7364. spine.Color = Color;
  7365. var MathUtils = (function () {
  7366. function MathUtils() {
  7367. }
  7368. MathUtils.clamp = function (value, min, max) {
  7369. if (value < min)
  7370. return min;
  7371. if (value > max)
  7372. return max;
  7373. return value;
  7374. };
  7375. MathUtils.cosDeg = function (degrees) {
  7376. return Math.cos(degrees * MathUtils.degRad);
  7377. };
  7378. MathUtils.sinDeg = function (degrees) {
  7379. return Math.sin(degrees * MathUtils.degRad);
  7380. };
  7381. MathUtils.signum = function (value) {
  7382. return value > 0 ? 1 : value < 0 ? -1 : 0;
  7383. };
  7384. MathUtils.toInt = function (x) {
  7385. return x > 0 ? Math.floor(x) : Math.ceil(x);
  7386. };
  7387. MathUtils.cbrt = function (x) {
  7388. var y = Math.pow(Math.abs(x), 1 / 3);
  7389. return x < 0 ? -y : y;
  7390. };
  7391. MathUtils.randomTriangular = function (min, max) {
  7392. return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
  7393. };
  7394. MathUtils.randomTriangularWith = function (min, max, mode) {
  7395. var u = Math.random();
  7396. var d = max - min;
  7397. if (u <= (mode - min) / d)
  7398. return min + Math.sqrt(u * d * (mode - min));
  7399. return max - Math.sqrt((1 - u) * d * (max - mode));
  7400. };
  7401. MathUtils.PI = 3.1415927;
  7402. MathUtils.PI2 = MathUtils.PI * 2;
  7403. MathUtils.radiansToDegrees = 180 / MathUtils.PI;
  7404. MathUtils.radDeg = MathUtils.radiansToDegrees;
  7405. MathUtils.degreesToRadians = MathUtils.PI / 180;
  7406. MathUtils.degRad = MathUtils.degreesToRadians;
  7407. return MathUtils;
  7408. }());
  7409. spine.MathUtils = MathUtils;
  7410. var Interpolation = (function () {
  7411. function Interpolation() {
  7412. }
  7413. Interpolation.prototype.apply = function (start, end, a) {
  7414. return start + (end - start) * this.applyInternal(a);
  7415. };
  7416. return Interpolation;
  7417. }());
  7418. spine.Interpolation = Interpolation;
  7419. var Pow = (function (_super) {
  7420. __extends(Pow, _super);
  7421. function Pow(power) {
  7422. var _this = _super.call(this) || this;
  7423. _this.power = 2;
  7424. _this.power = power;
  7425. return _this;
  7426. }
  7427. Pow.prototype.applyInternal = function (a) {
  7428. if (a <= 0.5)
  7429. return Math.pow(a * 2, this.power) / 2;
  7430. return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
  7431. };
  7432. return Pow;
  7433. }(Interpolation));
  7434. spine.Pow = Pow;
  7435. var PowOut = (function (_super) {
  7436. __extends(PowOut, _super);
  7437. function PowOut(power) {
  7438. return _super.call(this, power) || this;
  7439. }
  7440. PowOut.prototype.applyInternal = function (a) {
  7441. return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
  7442. };
  7443. return PowOut;
  7444. }(Pow));
  7445. spine.PowOut = PowOut;
  7446. var Utils = (function () {
  7447. function Utils() {
  7448. }
  7449. Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) {
  7450. for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) {
  7451. dest[j] = source[i];
  7452. }
  7453. };
  7454. Utils.setArraySize = function (array, size, value) {
  7455. if (value === void 0) { value = 0; }
  7456. var oldSize = array.length;
  7457. if (oldSize == size)
  7458. return array;
  7459. array.length = size;
  7460. if (oldSize < size) {
  7461. for (var i = oldSize; i < size; i++)
  7462. array[i] = value;
  7463. }
  7464. return array;
  7465. };
  7466. Utils.ensureArrayCapacity = function (array, size, value) {
  7467. if (value === void 0) { value = 0; }
  7468. if (array.length >= size)
  7469. return array;
  7470. return Utils.setArraySize(array, size, value);
  7471. };
  7472. Utils.newArray = function (size, defaultValue) {
  7473. var array = new Array(size);
  7474. for (var i = 0; i < size; i++)
  7475. array[i] = defaultValue;
  7476. return array;
  7477. };
  7478. Utils.newFloatArray = function (size) {
  7479. if (Utils.SUPPORTS_TYPED_ARRAYS) {
  7480. return new Float32Array(size);
  7481. }
  7482. else {
  7483. var array = new Array(size);
  7484. for (var i = 0; i < array.length; i++)
  7485. array[i] = 0;
  7486. return array;
  7487. }
  7488. };
  7489. Utils.newShortArray = function (size) {
  7490. if (Utils.SUPPORTS_TYPED_ARRAYS) {
  7491. return new Int16Array(size);
  7492. }
  7493. else {
  7494. var array = new Array(size);
  7495. for (var i = 0; i < array.length; i++)
  7496. array[i] = 0;
  7497. return array;
  7498. }
  7499. };
  7500. Utils.toFloatArray = function (array) {
  7501. return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
  7502. };
  7503. Utils.toSinglePrecision = function (value) {
  7504. return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
  7505. };
  7506. Utils.webkit602BugfixHelper = function (alpha, blend) {
  7507. };
  7508. Utils.contains = function (array, element, identity) {
  7509. if (identity === void 0) { identity = true; }
  7510. for (var i = 0; i < array.length; i++) {
  7511. if (array[i] == element)
  7512. return true;
  7513. }
  7514. return false;
  7515. };
  7516. Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";
  7517. return Utils;
  7518. }());
  7519. spine.Utils = Utils;
  7520. var DebugUtils = (function () {
  7521. function DebugUtils() {
  7522. }
  7523. DebugUtils.logBones = function (skeleton) {
  7524. for (var i = 0; i < skeleton.bones.length; i++) {
  7525. var bone = skeleton.bones[i];
  7526. console.log(bone.data.name + ", " + bone.a + ", " + bone.b + ", " + bone.c + ", " + bone.d + ", " + bone.worldX + ", " + bone.worldY);
  7527. }
  7528. };
  7529. return DebugUtils;
  7530. }());
  7531. spine.DebugUtils = DebugUtils;
  7532. var Pool = (function () {
  7533. function Pool(instantiator) {
  7534. this.items = new Array();
  7535. this.instantiator = instantiator;
  7536. }
  7537. Pool.prototype.obtain = function () {
  7538. return this.items.length > 0 ? this.items.pop() : this.instantiator();
  7539. };
  7540. Pool.prototype.free = function (item) {
  7541. if (item.reset)
  7542. item.reset();
  7543. this.items.push(item);
  7544. };
  7545. Pool.prototype.freeAll = function (items) {
  7546. for (var i = 0; i < items.length; i++) {
  7547. this.free(items[i]);
  7548. }
  7549. };
  7550. Pool.prototype.clear = function () {
  7551. this.items.length = 0;
  7552. };
  7553. return Pool;
  7554. }());
  7555. spine.Pool = Pool;
  7556. var Vector2 = (function () {
  7557. function Vector2(x, y) {
  7558. if (x === void 0) { x = 0; }
  7559. if (y === void 0) { y = 0; }
  7560. this.x = x;
  7561. this.y = y;
  7562. }
  7563. Vector2.prototype.set = function (x, y) {
  7564. this.x = x;
  7565. this.y = y;
  7566. return this;
  7567. };
  7568. Vector2.prototype.length = function () {
  7569. var x = this.x;
  7570. var y = this.y;
  7571. return Math.sqrt(x * x + y * y);
  7572. };
  7573. Vector2.prototype.normalize = function () {
  7574. var len = this.length();
  7575. if (len != 0) {
  7576. this.x /= len;
  7577. this.y /= len;
  7578. }
  7579. return this;
  7580. };
  7581. return Vector2;
  7582. }());
  7583. spine.Vector2 = Vector2;
  7584. var TimeKeeper = (function () {
  7585. function TimeKeeper() {
  7586. this.maxDelta = 0.064;
  7587. this.framesPerSecond = 0;
  7588. this.delta = 0;
  7589. this.totalTime = 0;
  7590. this.lastTime = Date.now() / 1000;
  7591. this.frameCount = 0;
  7592. this.frameTime = 0;
  7593. }
  7594. TimeKeeper.prototype.update = function () {
  7595. var now = Date.now() / 1000;
  7596. this.delta = now - this.lastTime;
  7597. this.frameTime += this.delta;
  7598. this.totalTime += this.delta;
  7599. if (this.delta > this.maxDelta)
  7600. this.delta = this.maxDelta;
  7601. this.lastTime = now;
  7602. this.frameCount++;
  7603. if (this.frameTime > 1) {
  7604. this.framesPerSecond = this.frameCount / this.frameTime;
  7605. this.frameTime = 0;
  7606. this.frameCount = 0;
  7607. }
  7608. };
  7609. return TimeKeeper;
  7610. }());
  7611. spine.TimeKeeper = TimeKeeper;
  7612. var WindowedMean = (function () {
  7613. function WindowedMean(windowSize) {
  7614. if (windowSize === void 0) { windowSize = 32; }
  7615. this.addedValues = 0;
  7616. this.lastValue = 0;
  7617. this.mean = 0;
  7618. this.dirty = true;
  7619. this.values = new Array(windowSize);
  7620. }
  7621. WindowedMean.prototype.hasEnoughData = function () {
  7622. return this.addedValues >= this.values.length;
  7623. };
  7624. WindowedMean.prototype.addValue = function (value) {
  7625. if (this.addedValues < this.values.length)
  7626. this.addedValues++;
  7627. this.values[this.lastValue++] = value;
  7628. if (this.lastValue > this.values.length - 1)
  7629. this.lastValue = 0;
  7630. this.dirty = true;
  7631. };
  7632. WindowedMean.prototype.getMean = function () {
  7633. if (this.hasEnoughData()) {
  7634. if (this.dirty) {
  7635. var mean = 0;
  7636. for (var i = 0; i < this.values.length; i++) {
  7637. mean += this.values[i];
  7638. }
  7639. this.mean = mean / this.values.length;
  7640. this.dirty = false;
  7641. }
  7642. return this.mean;
  7643. }
  7644. else {
  7645. return 0;
  7646. }
  7647. };
  7648. return WindowedMean;
  7649. }());
  7650. spine.WindowedMean = WindowedMean;
  7651. })(spine || (spine = {}));
  7652. (function () {
  7653. if (!Math.fround) {
  7654. Math.fround = (function (array) {
  7655. return function (x) {
  7656. return array[0] = x, array[0];
  7657. };
  7658. })(new Float32Array(1));
  7659. }
  7660. })();
  7661. var spine;
  7662. (function (spine) {
  7663. var Attachment = (function () {
  7664. function Attachment(name) {
  7665. if (name == null)
  7666. throw new Error("name cannot be null.");
  7667. this.name = name;
  7668. }
  7669. return Attachment;
  7670. }());
  7671. spine.Attachment = Attachment;
  7672. var VertexAttachment = (function (_super) {
  7673. __extends(VertexAttachment, _super);
  7674. function VertexAttachment(name) {
  7675. var _this = _super.call(this, name) || this;
  7676. _this.id = (VertexAttachment.nextID++ & 65535) << 11;
  7677. _this.worldVerticesLength = 0;
  7678. _this.deformAttachment = _this;
  7679. return _this;
  7680. }
  7681. VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
  7682. count = offset + (count >> 1) * stride;
  7683. var skeleton = slot.bone.skeleton;
  7684. var deformArray = slot.deform;
  7685. var vertices = this.vertices;
  7686. var bones = this.bones;
  7687. if (bones == null) {
  7688. if (deformArray.length > 0)
  7689. vertices = deformArray;
  7690. var bone = slot.bone;
  7691. var x = bone.worldX;
  7692. var y = bone.worldY;
  7693. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  7694. for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) {
  7695. var vx = vertices[v_1], vy = vertices[v_1 + 1];
  7696. worldVertices[w] = vx * a + vy * b + x;
  7697. worldVertices[w + 1] = vx * c + vy * d + y;
  7698. }
  7699. return;
  7700. }
  7701. var v = 0, skip = 0;
  7702. for (var i = 0; i < start; i += 2) {
  7703. var n = bones[v];
  7704. v += n + 1;
  7705. skip += n;
  7706. }
  7707. var skeletonBones = skeleton.bones;
  7708. if (deformArray.length == 0) {
  7709. for (var w = offset, b = skip * 3; w < count; w += stride) {
  7710. var wx = 0, wy = 0;
  7711. var n = bones[v++];
  7712. n += v;
  7713. for (; v < n; v++, b += 3) {
  7714. var bone = skeletonBones[bones[v]];
  7715. var vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2];
  7716. wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
  7717. wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
  7718. }
  7719. worldVertices[w] = wx;
  7720. worldVertices[w + 1] = wy;
  7721. }
  7722. }
  7723. else {
  7724. var deform = deformArray;
  7725. for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) {
  7726. var wx = 0, wy = 0;
  7727. var n = bones[v++];
  7728. n += v;
  7729. for (; v < n; v++, b += 3, f += 2) {
  7730. var bone = skeletonBones[bones[v]];
  7731. var vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2];
  7732. wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
  7733. wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
  7734. }
  7735. worldVertices[w] = wx;
  7736. worldVertices[w + 1] = wy;
  7737. }
  7738. }
  7739. };
  7740. VertexAttachment.prototype.copyTo = function (attachment) {
  7741. if (this.bones != null) {
  7742. attachment.bones = new Array(this.bones.length);
  7743. spine.Utils.arrayCopy(this.bones, 0, attachment.bones, 0, this.bones.length);
  7744. }
  7745. else
  7746. attachment.bones = null;
  7747. if (this.vertices != null) {
  7748. attachment.vertices = spine.Utils.newFloatArray(this.vertices.length);
  7749. spine.Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length);
  7750. }
  7751. else
  7752. attachment.vertices = null;
  7753. attachment.worldVerticesLength = this.worldVerticesLength;
  7754. attachment.deformAttachment = this.deformAttachment;
  7755. };
  7756. VertexAttachment.nextID = 0;
  7757. return VertexAttachment;
  7758. }(Attachment));
  7759. spine.VertexAttachment = VertexAttachment;
  7760. })(spine || (spine = {}));
  7761. var spine;
  7762. (function (spine) {
  7763. var AttachmentType;
  7764. (function (AttachmentType) {
  7765. AttachmentType[AttachmentType["Region"] = 0] = "Region";
  7766. AttachmentType[AttachmentType["BoundingBox"] = 1] = "BoundingBox";
  7767. AttachmentType[AttachmentType["Mesh"] = 2] = "Mesh";
  7768. AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh";
  7769. AttachmentType[AttachmentType["Path"] = 4] = "Path";
  7770. AttachmentType[AttachmentType["Point"] = 5] = "Point";
  7771. AttachmentType[AttachmentType["Clipping"] = 6] = "Clipping";
  7772. })(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {}));
  7773. })(spine || (spine = {}));
  7774. var spine;
  7775. (function (spine) {
  7776. var BoundingBoxAttachment = (function (_super) {
  7777. __extends(BoundingBoxAttachment, _super);
  7778. function BoundingBoxAttachment(name) {
  7779. var _this = _super.call(this, name) || this;
  7780. _this.color = new spine.Color(1, 1, 1, 1);
  7781. return _this;
  7782. }
  7783. BoundingBoxAttachment.prototype.copy = function () {
  7784. var copy = new BoundingBoxAttachment(this.name);
  7785. this.copyTo(copy);
  7786. copy.color.setFromColor(this.color);
  7787. return copy;
  7788. };
  7789. return BoundingBoxAttachment;
  7790. }(spine.VertexAttachment));
  7791. spine.BoundingBoxAttachment = BoundingBoxAttachment;
  7792. })(spine || (spine = {}));
  7793. var spine;
  7794. (function (spine) {
  7795. var ClippingAttachment = (function (_super) {
  7796. __extends(ClippingAttachment, _super);
  7797. function ClippingAttachment(name) {
  7798. var _this = _super.call(this, name) || this;
  7799. _this.color = new spine.Color(0.2275, 0.2275, 0.8078, 1);
  7800. return _this;
  7801. }
  7802. ClippingAttachment.prototype.copy = function () {
  7803. var copy = new ClippingAttachment(this.name);
  7804. this.copyTo(copy);
  7805. copy.endSlot = this.endSlot;
  7806. copy.color.setFromColor(this.color);
  7807. return copy;
  7808. };
  7809. return ClippingAttachment;
  7810. }(spine.VertexAttachment));
  7811. spine.ClippingAttachment = ClippingAttachment;
  7812. })(spine || (spine = {}));
  7813. var spine;
  7814. (function (spine) {
  7815. var MeshAttachment = (function (_super) {
  7816. __extends(MeshAttachment, _super);
  7817. function MeshAttachment(name) {
  7818. var _this = _super.call(this, name) || this;
  7819. _this.color = new spine.Color(1, 1, 1, 1);
  7820. _this.tempColor = new spine.Color(0, 0, 0, 0);
  7821. return _this;
  7822. }
  7823. MeshAttachment.prototype.updateUVs = function () {
  7824. var regionUVs = this.regionUVs;
  7825. if (this.uvs == null || this.uvs.length != regionUVs.length)
  7826. this.uvs = spine.Utils.newFloatArray(regionUVs.length);
  7827. var uvs = this.uvs;
  7828. var n = this.uvs.length;
  7829. var u = this.region.u, v = this.region.v, width = 0, height = 0;
  7830. if (this.region instanceof spine.TextureAtlasRegion) {
  7831. var region = this.region;
  7832. var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
  7833. switch (region.degrees) {
  7834. case 90:
  7835. u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
  7836. v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
  7837. width = region.originalHeight / textureWidth;
  7838. height = region.originalWidth / textureHeight;
  7839. for (var i = 0; i < n; i += 2) {
  7840. uvs[i] = u + regionUVs[i + 1] * width;
  7841. uvs[i + 1] = v + (1 - regionUVs[i]) * height;
  7842. }
  7843. return;
  7844. case 180:
  7845. u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
  7846. v -= region.offsetY / textureHeight;
  7847. width = region.originalWidth / textureWidth;
  7848. height = region.originalHeight / textureHeight;
  7849. for (var i = 0; i < n; i += 2) {
  7850. uvs[i] = u + (1 - regionUVs[i]) * width;
  7851. uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
  7852. }
  7853. return;
  7854. case 270:
  7855. u -= region.offsetY / textureWidth;
  7856. v -= region.offsetX / textureHeight;
  7857. width = region.originalHeight / textureWidth;
  7858. height = region.originalWidth / textureHeight;
  7859. for (var i = 0; i < n; i += 2) {
  7860. uvs[i] = u + (1 - regionUVs[i + 1]) * width;
  7861. uvs[i + 1] = v + regionUVs[i] * height;
  7862. }
  7863. return;
  7864. }
  7865. u -= region.offsetX / textureWidth;
  7866. v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
  7867. width = region.originalWidth / textureWidth;
  7868. height = region.originalHeight / textureHeight;
  7869. }
  7870. else if (this.region == null) {
  7871. u = v = 0;
  7872. width = height = 1;
  7873. }
  7874. else {
  7875. width = this.region.u2 - u;
  7876. height = this.region.v2 - v;
  7877. }
  7878. for (var i = 0; i < n; i += 2) {
  7879. uvs[i] = u + regionUVs[i] * width;
  7880. uvs[i + 1] = v + regionUVs[i + 1] * height;
  7881. }
  7882. };
  7883. MeshAttachment.prototype.getParentMesh = function () {
  7884. return this.parentMesh;
  7885. };
  7886. MeshAttachment.prototype.setParentMesh = function (parentMesh) {
  7887. this.parentMesh = parentMesh;
  7888. if (parentMesh != null) {
  7889. this.bones = parentMesh.bones;
  7890. this.vertices = parentMesh.vertices;
  7891. this.worldVerticesLength = parentMesh.worldVerticesLength;
  7892. this.regionUVs = parentMesh.regionUVs;
  7893. this.triangles = parentMesh.triangles;
  7894. this.hullLength = parentMesh.hullLength;
  7895. this.worldVerticesLength = parentMesh.worldVerticesLength;
  7896. }
  7897. };
  7898. MeshAttachment.prototype.copy = function () {
  7899. if (this.parentMesh != null)
  7900. return this.newLinkedMesh();
  7901. var copy = new MeshAttachment(this.name);
  7902. copy.region = this.region;
  7903. copy.path = this.path;
  7904. copy.color.setFromColor(this.color);
  7905. this.copyTo(copy);
  7906. copy.regionUVs = new Array(this.regionUVs.length);
  7907. spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
  7908. copy.uvs = new Array(this.uvs.length);
  7909. spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
  7910. copy.triangles = new Array(this.triangles.length);
  7911. spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
  7912. copy.hullLength = this.hullLength;
  7913. if (this.edges != null) {
  7914. copy.edges = new Array(this.edges.length);
  7915. spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
  7916. }
  7917. copy.width = this.width;
  7918. copy.height = this.height;
  7919. return copy;
  7920. };
  7921. MeshAttachment.prototype.newLinkedMesh = function () {
  7922. var copy = new MeshAttachment(this.name);
  7923. copy.region = this.region;
  7924. copy.path = this.path;
  7925. copy.color.setFromColor(this.color);
  7926. copy.deformAttachment = this.deformAttachment;
  7927. copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
  7928. copy.updateUVs();
  7929. return copy;
  7930. };
  7931. return MeshAttachment;
  7932. }(spine.VertexAttachment));
  7933. spine.MeshAttachment = MeshAttachment;
  7934. })(spine || (spine = {}));
  7935. var spine;
  7936. (function (spine) {
  7937. var PathAttachment = (function (_super) {
  7938. __extends(PathAttachment, _super);
  7939. function PathAttachment(name) {
  7940. var _this = _super.call(this, name) || this;
  7941. _this.closed = false;
  7942. _this.constantSpeed = false;
  7943. _this.color = new spine.Color(1, 1, 1, 1);
  7944. return _this;
  7945. }
  7946. PathAttachment.prototype.copy = function () {
  7947. var copy = new PathAttachment(this.name);
  7948. this.copyTo(copy);
  7949. copy.lengths = new Array(this.lengths.length);
  7950. spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
  7951. copy.closed = closed;
  7952. copy.constantSpeed = this.constantSpeed;
  7953. copy.color.setFromColor(this.color);
  7954. return copy;
  7955. };
  7956. return PathAttachment;
  7957. }(spine.VertexAttachment));
  7958. spine.PathAttachment = PathAttachment;
  7959. })(spine || (spine = {}));
  7960. var spine;
  7961. (function (spine) {
  7962. var PointAttachment = (function (_super) {
  7963. __extends(PointAttachment, _super);
  7964. function PointAttachment(name) {
  7965. var _this = _super.call(this, name) || this;
  7966. _this.color = new spine.Color(0.38, 0.94, 0, 1);
  7967. return _this;
  7968. }
  7969. PointAttachment.prototype.computeWorldPosition = function (bone, point) {
  7970. point.x = this.x * bone.a + this.y * bone.b + bone.worldX;
  7971. point.y = this.x * bone.c + this.y * bone.d + bone.worldY;
  7972. return point;
  7973. };
  7974. PointAttachment.prototype.computeWorldRotation = function (bone) {
  7975. var cos = spine.MathUtils.cosDeg(this.rotation), sin = spine.MathUtils.sinDeg(this.rotation);
  7976. var x = cos * bone.a + sin * bone.b;
  7977. var y = cos * bone.c + sin * bone.d;
  7978. return Math.atan2(y, x) * spine.MathUtils.radDeg;
  7979. };
  7980. PointAttachment.prototype.copy = function () {
  7981. var copy = new PointAttachment(this.name);
  7982. copy.x = this.x;
  7983. copy.y = this.y;
  7984. copy.rotation = this.rotation;
  7985. copy.color.setFromColor(this.color);
  7986. return copy;
  7987. };
  7988. return PointAttachment;
  7989. }(spine.VertexAttachment));
  7990. spine.PointAttachment = PointAttachment;
  7991. })(spine || (spine = {}));
  7992. var spine;
  7993. (function (spine) {
  7994. var RegionAttachment = (function (_super) {
  7995. __extends(RegionAttachment, _super);
  7996. function RegionAttachment(name) {
  7997. var _this = _super.call(this, name) || this;
  7998. _this.x = 0;
  7999. _this.y = 0;
  8000. _this.scaleX = 1;
  8001. _this.scaleY = 1;
  8002. _this.rotation = 0;
  8003. _this.width = 0;
  8004. _this.height = 0;
  8005. _this.color = new spine.Color(1, 1, 1, 1);
  8006. _this.offset = spine.Utils.newFloatArray(8);
  8007. _this.uvs = spine.Utils.newFloatArray(8);
  8008. _this.tempColor = new spine.Color(1, 1, 1, 1);
  8009. return _this;
  8010. }
  8011. RegionAttachment.prototype.updateOffset = function () {
  8012. var regionScaleX = this.width / this.region.originalWidth * this.scaleX;
  8013. var regionScaleY = this.height / this.region.originalHeight * this.scaleY;
  8014. var localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX;
  8015. var localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY;
  8016. var localX2 = localX + this.region.width * regionScaleX;
  8017. var localY2 = localY + this.region.height * regionScaleY;
  8018. var radians = this.rotation * Math.PI / 180;
  8019. var cos = Math.cos(radians);
  8020. var sin = Math.sin(radians);
  8021. var localXCos = localX * cos + this.x;
  8022. var localXSin = localX * sin;
  8023. var localYCos = localY * cos + this.y;
  8024. var localYSin = localY * sin;
  8025. var localX2Cos = localX2 * cos + this.x;
  8026. var localX2Sin = localX2 * sin;
  8027. var localY2Cos = localY2 * cos + this.y;
  8028. var localY2Sin = localY2 * sin;
  8029. var offset = this.offset;
  8030. offset[RegionAttachment.OX1] = localXCos - localYSin;
  8031. offset[RegionAttachment.OY1] = localYCos + localXSin;
  8032. offset[RegionAttachment.OX2] = localXCos - localY2Sin;
  8033. offset[RegionAttachment.OY2] = localY2Cos + localXSin;
  8034. offset[RegionAttachment.OX3] = localX2Cos - localY2Sin;
  8035. offset[RegionAttachment.OY3] = localY2Cos + localX2Sin;
  8036. offset[RegionAttachment.OX4] = localX2Cos - localYSin;
  8037. offset[RegionAttachment.OY4] = localYCos + localX2Sin;
  8038. };
  8039. RegionAttachment.prototype.setRegion = function (region) {
  8040. this.region = region;
  8041. var uvs = this.uvs;
  8042. if (region.rotate) {
  8043. uvs[2] = region.u;
  8044. uvs[3] = region.v2;
  8045. uvs[4] = region.u;
  8046. uvs[5] = region.v;
  8047. uvs[6] = region.u2;
  8048. uvs[7] = region.v;
  8049. uvs[0] = region.u2;
  8050. uvs[1] = region.v2;
  8051. }
  8052. else {
  8053. uvs[0] = region.u;
  8054. uvs[1] = region.v2;
  8055. uvs[2] = region.u;
  8056. uvs[3] = region.v;
  8057. uvs[4] = region.u2;
  8058. uvs[5] = region.v;
  8059. uvs[6] = region.u2;
  8060. uvs[7] = region.v2;
  8061. }
  8062. };
  8063. RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) {
  8064. var vertexOffset = this.offset;
  8065. var x = bone.worldX, y = bone.worldY;
  8066. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  8067. var offsetX = 0, offsetY = 0;
  8068. offsetX = vertexOffset[RegionAttachment.OX1];
  8069. offsetY = vertexOffset[RegionAttachment.OY1];
  8070. worldVertices[offset] = offsetX * a + offsetY * b + x;
  8071. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  8072. offset += stride;
  8073. offsetX = vertexOffset[RegionAttachment.OX2];
  8074. offsetY = vertexOffset[RegionAttachment.OY2];
  8075. worldVertices[offset] = offsetX * a + offsetY * b + x;
  8076. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  8077. offset += stride;
  8078. offsetX = vertexOffset[RegionAttachment.OX3];
  8079. offsetY = vertexOffset[RegionAttachment.OY3];
  8080. worldVertices[offset] = offsetX * a + offsetY * b + x;
  8081. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  8082. offset += stride;
  8083. offsetX = vertexOffset[RegionAttachment.OX4];
  8084. offsetY = vertexOffset[RegionAttachment.OY4];
  8085. worldVertices[offset] = offsetX * a + offsetY * b + x;
  8086. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  8087. };
  8088. RegionAttachment.prototype.copy = function () {
  8089. var copy = new RegionAttachment(this.name);
  8090. copy.region = this.region;
  8091. copy.rendererObject = this.rendererObject;
  8092. copy.path = this.path;
  8093. copy.x = this.x;
  8094. copy.y = this.y;
  8095. copy.scaleX = this.scaleX;
  8096. copy.scaleY = this.scaleY;
  8097. copy.rotation = this.rotation;
  8098. copy.width = this.width;
  8099. copy.height = this.height;
  8100. spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, 8);
  8101. spine.Utils.arrayCopy(this.offset, 0, copy.offset, 0, 8);
  8102. copy.color.setFromColor(this.color);
  8103. return copy;
  8104. };
  8105. RegionAttachment.OX1 = 0;
  8106. RegionAttachment.OY1 = 1;
  8107. RegionAttachment.OX2 = 2;
  8108. RegionAttachment.OY2 = 3;
  8109. RegionAttachment.OX3 = 4;
  8110. RegionAttachment.OY3 = 5;
  8111. RegionAttachment.OX4 = 6;
  8112. RegionAttachment.OY4 = 7;
  8113. RegionAttachment.X1 = 0;
  8114. RegionAttachment.Y1 = 1;
  8115. RegionAttachment.C1R = 2;
  8116. RegionAttachment.C1G = 3;
  8117. RegionAttachment.C1B = 4;
  8118. RegionAttachment.C1A = 5;
  8119. RegionAttachment.U1 = 6;
  8120. RegionAttachment.V1 = 7;
  8121. RegionAttachment.X2 = 8;
  8122. RegionAttachment.Y2 = 9;
  8123. RegionAttachment.C2R = 10;
  8124. RegionAttachment.C2G = 11;
  8125. RegionAttachment.C2B = 12;
  8126. RegionAttachment.C2A = 13;
  8127. RegionAttachment.U2 = 14;
  8128. RegionAttachment.V2 = 15;
  8129. RegionAttachment.X3 = 16;
  8130. RegionAttachment.Y3 = 17;
  8131. RegionAttachment.C3R = 18;
  8132. RegionAttachment.C3G = 19;
  8133. RegionAttachment.C3B = 20;
  8134. RegionAttachment.C3A = 21;
  8135. RegionAttachment.U3 = 22;
  8136. RegionAttachment.V3 = 23;
  8137. RegionAttachment.X4 = 24;
  8138. RegionAttachment.Y4 = 25;
  8139. RegionAttachment.C4R = 26;
  8140. RegionAttachment.C4G = 27;
  8141. RegionAttachment.C4B = 28;
  8142. RegionAttachment.C4A = 29;
  8143. RegionAttachment.U4 = 30;
  8144. RegionAttachment.V4 = 31;
  8145. return RegionAttachment;
  8146. }(spine.Attachment));
  8147. spine.RegionAttachment = RegionAttachment;
  8148. })(spine || (spine = {}));
  8149. var spine;
  8150. (function (spine) {
  8151. var JitterEffect = (function () {
  8152. function JitterEffect(jitterX, jitterY) {
  8153. this.jitterX = 0;
  8154. this.jitterY = 0;
  8155. this.jitterX = jitterX;
  8156. this.jitterY = jitterY;
  8157. }
  8158. JitterEffect.prototype.begin = function (skeleton) {
  8159. };
  8160. JitterEffect.prototype.transform = function (position, uv, light, dark) {
  8161. position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
  8162. position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
  8163. };
  8164. JitterEffect.prototype.end = function () {
  8165. };
  8166. return JitterEffect;
  8167. }());
  8168. spine.JitterEffect = JitterEffect;
  8169. })(spine || (spine = {}));
  8170. var spine;
  8171. (function (spine) {
  8172. var SwirlEffect = (function () {
  8173. function SwirlEffect(radius) {
  8174. this.centerX = 0;
  8175. this.centerY = 0;
  8176. this.radius = 0;
  8177. this.angle = 0;
  8178. this.worldX = 0;
  8179. this.worldY = 0;
  8180. this.radius = radius;
  8181. }
  8182. SwirlEffect.prototype.begin = function (skeleton) {
  8183. this.worldX = skeleton.x + this.centerX;
  8184. this.worldY = skeleton.y + this.centerY;
  8185. };
  8186. SwirlEffect.prototype.transform = function (position, uv, light, dark) {
  8187. var radAngle = this.angle * spine.MathUtils.degreesToRadians;
  8188. var x = position.x - this.worldX;
  8189. var y = position.y - this.worldY;
  8190. var dist = Math.sqrt(x * x + y * y);
  8191. if (dist < this.radius) {
  8192. var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
  8193. var cos = Math.cos(theta);
  8194. var sin = Math.sin(theta);
  8195. position.x = cos * x - sin * y + this.worldX;
  8196. position.y = sin * x + cos * y + this.worldY;
  8197. }
  8198. };
  8199. SwirlEffect.prototype.end = function () {
  8200. };
  8201. SwirlEffect.interpolation = new spine.PowOut(2);
  8202. return SwirlEffect;
  8203. }());
  8204. spine.SwirlEffect = SwirlEffect;
  8205. })(spine || (spine = {}));
  8206. var spine;
  8207. (function (spine) {
  8208. var canvas;
  8209. (function (canvas) {
  8210. var AssetManager = (function (_super) {
  8211. __extends(AssetManager, _super);
  8212. function AssetManager(pathPrefix) {
  8213. if (pathPrefix === void 0) { pathPrefix = ""; }
  8214. return _super.call(this, function (image) { return new spine.canvas.CanvasTexture(image); }, pathPrefix) || this;
  8215. }
  8216. return AssetManager;
  8217. }(spine.AssetManager));
  8218. canvas.AssetManager = AssetManager;
  8219. })(canvas = spine.canvas || (spine.canvas = {}));
  8220. })(spine || (spine = {}));
  8221. var spine;
  8222. (function (spine) {
  8223. var canvas;
  8224. (function (canvas) {
  8225. var CanvasTexture = (function (_super) {
  8226. __extends(CanvasTexture, _super);
  8227. function CanvasTexture(image) {
  8228. return _super.call(this, image) || this;
  8229. }
  8230. CanvasTexture.prototype.setFilters = function (minFilter, magFilter) { };
  8231. CanvasTexture.prototype.setWraps = function (uWrap, vWrap) { };
  8232. CanvasTexture.prototype.dispose = function () { };
  8233. return CanvasTexture;
  8234. }(spine.Texture));
  8235. canvas.CanvasTexture = CanvasTexture;
  8236. })(canvas = spine.canvas || (spine.canvas = {}));
  8237. })(spine || (spine = {}));
  8238. var spine;
  8239. (function (spine) {
  8240. var canvas;
  8241. (function (canvas) {
  8242. var SkeletonRenderer = (function () {
  8243. function SkeletonRenderer(context) {
  8244. this.triangleRendering = false;
  8245. this.debugRendering = false;
  8246. this.vertices = spine.Utils.newFloatArray(8 * 1024);
  8247. this.tempColor = new spine.Color();
  8248. this.ctx = context;
  8249. }
  8250. SkeletonRenderer.prototype.draw = function (skeleton) {
  8251. if (this.triangleRendering)
  8252. this.drawTriangles(skeleton);
  8253. else
  8254. this.drawImages(skeleton);
  8255. };
  8256. SkeletonRenderer.prototype.drawImages = function (skeleton) {
  8257. var ctx = this.ctx;
  8258. var drawOrder = skeleton.drawOrder;
  8259. if (this.debugRendering)
  8260. ctx.strokeStyle = "green";
  8261. ctx.save();
  8262. for (var i = 0, n = drawOrder.length; i < n; i++) {
  8263. var slot = drawOrder[i];
  8264. if (!slot.bone.active)
  8265. continue;
  8266. var attachment = slot.getAttachment();
  8267. var regionAttachment = null;
  8268. var region = null;
  8269. var image = null;
  8270. if (attachment instanceof spine.RegionAttachment) {
  8271. regionAttachment = attachment;
  8272. region = regionAttachment.region;
  8273. image = region.texture.getImage();
  8274. }
  8275. else
  8276. continue;
  8277. var skeleton_1 = slot.bone.skeleton;
  8278. var skeletonColor = skeleton_1.color;
  8279. var slotColor = slot.color;
  8280. var regionColor = regionAttachment.color;
  8281. var alpha = skeletonColor.a * slotColor.a * regionColor.a;
  8282. var color = this.tempColor;
  8283. color.set(skeletonColor.r * slotColor.r * regionColor.r, skeletonColor.g * slotColor.g * regionColor.g, skeletonColor.b * slotColor.b * regionColor.b, alpha);
  8284. var att = attachment;
  8285. var bone = slot.bone;
  8286. var w = region.width;
  8287. var h = region.height;
  8288. ctx.save();
  8289. ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
  8290. ctx.translate(attachment.offset[0], attachment.offset[1]);
  8291. ctx.rotate(attachment.rotation * Math.PI / 180);
  8292. var atlasScale = att.width / w;
  8293. ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY);
  8294. ctx.translate(w / 2, h / 2);
  8295. if (attachment.region.rotate) {
  8296. var t = w;
  8297. w = h;
  8298. h = t;
  8299. ctx.rotate(-Math.PI / 2);
  8300. }
  8301. ctx.scale(1, -1);
  8302. ctx.translate(-w / 2, -h / 2);
  8303. if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
  8304. ctx.globalAlpha = color.a;
  8305. }
  8306. ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
  8307. if (this.debugRendering)
  8308. ctx.strokeRect(0, 0, w, h);
  8309. ctx.restore();
  8310. }
  8311. ctx.restore();
  8312. };
  8313. SkeletonRenderer.prototype.drawTriangles = function (skeleton) {
  8314. var blendMode = null;
  8315. var vertices = this.vertices;
  8316. var triangles = null;
  8317. var drawOrder = skeleton.drawOrder;
  8318. for (var i = 0, n = drawOrder.length; i < n; i++) {
  8319. var slot = drawOrder[i];
  8320. var attachment = slot.getAttachment();
  8321. var texture = null;
  8322. var region = null;
  8323. if (attachment instanceof spine.RegionAttachment) {
  8324. var regionAttachment = attachment;
  8325. vertices = this.computeRegionVertices(slot, regionAttachment, false);
  8326. triangles = SkeletonRenderer.QUAD_TRIANGLES;
  8327. region = regionAttachment.region;
  8328. texture = region.texture.getImage();
  8329. }
  8330. else if (attachment instanceof spine.MeshAttachment) {
  8331. var mesh = attachment;
  8332. vertices = this.computeMeshVertices(slot, mesh, false);
  8333. triangles = mesh.triangles;
  8334. texture = mesh.region.renderObject.texture.getImage();
  8335. }
  8336. else
  8337. continue;
  8338. if (texture != null) {
  8339. var slotBlendMode = slot.data.blendMode;
  8340. if (slotBlendMode != blendMode) {
  8341. blendMode = slotBlendMode;
  8342. }
  8343. var skeleton_2 = slot.bone.skeleton;
  8344. var skeletonColor = skeleton_2.color;
  8345. var slotColor = slot.color;
  8346. var attachmentColor = attachment.color;
  8347. var alpha = skeletonColor.a * slotColor.a * attachmentColor.a;
  8348. var color = this.tempColor;
  8349. color.set(skeletonColor.r * slotColor.r * attachmentColor.r, skeletonColor.g * slotColor.g * attachmentColor.g, skeletonColor.b * slotColor.b * attachmentColor.b, alpha);
  8350. var ctx = this.ctx;
  8351. if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) {
  8352. ctx.globalAlpha = color.a;
  8353. }
  8354. for (var j = 0; j < triangles.length; j += 3) {
  8355. var t1 = triangles[j] * 8, t2 = triangles[j + 1] * 8, t3 = triangles[j + 2] * 8;
  8356. var x0 = vertices[t1], y0 = vertices[t1 + 1], u0 = vertices[t1 + 6], v0 = vertices[t1 + 7];
  8357. var x1 = vertices[t2], y1 = vertices[t2 + 1], u1 = vertices[t2 + 6], v1 = vertices[t2 + 7];
  8358. var x2 = vertices[t3], y2 = vertices[t3 + 1], u2 = vertices[t3 + 6], v2 = vertices[t3 + 7];
  8359. this.drawTriangle(texture, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
  8360. if (this.debugRendering) {
  8361. ctx.strokeStyle = "green";
  8362. ctx.beginPath();
  8363. ctx.moveTo(x0, y0);
  8364. ctx.lineTo(x1, y1);
  8365. ctx.lineTo(x2, y2);
  8366. ctx.lineTo(x0, y0);
  8367. ctx.stroke();
  8368. }
  8369. }
  8370. }
  8371. }
  8372. this.ctx.globalAlpha = 1;
  8373. };
  8374. SkeletonRenderer.prototype.drawTriangle = function (img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) {
  8375. var ctx = this.ctx;
  8376. u0 *= img.width;
  8377. v0 *= img.height;
  8378. u1 *= img.width;
  8379. v1 *= img.height;
  8380. u2 *= img.width;
  8381. v2 *= img.height;
  8382. ctx.beginPath();
  8383. ctx.moveTo(x0, y0);
  8384. ctx.lineTo(x1, y1);
  8385. ctx.lineTo(x2, y2);
  8386. ctx.closePath();
  8387. x1 -= x0;
  8388. y1 -= y0;
  8389. x2 -= x0;
  8390. y2 -= y0;
  8391. u1 -= u0;
  8392. v1 -= v0;
  8393. u2 -= u0;
  8394. v2 -= v0;
  8395. var det = 1 / (u1 * v2 - u2 * v1), a = (v2 * x1 - v1 * x2) * det, b = (v2 * y1 - v1 * y2) * det, c = (u1 * x2 - u2 * x1) * det, d = (u1 * y2 - u2 * y1) * det, e = x0 - a * u0 - c * v0, f = y0 - b * u0 - d * v0;
  8396. ctx.save();
  8397. ctx.transform(a, b, c, d, e, f);
  8398. ctx.clip();
  8399. ctx.drawImage(img, 0, 0);
  8400. ctx.restore();
  8401. };
  8402. SkeletonRenderer.prototype.computeRegionVertices = function (slot, region, pma) {
  8403. var skeleton = slot.bone.skeleton;
  8404. var skeletonColor = skeleton.color;
  8405. var slotColor = slot.color;
  8406. var regionColor = region.color;
  8407. var alpha = skeletonColor.a * slotColor.a * regionColor.a;
  8408. var multiplier = pma ? alpha : 1;
  8409. var color = this.tempColor;
  8410. color.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha);
  8411. region.computeWorldVertices(slot.bone, this.vertices, 0, SkeletonRenderer.VERTEX_SIZE);
  8412. var vertices = this.vertices;
  8413. var uvs = region.uvs;
  8414. vertices[spine.RegionAttachment.C1R] = color.r;
  8415. vertices[spine.RegionAttachment.C1G] = color.g;
  8416. vertices[spine.RegionAttachment.C1B] = color.b;
  8417. vertices[spine.RegionAttachment.C1A] = color.a;
  8418. vertices[spine.RegionAttachment.U1] = uvs[0];
  8419. vertices[spine.RegionAttachment.V1] = uvs[1];
  8420. vertices[spine.RegionAttachment.C2R] = color.r;
  8421. vertices[spine.RegionAttachment.C2G] = color.g;
  8422. vertices[spine.RegionAttachment.C2B] = color.b;
  8423. vertices[spine.RegionAttachment.C2A] = color.a;
  8424. vertices[spine.RegionAttachment.U2] = uvs[2];
  8425. vertices[spine.RegionAttachment.V2] = uvs[3];
  8426. vertices[spine.RegionAttachment.C3R] = color.r;
  8427. vertices[spine.RegionAttachment.C3G] = color.g;
  8428. vertices[spine.RegionAttachment.C3B] = color.b;
  8429. vertices[spine.RegionAttachment.C3A] = color.a;
  8430. vertices[spine.RegionAttachment.U3] = uvs[4];
  8431. vertices[spine.RegionAttachment.V3] = uvs[5];
  8432. vertices[spine.RegionAttachment.C4R] = color.r;
  8433. vertices[spine.RegionAttachment.C4G] = color.g;
  8434. vertices[spine.RegionAttachment.C4B] = color.b;
  8435. vertices[spine.RegionAttachment.C4A] = color.a;
  8436. vertices[spine.RegionAttachment.U4] = uvs[6];
  8437. vertices[spine.RegionAttachment.V4] = uvs[7];
  8438. return vertices;
  8439. };
  8440. SkeletonRenderer.prototype.computeMeshVertices = function (slot, mesh, pma) {
  8441. var skeleton = slot.bone.skeleton;
  8442. var skeletonColor = skeleton.color;
  8443. var slotColor = slot.color;
  8444. var regionColor = mesh.color;
  8445. var alpha = skeletonColor.a * slotColor.a * regionColor.a;
  8446. var multiplier = pma ? alpha : 1;
  8447. var color = this.tempColor;
  8448. color.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha);
  8449. var numVertices = mesh.worldVerticesLength / 2;
  8450. if (this.vertices.length < mesh.worldVerticesLength) {
  8451. this.vertices = spine.Utils.newFloatArray(mesh.worldVerticesLength);
  8452. }
  8453. var vertices = this.vertices;
  8454. mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, SkeletonRenderer.VERTEX_SIZE);
  8455. var uvs = mesh.uvs;
  8456. for (var i = 0, n = numVertices, u = 0, v = 2; i < n; i++) {
  8457. vertices[v++] = color.r;
  8458. vertices[v++] = color.g;
  8459. vertices[v++] = color.b;
  8460. vertices[v++] = color.a;
  8461. vertices[v++] = uvs[u++];
  8462. vertices[v++] = uvs[u++];
  8463. v += 2;
  8464. }
  8465. return vertices;
  8466. };
  8467. SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
  8468. SkeletonRenderer.VERTEX_SIZE = 2 + 2 + 4;
  8469. return SkeletonRenderer;
  8470. }());
  8471. canvas.SkeletonRenderer = SkeletonRenderer;
  8472. })(canvas = spine.canvas || (spine.canvas = {}));
  8473. })(spine || (spine = {}));
  8474. var spine;
  8475. (function (spine) {
  8476. var webgl;
  8477. (function (webgl) {
  8478. var AssetManager = (function (_super) {
  8479. __extends(AssetManager, _super);
  8480. function AssetManager(context, pathPrefix) {
  8481. if (pathPrefix === void 0) { pathPrefix = ""; }
  8482. return _super.call(this, function (image) {
  8483. return new spine.webgl.GLTexture(context, image);
  8484. }, pathPrefix) || this;
  8485. }
  8486. return AssetManager;
  8487. }(spine.AssetManager));
  8488. webgl.AssetManager = AssetManager;
  8489. })(webgl = spine.webgl || (spine.webgl = {}));
  8490. })(spine || (spine = {}));
  8491. var spine;
  8492. (function (spine) {
  8493. var webgl;
  8494. (function (webgl) {
  8495. var OrthoCamera = (function () {
  8496. function OrthoCamera(viewportWidth, viewportHeight) {
  8497. this.position = new webgl.Vector3(0, 0, 0);
  8498. this.direction = new webgl.Vector3(0, 0, -1);
  8499. this.up = new webgl.Vector3(0, 1, 0);
  8500. this.near = 0;
  8501. this.far = 100;
  8502. this.zoom = 1;
  8503. this.viewportWidth = 0;
  8504. this.viewportHeight = 0;
  8505. this.projectionView = new webgl.Matrix4();
  8506. this.inverseProjectionView = new webgl.Matrix4();
  8507. this.projection = new webgl.Matrix4();
  8508. this.view = new webgl.Matrix4();
  8509. this.tmp = new webgl.Vector3();
  8510. this.viewportWidth = viewportWidth;
  8511. this.viewportHeight = viewportHeight;
  8512. this.update();
  8513. }
  8514. OrthoCamera.prototype.update = function () {
  8515. var projection = this.projection;
  8516. var view = this.view;
  8517. var projectionView = this.projectionView;
  8518. var inverseProjectionView = this.inverseProjectionView;
  8519. var zoom = this.zoom, viewportWidth = this.viewportWidth, viewportHeight = this.viewportHeight;
  8520. projection.ortho(zoom * (-viewportWidth / 2), zoom * (viewportWidth / 2), zoom * (-viewportHeight / 2), zoom * (viewportHeight / 2), this.near, this.far);
  8521. view.lookAt(this.position, this.direction, this.up);
  8522. projectionView.set(projection.values);
  8523. projectionView.multiply(view);
  8524. inverseProjectionView.set(projectionView.values).invert();
  8525. };
  8526. OrthoCamera.prototype.screenToWorld = function (screenCoords, screenWidth, screenHeight) {
  8527. var x = screenCoords.x, y = screenHeight - screenCoords.y - 1;
  8528. var tmp = this.tmp;
  8529. tmp.x = (2 * x) / screenWidth - 1;
  8530. tmp.y = (2 * y) / screenHeight - 1;
  8531. tmp.z = (2 * screenCoords.z) - 1;
  8532. tmp.project(this.inverseProjectionView);
  8533. screenCoords.set(tmp.x, tmp.y, tmp.z);
  8534. return screenCoords;
  8535. };
  8536. OrthoCamera.prototype.setViewport = function (viewportWidth, viewportHeight) {
  8537. this.viewportWidth = viewportWidth;
  8538. this.viewportHeight = viewportHeight;
  8539. };
  8540. return OrthoCamera;
  8541. }());
  8542. webgl.OrthoCamera = OrthoCamera;
  8543. })(webgl = spine.webgl || (spine.webgl = {}));
  8544. })(spine || (spine = {}));
  8545. var spine;
  8546. (function (spine) {
  8547. var webgl;
  8548. (function (webgl) {
  8549. var GLTexture = (function (_super) {
  8550. __extends(GLTexture, _super);
  8551. function GLTexture(context, image, useMipMaps) {
  8552. if (useMipMaps === void 0) { useMipMaps = false; }
  8553. var _this = _super.call(this, image) || this;
  8554. _this.texture = null;
  8555. _this.boundUnit = 0;
  8556. _this.useMipMaps = false;
  8557. _this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  8558. _this.useMipMaps = useMipMaps;
  8559. _this.restore();
  8560. _this.context.addRestorable(_this);
  8561. return _this;
  8562. }
  8563. GLTexture.prototype.setFilters = function (minFilter, magFilter) {
  8564. var gl = this.context.gl;
  8565. this.bind();
  8566. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
  8567. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, GLTexture.validateMagFilter(magFilter));
  8568. };
  8569. GLTexture.validateMagFilter = function (magFilter) {
  8570. switch (magFilter) {
  8571. case spine.TextureFilter.MipMap:
  8572. case spine.TextureFilter.MipMapLinearLinear:
  8573. case spine.TextureFilter.MipMapLinearNearest:
  8574. case spine.TextureFilter.MipMapNearestLinear:
  8575. case spine.TextureFilter.MipMapNearestNearest:
  8576. return spine.TextureFilter.Linear;
  8577. default:
  8578. return magFilter;
  8579. }
  8580. };
  8581. GLTexture.prototype.setWraps = function (uWrap, vWrap) {
  8582. var gl = this.context.gl;
  8583. this.bind();
  8584. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
  8585. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
  8586. };
  8587. GLTexture.prototype.update = function (useMipMaps) {
  8588. var gl = this.context.gl;
  8589. if (!this.texture) {
  8590. this.texture = this.context.gl.createTexture();
  8591. }
  8592. this.bind();
  8593. if (GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL)
  8594. gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
  8595. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
  8596. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  8597. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  8598. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  8599. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  8600. if (useMipMaps)
  8601. gl.generateMipmap(gl.TEXTURE_2D);
  8602. };
  8603. GLTexture.prototype.restore = function () {
  8604. this.texture = null;
  8605. this.update(this.useMipMaps);
  8606. };
  8607. GLTexture.prototype.bind = function (unit) {
  8608. if (unit === void 0) { unit = 0; }
  8609. var gl = this.context.gl;
  8610. this.boundUnit = unit;
  8611. gl.activeTexture(gl.TEXTURE0 + unit);
  8612. gl.bindTexture(gl.TEXTURE_2D, this.texture);
  8613. };
  8614. GLTexture.prototype.unbind = function () {
  8615. var gl = this.context.gl;
  8616. gl.activeTexture(gl.TEXTURE0 + this.boundUnit);
  8617. gl.bindTexture(gl.TEXTURE_2D, null);
  8618. };
  8619. GLTexture.prototype.dispose = function () {
  8620. this.context.removeRestorable(this);
  8621. var gl = this.context.gl;
  8622. gl.deleteTexture(this.texture);
  8623. };
  8624. GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL = false;
  8625. return GLTexture;
  8626. }(spine.Texture));
  8627. webgl.GLTexture = GLTexture;
  8628. })(webgl = spine.webgl || (spine.webgl = {}));
  8629. })(spine || (spine = {}));
  8630. var spine;
  8631. (function (spine) {
  8632. var webgl;
  8633. (function (webgl) {
  8634. var Input = (function () {
  8635. function Input(element) {
  8636. this.lastX = 0;
  8637. this.lastY = 0;
  8638. this.buttonDown = false;
  8639. this.currTouch = null;
  8640. this.touchesPool = new spine.Pool(function () {
  8641. return new spine.webgl.Touch(0, 0, 0);
  8642. });
  8643. this.listeners = new Array();
  8644. this.element = element;
  8645. this.setupCallbacks(element);
  8646. }
  8647. Input.prototype.setupCallbacks = function (element) {
  8648. var _this = this;
  8649. var mouseDown = function (ev) {
  8650. if (ev instanceof MouseEvent) {
  8651. var rect = element.getBoundingClientRect();
  8652. var x = ev.clientX - rect.left;
  8653. var y = ev.clientY - rect.top;
  8654. var listeners = _this.listeners;
  8655. for (var i = 0; i < listeners.length; i++) {
  8656. if (listeners[i].down)
  8657. listeners[i].down(x, y);
  8658. }
  8659. _this.lastX = x;
  8660. _this.lastY = y;
  8661. _this.buttonDown = true;
  8662. document.addEventListener("mousemove", mouseMove);
  8663. document.addEventListener("mouseup", mouseUp);
  8664. }
  8665. };
  8666. var mouseMove = function (ev) {
  8667. if (ev instanceof MouseEvent) {
  8668. var rect = element.getBoundingClientRect();
  8669. var x = ev.clientX - rect.left;
  8670. var y = ev.clientY - rect.top;
  8671. var listeners = _this.listeners;
  8672. for (var i = 0; i < listeners.length; i++) {
  8673. if (_this.buttonDown) {
  8674. if (listeners[i].dragged)
  8675. listeners[i].dragged(x, y);
  8676. }
  8677. else {
  8678. if (listeners[i].moved)
  8679. listeners[i].moved(x, y);
  8680. }
  8681. }
  8682. _this.lastX = x;
  8683. _this.lastY = y;
  8684. }
  8685. };
  8686. var mouseUp = function (ev) {
  8687. if (ev instanceof MouseEvent) {
  8688. var rect = element.getBoundingClientRect();
  8689. var x = ev.clientX - rect.left;
  8690. var y = ev.clientY - rect.top;
  8691. var listeners = _this.listeners;
  8692. for (var i = 0; i < listeners.length; i++) {
  8693. if (listeners[i].up)
  8694. listeners[i].up(x, y);
  8695. }
  8696. _this.lastX = x;
  8697. _this.lastY = y;
  8698. _this.buttonDown = false;
  8699. document.removeEventListener("mousemove", mouseMove);
  8700. document.removeEventListener("mouseup", mouseUp);
  8701. }
  8702. };
  8703. element.addEventListener("mousedown", mouseDown, true);
  8704. element.addEventListener("mousemove", mouseMove, true);
  8705. element.addEventListener("mouseup", mouseUp, true);
  8706. element.addEventListener("touchstart", function (ev) {
  8707. if (_this.currTouch != null)
  8708. return;
  8709. var touches = ev.changedTouches;
  8710. for (var i = 0; i < touches.length; i++) {
  8711. var touch = touches[i];
  8712. var rect = element.getBoundingClientRect();
  8713. var x = touch.clientX - rect.left;
  8714. var y = touch.clientY - rect.top;
  8715. _this.currTouch = _this.touchesPool.obtain();
  8716. _this.currTouch.identifier = touch.identifier;
  8717. _this.currTouch.x = x;
  8718. _this.currTouch.y = y;
  8719. break;
  8720. }
  8721. var listeners = _this.listeners;
  8722. for (var i_17 = 0; i_17 < listeners.length; i_17++) {
  8723. if (listeners[i_17].down)
  8724. listeners[i_17].down(_this.currTouch.x, _this.currTouch.y);
  8725. }
  8726. _this.lastX = _this.currTouch.x;
  8727. _this.lastY = _this.currTouch.y;
  8728. _this.buttonDown = true;
  8729. ev.preventDefault();
  8730. }, false);
  8731. element.addEventListener("touchend", function (ev) {
  8732. var touches = ev.changedTouches;
  8733. for (var i = 0; i < touches.length; i++) {
  8734. var touch = touches[i];
  8735. if (_this.currTouch.identifier === touch.identifier) {
  8736. var rect = element.getBoundingClientRect();
  8737. var x = _this.currTouch.x = touch.clientX - rect.left;
  8738. var y = _this.currTouch.y = touch.clientY - rect.top;
  8739. _this.touchesPool.free(_this.currTouch);
  8740. var listeners = _this.listeners;
  8741. for (var i_18 = 0; i_18 < listeners.length; i_18++) {
  8742. if (listeners[i_18].up)
  8743. listeners[i_18].up(x, y);
  8744. }
  8745. _this.lastX = x;
  8746. _this.lastY = y;
  8747. _this.buttonDown = false;
  8748. _this.currTouch = null;
  8749. break;
  8750. }
  8751. }
  8752. ev.preventDefault();
  8753. }, false);
  8754. element.addEventListener("touchcancel", function (ev) {
  8755. var touches = ev.changedTouches;
  8756. for (var i = 0; i < touches.length; i++) {
  8757. var touch = touches[i];
  8758. if (_this.currTouch.identifier === touch.identifier) {
  8759. var rect = element.getBoundingClientRect();
  8760. var x = _this.currTouch.x = touch.clientX - rect.left;
  8761. var y = _this.currTouch.y = touch.clientY - rect.top;
  8762. _this.touchesPool.free(_this.currTouch);
  8763. var listeners = _this.listeners;
  8764. for (var i_19 = 0; i_19 < listeners.length; i_19++) {
  8765. if (listeners[i_19].up)
  8766. listeners[i_19].up(x, y);
  8767. }
  8768. _this.lastX = x;
  8769. _this.lastY = y;
  8770. _this.buttonDown = false;
  8771. _this.currTouch = null;
  8772. break;
  8773. }
  8774. }
  8775. ev.preventDefault();
  8776. }, false);
  8777. element.addEventListener("touchmove", function (ev) {
  8778. if (_this.currTouch == null)
  8779. return;
  8780. var touches = ev.changedTouches;
  8781. for (var i = 0; i < touches.length; i++) {
  8782. var touch = touches[i];
  8783. if (_this.currTouch.identifier === touch.identifier) {
  8784. var rect = element.getBoundingClientRect();
  8785. var x = touch.clientX - rect.left;
  8786. var y = touch.clientY - rect.top;
  8787. var listeners = _this.listeners;
  8788. for (var i_20 = 0; i_20 < listeners.length; i_20++) {
  8789. if (listeners[i_20].dragged)
  8790. listeners[i_20].dragged(x, y);
  8791. }
  8792. _this.lastX = _this.currTouch.x = x;
  8793. _this.lastY = _this.currTouch.y = y;
  8794. break;
  8795. }
  8796. }
  8797. ev.preventDefault();
  8798. }, false);
  8799. };
  8800. Input.prototype.addListener = function (listener) {
  8801. this.listeners.push(listener);
  8802. };
  8803. Input.prototype.removeListener = function (listener) {
  8804. var idx = this.listeners.indexOf(listener);
  8805. if (idx > -1) {
  8806. this.listeners.splice(idx, 1);
  8807. }
  8808. };
  8809. return Input;
  8810. }());
  8811. webgl.Input = Input;
  8812. var Touch = (function () {
  8813. function Touch(identifier, x, y) {
  8814. this.identifier = identifier;
  8815. this.x = x;
  8816. this.y = y;
  8817. }
  8818. return Touch;
  8819. }());
  8820. webgl.Touch = Touch;
  8821. })(webgl = spine.webgl || (spine.webgl = {}));
  8822. })(spine || (spine = {}));
  8823. var spine;
  8824. (function (spine) {
  8825. var webgl;
  8826. (function (webgl) {
  8827. var LoadingScreen = (function () {
  8828. function LoadingScreen(renderer) {
  8829. this.logo = null;
  8830. this.spinner = null;
  8831. this.angle = 0;
  8832. this.fadeOut = 0;
  8833. this.timeKeeper = new spine.TimeKeeper();
  8834. this.backgroundColor = new spine.Color(0.135, 0.135, 0.135, 1);
  8835. this.tempColor = new spine.Color();
  8836. this.firstDraw = 0;
  8837. this.renderer = renderer;
  8838. this.timeKeeper.maxDelta = 9;
  8839. if (LoadingScreen.logoImg === null) {
  8840. var isSafari = navigator.userAgent.indexOf("Safari") > -1;
  8841. LoadingScreen.logoImg = new Image();
  8842. LoadingScreen.logoImg.src = LoadingScreen.SPINE_LOGO_DATA;
  8843. if (!isSafari)
  8844. LoadingScreen.logoImg.crossOrigin = "anonymous";
  8845. LoadingScreen.logoImg.onload = function (ev) {
  8846. LoadingScreen.loaded++;
  8847. };
  8848. LoadingScreen.spinnerImg = new Image();
  8849. LoadingScreen.spinnerImg.src = LoadingScreen.SPINNER_DATA;
  8850. if (!isSafari)
  8851. LoadingScreen.spinnerImg.crossOrigin = "anonymous";
  8852. LoadingScreen.spinnerImg.onload = function (ev) {
  8853. LoadingScreen.loaded++;
  8854. };
  8855. }
  8856. }
  8857. LoadingScreen.prototype.draw = function (complete) {
  8858. if (complete === void 0) { complete = false; }
  8859. if (complete && this.fadeOut > LoadingScreen.FADE_SECONDS)
  8860. return;
  8861. this.timeKeeper.update();
  8862. var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75));
  8863. this.angle -= this.timeKeeper.delta / 1.4 * 360 * (1 + 1.5 * Math.pow(a, 5));
  8864. var renderer = this.renderer;
  8865. var canvas = renderer.canvas;
  8866. var gl = renderer.context.gl;
  8867. renderer.resize(webgl.ResizeMode.Stretch);
  8868. var oldX = renderer.camera.position.x, oldY = renderer.camera.position.y;
  8869. renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);
  8870. renderer.camera.viewportWidth = canvas.width;
  8871. renderer.camera.viewportHeight = canvas.height;
  8872. if (!complete) {
  8873. gl.clearColor(this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a);
  8874. gl.clear(gl.COLOR_BUFFER_BIT);
  8875. this.tempColor.a = 1;
  8876. }
  8877. else {
  8878. this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);
  8879. if (this.fadeOut > LoadingScreen.FADE_SECONDS) {
  8880. renderer.camera.position.set(oldX, oldY, 0);
  8881. return;
  8882. }
  8883. a = 1 - this.fadeOut / LoadingScreen.FADE_SECONDS;
  8884. this.tempColor.setFromColor(this.backgroundColor);
  8885. this.tempColor.a = 1 - (a - 1) * (a - 1);
  8886. renderer.begin();
  8887. renderer.quad(true, 0, 0, canvas.width, 0, canvas.width, canvas.height, 0, canvas.height, this.tempColor, this.tempColor, this.tempColor, this.tempColor);
  8888. renderer.end();
  8889. }
  8890. this.tempColor.set(1, 1, 1, this.tempColor.a);
  8891. if (LoadingScreen.loaded != 2)
  8892. return;
  8893. if (this.logo === null) {
  8894. this.logo = new webgl.GLTexture(renderer.context, LoadingScreen.logoImg);
  8895. this.spinner = new webgl.GLTexture(renderer.context, LoadingScreen.spinnerImg);
  8896. }
  8897. this.logo.update(false);
  8898. this.spinner.update(false);
  8899. var logoWidth = this.logo.getImage().width;
  8900. var logoHeight = this.logo.getImage().height;
  8901. var spinnerWidth = this.spinner.getImage().width;
  8902. var spinnerHeight = this.spinner.getImage().height;
  8903. renderer.batcher.setBlendMode(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
  8904. renderer.begin();
  8905. renderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, this.tempColor);
  8906. renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerWidth) / 2, (canvas.height - spinnerHeight) / 2, spinnerWidth, spinnerHeight, spinnerWidth / 2, spinnerHeight / 2, this.angle, this.tempColor);
  8907. renderer.end();
  8908. renderer.camera.position.set(oldX, oldY, 0);
  8909. };
  8910. LoadingScreen.FADE_SECONDS = 1;
  8911. LoadingScreen.loaded = 0;
  8912. LoadingScreen.spinnerImg = null;
  8913. LoadingScreen.logoImg = null;
  8914. LoadingScreen.SPINNER_DATA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKMAAACjCAYAAADmbK6AAAAACXBIWXMAAAsTAAALEwEAmpwYAAALB2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VFdmVudCMiIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczpwaG90b3Nob3A9Imh0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9zaG9wLzEuMC8iIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIiB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNS41IChXaW5kb3dzKSIgeG1wOkNyZWF0ZURhdGU9IjIwMTYtMDktMDhUMTQ6MjU6MTIrMDI6MDAiIHhtcDpNZXRhZGF0YURhdGU9IjIwMTgtMTEtMTVUMTY6NDA6NTkrMDE6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDE4LTExLTE1VDE2OjQwOjU5KzAxOjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpmZDhlNTljMC02NGJjLTIxNGQtODAyZi1jZDlhODJjM2ZjMGMiIHhtcE1NOkRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDpmYmNmZWJlYS03MjY2LWE0NGQtOTI4NS0wOTJmNGNhYzk4ZWEiIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHRpZmY6T3JpZW50YXRpb249IjEiIHRpZmY6WFJlc29sdXRpb249IjcyMDAwMC8xMDAwMCIgdGlmZjpZUmVzb2x1dGlvbj0iNzIwMDAwLzEwMDAwIiB0aWZmOlJlc29sdXRpb25Vbml0PSIyIiBleGlmOkNvbG9yU3BhY2U9IjY1NTM1IiBleGlmOlBpeGVsWERpbWVuc2lvbj0iMjk3IiBleGlmOlBpeGVsWURpbWVuc2lvbj0iMjQyIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiIHN0RXZ0OndoZW49IjIwMTYtMDktMDhUMTQ6MjU6MTIrMDI6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE1LjUgKFdpbmRvd3MpIi8+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJzYXZlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDpiNThlMTlkNi0xYTRjLTQyNDEtODU0ZC01MDVlZjYxMjRhODQiIHN0RXZ0OndoZW49IjIwMTgtMTEtMTVUMTY6NDA6MjMrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAoV2luZG93cykiIHN0RXZ0OmNoYW5nZWQ9Ii8iLz4gPHJkZjpsaSBzdEV2dDphY3Rpb249InNhdmVkIiBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjQ3YzYzYzIwLWJkYjgtYzM0YS1hYzMyLWQ5MDdjOWEyOTA0MCIgc3RFdnQ6d2hlbj0iMjAxOC0xMS0xNVQxNjo0MDo1OSswMTowMCIgc3RFdnQ6c29mdHdhcmVBZ2VudD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY29udmVydGVkIiBzdEV2dDpwYXJhbWV0ZXJzPSJmcm9tIGFwcGxpY2F0aW9uL3ZuZC5hZG9iZS5waG90b3Nob3AgdG8gaW1hZ2UvcG5nIi8+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJkZXJpdmVkIiBzdEV2dDpwYXJhbWV0ZXJzPSJjb252ZXJ0ZWQgZnJvbSBhcHBsaWNhdGlvbi92bmQuYWRvYmUucGhvdG9zaG9wIHRvIGltYWdlL3BuZyIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6ZmQ4ZTU5YzAtNjRiYy0yMTRkLTgwMmYtY2Q5YTgyYzNmYzBjIiBzdEV2dDp3aGVuPSIyMDE4LTExLTE1VDE2OjQwOjU5KzAxOjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgKFdpbmRvd3MpIiBzdEV2dDpjaGFuZ2VkPSIvIi8+IDwvcmRmOlNlcT4gPC94bXBNTTpIaXN0b3J5PiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo0N2M2M2MyMC1iZGI4LWMzNGEtYWMzMi1kOTA3YzlhMjkwNDAiIHN0UmVmOmRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDo2OWRmZjljYy01YzFiLWE5NDctOTc3OS03ODgxZjM0ODk3MDMiIHN0UmVmOm9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiLz4gPHBob3Rvc2hvcDpEb2N1bWVudEFuY2VzdG9ycz4gPHJkZjpCYWc+IDxyZGY6bGk+eG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2U8L3JkZjpsaT4gPC9yZGY6QmFnPiA8L3Bob3Rvc2hvcDpEb2N1bWVudEFuY2VzdG9ycz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7qS4aQAAAKZElEQVR42u2de4xVxR3HP8dd3rQryPKo4dGNbtVAQRa1YB93E1tTS7VYqCBiSWhsqGltSx+0xD60tKBorYnNkkBtFUt9xJaGNGlty6EqRAK1KlalshK2C8tzpcIigpz+MbPr5e5y987dM2fv4/tJbjC7v3P2+JvPnTMzZ85MEEURQhQClUpB7gRBAECUYiYwH6gDqoEKoA1oBDYCy4OQJgB92R3yq2S5yRilWASs6CZ0DzA5CNmn/ObOOUpB7kQpRgNLcwj9AHCnMiYZfXIT0C/H2DlRSs0gyeiPaQ6xg4FapUwy+mKUY/wwpUwy+uK4Y/xhpUwy+mKfY3yTUiYZfdHiENsahBxRyiSjL5odYncpXZLRJ3sdYhuVLslYKDKqZpSMBXObVs0oGQumA6OaUTL6Iwg5CBzNMXy7MiYZffNCDjH7g5DdSpVk9M36mGKEZOwxq4Fj3cT8UmmSjEm0Gw8At2UJaQhCtilTeeRWM5EdkmVfOwCIUtQBE4AqILC1ZQuwPgjpSKryWwgy1gfZfjsQ886IKFY2xO9N0jOR69srDOAtzCyYFuCUSrcg6AOcBIYCY4C3gVeT+uNJyvg94GPAxzFjcDuBl4C/AP+UBwXBR4AaYDYwDvgr8Drwi1KScRnwXfut6wNcYT+7Ma97LgX+JRd6jfOAucAXgCvTfl4DvAuMtJVJ0cu41IoYWRHTGWM/1TZmq/2fF8nR14r4U2BQF7+LgMW2k7bY54X4Htr5EvD99s5SlriPArcAY+VGsh1YYDpwMzAgSwy2svhWscpYA/wkx9gKm5S5wBA5kgjnAJcDX7NNpVxcWAZMLUYZJwHDHeKrgXnAdWjZlSS4BLgVuMzRlxt9eeNTxsG2veFyy7gQWAR8Sq54byfeYDssAx3LqLabJldBytgMHMjjuPHAQvTOsU++aJtE/fI4dpevTqZPGV+2veN8+DTwIHCBr29hmVJhJXwA+GAex7cBjxZjm7EFWAL8DfeX39s7NPOy9PKEO7XAV+k8xJYLrcDPgL8Xo4xgJqIuA7bkeXw9ZsBVxMMMYEqex64FfuO7e++bTcAPgD8Bpx2PvRSYKIdi61DOs3edXImAV4Cv2zJsKnYZ24B/AJ+xteRrwAmHBF4mj2JhEnCRg4QnrYh3YZ5NH/J9gUmP5zXYtsdsW+Pl8vffkEex8I5D7HHgGeBhe0dLhKRlbMJM298NXI8Z68rGk8AGeRQLu4DHMGOL2dgJPA78AXguyQvsjScdrTYp2zBDPzfbXl7mmNc64B7MFCbRc/bbfPYHrs343WnbZHsG+BXwZ8y65JS6jOnfwPuBg8BnMQtxjsWsh/0IsNJ2fkR8bAHutbfhG2x7vp9tDzZiFs5/Non2YaHJ2N6OWQf8BxiBeRx4EDPZ9nm544WNVsLtwFWYJ2Wh/fmO3ryw3noHpiv6YyZ5NsuXROhrRypeAv7nfHQJvAOTjbclYuJ3pWcL6YL03rSQjEJIRiEZhZCMQjIKIRmFZBRCMgrJKIRkFJJRCMkoJKMQklFIRiEkoxCSUUhGISSjkIxCSEYhGYWQjEIyCiEZhWQUQjIKySiEZBSSUQjJKCSjEAVCJUAQmCWPoxSjgZuAaZgF348D+zD7ADYDe+2nGWgJQg52dVJvSzOLgqHdmU5ln2IYZou9861Do+x/j8Ss2z7AOrQJWBOEZtetKIrMmt5BEBClWAQsxW3b16OY/QHXA6uD0GzpG0VRPmt6i2KSMeyQrxpYgNl4dCJmV7NcOQEsCULu6ZCR+mAmZiOannAMuC0IWS0Zy0PGKMUCzFZug3p4ullsiJ5obzPOj+H6BgGrohR1KqrSx5bzqhhE7PCvXcY4BZqgoioL4iznunQZq2M8cZXKqSyIs5yr02WsiPHEaiyWSbMxxnNVpMvYFuOJj6mcyoI4y7ktXcbGGE/conIqC+Is58Z0GTfGdNIGzJijKH3W2/KOg43pMi4n//2F92P2KJ4ShCwMQvT4pRwajCFRELIQmGLLf3+ep9pj/TvjCcwI4E5gDp1H0VsxO7k3Zvy7PQjZnXl2DXqXhYydiFKMAcYD44CajH+HZIQfBdYCtwch+854HJh2wkqgFhgGHAaagpAjLhcqGctTxqxOpKgCRgNDMXuK7whCTqU7U9khz3ucAv59xomUe9FVhePGEfs5q1eaQiYKBskoJKMQklFIRiEko5CMQkhGIRmFkIxCMgohGYVkFEIyCskohGQUklEIySiEZBSSUQjJKCSjEJJRSEYhJKOQjEJIRiEZhZCMQjIKIRmFZBSijGXMvIZ+KpZEaF8qeygwHOjb2xdUWQBJqQL6ADOBi4GHMGuGH5Iv3hiG2SJtIWaV4mZgB/AadF6jvVxkvAKzv3UdMNX+bDJm9fx10PV+1qLHIl4P3GLzfh3QBLwKbAZ+DJwuFxkDm5CZmN0Vzsv4/TTMyviVwGOYnRZEPAwBZgDfAC5K+/lo+5kKXAjcBzwPnCz1NuP77LfxO12I2M7FNmFXE+++huVOPfDNDBEz25FzgHuBa4Bzk8x/0jJeCiwCFmP2BsnGh4BbgYFyKDZmZRExnTpbGcywHZySuk0PsbeAG4HZDt+2C6yMb8mjWHgXs+NFd5v09Ac+AYzC7An0EPBKqdSM1wDfBqY7Vvubk263lDhPYHamypVa4MvAHUCq2GvGgcB8YAEwKQ/5nwa33blEVrYDLwJXOhxzLvBJzDhkK/BCMdaMA4C5wF2Y4RrXv7UF+KO9tYh42A08msfoRxVwLfBDYGwxyliLGUMclMexL9rOy075EyvvAKuBlcCbeTa3Pl+MMk7GbP/qyiHg18BWueOFNnu3ymeP8X62h11dbDKm7K3a9Zv7e+BJOeOVRmCNvQO5cgmdt4AueBkH5zCE0FWHpQH4r3zxzlPAw3kcdxg4VmwybnaMfx1YAWxTpyURjtj24wpHuZ7C0yNanzL+FnjZIX4lsEGOJEorcDewKcf4vTb+ZLHJuAeYBxzvJm4/8CPg58AJ+ZE4BzBDNk93k//jwOeAN4qxNw1m5sdV9jZwtlvv48ADujX3GpFtUt0OhPZnJzN63wdtOW7xeSFJPJvehBnBv8/2ricAp2wb8UHgETRvsRDYCiy3IrbPCWi0Mt4BPOf7AoIoivycub5TR/rDmBkjs4Df2fbHJjlQcLwfuNyW13rMXILOkyQ2REUtI5jnnG+mNRFOF3Gh1dlavgozhHUMaLEFGJWImBVnbT4VlYwlSBCYL1iUYgGw6ixhDUHIwo4GmfIrGX3JGKWotj3KbM/cpwQh2yRjYfWmS5EFdD/54ytKk2RMgukxxQjJ2GMm5hAzPEoxRqmSjN6IUgwj9xkr45UxyeiTkQ6x45QuyeiT8x1ia5QuyeiTUaoZJWMxyqiaUTIWzG1aNaNkLJgOzJAoRZVSJhl9McIxfrRSJhl94fq241ClTDL6Yq9jvCYNS0ZvuEwGPopZmlhIRi+sIfeXxtYGIaeUMsnohSCkCViSQ+gezAtOwiW/mvzpkKz3ZnrPxCz1V4dZd6YC8+JSI2YNm+VWXE2ulYyiGPk/nslB8d6ayMkAAAAASUVORK5CYII=";
  8915. LoadingScreen.SPINE_LOGO_DATA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKUAAABsCAYAAAALzHKmAAAACXBIWXMAAAsTAAALEwEAmpwYAAALB2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VFdmVudCMiIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczpwaG90b3Nob3A9Imh0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9zaG9wLzEuMC8iIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIiB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNS41IChXaW5kb3dzKSIgeG1wOkNyZWF0ZURhdGU9IjIwMTYtMDktMDhUMTQ6MjU6MTIrMDI6MDAiIHhtcDpNZXRhZGF0YURhdGU9IjIwMTgtMTEtMTVUMTY6NDA6NTkrMDE6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDE4LTExLTE1VDE2OjQwOjU5KzAxOjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowMTdhZGQ3Ni04OTZlLThlNGUtYmM5MS00ZjEyNjI1YjA3MjgiIHhtcE1NOkRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDplMTViNGE2ZS1hMDg3LWEzNDktODdhOS1mNDYzYjE2MzQ0Y2MiIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHRpZmY6T3JpZW50YXRpb249IjEiIHRpZmY6WFJlc29sdXRpb249IjcyMDAwMC8xMDAwMCIgdGlmZjpZUmVzb2x1dGlvbj0iNzIwMDAwLzEwMDAwIiB0aWZmOlJlc29sdXRpb25Vbml0PSIyIiBleGlmOkNvbG9yU3BhY2U9IjY1NTM1IiBleGlmOlBpeGVsWERpbWVuc2lvbj0iMjk3IiBleGlmOlBpeGVsWURpbWVuc2lvbj0iMjQyIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiIHN0RXZ0OndoZW49IjIwMTYtMDktMDhUMTQ6MjU6MTIrMDI6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE1LjUgKFdpbmRvd3MpIi8+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJzYXZlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDpiNThlMTlkNi0xYTRjLTQyNDEtODU0ZC01MDVlZjYxMjRhODQiIHN0RXZ0OndoZW49IjIwMTgtMTEtMTVUMTY6NDA6MjMrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAoV2luZG93cykiIHN0RXZ0OmNoYW5nZWQ9Ii8iLz4gPHJkZjpsaSBzdEV2dDphY3Rpb249InNhdmVkIiBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjJlNjJiMWM2LWIxYzQtNDk0MC04MDMxLWU4ZDkyNTBmODJjNSIgc3RFdnQ6d2hlbj0iMjAxOC0xMS0xNVQxNjo0MDo1OSswMTowMCIgc3RFdnQ6c29mdHdhcmVBZ2VudD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY29udmVydGVkIiBzdEV2dDpwYXJhbWV0ZXJzPSJmcm9tIGFwcGxpY2F0aW9uL3ZuZC5hZG9iZS5waG90b3Nob3AgdG8gaW1hZ2UvcG5nIi8+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJkZXJpdmVkIiBzdEV2dDpwYXJhbWV0ZXJzPSJjb252ZXJ0ZWQgZnJvbSBhcHBsaWNhdGlvbi92bmQuYWRvYmUucGhvdG9zaG9wIHRvIGltYWdlL3BuZyIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDE3YWRkNzYtODk2ZS04ZTRlLWJjOTEtNGYxMjYyNWIwNzI4IiBzdEV2dDp3aGVuPSIyMDE4LTExLTE1VDE2OjQwOjU5KzAxOjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgKFdpbmRvd3MpIiBzdEV2dDpjaGFuZ2VkPSIvIi8+IDwvcmRmOlNlcT4gPC94bXBNTTpIaXN0b3J5PiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDoyZTYyYjFjNi1iMWM0LTQ5NDAtODAzMS1lOGQ5MjUwZjgyYzUiIHN0UmVmOmRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDo2OWRmZjljYy01YzFiLWE5NDctOTc3OS03ODgxZjM0ODk3MDMiIHN0UmVmOm9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiLz4gPHBob3Rvc2hvcDpEb2N1bWVudEFuY2VzdG9ycz4gPHJkZjpCYWc+IDxyZGY6bGk+eG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2U8L3JkZjpsaT4gPC9yZGY6QmFnPiA8L3Bob3Rvc2hvcDpEb2N1bWVudEFuY2VzdG9ycz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5ayrctAAATYUlEQVR42u2dfVQV553Hv88AXq5uAAlJ0CBem912jQh60kZ8y0tdC5soJnoaXzC4Tdz4cjya1GN206Zqsu3Jpm6yeM5uTG3iaYGoJNFdEY3GaFGD0p4mqS9AXpoV0OZFUOHS3usFuc/+Idde8M7M8zr3gsw5HOCZZ2aemecz39/LPPMMMLAMLDG2kIFzjqmFDiDZP6AkN3gf0gEob8x2kj4MCx2AMnbb1BcVld6IwJJ+0oYb2YTT/gYq6WPHJP3gmtA+Biztr1CSKLevLytprCkh7ctQkj4KsK590hiGlsbSOcVCR5I+BC7pA6BEAzQaq1DqhFFH3Vg16TSG4KHRgNPpyFd1XdIHAyrdCkhjADgaTSiJw/VIP1BSp6GhUQSOOgmlkzASxSqq2zpQB+ClGiGlUb65tAUZOmDUAa5u5XRSgajibVRCR3VCSRyoQwSBE/EvYy3YkYGESuwrpuAkDgPJCg4RhFVUNUkMw6hK6agDcFInoSQxAqNqWHVdD6fUhQqUsfiaVCN41IlOUBEx88JIJCCU8T+tttOR6pEFUgRQXoCVrydRAJJw/G+2jig6llN+p0wnsZpYXsAoxzGognYzryeagBRRR8L5t4iCRsvflDHnIopINcCpGkzlUOoCkqWcKABdlznXZa5lTK7Z/6zlvMeXXqdTCVWoI696ygZN0YZSp/KxQCijmiJgUp3gyQBpVy4Kq4gPqhpWlQrCCxgPeLz70wqmyqcksgELS5kKQEWCIBn1FEn7qFBKKgmnajCloZQtlwWSZR0PoCJBkJMDMnT4iSxlsQCmFJQidVUASQS3ZSlXadqhWDVkTCoLiDKw8t40XOU6oFQBJMtvkSBJ1ITLqKaOgIbVF+y9jd3/omAqVUtViigTTfMAyKqqKnxOlWZcFEzVZjrSb11gaodSRiVVAikCo4hKyjzpkh3No8tf1AUmrxnXCmW0gSSCcIqki4hipbTqGNU+IwuMqsAUfSLVoywezi46gGSFU8Sk86bBKOd1oJzrwuuEQLIbBU8sfiPC37DYhuW8pEfex3NcQBUqyVrO+7edeZdNIfFCSi22oZwdSkzUk1jAaQcrGMA0O34kUJXAaAYl0aSMkRQMjODxAArGct6onPf68CgLbGCkNv4r4axrp4wwUUc7CAnDdkzXJ14SNFHVEQFNRjHtbg7ZoMfuOlHGDiG9/DPCCDgLjDBROFgon50ZV6mQ1/YVzwmgSniJhFryAMpybB4TLjJLRqTOZPUbZYIrwmiqZYC02lboXOIV0C3qm5nVZQGSSCiuaETOe5PygEg4AbXyM1lhJIxqqiWYUQklUaiShMGc2gFpBbDdcXl9StHXka38KVZ/i8V35DXzZibcClIWtRS90ZQpJa/ysZhtHiBV+pk8imm2TjTFwxsQWIHL42PaRd4iroW0ksZLKAFv5MoKbyQQVZl1mShc5LxYOo4Fxt4KyZPysXMhrOrwqKWyHGa8wiCHVSXtzDaxgYSA36xDEk4V5lvGpxRVIZb8pZ0Z571x7My6Up9S17SBhMGvjASfocCUi0TkvOaZMJh11vSPGVSEcT0s1JYyKKnu1BABQOMloeJ9ssMCg53phoKUkVDQs2MMcvNSsZICwfYufPZVB+o/86HxbAAXP/ah9Z2LuPSnAK5wqB1PLlIkmGEBkzVbwKuWolkE6ddXeYeb2akfEfwRTRnZRf89/r84Bf81NB73WtDQ+VUHKocfw1ob35J3QAXrYApq8X94edBmvVUZS9si/Qbr/wacWXgeN/LCCAHAQ+sNhvqhOiQOcNucZMKwQXh42XCkM95AELjZRFNjRCAPSxSmAbXlKXlNOlF0wj2WoqKi5Hnz5mdTGiQA8OCDDx4T6aiNGzeOufnmm5MBoKysrHbfvn3tVhf40hX8MSked1u1LUhx+e1mXGBIz1znC77xxtaJhmFQwzDo3LmPHBdJ6ezZs2cqIVf3UVt7unH16tWNsB4gwpItsPKdlSfTZd4EZH1MKKJkEX8WLfqnlPXr1/8oNTV1QQ8QgsG2pqamX+TkZG+OtP/y8jcn5efnb+nq6vKmpg7NfeONrZOmT5++3uVyZYTvp76+vjg3d8IWs2vy2DDcsunvUDrIQLrZBT3fgXduO4ZnrEx1aWlpbkHBrM0AkJyclFVZWZl3990TngpvT1dXl7e29vRLU6dOLTcxmT3+P3Hi5NLMzMwlhmEkh7fH7/cfraqqemHevLknTMy10yZci/mO2rR5GzZs2JaamrogGAy2Xbx4cWtTU9OLXq93r2EYyR6P52kLdQQAxMXFJR05cvSRGTNmvOZyuTJ8Pl+d1+utCa0fPXr0kydOnHzSzFRu+RLNM09j7qc+vHY5iIbe7Wu7gt8t+wwbGG9YAEBV1eHvT516z0uh9vj9/tpQW7Ozc54rL39zkt1Dh6+/Pl/h8XieNgwjORAInGpqanqxvb19TzAYbHO73VPz8vK2vfXW29kKUnuOLIZitYWFryjlq1RXV890uVxjAWD37oqFo0Z5fjR2bNYvRozIWLFx48b7zpw5s8EmqgYA5OTkrA8EAud2767452HD0ueOGJHxxLp16x7w+Xx1AODxeB5buXLlCDOf9d2L8H7rd3jFfQSzv/MBpjx7BrP/4yzmP1qP76W8j6U7m3HJzpoEg8Fr5ePHj1/n8/nqtmx5fe6wYemPpKffNreysnJxaP2999672sqi/eEPJ5YkJiZmAcDhw1WP3nrrLQVjx2Ztysi4ffmqVSunBAKBU4ZhJE+bNu1VDj81qosRZfVjyU0CABk6dGgmAHR2djYVFRWdCl+3du1Pzo0bl7PZDPxwCHw+X11R0aOPLFy4sCa0vrj4P8+9++7+jaE6P/jBY3NYgrTft8P3s0Y0rPkcn5R9jRaGtNR159zdnieeeuqpulBZYeGCmsbGxtcBwO12jzFT3Iceejh55MiRTwBAQ0PDzwsKCqrDj1NSUuL98MMPX+hW3pHvvXdwqoK+1jELs3KlVGHmbZPVgUBHGwAkJCRklpSUjBW9MB988PvXwwKaa3UWLVpUEwgEzgFAamrqnWYppZ+Owt8eHoeCfdmY/vYYTH43B9/76Nt4tP5uLHlrDCbyntd77x0oPnDggLd3nbNnz9aG/i4vf3NipG1XrFgxKeRD7tq1a2+k4+Tn570fDAbbAOD222/P5uwTJ9/41BJ9izaOKXVQXFxcWVxc/IxhGMmzZj20+5NPPn21vLx8+9q1Pzlrd/xwpWxtbfWawev3+//kcrkyUlJSJpi1618z8cs4guRIx/mmG34Aky2i0+si1bC29VgX1s4e7Q+vl5aWNiJUmJ2dnVlRUTGiWxUpAISi8M7OzqaQ66O4r7UM4HDyxTEpn+XXv/5V2/Tp/1CYn/+PryQkJGSmp6cvXbVq1dLFixdX19TUbJ49++Fjsvm1L774oqYbSMtcpOk6YrqOuwND6S7W/dx///0l6CdLfBQVkntZuHDhqfnz58/84Q9XP5iZmbkgMTExa8iQIZOnTZs2+fPP/2/7HXd8Y63uNrR04vitgzAt0rqvOnAADgyCjbScOXNmAyGEAoBhGNd+E4Jrqrl//77KGwlK6hSY27Zta922bdtWANsrKiomT5iQ+y+JiYlZaWlp83bs2LlvzpzZx0X3PXz48Nyr/utV3zLS8vgn+Onr3wK9ZRDuI93X7wpFW9Nl7J51GpsQpY+4jxuX8yqsHy9SxMAH5p1KCfGAq3R/BQUF1cuXLy8KOfKjRo3KipDQ7bGkpKQkmbXrpptuGg0AXq+33uyglRfQdtsxPJ15HJOL6pE/4xS+m3AY373jt3j59F/gtzn369oUUrXedQn5a3lYnR7n5fP5rvmdW7ZsyXKYHW1fVjMcbqjyLyjs2PF2W0dHx1nWHdx117cfz8vLS+q9r4MHD82Ji4tLAoDm5uY6WM/6gHMBdJZ+jfN7LqAVzn0cqceyb9871X/NZ9433+6GjCXwoqWUvJ1hCUFjY9O/19XVLSssLOwR+R469JsHQsnjy5cvtyHSY6swNRo8ePCdpaVl5WVlZbmhstLS0gnjx49fBVx9vPfssz/eEaFN17VrrQee34zDA59OwIrWKdjsvwf/uysL90TYhjKCyzPvOH3++efPtrS0bO+OxOedOHFyaaR9VldXz2hsbHpRQf9R8E05I8RFvNM+oY1Pavpik8vlykxJSSl85ZVNz7z00svvB4NBEhcXlxwG5OlJkyZuh/mLUSGTVzd48OA7Z84s+OX5883nuvd97Znz0aNH/u3gwYPeCBexRwDzq7/HXYvS8VrvE5mSjO8DOGzRCT0nc+oOTnp3bASzHrFD16xZs2HTpk1ZiYmJWR6P5+lLl1qXBAKBU6H1brd7Snh1sD2rjqqJNxw6sOzkobSqquoFv99/NHShhwwZMjkEZEtLy/Zly5YtMrubwzv40KFDL3/00UfPdXV1eV0uV0YIyEAgcK6iYtcTs2bN2m+iCD3KvuyAN1LDr1D8xSSwuFYW3p7m5mavHRQXLlxoM1FdunPnjtbly5cXNTQ0/DwYDLYZhpHsdrunhH6Aq4MyPv744yWM6kwZ1VFr7tDub7P/HR8lBIAUFRWlRBi2Fn6DXXec0CghAKisrFxcWLjgOABSVlY2MQRG92M+rhfHGnKxZmQiFgAgXRTeLzuwf+Vn+O//aUErg2ljnemMdZQOBUBLSkrGpqXdkhQCPz8/7wjYBveKjBLinenN1nIAoCpHnvNOEGD2zo0RATKrdbZvPJaXvzk5BOXevXsfnz9/Xg3jednlYsnEJAz5hhvuPRdwsfUKuhhUHzYdZjWvJAuwlBE8ltHoVnDa3UDCUKp8omM3QwPrdlb7sVuHSD5luLns/ttquhIzGCP6eMe9aD/uRTtnMAfoeSXCDkie9rGabuX+qFOPGSMFHdREgVjA6w0N7xt2PLNWUCur8ZwHnu8kYWTbFfiS4zHY3wX/nFr8llEZRGG0U1Fq4xebKR+PD6kN1mg80bEC1Awyq1dCbUG0UEpWv9sUrCcz8OOkePR4Xp79N7jr5J8RsIFSdo5yW//SQkV5VZIKmmKhaDxeEkKr90/AYM5Z1NIOFtuX4ktLS08TQhZRSklpaWkt+N+tNl28XfhjOJS+LtSf/DMuC4Aoo5i8QFKbDIFTSfbIT7M4Ah2WYEck+FH9Zh/AN+EVU6RtBuo3B2PQ1tGYlZYAT3sXvljXgMqdzWiTMN0qfEuegEVHlC38eq1IR7BOJgAOIKEATqt9mKWw7CJuFZPx83x+xA5Klq8+iAIJsL8kZrdOGso4zo5gnQhV9qsOVuMheYbYs3yvmmc9lagn+iUGarMPVsW0y5FSAUXXYuLjBXZMBLdhmU02UtBjFQzx+ps850EtoLfzpbnVgUN5VOQxWdVR9MtmUiki1Skhq3wiTIBkgRMCKR/CWM6bV+W581kHL7DkMXk+1sQKJK9VcWQEEq/5FjXhIsGF7Ddt7MDhufAqTBYFlHzuWORLYpRBSXnNtowvKaWULDN42W3D+hkNMOQhAfNEN8/stay5U5nv3/AGPLI5TFa/kgrUlb05uW7gOEF1UqWWdhOk8kS9Ks0uT3BDGbbn8Sl54VTla1qZZ542Sy9xnGkgcAAkOoMukQBT1L+TMfci7gGvOecxsSzmXTaYYTk/nuvODSVLmchH5cH5t+hMuyyjuFmdedFXGyij/waoiXhlHlOyHgsMbY5q9G3le/LOu83ywSHRNBXLY1GRtA9vwMPaqU59wVZFG6DoWkkppajS8XyHW8V3t4lEekP09VS7kTp2Ebmsvyli0kWyBSqsyHVlcYIAyviWsmASThhVBjY84wtZ9suaK5RJy4iaaNa8pVKVNINSRi11gSkSheu4o82UkAVmnhymKIgi0TnA/8hRNPKmqqHkVUsnwBR91Meqjiocd5ZASgQKFT4nT1DDA6TUdSOaymXAFEkniZp7FSOBdAU9LOkVqgBQp4BkLieKgLUqkzXvVuDx7EMEQl35URHoIAmODMAqFJIZyjjNKqriE8a8yXynAxsIdgRrp/KabxkYow6kjFKIqqjKZDnhvAFELYNO8w3Jjuc15yLmmjWoUQZlnIT5UgGmjGqyjLtUrXy6oGRRTl2QivqwrJaJG2KZ5DQvsKwmmccHZVVD2fSSLmXk6XxRSHgVU5U6iqqnFJSyYKqAU+QGiJVAh2oClUdhqeLjSgOpSjFkTbwOVRXNGEDB9aCSwFIFHa3DFZBRfi1Q6gBTFk4Rs63zGijrFIg/ylRt7lW3m6kOUagQqiJ5orFONKJtHR0ok/vUAaPKOrbRt2owZZVTJmhRDaKOYW26I1st06yoBFKmk4jD61UCShSfq1OdpTLgUDW6R8t87rqcfZ1BlMr6uq6Vjhf2owGvozDKmG9dyiQCeTSAiwXVdNIP1A2uls7QkYhW/fgzVgIeXVOe6ISFOnSOjjn+uuHsK5F2NM1hLG/jSGfpjoSdjLSJg7Cp7FjaR7ZzXEGcinBJDF8DnZ1Ho7wPrYNadHdINGCLdVMdrU6nMdimqHYgiaF2kn4IXJ8FMJY6iPRxsPqTksbc55ZJP2vHgOnuYwD2tU4k/eycaT891g0F5YDZ7qfQ3SidTAZgG4By4FwHgBtYBpYbZ/l/2EJnC9N0gaQAAAAASUVORK5CYII=";
  8916. return LoadingScreen;
  8917. }());
  8918. webgl.LoadingScreen = LoadingScreen;
  8919. })(webgl = spine.webgl || (spine.webgl = {}));
  8920. })(spine || (spine = {}));
  8921. var spine;
  8922. (function (spine) {
  8923. var webgl;
  8924. (function (webgl) {
  8925. webgl.M00 = 0;
  8926. webgl.M01 = 4;
  8927. webgl.M02 = 8;
  8928. webgl.M03 = 12;
  8929. webgl.M10 = 1;
  8930. webgl.M11 = 5;
  8931. webgl.M12 = 9;
  8932. webgl.M13 = 13;
  8933. webgl.M20 = 2;
  8934. webgl.M21 = 6;
  8935. webgl.M22 = 10;
  8936. webgl.M23 = 14;
  8937. webgl.M30 = 3;
  8938. webgl.M31 = 7;
  8939. webgl.M32 = 11;
  8940. webgl.M33 = 15;
  8941. var Matrix4 = (function () {
  8942. function Matrix4() {
  8943. this.temp = new Float32Array(16);
  8944. this.values = new Float32Array(16);
  8945. var v = this.values;
  8946. v[webgl.M00] = 1;
  8947. v[webgl.M11] = 1;
  8948. v[webgl.M22] = 1;
  8949. v[webgl.M33] = 1;
  8950. }
  8951. Matrix4.prototype.set = function (values) {
  8952. this.values.set(values);
  8953. return this;
  8954. };
  8955. Matrix4.prototype.transpose = function () {
  8956. var t = this.temp;
  8957. var v = this.values;
  8958. t[webgl.M00] = v[webgl.M00];
  8959. t[webgl.M01] = v[webgl.M10];
  8960. t[webgl.M02] = v[webgl.M20];
  8961. t[webgl.M03] = v[webgl.M30];
  8962. t[webgl.M10] = v[webgl.M01];
  8963. t[webgl.M11] = v[webgl.M11];
  8964. t[webgl.M12] = v[webgl.M21];
  8965. t[webgl.M13] = v[webgl.M31];
  8966. t[webgl.M20] = v[webgl.M02];
  8967. t[webgl.M21] = v[webgl.M12];
  8968. t[webgl.M22] = v[webgl.M22];
  8969. t[webgl.M23] = v[webgl.M32];
  8970. t[webgl.M30] = v[webgl.M03];
  8971. t[webgl.M31] = v[webgl.M13];
  8972. t[webgl.M32] = v[webgl.M23];
  8973. t[webgl.M33] = v[webgl.M33];
  8974. return this.set(t);
  8975. };
  8976. Matrix4.prototype.identity = function () {
  8977. var v = this.values;
  8978. v[webgl.M00] = 1;
  8979. v[webgl.M01] = 0;
  8980. v[webgl.M02] = 0;
  8981. v[webgl.M03] = 0;
  8982. v[webgl.M10] = 0;
  8983. v[webgl.M11] = 1;
  8984. v[webgl.M12] = 0;
  8985. v[webgl.M13] = 0;
  8986. v[webgl.M20] = 0;
  8987. v[webgl.M21] = 0;
  8988. v[webgl.M22] = 1;
  8989. v[webgl.M23] = 0;
  8990. v[webgl.M30] = 0;
  8991. v[webgl.M31] = 0;
  8992. v[webgl.M32] = 0;
  8993. v[webgl.M33] = 1;
  8994. return this;
  8995. };
  8996. Matrix4.prototype.invert = function () {
  8997. var v = this.values;
  8998. var t = this.temp;
  8999. var l_det = v[webgl.M30] * v[webgl.M21] * v[webgl.M12] * v[webgl.M03] - v[webgl.M20] * v[webgl.M31] * v[webgl.M12] * v[webgl.M03] - v[webgl.M30] * v[webgl.M11] * v[webgl.M22] * v[webgl.M03]
  9000. + v[webgl.M10] * v[webgl.M31] * v[webgl.M22] * v[webgl.M03] + v[webgl.M20] * v[webgl.M11] * v[webgl.M32] * v[webgl.M03] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32] * v[webgl.M03]
  9001. - v[webgl.M30] * v[webgl.M21] * v[webgl.M02] * v[webgl.M13] + v[webgl.M20] * v[webgl.M31] * v[webgl.M02] * v[webgl.M13] + v[webgl.M30] * v[webgl.M01] * v[webgl.M22] * v[webgl.M13]
  9002. - v[webgl.M00] * v[webgl.M31] * v[webgl.M22] * v[webgl.M13] - v[webgl.M20] * v[webgl.M01] * v[webgl.M32] * v[webgl.M13] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32] * v[webgl.M13]
  9003. + v[webgl.M30] * v[webgl.M11] * v[webgl.M02] * v[webgl.M23] - v[webgl.M10] * v[webgl.M31] * v[webgl.M02] * v[webgl.M23] - v[webgl.M30] * v[webgl.M01] * v[webgl.M12] * v[webgl.M23]
  9004. + v[webgl.M00] * v[webgl.M31] * v[webgl.M12] * v[webgl.M23] + v[webgl.M10] * v[webgl.M01] * v[webgl.M32] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32] * v[webgl.M23]
  9005. - v[webgl.M20] * v[webgl.M11] * v[webgl.M02] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M02] * v[webgl.M33] + v[webgl.M20] * v[webgl.M01] * v[webgl.M12] * v[webgl.M33]
  9006. - v[webgl.M00] * v[webgl.M21] * v[webgl.M12] * v[webgl.M33] - v[webgl.M10] * v[webgl.M01] * v[webgl.M22] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22] * v[webgl.M33];
  9007. if (l_det == 0)
  9008. throw new Error("non-invertible matrix");
  9009. var inv_det = 1.0 / l_det;
  9010. t[webgl.M00] = v[webgl.M12] * v[webgl.M23] * v[webgl.M31] - v[webgl.M13] * v[webgl.M22] * v[webgl.M31] + v[webgl.M13] * v[webgl.M21] * v[webgl.M32]
  9011. - v[webgl.M11] * v[webgl.M23] * v[webgl.M32] - v[webgl.M12] * v[webgl.M21] * v[webgl.M33] + v[webgl.M11] * v[webgl.M22] * v[webgl.M33];
  9012. t[webgl.M01] = v[webgl.M03] * v[webgl.M22] * v[webgl.M31] - v[webgl.M02] * v[webgl.M23] * v[webgl.M31] - v[webgl.M03] * v[webgl.M21] * v[webgl.M32]
  9013. + v[webgl.M01] * v[webgl.M23] * v[webgl.M32] + v[webgl.M02] * v[webgl.M21] * v[webgl.M33] - v[webgl.M01] * v[webgl.M22] * v[webgl.M33];
  9014. t[webgl.M02] = v[webgl.M02] * v[webgl.M13] * v[webgl.M31] - v[webgl.M03] * v[webgl.M12] * v[webgl.M31] + v[webgl.M03] * v[webgl.M11] * v[webgl.M32]
  9015. - v[webgl.M01] * v[webgl.M13] * v[webgl.M32] - v[webgl.M02] * v[webgl.M11] * v[webgl.M33] + v[webgl.M01] * v[webgl.M12] * v[webgl.M33];
  9016. t[webgl.M03] = v[webgl.M03] * v[webgl.M12] * v[webgl.M21] - v[webgl.M02] * v[webgl.M13] * v[webgl.M21] - v[webgl.M03] * v[webgl.M11] * v[webgl.M22]
  9017. + v[webgl.M01] * v[webgl.M13] * v[webgl.M22] + v[webgl.M02] * v[webgl.M11] * v[webgl.M23] - v[webgl.M01] * v[webgl.M12] * v[webgl.M23];
  9018. t[webgl.M10] = v[webgl.M13] * v[webgl.M22] * v[webgl.M30] - v[webgl.M12] * v[webgl.M23] * v[webgl.M30] - v[webgl.M13] * v[webgl.M20] * v[webgl.M32]
  9019. + v[webgl.M10] * v[webgl.M23] * v[webgl.M32] + v[webgl.M12] * v[webgl.M20] * v[webgl.M33] - v[webgl.M10] * v[webgl.M22] * v[webgl.M33];
  9020. t[webgl.M11] = v[webgl.M02] * v[webgl.M23] * v[webgl.M30] - v[webgl.M03] * v[webgl.M22] * v[webgl.M30] + v[webgl.M03] * v[webgl.M20] * v[webgl.M32]
  9021. - v[webgl.M00] * v[webgl.M23] * v[webgl.M32] - v[webgl.M02] * v[webgl.M20] * v[webgl.M33] + v[webgl.M00] * v[webgl.M22] * v[webgl.M33];
  9022. t[webgl.M12] = v[webgl.M03] * v[webgl.M12] * v[webgl.M30] - v[webgl.M02] * v[webgl.M13] * v[webgl.M30] - v[webgl.M03] * v[webgl.M10] * v[webgl.M32]
  9023. + v[webgl.M00] * v[webgl.M13] * v[webgl.M32] + v[webgl.M02] * v[webgl.M10] * v[webgl.M33] - v[webgl.M00] * v[webgl.M12] * v[webgl.M33];
  9024. t[webgl.M13] = v[webgl.M02] * v[webgl.M13] * v[webgl.M20] - v[webgl.M03] * v[webgl.M12] * v[webgl.M20] + v[webgl.M03] * v[webgl.M10] * v[webgl.M22]
  9025. - v[webgl.M00] * v[webgl.M13] * v[webgl.M22] - v[webgl.M02] * v[webgl.M10] * v[webgl.M23] + v[webgl.M00] * v[webgl.M12] * v[webgl.M23];
  9026. t[webgl.M20] = v[webgl.M11] * v[webgl.M23] * v[webgl.M30] - v[webgl.M13] * v[webgl.M21] * v[webgl.M30] + v[webgl.M13] * v[webgl.M20] * v[webgl.M31]
  9027. - v[webgl.M10] * v[webgl.M23] * v[webgl.M31] - v[webgl.M11] * v[webgl.M20] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M33];
  9028. t[webgl.M21] = v[webgl.M03] * v[webgl.M21] * v[webgl.M30] - v[webgl.M01] * v[webgl.M23] * v[webgl.M30] - v[webgl.M03] * v[webgl.M20] * v[webgl.M31]
  9029. + v[webgl.M00] * v[webgl.M23] * v[webgl.M31] + v[webgl.M01] * v[webgl.M20] * v[webgl.M33] - v[webgl.M00] * v[webgl.M21] * v[webgl.M33];
  9030. t[webgl.M22] = v[webgl.M01] * v[webgl.M13] * v[webgl.M30] - v[webgl.M03] * v[webgl.M11] * v[webgl.M30] + v[webgl.M03] * v[webgl.M10] * v[webgl.M31]
  9031. - v[webgl.M00] * v[webgl.M13] * v[webgl.M31] - v[webgl.M01] * v[webgl.M10] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M33];
  9032. t[webgl.M23] = v[webgl.M03] * v[webgl.M11] * v[webgl.M20] - v[webgl.M01] * v[webgl.M13] * v[webgl.M20] - v[webgl.M03] * v[webgl.M10] * v[webgl.M21]
  9033. + v[webgl.M00] * v[webgl.M13] * v[webgl.M21] + v[webgl.M01] * v[webgl.M10] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M23];
  9034. t[webgl.M30] = v[webgl.M12] * v[webgl.M21] * v[webgl.M30] - v[webgl.M11] * v[webgl.M22] * v[webgl.M30] - v[webgl.M12] * v[webgl.M20] * v[webgl.M31]
  9035. + v[webgl.M10] * v[webgl.M22] * v[webgl.M31] + v[webgl.M11] * v[webgl.M20] * v[webgl.M32] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32];
  9036. t[webgl.M31] = v[webgl.M01] * v[webgl.M22] * v[webgl.M30] - v[webgl.M02] * v[webgl.M21] * v[webgl.M30] + v[webgl.M02] * v[webgl.M20] * v[webgl.M31]
  9037. - v[webgl.M00] * v[webgl.M22] * v[webgl.M31] - v[webgl.M01] * v[webgl.M20] * v[webgl.M32] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32];
  9038. t[webgl.M32] = v[webgl.M02] * v[webgl.M11] * v[webgl.M30] - v[webgl.M01] * v[webgl.M12] * v[webgl.M30] - v[webgl.M02] * v[webgl.M10] * v[webgl.M31]
  9039. + v[webgl.M00] * v[webgl.M12] * v[webgl.M31] + v[webgl.M01] * v[webgl.M10] * v[webgl.M32] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32];
  9040. t[webgl.M33] = v[webgl.M01] * v[webgl.M12] * v[webgl.M20] - v[webgl.M02] * v[webgl.M11] * v[webgl.M20] + v[webgl.M02] * v[webgl.M10] * v[webgl.M21]
  9041. - v[webgl.M00] * v[webgl.M12] * v[webgl.M21] - v[webgl.M01] * v[webgl.M10] * v[webgl.M22] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22];
  9042. v[webgl.M00] = t[webgl.M00] * inv_det;
  9043. v[webgl.M01] = t[webgl.M01] * inv_det;
  9044. v[webgl.M02] = t[webgl.M02] * inv_det;
  9045. v[webgl.M03] = t[webgl.M03] * inv_det;
  9046. v[webgl.M10] = t[webgl.M10] * inv_det;
  9047. v[webgl.M11] = t[webgl.M11] * inv_det;
  9048. v[webgl.M12] = t[webgl.M12] * inv_det;
  9049. v[webgl.M13] = t[webgl.M13] * inv_det;
  9050. v[webgl.M20] = t[webgl.M20] * inv_det;
  9051. v[webgl.M21] = t[webgl.M21] * inv_det;
  9052. v[webgl.M22] = t[webgl.M22] * inv_det;
  9053. v[webgl.M23] = t[webgl.M23] * inv_det;
  9054. v[webgl.M30] = t[webgl.M30] * inv_det;
  9055. v[webgl.M31] = t[webgl.M31] * inv_det;
  9056. v[webgl.M32] = t[webgl.M32] * inv_det;
  9057. v[webgl.M33] = t[webgl.M33] * inv_det;
  9058. return this;
  9059. };
  9060. Matrix4.prototype.determinant = function () {
  9061. var v = this.values;
  9062. return v[webgl.M30] * v[webgl.M21] * v[webgl.M12] * v[webgl.M03] - v[webgl.M20] * v[webgl.M31] * v[webgl.M12] * v[webgl.M03] - v[webgl.M30] * v[webgl.M11] * v[webgl.M22] * v[webgl.M03]
  9063. + v[webgl.M10] * v[webgl.M31] * v[webgl.M22] * v[webgl.M03] + v[webgl.M20] * v[webgl.M11] * v[webgl.M32] * v[webgl.M03] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32] * v[webgl.M03]
  9064. - v[webgl.M30] * v[webgl.M21] * v[webgl.M02] * v[webgl.M13] + v[webgl.M20] * v[webgl.M31] * v[webgl.M02] * v[webgl.M13] + v[webgl.M30] * v[webgl.M01] * v[webgl.M22] * v[webgl.M13]
  9065. - v[webgl.M00] * v[webgl.M31] * v[webgl.M22] * v[webgl.M13] - v[webgl.M20] * v[webgl.M01] * v[webgl.M32] * v[webgl.M13] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32] * v[webgl.M13]
  9066. + v[webgl.M30] * v[webgl.M11] * v[webgl.M02] * v[webgl.M23] - v[webgl.M10] * v[webgl.M31] * v[webgl.M02] * v[webgl.M23] - v[webgl.M30] * v[webgl.M01] * v[webgl.M12] * v[webgl.M23]
  9067. + v[webgl.M00] * v[webgl.M31] * v[webgl.M12] * v[webgl.M23] + v[webgl.M10] * v[webgl.M01] * v[webgl.M32] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32] * v[webgl.M23]
  9068. - v[webgl.M20] * v[webgl.M11] * v[webgl.M02] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M02] * v[webgl.M33] + v[webgl.M20] * v[webgl.M01] * v[webgl.M12] * v[webgl.M33]
  9069. - v[webgl.M00] * v[webgl.M21] * v[webgl.M12] * v[webgl.M33] - v[webgl.M10] * v[webgl.M01] * v[webgl.M22] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22] * v[webgl.M33];
  9070. };
  9071. Matrix4.prototype.translate = function (x, y, z) {
  9072. var v = this.values;
  9073. v[webgl.M03] += x;
  9074. v[webgl.M13] += y;
  9075. v[webgl.M23] += z;
  9076. return this;
  9077. };
  9078. Matrix4.prototype.copy = function () {
  9079. return new Matrix4().set(this.values);
  9080. };
  9081. Matrix4.prototype.projection = function (near, far, fovy, aspectRatio) {
  9082. this.identity();
  9083. var l_fd = (1.0 / Math.tan((fovy * (Math.PI / 180)) / 2.0));
  9084. var l_a1 = (far + near) / (near - far);
  9085. var l_a2 = (2 * far * near) / (near - far);
  9086. var v = this.values;
  9087. v[webgl.M00] = l_fd / aspectRatio;
  9088. v[webgl.M10] = 0;
  9089. v[webgl.M20] = 0;
  9090. v[webgl.M30] = 0;
  9091. v[webgl.M01] = 0;
  9092. v[webgl.M11] = l_fd;
  9093. v[webgl.M21] = 0;
  9094. v[webgl.M31] = 0;
  9095. v[webgl.M02] = 0;
  9096. v[webgl.M12] = 0;
  9097. v[webgl.M22] = l_a1;
  9098. v[webgl.M32] = -1;
  9099. v[webgl.M03] = 0;
  9100. v[webgl.M13] = 0;
  9101. v[webgl.M23] = l_a2;
  9102. v[webgl.M33] = 0;
  9103. return this;
  9104. };
  9105. Matrix4.prototype.ortho2d = function (x, y, width, height) {
  9106. return this.ortho(x, x + width, y, y + height, 0, 1);
  9107. };
  9108. Matrix4.prototype.ortho = function (left, right, bottom, top, near, far) {
  9109. this.identity();
  9110. var x_orth = 2 / (right - left);
  9111. var y_orth = 2 / (top - bottom);
  9112. var z_orth = -2 / (far - near);
  9113. var tx = -(right + left) / (right - left);
  9114. var ty = -(top + bottom) / (top - bottom);
  9115. var tz = -(far + near) / (far - near);
  9116. var v = this.values;
  9117. v[webgl.M00] = x_orth;
  9118. v[webgl.M10] = 0;
  9119. v[webgl.M20] = 0;
  9120. v[webgl.M30] = 0;
  9121. v[webgl.M01] = 0;
  9122. v[webgl.M11] = y_orth;
  9123. v[webgl.M21] = 0;
  9124. v[webgl.M31] = 0;
  9125. v[webgl.M02] = 0;
  9126. v[webgl.M12] = 0;
  9127. v[webgl.M22] = z_orth;
  9128. v[webgl.M32] = 0;
  9129. v[webgl.M03] = tx;
  9130. v[webgl.M13] = ty;
  9131. v[webgl.M23] = tz;
  9132. v[webgl.M33] = 1;
  9133. return this;
  9134. };
  9135. Matrix4.prototype.multiply = function (matrix) {
  9136. var t = this.temp;
  9137. var v = this.values;
  9138. var m = matrix.values;
  9139. t[webgl.M00] = v[webgl.M00] * m[webgl.M00] + v[webgl.M01] * m[webgl.M10] + v[webgl.M02] * m[webgl.M20] + v[webgl.M03] * m[webgl.M30];
  9140. t[webgl.M01] = v[webgl.M00] * m[webgl.M01] + v[webgl.M01] * m[webgl.M11] + v[webgl.M02] * m[webgl.M21] + v[webgl.M03] * m[webgl.M31];
  9141. t[webgl.M02] = v[webgl.M00] * m[webgl.M02] + v[webgl.M01] * m[webgl.M12] + v[webgl.M02] * m[webgl.M22] + v[webgl.M03] * m[webgl.M32];
  9142. t[webgl.M03] = v[webgl.M00] * m[webgl.M03] + v[webgl.M01] * m[webgl.M13] + v[webgl.M02] * m[webgl.M23] + v[webgl.M03] * m[webgl.M33];
  9143. t[webgl.M10] = v[webgl.M10] * m[webgl.M00] + v[webgl.M11] * m[webgl.M10] + v[webgl.M12] * m[webgl.M20] + v[webgl.M13] * m[webgl.M30];
  9144. t[webgl.M11] = v[webgl.M10] * m[webgl.M01] + v[webgl.M11] * m[webgl.M11] + v[webgl.M12] * m[webgl.M21] + v[webgl.M13] * m[webgl.M31];
  9145. t[webgl.M12] = v[webgl.M10] * m[webgl.M02] + v[webgl.M11] * m[webgl.M12] + v[webgl.M12] * m[webgl.M22] + v[webgl.M13] * m[webgl.M32];
  9146. t[webgl.M13] = v[webgl.M10] * m[webgl.M03] + v[webgl.M11] * m[webgl.M13] + v[webgl.M12] * m[webgl.M23] + v[webgl.M13] * m[webgl.M33];
  9147. t[webgl.M20] = v[webgl.M20] * m[webgl.M00] + v[webgl.M21] * m[webgl.M10] + v[webgl.M22] * m[webgl.M20] + v[webgl.M23] * m[webgl.M30];
  9148. t[webgl.M21] = v[webgl.M20] * m[webgl.M01] + v[webgl.M21] * m[webgl.M11] + v[webgl.M22] * m[webgl.M21] + v[webgl.M23] * m[webgl.M31];
  9149. t[webgl.M22] = v[webgl.M20] * m[webgl.M02] + v[webgl.M21] * m[webgl.M12] + v[webgl.M22] * m[webgl.M22] + v[webgl.M23] * m[webgl.M32];
  9150. t[webgl.M23] = v[webgl.M20] * m[webgl.M03] + v[webgl.M21] * m[webgl.M13] + v[webgl.M22] * m[webgl.M23] + v[webgl.M23] * m[webgl.M33];
  9151. t[webgl.M30] = v[webgl.M30] * m[webgl.M00] + v[webgl.M31] * m[webgl.M10] + v[webgl.M32] * m[webgl.M20] + v[webgl.M33] * m[webgl.M30];
  9152. t[webgl.M31] = v[webgl.M30] * m[webgl.M01] + v[webgl.M31] * m[webgl.M11] + v[webgl.M32] * m[webgl.M21] + v[webgl.M33] * m[webgl.M31];
  9153. t[webgl.M32] = v[webgl.M30] * m[webgl.M02] + v[webgl.M31] * m[webgl.M12] + v[webgl.M32] * m[webgl.M22] + v[webgl.M33] * m[webgl.M32];
  9154. t[webgl.M33] = v[webgl.M30] * m[webgl.M03] + v[webgl.M31] * m[webgl.M13] + v[webgl.M32] * m[webgl.M23] + v[webgl.M33] * m[webgl.M33];
  9155. return this.set(this.temp);
  9156. };
  9157. Matrix4.prototype.multiplyLeft = function (matrix) {
  9158. var t = this.temp;
  9159. var v = this.values;
  9160. var m = matrix.values;
  9161. t[webgl.M00] = m[webgl.M00] * v[webgl.M00] + m[webgl.M01] * v[webgl.M10] + m[webgl.M02] * v[webgl.M20] + m[webgl.M03] * v[webgl.M30];
  9162. t[webgl.M01] = m[webgl.M00] * v[webgl.M01] + m[webgl.M01] * v[webgl.M11] + m[webgl.M02] * v[webgl.M21] + m[webgl.M03] * v[webgl.M31];
  9163. t[webgl.M02] = m[webgl.M00] * v[webgl.M02] + m[webgl.M01] * v[webgl.M12] + m[webgl.M02] * v[webgl.M22] + m[webgl.M03] * v[webgl.M32];
  9164. t[webgl.M03] = m[webgl.M00] * v[webgl.M03] + m[webgl.M01] * v[webgl.M13] + m[webgl.M02] * v[webgl.M23] + m[webgl.M03] * v[webgl.M33];
  9165. t[webgl.M10] = m[webgl.M10] * v[webgl.M00] + m[webgl.M11] * v[webgl.M10] + m[webgl.M12] * v[webgl.M20] + m[webgl.M13] * v[webgl.M30];
  9166. t[webgl.M11] = m[webgl.M10] * v[webgl.M01] + m[webgl.M11] * v[webgl.M11] + m[webgl.M12] * v[webgl.M21] + m[webgl.M13] * v[webgl.M31];
  9167. t[webgl.M12] = m[webgl.M10] * v[webgl.M02] + m[webgl.M11] * v[webgl.M12] + m[webgl.M12] * v[webgl.M22] + m[webgl.M13] * v[webgl.M32];
  9168. t[webgl.M13] = m[webgl.M10] * v[webgl.M03] + m[webgl.M11] * v[webgl.M13] + m[webgl.M12] * v[webgl.M23] + m[webgl.M13] * v[webgl.M33];
  9169. t[webgl.M20] = m[webgl.M20] * v[webgl.M00] + m[webgl.M21] * v[webgl.M10] + m[webgl.M22] * v[webgl.M20] + m[webgl.M23] * v[webgl.M30];
  9170. t[webgl.M21] = m[webgl.M20] * v[webgl.M01] + m[webgl.M21] * v[webgl.M11] + m[webgl.M22] * v[webgl.M21] + m[webgl.M23] * v[webgl.M31];
  9171. t[webgl.M22] = m[webgl.M20] * v[webgl.M02] + m[webgl.M21] * v[webgl.M12] + m[webgl.M22] * v[webgl.M22] + m[webgl.M23] * v[webgl.M32];
  9172. t[webgl.M23] = m[webgl.M20] * v[webgl.M03] + m[webgl.M21] * v[webgl.M13] + m[webgl.M22] * v[webgl.M23] + m[webgl.M23] * v[webgl.M33];
  9173. t[webgl.M30] = m[webgl.M30] * v[webgl.M00] + m[webgl.M31] * v[webgl.M10] + m[webgl.M32] * v[webgl.M20] + m[webgl.M33] * v[webgl.M30];
  9174. t[webgl.M31] = m[webgl.M30] * v[webgl.M01] + m[webgl.M31] * v[webgl.M11] + m[webgl.M32] * v[webgl.M21] + m[webgl.M33] * v[webgl.M31];
  9175. t[webgl.M32] = m[webgl.M30] * v[webgl.M02] + m[webgl.M31] * v[webgl.M12] + m[webgl.M32] * v[webgl.M22] + m[webgl.M33] * v[webgl.M32];
  9176. t[webgl.M33] = m[webgl.M30] * v[webgl.M03] + m[webgl.M31] * v[webgl.M13] + m[webgl.M32] * v[webgl.M23] + m[webgl.M33] * v[webgl.M33];
  9177. return this.set(this.temp);
  9178. };
  9179. Matrix4.prototype.lookAt = function (position, direction, up) {
  9180. Matrix4.initTemps();
  9181. var xAxis = Matrix4.xAxis, yAxis = Matrix4.yAxis, zAxis = Matrix4.zAxis;
  9182. zAxis.setFrom(direction).normalize();
  9183. xAxis.setFrom(direction).normalize();
  9184. xAxis.cross(up).normalize();
  9185. yAxis.setFrom(xAxis).cross(zAxis).normalize();
  9186. this.identity();
  9187. var val = this.values;
  9188. val[webgl.M00] = xAxis.x;
  9189. val[webgl.M01] = xAxis.y;
  9190. val[webgl.M02] = xAxis.z;
  9191. val[webgl.M10] = yAxis.x;
  9192. val[webgl.M11] = yAxis.y;
  9193. val[webgl.M12] = yAxis.z;
  9194. val[webgl.M20] = -zAxis.x;
  9195. val[webgl.M21] = -zAxis.y;
  9196. val[webgl.M22] = -zAxis.z;
  9197. Matrix4.tmpMatrix.identity();
  9198. Matrix4.tmpMatrix.values[webgl.M03] = -position.x;
  9199. Matrix4.tmpMatrix.values[webgl.M13] = -position.y;
  9200. Matrix4.tmpMatrix.values[webgl.M23] = -position.z;
  9201. this.multiply(Matrix4.tmpMatrix);
  9202. return this;
  9203. };
  9204. Matrix4.initTemps = function () {
  9205. if (Matrix4.xAxis === null)
  9206. Matrix4.xAxis = new webgl.Vector3();
  9207. if (Matrix4.yAxis === null)
  9208. Matrix4.yAxis = new webgl.Vector3();
  9209. if (Matrix4.zAxis === null)
  9210. Matrix4.zAxis = new webgl.Vector3();
  9211. };
  9212. Matrix4.xAxis = null;
  9213. Matrix4.yAxis = null;
  9214. Matrix4.zAxis = null;
  9215. Matrix4.tmpMatrix = new Matrix4();
  9216. return Matrix4;
  9217. }());
  9218. webgl.Matrix4 = Matrix4;
  9219. })(webgl = spine.webgl || (spine.webgl = {}));
  9220. })(spine || (spine = {}));
  9221. var spine;
  9222. (function (spine) {
  9223. var webgl;
  9224. (function (webgl) {
  9225. var Mesh = (function () {
  9226. function Mesh(context, attributes, maxVertices, maxIndices) {
  9227. this.attributes = attributes;
  9228. this.verticesLength = 0;
  9229. this.dirtyVertices = false;
  9230. this.indicesLength = 0;
  9231. this.dirtyIndices = false;
  9232. this.elementsPerVertex = 0;
  9233. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  9234. this.elementsPerVertex = 0;
  9235. for (var i = 0; i < attributes.length; i++) {
  9236. this.elementsPerVertex += attributes[i].numElements;
  9237. }
  9238. this.vertices = new Float32Array(maxVertices * this.elementsPerVertex);
  9239. this.indices = new Uint16Array(maxIndices);
  9240. this.context.addRestorable(this);
  9241. }
  9242. Mesh.prototype.getAttributes = function () { return this.attributes; };
  9243. Mesh.prototype.maxVertices = function () { return this.vertices.length / this.elementsPerVertex; };
  9244. Mesh.prototype.numVertices = function () { return this.verticesLength / this.elementsPerVertex; };
  9245. Mesh.prototype.setVerticesLength = function (length) {
  9246. this.dirtyVertices = true;
  9247. this.verticesLength = length;
  9248. };
  9249. Mesh.prototype.getVertices = function () { return this.vertices; };
  9250. Mesh.prototype.maxIndices = function () { return this.indices.length; };
  9251. Mesh.prototype.numIndices = function () { return this.indicesLength; };
  9252. Mesh.prototype.setIndicesLength = function (length) {
  9253. this.dirtyIndices = true;
  9254. this.indicesLength = length;
  9255. };
  9256. Mesh.prototype.getIndices = function () { return this.indices; };
  9257. ;
  9258. Mesh.prototype.getVertexSizeInFloats = function () {
  9259. var size = 0;
  9260. for (var i = 0; i < this.attributes.length; i++) {
  9261. var attribute = this.attributes[i];
  9262. size += attribute.numElements;
  9263. }
  9264. return size;
  9265. };
  9266. Mesh.prototype.setVertices = function (vertices) {
  9267. this.dirtyVertices = true;
  9268. if (vertices.length > this.vertices.length)
  9269. throw Error("Mesh can't store more than " + this.maxVertices() + " vertices");
  9270. this.vertices.set(vertices, 0);
  9271. this.verticesLength = vertices.length;
  9272. };
  9273. Mesh.prototype.setIndices = function (indices) {
  9274. this.dirtyIndices = true;
  9275. if (indices.length > this.indices.length)
  9276. throw Error("Mesh can't store more than " + this.maxIndices() + " indices");
  9277. this.indices.set(indices, 0);
  9278. this.indicesLength = indices.length;
  9279. };
  9280. Mesh.prototype.draw = function (shader, primitiveType) {
  9281. this.drawWithOffset(shader, primitiveType, 0, this.indicesLength > 0 ? this.indicesLength : this.verticesLength / this.elementsPerVertex);
  9282. };
  9283. Mesh.prototype.drawWithOffset = function (shader, primitiveType, offset, count) {
  9284. var gl = this.context.gl;
  9285. if (this.dirtyVertices || this.dirtyIndices)
  9286. this.update();
  9287. this.bind(shader);
  9288. if (this.indicesLength > 0) {
  9289. gl.drawElements(primitiveType, count, gl.UNSIGNED_SHORT, offset * 2);
  9290. }
  9291. else {
  9292. gl.drawArrays(primitiveType, offset, count);
  9293. }
  9294. this.unbind(shader);
  9295. };
  9296. Mesh.prototype.bind = function (shader) {
  9297. var gl = this.context.gl;
  9298. gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);
  9299. var offset = 0;
  9300. for (var i = 0; i < this.attributes.length; i++) {
  9301. var attrib = this.attributes[i];
  9302. var location_1 = shader.getAttributeLocation(attrib.name);
  9303. gl.enableVertexAttribArray(location_1);
  9304. gl.vertexAttribPointer(location_1, attrib.numElements, gl.FLOAT, false, this.elementsPerVertex * 4, offset * 4);
  9305. offset += attrib.numElements;
  9306. }
  9307. if (this.indicesLength > 0)
  9308. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
  9309. };
  9310. Mesh.prototype.unbind = function (shader) {
  9311. var gl = this.context.gl;
  9312. for (var i = 0; i < this.attributes.length; i++) {
  9313. var attrib = this.attributes[i];
  9314. var location_2 = shader.getAttributeLocation(attrib.name);
  9315. gl.disableVertexAttribArray(location_2);
  9316. }
  9317. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  9318. if (this.indicesLength > 0)
  9319. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
  9320. };
  9321. Mesh.prototype.update = function () {
  9322. var gl = this.context.gl;
  9323. if (this.dirtyVertices) {
  9324. if (!this.verticesBuffer) {
  9325. this.verticesBuffer = gl.createBuffer();
  9326. }
  9327. gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);
  9328. gl.bufferData(gl.ARRAY_BUFFER, this.vertices.subarray(0, this.verticesLength), gl.DYNAMIC_DRAW);
  9329. this.dirtyVertices = false;
  9330. }
  9331. if (this.dirtyIndices) {
  9332. if (!this.indicesBuffer) {
  9333. this.indicesBuffer = gl.createBuffer();
  9334. }
  9335. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
  9336. gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices.subarray(0, this.indicesLength), gl.DYNAMIC_DRAW);
  9337. this.dirtyIndices = false;
  9338. }
  9339. };
  9340. Mesh.prototype.restore = function () {
  9341. this.verticesBuffer = null;
  9342. this.indicesBuffer = null;
  9343. this.update();
  9344. };
  9345. Mesh.prototype.dispose = function () {
  9346. this.context.removeRestorable(this);
  9347. var gl = this.context.gl;
  9348. gl.deleteBuffer(this.verticesBuffer);
  9349. gl.deleteBuffer(this.indicesBuffer);
  9350. };
  9351. return Mesh;
  9352. }());
  9353. webgl.Mesh = Mesh;
  9354. var VertexAttribute = (function () {
  9355. function VertexAttribute(name, type, numElements) {
  9356. this.name = name;
  9357. this.type = type;
  9358. this.numElements = numElements;
  9359. }
  9360. return VertexAttribute;
  9361. }());
  9362. webgl.VertexAttribute = VertexAttribute;
  9363. var Position2Attribute = (function (_super) {
  9364. __extends(Position2Attribute, _super);
  9365. function Position2Attribute() {
  9366. return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 2) || this;
  9367. }
  9368. return Position2Attribute;
  9369. }(VertexAttribute));
  9370. webgl.Position2Attribute = Position2Attribute;
  9371. var Position3Attribute = (function (_super) {
  9372. __extends(Position3Attribute, _super);
  9373. function Position3Attribute() {
  9374. return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 3) || this;
  9375. }
  9376. return Position3Attribute;
  9377. }(VertexAttribute));
  9378. webgl.Position3Attribute = Position3Attribute;
  9379. var TexCoordAttribute = (function (_super) {
  9380. __extends(TexCoordAttribute, _super);
  9381. function TexCoordAttribute(unit) {
  9382. if (unit === void 0) { unit = 0; }
  9383. return _super.call(this, webgl.Shader.TEXCOORDS + (unit == 0 ? "" : unit), VertexAttributeType.Float, 2) || this;
  9384. }
  9385. return TexCoordAttribute;
  9386. }(VertexAttribute));
  9387. webgl.TexCoordAttribute = TexCoordAttribute;
  9388. var ColorAttribute = (function (_super) {
  9389. __extends(ColorAttribute, _super);
  9390. function ColorAttribute() {
  9391. return _super.call(this, webgl.Shader.COLOR, VertexAttributeType.Float, 4) || this;
  9392. }
  9393. return ColorAttribute;
  9394. }(VertexAttribute));
  9395. webgl.ColorAttribute = ColorAttribute;
  9396. var Color2Attribute = (function (_super) {
  9397. __extends(Color2Attribute, _super);
  9398. function Color2Attribute() {
  9399. return _super.call(this, webgl.Shader.COLOR2, VertexAttributeType.Float, 4) || this;
  9400. }
  9401. return Color2Attribute;
  9402. }(VertexAttribute));
  9403. webgl.Color2Attribute = Color2Attribute;
  9404. var VertexAttributeType;
  9405. (function (VertexAttributeType) {
  9406. VertexAttributeType[VertexAttributeType["Float"] = 0] = "Float";
  9407. })(VertexAttributeType = webgl.VertexAttributeType || (webgl.VertexAttributeType = {}));
  9408. })(webgl = spine.webgl || (spine.webgl = {}));
  9409. })(spine || (spine = {}));
  9410. var spine;
  9411. (function (spine) {
  9412. var webgl;
  9413. (function (webgl) {
  9414. var PolygonBatcher = (function () {
  9415. function PolygonBatcher(context, twoColorTint, maxVertices) {
  9416. if (twoColorTint === void 0) { twoColorTint = true; }
  9417. if (maxVertices === void 0) { maxVertices = 10920; }
  9418. this.isDrawing = false;
  9419. this.shader = null;
  9420. this.lastTexture = null;
  9421. this.verticesLength = 0;
  9422. this.indicesLength = 0;
  9423. if (maxVertices > 10920)
  9424. throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
  9425. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  9426. var attributes = twoColorTint ?
  9427. [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute(), new webgl.Color2Attribute()] :
  9428. [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute()];
  9429. this.mesh = new webgl.Mesh(context, attributes, maxVertices, maxVertices * 3);
  9430. this.srcBlend = this.context.gl.SRC_ALPHA;
  9431. this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;
  9432. }
  9433. PolygonBatcher.prototype.begin = function (shader) {
  9434. var gl = this.context.gl;
  9435. if (this.isDrawing)
  9436. throw new Error("PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()");
  9437. this.drawCalls = 0;
  9438. this.shader = shader;
  9439. this.lastTexture = null;
  9440. this.isDrawing = true;
  9441. gl.enable(gl.BLEND);
  9442. gl.blendFunc(this.srcBlend, this.dstBlend);
  9443. };
  9444. PolygonBatcher.prototype.setBlendMode = function (srcBlend, dstBlend) {
  9445. var gl = this.context.gl;
  9446. this.srcBlend = srcBlend;
  9447. this.dstBlend = dstBlend;
  9448. if (this.isDrawing) {
  9449. this.flush();
  9450. gl.blendFunc(this.srcBlend, this.dstBlend);
  9451. }
  9452. };
  9453. PolygonBatcher.prototype.draw = function (texture, vertices, indices) {
  9454. if (texture != this.lastTexture) {
  9455. this.flush();
  9456. this.lastTexture = texture;
  9457. }
  9458. else if (this.verticesLength + vertices.length > this.mesh.getVertices().length ||
  9459. this.indicesLength + indices.length > this.mesh.getIndices().length) {
  9460. this.flush();
  9461. }
  9462. var indexStart = this.mesh.numVertices();
  9463. this.mesh.getVertices().set(vertices, this.verticesLength);
  9464. this.verticesLength += vertices.length;
  9465. this.mesh.setVerticesLength(this.verticesLength);
  9466. var indicesArray = this.mesh.getIndices();
  9467. for (var i = this.indicesLength, j = 0; j < indices.length; i++, j++)
  9468. indicesArray[i] = indices[j] + indexStart;
  9469. this.indicesLength += indices.length;
  9470. this.mesh.setIndicesLength(this.indicesLength);
  9471. };
  9472. PolygonBatcher.prototype.flush = function () {
  9473. var gl = this.context.gl;
  9474. if (this.verticesLength == 0)
  9475. return;
  9476. this.lastTexture.bind();
  9477. this.mesh.draw(this.shader, gl.TRIANGLES);
  9478. this.verticesLength = 0;
  9479. this.indicesLength = 0;
  9480. this.mesh.setVerticesLength(0);
  9481. this.mesh.setIndicesLength(0);
  9482. this.drawCalls++;
  9483. };
  9484. PolygonBatcher.prototype.end = function () {
  9485. var gl = this.context.gl;
  9486. if (!this.isDrawing)
  9487. throw new Error("PolygonBatch is not drawing. Call PolygonBatch.begin() before calling PolygonBatch.end()");
  9488. if (this.verticesLength > 0 || this.indicesLength > 0)
  9489. this.flush();
  9490. this.shader = null;
  9491. this.lastTexture = null;
  9492. this.isDrawing = false;
  9493. gl.disable(gl.BLEND);
  9494. };
  9495. PolygonBatcher.prototype.getDrawCalls = function () { return this.drawCalls; };
  9496. PolygonBatcher.prototype.dispose = function () {
  9497. this.mesh.dispose();
  9498. };
  9499. return PolygonBatcher;
  9500. }());
  9501. webgl.PolygonBatcher = PolygonBatcher;
  9502. })(webgl = spine.webgl || (spine.webgl = {}));
  9503. })(spine || (spine = {}));
  9504. var spine;
  9505. (function (spine) {
  9506. var webgl;
  9507. (function (webgl) {
  9508. var SceneRenderer = (function () {
  9509. function SceneRenderer(canvas, context, twoColorTint) {
  9510. if (twoColorTint === void 0) { twoColorTint = true; }
  9511. this.twoColorTint = false;
  9512. this.activeRenderer = null;
  9513. this.QUAD = [
  9514. 0, 0, 1, 1, 1, 1, 0, 0,
  9515. 0, 0, 1, 1, 1, 1, 0, 0,
  9516. 0, 0, 1, 1, 1, 1, 0, 0,
  9517. 0, 0, 1, 1, 1, 1, 0, 0,
  9518. ];
  9519. this.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
  9520. this.WHITE = new spine.Color(1, 1, 1, 1);
  9521. this.canvas = canvas;
  9522. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  9523. this.twoColorTint = twoColorTint;
  9524. this.camera = new webgl.OrthoCamera(canvas.width, canvas.height);
  9525. this.batcherShader = twoColorTint ? webgl.Shader.newTwoColoredTextured(this.context) : webgl.Shader.newColoredTextured(this.context);
  9526. this.batcher = new webgl.PolygonBatcher(this.context, twoColorTint);
  9527. this.shapesShader = webgl.Shader.newColored(this.context);
  9528. this.shapes = new webgl.ShapeRenderer(this.context);
  9529. this.skeletonRenderer = new webgl.SkeletonRenderer(this.context, twoColorTint);
  9530. this.skeletonDebugRenderer = new webgl.SkeletonDebugRenderer(this.context);
  9531. }
  9532. SceneRenderer.prototype.begin = function () {
  9533. this.camera.update();
  9534. this.enableRenderer(this.batcher);
  9535. };
  9536. SceneRenderer.prototype.drawSkeleton = function (skeleton, premultipliedAlpha, slotRangeStart, slotRangeEnd) {
  9537. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9538. if (slotRangeStart === void 0) { slotRangeStart = -1; }
  9539. if (slotRangeEnd === void 0) { slotRangeEnd = -1; }
  9540. this.enableRenderer(this.batcher);
  9541. this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
  9542. this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd);
  9543. };
  9544. SceneRenderer.prototype.drawSkeletonDebug = function (skeleton, premultipliedAlpha, ignoredBones) {
  9545. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9546. if (ignoredBones === void 0) { ignoredBones = null; }
  9547. this.enableRenderer(this.shapes);
  9548. this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha;
  9549. this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones);
  9550. };
  9551. SceneRenderer.prototype.drawTexture = function (texture, x, y, width, height, color) {
  9552. if (color === void 0) { color = null; }
  9553. this.enableRenderer(this.batcher);
  9554. if (color === null)
  9555. color = this.WHITE;
  9556. var quad = this.QUAD;
  9557. var i = 0;
  9558. quad[i++] = x;
  9559. quad[i++] = y;
  9560. quad[i++] = color.r;
  9561. quad[i++] = color.g;
  9562. quad[i++] = color.b;
  9563. quad[i++] = color.a;
  9564. quad[i++] = 0;
  9565. quad[i++] = 1;
  9566. if (this.twoColorTint) {
  9567. quad[i++] = 0;
  9568. quad[i++] = 0;
  9569. quad[i++] = 0;
  9570. quad[i++] = 0;
  9571. }
  9572. quad[i++] = x + width;
  9573. quad[i++] = y;
  9574. quad[i++] = color.r;
  9575. quad[i++] = color.g;
  9576. quad[i++] = color.b;
  9577. quad[i++] = color.a;
  9578. quad[i++] = 1;
  9579. quad[i++] = 1;
  9580. if (this.twoColorTint) {
  9581. quad[i++] = 0;
  9582. quad[i++] = 0;
  9583. quad[i++] = 0;
  9584. quad[i++] = 0;
  9585. }
  9586. quad[i++] = x + width;
  9587. quad[i++] = y + height;
  9588. quad[i++] = color.r;
  9589. quad[i++] = color.g;
  9590. quad[i++] = color.b;
  9591. quad[i++] = color.a;
  9592. quad[i++] = 1;
  9593. quad[i++] = 0;
  9594. if (this.twoColorTint) {
  9595. quad[i++] = 0;
  9596. quad[i++] = 0;
  9597. quad[i++] = 0;
  9598. quad[i++] = 0;
  9599. }
  9600. quad[i++] = x;
  9601. quad[i++] = y + height;
  9602. quad[i++] = color.r;
  9603. quad[i++] = color.g;
  9604. quad[i++] = color.b;
  9605. quad[i++] = color.a;
  9606. quad[i++] = 0;
  9607. quad[i++] = 0;
  9608. if (this.twoColorTint) {
  9609. quad[i++] = 0;
  9610. quad[i++] = 0;
  9611. quad[i++] = 0;
  9612. quad[i++] = 0;
  9613. }
  9614. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  9615. };
  9616. SceneRenderer.prototype.drawTextureUV = function (texture, x, y, width, height, u, v, u2, v2, color) {
  9617. if (color === void 0) { color = null; }
  9618. this.enableRenderer(this.batcher);
  9619. if (color === null)
  9620. color = this.WHITE;
  9621. var quad = this.QUAD;
  9622. var i = 0;
  9623. quad[i++] = x;
  9624. quad[i++] = y;
  9625. quad[i++] = color.r;
  9626. quad[i++] = color.g;
  9627. quad[i++] = color.b;
  9628. quad[i++] = color.a;
  9629. quad[i++] = u;
  9630. quad[i++] = v;
  9631. if (this.twoColorTint) {
  9632. quad[i++] = 0;
  9633. quad[i++] = 0;
  9634. quad[i++] = 0;
  9635. quad[i++] = 0;
  9636. }
  9637. quad[i++] = x + width;
  9638. quad[i++] = y;
  9639. quad[i++] = color.r;
  9640. quad[i++] = color.g;
  9641. quad[i++] = color.b;
  9642. quad[i++] = color.a;
  9643. quad[i++] = u2;
  9644. quad[i++] = v;
  9645. if (this.twoColorTint) {
  9646. quad[i++] = 0;
  9647. quad[i++] = 0;
  9648. quad[i++] = 0;
  9649. quad[i++] = 0;
  9650. }
  9651. quad[i++] = x + width;
  9652. quad[i++] = y + height;
  9653. quad[i++] = color.r;
  9654. quad[i++] = color.g;
  9655. quad[i++] = color.b;
  9656. quad[i++] = color.a;
  9657. quad[i++] = u2;
  9658. quad[i++] = v2;
  9659. if (this.twoColorTint) {
  9660. quad[i++] = 0;
  9661. quad[i++] = 0;
  9662. quad[i++] = 0;
  9663. quad[i++] = 0;
  9664. }
  9665. quad[i++] = x;
  9666. quad[i++] = y + height;
  9667. quad[i++] = color.r;
  9668. quad[i++] = color.g;
  9669. quad[i++] = color.b;
  9670. quad[i++] = color.a;
  9671. quad[i++] = u;
  9672. quad[i++] = v2;
  9673. if (this.twoColorTint) {
  9674. quad[i++] = 0;
  9675. quad[i++] = 0;
  9676. quad[i++] = 0;
  9677. quad[i++] = 0;
  9678. }
  9679. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  9680. };
  9681. SceneRenderer.prototype.drawTextureRotated = function (texture, x, y, width, height, pivotX, pivotY, angle, color, premultipliedAlpha) {
  9682. if (color === void 0) { color = null; }
  9683. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9684. this.enableRenderer(this.batcher);
  9685. if (color === null)
  9686. color = this.WHITE;
  9687. var quad = this.QUAD;
  9688. var worldOriginX = x + pivotX;
  9689. var worldOriginY = y + pivotY;
  9690. var fx = -pivotX;
  9691. var fy = -pivotY;
  9692. var fx2 = width - pivotX;
  9693. var fy2 = height - pivotY;
  9694. var p1x = fx;
  9695. var p1y = fy;
  9696. var p2x = fx;
  9697. var p2y = fy2;
  9698. var p3x = fx2;
  9699. var p3y = fy2;
  9700. var p4x = fx2;
  9701. var p4y = fy;
  9702. var x1 = 0;
  9703. var y1 = 0;
  9704. var x2 = 0;
  9705. var y2 = 0;
  9706. var x3 = 0;
  9707. var y3 = 0;
  9708. var x4 = 0;
  9709. var y4 = 0;
  9710. if (angle != 0) {
  9711. var cos = spine.MathUtils.cosDeg(angle);
  9712. var sin = spine.MathUtils.sinDeg(angle);
  9713. x1 = cos * p1x - sin * p1y;
  9714. y1 = sin * p1x + cos * p1y;
  9715. x4 = cos * p2x - sin * p2y;
  9716. y4 = sin * p2x + cos * p2y;
  9717. x3 = cos * p3x - sin * p3y;
  9718. y3 = sin * p3x + cos * p3y;
  9719. x2 = x3 + (x1 - x4);
  9720. y2 = y3 + (y1 - y4);
  9721. }
  9722. else {
  9723. x1 = p1x;
  9724. y1 = p1y;
  9725. x4 = p2x;
  9726. y4 = p2y;
  9727. x3 = p3x;
  9728. y3 = p3y;
  9729. x2 = p4x;
  9730. y2 = p4y;
  9731. }
  9732. x1 += worldOriginX;
  9733. y1 += worldOriginY;
  9734. x2 += worldOriginX;
  9735. y2 += worldOriginY;
  9736. x3 += worldOriginX;
  9737. y3 += worldOriginY;
  9738. x4 += worldOriginX;
  9739. y4 += worldOriginY;
  9740. var i = 0;
  9741. quad[i++] = x1;
  9742. quad[i++] = y1;
  9743. quad[i++] = color.r;
  9744. quad[i++] = color.g;
  9745. quad[i++] = color.b;
  9746. quad[i++] = color.a;
  9747. quad[i++] = 0;
  9748. quad[i++] = 1;
  9749. if (this.twoColorTint) {
  9750. quad[i++] = 0;
  9751. quad[i++] = 0;
  9752. quad[i++] = 0;
  9753. quad[i++] = 0;
  9754. }
  9755. quad[i++] = x2;
  9756. quad[i++] = y2;
  9757. quad[i++] = color.r;
  9758. quad[i++] = color.g;
  9759. quad[i++] = color.b;
  9760. quad[i++] = color.a;
  9761. quad[i++] = 1;
  9762. quad[i++] = 1;
  9763. if (this.twoColorTint) {
  9764. quad[i++] = 0;
  9765. quad[i++] = 0;
  9766. quad[i++] = 0;
  9767. quad[i++] = 0;
  9768. }
  9769. quad[i++] = x3;
  9770. quad[i++] = y3;
  9771. quad[i++] = color.r;
  9772. quad[i++] = color.g;
  9773. quad[i++] = color.b;
  9774. quad[i++] = color.a;
  9775. quad[i++] = 1;
  9776. quad[i++] = 0;
  9777. if (this.twoColorTint) {
  9778. quad[i++] = 0;
  9779. quad[i++] = 0;
  9780. quad[i++] = 0;
  9781. quad[i++] = 0;
  9782. }
  9783. quad[i++] = x4;
  9784. quad[i++] = y4;
  9785. quad[i++] = color.r;
  9786. quad[i++] = color.g;
  9787. quad[i++] = color.b;
  9788. quad[i++] = color.a;
  9789. quad[i++] = 0;
  9790. quad[i++] = 0;
  9791. if (this.twoColorTint) {
  9792. quad[i++] = 0;
  9793. quad[i++] = 0;
  9794. quad[i++] = 0;
  9795. quad[i++] = 0;
  9796. }
  9797. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  9798. };
  9799. SceneRenderer.prototype.drawRegion = function (region, x, y, width, height, color, premultipliedAlpha) {
  9800. if (color === void 0) { color = null; }
  9801. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9802. this.enableRenderer(this.batcher);
  9803. if (color === null)
  9804. color = this.WHITE;
  9805. var quad = this.QUAD;
  9806. var i = 0;
  9807. quad[i++] = x;
  9808. quad[i++] = y;
  9809. quad[i++] = color.r;
  9810. quad[i++] = color.g;
  9811. quad[i++] = color.b;
  9812. quad[i++] = color.a;
  9813. quad[i++] = region.u;
  9814. quad[i++] = region.v2;
  9815. if (this.twoColorTint) {
  9816. quad[i++] = 0;
  9817. quad[i++] = 0;
  9818. quad[i++] = 0;
  9819. quad[i++] = 0;
  9820. }
  9821. quad[i++] = x + width;
  9822. quad[i++] = y;
  9823. quad[i++] = color.r;
  9824. quad[i++] = color.g;
  9825. quad[i++] = color.b;
  9826. quad[i++] = color.a;
  9827. quad[i++] = region.u2;
  9828. quad[i++] = region.v2;
  9829. if (this.twoColorTint) {
  9830. quad[i++] = 0;
  9831. quad[i++] = 0;
  9832. quad[i++] = 0;
  9833. quad[i++] = 0;
  9834. }
  9835. quad[i++] = x + width;
  9836. quad[i++] = y + height;
  9837. quad[i++] = color.r;
  9838. quad[i++] = color.g;
  9839. quad[i++] = color.b;
  9840. quad[i++] = color.a;
  9841. quad[i++] = region.u2;
  9842. quad[i++] = region.v;
  9843. if (this.twoColorTint) {
  9844. quad[i++] = 0;
  9845. quad[i++] = 0;
  9846. quad[i++] = 0;
  9847. quad[i++] = 0;
  9848. }
  9849. quad[i++] = x;
  9850. quad[i++] = y + height;
  9851. quad[i++] = color.r;
  9852. quad[i++] = color.g;
  9853. quad[i++] = color.b;
  9854. quad[i++] = color.a;
  9855. quad[i++] = region.u;
  9856. quad[i++] = region.v;
  9857. if (this.twoColorTint) {
  9858. quad[i++] = 0;
  9859. quad[i++] = 0;
  9860. quad[i++] = 0;
  9861. quad[i++] = 0;
  9862. }
  9863. this.batcher.draw(region.texture, quad, this.QUAD_TRIANGLES);
  9864. };
  9865. SceneRenderer.prototype.line = function (x, y, x2, y2, color, color2) {
  9866. if (color === void 0) { color = null; }
  9867. if (color2 === void 0) { color2 = null; }
  9868. this.enableRenderer(this.shapes);
  9869. this.shapes.line(x, y, x2, y2, color);
  9870. };
  9871. SceneRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {
  9872. if (color === void 0) { color = null; }
  9873. if (color2 === void 0) { color2 = null; }
  9874. if (color3 === void 0) { color3 = null; }
  9875. this.enableRenderer(this.shapes);
  9876. this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3);
  9877. };
  9878. SceneRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
  9879. if (color === void 0) { color = null; }
  9880. if (color2 === void 0) { color2 = null; }
  9881. if (color3 === void 0) { color3 = null; }
  9882. if (color4 === void 0) { color4 = null; }
  9883. this.enableRenderer(this.shapes);
  9884. this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4);
  9885. };
  9886. SceneRenderer.prototype.rect = function (filled, x, y, width, height, color) {
  9887. if (color === void 0) { color = null; }
  9888. this.enableRenderer(this.shapes);
  9889. this.shapes.rect(filled, x, y, width, height, color);
  9890. };
  9891. SceneRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) {
  9892. if (color === void 0) { color = null; }
  9893. this.enableRenderer(this.shapes);
  9894. this.shapes.rectLine(filled, x1, y1, x2, y2, width, color);
  9895. };
  9896. SceneRenderer.prototype.polygon = function (polygonVertices, offset, count, color) {
  9897. if (color === void 0) { color = null; }
  9898. this.enableRenderer(this.shapes);
  9899. this.shapes.polygon(polygonVertices, offset, count, color);
  9900. };
  9901. SceneRenderer.prototype.circle = function (filled, x, y, radius, color, segments) {
  9902. if (color === void 0) { color = null; }
  9903. if (segments === void 0) { segments = 0; }
  9904. this.enableRenderer(this.shapes);
  9905. this.shapes.circle(filled, x, y, radius, color, segments);
  9906. };
  9907. SceneRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
  9908. if (color === void 0) { color = null; }
  9909. this.enableRenderer(this.shapes);
  9910. this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color);
  9911. };
  9912. SceneRenderer.prototype.end = function () {
  9913. if (this.activeRenderer === this.batcher)
  9914. this.batcher.end();
  9915. else if (this.activeRenderer === this.shapes)
  9916. this.shapes.end();
  9917. this.activeRenderer = null;
  9918. };
  9919. SceneRenderer.prototype.resize = function (resizeMode) {
  9920. var canvas = this.canvas;
  9921. var w = canvas.clientWidth;
  9922. var h = canvas.clientHeight;
  9923. if (canvas.width != w || canvas.height != h) {
  9924. canvas.width = w;
  9925. canvas.height = h;
  9926. }
  9927. this.context.gl.viewport(0, 0, canvas.width, canvas.height);
  9928. if (resizeMode === ResizeMode.Stretch) {
  9929. }
  9930. else if (resizeMode === ResizeMode.Expand) {
  9931. this.camera.setViewport(w, h);
  9932. }
  9933. else if (resizeMode === ResizeMode.Fit) {
  9934. var sourceWidth = canvas.width, sourceHeight = canvas.height;
  9935. var targetWidth = this.camera.viewportWidth, targetHeight = this.camera.viewportHeight;
  9936. var targetRatio = targetHeight / targetWidth;
  9937. var sourceRatio = sourceHeight / sourceWidth;
  9938. var scale = targetRatio < sourceRatio ? targetWidth / sourceWidth : targetHeight / sourceHeight;
  9939. this.camera.viewportWidth = sourceWidth * scale;
  9940. this.camera.viewportHeight = sourceHeight * scale;
  9941. }
  9942. this.camera.update();
  9943. };
  9944. SceneRenderer.prototype.enableRenderer = function (renderer) {
  9945. if (this.activeRenderer === renderer)
  9946. return;
  9947. this.end();
  9948. if (renderer instanceof webgl.PolygonBatcher) {
  9949. this.batcherShader.bind();
  9950. this.batcherShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values);
  9951. this.batcherShader.setUniformi("u_texture", 0);
  9952. this.batcher.begin(this.batcherShader);
  9953. this.activeRenderer = this.batcher;
  9954. }
  9955. else if (renderer instanceof webgl.ShapeRenderer) {
  9956. this.shapesShader.bind();
  9957. this.shapesShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values);
  9958. this.shapes.begin(this.shapesShader);
  9959. this.activeRenderer = this.shapes;
  9960. }
  9961. else {
  9962. this.activeRenderer = this.skeletonDebugRenderer;
  9963. }
  9964. };
  9965. SceneRenderer.prototype.dispose = function () {
  9966. this.batcher.dispose();
  9967. this.batcherShader.dispose();
  9968. this.shapes.dispose();
  9969. this.shapesShader.dispose();
  9970. this.skeletonDebugRenderer.dispose();
  9971. };
  9972. return SceneRenderer;
  9973. }());
  9974. webgl.SceneRenderer = SceneRenderer;
  9975. var ResizeMode;
  9976. (function (ResizeMode) {
  9977. ResizeMode[ResizeMode["Stretch"] = 0] = "Stretch";
  9978. ResizeMode[ResizeMode["Expand"] = 1] = "Expand";
  9979. ResizeMode[ResizeMode["Fit"] = 2] = "Fit";
  9980. })(ResizeMode = webgl.ResizeMode || (webgl.ResizeMode = {}));
  9981. })(webgl = spine.webgl || (spine.webgl = {}));
  9982. })(spine || (spine = {}));
  9983. var spine;
  9984. (function (spine) {
  9985. var webgl;
  9986. (function (webgl) {
  9987. var Shader = (function () {
  9988. function Shader(context, vertexShader, fragmentShader) {
  9989. this.vertexShader = vertexShader;
  9990. this.fragmentShader = fragmentShader;
  9991. this.vs = null;
  9992. this.fs = null;
  9993. this.program = null;
  9994. this.tmp2x2 = new Float32Array(2 * 2);
  9995. this.tmp3x3 = new Float32Array(3 * 3);
  9996. this.tmp4x4 = new Float32Array(4 * 4);
  9997. this.vsSource = vertexShader;
  9998. this.fsSource = fragmentShader;
  9999. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  10000. this.context.addRestorable(this);
  10001. this.compile();
  10002. }
  10003. Shader.prototype.getProgram = function () { return this.program; };
  10004. Shader.prototype.getVertexShader = function () { return this.vertexShader; };
  10005. Shader.prototype.getFragmentShader = function () { return this.fragmentShader; };
  10006. Shader.prototype.getVertexShaderSource = function () { return this.vsSource; };
  10007. Shader.prototype.getFragmentSource = function () { return this.fsSource; };
  10008. Shader.prototype.compile = function () {
  10009. var gl = this.context.gl;
  10010. try {
  10011. this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader);
  10012. this.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader);
  10013. this.program = this.compileProgram(this.vs, this.fs);
  10014. }
  10015. catch (e) {
  10016. this.dispose();
  10017. throw e;
  10018. }
  10019. };
  10020. Shader.prototype.compileShader = function (type, source) {
  10021. var gl = this.context.gl;
  10022. var shader = gl.createShader(type);
  10023. gl.shaderSource(shader, source);
  10024. gl.compileShader(shader);
  10025. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  10026. var error = "Couldn't compile shader: " + gl.getShaderInfoLog(shader);
  10027. gl.deleteShader(shader);
  10028. if (!gl.isContextLost())
  10029. throw new Error(error);
  10030. }
  10031. return shader;
  10032. };
  10033. Shader.prototype.compileProgram = function (vs, fs) {
  10034. var gl = this.context.gl;
  10035. var program = gl.createProgram();
  10036. gl.attachShader(program, vs);
  10037. gl.attachShader(program, fs);
  10038. gl.linkProgram(program);
  10039. if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
  10040. var error = "Couldn't compile shader program: " + gl.getProgramInfoLog(program);
  10041. gl.deleteProgram(program);
  10042. if (!gl.isContextLost())
  10043. throw new Error(error);
  10044. }
  10045. return program;
  10046. };
  10047. Shader.prototype.restore = function () {
  10048. this.compile();
  10049. };
  10050. Shader.prototype.bind = function () {
  10051. this.context.gl.useProgram(this.program);
  10052. };
  10053. Shader.prototype.unbind = function () {
  10054. this.context.gl.useProgram(null);
  10055. };
  10056. Shader.prototype.setUniformi = function (uniform, value) {
  10057. this.context.gl.uniform1i(this.getUniformLocation(uniform), value);
  10058. };
  10059. Shader.prototype.setUniformf = function (uniform, value) {
  10060. this.context.gl.uniform1f(this.getUniformLocation(uniform), value);
  10061. };
  10062. Shader.prototype.setUniform2f = function (uniform, value, value2) {
  10063. this.context.gl.uniform2f(this.getUniformLocation(uniform), value, value2);
  10064. };
  10065. Shader.prototype.setUniform3f = function (uniform, value, value2, value3) {
  10066. this.context.gl.uniform3f(this.getUniformLocation(uniform), value, value2, value3);
  10067. };
  10068. Shader.prototype.setUniform4f = function (uniform, value, value2, value3, value4) {
  10069. this.context.gl.uniform4f(this.getUniformLocation(uniform), value, value2, value3, value4);
  10070. };
  10071. Shader.prototype.setUniform2x2f = function (uniform, value) {
  10072. var gl = this.context.gl;
  10073. this.tmp2x2.set(value);
  10074. gl.uniformMatrix2fv(this.getUniformLocation(uniform), false, this.tmp2x2);
  10075. };
  10076. Shader.prototype.setUniform3x3f = function (uniform, value) {
  10077. var gl = this.context.gl;
  10078. this.tmp3x3.set(value);
  10079. gl.uniformMatrix3fv(this.getUniformLocation(uniform), false, this.tmp3x3);
  10080. };
  10081. Shader.prototype.setUniform4x4f = function (uniform, value) {
  10082. var gl = this.context.gl;
  10083. this.tmp4x4.set(value);
  10084. gl.uniformMatrix4fv(this.getUniformLocation(uniform), false, this.tmp4x4);
  10085. };
  10086. Shader.prototype.getUniformLocation = function (uniform) {
  10087. var gl = this.context.gl;
  10088. var location = gl.getUniformLocation(this.program, uniform);
  10089. if (!location && !gl.isContextLost())
  10090. throw new Error("Couldn't find location for uniform " + uniform);
  10091. return location;
  10092. };
  10093. Shader.prototype.getAttributeLocation = function (attribute) {
  10094. var gl = this.context.gl;
  10095. var location = gl.getAttribLocation(this.program, attribute);
  10096. if (location == -1 && !gl.isContextLost())
  10097. throw new Error("Couldn't find location for attribute " + attribute);
  10098. return location;
  10099. };
  10100. Shader.prototype.dispose = function () {
  10101. this.context.removeRestorable(this);
  10102. var gl = this.context.gl;
  10103. if (this.vs) {
  10104. gl.deleteShader(this.vs);
  10105. this.vs = null;
  10106. }
  10107. if (this.fs) {
  10108. gl.deleteShader(this.fs);
  10109. this.fs = null;
  10110. }
  10111. if (this.program) {
  10112. gl.deleteProgram(this.program);
  10113. this.program = null;
  10114. }
  10115. };
  10116. Shader.newColoredTextured = function (context) {
  10117. var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_color;\n\t\t\t\tvarying vec2 v_texCoords;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_color = " + Shader.COLOR + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t";
  10118. var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_color;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tgl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n\t\t\t\t}\n\t\t\t";
  10119. return new Shader(context, vs, fs);
  10120. };
  10121. Shader.newTwoColoredTextured = function (context) {
  10122. var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR2 + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_light;\n\t\t\t\tvarying vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_light = " + Shader.COLOR + ";\n\t\t\t\t\tv_dark = " + Shader.COLOR2 + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t";
  10123. var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_light;\n\t\t\t\tvarying LOWP vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tvec4 texColor = texture2D(u_texture, v_texCoords);\n\t\t\t\t\tgl_FragColor.a = texColor.a * v_light.a;\n\t\t\t\t\tgl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n\t\t\t\t}\n\t\t\t";
  10124. return new Shader(context, vs, fs);
  10125. };
  10126. Shader.newColored = function (context) {
  10127. var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_color;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_color = " + Shader.COLOR + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t";
  10128. var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_color;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tgl_FragColor = v_color;\n\t\t\t\t}\n\t\t\t";
  10129. return new Shader(context, vs, fs);
  10130. };
  10131. Shader.MVP_MATRIX = "u_projTrans";
  10132. Shader.POSITION = "a_position";
  10133. Shader.COLOR = "a_color";
  10134. Shader.COLOR2 = "a_color2";
  10135. Shader.TEXCOORDS = "a_texCoords";
  10136. Shader.SAMPLER = "u_texture";
  10137. return Shader;
  10138. }());
  10139. webgl.Shader = Shader;
  10140. })(webgl = spine.webgl || (spine.webgl = {}));
  10141. })(spine || (spine = {}));
  10142. var spine;
  10143. (function (spine) {
  10144. var webgl;
  10145. (function (webgl) {
  10146. var ShapeRenderer = (function () {
  10147. function ShapeRenderer(context, maxVertices) {
  10148. if (maxVertices === void 0) { maxVertices = 10920; }
  10149. this.isDrawing = false;
  10150. this.shapeType = ShapeType.Filled;
  10151. this.color = new spine.Color(1, 1, 1, 1);
  10152. this.vertexIndex = 0;
  10153. this.tmp = new spine.Vector2();
  10154. if (maxVertices > 10920)
  10155. throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
  10156. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  10157. this.mesh = new webgl.Mesh(context, [new webgl.Position2Attribute(), new webgl.ColorAttribute()], maxVertices, 0);
  10158. this.srcBlend = this.context.gl.SRC_ALPHA;
  10159. this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;
  10160. }
  10161. ShapeRenderer.prototype.begin = function (shader) {
  10162. if (this.isDrawing)
  10163. throw new Error("ShapeRenderer.begin() has already been called");
  10164. this.shader = shader;
  10165. this.vertexIndex = 0;
  10166. this.isDrawing = true;
  10167. var gl = this.context.gl;
  10168. gl.enable(gl.BLEND);
  10169. gl.blendFunc(this.srcBlend, this.dstBlend);
  10170. };
  10171. ShapeRenderer.prototype.setBlendMode = function (srcBlend, dstBlend) {
  10172. var gl = this.context.gl;
  10173. this.srcBlend = srcBlend;
  10174. this.dstBlend = dstBlend;
  10175. if (this.isDrawing) {
  10176. this.flush();
  10177. gl.blendFunc(this.srcBlend, this.dstBlend);
  10178. }
  10179. };
  10180. ShapeRenderer.prototype.setColor = function (color) {
  10181. this.color.setFromColor(color);
  10182. };
  10183. ShapeRenderer.prototype.setColorWith = function (r, g, b, a) {
  10184. this.color.set(r, g, b, a);
  10185. };
  10186. ShapeRenderer.prototype.point = function (x, y, color) {
  10187. if (color === void 0) { color = null; }
  10188. this.check(ShapeType.Point, 1);
  10189. if (color === null)
  10190. color = this.color;
  10191. this.vertex(x, y, color);
  10192. };
  10193. ShapeRenderer.prototype.line = function (x, y, x2, y2, color) {
  10194. if (color === void 0) { color = null; }
  10195. this.check(ShapeType.Line, 2);
  10196. var vertices = this.mesh.getVertices();
  10197. var idx = this.vertexIndex;
  10198. if (color === null)
  10199. color = this.color;
  10200. this.vertex(x, y, color);
  10201. this.vertex(x2, y2, color);
  10202. };
  10203. ShapeRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {
  10204. if (color === void 0) { color = null; }
  10205. if (color2 === void 0) { color2 = null; }
  10206. if (color3 === void 0) { color3 = null; }
  10207. this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
  10208. var vertices = this.mesh.getVertices();
  10209. var idx = this.vertexIndex;
  10210. if (color === null)
  10211. color = this.color;
  10212. if (color2 === null)
  10213. color2 = this.color;
  10214. if (color3 === null)
  10215. color3 = this.color;
  10216. if (filled) {
  10217. this.vertex(x, y, color);
  10218. this.vertex(x2, y2, color2);
  10219. this.vertex(x3, y3, color3);
  10220. }
  10221. else {
  10222. this.vertex(x, y, color);
  10223. this.vertex(x2, y2, color2);
  10224. this.vertex(x2, y2, color);
  10225. this.vertex(x3, y3, color2);
  10226. this.vertex(x3, y3, color);
  10227. this.vertex(x, y, color2);
  10228. }
  10229. };
  10230. ShapeRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
  10231. if (color === void 0) { color = null; }
  10232. if (color2 === void 0) { color2 = null; }
  10233. if (color3 === void 0) { color3 = null; }
  10234. if (color4 === void 0) { color4 = null; }
  10235. this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
  10236. var vertices = this.mesh.getVertices();
  10237. var idx = this.vertexIndex;
  10238. if (color === null)
  10239. color = this.color;
  10240. if (color2 === null)
  10241. color2 = this.color;
  10242. if (color3 === null)
  10243. color3 = this.color;
  10244. if (color4 === null)
  10245. color4 = this.color;
  10246. if (filled) {
  10247. this.vertex(x, y, color);
  10248. this.vertex(x2, y2, color2);
  10249. this.vertex(x3, y3, color3);
  10250. this.vertex(x3, y3, color3);
  10251. this.vertex(x4, y4, color4);
  10252. this.vertex(x, y, color);
  10253. }
  10254. else {
  10255. this.vertex(x, y, color);
  10256. this.vertex(x2, y2, color2);
  10257. this.vertex(x2, y2, color2);
  10258. this.vertex(x3, y3, color3);
  10259. this.vertex(x3, y3, color3);
  10260. this.vertex(x4, y4, color4);
  10261. this.vertex(x4, y4, color4);
  10262. this.vertex(x, y, color);
  10263. }
  10264. };
  10265. ShapeRenderer.prototype.rect = function (filled, x, y, width, height, color) {
  10266. if (color === void 0) { color = null; }
  10267. this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color);
  10268. };
  10269. ShapeRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) {
  10270. if (color === void 0) { color = null; }
  10271. this.check(filled ? ShapeType.Filled : ShapeType.Line, 8);
  10272. if (color === null)
  10273. color = this.color;
  10274. var t = this.tmp.set(y2 - y1, x1 - x2);
  10275. t.normalize();
  10276. width *= 0.5;
  10277. var tx = t.x * width;
  10278. var ty = t.y * width;
  10279. if (!filled) {
  10280. this.vertex(x1 + tx, y1 + ty, color);
  10281. this.vertex(x1 - tx, y1 - ty, color);
  10282. this.vertex(x2 + tx, y2 + ty, color);
  10283. this.vertex(x2 - tx, y2 - ty, color);
  10284. this.vertex(x2 + tx, y2 + ty, color);
  10285. this.vertex(x1 + tx, y1 + ty, color);
  10286. this.vertex(x2 - tx, y2 - ty, color);
  10287. this.vertex(x1 - tx, y1 - ty, color);
  10288. }
  10289. else {
  10290. this.vertex(x1 + tx, y1 + ty, color);
  10291. this.vertex(x1 - tx, y1 - ty, color);
  10292. this.vertex(x2 + tx, y2 + ty, color);
  10293. this.vertex(x2 - tx, y2 - ty, color);
  10294. this.vertex(x2 + tx, y2 + ty, color);
  10295. this.vertex(x1 - tx, y1 - ty, color);
  10296. }
  10297. };
  10298. ShapeRenderer.prototype.x = function (x, y, size) {
  10299. this.line(x - size, y - size, x + size, y + size);
  10300. this.line(x - size, y + size, x + size, y - size);
  10301. };
  10302. ShapeRenderer.prototype.polygon = function (polygonVertices, offset, count, color) {
  10303. if (color === void 0) { color = null; }
  10304. if (count < 3)
  10305. throw new Error("Polygon must contain at least 3 vertices");
  10306. this.check(ShapeType.Line, count * 2);
  10307. if (color === null)
  10308. color = this.color;
  10309. var vertices = this.mesh.getVertices();
  10310. var idx = this.vertexIndex;
  10311. offset <<= 1;
  10312. count <<= 1;
  10313. var firstX = polygonVertices[offset];
  10314. var firstY = polygonVertices[offset + 1];
  10315. var last = offset + count;
  10316. for (var i = offset, n = offset + count - 2; i < n; i += 2) {
  10317. var x1 = polygonVertices[i];
  10318. var y1 = polygonVertices[i + 1];
  10319. var x2 = 0;
  10320. var y2 = 0;
  10321. if (i + 2 >= last) {
  10322. x2 = firstX;
  10323. y2 = firstY;
  10324. }
  10325. else {
  10326. x2 = polygonVertices[i + 2];
  10327. y2 = polygonVertices[i + 3];
  10328. }
  10329. this.vertex(x1, y1, color);
  10330. this.vertex(x2, y2, color);
  10331. }
  10332. };
  10333. ShapeRenderer.prototype.circle = function (filled, x, y, radius, color, segments) {
  10334. if (color === void 0) { color = null; }
  10335. if (segments === void 0) { segments = 0; }
  10336. if (segments === 0)
  10337. segments = Math.max(1, (6 * spine.MathUtils.cbrt(radius)) | 0);
  10338. if (segments <= 0)
  10339. throw new Error("segments must be > 0.");
  10340. if (color === null)
  10341. color = this.color;
  10342. var angle = 2 * spine.MathUtils.PI / segments;
  10343. var cos = Math.cos(angle);
  10344. var sin = Math.sin(angle);
  10345. var cx = radius, cy = 0;
  10346. if (!filled) {
  10347. this.check(ShapeType.Line, segments * 2 + 2);
  10348. for (var i = 0; i < segments; i++) {
  10349. this.vertex(x + cx, y + cy, color);
  10350. var temp_1 = cx;
  10351. cx = cos * cx - sin * cy;
  10352. cy = sin * temp_1 + cos * cy;
  10353. this.vertex(x + cx, y + cy, color);
  10354. }
  10355. this.vertex(x + cx, y + cy, color);
  10356. }
  10357. else {
  10358. this.check(ShapeType.Filled, segments * 3 + 3);
  10359. segments--;
  10360. for (var i = 0; i < segments; i++) {
  10361. this.vertex(x, y, color);
  10362. this.vertex(x + cx, y + cy, color);
  10363. var temp_2 = cx;
  10364. cx = cos * cx - sin * cy;
  10365. cy = sin * temp_2 + cos * cy;
  10366. this.vertex(x + cx, y + cy, color);
  10367. }
  10368. this.vertex(x, y, color);
  10369. this.vertex(x + cx, y + cy, color);
  10370. }
  10371. var temp = cx;
  10372. cx = radius;
  10373. cy = 0;
  10374. this.vertex(x + cx, y + cy, color);
  10375. };
  10376. ShapeRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
  10377. if (color === void 0) { color = null; }
  10378. this.check(ShapeType.Line, segments * 2 + 2);
  10379. if (color === null)
  10380. color = this.color;
  10381. var subdiv_step = 1 / segments;
  10382. var subdiv_step2 = subdiv_step * subdiv_step;
  10383. var subdiv_step3 = subdiv_step * subdiv_step * subdiv_step;
  10384. var pre1 = 3 * subdiv_step;
  10385. var pre2 = 3 * subdiv_step2;
  10386. var pre4 = 6 * subdiv_step2;
  10387. var pre5 = 6 * subdiv_step3;
  10388. var tmp1x = x1 - cx1 * 2 + cx2;
  10389. var tmp1y = y1 - cy1 * 2 + cy2;
  10390. var tmp2x = (cx1 - cx2) * 3 - x1 + x2;
  10391. var tmp2y = (cy1 - cy2) * 3 - y1 + y2;
  10392. var fx = x1;
  10393. var fy = y1;
  10394. var dfx = (cx1 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3;
  10395. var dfy = (cy1 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3;
  10396. var ddfx = tmp1x * pre4 + tmp2x * pre5;
  10397. var ddfy = tmp1y * pre4 + tmp2y * pre5;
  10398. var dddfx = tmp2x * pre5;
  10399. var dddfy = tmp2y * pre5;
  10400. while (segments-- > 0) {
  10401. this.vertex(fx, fy, color);
  10402. fx += dfx;
  10403. fy += dfy;
  10404. dfx += ddfx;
  10405. dfy += ddfy;
  10406. ddfx += dddfx;
  10407. ddfy += dddfy;
  10408. this.vertex(fx, fy, color);
  10409. }
  10410. this.vertex(fx, fy, color);
  10411. this.vertex(x2, y2, color);
  10412. };
  10413. ShapeRenderer.prototype.vertex = function (x, y, color) {
  10414. var idx = this.vertexIndex;
  10415. var vertices = this.mesh.getVertices();
  10416. vertices[idx++] = x;
  10417. vertices[idx++] = y;
  10418. vertices[idx++] = color.r;
  10419. vertices[idx++] = color.g;
  10420. vertices[idx++] = color.b;
  10421. vertices[idx++] = color.a;
  10422. this.vertexIndex = idx;
  10423. };
  10424. ShapeRenderer.prototype.end = function () {
  10425. if (!this.isDrawing)
  10426. throw new Error("ShapeRenderer.begin() has not been called");
  10427. this.flush();
  10428. this.context.gl.disable(this.context.gl.BLEND);
  10429. this.isDrawing = false;
  10430. };
  10431. ShapeRenderer.prototype.flush = function () {
  10432. if (this.vertexIndex == 0)
  10433. return;
  10434. this.mesh.setVerticesLength(this.vertexIndex);
  10435. this.mesh.draw(this.shader, this.shapeType);
  10436. this.vertexIndex = 0;
  10437. };
  10438. ShapeRenderer.prototype.check = function (shapeType, numVertices) {
  10439. if (!this.isDrawing)
  10440. throw new Error("ShapeRenderer.begin() has not been called");
  10441. if (this.shapeType == shapeType) {
  10442. if (this.mesh.maxVertices() - this.mesh.numVertices() < numVertices)
  10443. this.flush();
  10444. else
  10445. return;
  10446. }
  10447. else {
  10448. this.flush();
  10449. this.shapeType = shapeType;
  10450. }
  10451. };
  10452. ShapeRenderer.prototype.dispose = function () {
  10453. this.mesh.dispose();
  10454. };
  10455. return ShapeRenderer;
  10456. }());
  10457. webgl.ShapeRenderer = ShapeRenderer;
  10458. var ShapeType;
  10459. (function (ShapeType) {
  10460. ShapeType[ShapeType["Point"] = 0] = "Point";
  10461. ShapeType[ShapeType["Line"] = 1] = "Line";
  10462. ShapeType[ShapeType["Filled"] = 4] = "Filled";
  10463. })(ShapeType = webgl.ShapeType || (webgl.ShapeType = {}));
  10464. })(webgl = spine.webgl || (spine.webgl = {}));
  10465. })(spine || (spine = {}));
  10466. var spine;
  10467. (function (spine) {
  10468. var webgl;
  10469. (function (webgl) {
  10470. var SkeletonDebugRenderer = (function () {
  10471. function SkeletonDebugRenderer(context) {
  10472. this.boneLineColor = new spine.Color(1, 0, 0, 1);
  10473. this.boneOriginColor = new spine.Color(0, 1, 0, 1);
  10474. this.attachmentLineColor = new spine.Color(0, 0, 1, 0.5);
  10475. this.triangleLineColor = new spine.Color(1, 0.64, 0, 0.5);
  10476. this.pathColor = new spine.Color().setFromString("FF7F00");
  10477. this.clipColor = new spine.Color(0.8, 0, 0, 2);
  10478. this.aabbColor = new spine.Color(0, 1, 0, 0.5);
  10479. this.drawBones = true;
  10480. this.drawRegionAttachments = true;
  10481. this.drawBoundingBoxes = true;
  10482. this.drawMeshHull = true;
  10483. this.drawMeshTriangles = true;
  10484. this.drawPaths = true;
  10485. this.drawSkeletonXY = false;
  10486. this.drawClipping = true;
  10487. this.premultipliedAlpha = false;
  10488. this.scale = 1;
  10489. this.boneWidth = 2;
  10490. this.bounds = new spine.SkeletonBounds();
  10491. this.temp = new Array();
  10492. this.vertices = spine.Utils.newFloatArray(2 * 1024);
  10493. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  10494. }
  10495. SkeletonDebugRenderer.prototype.draw = function (shapes, skeleton, ignoredBones) {
  10496. if (ignoredBones === void 0) { ignoredBones = null; }
  10497. var skeletonX = skeleton.x;
  10498. var skeletonY = skeleton.y;
  10499. var gl = this.context.gl;
  10500. var srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;
  10501. shapes.setBlendMode(srcFunc, gl.ONE_MINUS_SRC_ALPHA);
  10502. var bones = skeleton.bones;
  10503. if (this.drawBones) {
  10504. shapes.setColor(this.boneLineColor);
  10505. for (var i = 0, n = bones.length; i < n; i++) {
  10506. var bone = bones[i];
  10507. if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)
  10508. continue;
  10509. if (bone.parent == null)
  10510. continue;
  10511. var x = skeletonX + bone.data.length * bone.a + bone.worldX;
  10512. var y = skeletonY + bone.data.length * bone.c + bone.worldY;
  10513. shapes.rectLine(true, skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, this.boneWidth * this.scale);
  10514. }
  10515. if (this.drawSkeletonXY)
  10516. shapes.x(skeletonX, skeletonY, 4 * this.scale);
  10517. }
  10518. if (this.drawRegionAttachments) {
  10519. shapes.setColor(this.attachmentLineColor);
  10520. var slots = skeleton.slots;
  10521. for (var i = 0, n = slots.length; i < n; i++) {
  10522. var slot = slots[i];
  10523. var attachment = slot.getAttachment();
  10524. if (attachment instanceof spine.RegionAttachment) {
  10525. var regionAttachment = attachment;
  10526. var vertices = this.vertices;
  10527. regionAttachment.computeWorldVertices(slot.bone, vertices, 0, 2);
  10528. shapes.line(vertices[0], vertices[1], vertices[2], vertices[3]);
  10529. shapes.line(vertices[2], vertices[3], vertices[4], vertices[5]);
  10530. shapes.line(vertices[4], vertices[5], vertices[6], vertices[7]);
  10531. shapes.line(vertices[6], vertices[7], vertices[0], vertices[1]);
  10532. }
  10533. }
  10534. }
  10535. if (this.drawMeshHull || this.drawMeshTriangles) {
  10536. var slots = skeleton.slots;
  10537. for (var i = 0, n = slots.length; i < n; i++) {
  10538. var slot = slots[i];
  10539. if (!slot.bone.active)
  10540. continue;
  10541. var attachment = slot.getAttachment();
  10542. if (!(attachment instanceof spine.MeshAttachment))
  10543. continue;
  10544. var mesh = attachment;
  10545. var vertices = this.vertices;
  10546. mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 2);
  10547. var triangles = mesh.triangles;
  10548. var hullLength = mesh.hullLength;
  10549. if (this.drawMeshTriangles) {
  10550. shapes.setColor(this.triangleLineColor);
  10551. for (var ii = 0, nn = triangles.length; ii < nn; ii += 3) {
  10552. var v1 = triangles[ii] * 2, v2 = triangles[ii + 1] * 2, v3 = triangles[ii + 2] * 2;
  10553. shapes.triangle(false, vertices[v1], vertices[v1 + 1], vertices[v2], vertices[v2 + 1], vertices[v3], vertices[v3 + 1]);
  10554. }
  10555. }
  10556. if (this.drawMeshHull && hullLength > 0) {
  10557. shapes.setColor(this.attachmentLineColor);
  10558. hullLength = (hullLength >> 1) * 2;
  10559. var lastX = vertices[hullLength - 2], lastY = vertices[hullLength - 1];
  10560. for (var ii = 0, nn = hullLength; ii < nn; ii += 2) {
  10561. var x = vertices[ii], y = vertices[ii + 1];
  10562. shapes.line(x, y, lastX, lastY);
  10563. lastX = x;
  10564. lastY = y;
  10565. }
  10566. }
  10567. }
  10568. }
  10569. if (this.drawBoundingBoxes) {
  10570. var bounds = this.bounds;
  10571. bounds.update(skeleton, true);
  10572. shapes.setColor(this.aabbColor);
  10573. shapes.rect(false, bounds.minX, bounds.minY, bounds.getWidth(), bounds.getHeight());
  10574. var polygons = bounds.polygons;
  10575. var boxes = bounds.boundingBoxes;
  10576. for (var i = 0, n = polygons.length; i < n; i++) {
  10577. var polygon = polygons[i];
  10578. shapes.setColor(boxes[i].color);
  10579. shapes.polygon(polygon, 0, polygon.length);
  10580. }
  10581. }
  10582. if (this.drawPaths) {
  10583. var slots = skeleton.slots;
  10584. for (var i = 0, n = slots.length; i < n; i++) {
  10585. var slot = slots[i];
  10586. if (!slot.bone.active)
  10587. continue;
  10588. var attachment = slot.getAttachment();
  10589. if (!(attachment instanceof spine.PathAttachment))
  10590. continue;
  10591. var path = attachment;
  10592. var nn = path.worldVerticesLength;
  10593. var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
  10594. path.computeWorldVertices(slot, 0, nn, world, 0, 2);
  10595. var color = this.pathColor;
  10596. var x1 = world[2], y1 = world[3], x2 = 0, y2 = 0;
  10597. if (path.closed) {
  10598. shapes.setColor(color);
  10599. var cx1 = world[0], cy1 = world[1], cx2 = world[nn - 2], cy2 = world[nn - 1];
  10600. x2 = world[nn - 4];
  10601. y2 = world[nn - 3];
  10602. shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);
  10603. shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);
  10604. shapes.line(x1, y1, cx1, cy1);
  10605. shapes.line(x2, y2, cx2, cy2);
  10606. }
  10607. nn -= 4;
  10608. for (var ii = 4; ii < nn; ii += 6) {
  10609. var cx1 = world[ii], cy1 = world[ii + 1], cx2 = world[ii + 2], cy2 = world[ii + 3];
  10610. x2 = world[ii + 4];
  10611. y2 = world[ii + 5];
  10612. shapes.setColor(color);
  10613. shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);
  10614. shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);
  10615. shapes.line(x1, y1, cx1, cy1);
  10616. shapes.line(x2, y2, cx2, cy2);
  10617. x1 = x2;
  10618. y1 = y2;
  10619. }
  10620. }
  10621. }
  10622. if (this.drawBones) {
  10623. shapes.setColor(this.boneOriginColor);
  10624. for (var i = 0, n = bones.length; i < n; i++) {
  10625. var bone = bones[i];
  10626. if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)
  10627. continue;
  10628. shapes.circle(true, skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * this.scale, SkeletonDebugRenderer.GREEN, 8);
  10629. }
  10630. }
  10631. if (this.drawClipping) {
  10632. var slots = skeleton.slots;
  10633. shapes.setColor(this.clipColor);
  10634. for (var i = 0, n = slots.length; i < n; i++) {
  10635. var slot = slots[i];
  10636. if (!slot.bone.active)
  10637. continue;
  10638. var attachment = slot.getAttachment();
  10639. if (!(attachment instanceof spine.ClippingAttachment))
  10640. continue;
  10641. var clip = attachment;
  10642. var nn = clip.worldVerticesLength;
  10643. var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
  10644. clip.computeWorldVertices(slot, 0, nn, world, 0, 2);
  10645. for (var i_21 = 0, n_3 = world.length; i_21 < n_3; i_21 += 2) {
  10646. var x = world[i_21];
  10647. var y = world[i_21 + 1];
  10648. var x2 = world[(i_21 + 2) % world.length];
  10649. var y2 = world[(i_21 + 3) % world.length];
  10650. shapes.line(x, y, x2, y2);
  10651. }
  10652. }
  10653. }
  10654. };
  10655. SkeletonDebugRenderer.prototype.dispose = function () {
  10656. };
  10657. SkeletonDebugRenderer.LIGHT_GRAY = new spine.Color(192 / 255, 192 / 255, 192 / 255, 1);
  10658. SkeletonDebugRenderer.GREEN = new spine.Color(0, 1, 0, 1);
  10659. return SkeletonDebugRenderer;
  10660. }());
  10661. webgl.SkeletonDebugRenderer = SkeletonDebugRenderer;
  10662. })(webgl = spine.webgl || (spine.webgl = {}));
  10663. })(spine || (spine = {}));
  10664. var spine;
  10665. (function (spine) {
  10666. var webgl;
  10667. (function (webgl) {
  10668. var Renderable = (function () {
  10669. function Renderable(vertices, numVertices, numFloats) {
  10670. this.vertices = vertices;
  10671. this.numVertices = numVertices;
  10672. this.numFloats = numFloats;
  10673. }
  10674. return Renderable;
  10675. }());
  10676. ;
  10677. var SkeletonRenderer = (function () {
  10678. function SkeletonRenderer(context, twoColorTint) {
  10679. if (twoColorTint === void 0) { twoColorTint = true; }
  10680. this.premultipliedAlpha = false;
  10681. this.vertexEffect = null;
  10682. this.tempColor = new spine.Color();
  10683. this.tempColor2 = new spine.Color();
  10684. this.vertexSize = 2 + 2 + 4;
  10685. this.twoColorTint = false;
  10686. this.renderable = new Renderable(null, 0, 0);
  10687. this.clipper = new spine.SkeletonClipping();
  10688. this.temp = new spine.Vector2();
  10689. this.temp2 = new spine.Vector2();
  10690. this.temp3 = new spine.Color();
  10691. this.temp4 = new spine.Color();
  10692. this.twoColorTint = twoColorTint;
  10693. if (twoColorTint)
  10694. this.vertexSize += 4;
  10695. this.vertices = spine.Utils.newFloatArray(this.vertexSize * 1024);
  10696. }
  10697. SkeletonRenderer.prototype.draw = function (batcher, skeleton, slotRangeStart, slotRangeEnd) {
  10698. if (slotRangeStart === void 0) { slotRangeStart = -1; }
  10699. if (slotRangeEnd === void 0) { slotRangeEnd = -1; }
  10700. var clipper = this.clipper;
  10701. var premultipliedAlpha = this.premultipliedAlpha;
  10702. var twoColorTint = this.twoColorTint;
  10703. var blendMode = null;
  10704. var tempPos = this.temp;
  10705. var tempUv = this.temp2;
  10706. var tempLight = this.temp3;
  10707. var tempDark = this.temp4;
  10708. var renderable = this.renderable;
  10709. var uvs = null;
  10710. var triangles = null;
  10711. var drawOrder = skeleton.drawOrder;
  10712. var attachmentColor = null;
  10713. var skeletonColor = skeleton.color;
  10714. var vertexSize = twoColorTint ? 12 : 8;
  10715. var inRange = false;
  10716. if (slotRangeStart == -1)
  10717. inRange = true;
  10718. for (var i = 0, n = drawOrder.length; i < n; i++) {
  10719. var clippedVertexSize = clipper.isClipping() ? 2 : vertexSize;
  10720. var slot = drawOrder[i];
  10721. if (!slot.bone.active) {
  10722. clipper.clipEndWithSlot(slot);
  10723. continue;
  10724. }
  10725. if (slotRangeStart >= 0 && slotRangeStart == slot.data.index) {
  10726. inRange = true;
  10727. }
  10728. if (!inRange) {
  10729. clipper.clipEndWithSlot(slot);
  10730. continue;
  10731. }
  10732. if (slotRangeEnd >= 0 && slotRangeEnd == slot.data.index) {
  10733. inRange = false;
  10734. }
  10735. var attachment = slot.getAttachment();
  10736. var texture = null;
  10737. if (attachment instanceof spine.RegionAttachment) {
  10738. var region = attachment;
  10739. renderable.vertices = this.vertices;
  10740. renderable.numVertices = 4;
  10741. renderable.numFloats = clippedVertexSize << 2;
  10742. region.computeWorldVertices(slot.bone, renderable.vertices, 0, clippedVertexSize);
  10743. triangles = SkeletonRenderer.QUAD_TRIANGLES;
  10744. uvs = region.uvs;
  10745. texture = region.region.renderObject.texture;
  10746. attachmentColor = region.color;
  10747. }
  10748. else if (attachment instanceof spine.MeshAttachment) {
  10749. var mesh = attachment;
  10750. renderable.vertices = this.vertices;
  10751. renderable.numVertices = (mesh.worldVerticesLength >> 1);
  10752. renderable.numFloats = renderable.numVertices * clippedVertexSize;
  10753. if (renderable.numFloats > renderable.vertices.length) {
  10754. renderable.vertices = this.vertices = spine.Utils.newFloatArray(renderable.numFloats);
  10755. }
  10756. mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize);
  10757. triangles = mesh.triangles;
  10758. texture = mesh.region.renderObject.texture;
  10759. uvs = mesh.uvs;
  10760. attachmentColor = mesh.color;
  10761. }
  10762. else if (attachment instanceof spine.ClippingAttachment) {
  10763. var clip = (attachment);
  10764. clipper.clipStart(slot, clip);
  10765. continue;
  10766. }
  10767. else {
  10768. clipper.clipEndWithSlot(slot);
  10769. continue;
  10770. }
  10771. if (texture != null) {
  10772. var slotColor = slot.color;
  10773. var finalColor = this.tempColor;
  10774. finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r;
  10775. finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g;
  10776. finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;
  10777. finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a;
  10778. if (premultipliedAlpha) {
  10779. finalColor.r *= finalColor.a;
  10780. finalColor.g *= finalColor.a;
  10781. finalColor.b *= finalColor.a;
  10782. }
  10783. var darkColor = this.tempColor2;
  10784. if (slot.darkColor == null)
  10785. darkColor.set(0, 0, 0, 1.0);
  10786. else {
  10787. if (premultipliedAlpha) {
  10788. darkColor.r = slot.darkColor.r * finalColor.a;
  10789. darkColor.g = slot.darkColor.g * finalColor.a;
  10790. darkColor.b = slot.darkColor.b * finalColor.a;
  10791. }
  10792. else {
  10793. darkColor.setFromColor(slot.darkColor);
  10794. }
  10795. darkColor.a = premultipliedAlpha ? 1.0 : 0.0;
  10796. }
  10797. var slotBlendMode = slot.data.blendMode;
  10798. if (slotBlendMode != blendMode) {
  10799. blendMode = slotBlendMode;
  10800. batcher.setBlendMode(webgl.WebGLBlendModeConverter.getSourceGLBlendMode(blendMode, premultipliedAlpha), webgl.WebGLBlendModeConverter.getDestGLBlendMode(blendMode));
  10801. }
  10802. if (clipper.isClipping()) {
  10803. clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
  10804. var clippedVertices = new Float32Array(clipper.clippedVertices);
  10805. var clippedTriangles = clipper.clippedTriangles;
  10806. if (this.vertexEffect != null) {
  10807. var vertexEffect = this.vertexEffect;
  10808. var verts = clippedVertices;
  10809. if (!twoColorTint) {
  10810. for (var v = 0, n_4 = clippedVertices.length; v < n_4; v += vertexSize) {
  10811. tempPos.x = verts[v];
  10812. tempPos.y = verts[v + 1];
  10813. tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
  10814. tempUv.x = verts[v + 6];
  10815. tempUv.y = verts[v + 7];
  10816. tempDark.set(0, 0, 0, 0);
  10817. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  10818. verts[v] = tempPos.x;
  10819. verts[v + 1] = tempPos.y;
  10820. verts[v + 2] = tempLight.r;
  10821. verts[v + 3] = tempLight.g;
  10822. verts[v + 4] = tempLight.b;
  10823. verts[v + 5] = tempLight.a;
  10824. verts[v + 6] = tempUv.x;
  10825. verts[v + 7] = tempUv.y;
  10826. }
  10827. }
  10828. else {
  10829. for (var v = 0, n_5 = clippedVertices.length; v < n_5; v += vertexSize) {
  10830. tempPos.x = verts[v];
  10831. tempPos.y = verts[v + 1];
  10832. tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
  10833. tempUv.x = verts[v + 6];
  10834. tempUv.y = verts[v + 7];
  10835. tempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]);
  10836. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  10837. verts[v] = tempPos.x;
  10838. verts[v + 1] = tempPos.y;
  10839. verts[v + 2] = tempLight.r;
  10840. verts[v + 3] = tempLight.g;
  10841. verts[v + 4] = tempLight.b;
  10842. verts[v + 5] = tempLight.a;
  10843. verts[v + 6] = tempUv.x;
  10844. verts[v + 7] = tempUv.y;
  10845. verts[v + 8] = tempDark.r;
  10846. verts[v + 9] = tempDark.g;
  10847. verts[v + 10] = tempDark.b;
  10848. verts[v + 11] = tempDark.a;
  10849. }
  10850. }
  10851. }
  10852. batcher.draw(texture, clippedVertices, clippedTriangles);
  10853. }
  10854. else {
  10855. var verts = renderable.vertices;
  10856. if (this.vertexEffect != null) {
  10857. var vertexEffect = this.vertexEffect;
  10858. if (!twoColorTint) {
  10859. for (var v = 0, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) {
  10860. tempPos.x = verts[v];
  10861. tempPos.y = verts[v + 1];
  10862. tempUv.x = uvs[u];
  10863. tempUv.y = uvs[u + 1];
  10864. tempLight.setFromColor(finalColor);
  10865. tempDark.set(0, 0, 0, 0);
  10866. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  10867. verts[v] = tempPos.x;
  10868. verts[v + 1] = tempPos.y;
  10869. verts[v + 2] = tempLight.r;
  10870. verts[v + 3] = tempLight.g;
  10871. verts[v + 4] = tempLight.b;
  10872. verts[v + 5] = tempLight.a;
  10873. verts[v + 6] = tempUv.x;
  10874. verts[v + 7] = tempUv.y;
  10875. }
  10876. }
  10877. else {
  10878. for (var v = 0, u = 0, n_7 = renderable.numFloats; v < n_7; v += vertexSize, u += 2) {
  10879. tempPos.x = verts[v];
  10880. tempPos.y = verts[v + 1];
  10881. tempUv.x = uvs[u];
  10882. tempUv.y = uvs[u + 1];
  10883. tempLight.setFromColor(finalColor);
  10884. tempDark.setFromColor(darkColor);
  10885. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  10886. verts[v] = tempPos.x;
  10887. verts[v + 1] = tempPos.y;
  10888. verts[v + 2] = tempLight.r;
  10889. verts[v + 3] = tempLight.g;
  10890. verts[v + 4] = tempLight.b;
  10891. verts[v + 5] = tempLight.a;
  10892. verts[v + 6] = tempUv.x;
  10893. verts[v + 7] = tempUv.y;
  10894. verts[v + 8] = tempDark.r;
  10895. verts[v + 9] = tempDark.g;
  10896. verts[v + 10] = tempDark.b;
  10897. verts[v + 11] = tempDark.a;
  10898. }
  10899. }
  10900. }
  10901. else {
  10902. if (!twoColorTint) {
  10903. for (var v = 2, u = 0, n_8 = renderable.numFloats; v < n_8; v += vertexSize, u += 2) {
  10904. verts[v] = finalColor.r;
  10905. verts[v + 1] = finalColor.g;
  10906. verts[v + 2] = finalColor.b;
  10907. verts[v + 3] = finalColor.a;
  10908. verts[v + 4] = uvs[u];
  10909. verts[v + 5] = uvs[u + 1];
  10910. }
  10911. }
  10912. else {
  10913. for (var v = 2, u = 0, n_9 = renderable.numFloats; v < n_9; v += vertexSize, u += 2) {
  10914. verts[v] = finalColor.r;
  10915. verts[v + 1] = finalColor.g;
  10916. verts[v + 2] = finalColor.b;
  10917. verts[v + 3] = finalColor.a;
  10918. verts[v + 4] = uvs[u];
  10919. verts[v + 5] = uvs[u + 1];
  10920. verts[v + 6] = darkColor.r;
  10921. verts[v + 7] = darkColor.g;
  10922. verts[v + 8] = darkColor.b;
  10923. verts[v + 9] = darkColor.a;
  10924. }
  10925. }
  10926. }
  10927. var view = renderable.vertices.subarray(0, renderable.numFloats);
  10928. batcher.draw(texture, view, triangles);
  10929. }
  10930. }
  10931. clipper.clipEndWithSlot(slot);
  10932. }
  10933. clipper.clipEnd();
  10934. };
  10935. SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
  10936. return SkeletonRenderer;
  10937. }());
  10938. webgl.SkeletonRenderer = SkeletonRenderer;
  10939. })(webgl = spine.webgl || (spine.webgl = {}));
  10940. })(spine || (spine = {}));
  10941. var spine;
  10942. (function (spine) {
  10943. var webgl;
  10944. (function (webgl) {
  10945. var Vector3 = (function () {
  10946. function Vector3(x, y, z) {
  10947. if (x === void 0) { x = 0; }
  10948. if (y === void 0) { y = 0; }
  10949. if (z === void 0) { z = 0; }
  10950. this.x = 0;
  10951. this.y = 0;
  10952. this.z = 0;
  10953. this.x = x;
  10954. this.y = y;
  10955. this.z = z;
  10956. }
  10957. Vector3.prototype.setFrom = function (v) {
  10958. this.x = v.x;
  10959. this.y = v.y;
  10960. this.z = v.z;
  10961. return this;
  10962. };
  10963. Vector3.prototype.set = function (x, y, z) {
  10964. this.x = x;
  10965. this.y = y;
  10966. this.z = z;
  10967. return this;
  10968. };
  10969. Vector3.prototype.add = function (v) {
  10970. this.x += v.x;
  10971. this.y += v.y;
  10972. this.z += v.z;
  10973. return this;
  10974. };
  10975. Vector3.prototype.sub = function (v) {
  10976. this.x -= v.x;
  10977. this.y -= v.y;
  10978. this.z -= v.z;
  10979. return this;
  10980. };
  10981. Vector3.prototype.scale = function (s) {
  10982. this.x *= s;
  10983. this.y *= s;
  10984. this.z *= s;
  10985. return this;
  10986. };
  10987. Vector3.prototype.normalize = function () {
  10988. var len = this.length();
  10989. if (len == 0)
  10990. return this;
  10991. len = 1 / len;
  10992. this.x *= len;
  10993. this.y *= len;
  10994. this.z *= len;
  10995. return this;
  10996. };
  10997. Vector3.prototype.cross = function (v) {
  10998. return this.set(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x);
  10999. };
  11000. Vector3.prototype.multiply = function (matrix) {
  11001. var l_mat = matrix.values;
  11002. return this.set(this.x * l_mat[webgl.M00] + this.y * l_mat[webgl.M01] + this.z * l_mat[webgl.M02] + l_mat[webgl.M03], this.x * l_mat[webgl.M10] + this.y * l_mat[webgl.M11] + this.z * l_mat[webgl.M12] + l_mat[webgl.M13], this.x * l_mat[webgl.M20] + this.y * l_mat[webgl.M21] + this.z * l_mat[webgl.M22] + l_mat[webgl.M23]);
  11003. };
  11004. Vector3.prototype.project = function (matrix) {
  11005. var l_mat = matrix.values;
  11006. var l_w = 1 / (this.x * l_mat[webgl.M30] + this.y * l_mat[webgl.M31] + this.z * l_mat[webgl.M32] + l_mat[webgl.M33]);
  11007. return this.set((this.x * l_mat[webgl.M00] + this.y * l_mat[webgl.M01] + this.z * l_mat[webgl.M02] + l_mat[webgl.M03]) * l_w, (this.x * l_mat[webgl.M10] + this.y * l_mat[webgl.M11] + this.z * l_mat[webgl.M12] + l_mat[webgl.M13]) * l_w, (this.x * l_mat[webgl.M20] + this.y * l_mat[webgl.M21] + this.z * l_mat[webgl.M22] + l_mat[webgl.M23]) * l_w);
  11008. };
  11009. Vector3.prototype.dot = function (v) {
  11010. return this.x * v.x + this.y * v.y + this.z * v.z;
  11011. };
  11012. Vector3.prototype.length = function () {
  11013. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  11014. };
  11015. Vector3.prototype.distance = function (v) {
  11016. var a = v.x - this.x;
  11017. var b = v.y - this.y;
  11018. var c = v.z - this.z;
  11019. return Math.sqrt(a * a + b * b + c * c);
  11020. };
  11021. return Vector3;
  11022. }());
  11023. webgl.Vector3 = Vector3;
  11024. })(webgl = spine.webgl || (spine.webgl = {}));
  11025. })(spine || (spine = {}));
  11026. var spine;
  11027. (function (spine) {
  11028. var webgl;
  11029. (function (webgl) {
  11030. var ManagedWebGLRenderingContext = (function () {
  11031. function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {
  11032. if (contextConfig === void 0) { contextConfig = { alpha: "true" }; }
  11033. this.restorables = new Array();
  11034. if (canvasOrContext instanceof HTMLCanvasElement || canvasOrContext instanceof EventTarget) {
  11035. this.setupCanvas(canvasOrContext, contextConfig);
  11036. }
  11037. else {
  11038. this.gl = canvasOrContext;
  11039. this.canvas = this.gl.canvas;
  11040. }
  11041. }
  11042. ManagedWebGLRenderingContext.prototype.setupCanvas = function (canvas, contextConfig) {
  11043. var _this = this;
  11044. this.gl = (canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig));
  11045. this.canvas = canvas;
  11046. canvas.addEventListener("webglcontextlost", function (e) {
  11047. var event = e;
  11048. if (e) {
  11049. e.preventDefault();
  11050. }
  11051. });
  11052. canvas.addEventListener("webglcontextrestored", function (e) {
  11053. for (var i = 0, n = _this.restorables.length; i < n; i++) {
  11054. _this.restorables[i].restore();
  11055. }
  11056. });
  11057. };
  11058. ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) {
  11059. this.restorables.push(restorable);
  11060. };
  11061. ManagedWebGLRenderingContext.prototype.removeRestorable = function (restorable) {
  11062. var index = this.restorables.indexOf(restorable);
  11063. if (index > -1)
  11064. this.restorables.splice(index, 1);
  11065. };
  11066. return ManagedWebGLRenderingContext;
  11067. }());
  11068. webgl.ManagedWebGLRenderingContext = ManagedWebGLRenderingContext;
  11069. var WebGLBlendModeConverter = (function () {
  11070. function WebGLBlendModeConverter() {
  11071. }
  11072. WebGLBlendModeConverter.getDestGLBlendMode = function (blendMode) {
  11073. switch (blendMode) {
  11074. case spine.BlendMode.Normal: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  11075. case spine.BlendMode.Additive: return WebGLBlendModeConverter.ONE;
  11076. case spine.BlendMode.Multiply: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  11077. case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  11078. default: throw new Error("Unknown blend mode: " + blendMode);
  11079. }
  11080. };
  11081. WebGLBlendModeConverter.getSourceGLBlendMode = function (blendMode, premultipliedAlpha) {
  11082. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  11083. switch (blendMode) {
  11084. case spine.BlendMode.Normal: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA;
  11085. case spine.BlendMode.Additive: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA;
  11086. case spine.BlendMode.Multiply: return WebGLBlendModeConverter.DST_COLOR;
  11087. case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE;
  11088. default: throw new Error("Unknown blend mode: " + blendMode);
  11089. }
  11090. };
  11091. WebGLBlendModeConverter.ZERO = 0;
  11092. WebGLBlendModeConverter.ONE = 1;
  11093. WebGLBlendModeConverter.SRC_COLOR = 0x0300;
  11094. WebGLBlendModeConverter.ONE_MINUS_SRC_COLOR = 0x0301;
  11095. WebGLBlendModeConverter.SRC_ALPHA = 0x0302;
  11096. WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA = 0x0303;
  11097. WebGLBlendModeConverter.DST_ALPHA = 0x0304;
  11098. WebGLBlendModeConverter.ONE_MINUS_DST_ALPHA = 0x0305;
  11099. WebGLBlendModeConverter.DST_COLOR = 0x0306;
  11100. return WebGLBlendModeConverter;
  11101. }());
  11102. webgl.WebGLBlendModeConverter = WebGLBlendModeConverter;
  11103. })(webgl = spine.webgl || (spine.webgl = {}));
  11104. })(spine || (spine = {}));
  11105. var spine;
  11106. (function (spine) {
  11107. var threejs;
  11108. (function (threejs) {
  11109. var AssetManager = (function (_super) {
  11110. __extends(AssetManager, _super);
  11111. function AssetManager(pathPrefix) {
  11112. if (pathPrefix === void 0) { pathPrefix = ""; }
  11113. return _super.call(this, function (image) {
  11114. return new threejs.ThreeJsTexture(image);
  11115. }, pathPrefix) || this;
  11116. }
  11117. return AssetManager;
  11118. }(spine.AssetManager));
  11119. threejs.AssetManager = AssetManager;
  11120. })(threejs = spine.threejs || (spine.threejs = {}));
  11121. })(spine || (spine = {}));
  11122. var spine;
  11123. (function (spine) {
  11124. var threejs;
  11125. (function (threejs) {
  11126. var MeshBatcher = (function (_super) {
  11127. __extends(MeshBatcher, _super);
  11128. function MeshBatcher(maxVertices, materialCustomizer) {
  11129. if (maxVertices === void 0) { maxVertices = 10920; }
  11130. if (materialCustomizer === void 0) { materialCustomizer = function (parameters) { }; }
  11131. var _this = _super.call(this) || this;
  11132. _this.verticesLength = 0;
  11133. _this.indicesLength = 0;
  11134. if (maxVertices > 10920)
  11135. throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
  11136. var vertices = _this.vertices = new Float32Array(maxVertices * MeshBatcher.VERTEX_SIZE);
  11137. var indices = _this.indices = new Uint16Array(maxVertices * 3);
  11138. var geo = new THREE.BufferGeometry();
  11139. var vertexBuffer = _this.vertexBuffer = new THREE.InterleavedBuffer(vertices, MeshBatcher.VERTEX_SIZE);
  11140. vertexBuffer.usage = WebGLRenderingContext.DYNAMIC_DRAW;
  11141. geo.setAttribute("position", new THREE.InterleavedBufferAttribute(vertexBuffer, 3, 0, false));
  11142. geo.setAttribute("color", new THREE.InterleavedBufferAttribute(vertexBuffer, 4, 3, false));
  11143. geo.setAttribute("uv", new THREE.InterleavedBufferAttribute(vertexBuffer, 2, 7, false));
  11144. geo.setIndex(new THREE.BufferAttribute(indices, 1));
  11145. geo.getIndex().usage = WebGLRenderingContext.DYNAMIC_DRAW;
  11146. ;
  11147. geo.drawRange.start = 0;
  11148. geo.drawRange.count = 0;
  11149. _this.geometry = geo;
  11150. _this.material = new threejs.SkeletonMeshMaterial(materialCustomizer);
  11151. return _this;
  11152. }
  11153. MeshBatcher.prototype.dispose = function () {
  11154. this.geometry.dispose();
  11155. if (this.material instanceof THREE.Material)
  11156. this.material.dispose();
  11157. else if (this.material) {
  11158. for (var i = 0; i < this.material.length; i++) {
  11159. var material = this.material[i];
  11160. if (material instanceof THREE.Material)
  11161. material.dispose();
  11162. }
  11163. }
  11164. };
  11165. MeshBatcher.prototype.clear = function () {
  11166. var geo = this.geometry;
  11167. geo.drawRange.start = 0;
  11168. geo.drawRange.count = 0;
  11169. this.material.uniforms.map.value = null;
  11170. };
  11171. MeshBatcher.prototype.begin = function () {
  11172. this.verticesLength = 0;
  11173. this.indicesLength = 0;
  11174. };
  11175. MeshBatcher.prototype.canBatch = function (verticesLength, indicesLength) {
  11176. if (this.indicesLength + indicesLength >= this.indices.byteLength / 2)
  11177. return false;
  11178. if (this.verticesLength + verticesLength >= this.vertices.byteLength / 2)
  11179. return false;
  11180. return true;
  11181. };
  11182. MeshBatcher.prototype.batch = function (vertices, verticesLength, indices, indicesLength, z) {
  11183. if (z === void 0) { z = 0; }
  11184. var indexStart = this.verticesLength / MeshBatcher.VERTEX_SIZE;
  11185. var vertexBuffer = this.vertices;
  11186. var i = this.verticesLength;
  11187. var j = 0;
  11188. for (; j < verticesLength;) {
  11189. vertexBuffer[i++] = vertices[j++];
  11190. vertexBuffer[i++] = vertices[j++];
  11191. vertexBuffer[i++] = z;
  11192. vertexBuffer[i++] = vertices[j++];
  11193. vertexBuffer[i++] = vertices[j++];
  11194. vertexBuffer[i++] = vertices[j++];
  11195. vertexBuffer[i++] = vertices[j++];
  11196. vertexBuffer[i++] = vertices[j++];
  11197. vertexBuffer[i++] = vertices[j++];
  11198. }
  11199. this.verticesLength = i;
  11200. var indicesArray = this.indices;
  11201. for (i = this.indicesLength, j = 0; j < indicesLength; i++, j++)
  11202. indicesArray[i] = indices[j] + indexStart;
  11203. this.indicesLength += indicesLength;
  11204. };
  11205. MeshBatcher.prototype.end = function () {
  11206. this.vertexBuffer.needsUpdate = this.verticesLength > 0;
  11207. this.vertexBuffer.updateRange.offset = 0;
  11208. this.vertexBuffer.updateRange.count = this.verticesLength;
  11209. var geo = this.geometry;
  11210. geo.getIndex().needsUpdate = this.indicesLength > 0;
  11211. geo.getIndex().updateRange.offset = 0;
  11212. geo.getIndex().updateRange.count = this.indicesLength;
  11213. geo.drawRange.start = 0;
  11214. geo.drawRange.count = this.indicesLength;
  11215. };
  11216. MeshBatcher.VERTEX_SIZE = 9;
  11217. return MeshBatcher;
  11218. }(THREE.Mesh));
  11219. threejs.MeshBatcher = MeshBatcher;
  11220. })(threejs = spine.threejs || (spine.threejs = {}));
  11221. })(spine || (spine = {}));
  11222. var spine;
  11223. (function (spine) {
  11224. var threejs;
  11225. (function (threejs) {
  11226. var SkeletonMeshMaterial = (function (_super) {
  11227. __extends(SkeletonMeshMaterial, _super);
  11228. function SkeletonMeshMaterial(customizer) {
  11229. var _this = this;
  11230. var vertexShader = "\n\t\t\t\tattribute vec4 color;\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tvarying vec4 vColor;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tvColor = color;\n\t\t\t\t\tgl_Position = projectionMatrix*modelViewMatrix*vec4(position,1.0);\n\t\t\t\t}\n\t\t\t";
  11231. var fragmentShader = "\n\t\t\t\tuniform sampler2D map;\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tvarying vec4 vColor;\n\t\t\t\tvoid main(void) {\n\t\t\t\t\tgl_FragColor = texture2D(map, vUv)*vColor;\n\t\t\t\t}\n\t\t\t";
  11232. var parameters = {
  11233. uniforms: {
  11234. map: { type: "t", value: null }
  11235. },
  11236. vertexShader: vertexShader,
  11237. fragmentShader: fragmentShader,
  11238. side: THREE.DoubleSide,
  11239. transparent: true,
  11240. alphaTest: 0.5
  11241. };
  11242. customizer(parameters);
  11243. _this = _super.call(this, parameters) || this;
  11244. return _this;
  11245. }
  11246. ;
  11247. return SkeletonMeshMaterial;
  11248. }(THREE.ShaderMaterial));
  11249. threejs.SkeletonMeshMaterial = SkeletonMeshMaterial;
  11250. var SkeletonMesh = (function (_super) {
  11251. __extends(SkeletonMesh, _super);
  11252. function SkeletonMesh(skeletonData, materialCustomizer) {
  11253. if (materialCustomizer === void 0) { materialCustomizer = function (parameters) { }; }
  11254. var _this = _super.call(this) || this;
  11255. _this.tempPos = new spine.Vector2();
  11256. _this.tempUv = new spine.Vector2();
  11257. _this.tempLight = new spine.Color();
  11258. _this.tempDark = new spine.Color();
  11259. _this.zOffset = 0.1;
  11260. _this.batches = new Array();
  11261. _this.nextBatchIndex = 0;
  11262. _this.clipper = new spine.SkeletonClipping();
  11263. _this.vertices = spine.Utils.newFloatArray(1024);
  11264. _this.tempColor = new spine.Color();
  11265. _this.materialCustomizer = materialCustomizer;
  11266. _this.skeleton = new spine.Skeleton(skeletonData);
  11267. var animData = new spine.AnimationStateData(skeletonData);
  11268. _this.state = new spine.AnimationState(animData);
  11269. return _this;
  11270. }
  11271. SkeletonMesh.prototype.update = function (deltaTime) {
  11272. var state = this.state;
  11273. var skeleton = this.skeleton;
  11274. state.update(deltaTime);
  11275. state.apply(skeleton);
  11276. skeleton.updateWorldTransform();
  11277. this.updateGeometry();
  11278. };
  11279. SkeletonMesh.prototype.dispose = function () {
  11280. for (var i = 0; i < this.batches.length; i++) {
  11281. this.batches[i].dispose();
  11282. }
  11283. };
  11284. SkeletonMesh.prototype.clearBatches = function () {
  11285. for (var i = 0; i < this.batches.length; i++) {
  11286. this.batches[i].clear();
  11287. this.batches[i].visible = false;
  11288. }
  11289. this.nextBatchIndex = 0;
  11290. };
  11291. SkeletonMesh.prototype.nextBatch = function () {
  11292. if (this.batches.length == this.nextBatchIndex) {
  11293. var batch_1 = new threejs.MeshBatcher(10920, this.materialCustomizer);
  11294. this.add(batch_1);
  11295. this.batches.push(batch_1);
  11296. }
  11297. var batch = this.batches[this.nextBatchIndex++];
  11298. batch.visible = true;
  11299. return batch;
  11300. };
  11301. SkeletonMesh.prototype.updateGeometry = function () {
  11302. this.clearBatches();
  11303. var tempPos = this.tempPos;
  11304. var tempUv = this.tempUv;
  11305. var tempLight = this.tempLight;
  11306. var tempDark = this.tempDark;
  11307. var numVertices = 0;
  11308. var verticesLength = 0;
  11309. var indicesLength = 0;
  11310. var blendMode = null;
  11311. var clipper = this.clipper;
  11312. var vertices = this.vertices;
  11313. var triangles = null;
  11314. var uvs = null;
  11315. var drawOrder = this.skeleton.drawOrder;
  11316. var batch = this.nextBatch();
  11317. batch.begin();
  11318. var z = 0;
  11319. var zOffset = this.zOffset;
  11320. for (var i = 0, n = drawOrder.length; i < n; i++) {
  11321. var vertexSize = clipper.isClipping() ? 2 : SkeletonMesh.VERTEX_SIZE;
  11322. var slot = drawOrder[i];
  11323. if (!slot.bone.active)
  11324. continue;
  11325. var attachment = slot.getAttachment();
  11326. var attachmentColor = null;
  11327. var texture = null;
  11328. var numFloats = 0;
  11329. if (attachment instanceof spine.RegionAttachment) {
  11330. var region = attachment;
  11331. attachmentColor = region.color;
  11332. vertices = this.vertices;
  11333. numFloats = vertexSize * 4;
  11334. region.computeWorldVertices(slot.bone, vertices, 0, vertexSize);
  11335. triangles = SkeletonMesh.QUAD_TRIANGLES;
  11336. uvs = region.uvs;
  11337. texture = region.region.renderObject.texture;
  11338. }
  11339. else if (attachment instanceof spine.MeshAttachment) {
  11340. var mesh = attachment;
  11341. attachmentColor = mesh.color;
  11342. vertices = this.vertices;
  11343. numFloats = (mesh.worldVerticesLength >> 1) * vertexSize;
  11344. if (numFloats > vertices.length) {
  11345. vertices = this.vertices = spine.Utils.newFloatArray(numFloats);
  11346. }
  11347. mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, vertexSize);
  11348. triangles = mesh.triangles;
  11349. uvs = mesh.uvs;
  11350. texture = mesh.region.renderObject.texture;
  11351. }
  11352. else if (attachment instanceof spine.ClippingAttachment) {
  11353. var clip = (attachment);
  11354. clipper.clipStart(slot, clip);
  11355. continue;
  11356. }
  11357. else
  11358. continue;
  11359. if (texture != null) {
  11360. var skeleton = slot.bone.skeleton;
  11361. var skeletonColor = skeleton.color;
  11362. var slotColor = slot.color;
  11363. var alpha = skeletonColor.a * slotColor.a * attachmentColor.a;
  11364. var color = this.tempColor;
  11365. color.set(skeletonColor.r * slotColor.r * attachmentColor.r, skeletonColor.g * slotColor.g * attachmentColor.g, skeletonColor.b * slotColor.b * attachmentColor.b, alpha);
  11366. var finalVertices = void 0;
  11367. var finalVerticesLength = void 0;
  11368. var finalIndices = void 0;
  11369. var finalIndicesLength = void 0;
  11370. if (clipper.isClipping()) {
  11371. clipper.clipTriangles(vertices, numFloats, triangles, triangles.length, uvs, color, null, false);
  11372. var clippedVertices = clipper.clippedVertices;
  11373. var clippedTriangles = clipper.clippedTriangles;
  11374. if (this.vertexEffect != null) {
  11375. var vertexEffect = this.vertexEffect;
  11376. var verts = clippedVertices;
  11377. for (var v = 0, n_10 = clippedVertices.length; v < n_10; v += vertexSize) {
  11378. tempPos.x = verts[v];
  11379. tempPos.y = verts[v + 1];
  11380. tempLight.setFromColor(color);
  11381. tempDark.set(0, 0, 0, 0);
  11382. tempUv.x = verts[v + 6];
  11383. tempUv.y = verts[v + 7];
  11384. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  11385. verts[v] = tempPos.x;
  11386. verts[v + 1] = tempPos.y;
  11387. verts[v + 2] = tempLight.r;
  11388. verts[v + 3] = tempLight.g;
  11389. verts[v + 4] = tempLight.b;
  11390. verts[v + 5] = tempLight.a;
  11391. verts[v + 6] = tempUv.x;
  11392. verts[v + 7] = tempUv.y;
  11393. }
  11394. }
  11395. finalVertices = clippedVertices;
  11396. finalVerticesLength = clippedVertices.length;
  11397. finalIndices = clippedTriangles;
  11398. finalIndicesLength = clippedTriangles.length;
  11399. }
  11400. else {
  11401. var verts = vertices;
  11402. if (this.vertexEffect != null) {
  11403. var vertexEffect = this.vertexEffect;
  11404. for (var v = 0, u = 0, n_11 = numFloats; v < n_11; v += vertexSize, u += 2) {
  11405. tempPos.x = verts[v];
  11406. tempPos.y = verts[v + 1];
  11407. tempLight.setFromColor(color);
  11408. tempDark.set(0, 0, 0, 0);
  11409. tempUv.x = uvs[u];
  11410. tempUv.y = uvs[u + 1];
  11411. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  11412. verts[v] = tempPos.x;
  11413. verts[v + 1] = tempPos.y;
  11414. verts[v + 2] = tempLight.r;
  11415. verts[v + 3] = tempLight.g;
  11416. verts[v + 4] = tempLight.b;
  11417. verts[v + 5] = tempLight.a;
  11418. verts[v + 6] = tempUv.x;
  11419. verts[v + 7] = tempUv.y;
  11420. }
  11421. }
  11422. else {
  11423. for (var v = 2, u = 0, n_12 = numFloats; v < n_12; v += vertexSize, u += 2) {
  11424. verts[v] = color.r;
  11425. verts[v + 1] = color.g;
  11426. verts[v + 2] = color.b;
  11427. verts[v + 3] = color.a;
  11428. verts[v + 4] = uvs[u];
  11429. verts[v + 5] = uvs[u + 1];
  11430. }
  11431. }
  11432. finalVertices = vertices;
  11433. finalVerticesLength = numFloats;
  11434. finalIndices = triangles;
  11435. finalIndicesLength = triangles.length;
  11436. }
  11437. if (finalVerticesLength == 0 || finalIndicesLength == 0)
  11438. continue;
  11439. if (!batch.canBatch(finalVerticesLength, finalIndicesLength)) {
  11440. batch.end();
  11441. batch = this.nextBatch();
  11442. batch.begin();
  11443. }
  11444. var batchMaterial = batch.material;
  11445. if (batchMaterial.uniforms.map.value == null) {
  11446. batchMaterial.uniforms.map.value = texture.texture;
  11447. }
  11448. if (batchMaterial.uniforms.map.value != texture.texture) {
  11449. batch.end();
  11450. batch = this.nextBatch();
  11451. batch.begin();
  11452. batchMaterial = batch.material;
  11453. batchMaterial.uniforms.map.value = texture.texture;
  11454. }
  11455. batchMaterial.needsUpdate = true;
  11456. batch.batch(finalVertices, finalVerticesLength, finalIndices, finalIndicesLength, z);
  11457. z += zOffset;
  11458. }
  11459. clipper.clipEndWithSlot(slot);
  11460. }
  11461. clipper.clipEnd();
  11462. batch.end();
  11463. };
  11464. SkeletonMesh.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
  11465. SkeletonMesh.VERTEX_SIZE = 2 + 2 + 4;
  11466. return SkeletonMesh;
  11467. }(THREE.Object3D));
  11468. threejs.SkeletonMesh = SkeletonMesh;
  11469. })(threejs = spine.threejs || (spine.threejs = {}));
  11470. })(spine || (spine = {}));
  11471. var spine;
  11472. (function (spine) {
  11473. var threejs;
  11474. (function (threejs) {
  11475. var ThreeJsTexture = (function (_super) {
  11476. __extends(ThreeJsTexture, _super);
  11477. function ThreeJsTexture(image) {
  11478. var _this = _super.call(this, image) || this;
  11479. _this.texture = new THREE.Texture(image);
  11480. _this.texture.flipY = false;
  11481. _this.texture.needsUpdate = true;
  11482. return _this;
  11483. }
  11484. ThreeJsTexture.prototype.setFilters = function (minFilter, magFilter) {
  11485. this.texture.minFilter = ThreeJsTexture.toThreeJsTextureFilter(minFilter);
  11486. this.texture.magFilter = ThreeJsTexture.toThreeJsTextureFilter(magFilter);
  11487. };
  11488. ThreeJsTexture.prototype.setWraps = function (uWrap, vWrap) {
  11489. this.texture.wrapS = ThreeJsTexture.toThreeJsTextureWrap(uWrap);
  11490. this.texture.wrapT = ThreeJsTexture.toThreeJsTextureWrap(vWrap);
  11491. };
  11492. ThreeJsTexture.prototype.dispose = function () {
  11493. this.texture.dispose();
  11494. };
  11495. ThreeJsTexture.toThreeJsTextureFilter = function (filter) {
  11496. if (filter === spine.TextureFilter.Linear)
  11497. return THREE.LinearFilter;
  11498. else if (filter === spine.TextureFilter.MipMap)
  11499. return THREE.LinearMipMapLinearFilter;
  11500. else if (filter === spine.TextureFilter.MipMapLinearNearest)
  11501. return THREE.LinearMipMapNearestFilter;
  11502. else if (filter === spine.TextureFilter.MipMapNearestLinear)
  11503. return THREE.NearestMipMapLinearFilter;
  11504. else if (filter === spine.TextureFilter.MipMapNearestNearest)
  11505. return THREE.NearestMipMapNearestFilter;
  11506. else if (filter === spine.TextureFilter.Nearest)
  11507. return THREE.NearestFilter;
  11508. else
  11509. throw new Error("Unknown texture filter: " + filter);
  11510. };
  11511. ThreeJsTexture.toThreeJsTextureWrap = function (wrap) {
  11512. if (wrap === spine.TextureWrap.ClampToEdge)
  11513. return THREE.ClampToEdgeWrapping;
  11514. else if (wrap === spine.TextureWrap.MirroredRepeat)
  11515. return THREE.MirroredRepeatWrapping;
  11516. else if (wrap === spine.TextureWrap.Repeat)
  11517. return THREE.RepeatWrapping;
  11518. else
  11519. throw new Error("Unknown texture wrap: " + wrap);
  11520. };
  11521. return ThreeJsTexture;
  11522. }(spine.Texture));
  11523. threejs.ThreeJsTexture = ThreeJsTexture;
  11524. })(threejs = spine.threejs || (spine.threejs = {}));
  11525. })(spine || (spine = {}));
  11526. var spine;
  11527. (function (spine) {
  11528. var Popup = (function () {
  11529. function Popup(player, parent, htmlContent) {
  11530. this.player = player;
  11531. this.dom = createElement("\n\t\t\t\t<div class=\"spine-player-popup spine-player-hidden\">\n\t\t\t\t</div>\n\t\t\t");
  11532. this.dom.innerHTML = htmlContent;
  11533. parent.appendChild(this.dom);
  11534. }
  11535. Popup.prototype.show = function (dismissedListener) {
  11536. var _this = this;
  11537. this.dom.classList.remove("spine-player-hidden");
  11538. var dismissed = false;
  11539. var resize = function () {
  11540. if (!dismissed)
  11541. requestAnimationFrame(resize);
  11542. var bottomOffset = Math.abs(_this.dom.getBoundingClientRect().bottom - _this.player.getBoundingClientRect().bottom);
  11543. var rightOffset = Math.abs(_this.dom.getBoundingClientRect().right - _this.player.getBoundingClientRect().right);
  11544. var maxHeight = _this.player.clientHeight - bottomOffset - rightOffset;
  11545. _this.dom.style.maxHeight = maxHeight + "px";
  11546. };
  11547. requestAnimationFrame(resize);
  11548. var justClicked = true;
  11549. var windowClickListener = function (event) {
  11550. if (justClicked) {
  11551. justClicked = false;
  11552. return;
  11553. }
  11554. if (!isContained(_this.dom, event.target)) {
  11555. _this.dom.remove();
  11556. window.removeEventListener("click", windowClickListener);
  11557. dismissedListener();
  11558. dismissed = true;
  11559. }
  11560. };
  11561. window.addEventListener("click", windowClickListener);
  11562. };
  11563. return Popup;
  11564. }());
  11565. var Switch = (function () {
  11566. function Switch(text) {
  11567. this.text = text;
  11568. this.enabled = false;
  11569. }
  11570. Switch.prototype.render = function () {
  11571. var _this = this;
  11572. this["switch"] = createElement("\n\t\t\t\t<div class=\"spine-player-switch\">\n\t\t\t\t\t<span class=\"spine-player-switch-text\">" + this.text + "</span>\n\t\t\t\t\t<div class=\"spine-player-switch-knob-area\">\n\t\t\t\t\t\t<div class=\"spine-player-switch-knob\"></div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t");
  11573. this["switch"].addEventListener("click", function () {
  11574. _this.setEnabled(!_this.enabled);
  11575. if (_this.change)
  11576. _this.change(_this.enabled);
  11577. });
  11578. return this["switch"];
  11579. };
  11580. Switch.prototype.setEnabled = function (enabled) {
  11581. if (enabled)
  11582. this["switch"].classList.add("active");
  11583. else
  11584. this["switch"].classList.remove("active");
  11585. this.enabled = enabled;
  11586. };
  11587. Switch.prototype.isEnabled = function () {
  11588. return this.enabled;
  11589. };
  11590. return Switch;
  11591. }());
  11592. var Slider = (function () {
  11593. function Slider(snaps, snapPercentage, big) {
  11594. if (snaps === void 0) { snaps = 0; }
  11595. if (snapPercentage === void 0) { snapPercentage = 0.1; }
  11596. if (big === void 0) { big = false; }
  11597. this.snaps = snaps;
  11598. this.snapPercentage = snapPercentage;
  11599. this.big = big;
  11600. }
  11601. Slider.prototype.render = function () {
  11602. var _this = this;
  11603. this.slider = createElement("\n\t\t\t\t<div class=\"spine-player-slider " + (this.big ? "big" : "") + "\">\n\t\t\t\t\t<div class=\"spine-player-slider-value\"></div>\n\t\t\t\t\t<!--<div class=\"spine-player-slider-knob\"></div>-->\n\t\t\t\t</div>\n\t\t\t");
  11604. this.value = findWithClass(this.slider, "spine-player-slider-value")[0];
  11605. this.setValue(0);
  11606. var input = new spine.webgl.Input(this.slider);
  11607. var dragging = false;
  11608. input.addListener({
  11609. down: function (x, y) {
  11610. dragging = true;
  11611. _this.value.classList.add("hovering");
  11612. },
  11613. up: function (x, y) {
  11614. dragging = false;
  11615. var percentage = x / _this.slider.clientWidth;
  11616. percentage = percentage = Math.max(0, Math.min(percentage, 1));
  11617. _this.setValue(x / _this.slider.clientWidth);
  11618. if (_this.change)
  11619. _this.change(percentage);
  11620. _this.value.classList.remove("hovering");
  11621. },
  11622. moved: function (x, y) {
  11623. if (dragging) {
  11624. var percentage = x / _this.slider.clientWidth;
  11625. percentage = Math.max(0, Math.min(percentage, 1));
  11626. percentage = _this.setValue(x / _this.slider.clientWidth);
  11627. if (_this.change)
  11628. _this.change(percentage);
  11629. }
  11630. },
  11631. dragged: function (x, y) {
  11632. var percentage = x / _this.slider.clientWidth;
  11633. percentage = Math.max(0, Math.min(percentage, 1));
  11634. percentage = _this.setValue(x / _this.slider.clientWidth);
  11635. if (_this.change)
  11636. _this.change(percentage);
  11637. }
  11638. });
  11639. return this.slider;
  11640. };
  11641. Slider.prototype.setValue = function (percentage) {
  11642. percentage = Math.max(0, Math.min(1, percentage));
  11643. if (this.snaps > 0) {
  11644. var modulo = percentage % (1 / this.snaps);
  11645. if (modulo < (1 / this.snaps) * this.snapPercentage) {
  11646. percentage = percentage - modulo;
  11647. }
  11648. else if (modulo > (1 / this.snaps) - (1 / this.snaps) * this.snapPercentage) {
  11649. percentage = percentage - modulo + (1 / this.snaps);
  11650. }
  11651. percentage = Math.max(0, Math.min(1, percentage));
  11652. }
  11653. this.value.style.width = "" + (percentage * 100) + "%";
  11654. return percentage;
  11655. };
  11656. return Slider;
  11657. }());
  11658. var SpinePlayer = (function () {
  11659. function SpinePlayer(parent, config) {
  11660. this.config = config;
  11661. this.paused = true;
  11662. this.playTime = 0;
  11663. this.speed = 1;
  11664. this.time = new spine.TimeKeeper();
  11665. this.animationViewports = {};
  11666. this.currentViewport = null;
  11667. this.previousViewport = null;
  11668. this.viewportTransitionStart = 0;
  11669. this.stopRequestAnimationFrame = false;
  11670. this.cancelId = 0;
  11671. if (typeof parent === "string")
  11672. this.parent = document.getElementById(parent);
  11673. else
  11674. this.parent = parent;
  11675. this.parent.appendChild(this.render());
  11676. }
  11677. SpinePlayer.prototype.validateConfig = function (config) {
  11678. if (!config)
  11679. throw new Error("Please pass a configuration to new.spine.SpinePlayer().");
  11680. if (!config.jsonUrl && !config.skelUrl)
  11681. throw new Error("Please specify the URL of the skeleton JSON or .skel file.");
  11682. if (!config.atlasUrl)
  11683. throw new Error("Please specify the URL of the atlas file.");
  11684. if (!config.alpha)
  11685. config.alpha = false;
  11686. if (!config.backgroundColor)
  11687. config.backgroundColor = "#000000";
  11688. if (!config.fullScreenBackgroundColor)
  11689. config.fullScreenBackgroundColor = config.backgroundColor;
  11690. if (typeof config.premultipliedAlpha === "undefined")
  11691. config.premultipliedAlpha = true;
  11692. if (!config.success)
  11693. config.success = function (widget) { };
  11694. if (!config.error)
  11695. config.error = function (widget, msg) { };
  11696. if (!config.debug)
  11697. config.debug = {
  11698. bones: false,
  11699. regions: false,
  11700. meshes: false,
  11701. bounds: false,
  11702. clipping: false,
  11703. paths: false,
  11704. points: false,
  11705. hulls: false
  11706. };
  11707. if (typeof config.debug.bones === "undefined")
  11708. config.debug.bones = false;
  11709. if (typeof config.debug.bounds === "undefined")
  11710. config.debug.bounds = false;
  11711. if (typeof config.debug.clipping === "undefined")
  11712. config.debug.clipping = false;
  11713. if (typeof config.debug.hulls === "undefined")
  11714. config.debug.hulls = false;
  11715. if (typeof config.debug.paths === "undefined")
  11716. config.debug.paths = false;
  11717. if (typeof config.debug.points === "undefined")
  11718. config.debug.points = false;
  11719. if (typeof config.debug.regions === "undefined")
  11720. config.debug.regions = false;
  11721. if (typeof config.debug.meshes === "undefined")
  11722. config.debug.meshes = false;
  11723. if (config.animations && config.animation) {
  11724. if (config.animations.indexOf(config.animation) < 0)
  11725. throw new Error("Default animation '" + config.animation + "' is not contained in the list of selectable animations " + escapeHtml(JSON.stringify(this.config.animations)) + ".");
  11726. }
  11727. if (config.skins && config.skin) {
  11728. if (config.skins.indexOf(config.skin) < 0)
  11729. throw new Error("Default skin '" + config.skin + "' is not contained in the list of selectable skins " + escapeHtml(JSON.stringify(this.config.skins)) + ".");
  11730. }
  11731. if (!config.controlBones)
  11732. config.controlBones = [];
  11733. if (typeof config.showControls === "undefined")
  11734. config.showControls = true;
  11735. if (typeof config.defaultMix === "undefined")
  11736. config.defaultMix = 0.25;
  11737. return config;
  11738. };
  11739. SpinePlayer.prototype.showError = function (error) {
  11740. var errorDom = findWithClass(this.dom, "spine-player-error")[0];
  11741. errorDom.classList.remove("spine-player-hidden");
  11742. errorDom.innerHTML = "<p style=\"text-align: center; align-self: center;\">" + error + "</p>";
  11743. this.config.error(this, error);
  11744. };
  11745. SpinePlayer.prototype.render = function () {
  11746. var _this = this;
  11747. var config = this.config;
  11748. var dom = this.dom = createElement("\n\t\t\t\t<div class=\"spine-player\">\n\t\t\t\t\t<canvas class=\"spine-player-canvas\"></canvas>\n\t\t\t\t\t<div class=\"spine-player-error spine-player-hidden\"></div>\n\t\t\t\t\t<div class=\"spine-player-controls spine-player-popup-parent spine-player-controls-hidden\">\n\t\t\t\t\t\t<div class=\"spine-player-timeline\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"spine-player-buttons\">\n\t\t\t\t\t\t\t<button id=\"spine-player-button-play-pause\" class=\"spine-player-button spine-player-button-icon-pause\"></button>\n\t\t\t\t\t\t\t<div class=\"spine-player-button-spacer\"></div>\n\t\t\t\t\t\t\t<button id=\"spine-player-button-speed\" class=\"spine-player-button spine-player-button-icon-speed\"></button>\n\t\t\t\t\t\t\t<button id=\"spine-player-button-animation\" class=\"spine-player-button spine-player-button-icon-animations\"></button>\n\t\t\t\t\t\t\t<button id=\"spine-player-button-skin\" class=\"spine-player-button spine-player-button-icon-skins\"></button>\n\t\t\t\t\t\t\t<button id=\"spine-player-button-settings\" class=\"spine-player-button spine-player-button-icon-settings\"></button>\n\t\t\t\t\t\t\t<button id=\"spine-player-button-fullscreen\" class=\"spine-player-button spine-player-button-icon-fullscreen\"></button>\n\t\t\t\t\t\t\t<img id=\"spine-player-button-logo\" class=\"spine-player-button-icon-spine-logo\" src=\"data:image/svg+xml,%3Csvg%20id%3D%22Spine_Logo%22%20data-name%3D%22Spine%20Logo%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20104%2031.16%22%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill%3A%23fff%3B%7D.cls-2%7Bfill%3A%23ff4000%3B%7D%3C%2Fstyle%3E%3C%2Fdefs%3E%3Ctitle%3Espine-logo-white%3C%2Ftitle%3E%3Cpath%20id%3D%22e%22%20class%3D%22cls-1%22%20d%3D%22M104%2C12.68a1.31%2C1.31%2C0%2C0%2C1-.37%2C1%2C1.28%2C1.28%2C0%2C0%2C1-.85.31H91.57a10.51%2C10.51%2C0%2C0%2C0%2C.29%2C2.55%2C4.92%2C4.92%2C0%2C0%2C0%2C1%2C2A4.27%2C4.27%2C0%2C0%2C0%2C94.5%2C19.8a6.89%2C6.89%2C0%2C0%2C0%2C2.6.44%2C10.66%2C10.66%2C0%2C0%2C0%2C2.17-.2%2C12.81%2C12.81%2C0%2C0%2C0%2C1.64-.44q.69-.25%2C1.14-.44a1.87%2C1.87%2C0%2C0%2C1%2C.68-.2A.44.44%2C0%2C0%2C1%2C103%2C19a.43.43%2C0%2C0%2C1%2C.16.2%2C1.38%2C1.38%2C0%2C0%2C1%2C.09.37%2C4.89%2C4.89%2C0%2C0%2C1%2C0%2C.58%2C4.14%2C4.14%2C0%2C0%2C1%2C0%2C.43v.32a.83.83%2C0%2C0%2C1-.09.26%2C1.1%2C1.1%2C0%2C0%2C1-.17.22%2C2.77%2C2.77%2C0%2C0%2C1-.61.34%2C8.94%2C8.94%2C0%2C0%2C1-1.32.46%2C18.54%2C18.54%2C0%2C0%2C1-1.88.41%2C13.78%2C13.78%2C0%2C0%2C1-2.28.18%2C10.55%2C10.55%2C0%2C0%2C1-3.68-.59%2C6.82%2C6.82%2C0%2C0%2C1-2.66-1.74%2C7.44%2C7.44%2C0%2C0%2C1-1.63-2.89%2C13.48%2C13.48%2C0%2C0%2C1-.55-4%2C12.76%2C12.76%2C0%2C0%2C1%2C.57-3.94%2C8.35%2C8.35%2C0%2C0%2C1%2C1.64-3%2C7.15%2C7.15%2C0%2C0%2C1%2C2.58-1.87%2C8.47%2C8.47%2C0%2C0%2C1%2C3.39-.65%2C8.19%2C8.19%2C0%2C0%2C1%2C3.41.64%2C6.46%2C6.46%2C0%2C0%2C1%2C2.32%2C1.73A7%2C7%2C0%2C0%2C1%2C103.59%2C9a11.17%2C11.17%2C0%2C0%2C1%2C.43%2C3.13Zm-3.14-.93a5.69%2C5.69%2C0%2C0%2C0-1.09-3.86%2C4.17%2C4.17%2C0%2C0%2C0-3.42-1.4%2C4.52%2C4.52%2C0%2C0%2C0-2%2C.44%2C4.41%2C4.41%2C0%2C0%2C0-1.47%2C1.15A5.29%2C5.29%2C0%2C0%2C0%2C92%2C9.75a7%2C7%2C0%2C0%2C0-.36%2C2Z%22%2F%3E%3Cpath%20id%3D%22n%22%20class%3D%22cls-1%22%20d%3D%22M80.68%2C21.94a.42.42%2C0%2C0%2C1-.08.26.59.59%2C0%2C0%2C1-.25.18%2C1.74%2C1.74%2C0%2C0%2C1-.47.11%2C6.31%2C6.31%2C0%2C0%2C1-.76%2C0%2C6.5%2C6.5%2C0%2C0%2C1-.78%2C0%2C1.74%2C1.74%2C0%2C0%2C1-.47-.11.59.59%2C0%2C0%2C1-.25-.18.42.42%2C0%2C0%2C1-.08-.26V12a9.8%2C9.8%2C0%2C0%2C0-.23-2.35%2C4.86%2C4.86%2C0%2C0%2C0-.66-1.53%2C2.88%2C2.88%2C0%2C0%2C0-1.13-1%2C3.57%2C3.57%2C0%2C0%2C0-1.6-.34%2C4%2C4%2C0%2C0%2C0-2.35.83A12.71%2C12.71%2C0%2C0%2C0%2C69.11%2C10v11.9a.42.42%2C0%2C0%2C1-.08.26.59.59%2C0%2C0%2C1-.25.18%2C1.74%2C1.74%2C0%2C0%2C1-.47.11%2C6.51%2C6.51%2C0%2C0%2C1-.78%2C0%2C6.31%2C6.31%2C0%2C0%2C1-.76%2C0%2C1.88%2C1.88%2C0%2C0%2C1-.48-.11.52.52%2C0%2C0%2C1-.25-.18.46.46%2C0%2C0%2C1-.07-.26v-17A.53.53%2C0%2C0%2C1%2C66%2C4.69a.5.5%2C0%2C0%2C1%2C.23-.19%2C1.28%2C1.28%2C0%2C0%2C1%2C.44-.11%2C8.53%2C8.53%2C0%2C0%2C1%2C1.39%2C0%2C1.12%2C1.12%2C0%2C0%2C1%2C.43.11.6.6%2C0%2C0%2C1%2C.22.19.47.47%2C0%2C0%2C1%2C.07.26V7.2a10.46%2C10.46%2C0%2C0%2C1%2C2.87-2.36%2C6.17%2C6.17%2C0%2C0%2C1%2C2.88-.75%2C6.41%2C6.41%2C0%2C0%2C1%2C2.87.58%2C5.16%2C5.16%2C0%2C0%2C1%2C1.88%2C1.54%2C6.15%2C6.15%2C0%2C0%2C1%2C1%2C2.26%2C13.46%2C13.46%2C0%2C0%2C1%2C.31%2C3.11Z%22%2F%3E%3Cg%20id%3D%22i%22%3E%3Cpath%20class%3D%22cls-2%22%20d%3D%22M43.35%2C2.86c.09%2C2.6%2C1.89%2C4%2C5.48%2C4.61%2C3%2C.48%2C5.79.24%2C6.69-2.37%2C1.75-5.09-2.4-3.82-6-4.39S43.21-1.32%2C43.35%2C2.86Z%22%2F%3E%3Cpath%20class%3D%22cls-2%22%20d%3D%22M44.43%2C13.55c.33%2C1.94%2C2.14%2C3.06%2C4.91%2C3s4.84-1.16%2C5.13-3.25c.53-3.88-2.53-2.38-5.3-2.3S43.77%2C9.74%2C44.43%2C13.55Z%22%2F%3E%3Cpath%20class%3D%22cls-2%22%20d%3D%22M48%2C22.44c.55%2C1.45%2C2.06%2C2.06%2C4.1%2C1.63s3.45-1.11%2C3.33-2.76c-.21-3.06-2.22-2.1-4.26-1.66S47%2C19.6%2C48%2C22.44Z%22%2F%3E%3Cpath%20class%3D%22cls-2%22%20d%3D%22M49.78%2C29.22c.16%2C1.22%2C1.22%2C2%2C2.88%2C1.93s2.92-.67%2C3.13-2c.4-2.43-1.46-1.53-3.12-1.51S49.5%2C26.82%2C49.78%2C29.22Z%22%2F%3E%3C%2Fg%3E%3Cpath%20id%3D%22p%22%20class%3D%22cls-1%22%20d%3D%22M35.28%2C13.16a15.33%2C15.33%2C0%2C0%2C1-.48%2C4%2C8.75%2C8.75%2C0%2C0%2C1-1.42%2C3%2C6.35%2C6.35%2C0%2C0%2C1-2.32%2C1.91%2C7.14%2C7.14%2C0%2C0%2C1-3.16.67%2C6.1%2C6.1%2C0%2C0%2C1-1.4-.15%2C5.34%2C5.34%2C0%2C0%2C1-1.26-.47A7.29%2C7.29%2C0%2C0%2C1%2C24%2C21.31q-.61-.49-1.29-1.15v8.51a.47.47%2C0%2C0%2C1-.08.26.56.56%2C0%2C0%2C1-.25.19%2C1.74%2C1.74%2C0%2C0%2C1-.47.11%2C6.47%2C6.47%2C0%2C0%2C1-.78%2C0%2C6.26%2C6.26%2C0%2C0%2C1-.76%2C0%2C1.89%2C1.89%2C0%2C0%2C1-.48-.11.49.49%2C0%2C0%2C1-.25-.19.51.51%2C0%2C0%2C1-.07-.26V4.91a.57.57%2C0%2C0%2C1%2C.06-.27.46.46%2C0%2C0%2C1%2C.23-.18%2C1.47%2C1.47%2C0%2C0%2C1%2C.44-.1%2C7.41%2C7.41%2C0%2C0%2C1%2C1.3%2C0%2C1.45%2C1.45%2C0%2C0%2C1%2C.43.1.52.52%2C0%2C0%2C1%2C.24.18.51.51%2C0%2C0%2C1%2C.07.27V7.2a18.06%2C18.06%2C0%2C0%2C1%2C1.49-1.38%2C9%2C9%2C0%2C0%2C1%2C1.45-1%2C6.82%2C6.82%2C0%2C0%2C1%2C1.49-.59%2C7.09%2C7.09%2C0%2C0%2C1%2C4.78.52%2C6%2C6%2C0%2C0%2C1%2C2.13%2C2%2C8.79%2C8.79%2C0%2C0%2C1%2C1.2%2C2.9A15.72%2C15.72%2C0%2C0%2C1%2C35.28%2C13.16ZM32%2C13.52a15.64%2C15.64%2C0%2C0%2C0-.2-2.53%2C7.32%2C7.32%2C0%2C0%2C0-.69-2.17%2C4.06%2C4.06%2C0%2C0%2C0-1.3-1.51%2C3.49%2C3.49%2C0%2C0%2C0-2-.57%2C4.1%2C4.1%2C0%2C0%2C0-1.2.18%2C4.92%2C4.92%2C0%2C0%2C0-1.2.57%2C8.54%2C8.54%2C0%2C0%2C0-1.28%2C1A15.77%2C15.77%2C0%2C0%2C0%2C22.76%2C10v6.77a13.53%2C13.53%2C0%2C0%2C0%2C2.46%2C2.4%2C4.12%2C4.12%2C0%2C0%2C0%2C2.44.83%2C3.56%2C3.56%2C0%2C0%2C0%2C2-.57A4.28%2C4.28%2C0%2C0%2C0%2C31%2C18a7.58%2C7.58%2C0%2C0%2C0%2C.77-2.12A11.43%2C11.43%2C0%2C0%2C0%2C32%2C13.52Z%22%2F%3E%3Cpath%20id%3D%22s%22%20class%3D%22cls-1%22%20d%3D%22M12%2C17.3a5.39%2C5.39%2C0%2C0%2C1-.48%2C2.33%2C4.73%2C4.73%2C0%2C0%2C1-1.37%2C1.72%2C6.19%2C6.19%2C0%2C0%2C1-2.12%2C1.06%2C9.62%2C9.62%2C0%2C0%2C1-2.71.36%2C10.38%2C10.38%2C0%2C0%2C1-3.21-.5%2C7.63%2C7.63%2C0%2C0%2C1-1.11-.45%2C3.25%2C3.25%2C0%2C0%2C1-.66-.43%2C1.09%2C1.09%2C0%2C0%2C1-.3-.53A3.59%2C3.59%2C0%2C0%2C1%2C0%2C19.93a4.06%2C4.06%2C0%2C0%2C1%2C0-.61%2C2%2C2%2C0%2C0%2C1%2C.09-.4.42.42%2C0%2C0%2C1%2C.16-.22.43.43%2C0%2C0%2C1%2C.24-.07%2C1.35%2C1.35%2C0%2C0%2C1%2C.61.26q.41.26%2C1%2C.56A9.22%2C9.22%2C0%2C0%2C0%2C3.51%2C20a6.25%2C6.25%2C0%2C0%2C0%2C1.87.26%2C5.62%2C5.62%2C0%2C0%2C0%2C1.44-.17%2C3.48%2C3.48%2C0%2C0%2C0%2C1.12-.5%2C2.23%2C2.23%2C0%2C0%2C0%2C.73-.84%2C2.68%2C2.68%2C0%2C0%2C0%2C.26-1.21%2C2%2C2%2C0%2C0%2C0-.37-1.21%2C3.55%2C3.55%2C0%2C0%2C0-1-.87A8.09%2C8.09%2C0%2C0%2C0%2C6.2%2C14.8l-1.56-.61a16%2C16%2C0%2C0%2C1-1.57-.73%2C6%2C6%2C0%2C0%2C1-1.37-1%2C4.52%2C4.52%2C0%2C0%2C1-1-1.4%2C4.69%2C4.69%2C0%2C0%2C1-.37-2A4.88%2C4.88%2C0%2C0%2C1%2C.72%2C7.19%2C4.46%2C4.46%2C0%2C0%2C1%2C1.88%2C5.58%2C5.83%2C5.83%2C0%2C0%2C1%2C3.82%2C4.47%2C8.06%2C8.06%2C0%2C0%2C1%2C6.53%2C4a8.28%2C8.28%2C0%2C0%2C1%2C1.36.11%2C9.36%2C9.36%2C0%2C0%2C1%2C1.23.28%2C5.92%2C5.92%2C0%2C0%2C1%2C.94.37%2C4.09%2C4.09%2C0%2C0%2C1%2C.59.35%2C1%2C1%2C0%2C0%2C1%2C.26.26.83.83%2C0%2C0%2C1%2C.09.26%2C1.32%2C1.32%2C0%2C0%2C0%2C.06.35%2C3.87%2C3.87%2C0%2C0%2C1%2C0%2C.51%2C4.76%2C4.76%2C0%2C0%2C1%2C0%2C.56%2C1.39%2C1.39%2C0%2C0%2C1-.09.39.5.5%2C0%2C0%2C1-.16.22.35.35%2C0%2C0%2C1-.21.07%2C1%2C1%2C0%2C0%2C1-.49-.21%2C7%2C7%2C0%2C0%2C0-.83-.44%2C9.26%2C9.26%2C0%2C0%2C0-1.2-.44A5.49%2C5.49%2C0%2C0%2C0%2C6.5%2C6.48a4.93%2C4.93%2C0%2C0%2C0-1.4.18%2C2.69%2C2.69%2C0%2C0%2C0-1%2C.51A2.16%2C2.16%2C0%2C0%2C0%2C3.51%2C8a2.43%2C2.43%2C0%2C0%2C0-.2%2C1%2C2%2C2%2C0%2C0%2C0%2C.38%2C1.24%2C3.6%2C3.6%2C0%2C0%2C0%2C1%2C.88%2C8.25%2C8.25%2C0%2C0%2C0%2C1.38.68l1.58.62q.8.32%2C1.59.72a6%2C6%2C0%2C0%2C1%2C1.39%2C1%2C4.37%2C4.37%2C0%2C0%2C1%2C1%2C1.36A4.46%2C4.46%2C0%2C0%2C1%2C12%2C17.3Z%22%2F%3E%3C%2Fsvg%3E\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t");
  11749. try {
  11750. this.config = this.validateConfig(config);
  11751. }
  11752. catch (e) {
  11753. this.showError(e);
  11754. return dom;
  11755. }
  11756. try {
  11757. this.canvas = findWithClass(dom, "spine-player-canvas")[0];
  11758. var webglConfig = { alpha: config.alpha };
  11759. this.context = new spine.webgl.ManagedWebGLRenderingContext(this.canvas, webglConfig);
  11760. this.sceneRenderer = new spine.webgl.SceneRenderer(this.canvas, this.context, true);
  11761. this.loadingScreen = new spine.webgl.LoadingScreen(this.sceneRenderer);
  11762. }
  11763. catch (e) {
  11764. this.showError("Sorry, your browser does not support WebGL.<br><br>Please use the latest version of Firefox, Chrome, Edge, or Safari.");
  11765. return dom;
  11766. }
  11767. this.assetManager = new spine.webgl.AssetManager(this.context);
  11768. if (config.rawDataURIs) {
  11769. for (var path in config.rawDataURIs) {
  11770. var data = config.rawDataURIs[path];
  11771. this.assetManager.setRawDataURI(path, data);
  11772. }
  11773. }
  11774. if (config.jsonUrl)
  11775. this.assetManager.loadText(config.jsonUrl);
  11776. else
  11777. this.assetManager.loadBinary(config.skelUrl);
  11778. this.assetManager.loadTextureAtlas(config.atlasUrl);
  11779. if (config.backgroundImage && config.backgroundImage.url)
  11780. this.assetManager.loadTexture(config.backgroundImage.url);
  11781. requestAnimationFrame(function () { return _this.drawFrame(); });
  11782. this.playerControls = findWithClass(dom, "spine-player-controls")[0];
  11783. var timeline = findWithClass(dom, "spine-player-timeline")[0];
  11784. this.timelineSlider = new Slider();
  11785. timeline.appendChild(this.timelineSlider.render());
  11786. this.playButton = findWithId(dom, "spine-player-button-play-pause")[0];
  11787. var speedButton = findWithId(dom, "spine-player-button-speed")[0];
  11788. this.animationButton = findWithId(dom, "spine-player-button-animation")[0];
  11789. this.skinButton = findWithId(dom, "spine-player-button-skin")[0];
  11790. var settingsButton = findWithId(dom, "spine-player-button-settings")[0];
  11791. var fullscreenButton = findWithId(dom, "spine-player-button-fullscreen")[0];
  11792. var logoButton = findWithId(dom, "spine-player-button-logo")[0];
  11793. this.playButton.onclick = function () {
  11794. if (_this.paused)
  11795. _this.play();
  11796. else
  11797. _this.pause();
  11798. };
  11799. speedButton.onclick = function () {
  11800. _this.showSpeedDialog(speedButton);
  11801. };
  11802. this.animationButton.onclick = function () {
  11803. _this.showAnimationsDialog(_this.animationButton);
  11804. };
  11805. this.skinButton.onclick = function () {
  11806. _this.showSkinsDialog(_this.skinButton);
  11807. };
  11808. settingsButton.onclick = function () {
  11809. _this.showSettingsDialog(settingsButton);
  11810. };
  11811. var oldWidth = this.canvas.clientWidth;
  11812. var oldHeight = this.canvas.clientHeight;
  11813. var oldStyleWidth = this.canvas.style.width;
  11814. var oldStyleHeight = this.canvas.style.height;
  11815. var isFullscreen = false;
  11816. fullscreenButton.onclick = function () {
  11817. var fullscreenChanged = function () {
  11818. isFullscreen = !isFullscreen;
  11819. if (!isFullscreen) {
  11820. _this.canvas.style.width = "" + oldWidth + "px";
  11821. _this.canvas.style.height = "" + oldHeight + "px";
  11822. _this.drawFrame(false);
  11823. requestAnimationFrame(function () {
  11824. _this.canvas.style.width = oldStyleWidth;
  11825. _this.canvas.style.height = oldStyleHeight;
  11826. });
  11827. }
  11828. };
  11829. var doc = document;
  11830. dom.onfullscreenchange = fullscreenChanged;
  11831. dom.onwebkitfullscreenchange = fullscreenChanged;
  11832. if (doc.fullscreenElement || doc.webkitFullscreenElement || doc.mozFullScreenElement || doc.msFullscreenElement) {
  11833. if (doc.exitFullscreen)
  11834. doc.exitFullscreen();
  11835. else if (doc.mozCancelFullScreen)
  11836. doc.mozCancelFullScreen();
  11837. else if (doc.webkitExitFullscreen)
  11838. doc.webkitExitFullscreen();
  11839. else if (doc.msExitFullscreen)
  11840. doc.msExitFullscreen();
  11841. }
  11842. else {
  11843. oldWidth = _this.canvas.clientWidth;
  11844. oldHeight = _this.canvas.clientHeight;
  11845. oldStyleWidth = _this.canvas.style.width;
  11846. oldStyleHeight = _this.canvas.style.height;
  11847. var player = dom;
  11848. if (player.requestFullscreen)
  11849. player.requestFullscreen();
  11850. else if (player.webkitRequestFullScreen)
  11851. player.webkitRequestFullScreen();
  11852. else if (player.mozRequestFullScreen)
  11853. player.mozRequestFullScreen();
  11854. else if (player.msRequestFullscreen)
  11855. player.msRequestFullscreen();
  11856. }
  11857. };
  11858. logoButton.onclick = function () {
  11859. window.open("http://esotericsoftware.com");
  11860. };
  11861. window.onresize = function () {
  11862. _this.drawFrame(false);
  11863. };
  11864. return dom;
  11865. };
  11866. SpinePlayer.prototype.showSpeedDialog = function (speedButton) {
  11867. var _this = this;
  11868. if (this.lastPopup)
  11869. this.lastPopup.dom.remove();
  11870. if (this.lastPopup && findWithClass(this.lastPopup.dom, "spine-player-popup-title")[0].textContent == "Speed") {
  11871. this.lastPopup = null;
  11872. speedButton.classList.remove("spine-player-button-icon-speed-selected");
  11873. return;
  11874. }
  11875. var popup = new Popup(this.dom, this.playerControls, "\n\t\t\t\t<div class=\"spine-player-popup-title\">Speed</div>\n\t\t\t\t<hr>\n\t\t\t\t<div class=\"spine-player-row\" style=\"user-select: none; align-items: center; padding: 8px;\">\n\t\t\t\t\t<div class=\"spine-player-column\">\n\t\t\t\t\t\t<div class=\"spine-player-speed-slider\" style=\"margin-bottom: 4px;\"></div>\n\t\t\t\t\t\t<div class=\"spine-player-row\" style=\"justify-content: space-between;\">\n\t\t\t\t\t\t\t<div>0.1x</div>\n\t\t\t\t\t\t\t<div>1x</div>\n\t\t\t\t\t\t\t<div>2x</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t");
  11876. var sliderParent = findWithClass(popup.dom, "spine-player-speed-slider")[0];
  11877. var slider = new Slider(2, 0.1, true);
  11878. sliderParent.appendChild(slider.render());
  11879. slider.setValue(this.speed / 2);
  11880. slider.change = function (percentage) {
  11881. _this.speed = percentage * 2;
  11882. };
  11883. speedButton.classList.add("spine-player-button-icon-speed-selected");
  11884. popup.show(function () {
  11885. speedButton.classList.remove("spine-player-button-icon-speed-selected");
  11886. popup.dom.remove();
  11887. _this.lastPopup = null;
  11888. });
  11889. this.lastPopup = popup;
  11890. };
  11891. SpinePlayer.prototype.showAnimationsDialog = function (animationsButton) {
  11892. var _this = this;
  11893. if (this.lastPopup)
  11894. this.lastPopup.dom.remove();
  11895. if (this.lastPopup && findWithClass(this.lastPopup.dom, "spine-player-popup-title")[0].textContent == "Animations") {
  11896. this.lastPopup = null;
  11897. animationsButton.classList.remove("spine-player-button-icon-animations-selected");
  11898. return;
  11899. }
  11900. if (!this.skeleton || this.skeleton.data.animations.length == 0)
  11901. return;
  11902. var popup = new Popup(this.dom, this.playerControls, "\n\t\t\t\t<div class=\"spine-player-popup-title\">Animations</div>\n\t\t\t\t<hr>\n\t\t\t\t<ul class=\"spine-player-list\"></ul>\n\t\t\t");
  11903. var rows = findWithClass(popup.dom, "spine-player-list")[0];
  11904. this.skeleton.data.animations.forEach(function (animation) {
  11905. if (_this.config.animations && _this.config.animations.indexOf(animation.name) < 0) {
  11906. return;
  11907. }
  11908. var row = createElement("\n\t\t\t\t\t<li class=\"spine-player-list-item selectable\">\n\t\t\t\t\t\t<div class=\"selectable-circle\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"selectable-text\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</li>\n\t\t\t\t");
  11909. if (animation.name == _this.config.animation)
  11910. row.classList.add("selected");
  11911. findWithClass(row, "selectable-text")[0].innerText = animation.name;
  11912. rows.appendChild(row);
  11913. row.onclick = function () {
  11914. removeClass(rows.children, "selected");
  11915. row.classList.add("selected");
  11916. _this.config.animation = animation.name;
  11917. _this.playTime = 0;
  11918. _this.setAnimation(animation.name);
  11919. };
  11920. });
  11921. animationsButton.classList.add("spine-player-button-icon-animations-selected");
  11922. popup.show(function () {
  11923. animationsButton.classList.remove("spine-player-button-icon-animations-selected");
  11924. popup.dom.remove();
  11925. _this.lastPopup = null;
  11926. });
  11927. this.lastPopup = popup;
  11928. };
  11929. SpinePlayer.prototype.showSkinsDialog = function (skinButton) {
  11930. var _this = this;
  11931. if (this.lastPopup)
  11932. this.lastPopup.dom.remove();
  11933. if (this.lastPopup && findWithClass(this.lastPopup.dom, "spine-player-popup-title")[0].textContent == "Skins") {
  11934. this.lastPopup = null;
  11935. skinButton.classList.remove("spine-player-button-icon-skins-selected");
  11936. return;
  11937. }
  11938. if (!this.skeleton || this.skeleton.data.animations.length == 0)
  11939. return;
  11940. var popup = new Popup(this.dom, this.playerControls, "\n\t\t\t\t<div class=\"spine-player-popup-title\">Skins</div>\n\t\t\t\t<hr>\n\t\t\t\t<ul class=\"spine-player-list\"></ul>\n\t\t\t");
  11941. var rows = findWithClass(popup.dom, "spine-player-list")[0];
  11942. this.skeleton.data.skins.forEach(function (skin) {
  11943. if (_this.config.skins && _this.config.skins.indexOf(skin.name) < 0) {
  11944. return;
  11945. }
  11946. var row = createElement("\n\t\t\t\t\t<li class=\"spine-player-list-item selectable\">\n\t\t\t\t\t\t<div class=\"selectable-circle\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"selectable-text\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</li>\n\t\t\t\t");
  11947. if (skin.name == _this.config.skin)
  11948. row.classList.add("selected");
  11949. findWithClass(row, "selectable-text")[0].innerText = skin.name;
  11950. rows.appendChild(row);
  11951. row.onclick = function () {
  11952. removeClass(rows.children, "selected");
  11953. row.classList.add("selected");
  11954. _this.config.skin = skin.name;
  11955. _this.skeleton.setSkinByName(_this.config.skin);
  11956. _this.skeleton.setSlotsToSetupPose();
  11957. };
  11958. });
  11959. skinButton.classList.add("spine-player-button-icon-skins-selected");
  11960. popup.show(function () {
  11961. skinButton.classList.remove("spine-player-button-icon-skins-selected");
  11962. popup.dom.remove();
  11963. _this.lastPopup = null;
  11964. });
  11965. this.lastPopup = popup;
  11966. };
  11967. SpinePlayer.prototype.showSettingsDialog = function (settingsButton) {
  11968. var _this = this;
  11969. if (this.lastPopup)
  11970. this.lastPopup.dom.remove();
  11971. if (this.lastPopup && findWithClass(this.lastPopup.dom, "spine-player-popup-title")[0].textContent == "Debug") {
  11972. this.lastPopup = null;
  11973. settingsButton.classList.remove("spine-player-button-icon-settings-selected");
  11974. return;
  11975. }
  11976. if (!this.skeleton || this.skeleton.data.animations.length == 0)
  11977. return;
  11978. var popup = new Popup(this.dom, this.playerControls, "\n\t\t\t\t<div class=\"spine-player-popup-title\">Debug</div>\n\t\t\t\t<hr>\n\t\t\t\t<ul class=\"spine-player-list\">\n\t\t\t\t</li>\n\t\t\t");
  11979. var rows = findWithClass(popup.dom, "spine-player-list")[0];
  11980. var makeItem = function (label, name) {
  11981. var row = createElement("<li class=\"spine-player-list-item\"></li>");
  11982. var s = new Switch(label);
  11983. row.appendChild(s.render());
  11984. s.setEnabled(_this.config.debug[name]);
  11985. s.change = function (value) {
  11986. _this.config.debug[name] = value;
  11987. };
  11988. rows.appendChild(row);
  11989. };
  11990. makeItem("Bones", "bones");
  11991. makeItem("Regions", "regions");
  11992. makeItem("Meshes", "meshes");
  11993. makeItem("Bounds", "bounds");
  11994. makeItem("Paths", "paths");
  11995. makeItem("Clipping", "clipping");
  11996. makeItem("Points", "points");
  11997. makeItem("Hulls", "hulls");
  11998. settingsButton.classList.add("spine-player-button-icon-settings-selected");
  11999. popup.show(function () {
  12000. settingsButton.classList.remove("spine-player-button-icon-settings-selected");
  12001. popup.dom.remove();
  12002. _this.lastPopup = null;
  12003. });
  12004. this.lastPopup = popup;
  12005. };
  12006. SpinePlayer.prototype.drawFrame = function (requestNextFrame) {
  12007. var _this = this;
  12008. if (requestNextFrame === void 0) { requestNextFrame = true; }
  12009. if (requestNextFrame && !this.stopRequestAnimationFrame)
  12010. requestAnimationFrame(function () { return _this.drawFrame(); });
  12011. var ctx = this.context;
  12012. var gl = ctx.gl;
  12013. var doc = document;
  12014. var isFullscreen = doc.fullscreenElement || doc.webkitFullscreenElement || doc.mozFullScreenElement || doc.msFullscreenElement;
  12015. var bg = new spine.Color().setFromString(isFullscreen ? this.config.fullScreenBackgroundColor : this.config.backgroundColor);
  12016. gl.clearColor(bg.r, bg.g, bg.b, bg.a);
  12017. gl.clear(gl.COLOR_BUFFER_BIT);
  12018. this.loadingScreen.backgroundColor.setFromColor(bg);
  12019. this.loadingScreen.draw(this.assetManager.isLoadingComplete());
  12020. if (this.assetManager.isLoadingComplete() && this.skeleton == null)
  12021. this.loadSkeleton();
  12022. this.sceneRenderer.resize(spine.webgl.ResizeMode.Expand);
  12023. if (this.loaded) {
  12024. if (!this.paused && this.config.animation) {
  12025. this.time.update();
  12026. var delta = this.time.delta * this.speed;
  12027. var animationDuration = this.animationState.getCurrent(0).animation.duration;
  12028. this.playTime += delta;
  12029. while (this.playTime >= animationDuration && animationDuration != 0) {
  12030. this.playTime -= animationDuration;
  12031. }
  12032. this.playTime = Math.max(0, Math.min(this.playTime, animationDuration));
  12033. this.timelineSlider.setValue(this.playTime / animationDuration);
  12034. this.animationState.update(delta);
  12035. this.animationState.apply(this.skeleton);
  12036. }
  12037. this.skeleton.updateWorldTransform();
  12038. var viewport = {
  12039. x: this.currentViewport.x - this.currentViewport.padLeft,
  12040. y: this.currentViewport.y - this.currentViewport.padBottom,
  12041. width: this.currentViewport.width + this.currentViewport.padLeft + this.currentViewport.padRight,
  12042. height: this.currentViewport.height + this.currentViewport.padBottom + this.currentViewport.padTop
  12043. };
  12044. var transitionAlpha = ((performance.now() - this.viewportTransitionStart) / 1000) / this.config.viewport.transitionTime;
  12045. if (this.previousViewport && transitionAlpha < 1) {
  12046. var oldViewport = {
  12047. x: this.previousViewport.x - this.previousViewport.padLeft,
  12048. y: this.previousViewport.y - this.previousViewport.padBottom,
  12049. width: this.previousViewport.width + this.previousViewport.padLeft + this.previousViewport.padRight,
  12050. height: this.previousViewport.height + this.previousViewport.padBottom + this.previousViewport.padTop
  12051. };
  12052. viewport = {
  12053. x: oldViewport.x + (viewport.x - oldViewport.x) * transitionAlpha,
  12054. y: oldViewport.y + (viewport.y - oldViewport.y) * transitionAlpha,
  12055. width: oldViewport.width + (viewport.width - oldViewport.width) * transitionAlpha,
  12056. height: oldViewport.height + (viewport.height - oldViewport.height) * transitionAlpha
  12057. };
  12058. }
  12059. var viewportSize = this.scale(viewport.width, viewport.height, this.canvas.width, this.canvas.height);
  12060. this.sceneRenderer.camera.zoom = viewport.width / viewportSize.x;
  12061. this.sceneRenderer.camera.position.x = viewport.x + viewport.width / 2;
  12062. this.sceneRenderer.camera.position.y = viewport.y + viewport.height / 2;
  12063. this.sceneRenderer.begin();
  12064. if (this.config.backgroundImage && this.config.backgroundImage.url) {
  12065. var bgImage = this.assetManager.get(this.config.backgroundImage.url);
  12066. if (!(this.config.backgroundImage.hasOwnProperty("x") && this.config.backgroundImage.hasOwnProperty("y") && this.config.backgroundImage.hasOwnProperty("width") && this.config.backgroundImage.hasOwnProperty("height"))) {
  12067. this.sceneRenderer.drawTexture(bgImage, viewport.x, viewport.y, viewport.width, viewport.height);
  12068. }
  12069. else {
  12070. this.sceneRenderer.drawTexture(bgImage, this.config.backgroundImage.x, this.config.backgroundImage.y, this.config.backgroundImage.width, this.config.backgroundImage.height);
  12071. }
  12072. }
  12073. this.sceneRenderer.drawSkeleton(this.skeleton, this.config.premultipliedAlpha);
  12074. this.sceneRenderer.skeletonDebugRenderer.drawBones = this.config.debug.bones;
  12075. this.sceneRenderer.skeletonDebugRenderer.drawBoundingBoxes = this.config.debug.bounds;
  12076. this.sceneRenderer.skeletonDebugRenderer.drawClipping = this.config.debug.clipping;
  12077. this.sceneRenderer.skeletonDebugRenderer.drawMeshHull = this.config.debug.hulls;
  12078. this.sceneRenderer.skeletonDebugRenderer.drawPaths = this.config.debug.paths;
  12079. this.sceneRenderer.skeletonDebugRenderer.drawRegionAttachments = this.config.debug.regions;
  12080. this.sceneRenderer.skeletonDebugRenderer.drawMeshTriangles = this.config.debug.meshes;
  12081. this.sceneRenderer.drawSkeletonDebug(this.skeleton, this.config.premultipliedAlpha);
  12082. var controlBones = this.config.controlBones;
  12083. var selectedBones = this.selectedBones;
  12084. var skeleton = this.skeleton;
  12085. gl.lineWidth(2);
  12086. for (var i = 0; i < controlBones.length; i++) {
  12087. var bone = skeleton.findBone(controlBones[i]);
  12088. if (!bone)
  12089. continue;
  12090. var colorInner = selectedBones[i] !== null ? SpinePlayer.HOVER_COLOR_INNER : SpinePlayer.NON_HOVER_COLOR_INNER;
  12091. var colorOuter = selectedBones[i] !== null ? SpinePlayer.HOVER_COLOR_OUTER : SpinePlayer.NON_HOVER_COLOR_OUTER;
  12092. this.sceneRenderer.circle(true, skeleton.x + bone.worldX, skeleton.y + bone.worldY, 20, colorInner);
  12093. this.sceneRenderer.circle(false, skeleton.x + bone.worldX, skeleton.y + bone.worldY, 20, colorOuter);
  12094. }
  12095. gl.lineWidth(1);
  12096. if (this.config.viewport.debugRender) {
  12097. this.sceneRenderer.rect(false, this.currentViewport.x, this.currentViewport.y, this.currentViewport.width, this.currentViewport.height, spine.Color.GREEN);
  12098. this.sceneRenderer.rect(false, viewport.x, viewport.y, viewport.width, viewport.height, spine.Color.RED);
  12099. }
  12100. this.sceneRenderer.end();
  12101. this.sceneRenderer.camera.zoom = 0;
  12102. }
  12103. };
  12104. SpinePlayer.prototype.scale = function (sourceWidth, sourceHeight, targetWidth, targetHeight) {
  12105. var targetRatio = targetHeight / targetWidth;
  12106. var sourceRatio = sourceHeight / sourceWidth;
  12107. var scale = targetRatio > sourceRatio ? targetWidth / sourceWidth : targetHeight / sourceHeight;
  12108. var temp = new spine.Vector2();
  12109. temp.x = sourceWidth * scale;
  12110. temp.y = sourceHeight * scale;
  12111. return temp;
  12112. };
  12113. SpinePlayer.prototype.loadSkeleton = function () {
  12114. var _this = this;
  12115. if (this.loaded)
  12116. return;
  12117. if (this.assetManager.hasErrors()) {
  12118. this.showError("Error: assets could not be loaded.<br><br>" + escapeHtml(JSON.stringify(this.assetManager.getErrors())));
  12119. return;
  12120. }
  12121. var atlas = this.assetManager.get(this.config.atlasUrl);
  12122. var skeletonData;
  12123. if (this.config.jsonUrl) {
  12124. var jsonText = this.assetManager.get(this.config.jsonUrl);
  12125. var json = new spine.SkeletonJson(new spine.AtlasAttachmentLoader(atlas));
  12126. try {
  12127. skeletonData = json.readSkeletonData(jsonText);
  12128. }
  12129. catch (e) {
  12130. this.showError("Error: could not load skeleton .json.<br><br>" + e.toString());
  12131. return;
  12132. }
  12133. }
  12134. else {
  12135. var binaryData = this.assetManager.get(this.config.skelUrl);
  12136. var binary = new spine.SkeletonBinary(new spine.AtlasAttachmentLoader(atlas));
  12137. try {
  12138. skeletonData = binary.readSkeletonData(binaryData);
  12139. }
  12140. catch (e) {
  12141. this.showError("Error: could not load skeleton .skel.<br><br>" + e.toString());
  12142. return;
  12143. }
  12144. }
  12145. this.skeleton = new spine.Skeleton(skeletonData);
  12146. var stateData = new spine.AnimationStateData(skeletonData);
  12147. stateData.defaultMix = this.config.defaultMix;
  12148. this.animationState = new spine.AnimationState(stateData);
  12149. if (this.config.controlBones) {
  12150. this.config.controlBones.forEach(function (bone) {
  12151. if (!skeletonData.findBone(bone)) {
  12152. _this.showError("Error: control bone '" + bone + "' does not exist in skeleton.");
  12153. }
  12154. });
  12155. }
  12156. if (!this.config.skin) {
  12157. if (skeletonData.skins.length > 0) {
  12158. this.config.skin = skeletonData.skins[0].name;
  12159. }
  12160. }
  12161. if (this.config.skins && this.config.skin.length > 0) {
  12162. this.config.skins.forEach(function (skin) {
  12163. if (!_this.skeleton.data.findSkin(skin)) {
  12164. _this.showError("Error: skin '" + skin + "' in selectable skin list does not exist in skeleton.");
  12165. return;
  12166. }
  12167. });
  12168. }
  12169. if (this.config.skin) {
  12170. if (!this.skeleton.data.findSkin(this.config.skin)) {
  12171. this.showError("Error: skin '" + this.config.skin + "' does not exist in skeleton.");
  12172. return;
  12173. }
  12174. this.skeleton.setSkinByName(this.config.skin);
  12175. this.skeleton.setSlotsToSetupPose();
  12176. }
  12177. if (!this.config.viewport) {
  12178. this.config.viewport = {
  12179. animations: {},
  12180. debugRender: false,
  12181. transitionTime: 0.2
  12182. };
  12183. }
  12184. if (typeof this.config.viewport.debugRender === "undefined")
  12185. this.config.viewport.debugRender = false;
  12186. if (typeof this.config.viewport.transitionTime === "undefined")
  12187. this.config.viewport.transitionTime = 0.2;
  12188. if (!this.config.viewport.animations) {
  12189. this.config.viewport.animations = {};
  12190. }
  12191. else {
  12192. Object.getOwnPropertyNames(this.config.viewport.animations).forEach(function (animation) {
  12193. if (!skeletonData.findAnimation(animation)) {
  12194. _this.showError("Error: animation '" + animation + "' for which a viewport was specified does not exist in skeleton.");
  12195. return;
  12196. }
  12197. });
  12198. }
  12199. if (this.config.animations && this.config.animations.length > 0) {
  12200. this.config.animations.forEach(function (animation) {
  12201. if (!_this.skeleton.data.findAnimation(animation)) {
  12202. _this.showError("Error: animation '" + animation + "' in selectable animation list does not exist in skeleton.");
  12203. return;
  12204. }
  12205. });
  12206. if (!this.config.animation) {
  12207. this.config.animation = this.config.animations[0];
  12208. }
  12209. }
  12210. if (!this.config.animation) {
  12211. if (skeletonData.animations.length > 0) {
  12212. this.config.animation = skeletonData.animations[0].name;
  12213. }
  12214. }
  12215. if (this.config.animation) {
  12216. if (!skeletonData.findAnimation(this.config.animation)) {
  12217. this.showError("Error: animation '" + this.config.animation + "' does not exist in skeleton.");
  12218. return;
  12219. }
  12220. this.play();
  12221. this.timelineSlider.change = function (percentage) {
  12222. _this.pause();
  12223. var animationDuration = _this.animationState.getCurrent(0).animation.duration;
  12224. var time = animationDuration * percentage;
  12225. _this.animationState.update(time - _this.playTime);
  12226. _this.animationState.apply(_this.skeleton);
  12227. _this.skeleton.updateWorldTransform();
  12228. _this.playTime = time;
  12229. };
  12230. }
  12231. this.setupInput();
  12232. if (skeletonData.skins.length == 1 || (this.config.skins && this.config.skins.length == 1))
  12233. this.skinButton.classList.add("spine-player-hidden");
  12234. if (skeletonData.animations.length == 1 || (this.config.animations && this.config.animations.length == 1))
  12235. this.animationButton.classList.add("spine-player-hidden");
  12236. this.config.success(this);
  12237. this.loaded = true;
  12238. };
  12239. SpinePlayer.prototype.setupInput = function () {
  12240. var _this = this;
  12241. var controlBones = this.config.controlBones;
  12242. var selectedBones = this.selectedBones = new Array(this.config.controlBones.length);
  12243. var canvas = this.canvas;
  12244. var input = new spine.webgl.Input(canvas);
  12245. var target = null;
  12246. var coords = new spine.webgl.Vector3();
  12247. var temp = new spine.webgl.Vector3();
  12248. var temp2 = new spine.Vector2();
  12249. var skeleton = this.skeleton;
  12250. var renderer = this.sceneRenderer;
  12251. input.addListener({
  12252. down: function (x, y) {
  12253. for (var i = 0; i < controlBones.length; i++) {
  12254. var bone = skeleton.findBone(controlBones[i]);
  12255. if (!bone)
  12256. continue;
  12257. renderer.camera.screenToWorld(coords.set(x, y, 0), canvas.width, canvas.height);
  12258. if (temp.set(skeleton.x + bone.worldX, skeleton.y + bone.worldY, 0).distance(coords) < 30) {
  12259. target = bone;
  12260. }
  12261. }
  12262. },
  12263. up: function (x, y) {
  12264. if (target) {
  12265. target = null;
  12266. }
  12267. else {
  12268. if (!_this.config.showControls)
  12269. return;
  12270. if (_this.paused)
  12271. _this.play();
  12272. else
  12273. _this.pause();
  12274. }
  12275. },
  12276. dragged: function (x, y) {
  12277. if (target != null) {
  12278. renderer.camera.screenToWorld(coords.set(x, y, 0), canvas.width, canvas.height);
  12279. if (target.parent !== null) {
  12280. target.parent.worldToLocal(temp2.set(coords.x - skeleton.x, coords.y - skeleton.y));
  12281. target.x = temp2.x;
  12282. target.y = temp2.y;
  12283. }
  12284. else {
  12285. target.x = coords.x - skeleton.x;
  12286. target.y = coords.y - skeleton.y;
  12287. }
  12288. }
  12289. },
  12290. moved: function (x, y) {
  12291. for (var i = 0; i < controlBones.length; i++) {
  12292. var bone = skeleton.findBone(controlBones[i]);
  12293. if (!bone)
  12294. continue;
  12295. renderer.camera.screenToWorld(coords.set(x, y, 0), canvas.width, canvas.height);
  12296. if (temp.set(skeleton.x + bone.worldX, skeleton.y + bone.worldY, 0).distance(coords) < 30) {
  12297. selectedBones[i] = bone;
  12298. }
  12299. else {
  12300. selectedBones[i] = null;
  12301. }
  12302. }
  12303. }
  12304. });
  12305. var mouseOverControls = true;
  12306. var mouseOverCanvas = false;
  12307. document.addEventListener("mousemove", function (ev) {
  12308. if (ev instanceof MouseEvent) {
  12309. handleHover(ev.clientX, ev.clientY);
  12310. }
  12311. });
  12312. document.addEventListener("touchmove", function (ev) {
  12313. if (ev instanceof TouchEvent) {
  12314. var touches = ev.changedTouches;
  12315. if (touches.length > 0) {
  12316. var touch = touches[0];
  12317. handleHover(touch.clientX, touch.clientY);
  12318. }
  12319. }
  12320. });
  12321. var handleHover = function (mouseX, mouseY) {
  12322. if (!_this.config.showControls)
  12323. return;
  12324. var popup = findWithClass(_this.dom, "spine-player-popup");
  12325. mouseOverControls = overlap(mouseX, mouseY, _this.playerControls.getBoundingClientRect());
  12326. mouseOverCanvas = overlap(mouseX, mouseY, _this.canvas.getBoundingClientRect());
  12327. clearTimeout(_this.cancelId);
  12328. var hide = popup.length == 0 && !mouseOverControls && !mouseOverCanvas && !_this.paused;
  12329. if (hide) {
  12330. _this.playerControls.classList.add("spine-player-controls-hidden");
  12331. }
  12332. else {
  12333. _this.playerControls.classList.remove("spine-player-controls-hidden");
  12334. }
  12335. if (!mouseOverControls && popup.length == 0 && !_this.paused) {
  12336. var remove = function () {
  12337. if (!_this.paused)
  12338. _this.playerControls.classList.add("spine-player-controls-hidden");
  12339. };
  12340. _this.cancelId = setTimeout(remove, 1000);
  12341. }
  12342. };
  12343. var overlap = function (mouseX, mouseY, rect) {
  12344. var x = mouseX - rect.left;
  12345. var y = mouseY - rect.top;
  12346. return x >= 0 && x <= rect.width && y >= 0 && y <= rect.height;
  12347. };
  12348. };
  12349. SpinePlayer.prototype.play = function () {
  12350. var _this = this;
  12351. this.paused = false;
  12352. var remove = function () {
  12353. if (!_this.paused)
  12354. _this.playerControls.classList.add("spine-player-controls-hidden");
  12355. };
  12356. this.cancelId = setTimeout(remove, 1000);
  12357. this.playButton.classList.remove("spine-player-button-icon-play");
  12358. this.playButton.classList.add("spine-player-button-icon-pause");
  12359. if (this.config.animation) {
  12360. if (!this.animationState.getCurrent(0)) {
  12361. this.setAnimation(this.config.animation);
  12362. }
  12363. }
  12364. };
  12365. SpinePlayer.prototype.pause = function () {
  12366. this.paused = true;
  12367. this.playerControls.classList.remove("spine-player-controls-hidden");
  12368. clearTimeout(this.cancelId);
  12369. this.playButton.classList.remove("spine-player-button-icon-pause");
  12370. this.playButton.classList.add("spine-player-button-icon-play");
  12371. };
  12372. SpinePlayer.prototype.setAnimation = function (animation, loop) {
  12373. if (loop === void 0) { loop = true; }
  12374. this.previousViewport = this.currentViewport;
  12375. var animViewport = this.calculateAnimationViewport(animation);
  12376. var viewport = {
  12377. x: animViewport.x,
  12378. y: animViewport.y,
  12379. width: animViewport.width,
  12380. height: animViewport.height,
  12381. padLeft: "10%",
  12382. padRight: "10%",
  12383. padTop: "10%",
  12384. padBottom: "10%"
  12385. };
  12386. var globalViewport = this.config.viewport;
  12387. if (typeof globalViewport.x !== "undefined" && typeof globalViewport.y !== "undefined" && typeof globalViewport.width !== "undefined" && typeof globalViewport.height !== "undefined") {
  12388. viewport.x = globalViewport.x;
  12389. viewport.y = globalViewport.y;
  12390. viewport.width = globalViewport.width;
  12391. viewport.height = globalViewport.height;
  12392. }
  12393. if (typeof globalViewport.padLeft !== "undefined")
  12394. viewport.padLeft = globalViewport.padLeft;
  12395. if (typeof globalViewport.padRight !== "undefined")
  12396. viewport.padRight = globalViewport.padRight;
  12397. if (typeof globalViewport.padTop !== "undefined")
  12398. viewport.padTop = globalViewport.padTop;
  12399. if (typeof globalViewport.padBottom !== "undefined")
  12400. viewport.padBottom = globalViewport.padBottom;
  12401. var userAnimViewport = this.config.viewport.animations[animation];
  12402. if (userAnimViewport) {
  12403. if (typeof userAnimViewport.x !== "undefined" && typeof userAnimViewport.y !== "undefined" && typeof userAnimViewport.width !== "undefined" && typeof userAnimViewport.height !== "undefined") {
  12404. viewport.x = userAnimViewport.x;
  12405. viewport.y = userAnimViewport.y;
  12406. viewport.width = userAnimViewport.width;
  12407. viewport.height = userAnimViewport.height;
  12408. }
  12409. if (typeof userAnimViewport.padLeft !== "undefined")
  12410. viewport.padLeft = userAnimViewport.padLeft;
  12411. if (typeof userAnimViewport.padRight !== "undefined")
  12412. viewport.padRight = userAnimViewport.padRight;
  12413. if (typeof userAnimViewport.padTop !== "undefined")
  12414. viewport.padTop = userAnimViewport.padTop;
  12415. if (typeof userAnimViewport.padBottom !== "undefined")
  12416. viewport.padBottom = userAnimViewport.padBottom;
  12417. }
  12418. viewport.padLeft = this.percentageToWorldUnit(viewport.width, viewport.padLeft);
  12419. viewport.padRight = this.percentageToWorldUnit(viewport.width, viewport.padRight);
  12420. viewport.padBottom = this.percentageToWorldUnit(viewport.height, viewport.padBottom);
  12421. viewport.padTop = this.percentageToWorldUnit(viewport.height, viewport.padTop);
  12422. this.currentViewport = viewport;
  12423. this.viewportTransitionStart = performance.now();
  12424. this.animationState.clearTracks();
  12425. this.skeleton.setToSetupPose();
  12426. this.animationState.setAnimation(0, animation, loop);
  12427. };
  12428. SpinePlayer.prototype.percentageToWorldUnit = function (size, percentageOrAbsolute) {
  12429. if (typeof percentageOrAbsolute === "string") {
  12430. return size * parseFloat(percentageOrAbsolute.substr(0, percentageOrAbsolute.length - 1)) / 100;
  12431. }
  12432. else {
  12433. return percentageOrAbsolute;
  12434. }
  12435. };
  12436. SpinePlayer.prototype.calculateAnimationViewport = function (animationName) {
  12437. var animation = this.skeleton.data.findAnimation(animationName);
  12438. this.animationState.clearTracks();
  12439. this.skeleton.setToSetupPose();
  12440. this.animationState.setAnimationWith(0, animation, true);
  12441. var steps = 100;
  12442. var stepTime = animation.duration > 0 ? animation.duration / steps : 0;
  12443. var minX = 100000000;
  12444. var maxX = -100000000;
  12445. var minY = 100000000;
  12446. var maxY = -100000000;
  12447. var offset = new spine.Vector2();
  12448. var size = new spine.Vector2();
  12449. for (var i = 0; i < steps; i++) {
  12450. this.animationState.update(stepTime);
  12451. this.animationState.apply(this.skeleton);
  12452. this.skeleton.updateWorldTransform();
  12453. this.skeleton.getBounds(offset, size);
  12454. if (!isNaN(offset.x) && !isNaN(offset.y) && !isNaN(size.x) && !isNaN(size.y)) {
  12455. minX = Math.min(offset.x, minX);
  12456. maxX = Math.max(offset.x + size.x, maxX);
  12457. minY = Math.min(offset.y, minY);
  12458. maxY = Math.max(offset.y + size.y, maxY);
  12459. }
  12460. else {
  12461. console.log("Bounds of animation " + animationName + " are NaN");
  12462. }
  12463. }
  12464. offset.x = minX;
  12465. offset.y = minY;
  12466. size.x = maxX - minX;
  12467. size.y = maxY - minY;
  12468. return {
  12469. x: offset.x,
  12470. y: offset.y,
  12471. width: size.x,
  12472. height: size.y
  12473. };
  12474. };
  12475. SpinePlayer.prototype.stopRendering = function () {
  12476. this.stopRequestAnimationFrame = true;
  12477. };
  12478. SpinePlayer.HOVER_COLOR_INNER = new spine.Color(0.478, 0, 0, 0.25);
  12479. SpinePlayer.HOVER_COLOR_OUTER = new spine.Color(1, 1, 1, 1);
  12480. SpinePlayer.NON_HOVER_COLOR_INNER = new spine.Color(0.478, 0, 0, 0.5);
  12481. SpinePlayer.NON_HOVER_COLOR_OUTER = new spine.Color(1, 0, 0, 0.8);
  12482. return SpinePlayer;
  12483. }());
  12484. spine.SpinePlayer = SpinePlayer;
  12485. function isContained(dom, needle) {
  12486. if (dom === needle)
  12487. return true;
  12488. var findRecursive = function (dom, needle) {
  12489. for (var i = 0; i < dom.children.length; i++) {
  12490. var child = dom.children[i];
  12491. if (child === needle)
  12492. return true;
  12493. if (findRecursive(child, needle))
  12494. return true;
  12495. }
  12496. return false;
  12497. };
  12498. return findRecursive(dom, needle);
  12499. }
  12500. function findWithId(dom, id) {
  12501. var found = new Array();
  12502. var findRecursive = function (dom, id, found) {
  12503. for (var i = 0; i < dom.children.length; i++) {
  12504. var child = dom.children[i];
  12505. if (child.id === id)
  12506. found.push(child);
  12507. findRecursive(child, id, found);
  12508. }
  12509. };
  12510. findRecursive(dom, id, found);
  12511. return found;
  12512. }
  12513. function findWithClass(dom, className) {
  12514. var found = new Array();
  12515. var findRecursive = function (dom, className, found) {
  12516. for (var i = 0; i < dom.children.length; i++) {
  12517. var child = dom.children[i];
  12518. if (child.classList.contains(className))
  12519. found.push(child);
  12520. findRecursive(child, className, found);
  12521. }
  12522. };
  12523. findRecursive(dom, className, found);
  12524. return found;
  12525. }
  12526. function createElement(html) {
  12527. var dom = document.createElement("div");
  12528. dom.innerHTML = html;
  12529. return dom.children[0];
  12530. }
  12531. function removeClass(elements, clazz) {
  12532. for (var i = 0; i < elements.length; i++) {
  12533. elements[i].classList.remove(clazz);
  12534. }
  12535. }
  12536. function escapeHtml(str) {
  12537. if (!str)
  12538. return "";
  12539. return str
  12540. .replace(/&/g, "&amp;")
  12541. .replace(/</g, "&lt;")
  12542. .replace(/>/g, "&gt;")
  12543. .replace(/"/g, "&#34;")
  12544. .replace(/'/g, "&#39;");
  12545. }
  12546. })(spine || (spine = {}));
  12547. var spine;
  12548. (function (spine) {
  12549. var SpinePlayerEditor = (function () {
  12550. function SpinePlayerEditor(parent) {
  12551. this.prefix = "<html>\n<head>\n<style>\nbody {\n\tmargin: 0px;\n}\n</style>\n</head>\n<body>".trim();
  12552. this.postfix = "</body>";
  12553. this.timerId = 0;
  12554. this.render(parent);
  12555. }
  12556. SpinePlayerEditor.prototype.render = function (parent) {
  12557. var _this = this;
  12558. var dom = "\n\t\t\t\t<div class=\"spine-player-editor-container\">\n\t\t\t\t\t<div class=\"spine-player-editor-code\"></div>\n\t\t\t\t\t<iframe class=\"spine-player-editor-player\"></iframe>\n\t\t\t\t</div>\n\t\t\t";
  12559. parent.innerHTML = dom;
  12560. var codeElement = parent.getElementsByClassName("spine-player-editor-code")[0];
  12561. this.player = parent.getElementsByClassName("spine-player-editor-player")[0];
  12562. requestAnimationFrame(function () {
  12563. _this.code = CodeMirror(codeElement, {
  12564. lineNumbers: true,
  12565. tabSize: 3,
  12566. indentUnit: 3,
  12567. indentWithTabs: true,
  12568. scrollBarStyle: "native",
  12569. mode: "htmlmixed",
  12570. theme: "monokai"
  12571. });
  12572. _this.code.on("change", function () {
  12573. _this.startPlayer();
  12574. });
  12575. _this.setCode(SpinePlayerEditor.DEFAULT_CODE);
  12576. });
  12577. };
  12578. SpinePlayerEditor.prototype.setPreAndPostfix = function (prefix, postfix) {
  12579. this.prefix = prefix;
  12580. this.postfix = postfix;
  12581. this.startPlayer();
  12582. };
  12583. SpinePlayerEditor.prototype.setCode = function (code) {
  12584. this.code.setValue(code);
  12585. this.startPlayer();
  12586. };
  12587. SpinePlayerEditor.prototype.startPlayer = function () {
  12588. var _this = this;
  12589. clearTimeout(this.timerId);
  12590. this.timerId = setTimeout(function () {
  12591. var code = _this.code.getDoc().getValue();
  12592. code = _this.prefix + code + _this.postfix;
  12593. code = window.btoa(code);
  12594. _this.player.src = "";
  12595. _this.player.src = "data:text/html;base64," + code;
  12596. }, 500);
  12597. };
  12598. SpinePlayerEditor.DEFAULT_CODE = "\n<script src=\"https://esotericsoftware.com/files/spine-player/3.7/spine-player.js\"></script>\n<link rel=\"stylesheet\" href=\"https://esotericsoftware.com/files/spine-player/3.7/spine-player.css\">\n\n<div id=\"player-container\" style=\"width: 100%; height: 100vh;\"></div>\n\n<script>\nnew spine.SpinePlayer(\"player-container\", {\n\tjsonUrl: \"https://esotericsoftware.com/files/examples/spineboy/export/spineboy-pro.json\",\n\tatlasUrl: \"https://esotericsoftware.com/files/examples/spineboy/export/spineboy-pma.atlas\"\n});\n</script>\n\t\t".trim();
  12599. return SpinePlayerEditor;
  12600. }());
  12601. spine.SpinePlayerEditor = SpinePlayerEditor;
  12602. })(spine || (spine = {}));
  12603. //# sourceMappingURL=spine-all.js.map