spine-webgl.js 360 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. var spine;
  12. (function (spine) {
  13. var Animation = (function () {
  14. function Animation(name, timelines, duration) {
  15. if (name == null)
  16. throw new Error("name cannot be null.");
  17. if (timelines == null)
  18. throw new Error("timelines cannot be null.");
  19. this.name = name;
  20. this.timelines = timelines;
  21. this.duration = duration;
  22. }
  23. Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
  24. if (skeleton == null)
  25. throw new Error("skeleton cannot be null.");
  26. if (loop && this.duration != 0) {
  27. time %= this.duration;
  28. if (lastTime > 0)
  29. lastTime %= this.duration;
  30. }
  31. var timelines = this.timelines;
  32. for (var i = 0, n = timelines.length; i < n; i++)
  33. timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
  34. };
  35. Animation.binarySearch = function (values, target, step) {
  36. if (step === void 0) { step = 1; }
  37. var low = 0;
  38. var high = values.length / step - 2;
  39. if (high == 0)
  40. return step;
  41. var current = high >>> 1;
  42. while (true) {
  43. if (values[(current + 1) * step] <= target)
  44. low = current + 1;
  45. else
  46. high = current;
  47. if (low == high)
  48. return (low + 1) * step;
  49. current = (low + high) >>> 1;
  50. }
  51. };
  52. Animation.linearSearch = function (values, target, step) {
  53. for (var i = 0, last = values.length - step; i <= last; i += step)
  54. if (values[i] > target)
  55. return i;
  56. return -1;
  57. };
  58. return Animation;
  59. }());
  60. spine.Animation = Animation;
  61. var MixBlend;
  62. (function (MixBlend) {
  63. MixBlend[MixBlend["setup"] = 0] = "setup";
  64. MixBlend[MixBlend["first"] = 1] = "first";
  65. MixBlend[MixBlend["replace"] = 2] = "replace";
  66. MixBlend[MixBlend["add"] = 3] = "add";
  67. })(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
  68. var MixDirection;
  69. (function (MixDirection) {
  70. MixDirection[MixDirection["in"] = 0] = "in";
  71. MixDirection[MixDirection["out"] = 1] = "out";
  72. })(MixDirection = spine.MixDirection || (spine.MixDirection = {}));
  73. var TimelineType;
  74. (function (TimelineType) {
  75. TimelineType[TimelineType["rotate"] = 0] = "rotate";
  76. TimelineType[TimelineType["translate"] = 1] = "translate";
  77. TimelineType[TimelineType["scale"] = 2] = "scale";
  78. TimelineType[TimelineType["shear"] = 3] = "shear";
  79. TimelineType[TimelineType["attachment"] = 4] = "attachment";
  80. TimelineType[TimelineType["color"] = 5] = "color";
  81. TimelineType[TimelineType["deform"] = 6] = "deform";
  82. TimelineType[TimelineType["event"] = 7] = "event";
  83. TimelineType[TimelineType["drawOrder"] = 8] = "drawOrder";
  84. TimelineType[TimelineType["ikConstraint"] = 9] = "ikConstraint";
  85. TimelineType[TimelineType["transformConstraint"] = 10] = "transformConstraint";
  86. TimelineType[TimelineType["pathConstraintPosition"] = 11] = "pathConstraintPosition";
  87. TimelineType[TimelineType["pathConstraintSpacing"] = 12] = "pathConstraintSpacing";
  88. TimelineType[TimelineType["pathConstraintMix"] = 13] = "pathConstraintMix";
  89. TimelineType[TimelineType["twoColor"] = 14] = "twoColor";
  90. })(TimelineType = spine.TimelineType || (spine.TimelineType = {}));
  91. var CurveTimeline = (function () {
  92. function CurveTimeline(frameCount) {
  93. if (frameCount <= 0)
  94. throw new Error("frameCount must be > 0: " + frameCount);
  95. this.curves = spine.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);
  96. }
  97. CurveTimeline.prototype.getFrameCount = function () {
  98. return this.curves.length / CurveTimeline.BEZIER_SIZE + 1;
  99. };
  100. CurveTimeline.prototype.setLinear = function (frameIndex) {
  101. this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR;
  102. };
  103. CurveTimeline.prototype.setStepped = function (frameIndex) {
  104. this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED;
  105. };
  106. CurveTimeline.prototype.getCurveType = function (frameIndex) {
  107. var index = frameIndex * CurveTimeline.BEZIER_SIZE;
  108. if (index == this.curves.length)
  109. return CurveTimeline.LINEAR;
  110. var type = this.curves[index];
  111. if (type == CurveTimeline.LINEAR)
  112. return CurveTimeline.LINEAR;
  113. if (type == CurveTimeline.STEPPED)
  114. return CurveTimeline.STEPPED;
  115. return CurveTimeline.BEZIER;
  116. };
  117. CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) {
  118. var tmpx = (-cx1 * 2 + cx2) * 0.03, tmpy = (-cy1 * 2 + cy2) * 0.03;
  119. var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006;
  120. var ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy;
  121. var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667;
  122. var i = frameIndex * CurveTimeline.BEZIER_SIZE;
  123. var curves = this.curves;
  124. curves[i++] = CurveTimeline.BEZIER;
  125. var x = dfx, y = dfy;
  126. for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
  127. curves[i] = x;
  128. curves[i + 1] = y;
  129. dfx += ddfx;
  130. dfy += ddfy;
  131. ddfx += dddfx;
  132. ddfy += dddfy;
  133. x += dfx;
  134. y += dfy;
  135. }
  136. };
  137. CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) {
  138. percent = spine.MathUtils.clamp(percent, 0, 1);
  139. var curves = this.curves;
  140. var i = frameIndex * CurveTimeline.BEZIER_SIZE;
  141. var type = curves[i];
  142. if (type == CurveTimeline.LINEAR)
  143. return percent;
  144. if (type == CurveTimeline.STEPPED)
  145. return 0;
  146. i++;
  147. var x = 0;
  148. for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
  149. x = curves[i];
  150. if (x >= percent) {
  151. var prevX = void 0, prevY = void 0;
  152. if (i == start) {
  153. prevX = 0;
  154. prevY = 0;
  155. }
  156. else {
  157. prevX = curves[i - 2];
  158. prevY = curves[i - 1];
  159. }
  160. return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX);
  161. }
  162. }
  163. var y = curves[i - 1];
  164. return y + (1 - y) * (percent - x) / (1 - x);
  165. };
  166. CurveTimeline.LINEAR = 0;
  167. CurveTimeline.STEPPED = 1;
  168. CurveTimeline.BEZIER = 2;
  169. CurveTimeline.BEZIER_SIZE = 10 * 2 - 1;
  170. return CurveTimeline;
  171. }());
  172. spine.CurveTimeline = CurveTimeline;
  173. var RotateTimeline = (function (_super) {
  174. __extends(RotateTimeline, _super);
  175. function RotateTimeline(frameCount) {
  176. var _this = _super.call(this, frameCount) || this;
  177. _this.frames = spine.Utils.newFloatArray(frameCount << 1);
  178. return _this;
  179. }
  180. RotateTimeline.prototype.getPropertyId = function () {
  181. return (TimelineType.rotate << 24) + this.boneIndex;
  182. };
  183. RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) {
  184. frameIndex <<= 1;
  185. this.frames[frameIndex] = time;
  186. this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
  187. };
  188. RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  189. var frames = this.frames;
  190. var bone = skeleton.bones[this.boneIndex];
  191. if (time < frames[0]) {
  192. switch (blend) {
  193. case MixBlend.setup:
  194. bone.rotation = bone.data.rotation;
  195. return;
  196. case MixBlend.first:
  197. var r_1 = bone.data.rotation - bone.rotation;
  198. bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
  199. }
  200. return;
  201. }
  202. if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
  203. var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION];
  204. switch (blend) {
  205. case MixBlend.setup:
  206. bone.rotation = bone.data.rotation + r_2 * alpha;
  207. break;
  208. case MixBlend.first:
  209. case MixBlend.replace:
  210. r_2 += bone.data.rotation - bone.rotation;
  211. r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
  212. case MixBlend.add:
  213. bone.rotation += r_2 * alpha;
  214. }
  215. return;
  216. }
  217. var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES);
  218. var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
  219. var frameTime = frames[frame];
  220. var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
  221. var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
  222. r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
  223. switch (blend) {
  224. case MixBlend.setup:
  225. bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
  226. break;
  227. case MixBlend.first:
  228. case MixBlend.replace:
  229. r += bone.data.rotation - bone.rotation;
  230. case MixBlend.add:
  231. bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
  232. }
  233. };
  234. RotateTimeline.ENTRIES = 2;
  235. RotateTimeline.PREV_TIME = -2;
  236. RotateTimeline.PREV_ROTATION = -1;
  237. RotateTimeline.ROTATION = 1;
  238. return RotateTimeline;
  239. }(CurveTimeline));
  240. spine.RotateTimeline = RotateTimeline;
  241. var TranslateTimeline = (function (_super) {
  242. __extends(TranslateTimeline, _super);
  243. function TranslateTimeline(frameCount) {
  244. var _this = _super.call(this, frameCount) || this;
  245. _this.frames = spine.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES);
  246. return _this;
  247. }
  248. TranslateTimeline.prototype.getPropertyId = function () {
  249. return (TimelineType.translate << 24) + this.boneIndex;
  250. };
  251. TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) {
  252. frameIndex *= TranslateTimeline.ENTRIES;
  253. this.frames[frameIndex] = time;
  254. this.frames[frameIndex + TranslateTimeline.X] = x;
  255. this.frames[frameIndex + TranslateTimeline.Y] = y;
  256. };
  257. TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  258. var frames = this.frames;
  259. var bone = skeleton.bones[this.boneIndex];
  260. if (time < frames[0]) {
  261. switch (blend) {
  262. case MixBlend.setup:
  263. bone.x = bone.data.x;
  264. bone.y = bone.data.y;
  265. return;
  266. case MixBlend.first:
  267. bone.x += (bone.data.x - bone.x) * alpha;
  268. bone.y += (bone.data.y - bone.y) * alpha;
  269. }
  270. return;
  271. }
  272. var x = 0, y = 0;
  273. if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
  274. x = frames[frames.length + TranslateTimeline.PREV_X];
  275. y = frames[frames.length + TranslateTimeline.PREV_Y];
  276. }
  277. else {
  278. var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES);
  279. x = frames[frame + TranslateTimeline.PREV_X];
  280. y = frames[frame + TranslateTimeline.PREV_Y];
  281. var frameTime = frames[frame];
  282. var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime));
  283. x += (frames[frame + TranslateTimeline.X] - x) * percent;
  284. y += (frames[frame + TranslateTimeline.Y] - y) * percent;
  285. }
  286. switch (blend) {
  287. case MixBlend.setup:
  288. bone.x = bone.data.x + x * alpha;
  289. bone.y = bone.data.y + y * alpha;
  290. break;
  291. case MixBlend.first:
  292. case MixBlend.replace:
  293. bone.x += (bone.data.x + x - bone.x) * alpha;
  294. bone.y += (bone.data.y + y - bone.y) * alpha;
  295. break;
  296. case MixBlend.add:
  297. bone.x += x * alpha;
  298. bone.y += y * alpha;
  299. }
  300. };
  301. TranslateTimeline.ENTRIES = 3;
  302. TranslateTimeline.PREV_TIME = -3;
  303. TranslateTimeline.PREV_X = -2;
  304. TranslateTimeline.PREV_Y = -1;
  305. TranslateTimeline.X = 1;
  306. TranslateTimeline.Y = 2;
  307. return TranslateTimeline;
  308. }(CurveTimeline));
  309. spine.TranslateTimeline = TranslateTimeline;
  310. var ScaleTimeline = (function (_super) {
  311. __extends(ScaleTimeline, _super);
  312. function ScaleTimeline(frameCount) {
  313. return _super.call(this, frameCount) || this;
  314. }
  315. ScaleTimeline.prototype.getPropertyId = function () {
  316. return (TimelineType.scale << 24) + this.boneIndex;
  317. };
  318. ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  319. var frames = this.frames;
  320. var bone = skeleton.bones[this.boneIndex];
  321. if (time < frames[0]) {
  322. switch (blend) {
  323. case MixBlend.setup:
  324. bone.scaleX = bone.data.scaleX;
  325. bone.scaleY = bone.data.scaleY;
  326. return;
  327. case MixBlend.first:
  328. bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
  329. bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
  330. }
  331. return;
  332. }
  333. var x = 0, y = 0;
  334. if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
  335. x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
  336. y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY;
  337. }
  338. else {
  339. var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES);
  340. x = frames[frame + ScaleTimeline.PREV_X];
  341. y = frames[frame + ScaleTimeline.PREV_Y];
  342. var frameTime = frames[frame];
  343. var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime));
  344. x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX;
  345. y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
  346. }
  347. if (alpha == 1) {
  348. if (blend == MixBlend.add) {
  349. bone.scaleX += x - bone.data.scaleX;
  350. bone.scaleY += y - bone.data.scaleY;
  351. }
  352. else {
  353. bone.scaleX = x;
  354. bone.scaleY = y;
  355. }
  356. }
  357. else {
  358. var bx = 0, by = 0;
  359. if (direction == MixDirection.out) {
  360. switch (blend) {
  361. case MixBlend.setup:
  362. bx = bone.data.scaleX;
  363. by = bone.data.scaleY;
  364. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
  365. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
  366. break;
  367. case MixBlend.first:
  368. case MixBlend.replace:
  369. bx = bone.scaleX;
  370. by = bone.scaleY;
  371. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
  372. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
  373. break;
  374. case MixBlend.add:
  375. bx = bone.scaleX;
  376. by = bone.scaleY;
  377. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
  378. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
  379. }
  380. }
  381. else {
  382. switch (blend) {
  383. case MixBlend.setup:
  384. bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
  385. by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
  386. bone.scaleX = bx + (x - bx) * alpha;
  387. bone.scaleY = by + (y - by) * alpha;
  388. break;
  389. case MixBlend.first:
  390. case MixBlend.replace:
  391. bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
  392. by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
  393. bone.scaleX = bx + (x - bx) * alpha;
  394. bone.scaleY = by + (y - by) * alpha;
  395. break;
  396. case MixBlend.add:
  397. bx = spine.MathUtils.signum(x);
  398. by = spine.MathUtils.signum(y);
  399. bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
  400. bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
  401. }
  402. }
  403. }
  404. };
  405. return ScaleTimeline;
  406. }(TranslateTimeline));
  407. spine.ScaleTimeline = ScaleTimeline;
  408. var ShearTimeline = (function (_super) {
  409. __extends(ShearTimeline, _super);
  410. function ShearTimeline(frameCount) {
  411. return _super.call(this, frameCount) || this;
  412. }
  413. ShearTimeline.prototype.getPropertyId = function () {
  414. return (TimelineType.shear << 24) + this.boneIndex;
  415. };
  416. ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  417. var frames = this.frames;
  418. var bone = skeleton.bones[this.boneIndex];
  419. if (time < frames[0]) {
  420. switch (blend) {
  421. case MixBlend.setup:
  422. bone.shearX = bone.data.shearX;
  423. bone.shearY = bone.data.shearY;
  424. return;
  425. case MixBlend.first:
  426. bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
  427. bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
  428. }
  429. return;
  430. }
  431. var x = 0, y = 0;
  432. if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
  433. x = frames[frames.length + ShearTimeline.PREV_X];
  434. y = frames[frames.length + ShearTimeline.PREV_Y];
  435. }
  436. else {
  437. var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES);
  438. x = frames[frame + ShearTimeline.PREV_X];
  439. y = frames[frame + ShearTimeline.PREV_Y];
  440. var frameTime = frames[frame];
  441. var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime));
  442. x = x + (frames[frame + ShearTimeline.X] - x) * percent;
  443. y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
  444. }
  445. switch (blend) {
  446. case MixBlend.setup:
  447. bone.shearX = bone.data.shearX + x * alpha;
  448. bone.shearY = bone.data.shearY + y * alpha;
  449. break;
  450. case MixBlend.first:
  451. case MixBlend.replace:
  452. bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
  453. bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
  454. break;
  455. case MixBlend.add:
  456. bone.shearX += x * alpha;
  457. bone.shearY += y * alpha;
  458. }
  459. };
  460. return ShearTimeline;
  461. }(TranslateTimeline));
  462. spine.ShearTimeline = ShearTimeline;
  463. var ColorTimeline = (function (_super) {
  464. __extends(ColorTimeline, _super);
  465. function ColorTimeline(frameCount) {
  466. var _this = _super.call(this, frameCount) || this;
  467. _this.frames = spine.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES);
  468. return _this;
  469. }
  470. ColorTimeline.prototype.getPropertyId = function () {
  471. return (TimelineType.color << 24) + this.slotIndex;
  472. };
  473. ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) {
  474. frameIndex *= ColorTimeline.ENTRIES;
  475. this.frames[frameIndex] = time;
  476. this.frames[frameIndex + ColorTimeline.R] = r;
  477. this.frames[frameIndex + ColorTimeline.G] = g;
  478. this.frames[frameIndex + ColorTimeline.B] = b;
  479. this.frames[frameIndex + ColorTimeline.A] = a;
  480. };
  481. ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  482. var slot = skeleton.slots[this.slotIndex];
  483. var frames = this.frames;
  484. if (time < frames[0]) {
  485. switch (blend) {
  486. case MixBlend.setup:
  487. slot.color.setFromColor(slot.data.color);
  488. return;
  489. case MixBlend.first:
  490. var color = slot.color, setup = slot.data.color;
  491. color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
  492. }
  493. return;
  494. }
  495. var r = 0, g = 0, b = 0, a = 0;
  496. if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
  497. var i = frames.length;
  498. r = frames[i + ColorTimeline.PREV_R];
  499. g = frames[i + ColorTimeline.PREV_G];
  500. b = frames[i + ColorTimeline.PREV_B];
  501. a = frames[i + ColorTimeline.PREV_A];
  502. }
  503. else {
  504. var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES);
  505. r = frames[frame + ColorTimeline.PREV_R];
  506. g = frames[frame + ColorTimeline.PREV_G];
  507. b = frames[frame + ColorTimeline.PREV_B];
  508. a = frames[frame + ColorTimeline.PREV_A];
  509. var frameTime = frames[frame];
  510. var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime));
  511. r += (frames[frame + ColorTimeline.R] - r) * percent;
  512. g += (frames[frame + ColorTimeline.G] - g) * percent;
  513. b += (frames[frame + ColorTimeline.B] - b) * percent;
  514. a += (frames[frame + ColorTimeline.A] - a) * percent;
  515. }
  516. if (alpha == 1)
  517. slot.color.set(r, g, b, a);
  518. else {
  519. var color = slot.color;
  520. if (blend == MixBlend.setup)
  521. color.setFromColor(slot.data.color);
  522. color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
  523. }
  524. };
  525. ColorTimeline.ENTRIES = 5;
  526. ColorTimeline.PREV_TIME = -5;
  527. ColorTimeline.PREV_R = -4;
  528. ColorTimeline.PREV_G = -3;
  529. ColorTimeline.PREV_B = -2;
  530. ColorTimeline.PREV_A = -1;
  531. ColorTimeline.R = 1;
  532. ColorTimeline.G = 2;
  533. ColorTimeline.B = 3;
  534. ColorTimeline.A = 4;
  535. return ColorTimeline;
  536. }(CurveTimeline));
  537. spine.ColorTimeline = ColorTimeline;
  538. var TwoColorTimeline = (function (_super) {
  539. __extends(TwoColorTimeline, _super);
  540. function TwoColorTimeline(frameCount) {
  541. var _this = _super.call(this, frameCount) || this;
  542. _this.frames = spine.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES);
  543. return _this;
  544. }
  545. TwoColorTimeline.prototype.getPropertyId = function () {
  546. return (TimelineType.twoColor << 24) + this.slotIndex;
  547. };
  548. TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) {
  549. frameIndex *= TwoColorTimeline.ENTRIES;
  550. this.frames[frameIndex] = time;
  551. this.frames[frameIndex + TwoColorTimeline.R] = r;
  552. this.frames[frameIndex + TwoColorTimeline.G] = g;
  553. this.frames[frameIndex + TwoColorTimeline.B] = b;
  554. this.frames[frameIndex + TwoColorTimeline.A] = a;
  555. this.frames[frameIndex + TwoColorTimeline.R2] = r2;
  556. this.frames[frameIndex + TwoColorTimeline.G2] = g2;
  557. this.frames[frameIndex + TwoColorTimeline.B2] = b2;
  558. };
  559. TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  560. var slot = skeleton.slots[this.slotIndex];
  561. var frames = this.frames;
  562. if (time < frames[0]) {
  563. switch (blend) {
  564. case MixBlend.setup:
  565. slot.color.setFromColor(slot.data.color);
  566. slot.darkColor.setFromColor(slot.data.darkColor);
  567. return;
  568. case MixBlend.first:
  569. var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
  570. light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
  571. dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
  572. }
  573. return;
  574. }
  575. var r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0;
  576. if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) {
  577. var i = frames.length;
  578. r = frames[i + TwoColorTimeline.PREV_R];
  579. g = frames[i + TwoColorTimeline.PREV_G];
  580. b = frames[i + TwoColorTimeline.PREV_B];
  581. a = frames[i + TwoColorTimeline.PREV_A];
  582. r2 = frames[i + TwoColorTimeline.PREV_R2];
  583. g2 = frames[i + TwoColorTimeline.PREV_G2];
  584. b2 = frames[i + TwoColorTimeline.PREV_B2];
  585. }
  586. else {
  587. var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES);
  588. r = frames[frame + TwoColorTimeline.PREV_R];
  589. g = frames[frame + TwoColorTimeline.PREV_G];
  590. b = frames[frame + TwoColorTimeline.PREV_B];
  591. a = frames[frame + TwoColorTimeline.PREV_A];
  592. r2 = frames[frame + TwoColorTimeline.PREV_R2];
  593. g2 = frames[frame + TwoColorTimeline.PREV_G2];
  594. b2 = frames[frame + TwoColorTimeline.PREV_B2];
  595. var frameTime = frames[frame];
  596. var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime));
  597. r += (frames[frame + TwoColorTimeline.R] - r) * percent;
  598. g += (frames[frame + TwoColorTimeline.G] - g) * percent;
  599. b += (frames[frame + TwoColorTimeline.B] - b) * percent;
  600. a += (frames[frame + TwoColorTimeline.A] - a) * percent;
  601. r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent;
  602. g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent;
  603. b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent;
  604. }
  605. if (alpha == 1) {
  606. slot.color.set(r, g, b, a);
  607. slot.darkColor.set(r2, g2, b2, 1);
  608. }
  609. else {
  610. var light = slot.color, dark = slot.darkColor;
  611. if (blend == MixBlend.setup) {
  612. light.setFromColor(slot.data.color);
  613. dark.setFromColor(slot.data.darkColor);
  614. }
  615. light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha);
  616. dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0);
  617. }
  618. };
  619. TwoColorTimeline.ENTRIES = 8;
  620. TwoColorTimeline.PREV_TIME = -8;
  621. TwoColorTimeline.PREV_R = -7;
  622. TwoColorTimeline.PREV_G = -6;
  623. TwoColorTimeline.PREV_B = -5;
  624. TwoColorTimeline.PREV_A = -4;
  625. TwoColorTimeline.PREV_R2 = -3;
  626. TwoColorTimeline.PREV_G2 = -2;
  627. TwoColorTimeline.PREV_B2 = -1;
  628. TwoColorTimeline.R = 1;
  629. TwoColorTimeline.G = 2;
  630. TwoColorTimeline.B = 3;
  631. TwoColorTimeline.A = 4;
  632. TwoColorTimeline.R2 = 5;
  633. TwoColorTimeline.G2 = 6;
  634. TwoColorTimeline.B2 = 7;
  635. return TwoColorTimeline;
  636. }(CurveTimeline));
  637. spine.TwoColorTimeline = TwoColorTimeline;
  638. var AttachmentTimeline = (function () {
  639. function AttachmentTimeline(frameCount) {
  640. this.frames = spine.Utils.newFloatArray(frameCount);
  641. this.attachmentNames = new Array(frameCount);
  642. }
  643. AttachmentTimeline.prototype.getPropertyId = function () {
  644. return (TimelineType.attachment << 24) + this.slotIndex;
  645. };
  646. AttachmentTimeline.prototype.getFrameCount = function () {
  647. return this.frames.length;
  648. };
  649. AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) {
  650. this.frames[frameIndex] = time;
  651. this.attachmentNames[frameIndex] = attachmentName;
  652. };
  653. AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  654. var slot = skeleton.slots[this.slotIndex];
  655. if (direction == MixDirection.out && blend == MixBlend.setup) {
  656. var attachmentName_1 = slot.data.attachmentName;
  657. slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
  658. return;
  659. }
  660. var frames = this.frames;
  661. if (time < frames[0]) {
  662. if (blend == MixBlend.setup || blend == MixBlend.first) {
  663. var attachmentName_2 = slot.data.attachmentName;
  664. slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
  665. }
  666. return;
  667. }
  668. var frameIndex = 0;
  669. if (time >= frames[frames.length - 1])
  670. frameIndex = frames.length - 1;
  671. else
  672. frameIndex = Animation.binarySearch(frames, time, 1) - 1;
  673. var attachmentName = this.attachmentNames[frameIndex];
  674. skeleton.slots[this.slotIndex]
  675. .setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
  676. };
  677. return AttachmentTimeline;
  678. }());
  679. spine.AttachmentTimeline = AttachmentTimeline;
  680. var zeros = null;
  681. var DeformTimeline = (function (_super) {
  682. __extends(DeformTimeline, _super);
  683. function DeformTimeline(frameCount) {
  684. var _this = _super.call(this, frameCount) || this;
  685. _this.frames = spine.Utils.newFloatArray(frameCount);
  686. _this.frameVertices = new Array(frameCount);
  687. if (zeros == null)
  688. zeros = spine.Utils.newFloatArray(64);
  689. return _this;
  690. }
  691. DeformTimeline.prototype.getPropertyId = function () {
  692. return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
  693. };
  694. DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
  695. this.frames[frameIndex] = time;
  696. this.frameVertices[frameIndex] = vertices;
  697. };
  698. DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  699. var slot = skeleton.slots[this.slotIndex];
  700. var slotAttachment = slot.getAttachment();
  701. if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
  702. return;
  703. var verticesArray = slot.attachmentVertices;
  704. if (verticesArray.length == 0)
  705. blend = MixBlend.setup;
  706. var frameVertices = this.frameVertices;
  707. var vertexCount = frameVertices[0].length;
  708. var frames = this.frames;
  709. if (time < frames[0]) {
  710. var vertexAttachment = slotAttachment;
  711. switch (blend) {
  712. case MixBlend.setup:
  713. verticesArray.length = 0;
  714. return;
  715. case MixBlend.first:
  716. if (alpha == 1) {
  717. verticesArray.length = 0;
  718. break;
  719. }
  720. var vertices_1 = spine.Utils.setArraySize(verticesArray, vertexCount);
  721. if (vertexAttachment.bones == null) {
  722. var setupVertices = vertexAttachment.vertices;
  723. for (var i = 0; i < vertexCount; i++)
  724. vertices_1[i] += (setupVertices[i] - vertices_1[i]) * alpha;
  725. }
  726. else {
  727. alpha = 1 - alpha;
  728. for (var i = 0; i < vertexCount; i++)
  729. vertices_1[i] *= alpha;
  730. }
  731. }
  732. return;
  733. }
  734. var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
  735. if (time >= frames[frames.length - 1]) {
  736. var lastVertices = frameVertices[frames.length - 1];
  737. if (alpha == 1) {
  738. if (blend == MixBlend.add) {
  739. var vertexAttachment = slotAttachment;
  740. if (vertexAttachment.bones == null) {
  741. var setupVertices = vertexAttachment.vertices;
  742. for (var i_1 = 0; i_1 < vertexCount; i_1++) {
  743. vertices[i_1] += lastVertices[i_1] - setupVertices[i_1];
  744. }
  745. }
  746. else {
  747. for (var i_2 = 0; i_2 < vertexCount; i_2++)
  748. vertices[i_2] += lastVertices[i_2];
  749. }
  750. }
  751. else {
  752. spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
  753. }
  754. }
  755. else {
  756. switch (blend) {
  757. case MixBlend.setup: {
  758. var vertexAttachment_1 = slotAttachment;
  759. if (vertexAttachment_1.bones == null) {
  760. var setupVertices = vertexAttachment_1.vertices;
  761. for (var i_3 = 0; i_3 < vertexCount; i_3++) {
  762. var setup = setupVertices[i_3];
  763. vertices[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
  764. }
  765. }
  766. else {
  767. for (var i_4 = 0; i_4 < vertexCount; i_4++)
  768. vertices[i_4] = lastVertices[i_4] * alpha;
  769. }
  770. break;
  771. }
  772. case MixBlend.first:
  773. case MixBlend.replace:
  774. for (var i_5 = 0; i_5 < vertexCount; i_5++)
  775. vertices[i_5] += (lastVertices[i_5] - vertices[i_5]) * alpha;
  776. case MixBlend.add:
  777. var vertexAttachment = slotAttachment;
  778. if (vertexAttachment.bones == null) {
  779. var setupVertices = vertexAttachment.vertices;
  780. for (var i_6 = 0; i_6 < vertexCount; i_6++) {
  781. vertices[i_6] += (lastVertices[i_6] - setupVertices[i_6]) * alpha;
  782. }
  783. }
  784. else {
  785. for (var i_7 = 0; i_7 < vertexCount; i_7++)
  786. vertices[i_7] += lastVertices[i_7] * alpha;
  787. }
  788. }
  789. }
  790. return;
  791. }
  792. var frame = Animation.binarySearch(frames, time);
  793. var prevVertices = frameVertices[frame - 1];
  794. var nextVertices = frameVertices[frame];
  795. var frameTime = frames[frame];
  796. var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
  797. if (alpha == 1) {
  798. if (blend == MixBlend.add) {
  799. var vertexAttachment = slotAttachment;
  800. if (vertexAttachment.bones == null) {
  801. var setupVertices = vertexAttachment.vertices;
  802. for (var i_8 = 0; i_8 < vertexCount; i_8++) {
  803. var prev = prevVertices[i_8];
  804. vertices[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices[i_8];
  805. }
  806. }
  807. else {
  808. for (var i_9 = 0; i_9 < vertexCount; i_9++) {
  809. var prev = prevVertices[i_9];
  810. vertices[i_9] += prev + (nextVertices[i_9] - prev) * percent;
  811. }
  812. }
  813. }
  814. else {
  815. for (var i_10 = 0; i_10 < vertexCount; i_10++) {
  816. var prev = prevVertices[i_10];
  817. vertices[i_10] = prev + (nextVertices[i_10] - prev) * percent;
  818. }
  819. }
  820. }
  821. else {
  822. switch (blend) {
  823. case MixBlend.setup: {
  824. var vertexAttachment_2 = slotAttachment;
  825. if (vertexAttachment_2.bones == null) {
  826. var setupVertices = vertexAttachment_2.vertices;
  827. for (var i_11 = 0; i_11 < vertexCount; i_11++) {
  828. var prev = prevVertices[i_11], setup = setupVertices[i_11];
  829. vertices[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
  830. }
  831. }
  832. else {
  833. for (var i_12 = 0; i_12 < vertexCount; i_12++) {
  834. var prev = prevVertices[i_12];
  835. vertices[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
  836. }
  837. }
  838. break;
  839. }
  840. case MixBlend.first:
  841. case MixBlend.replace:
  842. for (var i_13 = 0; i_13 < vertexCount; i_13++) {
  843. var prev = prevVertices[i_13];
  844. vertices[i_13] += (prev + (nextVertices[i_13] - prev) * percent - vertices[i_13]) * alpha;
  845. }
  846. break;
  847. case MixBlend.add:
  848. var vertexAttachment = slotAttachment;
  849. if (vertexAttachment.bones == null) {
  850. var setupVertices = vertexAttachment.vertices;
  851. for (var i_14 = 0; i_14 < vertexCount; i_14++) {
  852. var prev = prevVertices[i_14];
  853. vertices[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices[i_14]) * alpha;
  854. }
  855. }
  856. else {
  857. for (var i_15 = 0; i_15 < vertexCount; i_15++) {
  858. var prev = prevVertices[i_15];
  859. vertices[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
  860. }
  861. }
  862. }
  863. }
  864. };
  865. return DeformTimeline;
  866. }(CurveTimeline));
  867. spine.DeformTimeline = DeformTimeline;
  868. var EventTimeline = (function () {
  869. function EventTimeline(frameCount) {
  870. this.frames = spine.Utils.newFloatArray(frameCount);
  871. this.events = new Array(frameCount);
  872. }
  873. EventTimeline.prototype.getPropertyId = function () {
  874. return TimelineType.event << 24;
  875. };
  876. EventTimeline.prototype.getFrameCount = function () {
  877. return this.frames.length;
  878. };
  879. EventTimeline.prototype.setFrame = function (frameIndex, event) {
  880. this.frames[frameIndex] = event.time;
  881. this.events[frameIndex] = event;
  882. };
  883. EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  884. if (firedEvents == null)
  885. return;
  886. var frames = this.frames;
  887. var frameCount = this.frames.length;
  888. if (lastTime > time) {
  889. this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
  890. lastTime = -1;
  891. }
  892. else if (lastTime >= frames[frameCount - 1])
  893. return;
  894. if (time < frames[0])
  895. return;
  896. var frame = 0;
  897. if (lastTime < frames[0])
  898. frame = 0;
  899. else {
  900. frame = Animation.binarySearch(frames, lastTime);
  901. var frameTime = frames[frame];
  902. while (frame > 0) {
  903. if (frames[frame - 1] != frameTime)
  904. break;
  905. frame--;
  906. }
  907. }
  908. for (; frame < frameCount && time >= frames[frame]; frame++)
  909. firedEvents.push(this.events[frame]);
  910. };
  911. return EventTimeline;
  912. }());
  913. spine.EventTimeline = EventTimeline;
  914. var DrawOrderTimeline = (function () {
  915. function DrawOrderTimeline(frameCount) {
  916. this.frames = spine.Utils.newFloatArray(frameCount);
  917. this.drawOrders = new Array(frameCount);
  918. }
  919. DrawOrderTimeline.prototype.getPropertyId = function () {
  920. return TimelineType.drawOrder << 24;
  921. };
  922. DrawOrderTimeline.prototype.getFrameCount = function () {
  923. return this.frames.length;
  924. };
  925. DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
  926. this.frames[frameIndex] = time;
  927. this.drawOrders[frameIndex] = drawOrder;
  928. };
  929. DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  930. var drawOrder = skeleton.drawOrder;
  931. var slots = skeleton.slots;
  932. if (direction == MixDirection.out && blend == MixBlend.setup) {
  933. spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
  934. return;
  935. }
  936. var frames = this.frames;
  937. if (time < frames[0]) {
  938. if (blend == MixBlend.setup || blend == MixBlend.first)
  939. spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
  940. return;
  941. }
  942. var frame = 0;
  943. if (time >= frames[frames.length - 1])
  944. frame = frames.length - 1;
  945. else
  946. frame = Animation.binarySearch(frames, time) - 1;
  947. var drawOrderToSetupIndex = this.drawOrders[frame];
  948. if (drawOrderToSetupIndex == null)
  949. spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
  950. else {
  951. for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
  952. drawOrder[i] = slots[drawOrderToSetupIndex[i]];
  953. }
  954. };
  955. return DrawOrderTimeline;
  956. }());
  957. spine.DrawOrderTimeline = DrawOrderTimeline;
  958. var IkConstraintTimeline = (function (_super) {
  959. __extends(IkConstraintTimeline, _super);
  960. function IkConstraintTimeline(frameCount) {
  961. var _this = _super.call(this, frameCount) || this;
  962. _this.frames = spine.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES);
  963. return _this;
  964. }
  965. IkConstraintTimeline.prototype.getPropertyId = function () {
  966. return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex;
  967. };
  968. IkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, bendDirection, compress, stretch) {
  969. frameIndex *= IkConstraintTimeline.ENTRIES;
  970. this.frames[frameIndex] = time;
  971. this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
  972. this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
  973. this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress ? 1 : 0;
  974. this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch ? 1 : 0;
  975. };
  976. IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  977. var frames = this.frames;
  978. var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
  979. if (time < frames[0]) {
  980. switch (blend) {
  981. case MixBlend.setup:
  982. constraint.mix = constraint.data.mix;
  983. constraint.bendDirection = constraint.data.bendDirection;
  984. constraint.compress = constraint.data.compress;
  985. constraint.stretch = constraint.data.stretch;
  986. return;
  987. case MixBlend.first:
  988. constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
  989. constraint.bendDirection = constraint.data.bendDirection;
  990. constraint.compress = constraint.data.compress;
  991. constraint.stretch = constraint.data.stretch;
  992. }
  993. return;
  994. }
  995. if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
  996. if (blend == MixBlend.setup) {
  997. constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
  998. if (direction == MixDirection.out) {
  999. constraint.bendDirection = constraint.data.bendDirection;
  1000. constraint.compress = constraint.data.compress;
  1001. constraint.stretch = constraint.data.stretch;
  1002. }
  1003. else {
  1004. constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1005. constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1006. constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0;
  1007. }
  1008. }
  1009. else {
  1010. constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
  1011. if (direction == MixDirection["in"]) {
  1012. constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1013. constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1014. constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0;
  1015. }
  1016. }
  1017. return;
  1018. }
  1019. var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES);
  1020. var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
  1021. var frameTime = frames[frame];
  1022. var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
  1023. if (blend == MixBlend.setup) {
  1024. constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
  1025. if (direction == MixDirection.out) {
  1026. constraint.bendDirection = constraint.data.bendDirection;
  1027. constraint.compress = constraint.data.compress;
  1028. constraint.stretch = constraint.data.stretch;
  1029. }
  1030. else {
  1031. constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1032. constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1033. constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0;
  1034. }
  1035. }
  1036. else {
  1037. constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
  1038. if (direction == MixDirection["in"]) {
  1039. constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1040. constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1041. constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0;
  1042. }
  1043. }
  1044. };
  1045. IkConstraintTimeline.ENTRIES = 5;
  1046. IkConstraintTimeline.PREV_TIME = -5;
  1047. IkConstraintTimeline.PREV_MIX = -4;
  1048. IkConstraintTimeline.PREV_BEND_DIRECTION = -3;
  1049. IkConstraintTimeline.PREV_COMPRESS = -2;
  1050. IkConstraintTimeline.PREV_STRETCH = -1;
  1051. IkConstraintTimeline.MIX = 1;
  1052. IkConstraintTimeline.BEND_DIRECTION = 2;
  1053. IkConstraintTimeline.COMPRESS = 3;
  1054. IkConstraintTimeline.STRETCH = 4;
  1055. return IkConstraintTimeline;
  1056. }(CurveTimeline));
  1057. spine.IkConstraintTimeline = IkConstraintTimeline;
  1058. var TransformConstraintTimeline = (function (_super) {
  1059. __extends(TransformConstraintTimeline, _super);
  1060. function TransformConstraintTimeline(frameCount) {
  1061. var _this = _super.call(this, frameCount) || this;
  1062. _this.frames = spine.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES);
  1063. return _this;
  1064. }
  1065. TransformConstraintTimeline.prototype.getPropertyId = function () {
  1066. return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex;
  1067. };
  1068. TransformConstraintTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) {
  1069. frameIndex *= TransformConstraintTimeline.ENTRIES;
  1070. this.frames[frameIndex] = time;
  1071. this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix;
  1072. this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix;
  1073. this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
  1074. this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
  1075. };
  1076. TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1077. var frames = this.frames;
  1078. var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
  1079. if (time < frames[0]) {
  1080. var data = constraint.data;
  1081. switch (blend) {
  1082. case MixBlend.setup:
  1083. constraint.rotateMix = data.rotateMix;
  1084. constraint.translateMix = data.translateMix;
  1085. constraint.scaleMix = data.scaleMix;
  1086. constraint.shearMix = data.shearMix;
  1087. return;
  1088. case MixBlend.first:
  1089. constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
  1090. constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
  1091. constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
  1092. constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
  1093. }
  1094. return;
  1095. }
  1096. var rotate = 0, translate = 0, scale = 0, shear = 0;
  1097. if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
  1098. var i = frames.length;
  1099. rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE];
  1100. translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE];
  1101. scale = frames[i + TransformConstraintTimeline.PREV_SCALE];
  1102. shear = frames[i + TransformConstraintTimeline.PREV_SHEAR];
  1103. }
  1104. else {
  1105. var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES);
  1106. rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE];
  1107. translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE];
  1108. scale = frames[frame + TransformConstraintTimeline.PREV_SCALE];
  1109. shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR];
  1110. var frameTime = frames[frame];
  1111. var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime));
  1112. rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent;
  1113. translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent;
  1114. scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
  1115. shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
  1116. }
  1117. if (blend == MixBlend.setup) {
  1118. var data = constraint.data;
  1119. constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
  1120. constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
  1121. constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;
  1122. constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha;
  1123. }
  1124. else {
  1125. constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
  1126. constraint.translateMix += (translate - constraint.translateMix) * alpha;
  1127. constraint.scaleMix += (scale - constraint.scaleMix) * alpha;
  1128. constraint.shearMix += (shear - constraint.shearMix) * alpha;
  1129. }
  1130. };
  1131. TransformConstraintTimeline.ENTRIES = 5;
  1132. TransformConstraintTimeline.PREV_TIME = -5;
  1133. TransformConstraintTimeline.PREV_ROTATE = -4;
  1134. TransformConstraintTimeline.PREV_TRANSLATE = -3;
  1135. TransformConstraintTimeline.PREV_SCALE = -2;
  1136. TransformConstraintTimeline.PREV_SHEAR = -1;
  1137. TransformConstraintTimeline.ROTATE = 1;
  1138. TransformConstraintTimeline.TRANSLATE = 2;
  1139. TransformConstraintTimeline.SCALE = 3;
  1140. TransformConstraintTimeline.SHEAR = 4;
  1141. return TransformConstraintTimeline;
  1142. }(CurveTimeline));
  1143. spine.TransformConstraintTimeline = TransformConstraintTimeline;
  1144. var PathConstraintPositionTimeline = (function (_super) {
  1145. __extends(PathConstraintPositionTimeline, _super);
  1146. function PathConstraintPositionTimeline(frameCount) {
  1147. var _this = _super.call(this, frameCount) || this;
  1148. _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES);
  1149. return _this;
  1150. }
  1151. PathConstraintPositionTimeline.prototype.getPropertyId = function () {
  1152. return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex;
  1153. };
  1154. PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) {
  1155. frameIndex *= PathConstraintPositionTimeline.ENTRIES;
  1156. this.frames[frameIndex] = time;
  1157. this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
  1158. };
  1159. PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1160. var frames = this.frames;
  1161. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1162. if (time < frames[0]) {
  1163. switch (blend) {
  1164. case MixBlend.setup:
  1165. constraint.position = constraint.data.position;
  1166. return;
  1167. case MixBlend.first:
  1168. constraint.position += (constraint.data.position - constraint.position) * alpha;
  1169. }
  1170. return;
  1171. }
  1172. var position = 0;
  1173. if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
  1174. position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
  1175. else {
  1176. var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES);
  1177. position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE];
  1178. var frameTime = frames[frame];
  1179. var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
  1180. position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
  1181. }
  1182. if (blend == MixBlend.setup)
  1183. constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
  1184. else
  1185. constraint.position += (position - constraint.position) * alpha;
  1186. };
  1187. PathConstraintPositionTimeline.ENTRIES = 2;
  1188. PathConstraintPositionTimeline.PREV_TIME = -2;
  1189. PathConstraintPositionTimeline.PREV_VALUE = -1;
  1190. PathConstraintPositionTimeline.VALUE = 1;
  1191. return PathConstraintPositionTimeline;
  1192. }(CurveTimeline));
  1193. spine.PathConstraintPositionTimeline = PathConstraintPositionTimeline;
  1194. var PathConstraintSpacingTimeline = (function (_super) {
  1195. __extends(PathConstraintSpacingTimeline, _super);
  1196. function PathConstraintSpacingTimeline(frameCount) {
  1197. return _super.call(this, frameCount) || this;
  1198. }
  1199. PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
  1200. return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
  1201. };
  1202. PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1203. var frames = this.frames;
  1204. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1205. if (time < frames[0]) {
  1206. switch (blend) {
  1207. case MixBlend.setup:
  1208. constraint.spacing = constraint.data.spacing;
  1209. return;
  1210. case MixBlend.first:
  1211. constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
  1212. }
  1213. return;
  1214. }
  1215. var spacing = 0;
  1216. if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
  1217. spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
  1218. else {
  1219. var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES);
  1220. spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE];
  1221. var frameTime = frames[frame];
  1222. var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
  1223. spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
  1224. }
  1225. if (blend == MixBlend.setup)
  1226. constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
  1227. else
  1228. constraint.spacing += (spacing - constraint.spacing) * alpha;
  1229. };
  1230. return PathConstraintSpacingTimeline;
  1231. }(PathConstraintPositionTimeline));
  1232. spine.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline;
  1233. var PathConstraintMixTimeline = (function (_super) {
  1234. __extends(PathConstraintMixTimeline, _super);
  1235. function PathConstraintMixTimeline(frameCount) {
  1236. var _this = _super.call(this, frameCount) || this;
  1237. _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES);
  1238. return _this;
  1239. }
  1240. PathConstraintMixTimeline.prototype.getPropertyId = function () {
  1241. return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex;
  1242. };
  1243. PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) {
  1244. frameIndex *= PathConstraintMixTimeline.ENTRIES;
  1245. this.frames[frameIndex] = time;
  1246. this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
  1247. this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
  1248. };
  1249. PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1250. var frames = this.frames;
  1251. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1252. if (time < frames[0]) {
  1253. switch (blend) {
  1254. case MixBlend.setup:
  1255. constraint.rotateMix = constraint.data.rotateMix;
  1256. constraint.translateMix = constraint.data.translateMix;
  1257. return;
  1258. case MixBlend.first:
  1259. constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
  1260. constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
  1261. }
  1262. return;
  1263. }
  1264. var rotate = 0, translate = 0;
  1265. if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
  1266. rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
  1267. translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE];
  1268. }
  1269. else {
  1270. var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES);
  1271. rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE];
  1272. translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE];
  1273. var frameTime = frames[frame];
  1274. var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime));
  1275. rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
  1276. translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
  1277. }
  1278. if (blend == MixBlend.setup) {
  1279. constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
  1280. constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
  1281. }
  1282. else {
  1283. constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
  1284. constraint.translateMix += (translate - constraint.translateMix) * alpha;
  1285. }
  1286. };
  1287. PathConstraintMixTimeline.ENTRIES = 3;
  1288. PathConstraintMixTimeline.PREV_TIME = -3;
  1289. PathConstraintMixTimeline.PREV_ROTATE = -2;
  1290. PathConstraintMixTimeline.PREV_TRANSLATE = -1;
  1291. PathConstraintMixTimeline.ROTATE = 1;
  1292. PathConstraintMixTimeline.TRANSLATE = 2;
  1293. return PathConstraintMixTimeline;
  1294. }(CurveTimeline));
  1295. spine.PathConstraintMixTimeline = PathConstraintMixTimeline;
  1296. })(spine || (spine = {}));
  1297. var spine;
  1298. (function (spine) {
  1299. var AnimationState = (function () {
  1300. function AnimationState(data) {
  1301. this.tracks = new Array();
  1302. this.events = new Array();
  1303. this.listeners = new Array();
  1304. this.queue = new EventQueue(this);
  1305. this.propertyIDs = new spine.IntSet();
  1306. this.animationsChanged = false;
  1307. this.timeScale = 1;
  1308. this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
  1309. this.data = data;
  1310. }
  1311. AnimationState.prototype.update = function (delta) {
  1312. delta *= this.timeScale;
  1313. var tracks = this.tracks;
  1314. for (var i = 0, n = tracks.length; i < n; i++) {
  1315. var current = tracks[i];
  1316. if (current == null)
  1317. continue;
  1318. current.animationLast = current.nextAnimationLast;
  1319. current.trackLast = current.nextTrackLast;
  1320. var currentDelta = delta * current.timeScale;
  1321. if (current.delay > 0) {
  1322. current.delay -= currentDelta;
  1323. if (current.delay > 0)
  1324. continue;
  1325. currentDelta = -current.delay;
  1326. current.delay = 0;
  1327. }
  1328. var next = current.next;
  1329. if (next != null) {
  1330. var nextTime = current.trackLast - next.delay;
  1331. if (nextTime >= 0) {
  1332. next.delay = 0;
  1333. next.trackTime = current.timeScale == 0 ? 0 : (nextTime / current.timeScale + delta) * next.timeScale;
  1334. current.trackTime += currentDelta;
  1335. this.setCurrent(i, next, true);
  1336. while (next.mixingFrom != null) {
  1337. next.mixTime += delta;
  1338. next = next.mixingFrom;
  1339. }
  1340. continue;
  1341. }
  1342. }
  1343. else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) {
  1344. tracks[i] = null;
  1345. this.queue.end(current);
  1346. this.disposeNext(current);
  1347. continue;
  1348. }
  1349. if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) {
  1350. var from = current.mixingFrom;
  1351. current.mixingFrom = null;
  1352. if (from != null)
  1353. from.mixingTo = null;
  1354. while (from != null) {
  1355. this.queue.end(from);
  1356. from = from.mixingFrom;
  1357. }
  1358. }
  1359. current.trackTime += currentDelta;
  1360. }
  1361. this.queue.drain();
  1362. };
  1363. AnimationState.prototype.updateMixingFrom = function (to, delta) {
  1364. var from = to.mixingFrom;
  1365. if (from == null)
  1366. return true;
  1367. var finished = this.updateMixingFrom(from, delta);
  1368. from.animationLast = from.nextAnimationLast;
  1369. from.trackLast = from.nextTrackLast;
  1370. if (to.mixTime > 0 && to.mixTime >= to.mixDuration) {
  1371. if (from.totalAlpha == 0 || to.mixDuration == 0) {
  1372. to.mixingFrom = from.mixingFrom;
  1373. if (from.mixingFrom != null)
  1374. from.mixingFrom.mixingTo = to;
  1375. to.interruptAlpha = from.interruptAlpha;
  1376. this.queue.end(from);
  1377. }
  1378. return finished;
  1379. }
  1380. from.trackTime += delta * from.timeScale;
  1381. to.mixTime += delta;
  1382. return false;
  1383. };
  1384. AnimationState.prototype.apply = function (skeleton) {
  1385. if (skeleton == null)
  1386. throw new Error("skeleton cannot be null.");
  1387. if (this.animationsChanged)
  1388. this._animationsChanged();
  1389. var events = this.events;
  1390. var tracks = this.tracks;
  1391. var applied = false;
  1392. for (var i = 0, n = tracks.length; i < n; i++) {
  1393. var current = tracks[i];
  1394. if (current == null || current.delay > 0)
  1395. continue;
  1396. applied = true;
  1397. var blend = i == 0 ? spine.MixBlend.first : current.mixBlend;
  1398. var mix = current.alpha;
  1399. if (current.mixingFrom != null)
  1400. mix *= this.applyMixingFrom(current, skeleton, blend);
  1401. else if (current.trackTime >= current.trackEnd && current.next == null)
  1402. mix = 0;
  1403. var animationLast = current.animationLast, animationTime = current.getAnimationTime();
  1404. var timelineCount = current.animation.timelines.length;
  1405. var timelines = current.animation.timelines;
  1406. if ((i == 0 && mix == 1) || blend == spine.MixBlend.add) {
  1407. for (var ii = 0; ii < timelineCount; ii++)
  1408. timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection["in"]);
  1409. }
  1410. else {
  1411. var timelineMode = current.timelineMode;
  1412. var firstFrame = current.timelinesRotation.length == 0;
  1413. if (firstFrame)
  1414. spine.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null);
  1415. var timelinesRotation = current.timelinesRotation;
  1416. for (var ii = 0; ii < timelineCount; ii++) {
  1417. var timeline = timelines[ii];
  1418. var timelineBlend = timelineMode[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
  1419. if (timeline instanceof spine.RotateTimeline) {
  1420. this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
  1421. }
  1422. else {
  1423. spine.Utils.webkit602BugfixHelper(mix, blend);
  1424. timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection["in"]);
  1425. }
  1426. }
  1427. }
  1428. this.queueEvents(current, animationTime);
  1429. events.length = 0;
  1430. current.nextAnimationLast = animationTime;
  1431. current.nextTrackLast = current.trackTime;
  1432. }
  1433. this.queue.drain();
  1434. return applied;
  1435. };
  1436. AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
  1437. var from = to.mixingFrom;
  1438. if (from.mixingFrom != null)
  1439. this.applyMixingFrom(from, skeleton, blend);
  1440. var mix = 0;
  1441. if (to.mixDuration == 0) {
  1442. mix = 1;
  1443. if (blend == spine.MixBlend.first)
  1444. blend = spine.MixBlend.setup;
  1445. }
  1446. else {
  1447. mix = to.mixTime / to.mixDuration;
  1448. if (mix > 1)
  1449. mix = 1;
  1450. if (blend != spine.MixBlend.first)
  1451. blend = from.mixBlend;
  1452. }
  1453. var events = mix < from.eventThreshold ? this.events : null;
  1454. var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
  1455. var animationLast = from.animationLast, animationTime = from.getAnimationTime();
  1456. var timelineCount = from.animation.timelines.length;
  1457. var timelines = from.animation.timelines;
  1458. var alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix);
  1459. if (blend == spine.MixBlend.add) {
  1460. for (var i = 0; i < timelineCount; i++)
  1461. timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.out);
  1462. }
  1463. else {
  1464. var timelineMode = from.timelineMode;
  1465. var timelineHoldMix = from.timelineHoldMix;
  1466. var firstFrame = from.timelinesRotation.length == 0;
  1467. if (firstFrame)
  1468. spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
  1469. var timelinesRotation = from.timelinesRotation;
  1470. from.totalAlpha = 0;
  1471. for (var i = 0; i < timelineCount; i++) {
  1472. var timeline = timelines[i];
  1473. var direction = spine.MixDirection.out;
  1474. var timelineBlend = void 0;
  1475. var alpha = 0;
  1476. switch (timelineMode[i]) {
  1477. case AnimationState.SUBSEQUENT:
  1478. if (!attachments && timeline instanceof spine.AttachmentTimeline)
  1479. continue;
  1480. if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
  1481. continue;
  1482. timelineBlend = blend;
  1483. alpha = alphaMix;
  1484. break;
  1485. case AnimationState.FIRST:
  1486. timelineBlend = spine.MixBlend.setup;
  1487. alpha = alphaMix;
  1488. break;
  1489. case AnimationState.HOLD:
  1490. timelineBlend = spine.MixBlend.setup;
  1491. alpha = alphaHold;
  1492. break;
  1493. default:
  1494. timelineBlend = spine.MixBlend.setup;
  1495. var holdMix = timelineHoldMix[i];
  1496. alpha = alphaHold * Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration);
  1497. break;
  1498. }
  1499. from.totalAlpha += alpha;
  1500. if (timeline instanceof spine.RotateTimeline)
  1501. this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
  1502. else {
  1503. spine.Utils.webkit602BugfixHelper(alpha, blend);
  1504. if (timelineBlend == spine.MixBlend.setup) {
  1505. if (timeline instanceof spine.AttachmentTimeline) {
  1506. if (attachments)
  1507. direction = spine.MixDirection.out;
  1508. }
  1509. else if (timeline instanceof spine.DrawOrderTimeline) {
  1510. if (drawOrder)
  1511. direction = spine.MixDirection.out;
  1512. }
  1513. }
  1514. timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction);
  1515. }
  1516. }
  1517. }
  1518. if (to.mixDuration > 0)
  1519. this.queueEvents(from, animationTime);
  1520. this.events.length = 0;
  1521. from.nextAnimationLast = animationTime;
  1522. from.nextTrackLast = from.trackTime;
  1523. return mix;
  1524. };
  1525. AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
  1526. if (firstFrame)
  1527. timelinesRotation[i] = 0;
  1528. if (alpha == 1) {
  1529. timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection["in"]);
  1530. return;
  1531. }
  1532. var rotateTimeline = timeline;
  1533. var frames = rotateTimeline.frames;
  1534. var bone = skeleton.bones[rotateTimeline.boneIndex];
  1535. var r1 = 0, r2 = 0;
  1536. if (time < frames[0]) {
  1537. switch (blend) {
  1538. case spine.MixBlend.setup:
  1539. bone.rotation = bone.data.rotation;
  1540. default:
  1541. return;
  1542. case spine.MixBlend.first:
  1543. r1 = bone.rotation;
  1544. r2 = bone.data.rotation;
  1545. }
  1546. }
  1547. else {
  1548. r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
  1549. if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
  1550. r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
  1551. else {
  1552. var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
  1553. var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
  1554. var frameTime = frames[frame];
  1555. var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
  1556. r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
  1557. r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
  1558. r2 = prevRotation + r2 * percent + bone.data.rotation;
  1559. r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
  1560. }
  1561. }
  1562. var total = 0, diff = r2 - r1;
  1563. diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
  1564. if (diff == 0) {
  1565. total = timelinesRotation[i];
  1566. }
  1567. else {
  1568. var lastTotal = 0, lastDiff = 0;
  1569. if (firstFrame) {
  1570. lastTotal = 0;
  1571. lastDiff = diff;
  1572. }
  1573. else {
  1574. lastTotal = timelinesRotation[i];
  1575. lastDiff = timelinesRotation[i + 1];
  1576. }
  1577. var current = diff > 0, dir = lastTotal >= 0;
  1578. if (spine.MathUtils.signum(lastDiff) != spine.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) {
  1579. if (Math.abs(lastTotal) > 180)
  1580. lastTotal += 360 * spine.MathUtils.signum(lastTotal);
  1581. dir = current;
  1582. }
  1583. total = diff + lastTotal - lastTotal % 360;
  1584. if (dir != current)
  1585. total += 360 * spine.MathUtils.signum(lastTotal);
  1586. timelinesRotation[i] = total;
  1587. }
  1588. timelinesRotation[i + 1] = diff;
  1589. r1 += total * alpha;
  1590. bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360;
  1591. };
  1592. AnimationState.prototype.queueEvents = function (entry, animationTime) {
  1593. var animationStart = entry.animationStart, animationEnd = entry.animationEnd;
  1594. var duration = animationEnd - animationStart;
  1595. var trackLastWrapped = entry.trackLast % duration;
  1596. var events = this.events;
  1597. var i = 0, n = events.length;
  1598. for (; i < n; i++) {
  1599. var event_1 = events[i];
  1600. if (event_1.time < trackLastWrapped)
  1601. break;
  1602. if (event_1.time > animationEnd)
  1603. continue;
  1604. this.queue.event(entry, event_1);
  1605. }
  1606. var complete = false;
  1607. if (entry.loop)
  1608. complete = duration == 0 || trackLastWrapped > entry.trackTime % duration;
  1609. else
  1610. complete = animationTime >= animationEnd && entry.animationLast < animationEnd;
  1611. if (complete)
  1612. this.queue.complete(entry);
  1613. for (; i < n; i++) {
  1614. var event_2 = events[i];
  1615. if (event_2.time < animationStart)
  1616. continue;
  1617. this.queue.event(entry, events[i]);
  1618. }
  1619. };
  1620. AnimationState.prototype.clearTracks = function () {
  1621. var oldDrainDisabled = this.queue.drainDisabled;
  1622. this.queue.drainDisabled = true;
  1623. for (var i = 0, n = this.tracks.length; i < n; i++)
  1624. this.clearTrack(i);
  1625. this.tracks.length = 0;
  1626. this.queue.drainDisabled = oldDrainDisabled;
  1627. this.queue.drain();
  1628. };
  1629. AnimationState.prototype.clearTrack = function (trackIndex) {
  1630. if (trackIndex >= this.tracks.length)
  1631. return;
  1632. var current = this.tracks[trackIndex];
  1633. if (current == null)
  1634. return;
  1635. this.queue.end(current);
  1636. this.disposeNext(current);
  1637. var entry = current;
  1638. while (true) {
  1639. var from = entry.mixingFrom;
  1640. if (from == null)
  1641. break;
  1642. this.queue.end(from);
  1643. entry.mixingFrom = null;
  1644. entry.mixingTo = null;
  1645. entry = from;
  1646. }
  1647. this.tracks[current.trackIndex] = null;
  1648. this.queue.drain();
  1649. };
  1650. AnimationState.prototype.setCurrent = function (index, current, interrupt) {
  1651. var from = this.expandToIndex(index);
  1652. this.tracks[index] = current;
  1653. if (from != null) {
  1654. if (interrupt)
  1655. this.queue.interrupt(from);
  1656. current.mixingFrom = from;
  1657. from.mixingTo = current;
  1658. current.mixTime = 0;
  1659. if (from.mixingFrom != null && from.mixDuration > 0)
  1660. current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration);
  1661. from.timelinesRotation.length = 0;
  1662. }
  1663. this.queue.start(current);
  1664. };
  1665. AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) {
  1666. var animation = this.data.skeletonData.findAnimation(animationName);
  1667. if (animation == null)
  1668. throw new Error("Animation not found: " + animationName);
  1669. return this.setAnimationWith(trackIndex, animation, loop);
  1670. };
  1671. AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) {
  1672. if (animation == null)
  1673. throw new Error("animation cannot be null.");
  1674. var interrupt = true;
  1675. var current = this.expandToIndex(trackIndex);
  1676. if (current != null) {
  1677. if (current.nextTrackLast == -1) {
  1678. this.tracks[trackIndex] = current.mixingFrom;
  1679. this.queue.interrupt(current);
  1680. this.queue.end(current);
  1681. this.disposeNext(current);
  1682. current = current.mixingFrom;
  1683. interrupt = false;
  1684. }
  1685. else
  1686. this.disposeNext(current);
  1687. }
  1688. var entry = this.trackEntry(trackIndex, animation, loop, current);
  1689. this.setCurrent(trackIndex, entry, interrupt);
  1690. this.queue.drain();
  1691. return entry;
  1692. };
  1693. AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) {
  1694. var animation = this.data.skeletonData.findAnimation(animationName);
  1695. if (animation == null)
  1696. throw new Error("Animation not found: " + animationName);
  1697. return this.addAnimationWith(trackIndex, animation, loop, delay);
  1698. };
  1699. AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) {
  1700. if (animation == null)
  1701. throw new Error("animation cannot be null.");
  1702. var last = this.expandToIndex(trackIndex);
  1703. if (last != null) {
  1704. while (last.next != null)
  1705. last = last.next;
  1706. }
  1707. var entry = this.trackEntry(trackIndex, animation, loop, last);
  1708. if (last == null) {
  1709. this.setCurrent(trackIndex, entry, true);
  1710. this.queue.drain();
  1711. }
  1712. else {
  1713. last.next = entry;
  1714. if (delay <= 0) {
  1715. var duration = last.animationEnd - last.animationStart;
  1716. if (duration != 0) {
  1717. if (last.loop)
  1718. delay += duration * (1 + ((last.trackTime / duration) | 0));
  1719. else
  1720. delay += Math.max(duration, last.trackTime);
  1721. delay -= this.data.getMix(last.animation, animation);
  1722. }
  1723. else
  1724. delay = last.trackTime;
  1725. }
  1726. }
  1727. entry.delay = delay;
  1728. return entry;
  1729. };
  1730. AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) {
  1731. var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false);
  1732. entry.mixDuration = mixDuration;
  1733. entry.trackEnd = mixDuration;
  1734. return entry;
  1735. };
  1736. AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) {
  1737. if (delay <= 0)
  1738. delay -= mixDuration;
  1739. var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay);
  1740. entry.mixDuration = mixDuration;
  1741. entry.trackEnd = mixDuration;
  1742. return entry;
  1743. };
  1744. AnimationState.prototype.setEmptyAnimations = function (mixDuration) {
  1745. var oldDrainDisabled = this.queue.drainDisabled;
  1746. this.queue.drainDisabled = true;
  1747. for (var i = 0, n = this.tracks.length; i < n; i++) {
  1748. var current = this.tracks[i];
  1749. if (current != null)
  1750. this.setEmptyAnimation(current.trackIndex, mixDuration);
  1751. }
  1752. this.queue.drainDisabled = oldDrainDisabled;
  1753. this.queue.drain();
  1754. };
  1755. AnimationState.prototype.expandToIndex = function (index) {
  1756. if (index < this.tracks.length)
  1757. return this.tracks[index];
  1758. spine.Utils.ensureArrayCapacity(this.tracks, index + 1, null);
  1759. this.tracks.length = index + 1;
  1760. return null;
  1761. };
  1762. AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) {
  1763. var entry = this.trackEntryPool.obtain();
  1764. entry.trackIndex = trackIndex;
  1765. entry.animation = animation;
  1766. entry.loop = loop;
  1767. entry.holdPrevious = false;
  1768. entry.eventThreshold = 0;
  1769. entry.attachmentThreshold = 0;
  1770. entry.drawOrderThreshold = 0;
  1771. entry.animationStart = 0;
  1772. entry.animationEnd = animation.duration;
  1773. entry.animationLast = -1;
  1774. entry.nextAnimationLast = -1;
  1775. entry.delay = 0;
  1776. entry.trackTime = 0;
  1777. entry.trackLast = -1;
  1778. entry.nextTrackLast = -1;
  1779. entry.trackEnd = Number.MAX_VALUE;
  1780. entry.timeScale = 1;
  1781. entry.alpha = 1;
  1782. entry.interruptAlpha = 1;
  1783. entry.mixTime = 0;
  1784. entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation);
  1785. return entry;
  1786. };
  1787. AnimationState.prototype.disposeNext = function (entry) {
  1788. var next = entry.next;
  1789. while (next != null) {
  1790. this.queue.dispose(next);
  1791. next = next.next;
  1792. }
  1793. entry.next = null;
  1794. };
  1795. AnimationState.prototype._animationsChanged = function () {
  1796. this.animationsChanged = false;
  1797. this.propertyIDs.clear();
  1798. for (var i = 0, n = this.tracks.length; i < n; i++) {
  1799. var entry = this.tracks[i];
  1800. if (entry == null)
  1801. continue;
  1802. while (entry.mixingFrom != null)
  1803. entry = entry.mixingFrom;
  1804. do {
  1805. if (entry.mixingFrom == null || entry.mixBlend != spine.MixBlend.add)
  1806. this.setTimelineModes(entry);
  1807. entry = entry.mixingTo;
  1808. } while (entry != null);
  1809. }
  1810. };
  1811. AnimationState.prototype.setTimelineModes = function (entry) {
  1812. var to = entry.mixingTo;
  1813. var timelines = entry.animation.timelines;
  1814. var timelinesCount = entry.animation.timelines.length;
  1815. var timelineMode = spine.Utils.setArraySize(entry.timelineMode, timelinesCount);
  1816. entry.timelineHoldMix.length = 0;
  1817. var timelineDipMix = spine.Utils.setArraySize(entry.timelineHoldMix, timelinesCount);
  1818. var propertyIDs = this.propertyIDs;
  1819. if (to != null && to.holdPrevious) {
  1820. for (var i = 0; i < timelinesCount; i++) {
  1821. propertyIDs.add(timelines[i].getPropertyId());
  1822. timelineMode[i] = AnimationState.HOLD;
  1823. }
  1824. return;
  1825. }
  1826. outer: for (var i = 0; i < timelinesCount; i++) {
  1827. var id = timelines[i].getPropertyId();
  1828. if (!propertyIDs.add(id))
  1829. timelineMode[i] = AnimationState.SUBSEQUENT;
  1830. else if (to == null || !this.hasTimeline(to, id))
  1831. timelineMode[i] = AnimationState.FIRST;
  1832. else {
  1833. for (var next = to.mixingTo; next != null; next = next.mixingTo) {
  1834. if (this.hasTimeline(next, id))
  1835. continue;
  1836. if (entry.mixDuration > 0) {
  1837. timelineMode[i] = AnimationState.HOLD_MIX;
  1838. timelineDipMix[i] = next;
  1839. continue outer;
  1840. }
  1841. break;
  1842. }
  1843. timelineMode[i] = AnimationState.HOLD;
  1844. }
  1845. }
  1846. };
  1847. AnimationState.prototype.hasTimeline = function (entry, id) {
  1848. var timelines = entry.animation.timelines;
  1849. for (var i = 0, n = timelines.length; i < n; i++)
  1850. if (timelines[i].getPropertyId() == id)
  1851. return true;
  1852. return false;
  1853. };
  1854. AnimationState.prototype.getCurrent = function (trackIndex) {
  1855. if (trackIndex >= this.tracks.length)
  1856. return null;
  1857. return this.tracks[trackIndex];
  1858. };
  1859. AnimationState.prototype.addListener = function (listener) {
  1860. if (listener == null)
  1861. throw new Error("listener cannot be null.");
  1862. this.listeners.push(listener);
  1863. };
  1864. AnimationState.prototype.removeListener = function (listener) {
  1865. var index = this.listeners.indexOf(listener);
  1866. if (index >= 0)
  1867. this.listeners.splice(index, 1);
  1868. };
  1869. AnimationState.prototype.clearListeners = function () {
  1870. this.listeners.length = 0;
  1871. };
  1872. AnimationState.prototype.clearListenerNotifications = function () {
  1873. this.queue.clear();
  1874. };
  1875. AnimationState.emptyAnimation = new spine.Animation("<empty>", [], 0);
  1876. AnimationState.SUBSEQUENT = 0;
  1877. AnimationState.FIRST = 1;
  1878. AnimationState.HOLD = 2;
  1879. AnimationState.HOLD_MIX = 3;
  1880. return AnimationState;
  1881. }());
  1882. spine.AnimationState = AnimationState;
  1883. var TrackEntry = (function () {
  1884. function TrackEntry() {
  1885. this.mixBlend = spine.MixBlend.replace;
  1886. this.timelineMode = new Array();
  1887. this.timelineHoldMix = new Array();
  1888. this.timelinesRotation = new Array();
  1889. }
  1890. TrackEntry.prototype.reset = function () {
  1891. this.next = null;
  1892. this.mixingFrom = null;
  1893. this.mixingTo = null;
  1894. this.animation = null;
  1895. this.listener = null;
  1896. this.timelineMode.length = 0;
  1897. this.timelineHoldMix.length = 0;
  1898. this.timelinesRotation.length = 0;
  1899. };
  1900. TrackEntry.prototype.getAnimationTime = function () {
  1901. if (this.loop) {
  1902. var duration = this.animationEnd - this.animationStart;
  1903. if (duration == 0)
  1904. return this.animationStart;
  1905. return (this.trackTime % duration) + this.animationStart;
  1906. }
  1907. return Math.min(this.trackTime + this.animationStart, this.animationEnd);
  1908. };
  1909. TrackEntry.prototype.setAnimationLast = function (animationLast) {
  1910. this.animationLast = animationLast;
  1911. this.nextAnimationLast = animationLast;
  1912. };
  1913. TrackEntry.prototype.isComplete = function () {
  1914. return this.trackTime >= this.animationEnd - this.animationStart;
  1915. };
  1916. TrackEntry.prototype.resetRotationDirections = function () {
  1917. this.timelinesRotation.length = 0;
  1918. };
  1919. return TrackEntry;
  1920. }());
  1921. spine.TrackEntry = TrackEntry;
  1922. var EventQueue = (function () {
  1923. function EventQueue(animState) {
  1924. this.objects = [];
  1925. this.drainDisabled = false;
  1926. this.animState = animState;
  1927. }
  1928. EventQueue.prototype.start = function (entry) {
  1929. this.objects.push(EventType.start);
  1930. this.objects.push(entry);
  1931. this.animState.animationsChanged = true;
  1932. };
  1933. EventQueue.prototype.interrupt = function (entry) {
  1934. this.objects.push(EventType.interrupt);
  1935. this.objects.push(entry);
  1936. };
  1937. EventQueue.prototype.end = function (entry) {
  1938. this.objects.push(EventType.end);
  1939. this.objects.push(entry);
  1940. this.animState.animationsChanged = true;
  1941. };
  1942. EventQueue.prototype.dispose = function (entry) {
  1943. this.objects.push(EventType.dispose);
  1944. this.objects.push(entry);
  1945. };
  1946. EventQueue.prototype.complete = function (entry) {
  1947. this.objects.push(EventType.complete);
  1948. this.objects.push(entry);
  1949. };
  1950. EventQueue.prototype.event = function (entry, event) {
  1951. this.objects.push(EventType.event);
  1952. this.objects.push(entry);
  1953. this.objects.push(event);
  1954. };
  1955. EventQueue.prototype.drain = function () {
  1956. if (this.drainDisabled)
  1957. return;
  1958. this.drainDisabled = true;
  1959. var objects = this.objects;
  1960. var listeners = this.animState.listeners;
  1961. for (var i = 0; i < objects.length; i += 2) {
  1962. var type = objects[i];
  1963. var entry = objects[i + 1];
  1964. switch (type) {
  1965. case EventType.start:
  1966. if (entry.listener != null && entry.listener.start)
  1967. entry.listener.start(entry);
  1968. for (var ii = 0; ii < listeners.length; ii++)
  1969. if (listeners[ii].start)
  1970. listeners[ii].start(entry);
  1971. break;
  1972. case EventType.interrupt:
  1973. if (entry.listener != null && entry.listener.interrupt)
  1974. entry.listener.interrupt(entry);
  1975. for (var ii = 0; ii < listeners.length; ii++)
  1976. if (listeners[ii].interrupt)
  1977. listeners[ii].interrupt(entry);
  1978. break;
  1979. case EventType.end:
  1980. if (entry.listener != null && entry.listener.end)
  1981. entry.listener.end(entry);
  1982. for (var ii = 0; ii < listeners.length; ii++)
  1983. if (listeners[ii].end)
  1984. listeners[ii].end(entry);
  1985. case EventType.dispose:
  1986. if (entry.listener != null && entry.listener.dispose)
  1987. entry.listener.dispose(entry);
  1988. for (var ii = 0; ii < listeners.length; ii++)
  1989. if (listeners[ii].dispose)
  1990. listeners[ii].dispose(entry);
  1991. this.animState.trackEntryPool.free(entry);
  1992. break;
  1993. case EventType.complete:
  1994. if (entry.listener != null && entry.listener.complete)
  1995. entry.listener.complete(entry);
  1996. for (var ii = 0; ii < listeners.length; ii++)
  1997. if (listeners[ii].complete)
  1998. listeners[ii].complete(entry);
  1999. break;
  2000. case EventType.event:
  2001. var event_3 = objects[i++ + 2];
  2002. if (entry.listener != null && entry.listener.event)
  2003. entry.listener.event(entry, event_3);
  2004. for (var ii = 0; ii < listeners.length; ii++)
  2005. if (listeners[ii].event)
  2006. listeners[ii].event(entry, event_3);
  2007. break;
  2008. }
  2009. }
  2010. this.clear();
  2011. this.drainDisabled = false;
  2012. };
  2013. EventQueue.prototype.clear = function () {
  2014. this.objects.length = 0;
  2015. };
  2016. return EventQueue;
  2017. }());
  2018. spine.EventQueue = EventQueue;
  2019. var EventType;
  2020. (function (EventType) {
  2021. EventType[EventType["start"] = 0] = "start";
  2022. EventType[EventType["interrupt"] = 1] = "interrupt";
  2023. EventType[EventType["end"] = 2] = "end";
  2024. EventType[EventType["dispose"] = 3] = "dispose";
  2025. EventType[EventType["complete"] = 4] = "complete";
  2026. EventType[EventType["event"] = 5] = "event";
  2027. })(EventType = spine.EventType || (spine.EventType = {}));
  2028. var AnimationStateAdapter2 = (function () {
  2029. function AnimationStateAdapter2() {
  2030. }
  2031. AnimationStateAdapter2.prototype.start = function (entry) {
  2032. };
  2033. AnimationStateAdapter2.prototype.interrupt = function (entry) {
  2034. };
  2035. AnimationStateAdapter2.prototype.end = function (entry) {
  2036. };
  2037. AnimationStateAdapter2.prototype.dispose = function (entry) {
  2038. };
  2039. AnimationStateAdapter2.prototype.complete = function (entry) {
  2040. };
  2041. AnimationStateAdapter2.prototype.event = function (entry, event) {
  2042. };
  2043. return AnimationStateAdapter2;
  2044. }());
  2045. spine.AnimationStateAdapter2 = AnimationStateAdapter2;
  2046. })(spine || (spine = {}));
  2047. var spine;
  2048. (function (spine) {
  2049. var AnimationStateData = (function () {
  2050. function AnimationStateData(skeletonData) {
  2051. this.animationToMixTime = {};
  2052. this.defaultMix = 0;
  2053. if (skeletonData == null)
  2054. throw new Error("skeletonData cannot be null.");
  2055. this.skeletonData = skeletonData;
  2056. }
  2057. AnimationStateData.prototype.setMix = function (fromName, toName, duration) {
  2058. var from = this.skeletonData.findAnimation(fromName);
  2059. if (from == null)
  2060. throw new Error("Animation not found: " + fromName);
  2061. var to = this.skeletonData.findAnimation(toName);
  2062. if (to == null)
  2063. throw new Error("Animation not found: " + toName);
  2064. this.setMixWith(from, to, duration);
  2065. };
  2066. AnimationStateData.prototype.setMixWith = function (from, to, duration) {
  2067. if (from == null)
  2068. throw new Error("from cannot be null.");
  2069. if (to == null)
  2070. throw new Error("to cannot be null.");
  2071. var key = from.name + "." + to.name;
  2072. this.animationToMixTime[key] = duration;
  2073. };
  2074. AnimationStateData.prototype.getMix = function (from, to) {
  2075. var key = from.name + "." + to.name;
  2076. var value = this.animationToMixTime[key];
  2077. return value === undefined ? this.defaultMix : value;
  2078. };
  2079. return AnimationStateData;
  2080. }());
  2081. spine.AnimationStateData = AnimationStateData;
  2082. })(spine || (spine = {}));
  2083. var spine;
  2084. (function (spine) {
  2085. var AssetManager = (function () {
  2086. function AssetManager(textureLoader, pathPrefix) {
  2087. if (pathPrefix === void 0) { pathPrefix = ""; }
  2088. this.assets = {};
  2089. this.errors = {};
  2090. this.toLoad = 0;
  2091. this.loaded = 0;
  2092. this.textureLoader = textureLoader;
  2093. this.pathPrefix = pathPrefix;
  2094. }
  2095. AssetManager.downloadText = function (url, success, error) {
  2096. var request = new XMLHttpRequest();
  2097. request.open("GET", url, true);
  2098. request.onload = function () {
  2099. if (request.status == 200) {
  2100. success(request.responseText);
  2101. }
  2102. else {
  2103. error(request.status, request.responseText);
  2104. }
  2105. };
  2106. request.onerror = function () {
  2107. error(request.status, request.responseText);
  2108. };
  2109. request.send();
  2110. };
  2111. AssetManager.downloadBinary = function (url, success, error) {
  2112. var request = new XMLHttpRequest();
  2113. request.open("GET", url, true);
  2114. request.responseType = "arraybuffer";
  2115. request.onload = function () {
  2116. if (request.status == 200) {
  2117. success(new Uint8Array(request.response));
  2118. }
  2119. else {
  2120. error(request.status, request.responseText);
  2121. }
  2122. };
  2123. request.onerror = function () {
  2124. error(request.status, request.responseText);
  2125. };
  2126. request.send();
  2127. };
  2128. AssetManager.prototype.loadText = function (path, success, error) {
  2129. var _this = this;
  2130. if (success === void 0) { success = null; }
  2131. if (error === void 0) { error = null; }
  2132. path = this.pathPrefix + path;
  2133. this.toLoad++;
  2134. AssetManager.downloadText(path, function (data) {
  2135. _this.assets[path] = data;
  2136. if (success)
  2137. success(path, data);
  2138. _this.toLoad--;
  2139. _this.loaded++;
  2140. }, function (state, responseText) {
  2141. _this.errors[path] = "Couldn't load text " + path + ": status " + status + ", " + responseText;
  2142. if (error)
  2143. error(path, "Couldn't load text " + path + ": status " + status + ", " + responseText);
  2144. _this.toLoad--;
  2145. _this.loaded++;
  2146. });
  2147. };
  2148. AssetManager.prototype.loadTexture = function (path, success, error) {
  2149. var _this = this;
  2150. if (success === void 0) { success = null; }
  2151. if (error === void 0) { error = null; }
  2152. path = this.pathPrefix + path;
  2153. this.toLoad++;
  2154. var img = new Image();
  2155. img.crossOrigin = "anonymous";
  2156. img.onload = function (ev) {
  2157. var texture = _this.textureLoader(img);
  2158. _this.assets[path] = texture;
  2159. _this.toLoad--;
  2160. _this.loaded++;
  2161. if (success)
  2162. success(path, img);
  2163. };
  2164. img.onerror = function (ev) {
  2165. _this.errors[path] = "Couldn't load image " + path;
  2166. _this.toLoad--;
  2167. _this.loaded++;
  2168. if (error)
  2169. error(path, "Couldn't load image " + path);
  2170. };
  2171. img.src = path;
  2172. };
  2173. AssetManager.prototype.loadTextureData = function (path, data, success, error) {
  2174. var _this = this;
  2175. if (success === void 0) { success = null; }
  2176. if (error === void 0) { error = null; }
  2177. path = this.pathPrefix + path;
  2178. this.toLoad++;
  2179. var img = new Image();
  2180. img.onload = function (ev) {
  2181. var texture = _this.textureLoader(img);
  2182. _this.assets[path] = texture;
  2183. _this.toLoad--;
  2184. _this.loaded++;
  2185. if (success)
  2186. success(path, img);
  2187. };
  2188. img.onerror = function (ev) {
  2189. _this.errors[path] = "Couldn't load image " + path;
  2190. _this.toLoad--;
  2191. _this.loaded++;
  2192. if (error)
  2193. error(path, "Couldn't load image " + path);
  2194. };
  2195. img.src = data;
  2196. };
  2197. AssetManager.prototype.loadTextureAtlas = function (path, success, error) {
  2198. var _this = this;
  2199. if (success === void 0) { success = null; }
  2200. if (error === void 0) { error = null; }
  2201. var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
  2202. path = this.pathPrefix + path;
  2203. this.toLoad++;
  2204. AssetManager.downloadText(path, function (atlasData) {
  2205. var pagesLoaded = { count: 0 };
  2206. var atlasPages = new Array();
  2207. try {
  2208. var atlas = new spine.TextureAtlas(atlasData, function (path) {
  2209. atlasPages.push(parent + "/" + path);
  2210. var image = document.createElement("img");
  2211. image.width = 16;
  2212. image.height = 16;
  2213. return new spine.FakeTexture(image);
  2214. });
  2215. }
  2216. catch (e) {
  2217. var ex = e;
  2218. _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message;
  2219. if (error)
  2220. error(path, "Couldn't load texture atlas " + path + ": " + ex.message);
  2221. _this.toLoad--;
  2222. _this.loaded++;
  2223. return;
  2224. }
  2225. var _loop_1 = function (atlasPage) {
  2226. var pageLoadError = false;
  2227. _this.loadTexture(atlasPage, function (imagePath, image) {
  2228. pagesLoaded.count++;
  2229. if (pagesLoaded.count == atlasPages.length) {
  2230. if (!pageLoadError) {
  2231. try {
  2232. var atlas = new spine.TextureAtlas(atlasData, function (path) {
  2233. return _this.get(parent + "/" + path);
  2234. });
  2235. _this.assets[path] = atlas;
  2236. if (success)
  2237. success(path, atlas);
  2238. _this.toLoad--;
  2239. _this.loaded++;
  2240. }
  2241. catch (e) {
  2242. var ex = e;
  2243. _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message;
  2244. if (error)
  2245. error(path, "Couldn't load texture atlas " + path + ": " + ex.message);
  2246. _this.toLoad--;
  2247. _this.loaded++;
  2248. }
  2249. }
  2250. else {
  2251. _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path;
  2252. if (error)
  2253. error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path);
  2254. _this.toLoad--;
  2255. _this.loaded++;
  2256. }
  2257. }
  2258. }, function (imagePath, errorMessage) {
  2259. pageLoadError = true;
  2260. pagesLoaded.count++;
  2261. if (pagesLoaded.count == atlasPages.length) {
  2262. _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path;
  2263. if (error)
  2264. error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path);
  2265. _this.toLoad--;
  2266. _this.loaded++;
  2267. }
  2268. });
  2269. };
  2270. for (var _i = 0, atlasPages_1 = atlasPages; _i < atlasPages_1.length; _i++) {
  2271. var atlasPage = atlasPages_1[_i];
  2272. _loop_1(atlasPage);
  2273. }
  2274. }, function (state, responseText) {
  2275. _this.errors[path] = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
  2276. if (error)
  2277. error(path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText);
  2278. _this.toLoad--;
  2279. _this.loaded++;
  2280. });
  2281. };
  2282. AssetManager.prototype.get = function (path) {
  2283. path = this.pathPrefix + path;
  2284. return this.assets[path];
  2285. };
  2286. AssetManager.prototype.remove = function (path) {
  2287. path = this.pathPrefix + path;
  2288. var asset = this.assets[path];
  2289. if (asset.dispose)
  2290. asset.dispose();
  2291. this.assets[path] = null;
  2292. };
  2293. AssetManager.prototype.removeAll = function () {
  2294. for (var key in this.assets) {
  2295. var asset = this.assets[key];
  2296. if (asset.dispose)
  2297. asset.dispose();
  2298. }
  2299. this.assets = {};
  2300. };
  2301. AssetManager.prototype.isLoadingComplete = function () {
  2302. return this.toLoad == 0;
  2303. };
  2304. AssetManager.prototype.getToLoad = function () {
  2305. return this.toLoad;
  2306. };
  2307. AssetManager.prototype.getLoaded = function () {
  2308. return this.loaded;
  2309. };
  2310. AssetManager.prototype.dispose = function () {
  2311. this.removeAll();
  2312. };
  2313. AssetManager.prototype.hasErrors = function () {
  2314. return Object.keys(this.errors).length > 0;
  2315. };
  2316. AssetManager.prototype.getErrors = function () {
  2317. return this.errors;
  2318. };
  2319. return AssetManager;
  2320. }());
  2321. spine.AssetManager = AssetManager;
  2322. })(spine || (spine = {}));
  2323. var spine;
  2324. (function (spine) {
  2325. var AtlasAttachmentLoader = (function () {
  2326. function AtlasAttachmentLoader(atlas) {
  2327. this.atlas = atlas;
  2328. }
  2329. AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) {
  2330. var region = this.atlas.findRegion(path);
  2331. if (region == null)
  2332. // throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")");
  2333. return null;
  2334. region.renderObject = region;
  2335. var attachment = new spine.RegionAttachment(name);
  2336. attachment.setRegion(region);
  2337. return attachment;
  2338. };
  2339. AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) {
  2340. var region = this.atlas.findRegion(path);
  2341. if (region == null)
  2342. // throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
  2343. return null;
  2344. region.renderObject = region;
  2345. var attachment = new spine.MeshAttachment(name);
  2346. attachment.region = region;
  2347. return attachment;
  2348. };
  2349. AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) {
  2350. return new spine.BoundingBoxAttachment(name);
  2351. };
  2352. AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) {
  2353. return new spine.PathAttachment(name);
  2354. };
  2355. AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) {
  2356. return new spine.PointAttachment(name);
  2357. };
  2358. AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) {
  2359. return new spine.ClippingAttachment(name);
  2360. };
  2361. return AtlasAttachmentLoader;
  2362. }());
  2363. spine.AtlasAttachmentLoader = AtlasAttachmentLoader;
  2364. })(spine || (spine = {}));
  2365. var spine;
  2366. (function (spine) {
  2367. var BlendMode;
  2368. (function (BlendMode) {
  2369. BlendMode[BlendMode["Normal"] = 0] = "Normal";
  2370. BlendMode[BlendMode["Additive"] = 1] = "Additive";
  2371. BlendMode[BlendMode["Multiply"] = 2] = "Multiply";
  2372. BlendMode[BlendMode["Screen"] = 3] = "Screen";
  2373. })(BlendMode = spine.BlendMode || (spine.BlendMode = {}));
  2374. })(spine || (spine = {}));
  2375. var spine;
  2376. (function (spine) {
  2377. var Bone = (function () {
  2378. function Bone(data, skeleton, parent) {
  2379. this.children = new Array();
  2380. this.x = 0;
  2381. this.y = 0;
  2382. this.rotation = 0;
  2383. this.scaleX = 0;
  2384. this.scaleY = 0;
  2385. this.shearX = 0;
  2386. this.shearY = 0;
  2387. this.ax = 0;
  2388. this.ay = 0;
  2389. this.arotation = 0;
  2390. this.ascaleX = 0;
  2391. this.ascaleY = 0;
  2392. this.ashearX = 0;
  2393. this.ashearY = 0;
  2394. this.appliedValid = false;
  2395. this.a = 0;
  2396. this.b = 0;
  2397. this.worldX = 0;
  2398. this.c = 0;
  2399. this.d = 0;
  2400. this.worldY = 0;
  2401. this.sorted = false;
  2402. if (data == null)
  2403. throw new Error("data cannot be null.");
  2404. if (skeleton == null)
  2405. throw new Error("skeleton cannot be null.");
  2406. this.data = data;
  2407. this.skeleton = skeleton;
  2408. this.parent = parent;
  2409. this.setToSetupPose();
  2410. }
  2411. Bone.prototype.update = function () {
  2412. this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);
  2413. };
  2414. Bone.prototype.updateWorldTransform = function () {
  2415. this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);
  2416. };
  2417. Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) {
  2418. this.ax = x;
  2419. this.ay = y;
  2420. this.arotation = rotation;
  2421. this.ascaleX = scaleX;
  2422. this.ascaleY = scaleY;
  2423. this.ashearX = shearX;
  2424. this.ashearY = shearY;
  2425. this.appliedValid = true;
  2426. var parent = this.parent;
  2427. if (parent == null) {
  2428. var skeleton = this.skeleton;
  2429. var rotationY = rotation + 90 + shearY;
  2430. var sx = skeleton.scaleX;
  2431. var sy = skeleton.scaleY;
  2432. this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
  2433. this.b = spine.MathUtils.cosDeg(rotationY) * scaleY * sx;
  2434. this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX * sy;
  2435. this.d = spine.MathUtils.sinDeg(rotationY) * scaleY * sy;
  2436. this.worldX = x * sx + skeleton.x;
  2437. this.worldY = y * sy + skeleton.y;
  2438. return;
  2439. }
  2440. var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
  2441. this.worldX = pa * x + pb * y + parent.worldX;
  2442. this.worldY = pc * x + pd * y + parent.worldY;
  2443. switch (this.data.transformMode) {
  2444. case spine.TransformMode.Normal: {
  2445. var rotationY = rotation + 90 + shearY;
  2446. var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;
  2447. var lb = spine.MathUtils.cosDeg(rotationY) * scaleY;
  2448. var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;
  2449. var ld = spine.MathUtils.sinDeg(rotationY) * scaleY;
  2450. this.a = pa * la + pb * lc;
  2451. this.b = pa * lb + pb * ld;
  2452. this.c = pc * la + pd * lc;
  2453. this.d = pc * lb + pd * ld;
  2454. return;
  2455. }
  2456. case spine.TransformMode.OnlyTranslation: {
  2457. var rotationY = rotation + 90 + shearY;
  2458. this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;
  2459. this.b = spine.MathUtils.cosDeg(rotationY) * scaleY;
  2460. this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;
  2461. this.d = spine.MathUtils.sinDeg(rotationY) * scaleY;
  2462. break;
  2463. }
  2464. case spine.TransformMode.NoRotationOrReflection: {
  2465. var s = pa * pa + pc * pc;
  2466. var prx = 0;
  2467. if (s > 0.0001) {
  2468. s = Math.abs(pa * pd - pb * pc) / s;
  2469. pb = pc * s;
  2470. pd = pa * s;
  2471. prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
  2472. }
  2473. else {
  2474. pa = 0;
  2475. pc = 0;
  2476. prx = 90 - Math.atan2(pd, pb) * spine.MathUtils.radDeg;
  2477. }
  2478. var rx = rotation + shearX - prx;
  2479. var ry = rotation + shearY - prx + 90;
  2480. var la = spine.MathUtils.cosDeg(rx) * scaleX;
  2481. var lb = spine.MathUtils.cosDeg(ry) * scaleY;
  2482. var lc = spine.MathUtils.sinDeg(rx) * scaleX;
  2483. var ld = spine.MathUtils.sinDeg(ry) * scaleY;
  2484. this.a = pa * la - pb * lc;
  2485. this.b = pa * lb - pb * ld;
  2486. this.c = pc * la + pd * lc;
  2487. this.d = pc * lb + pd * ld;
  2488. break;
  2489. }
  2490. case spine.TransformMode.NoScale:
  2491. case spine.TransformMode.NoScaleOrReflection: {
  2492. var cos = spine.MathUtils.cosDeg(rotation);
  2493. var sin = spine.MathUtils.sinDeg(rotation);
  2494. var za = (pa * cos + pb * sin) / this.skeleton.scaleX;
  2495. var zc = (pc * cos + pd * sin) / this.skeleton.scaleY;
  2496. var s = Math.sqrt(za * za + zc * zc);
  2497. if (s > 0.00001)
  2498. s = 1 / s;
  2499. za *= s;
  2500. zc *= s;
  2501. s = Math.sqrt(za * za + zc * zc);
  2502. if (this.data.transformMode == spine.TransformMode.NoScale
  2503. && (pa * pd - pb * pc < 0) != (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0))
  2504. s = -s;
  2505. var r = Math.PI / 2 + Math.atan2(zc, za);
  2506. var zb = Math.cos(r) * s;
  2507. var zd = Math.sin(r) * s;
  2508. var la = spine.MathUtils.cosDeg(shearX) * scaleX;
  2509. var lb = spine.MathUtils.cosDeg(90 + shearY) * scaleY;
  2510. var lc = spine.MathUtils.sinDeg(shearX) * scaleX;
  2511. var ld = spine.MathUtils.sinDeg(90 + shearY) * scaleY;
  2512. this.a = za * la + zb * lc;
  2513. this.b = za * lb + zb * ld;
  2514. this.c = zc * la + zd * lc;
  2515. this.d = zc * lb + zd * ld;
  2516. break;
  2517. }
  2518. }
  2519. this.a *= this.skeleton.scaleX;
  2520. this.b *= this.skeleton.scaleX;
  2521. this.c *= this.skeleton.scaleY;
  2522. this.d *= this.skeleton.scaleY;
  2523. };
  2524. Bone.prototype.setToSetupPose = function () {
  2525. var data = this.data;
  2526. this.x = data.x;
  2527. this.y = data.y;
  2528. this.rotation = data.rotation;
  2529. this.scaleX = data.scaleX;
  2530. this.scaleY = data.scaleY;
  2531. this.shearX = data.shearX;
  2532. this.shearY = data.shearY;
  2533. };
  2534. Bone.prototype.getWorldRotationX = function () {
  2535. return Math.atan2(this.c, this.a) * spine.MathUtils.radDeg;
  2536. };
  2537. Bone.prototype.getWorldRotationY = function () {
  2538. return Math.atan2(this.d, this.b) * spine.MathUtils.radDeg;
  2539. };
  2540. Bone.prototype.getWorldScaleX = function () {
  2541. return Math.sqrt(this.a * this.a + this.c * this.c);
  2542. };
  2543. Bone.prototype.getWorldScaleY = function () {
  2544. return Math.sqrt(this.b * this.b + this.d * this.d);
  2545. };
  2546. Bone.prototype.updateAppliedTransform = function () {
  2547. this.appliedValid = true;
  2548. var parent = this.parent;
  2549. if (parent == null) {
  2550. this.ax = this.worldX;
  2551. this.ay = this.worldY;
  2552. this.arotation = Math.atan2(this.c, this.a) * spine.MathUtils.radDeg;
  2553. this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c);
  2554. this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d);
  2555. this.ashearX = 0;
  2556. this.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * spine.MathUtils.radDeg;
  2557. return;
  2558. }
  2559. var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
  2560. var pid = 1 / (pa * pd - pb * pc);
  2561. var dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY;
  2562. this.ax = (dx * pd * pid - dy * pb * pid);
  2563. this.ay = (dy * pa * pid - dx * pc * pid);
  2564. var ia = pid * pd;
  2565. var id = pid * pa;
  2566. var ib = pid * pb;
  2567. var ic = pid * pc;
  2568. var ra = ia * this.a - ib * this.c;
  2569. var rb = ia * this.b - ib * this.d;
  2570. var rc = id * this.c - ic * this.a;
  2571. var rd = id * this.d - ic * this.b;
  2572. this.ashearX = 0;
  2573. this.ascaleX = Math.sqrt(ra * ra + rc * rc);
  2574. if (this.ascaleX > 0.0001) {
  2575. var det = ra * rd - rb * rc;
  2576. this.ascaleY = det / this.ascaleX;
  2577. this.ashearY = Math.atan2(ra * rb + rc * rd, det) * spine.MathUtils.radDeg;
  2578. this.arotation = Math.atan2(rc, ra) * spine.MathUtils.radDeg;
  2579. }
  2580. else {
  2581. this.ascaleX = 0;
  2582. this.ascaleY = Math.sqrt(rb * rb + rd * rd);
  2583. this.ashearY = 0;
  2584. this.arotation = 90 - Math.atan2(rd, rb) * spine.MathUtils.radDeg;
  2585. }
  2586. };
  2587. Bone.prototype.worldToLocal = function (world) {
  2588. var a = this.a, b = this.b, c = this.c, d = this.d;
  2589. var invDet = 1 / (a * d - b * c);
  2590. var x = world.x - this.worldX, y = world.y - this.worldY;
  2591. world.x = (x * d * invDet - y * b * invDet);
  2592. world.y = (y * a * invDet - x * c * invDet);
  2593. return world;
  2594. };
  2595. Bone.prototype.localToWorld = function (local) {
  2596. var x = local.x, y = local.y;
  2597. local.x = x * this.a + y * this.b + this.worldX;
  2598. local.y = x * this.c + y * this.d + this.worldY;
  2599. return local;
  2600. };
  2601. Bone.prototype.worldToLocalRotation = function (worldRotation) {
  2602. var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
  2603. return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
  2604. };
  2605. Bone.prototype.localToWorldRotation = function (localRotation) {
  2606. localRotation -= this.rotation - this.shearX;
  2607. var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
  2608. return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
  2609. };
  2610. Bone.prototype.rotateWorld = function (degrees) {
  2611. var a = this.a, b = this.b, c = this.c, d = this.d;
  2612. var cos = spine.MathUtils.cosDeg(degrees), sin = spine.MathUtils.sinDeg(degrees);
  2613. this.a = cos * a - sin * c;
  2614. this.b = cos * b - sin * d;
  2615. this.c = sin * a + cos * c;
  2616. this.d = sin * b + cos * d;
  2617. this.appliedValid = false;
  2618. };
  2619. return Bone;
  2620. }());
  2621. spine.Bone = Bone;
  2622. })(spine || (spine = {}));
  2623. var spine;
  2624. (function (spine) {
  2625. var BoneData = (function () {
  2626. function BoneData(index, name, parent) {
  2627. this.x = 0;
  2628. this.y = 0;
  2629. this.rotation = 0;
  2630. this.scaleX = 1;
  2631. this.scaleY = 1;
  2632. this.shearX = 0;
  2633. this.shearY = 0;
  2634. this.transformMode = TransformMode.Normal;
  2635. if (index < 0)
  2636. throw new Error("index must be >= 0.");
  2637. if (name == null)
  2638. throw new Error("name cannot be null.");
  2639. this.index = index;
  2640. this.name = name;
  2641. this.parent = parent;
  2642. }
  2643. return BoneData;
  2644. }());
  2645. spine.BoneData = BoneData;
  2646. var TransformMode;
  2647. (function (TransformMode) {
  2648. TransformMode[TransformMode["Normal"] = 0] = "Normal";
  2649. TransformMode[TransformMode["OnlyTranslation"] = 1] = "OnlyTranslation";
  2650. TransformMode[TransformMode["NoRotationOrReflection"] = 2] = "NoRotationOrReflection";
  2651. TransformMode[TransformMode["NoScale"] = 3] = "NoScale";
  2652. TransformMode[TransformMode["NoScaleOrReflection"] = 4] = "NoScaleOrReflection";
  2653. })(TransformMode = spine.TransformMode || (spine.TransformMode = {}));
  2654. })(spine || (spine = {}));
  2655. var spine;
  2656. (function (spine) {
  2657. var Event = (function () {
  2658. function Event(time, data) {
  2659. if (data == null)
  2660. throw new Error("data cannot be null.");
  2661. this.time = time;
  2662. this.data = data;
  2663. }
  2664. return Event;
  2665. }());
  2666. spine.Event = Event;
  2667. })(spine || (spine = {}));
  2668. var spine;
  2669. (function (spine) {
  2670. var EventData = (function () {
  2671. function EventData(name) {
  2672. this.name = name;
  2673. }
  2674. return EventData;
  2675. }());
  2676. spine.EventData = EventData;
  2677. })(spine || (spine = {}));
  2678. var spine;
  2679. (function (spine) {
  2680. var IkConstraint = (function () {
  2681. function IkConstraint(data, skeleton) {
  2682. this.bendDirection = 0;
  2683. this.compress = false;
  2684. this.stretch = false;
  2685. this.mix = 1;
  2686. if (data == null)
  2687. throw new Error("data cannot be null.");
  2688. if (skeleton == null)
  2689. throw new Error("skeleton cannot be null.");
  2690. this.data = data;
  2691. this.mix = data.mix;
  2692. this.bendDirection = data.bendDirection;
  2693. this.compress = data.compress;
  2694. this.stretch = data.stretch;
  2695. this.bones = new Array();
  2696. for (var i = 0; i < data.bones.length; i++)
  2697. this.bones.push(skeleton.findBone(data.bones[i].name));
  2698. this.target = skeleton.findBone(data.target.name);
  2699. }
  2700. IkConstraint.prototype.getOrder = function () {
  2701. return this.data.order;
  2702. };
  2703. IkConstraint.prototype.apply = function () {
  2704. this.update();
  2705. };
  2706. IkConstraint.prototype.update = function () {
  2707. var target = this.target;
  2708. var bones = this.bones;
  2709. switch (bones.length) {
  2710. case 1:
  2711. this.apply1(bones[0], target.worldX, target.worldY, this.compress, this.stretch, this.data.uniform, this.mix);
  2712. break;
  2713. case 2:
  2714. this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.stretch, this.mix);
  2715. break;
  2716. }
  2717. };
  2718. IkConstraint.prototype.apply1 = function (bone, targetX, targetY, compress, stretch, uniform, alpha) {
  2719. if (!bone.appliedValid)
  2720. bone.updateAppliedTransform();
  2721. var p = bone.parent;
  2722. var id = 1 / (p.a * p.d - p.b * p.c);
  2723. var x = targetX - p.worldX, y = targetY - p.worldY;
  2724. var tx = (x * p.d - y * p.b) * id - bone.ax, ty = (y * p.a - x * p.c) * id - bone.ay;
  2725. var rotationIK = Math.atan2(ty, tx) * spine.MathUtils.radDeg - bone.ashearX - bone.arotation;
  2726. if (bone.ascaleX < 0)
  2727. rotationIK += 180;
  2728. if (rotationIK > 180)
  2729. rotationIK -= 360;
  2730. else if (rotationIK < -180)
  2731. rotationIK += 360;
  2732. var sx = bone.ascaleX, sy = bone.ascaleY;
  2733. if (compress || stretch) {
  2734. var b = bone.data.length * sx, dd = Math.sqrt(tx * tx + ty * ty);
  2735. if ((compress && dd < b) || (stretch && dd > b) && b > 0.0001) {
  2736. var s = (dd / b - 1) * alpha + 1;
  2737. sx *= s;
  2738. if (uniform)
  2739. sy *= s;
  2740. }
  2741. }
  2742. bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, sx, sy, bone.ashearX, bone.ashearY);
  2743. };
  2744. IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, stretch, alpha) {
  2745. if (alpha == 0) {
  2746. child.updateWorldTransform();
  2747. return;
  2748. }
  2749. if (!parent.appliedValid)
  2750. parent.updateAppliedTransform();
  2751. if (!child.appliedValid)
  2752. child.updateAppliedTransform();
  2753. var px = parent.ax, py = parent.ay, psx = parent.ascaleX, sx = psx, psy = parent.ascaleY, csx = child.ascaleX;
  2754. var os1 = 0, os2 = 0, s2 = 0;
  2755. if (psx < 0) {
  2756. psx = -psx;
  2757. os1 = 180;
  2758. s2 = -1;
  2759. }
  2760. else {
  2761. os1 = 0;
  2762. s2 = 1;
  2763. }
  2764. if (psy < 0) {
  2765. psy = -psy;
  2766. s2 = -s2;
  2767. }
  2768. if (csx < 0) {
  2769. csx = -csx;
  2770. os2 = 180;
  2771. }
  2772. else
  2773. os2 = 0;
  2774. var cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d;
  2775. var u = Math.abs(psx - psy) <= 0.0001;
  2776. if (!u) {
  2777. cy = 0;
  2778. cwx = a * cx + parent.worldX;
  2779. cwy = c * cx + parent.worldY;
  2780. }
  2781. else {
  2782. cy = child.ay;
  2783. cwx = a * cx + b * cy + parent.worldX;
  2784. cwy = c * cx + d * cy + parent.worldY;
  2785. }
  2786. var pp = parent.parent;
  2787. a = pp.a;
  2788. b = pp.b;
  2789. c = pp.c;
  2790. d = pp.d;
  2791. var id = 1 / (a * d - b * c), x = targetX - pp.worldX, y = targetY - pp.worldY;
  2792. var tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py, dd = tx * tx + ty * ty;
  2793. x = cwx - pp.worldX;
  2794. y = cwy - pp.worldY;
  2795. var dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
  2796. var l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1 = 0, a2 = 0;
  2797. outer: if (u) {
  2798. l2 *= psx;
  2799. var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2);
  2800. if (cos < -1)
  2801. cos = -1;
  2802. else if (cos > 1) {
  2803. cos = 1;
  2804. if (stretch && l1 + l2 > 0.0001)
  2805. sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1;
  2806. }
  2807. a2 = Math.acos(cos) * bendDir;
  2808. a = l1 + l2 * cos;
  2809. b = l2 * Math.sin(a2);
  2810. a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b);
  2811. }
  2812. else {
  2813. a = psx * l2;
  2814. b = psy * l2;
  2815. var aa = a * a, bb = b * b, ta = Math.atan2(ty, tx);
  2816. c = bb * l1 * l1 + aa * dd - aa * bb;
  2817. var c1 = -2 * bb * l1, c2 = bb - aa;
  2818. d = c1 * c1 - 4 * c2 * c;
  2819. if (d >= 0) {
  2820. var q = Math.sqrt(d);
  2821. if (c1 < 0)
  2822. q = -q;
  2823. q = -(c1 + q) / 2;
  2824. var r0 = q / c2, r1 = c / q;
  2825. var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
  2826. if (r * r <= dd) {
  2827. y = Math.sqrt(dd - r * r) * bendDir;
  2828. a1 = ta - Math.atan2(y, r);
  2829. a2 = Math.atan2(y / psy, (r - l1) / psx);
  2830. break outer;
  2831. }
  2832. }
  2833. var minAngle = spine.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0;
  2834. var maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0;
  2835. c = -a * l1 / (aa - bb);
  2836. if (c >= -1 && c <= 1) {
  2837. c = Math.acos(c);
  2838. x = a * Math.cos(c) + l1;
  2839. y = b * Math.sin(c);
  2840. d = x * x + y * y;
  2841. if (d < minDist) {
  2842. minAngle = c;
  2843. minDist = d;
  2844. minX = x;
  2845. minY = y;
  2846. }
  2847. if (d > maxDist) {
  2848. maxAngle = c;
  2849. maxDist = d;
  2850. maxX = x;
  2851. maxY = y;
  2852. }
  2853. }
  2854. if (dd <= (minDist + maxDist) / 2) {
  2855. a1 = ta - Math.atan2(minY * bendDir, minX);
  2856. a2 = minAngle * bendDir;
  2857. }
  2858. else {
  2859. a1 = ta - Math.atan2(maxY * bendDir, maxX);
  2860. a2 = maxAngle * bendDir;
  2861. }
  2862. }
  2863. var os = Math.atan2(cy, cx) * s2;
  2864. var rotation = parent.arotation;
  2865. a1 = (a1 - os) * spine.MathUtils.radDeg + os1 - rotation;
  2866. if (a1 > 180)
  2867. a1 -= 360;
  2868. else if (a1 < -180)
  2869. a1 += 360;
  2870. parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0);
  2871. rotation = child.arotation;
  2872. a2 = ((a2 + os) * spine.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation;
  2873. if (a2 > 180)
  2874. a2 -= 360;
  2875. else if (a2 < -180)
  2876. a2 += 360;
  2877. child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY);
  2878. };
  2879. return IkConstraint;
  2880. }());
  2881. spine.IkConstraint = IkConstraint;
  2882. })(spine || (spine = {}));
  2883. var spine;
  2884. (function (spine) {
  2885. var IkConstraintData = (function () {
  2886. function IkConstraintData(name) {
  2887. this.order = 0;
  2888. this.bones = new Array();
  2889. this.bendDirection = 1;
  2890. this.compress = false;
  2891. this.stretch = false;
  2892. this.uniform = false;
  2893. this.mix = 1;
  2894. this.name = name;
  2895. }
  2896. return IkConstraintData;
  2897. }());
  2898. spine.IkConstraintData = IkConstraintData;
  2899. })(spine || (spine = {}));
  2900. var spine;
  2901. (function (spine) {
  2902. var PathConstraint = (function () {
  2903. function PathConstraint(data, skeleton) {
  2904. this.position = 0;
  2905. this.spacing = 0;
  2906. this.rotateMix = 0;
  2907. this.translateMix = 0;
  2908. this.spaces = new Array();
  2909. this.positions = new Array();
  2910. this.world = new Array();
  2911. this.curves = new Array();
  2912. this.lengths = new Array();
  2913. this.segments = new Array();
  2914. if (data == null)
  2915. throw new Error("data cannot be null.");
  2916. if (skeleton == null)
  2917. throw new Error("skeleton cannot be null.");
  2918. this.data = data;
  2919. this.bones = new Array();
  2920. for (var i = 0, n = data.bones.length; i < n; i++)
  2921. this.bones.push(skeleton.findBone(data.bones[i].name));
  2922. this.target = skeleton.findSlot(data.target.name);
  2923. this.position = data.position;
  2924. this.spacing = data.spacing;
  2925. this.rotateMix = data.rotateMix;
  2926. this.translateMix = data.translateMix;
  2927. }
  2928. PathConstraint.prototype.apply = function () {
  2929. this.update();
  2930. };
  2931. PathConstraint.prototype.update = function () {
  2932. var attachment = this.target.getAttachment();
  2933. if (!(attachment instanceof spine.PathAttachment))
  2934. return;
  2935. var rotateMix = this.rotateMix, translateMix = this.translateMix;
  2936. var translate = translateMix > 0, rotate = rotateMix > 0;
  2937. if (!translate && !rotate)
  2938. return;
  2939. var data = this.data;
  2940. var percentSpacing = data.spacingMode == spine.SpacingMode.Percent;
  2941. var rotateMode = data.rotateMode;
  2942. var tangents = rotateMode == spine.RotateMode.Tangent, scale = rotateMode == spine.RotateMode.ChainScale;
  2943. var boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1;
  2944. var bones = this.bones;
  2945. var spaces = spine.Utils.setArraySize(this.spaces, spacesCount), lengths = null;
  2946. var spacing = this.spacing;
  2947. if (scale || !percentSpacing) {
  2948. if (scale)
  2949. lengths = spine.Utils.setArraySize(this.lengths, boneCount);
  2950. var lengthSpacing = data.spacingMode == spine.SpacingMode.Length;
  2951. for (var i = 0, n = spacesCount - 1; i < n;) {
  2952. var bone = bones[i];
  2953. var setupLength = bone.data.length;
  2954. if (setupLength < PathConstraint.epsilon) {
  2955. if (scale)
  2956. lengths[i] = 0;
  2957. spaces[++i] = 0;
  2958. }
  2959. else if (percentSpacing) {
  2960. if (scale) {
  2961. var x = setupLength * bone.a, y = setupLength * bone.c;
  2962. var length_1 = Math.sqrt(x * x + y * y);
  2963. lengths[i] = length_1;
  2964. }
  2965. spaces[++i] = spacing;
  2966. }
  2967. else {
  2968. var x = setupLength * bone.a, y = setupLength * bone.c;
  2969. var length_2 = Math.sqrt(x * x + y * y);
  2970. if (scale)
  2971. lengths[i] = length_2;
  2972. spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_2 / setupLength;
  2973. }
  2974. }
  2975. }
  2976. else {
  2977. for (var i = 1; i < spacesCount; i++)
  2978. spaces[i] = spacing;
  2979. }
  2980. var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, percentSpacing);
  2981. var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
  2982. var tip = false;
  2983. if (offsetRotation == 0)
  2984. tip = rotateMode == spine.RotateMode.Chain;
  2985. else {
  2986. tip = false;
  2987. var p = this.target.bone;
  2988. offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  2989. }
  2990. for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
  2991. var bone = bones[i];
  2992. bone.worldX += (boneX - bone.worldX) * translateMix;
  2993. bone.worldY += (boneY - bone.worldY) * translateMix;
  2994. var x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY;
  2995. if (scale) {
  2996. var length_3 = lengths[i];
  2997. if (length_3 != 0) {
  2998. var s = (Math.sqrt(dx * dx + dy * dy) / length_3 - 1) * rotateMix + 1;
  2999. bone.a *= s;
  3000. bone.c *= s;
  3001. }
  3002. }
  3003. boneX = x;
  3004. boneY = y;
  3005. if (rotate) {
  3006. var a = bone.a, b = bone.b, c = bone.c, d = bone.d, r = 0, cos = 0, sin = 0;
  3007. if (tangents)
  3008. r = positions[p - 1];
  3009. else if (spaces[i + 1] == 0)
  3010. r = positions[p + 2];
  3011. else
  3012. r = Math.atan2(dy, dx);
  3013. r -= Math.atan2(c, a);
  3014. if (tip) {
  3015. cos = Math.cos(r);
  3016. sin = Math.sin(r);
  3017. var length_4 = bone.data.length;
  3018. boneX += (length_4 * (cos * a - sin * c) - dx) * rotateMix;
  3019. boneY += (length_4 * (sin * a + cos * c) - dy) * rotateMix;
  3020. }
  3021. else {
  3022. r += offsetRotation;
  3023. }
  3024. if (r > spine.MathUtils.PI)
  3025. r -= spine.MathUtils.PI2;
  3026. else if (r < -spine.MathUtils.PI)
  3027. r += spine.MathUtils.PI2;
  3028. r *= rotateMix;
  3029. cos = Math.cos(r);
  3030. sin = Math.sin(r);
  3031. bone.a = cos * a - sin * c;
  3032. bone.b = cos * b - sin * d;
  3033. bone.c = sin * a + cos * c;
  3034. bone.d = sin * b + cos * d;
  3035. }
  3036. bone.appliedValid = false;
  3037. }
  3038. };
  3039. PathConstraint.prototype.computeWorldPositions = function (path, spacesCount, tangents, percentPosition, percentSpacing) {
  3040. var target = this.target;
  3041. var position = this.position;
  3042. var spaces = this.spaces, out = spine.Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null;
  3043. var closed = path.closed;
  3044. var verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE;
  3045. if (!path.constantSpeed) {
  3046. var lengths = path.lengths;
  3047. curveCount -= closed ? 1 : 2;
  3048. var pathLength_1 = lengths[curveCount];
  3049. if (percentPosition)
  3050. position *= pathLength_1;
  3051. if (percentSpacing) {
  3052. for (var i = 1; i < spacesCount; i++)
  3053. spaces[i] *= pathLength_1;
  3054. }
  3055. world = spine.Utils.setArraySize(this.world, 8);
  3056. for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) {
  3057. var space = spaces[i];
  3058. position += space;
  3059. var p = position;
  3060. if (closed) {
  3061. p %= pathLength_1;
  3062. if (p < 0)
  3063. p += pathLength_1;
  3064. curve = 0;
  3065. }
  3066. else if (p < 0) {
  3067. if (prevCurve != PathConstraint.BEFORE) {
  3068. prevCurve = PathConstraint.BEFORE;
  3069. path.computeWorldVertices(target, 2, 4, world, 0, 2);
  3070. }
  3071. this.addBeforePosition(p, world, 0, out, o);
  3072. continue;
  3073. }
  3074. else if (p > pathLength_1) {
  3075. if (prevCurve != PathConstraint.AFTER) {
  3076. prevCurve = PathConstraint.AFTER;
  3077. path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2);
  3078. }
  3079. this.addAfterPosition(p - pathLength_1, world, 0, out, o);
  3080. continue;
  3081. }
  3082. for (;; curve++) {
  3083. var length_5 = lengths[curve];
  3084. if (p > length_5)
  3085. continue;
  3086. if (curve == 0)
  3087. p /= length_5;
  3088. else {
  3089. var prev = lengths[curve - 1];
  3090. p = (p - prev) / (length_5 - prev);
  3091. }
  3092. break;
  3093. }
  3094. if (curve != prevCurve) {
  3095. prevCurve = curve;
  3096. if (closed && curve == curveCount) {
  3097. path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2);
  3098. path.computeWorldVertices(target, 0, 4, world, 4, 2);
  3099. }
  3100. else
  3101. path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2);
  3102. }
  3103. 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));
  3104. }
  3105. return out;
  3106. }
  3107. if (closed) {
  3108. verticesLength += 2;
  3109. world = spine.Utils.setArraySize(this.world, verticesLength);
  3110. path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);
  3111. path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);
  3112. world[verticesLength - 2] = world[0];
  3113. world[verticesLength - 1] = world[1];
  3114. }
  3115. else {
  3116. curveCount--;
  3117. verticesLength -= 4;
  3118. world = spine.Utils.setArraySize(this.world, verticesLength);
  3119. path.computeWorldVertices(target, 2, verticesLength, world, 0, 2);
  3120. }
  3121. var curves = spine.Utils.setArraySize(this.curves, curveCount);
  3122. var pathLength = 0;
  3123. var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;
  3124. var tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0;
  3125. for (var i = 0, w = 2; i < curveCount; i++, w += 6) {
  3126. cx1 = world[w];
  3127. cy1 = world[w + 1];
  3128. cx2 = world[w + 2];
  3129. cy2 = world[w + 3];
  3130. x2 = world[w + 4];
  3131. y2 = world[w + 5];
  3132. tmpx = (x1 - cx1 * 2 + cx2) * 0.1875;
  3133. tmpy = (y1 - cy1 * 2 + cy2) * 0.1875;
  3134. dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375;
  3135. dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375;
  3136. ddfx = tmpx * 2 + dddfx;
  3137. ddfy = tmpy * 2 + dddfy;
  3138. dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667;
  3139. dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667;
  3140. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3141. dfx += ddfx;
  3142. dfy += ddfy;
  3143. ddfx += dddfx;
  3144. ddfy += dddfy;
  3145. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3146. dfx += ddfx;
  3147. dfy += ddfy;
  3148. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3149. dfx += ddfx + dddfx;
  3150. dfy += ddfy + dddfy;
  3151. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3152. curves[i] = pathLength;
  3153. x1 = x2;
  3154. y1 = y2;
  3155. }
  3156. if (percentPosition)
  3157. position *= pathLength;
  3158. else
  3159. position *= pathLength / path.lengths[curveCount - 1];
  3160. if (percentSpacing) {
  3161. for (var i = 1; i < spacesCount; i++)
  3162. spaces[i] *= pathLength;
  3163. }
  3164. var segments = this.segments;
  3165. var curveLength = 0;
  3166. for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) {
  3167. var space = spaces[i];
  3168. position += space;
  3169. var p = position;
  3170. if (closed) {
  3171. p %= pathLength;
  3172. if (p < 0)
  3173. p += pathLength;
  3174. curve = 0;
  3175. }
  3176. else if (p < 0) {
  3177. this.addBeforePosition(p, world, 0, out, o);
  3178. continue;
  3179. }
  3180. else if (p > pathLength) {
  3181. this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o);
  3182. continue;
  3183. }
  3184. for (;; curve++) {
  3185. var length_6 = curves[curve];
  3186. if (p > length_6)
  3187. continue;
  3188. if (curve == 0)
  3189. p /= length_6;
  3190. else {
  3191. var prev = curves[curve - 1];
  3192. p = (p - prev) / (length_6 - prev);
  3193. }
  3194. break;
  3195. }
  3196. if (curve != prevCurve) {
  3197. prevCurve = curve;
  3198. var ii = curve * 6;
  3199. x1 = world[ii];
  3200. y1 = world[ii + 1];
  3201. cx1 = world[ii + 2];
  3202. cy1 = world[ii + 3];
  3203. cx2 = world[ii + 4];
  3204. cy2 = world[ii + 5];
  3205. x2 = world[ii + 6];
  3206. y2 = world[ii + 7];
  3207. tmpx = (x1 - cx1 * 2 + cx2) * 0.03;
  3208. tmpy = (y1 - cy1 * 2 + cy2) * 0.03;
  3209. dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006;
  3210. dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006;
  3211. ddfx = tmpx * 2 + dddfx;
  3212. ddfy = tmpy * 2 + dddfy;
  3213. dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667;
  3214. dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667;
  3215. curveLength = Math.sqrt(dfx * dfx + dfy * dfy);
  3216. segments[0] = curveLength;
  3217. for (ii = 1; ii < 8; ii++) {
  3218. dfx += ddfx;
  3219. dfy += ddfy;
  3220. ddfx += dddfx;
  3221. ddfy += dddfy;
  3222. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3223. segments[ii] = curveLength;
  3224. }
  3225. dfx += ddfx;
  3226. dfy += ddfy;
  3227. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3228. segments[8] = curveLength;
  3229. dfx += ddfx + dddfx;
  3230. dfy += ddfy + dddfy;
  3231. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3232. segments[9] = curveLength;
  3233. segment = 0;
  3234. }
  3235. p *= curveLength;
  3236. for (;; segment++) {
  3237. var length_7 = segments[segment];
  3238. if (p > length_7)
  3239. continue;
  3240. if (segment == 0)
  3241. p /= length_7;
  3242. else {
  3243. var prev = segments[segment - 1];
  3244. p = segment + (p - prev) / (length_7 - prev);
  3245. }
  3246. break;
  3247. }
  3248. this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0));
  3249. }
  3250. return out;
  3251. };
  3252. PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) {
  3253. var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx);
  3254. out[o] = x1 + p * Math.cos(r);
  3255. out[o + 1] = y1 + p * Math.sin(r);
  3256. out[o + 2] = r;
  3257. };
  3258. PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) {
  3259. var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx);
  3260. out[o] = x1 + p * Math.cos(r);
  3261. out[o + 1] = y1 + p * Math.sin(r);
  3262. out[o + 2] = r;
  3263. };
  3264. PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) {
  3265. if (p == 0 || isNaN(p)) {
  3266. out[o] = x1;
  3267. out[o + 1] = y1;
  3268. out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1);
  3269. return;
  3270. }
  3271. var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;
  3272. var ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;
  3273. var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
  3274. out[o] = x;
  3275. out[o + 1] = y;
  3276. if (tangents) {
  3277. if (p < 0.001)
  3278. out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1);
  3279. else
  3280. out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
  3281. }
  3282. };
  3283. PathConstraint.prototype.getOrder = function () {
  3284. return this.data.order;
  3285. };
  3286. PathConstraint.NONE = -1;
  3287. PathConstraint.BEFORE = -2;
  3288. PathConstraint.AFTER = -3;
  3289. PathConstraint.epsilon = 0.00001;
  3290. return PathConstraint;
  3291. }());
  3292. spine.PathConstraint = PathConstraint;
  3293. })(spine || (spine = {}));
  3294. var spine;
  3295. (function (spine) {
  3296. var PathConstraintData = (function () {
  3297. function PathConstraintData(name) {
  3298. this.order = 0;
  3299. this.bones = new Array();
  3300. this.name = name;
  3301. }
  3302. return PathConstraintData;
  3303. }());
  3304. spine.PathConstraintData = PathConstraintData;
  3305. var PositionMode;
  3306. (function (PositionMode) {
  3307. PositionMode[PositionMode["Fixed"] = 0] = "Fixed";
  3308. PositionMode[PositionMode["Percent"] = 1] = "Percent";
  3309. })(PositionMode = spine.PositionMode || (spine.PositionMode = {}));
  3310. var SpacingMode;
  3311. (function (SpacingMode) {
  3312. SpacingMode[SpacingMode["Length"] = 0] = "Length";
  3313. SpacingMode[SpacingMode["Fixed"] = 1] = "Fixed";
  3314. SpacingMode[SpacingMode["Percent"] = 2] = "Percent";
  3315. })(SpacingMode = spine.SpacingMode || (spine.SpacingMode = {}));
  3316. var RotateMode;
  3317. (function (RotateMode) {
  3318. RotateMode[RotateMode["Tangent"] = 0] = "Tangent";
  3319. RotateMode[RotateMode["Chain"] = 1] = "Chain";
  3320. RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
  3321. })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
  3322. })(spine || (spine = {}));
  3323. var spine;
  3324. (function (spine) {
  3325. var Assets = (function () {
  3326. function Assets(clientId) {
  3327. this.toLoad = new Array();
  3328. this.assets = {};
  3329. this.clientId = clientId;
  3330. }
  3331. Assets.prototype.loaded = function () {
  3332. var i = 0;
  3333. for (var v in this.assets)
  3334. i++;
  3335. return i;
  3336. };
  3337. return Assets;
  3338. }());
  3339. var SharedAssetManager = (function () {
  3340. function SharedAssetManager(pathPrefix) {
  3341. if (pathPrefix === void 0) { pathPrefix = ""; }
  3342. this.clientAssets = {};
  3343. this.queuedAssets = {};
  3344. this.rawAssets = {};
  3345. this.errors = {};
  3346. this.pathPrefix = pathPrefix;
  3347. }
  3348. SharedAssetManager.prototype.queueAsset = function (clientId, textureLoader, path) {
  3349. var clientAssets = this.clientAssets[clientId];
  3350. if (clientAssets === null || clientAssets === undefined) {
  3351. clientAssets = new Assets(clientId);
  3352. this.clientAssets[clientId] = clientAssets;
  3353. }
  3354. if (textureLoader !== null)
  3355. clientAssets.textureLoader = textureLoader;
  3356. clientAssets.toLoad.push(path);
  3357. if (this.queuedAssets[path] === path) {
  3358. return false;
  3359. }
  3360. else {
  3361. this.queuedAssets[path] = path;
  3362. return true;
  3363. }
  3364. };
  3365. SharedAssetManager.prototype.loadText = function (clientId, path) {
  3366. var _this = this;
  3367. path = this.pathPrefix + path;
  3368. if (!this.queueAsset(clientId, null, path))
  3369. return;
  3370. var request = new XMLHttpRequest();
  3371. request.onreadystatechange = function () {
  3372. if (request.readyState == XMLHttpRequest.DONE) {
  3373. if (request.status >= 200 && request.status < 300) {
  3374. _this.rawAssets[path] = request.responseText;
  3375. }
  3376. else {
  3377. _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
  3378. }
  3379. }
  3380. };
  3381. request.open("GET", path, true);
  3382. request.send();
  3383. };
  3384. SharedAssetManager.prototype.loadJson = function (clientId, path) {
  3385. var _this = this;
  3386. path = this.pathPrefix + path;
  3387. if (!this.queueAsset(clientId, null, path))
  3388. return;
  3389. var request = new XMLHttpRequest();
  3390. request.onreadystatechange = function () {
  3391. if (request.readyState == XMLHttpRequest.DONE) {
  3392. if (request.status >= 200 && request.status < 300) {
  3393. _this.rawAssets[path] = JSON.parse(request.responseText);
  3394. }
  3395. else {
  3396. _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
  3397. }
  3398. }
  3399. };
  3400. request.open("GET", path, true);
  3401. request.send();
  3402. };
  3403. SharedAssetManager.prototype.loadTexture = function (clientId, textureLoader, path) {
  3404. var _this = this;
  3405. path = this.pathPrefix + path;
  3406. if (!this.queueAsset(clientId, textureLoader, path))
  3407. return;
  3408. var img = new Image();
  3409. img.src = path;
  3410. img.crossOrigin = "anonymous";
  3411. img.onload = function (ev) {
  3412. _this.rawAssets[path] = img;
  3413. };
  3414. img.onerror = function (ev) {
  3415. _this.errors[path] = "Couldn't load image " + path;
  3416. };
  3417. };
  3418. SharedAssetManager.prototype.get = function (clientId, path) {
  3419. path = this.pathPrefix + path;
  3420. var clientAssets = this.clientAssets[clientId];
  3421. if (clientAssets === null || clientAssets === undefined)
  3422. return true;
  3423. return clientAssets.assets[path];
  3424. };
  3425. SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
  3426. for (var i = 0; i < clientAssets.toLoad.length; i++) {
  3427. var path = clientAssets.toLoad[i];
  3428. var asset = clientAssets.assets[path];
  3429. if (asset === null || asset === undefined) {
  3430. var rawAsset = this.rawAssets[path];
  3431. if (rawAsset === null || rawAsset === undefined)
  3432. continue;
  3433. if (rawAsset instanceof HTMLImageElement) {
  3434. clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
  3435. }
  3436. else {
  3437. clientAssets.assets[path] = rawAsset;
  3438. }
  3439. }
  3440. }
  3441. };
  3442. SharedAssetManager.prototype.isLoadingComplete = function (clientId) {
  3443. var clientAssets = this.clientAssets[clientId];
  3444. if (clientAssets === null || clientAssets === undefined)
  3445. return true;
  3446. this.updateClientAssets(clientAssets);
  3447. return clientAssets.toLoad.length == clientAssets.loaded();
  3448. };
  3449. SharedAssetManager.prototype.dispose = function () {
  3450. };
  3451. SharedAssetManager.prototype.hasErrors = function () {
  3452. return Object.keys(this.errors).length > 0;
  3453. };
  3454. SharedAssetManager.prototype.getErrors = function () {
  3455. return this.errors;
  3456. };
  3457. return SharedAssetManager;
  3458. }());
  3459. spine.SharedAssetManager = SharedAssetManager;
  3460. })(spine || (spine = {}));
  3461. var spine;
  3462. (function (spine) {
  3463. var Skeleton = (function () {
  3464. function Skeleton(data) {
  3465. this._updateCache = new Array();
  3466. this.updateCacheReset = new Array();
  3467. this.time = 0;
  3468. this.scaleX = 1;
  3469. this.scaleY = 1;
  3470. this.x = 0;
  3471. this.y = 0;
  3472. if (data == null)
  3473. throw new Error("data cannot be null.");
  3474. this.data = data;
  3475. this.bones = new Array();
  3476. for (var i = 0; i < data.bones.length; i++) {
  3477. var boneData = data.bones[i];
  3478. var bone = void 0;
  3479. if (boneData.parent == null)
  3480. bone = new spine.Bone(boneData, this, null);
  3481. else {
  3482. var parent_1 = this.bones[boneData.parent.index];
  3483. bone = new spine.Bone(boneData, this, parent_1);
  3484. parent_1.children.push(bone);
  3485. }
  3486. this.bones.push(bone);
  3487. }
  3488. this.slots = new Array();
  3489. this.drawOrder = new Array();
  3490. for (var i = 0; i < data.slots.length; i++) {
  3491. var slotData = data.slots[i];
  3492. var bone = this.bones[slotData.boneData.index];
  3493. var slot = new spine.Slot(slotData, bone);
  3494. this.slots.push(slot);
  3495. this.drawOrder.push(slot);
  3496. }
  3497. this.ikConstraints = new Array();
  3498. for (var i = 0; i < data.ikConstraints.length; i++) {
  3499. var ikConstraintData = data.ikConstraints[i];
  3500. this.ikConstraints.push(new spine.IkConstraint(ikConstraintData, this));
  3501. }
  3502. this.transformConstraints = new Array();
  3503. for (var i = 0; i < data.transformConstraints.length; i++) {
  3504. var transformConstraintData = data.transformConstraints[i];
  3505. this.transformConstraints.push(new spine.TransformConstraint(transformConstraintData, this));
  3506. }
  3507. this.pathConstraints = new Array();
  3508. for (var i = 0; i < data.pathConstraints.length; i++) {
  3509. var pathConstraintData = data.pathConstraints[i];
  3510. this.pathConstraints.push(new spine.PathConstraint(pathConstraintData, this));
  3511. }
  3512. this.color = new spine.Color(1, 1, 1, 1);
  3513. this.updateCache();
  3514. }
  3515. Skeleton.prototype.updateCache = function () {
  3516. var updateCache = this._updateCache;
  3517. updateCache.length = 0;
  3518. this.updateCacheReset.length = 0;
  3519. var bones = this.bones;
  3520. for (var i = 0, n = bones.length; i < n; i++)
  3521. bones[i].sorted = false;
  3522. var ikConstraints = this.ikConstraints;
  3523. var transformConstraints = this.transformConstraints;
  3524. var pathConstraints = this.pathConstraints;
  3525. var ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length;
  3526. var constraintCount = ikCount + transformCount + pathCount;
  3527. outer: for (var i = 0; i < constraintCount; i++) {
  3528. for (var ii = 0; ii < ikCount; ii++) {
  3529. var constraint = ikConstraints[ii];
  3530. if (constraint.data.order == i) {
  3531. this.sortIkConstraint(constraint);
  3532. continue outer;
  3533. }
  3534. }
  3535. for (var ii = 0; ii < transformCount; ii++) {
  3536. var constraint = transformConstraints[ii];
  3537. if (constraint.data.order == i) {
  3538. this.sortTransformConstraint(constraint);
  3539. continue outer;
  3540. }
  3541. }
  3542. for (var ii = 0; ii < pathCount; ii++) {
  3543. var constraint = pathConstraints[ii];
  3544. if (constraint.data.order == i) {
  3545. this.sortPathConstraint(constraint);
  3546. continue outer;
  3547. }
  3548. }
  3549. }
  3550. for (var i = 0, n = bones.length; i < n; i++)
  3551. this.sortBone(bones[i]);
  3552. };
  3553. Skeleton.prototype.sortIkConstraint = function (constraint) {
  3554. var target = constraint.target;
  3555. this.sortBone(target);
  3556. var constrained = constraint.bones;
  3557. var parent = constrained[0];
  3558. this.sortBone(parent);
  3559. if (constrained.length > 1) {
  3560. var child = constrained[constrained.length - 1];
  3561. if (!(this._updateCache.indexOf(child) > -1))
  3562. this.updateCacheReset.push(child);
  3563. }
  3564. this._updateCache.push(constraint);
  3565. this.sortReset(parent.children);
  3566. constrained[constrained.length - 1].sorted = true;
  3567. };
  3568. Skeleton.prototype.sortPathConstraint = function (constraint) {
  3569. var slot = constraint.target;
  3570. var slotIndex = slot.data.index;
  3571. var slotBone = slot.bone;
  3572. if (this.skin != null)
  3573. this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone);
  3574. if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin)
  3575. this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone);
  3576. for (var i = 0, n = this.data.skins.length; i < n; i++)
  3577. this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone);
  3578. var attachment = slot.getAttachment();
  3579. if (attachment instanceof spine.PathAttachment)
  3580. this.sortPathConstraintAttachmentWith(attachment, slotBone);
  3581. var constrained = constraint.bones;
  3582. var boneCount = constrained.length;
  3583. for (var i = 0; i < boneCount; i++)
  3584. this.sortBone(constrained[i]);
  3585. this._updateCache.push(constraint);
  3586. for (var i = 0; i < boneCount; i++)
  3587. this.sortReset(constrained[i].children);
  3588. for (var i = 0; i < boneCount; i++)
  3589. constrained[i].sorted = true;
  3590. };
  3591. Skeleton.prototype.sortTransformConstraint = function (constraint) {
  3592. this.sortBone(constraint.target);
  3593. var constrained = constraint.bones;
  3594. var boneCount = constrained.length;
  3595. if (constraint.data.local) {
  3596. for (var i = 0; i < boneCount; i++) {
  3597. var child = constrained[i];
  3598. this.sortBone(child.parent);
  3599. if (!(this._updateCache.indexOf(child) > -1))
  3600. this.updateCacheReset.push(child);
  3601. }
  3602. }
  3603. else {
  3604. for (var i = 0; i < boneCount; i++) {
  3605. this.sortBone(constrained[i]);
  3606. }
  3607. }
  3608. this._updateCache.push(constraint);
  3609. for (var ii = 0; ii < boneCount; ii++)
  3610. this.sortReset(constrained[ii].children);
  3611. for (var ii = 0; ii < boneCount; ii++)
  3612. constrained[ii].sorted = true;
  3613. };
  3614. Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) {
  3615. var attachments = skin.attachments[slotIndex];
  3616. if (!attachments)
  3617. return;
  3618. for (var key in attachments) {
  3619. this.sortPathConstraintAttachmentWith(attachments[key], slotBone);
  3620. }
  3621. };
  3622. Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) {
  3623. if (!(attachment instanceof spine.PathAttachment))
  3624. return;
  3625. var pathBones = attachment.bones;
  3626. if (pathBones == null)
  3627. this.sortBone(slotBone);
  3628. else {
  3629. var bones = this.bones;
  3630. var i = 0;
  3631. while (i < pathBones.length) {
  3632. var boneCount = pathBones[i++];
  3633. for (var n = i + boneCount; i < n; i++) {
  3634. var boneIndex = pathBones[i];
  3635. this.sortBone(bones[boneIndex]);
  3636. }
  3637. }
  3638. }
  3639. };
  3640. Skeleton.prototype.sortBone = function (bone) {
  3641. if (bone.sorted)
  3642. return;
  3643. var parent = bone.parent;
  3644. if (parent != null)
  3645. this.sortBone(parent);
  3646. bone.sorted = true;
  3647. this._updateCache.push(bone);
  3648. };
  3649. Skeleton.prototype.sortReset = function (bones) {
  3650. for (var i = 0, n = bones.length; i < n; i++) {
  3651. var bone = bones[i];
  3652. if (bone.sorted)
  3653. this.sortReset(bone.children);
  3654. bone.sorted = false;
  3655. }
  3656. };
  3657. Skeleton.prototype.updateWorldTransform = function () {
  3658. var updateCacheReset = this.updateCacheReset;
  3659. for (var i = 0, n = updateCacheReset.length; i < n; i++) {
  3660. var bone = updateCacheReset[i];
  3661. bone.ax = bone.x;
  3662. bone.ay = bone.y;
  3663. bone.arotation = bone.rotation;
  3664. bone.ascaleX = bone.scaleX;
  3665. bone.ascaleY = bone.scaleY;
  3666. bone.ashearX = bone.shearX;
  3667. bone.ashearY = bone.shearY;
  3668. bone.appliedValid = true;
  3669. }
  3670. var updateCache = this._updateCache;
  3671. for (var i = 0, n = updateCache.length; i < n; i++)
  3672. updateCache[i].update();
  3673. };
  3674. Skeleton.prototype.setToSetupPose = function () {
  3675. this.setBonesToSetupPose();
  3676. this.setSlotsToSetupPose();
  3677. };
  3678. Skeleton.prototype.setBonesToSetupPose = function () {
  3679. var bones = this.bones;
  3680. for (var i = 0, n = bones.length; i < n; i++)
  3681. bones[i].setToSetupPose();
  3682. var ikConstraints = this.ikConstraints;
  3683. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  3684. var constraint = ikConstraints[i];
  3685. constraint.mix = constraint.data.mix;
  3686. constraint.bendDirection = constraint.data.bendDirection;
  3687. constraint.compress = constraint.data.compress;
  3688. constraint.stretch = constraint.data.stretch;
  3689. }
  3690. var transformConstraints = this.transformConstraints;
  3691. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  3692. var constraint = transformConstraints[i];
  3693. var data = constraint.data;
  3694. constraint.rotateMix = data.rotateMix;
  3695. constraint.translateMix = data.translateMix;
  3696. constraint.scaleMix = data.scaleMix;
  3697. constraint.shearMix = data.shearMix;
  3698. }
  3699. var pathConstraints = this.pathConstraints;
  3700. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  3701. var constraint = pathConstraints[i];
  3702. var data = constraint.data;
  3703. constraint.position = data.position;
  3704. constraint.spacing = data.spacing;
  3705. constraint.rotateMix = data.rotateMix;
  3706. constraint.translateMix = data.translateMix;
  3707. }
  3708. };
  3709. Skeleton.prototype.setSlotsToSetupPose = function () {
  3710. var slots = this.slots;
  3711. spine.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length);
  3712. for (var i = 0, n = slots.length; i < n; i++)
  3713. slots[i].setToSetupPose();
  3714. };
  3715. Skeleton.prototype.getRootBone = function () {
  3716. if (this.bones.length == 0)
  3717. return null;
  3718. return this.bones[0];
  3719. };
  3720. Skeleton.prototype.findBone = function (boneName) {
  3721. if (boneName == null)
  3722. throw new Error("boneName cannot be null.");
  3723. var bones = this.bones;
  3724. for (var i = 0, n = bones.length; i < n; i++) {
  3725. var bone = bones[i];
  3726. if (bone.data.name == boneName)
  3727. return bone;
  3728. }
  3729. return null;
  3730. };
  3731. Skeleton.prototype.findBoneIndex = function (boneName) {
  3732. if (boneName == null)
  3733. throw new Error("boneName cannot be null.");
  3734. var bones = this.bones;
  3735. for (var i = 0, n = bones.length; i < n; i++)
  3736. if (bones[i].data.name == boneName)
  3737. return i;
  3738. return -1;
  3739. };
  3740. Skeleton.prototype.findSlot = function (slotName) {
  3741. if (slotName == null)
  3742. throw new Error("slotName cannot be null.");
  3743. var slots = this.slots;
  3744. for (var i = 0, n = slots.length; i < n; i++) {
  3745. var slot = slots[i];
  3746. if (slot.data.name == slotName)
  3747. return slot;
  3748. }
  3749. return null;
  3750. };
  3751. Skeleton.prototype.findSlotIndex = function (slotName) {
  3752. if (slotName == null)
  3753. throw new Error("slotName cannot be null.");
  3754. var slots = this.slots;
  3755. for (var i = 0, n = slots.length; i < n; i++)
  3756. if (slots[i].data.name == slotName)
  3757. return i;
  3758. return -1;
  3759. };
  3760. Skeleton.prototype.setSkinByName = function (skinName) {
  3761. var skin = this.data.findSkin(skinName);
  3762. if (skin == null)
  3763. throw new Error("Skin not found: " + skinName);
  3764. this.setSkin(skin);
  3765. };
  3766. Skeleton.prototype.setSkin = function (newSkin) {
  3767. if (newSkin != null) {
  3768. if (this.skin != null)
  3769. newSkin.attachAll(this, this.skin);
  3770. else {
  3771. var slots = this.slots;
  3772. for (var i = 0, n = slots.length; i < n; i++) {
  3773. var slot = slots[i];
  3774. var name_1 = slot.data.attachmentName;
  3775. if (name_1 != null) {
  3776. var attachment = newSkin.getAttachment(i, name_1);
  3777. if (attachment != null)
  3778. slot.setAttachment(attachment);
  3779. }
  3780. }
  3781. }
  3782. }
  3783. this.skin = newSkin;
  3784. };
  3785. Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) {
  3786. return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName);
  3787. };
  3788. Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) {
  3789. if (attachmentName == null)
  3790. throw new Error("attachmentName cannot be null.");
  3791. if (this.skin != null) {
  3792. var attachment = this.skin.getAttachment(slotIndex, attachmentName);
  3793. if (attachment != null)
  3794. return attachment;
  3795. }
  3796. if (this.data.defaultSkin != null)
  3797. return this.data.defaultSkin.getAttachment(slotIndex, attachmentName);
  3798. return null;
  3799. };
  3800. Skeleton.prototype.setAttachment = function (slotName, attachmentName) {
  3801. if (slotName == null)
  3802. throw new Error("slotName cannot be null.");
  3803. var slots = this.slots;
  3804. for (var i = 0, n = slots.length; i < n; i++) {
  3805. var slot = slots[i];
  3806. if (slot.data.name == slotName) {
  3807. var attachment = null;
  3808. if (attachmentName != null) {
  3809. attachment = this.getAttachment(i, attachmentName);
  3810. if (attachment == null)
  3811. throw new Error("Attachment not found: " + attachmentName + ", for slot: " + slotName);
  3812. }
  3813. slot.setAttachment(attachment);
  3814. return;
  3815. }
  3816. }
  3817. throw new Error("Slot not found: " + slotName);
  3818. };
  3819. Skeleton.prototype.findIkConstraint = function (constraintName) {
  3820. if (constraintName == null)
  3821. throw new Error("constraintName cannot be null.");
  3822. var ikConstraints = this.ikConstraints;
  3823. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  3824. var ikConstraint = ikConstraints[i];
  3825. if (ikConstraint.data.name == constraintName)
  3826. return ikConstraint;
  3827. }
  3828. return null;
  3829. };
  3830. Skeleton.prototype.findTransformConstraint = function (constraintName) {
  3831. if (constraintName == null)
  3832. throw new Error("constraintName cannot be null.");
  3833. var transformConstraints = this.transformConstraints;
  3834. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  3835. var constraint = transformConstraints[i];
  3836. if (constraint.data.name == constraintName)
  3837. return constraint;
  3838. }
  3839. return null;
  3840. };
  3841. Skeleton.prototype.findPathConstraint = function (constraintName) {
  3842. if (constraintName == null)
  3843. throw new Error("constraintName cannot be null.");
  3844. var pathConstraints = this.pathConstraints;
  3845. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  3846. var constraint = pathConstraints[i];
  3847. if (constraint.data.name == constraintName)
  3848. return constraint;
  3849. }
  3850. return null;
  3851. };
  3852. Skeleton.prototype.getBounds = function (offset, size, temp) {
  3853. if (temp === void 0) { temp = new Array(2); }
  3854. if (offset == null)
  3855. throw new Error("offset cannot be null.");
  3856. if (size == null)
  3857. throw new Error("size cannot be null.");
  3858. var drawOrder = this.drawOrder;
  3859. var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;
  3860. for (var i = 0, n = drawOrder.length; i < n; i++) {
  3861. var slot = drawOrder[i];
  3862. var verticesLength = 0;
  3863. var vertices = null;
  3864. var attachment = slot.getAttachment();
  3865. if (attachment instanceof spine.RegionAttachment) {
  3866. verticesLength = 8;
  3867. vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
  3868. attachment.computeWorldVertices(slot.bone, vertices, 0, 2);
  3869. }
  3870. else if (attachment instanceof spine.MeshAttachment) {
  3871. var mesh = attachment;
  3872. verticesLength = mesh.worldVerticesLength;
  3873. vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
  3874. mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
  3875. }
  3876. if (vertices != null) {
  3877. for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
  3878. var x = vertices[ii], y = vertices[ii + 1];
  3879. minX = Math.min(minX, x);
  3880. minY = Math.min(minY, y);
  3881. maxX = Math.max(maxX, x);
  3882. maxY = Math.max(maxY, y);
  3883. }
  3884. }
  3885. }
  3886. offset.set(minX, minY);
  3887. size.set(maxX - minX, maxY - minY);
  3888. };
  3889. Skeleton.prototype.update = function (delta) {
  3890. this.time += delta;
  3891. };
  3892. return Skeleton;
  3893. }());
  3894. spine.Skeleton = Skeleton;
  3895. })(spine || (spine = {}));
  3896. var spine;
  3897. (function (spine) {
  3898. var SkeletonBounds = (function () {
  3899. function SkeletonBounds() {
  3900. this.minX = 0;
  3901. this.minY = 0;
  3902. this.maxX = 0;
  3903. this.maxY = 0;
  3904. this.boundingBoxes = new Array();
  3905. this.polygons = new Array();
  3906. this.polygonPool = new spine.Pool(function () {
  3907. return spine.Utils.newFloatArray(16);
  3908. });
  3909. }
  3910. SkeletonBounds.prototype.update = function (skeleton, updateAabb) {
  3911. if (skeleton == null)
  3912. throw new Error("skeleton cannot be null.");
  3913. var boundingBoxes = this.boundingBoxes;
  3914. var polygons = this.polygons;
  3915. var polygonPool = this.polygonPool;
  3916. var slots = skeleton.slots;
  3917. var slotCount = slots.length;
  3918. boundingBoxes.length = 0;
  3919. polygonPool.freeAll(polygons);
  3920. polygons.length = 0;
  3921. for (var i = 0; i < slotCount; i++) {
  3922. var slot = slots[i];
  3923. var attachment = slot.getAttachment();
  3924. if (attachment instanceof spine.BoundingBoxAttachment) {
  3925. var boundingBox = attachment;
  3926. boundingBoxes.push(boundingBox);
  3927. var polygon = polygonPool.obtain();
  3928. if (polygon.length != boundingBox.worldVerticesLength) {
  3929. polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength);
  3930. }
  3931. polygons.push(polygon);
  3932. boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2);
  3933. }
  3934. }
  3935. if (updateAabb) {
  3936. this.aabbCompute();
  3937. }
  3938. else {
  3939. this.minX = Number.POSITIVE_INFINITY;
  3940. this.minY = Number.POSITIVE_INFINITY;
  3941. this.maxX = Number.NEGATIVE_INFINITY;
  3942. this.maxY = Number.NEGATIVE_INFINITY;
  3943. }
  3944. };
  3945. SkeletonBounds.prototype.aabbCompute = function () {
  3946. var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;
  3947. var polygons = this.polygons;
  3948. for (var i = 0, n = polygons.length; i < n; i++) {
  3949. var polygon = polygons[i];
  3950. var vertices = polygon;
  3951. for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) {
  3952. var x = vertices[ii];
  3953. var y = vertices[ii + 1];
  3954. minX = Math.min(minX, x);
  3955. minY = Math.min(minY, y);
  3956. maxX = Math.max(maxX, x);
  3957. maxY = Math.max(maxY, y);
  3958. }
  3959. }
  3960. this.minX = minX;
  3961. this.minY = minY;
  3962. this.maxX = maxX;
  3963. this.maxY = maxY;
  3964. };
  3965. SkeletonBounds.prototype.aabbContainsPoint = function (x, y) {
  3966. return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY;
  3967. };
  3968. SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) {
  3969. var minX = this.minX;
  3970. var minY = this.minY;
  3971. var maxX = this.maxX;
  3972. var maxY = this.maxY;
  3973. if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY))
  3974. return false;
  3975. var m = (y2 - y1) / (x2 - x1);
  3976. var y = m * (minX - x1) + y1;
  3977. if (y > minY && y < maxY)
  3978. return true;
  3979. y = m * (maxX - x1) + y1;
  3980. if (y > minY && y < maxY)
  3981. return true;
  3982. var x = (minY - y1) / m + x1;
  3983. if (x > minX && x < maxX)
  3984. return true;
  3985. x = (maxY - y1) / m + x1;
  3986. if (x > minX && x < maxX)
  3987. return true;
  3988. return false;
  3989. };
  3990. SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) {
  3991. return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY;
  3992. };
  3993. SkeletonBounds.prototype.containsPoint = function (x, y) {
  3994. var polygons = this.polygons;
  3995. for (var i = 0, n = polygons.length; i < n; i++)
  3996. if (this.containsPointPolygon(polygons[i], x, y))
  3997. return this.boundingBoxes[i];
  3998. return null;
  3999. };
  4000. SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) {
  4001. var vertices = polygon;
  4002. var nn = polygon.length;
  4003. var prevIndex = nn - 2;
  4004. var inside = false;
  4005. for (var ii = 0; ii < nn; ii += 2) {
  4006. var vertexY = vertices[ii + 1];
  4007. var prevY = vertices[prevIndex + 1];
  4008. if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) {
  4009. var vertexX = vertices[ii];
  4010. if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x)
  4011. inside = !inside;
  4012. }
  4013. prevIndex = ii;
  4014. }
  4015. return inside;
  4016. };
  4017. SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) {
  4018. var polygons = this.polygons;
  4019. for (var i = 0, n = polygons.length; i < n; i++)
  4020. if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2))
  4021. return this.boundingBoxes[i];
  4022. return null;
  4023. };
  4024. SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) {
  4025. var vertices = polygon;
  4026. var nn = polygon.length;
  4027. var width12 = x1 - x2, height12 = y1 - y2;
  4028. var det1 = x1 * y2 - y1 * x2;
  4029. var x3 = vertices[nn - 2], y3 = vertices[nn - 1];
  4030. for (var ii = 0; ii < nn; ii += 2) {
  4031. var x4 = vertices[ii], y4 = vertices[ii + 1];
  4032. var det2 = x3 * y4 - y3 * x4;
  4033. var width34 = x3 - x4, height34 = y3 - y4;
  4034. var det3 = width12 * height34 - height12 * width34;
  4035. var x = (det1 * width34 - width12 * det2) / det3;
  4036. if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {
  4037. var y = (det1 * height34 - height12 * det2) / det3;
  4038. if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1)))
  4039. return true;
  4040. }
  4041. x3 = x4;
  4042. y3 = y4;
  4043. }
  4044. return false;
  4045. };
  4046. SkeletonBounds.prototype.getPolygon = function (boundingBox) {
  4047. if (boundingBox == null)
  4048. throw new Error("boundingBox cannot be null.");
  4049. var index = this.boundingBoxes.indexOf(boundingBox);
  4050. return index == -1 ? null : this.polygons[index];
  4051. };
  4052. SkeletonBounds.prototype.getWidth = function () {
  4053. return this.maxX - this.minX;
  4054. };
  4055. SkeletonBounds.prototype.getHeight = function () {
  4056. return this.maxY - this.minY;
  4057. };
  4058. return SkeletonBounds;
  4059. }());
  4060. spine.SkeletonBounds = SkeletonBounds;
  4061. })(spine || (spine = {}));
  4062. var spine;
  4063. (function (spine) {
  4064. var SkeletonClipping = (function () {
  4065. function SkeletonClipping() {
  4066. this.triangulator = new spine.Triangulator();
  4067. this.clippingPolygon = new Array();
  4068. this.clipOutput = new Array();
  4069. this.clippedVertices = new Array();
  4070. this.clippedTriangles = new Array();
  4071. this.scratch = new Array();
  4072. }
  4073. SkeletonClipping.prototype.clipStart = function (slot, clip) {
  4074. if (this.clipAttachment != null)
  4075. return 0;
  4076. this.clipAttachment = clip;
  4077. var n = clip.worldVerticesLength;
  4078. var vertices = spine.Utils.setArraySize(this.clippingPolygon, n);
  4079. clip.computeWorldVertices(slot, 0, n, vertices, 0, 2);
  4080. var clippingPolygon = this.clippingPolygon;
  4081. SkeletonClipping.makeClockwise(clippingPolygon);
  4082. var clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon));
  4083. for (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) {
  4084. var polygon = clippingPolygons[i];
  4085. SkeletonClipping.makeClockwise(polygon);
  4086. polygon.push(polygon[0]);
  4087. polygon.push(polygon[1]);
  4088. }
  4089. return clippingPolygons.length;
  4090. };
  4091. SkeletonClipping.prototype.clipEndWithSlot = function (slot) {
  4092. if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data)
  4093. this.clipEnd();
  4094. };
  4095. SkeletonClipping.prototype.clipEnd = function () {
  4096. if (this.clipAttachment == null)
  4097. return;
  4098. this.clipAttachment = null;
  4099. this.clippingPolygons = null;
  4100. this.clippedVertices.length = 0;
  4101. this.clippedTriangles.length = 0;
  4102. this.clippingPolygon.length = 0;
  4103. };
  4104. SkeletonClipping.prototype.isClipping = function () {
  4105. return this.clipAttachment != null;
  4106. };
  4107. SkeletonClipping.prototype.clipTriangles = function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) {
  4108. var clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
  4109. var clippedTriangles = this.clippedTriangles;
  4110. var polygons = this.clippingPolygons;
  4111. var polygonsCount = this.clippingPolygons.length;
  4112. var vertexSize = twoColor ? 12 : 8;
  4113. var index = 0;
  4114. clippedVertices.length = 0;
  4115. clippedTriangles.length = 0;
  4116. outer: for (var i = 0; i < trianglesLength; i += 3) {
  4117. var vertexOffset = triangles[i] << 1;
  4118. var x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
  4119. var u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
  4120. vertexOffset = triangles[i + 1] << 1;
  4121. var x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
  4122. var u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];
  4123. vertexOffset = triangles[i + 2] << 1;
  4124. var x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
  4125. var u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
  4126. for (var p = 0; p < polygonsCount; p++) {
  4127. var s = clippedVertices.length;
  4128. if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {
  4129. var clipOutputLength = clipOutput.length;
  4130. if (clipOutputLength == 0)
  4131. continue;
  4132. var d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
  4133. var d = 1 / (d0 * d2 + d1 * (y1 - y3));
  4134. var clipOutputCount = clipOutputLength >> 1;
  4135. var clipOutputItems = this.clipOutput;
  4136. var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize);
  4137. for (var ii = 0; ii < clipOutputLength; ii += 2) {
  4138. var x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
  4139. clippedVerticesItems[s] = x;
  4140. clippedVerticesItems[s + 1] = y;
  4141. clippedVerticesItems[s + 2] = light.r;
  4142. clippedVerticesItems[s + 3] = light.g;
  4143. clippedVerticesItems[s + 4] = light.b;
  4144. clippedVerticesItems[s + 5] = light.a;
  4145. var c0 = x - x3, c1 = y - y3;
  4146. var a = (d0 * c0 + d1 * c1) * d;
  4147. var b = (d4 * c0 + d2 * c1) * d;
  4148. var c = 1 - a - b;
  4149. clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c;
  4150. clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
  4151. if (twoColor) {
  4152. clippedVerticesItems[s + 8] = dark.r;
  4153. clippedVerticesItems[s + 9] = dark.g;
  4154. clippedVerticesItems[s + 10] = dark.b;
  4155. clippedVerticesItems[s + 11] = dark.a;
  4156. }
  4157. s += vertexSize;
  4158. }
  4159. s = clippedTriangles.length;
  4160. var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2));
  4161. clipOutputCount--;
  4162. for (var ii = 1; ii < clipOutputCount; ii++) {
  4163. clippedTrianglesItems[s] = index;
  4164. clippedTrianglesItems[s + 1] = (index + ii);
  4165. clippedTrianglesItems[s + 2] = (index + ii + 1);
  4166. s += 3;
  4167. }
  4168. index += clipOutputCount + 1;
  4169. }
  4170. else {
  4171. var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + 3 * vertexSize);
  4172. clippedVerticesItems[s] = x1;
  4173. clippedVerticesItems[s + 1] = y1;
  4174. clippedVerticesItems[s + 2] = light.r;
  4175. clippedVerticesItems[s + 3] = light.g;
  4176. clippedVerticesItems[s + 4] = light.b;
  4177. clippedVerticesItems[s + 5] = light.a;
  4178. if (!twoColor) {
  4179. clippedVerticesItems[s + 6] = u1;
  4180. clippedVerticesItems[s + 7] = v1;
  4181. clippedVerticesItems[s + 8] = x2;
  4182. clippedVerticesItems[s + 9] = y2;
  4183. clippedVerticesItems[s + 10] = light.r;
  4184. clippedVerticesItems[s + 11] = light.g;
  4185. clippedVerticesItems[s + 12] = light.b;
  4186. clippedVerticesItems[s + 13] = light.a;
  4187. clippedVerticesItems[s + 14] = u2;
  4188. clippedVerticesItems[s + 15] = v2;
  4189. clippedVerticesItems[s + 16] = x3;
  4190. clippedVerticesItems[s + 17] = y3;
  4191. clippedVerticesItems[s + 18] = light.r;
  4192. clippedVerticesItems[s + 19] = light.g;
  4193. clippedVerticesItems[s + 20] = light.b;
  4194. clippedVerticesItems[s + 21] = light.a;
  4195. clippedVerticesItems[s + 22] = u3;
  4196. clippedVerticesItems[s + 23] = v3;
  4197. }
  4198. else {
  4199. clippedVerticesItems[s + 6] = u1;
  4200. clippedVerticesItems[s + 7] = v1;
  4201. clippedVerticesItems[s + 8] = dark.r;
  4202. clippedVerticesItems[s + 9] = dark.g;
  4203. clippedVerticesItems[s + 10] = dark.b;
  4204. clippedVerticesItems[s + 11] = dark.a;
  4205. clippedVerticesItems[s + 12] = x2;
  4206. clippedVerticesItems[s + 13] = y2;
  4207. clippedVerticesItems[s + 14] = light.r;
  4208. clippedVerticesItems[s + 15] = light.g;
  4209. clippedVerticesItems[s + 16] = light.b;
  4210. clippedVerticesItems[s + 17] = light.a;
  4211. clippedVerticesItems[s + 18] = u2;
  4212. clippedVerticesItems[s + 19] = v2;
  4213. clippedVerticesItems[s + 20] = dark.r;
  4214. clippedVerticesItems[s + 21] = dark.g;
  4215. clippedVerticesItems[s + 22] = dark.b;
  4216. clippedVerticesItems[s + 23] = dark.a;
  4217. clippedVerticesItems[s + 24] = x3;
  4218. clippedVerticesItems[s + 25] = y3;
  4219. clippedVerticesItems[s + 26] = light.r;
  4220. clippedVerticesItems[s + 27] = light.g;
  4221. clippedVerticesItems[s + 28] = light.b;
  4222. clippedVerticesItems[s + 29] = light.a;
  4223. clippedVerticesItems[s + 30] = u3;
  4224. clippedVerticesItems[s + 31] = v3;
  4225. clippedVerticesItems[s + 32] = dark.r;
  4226. clippedVerticesItems[s + 33] = dark.g;
  4227. clippedVerticesItems[s + 34] = dark.b;
  4228. clippedVerticesItems[s + 35] = dark.a;
  4229. }
  4230. s = clippedTriangles.length;
  4231. var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3);
  4232. clippedTrianglesItems[s] = index;
  4233. clippedTrianglesItems[s + 1] = (index + 1);
  4234. clippedTrianglesItems[s + 2] = (index + 2);
  4235. index += 3;
  4236. continue outer;
  4237. }
  4238. }
  4239. }
  4240. };
  4241. SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) {
  4242. var originalOutput = output;
  4243. var clipped = false;
  4244. var input = null;
  4245. if (clippingArea.length % 4 >= 2) {
  4246. input = output;
  4247. output = this.scratch;
  4248. }
  4249. else
  4250. input = this.scratch;
  4251. input.length = 0;
  4252. input.push(x1);
  4253. input.push(y1);
  4254. input.push(x2);
  4255. input.push(y2);
  4256. input.push(x3);
  4257. input.push(y3);
  4258. input.push(x1);
  4259. input.push(y1);
  4260. output.length = 0;
  4261. var clippingVertices = clippingArea;
  4262. var clippingVerticesLast = clippingArea.length - 4;
  4263. for (var i = 0;; i += 2) {
  4264. var edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1];
  4265. var edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3];
  4266. var deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
  4267. var inputVertices = input;
  4268. var inputVerticesLength = input.length - 2, outputStart = output.length;
  4269. for (var ii = 0; ii < inputVerticesLength; ii += 2) {
  4270. var inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
  4271. var inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
  4272. var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0;
  4273. if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) {
  4274. if (side2) {
  4275. output.push(inputX2);
  4276. output.push(inputY2);
  4277. continue;
  4278. }
  4279. var c0 = inputY2 - inputY, c2 = inputX2 - inputX;
  4280. var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
  4281. if (Math.abs(s) > 0.000001) {
  4282. var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s;
  4283. output.push(edgeX + (edgeX2 - edgeX) * ua);
  4284. output.push(edgeY + (edgeY2 - edgeY) * ua);
  4285. }
  4286. else {
  4287. output.push(edgeX);
  4288. output.push(edgeY);
  4289. }
  4290. }
  4291. else if (side2) {
  4292. var c0 = inputY2 - inputY, c2 = inputX2 - inputX;
  4293. var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
  4294. if (Math.abs(s) > 0.000001) {
  4295. var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s;
  4296. output.push(edgeX + (edgeX2 - edgeX) * ua);
  4297. output.push(edgeY + (edgeY2 - edgeY) * ua);
  4298. }
  4299. else {
  4300. output.push(edgeX);
  4301. output.push(edgeY);
  4302. }
  4303. output.push(inputX2);
  4304. output.push(inputY2);
  4305. }
  4306. clipped = true;
  4307. }
  4308. if (outputStart == output.length) {
  4309. originalOutput.length = 0;
  4310. return true;
  4311. }
  4312. output.push(output[0]);
  4313. output.push(output[1]);
  4314. if (i == clippingVerticesLast)
  4315. break;
  4316. var temp = output;
  4317. output = input;
  4318. output.length = 0;
  4319. input = temp;
  4320. }
  4321. if (originalOutput != output) {
  4322. originalOutput.length = 0;
  4323. for (var i = 0, n = output.length - 2; i < n; i++)
  4324. originalOutput[i] = output[i];
  4325. }
  4326. else
  4327. originalOutput.length = originalOutput.length - 2;
  4328. return clipped;
  4329. };
  4330. SkeletonClipping.makeClockwise = function (polygon) {
  4331. var vertices = polygon;
  4332. var verticeslength = polygon.length;
  4333. var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0;
  4334. for (var i = 0, n = verticeslength - 3; i < n; i += 2) {
  4335. p1x = vertices[i];
  4336. p1y = vertices[i + 1];
  4337. p2x = vertices[i + 2];
  4338. p2y = vertices[i + 3];
  4339. area += p1x * p2y - p2x * p1y;
  4340. }
  4341. if (area < 0)
  4342. return;
  4343. for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) {
  4344. var x = vertices[i], y = vertices[i + 1];
  4345. var other = lastX - i;
  4346. vertices[i] = vertices[other];
  4347. vertices[i + 1] = vertices[other + 1];
  4348. vertices[other] = x;
  4349. vertices[other + 1] = y;
  4350. }
  4351. };
  4352. return SkeletonClipping;
  4353. }());
  4354. spine.SkeletonClipping = SkeletonClipping;
  4355. })(spine || (spine = {}));
  4356. var spine;
  4357. (function (spine) {
  4358. var SkeletonData = (function () {
  4359. function SkeletonData() {
  4360. this.bones = new Array();
  4361. this.slots = new Array();
  4362. this.skins = new Array();
  4363. this.events = new Array();
  4364. this.animations = new Array();
  4365. this.ikConstraints = new Array();
  4366. this.transformConstraints = new Array();
  4367. this.pathConstraints = new Array();
  4368. this.fps = 0;
  4369. }
  4370. SkeletonData.prototype.findBone = function (boneName) {
  4371. if (boneName == null)
  4372. throw new Error("boneName cannot be null.");
  4373. var bones = this.bones;
  4374. for (var i = 0, n = bones.length; i < n; i++) {
  4375. var bone = bones[i];
  4376. if (bone.name == boneName)
  4377. return bone;
  4378. }
  4379. return null;
  4380. };
  4381. SkeletonData.prototype.findBoneIndex = function (boneName) {
  4382. if (boneName == null)
  4383. throw new Error("boneName cannot be null.");
  4384. var bones = this.bones;
  4385. for (var i = 0, n = bones.length; i < n; i++)
  4386. if (bones[i].name == boneName)
  4387. return i;
  4388. return -1;
  4389. };
  4390. SkeletonData.prototype.findSlot = function (slotName) {
  4391. if (slotName == null)
  4392. throw new Error("slotName cannot be null.");
  4393. var slots = this.slots;
  4394. for (var i = 0, n = slots.length; i < n; i++) {
  4395. var slot = slots[i];
  4396. if (slot.name == slotName)
  4397. return slot;
  4398. }
  4399. return null;
  4400. };
  4401. SkeletonData.prototype.findSlotIndex = function (slotName) {
  4402. if (slotName == null)
  4403. throw new Error("slotName cannot be null.");
  4404. var slots = this.slots;
  4405. for (var i = 0, n = slots.length; i < n; i++)
  4406. if (slots[i].name == slotName)
  4407. return i;
  4408. return -1;
  4409. };
  4410. SkeletonData.prototype.findSkin = function (skinName) {
  4411. if (skinName == null)
  4412. throw new Error("skinName cannot be null.");
  4413. var skins = this.skins;
  4414. for (var i = 0, n = skins.length; i < n; i++) {
  4415. var skin = skins[i];
  4416. if (skin.name == skinName)
  4417. return skin;
  4418. }
  4419. return null;
  4420. };
  4421. SkeletonData.prototype.findEvent = function (eventDataName) {
  4422. if (eventDataName == null)
  4423. throw new Error("eventDataName cannot be null.");
  4424. var events = this.events;
  4425. for (var i = 0, n = events.length; i < n; i++) {
  4426. var event_4 = events[i];
  4427. if (event_4.name == eventDataName)
  4428. return event_4;
  4429. }
  4430. return null;
  4431. };
  4432. SkeletonData.prototype.findAnimation = function (animationName) {
  4433. if (animationName == null)
  4434. throw new Error("animationName cannot be null.");
  4435. var animations = this.animations;
  4436. for (var i = 0, n = animations.length; i < n; i++) {
  4437. var animation = animations[i];
  4438. if (animation.name == animationName)
  4439. return animation;
  4440. }
  4441. return null;
  4442. };
  4443. SkeletonData.prototype.findIkConstraint = function (constraintName) {
  4444. if (constraintName == null)
  4445. throw new Error("constraintName cannot be null.");
  4446. var ikConstraints = this.ikConstraints;
  4447. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  4448. var constraint = ikConstraints[i];
  4449. if (constraint.name == constraintName)
  4450. return constraint;
  4451. }
  4452. return null;
  4453. };
  4454. SkeletonData.prototype.findTransformConstraint = function (constraintName) {
  4455. if (constraintName == null)
  4456. throw new Error("constraintName cannot be null.");
  4457. var transformConstraints = this.transformConstraints;
  4458. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  4459. var constraint = transformConstraints[i];
  4460. if (constraint.name == constraintName)
  4461. return constraint;
  4462. }
  4463. return null;
  4464. };
  4465. SkeletonData.prototype.findPathConstraint = function (constraintName) {
  4466. if (constraintName == null)
  4467. throw new Error("constraintName cannot be null.");
  4468. var pathConstraints = this.pathConstraints;
  4469. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  4470. var constraint = pathConstraints[i];
  4471. if (constraint.name == constraintName)
  4472. return constraint;
  4473. }
  4474. return null;
  4475. };
  4476. SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) {
  4477. if (pathConstraintName == null)
  4478. throw new Error("pathConstraintName cannot be null.");
  4479. var pathConstraints = this.pathConstraints;
  4480. for (var i = 0, n = pathConstraints.length; i < n; i++)
  4481. if (pathConstraints[i].name == pathConstraintName)
  4482. return i;
  4483. return -1;
  4484. };
  4485. return SkeletonData;
  4486. }());
  4487. spine.SkeletonData = SkeletonData;
  4488. })(spine || (spine = {}));
  4489. var spine;
  4490. (function (spine) {
  4491. var SkeletonJson = (function () {
  4492. function SkeletonJson(attachmentLoader) {
  4493. this.scale = 1;
  4494. this.linkedMeshes = new Array();
  4495. this.attachmentLoader = attachmentLoader;
  4496. }
  4497. SkeletonJson.prototype.readSkeletonData = function (json) {
  4498. var scale = this.scale;
  4499. var skeletonData = new spine.SkeletonData();
  4500. var root = typeof (json) === "string" ? JSON.parse(json) : json;
  4501. var skeletonMap = root.skeleton;
  4502. if (skeletonMap != null) {
  4503. skeletonData.hash = skeletonMap.hash;
  4504. skeletonData.version = skeletonMap.spine;
  4505. skeletonData.width = skeletonMap.width;
  4506. skeletonData.height = skeletonMap.height;
  4507. skeletonData.fps = skeletonMap.fps;
  4508. skeletonData.imagesPath = skeletonMap.images;
  4509. }
  4510. if (root.bones) {
  4511. for (var i = 0; i < root.bones.length; i++) {
  4512. var boneMap = root.bones[i];
  4513. var parent_2 = null;
  4514. var parentName = this.getValue(boneMap, "parent", null);
  4515. if (parentName != null) {
  4516. parent_2 = skeletonData.findBone(parentName);
  4517. if (parent_2 == null)
  4518. throw new Error("Parent bone not found: " + parentName);
  4519. }
  4520. var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2);
  4521. data.length = this.getValue(boneMap, "length", 0) * scale;
  4522. data.x = this.getValue(boneMap, "x", 0) * scale;
  4523. data.y = this.getValue(boneMap, "y", 0) * scale;
  4524. data.rotation = this.getValue(boneMap, "rotation", 0);
  4525. data.scaleX = this.getValue(boneMap, "scaleX", 1);
  4526. data.scaleY = this.getValue(boneMap, "scaleY", 1);
  4527. data.shearX = this.getValue(boneMap, "shearX", 0);
  4528. data.shearY = this.getValue(boneMap, "shearY", 0);
  4529. data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal"));
  4530. skeletonData.bones.push(data);
  4531. }
  4532. }
  4533. if (root.slots) {
  4534. for (var i = 0; i < root.slots.length; i++) {
  4535. var slotMap = root.slots[i];
  4536. var slotName = slotMap.name;
  4537. var boneName = slotMap.bone;
  4538. var boneData = skeletonData.findBone(boneName);
  4539. if (boneData == null)
  4540. throw new Error("Slot bone not found: " + boneName);
  4541. var data = new spine.SlotData(skeletonData.slots.length, slotName, boneData);
  4542. var color = this.getValue(slotMap, "color", null);
  4543. if (color != null)
  4544. data.color.setFromString(color);
  4545. var dark = this.getValue(slotMap, "dark", null);
  4546. if (dark != null) {
  4547. data.darkColor = new spine.Color(1, 1, 1, 1);
  4548. data.darkColor.setFromString(dark);
  4549. }
  4550. data.attachmentName = this.getValue(slotMap, "attachment", null);
  4551. data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal"));
  4552. skeletonData.slots.push(data);
  4553. }
  4554. }
  4555. if (root.ik) {
  4556. for (var i = 0; i < root.ik.length; i++) {
  4557. var constraintMap = root.ik[i];
  4558. var data = new spine.IkConstraintData(constraintMap.name);
  4559. data.order = this.getValue(constraintMap, "order", 0);
  4560. for (var j = 0; j < constraintMap.bones.length; j++) {
  4561. var boneName = constraintMap.bones[j];
  4562. var bone = skeletonData.findBone(boneName);
  4563. if (bone == null)
  4564. throw new Error("IK bone not found: " + boneName);
  4565. data.bones.push(bone);
  4566. }
  4567. var targetName = constraintMap.target;
  4568. data.target = skeletonData.findBone(targetName);
  4569. if (data.target == null)
  4570. throw new Error("IK target bone not found: " + targetName);
  4571. data.mix = this.getValue(constraintMap, "mix", 1);
  4572. data.bendDirection = this.getValue(constraintMap, "bendPositive", true) ? 1 : -1;
  4573. data.compress = this.getValue(constraintMap, "compress", false);
  4574. data.stretch = this.getValue(constraintMap, "stretch", false);
  4575. data.uniform = this.getValue(constraintMap, "uniform", false);
  4576. skeletonData.ikConstraints.push(data);
  4577. }
  4578. }
  4579. if (root.transform) {
  4580. for (var i = 0; i < root.transform.length; i++) {
  4581. var constraintMap = root.transform[i];
  4582. var data = new spine.TransformConstraintData(constraintMap.name);
  4583. data.order = this.getValue(constraintMap, "order", 0);
  4584. for (var j = 0; j < constraintMap.bones.length; j++) {
  4585. var boneName = constraintMap.bones[j];
  4586. var bone = skeletonData.findBone(boneName);
  4587. if (bone == null)
  4588. throw new Error("Transform constraint bone not found: " + boneName);
  4589. data.bones.push(bone);
  4590. }
  4591. var targetName = constraintMap.target;
  4592. data.target = skeletonData.findBone(targetName);
  4593. if (data.target == null)
  4594. throw new Error("Transform constraint target bone not found: " + targetName);
  4595. data.local = this.getValue(constraintMap, "local", false);
  4596. data.relative = this.getValue(constraintMap, "relative", false);
  4597. data.offsetRotation = this.getValue(constraintMap, "rotation", 0);
  4598. data.offsetX = this.getValue(constraintMap, "x", 0) * scale;
  4599. data.offsetY = this.getValue(constraintMap, "y", 0) * scale;
  4600. data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0);
  4601. data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0);
  4602. data.offsetShearY = this.getValue(constraintMap, "shearY", 0);
  4603. data.rotateMix = this.getValue(constraintMap, "rotateMix", 1);
  4604. data.translateMix = this.getValue(constraintMap, "translateMix", 1);
  4605. data.scaleMix = this.getValue(constraintMap, "scaleMix", 1);
  4606. data.shearMix = this.getValue(constraintMap, "shearMix", 1);
  4607. skeletonData.transformConstraints.push(data);
  4608. }
  4609. }
  4610. if (root.path) {
  4611. for (var i = 0; i < root.path.length; i++) {
  4612. var constraintMap = root.path[i];
  4613. var data = new spine.PathConstraintData(constraintMap.name);
  4614. data.order = this.getValue(constraintMap, "order", 0);
  4615. for (var j = 0; j < constraintMap.bones.length; j++) {
  4616. var boneName = constraintMap.bones[j];
  4617. var bone = skeletonData.findBone(boneName);
  4618. if (bone == null)
  4619. throw new Error("Transform constraint bone not found: " + boneName);
  4620. data.bones.push(bone);
  4621. }
  4622. var targetName = constraintMap.target;
  4623. data.target = skeletonData.findSlot(targetName);
  4624. if (data.target == null)
  4625. throw new Error("Path target slot not found: " + targetName);
  4626. data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent"));
  4627. data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length"));
  4628. data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent"));
  4629. data.offsetRotation = this.getValue(constraintMap, "rotation", 0);
  4630. data.position = this.getValue(constraintMap, "position", 0);
  4631. if (data.positionMode == spine.PositionMode.Fixed)
  4632. data.position *= scale;
  4633. data.spacing = this.getValue(constraintMap, "spacing", 0);
  4634. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  4635. data.spacing *= scale;
  4636. data.rotateMix = this.getValue(constraintMap, "rotateMix", 1);
  4637. data.translateMix = this.getValue(constraintMap, "translateMix", 1);
  4638. skeletonData.pathConstraints.push(data);
  4639. }
  4640. }
  4641. if (root.skins) {
  4642. for (var skinName in root.skins) {
  4643. var skinMap = root.skins[skinName];
  4644. var skin = new spine.Skin(skinName);
  4645. for (var slotName in skinMap) {
  4646. var slotIndex = skeletonData.findSlotIndex(slotName);
  4647. if (slotIndex == -1)
  4648. throw new Error("Slot not found: " + slotName);
  4649. var slotMap = skinMap[slotName];
  4650. for (var entryName in slotMap) {
  4651. var attachment = this.readAttachment(slotMap[entryName], skin, slotIndex, entryName, skeletonData);
  4652. if (attachment != null)
  4653. skin.addAttachment(slotIndex, entryName, attachment);
  4654. }
  4655. }
  4656. skeletonData.skins.push(skin);
  4657. if (skin.name == "default")
  4658. skeletonData.defaultSkin = skin;
  4659. }
  4660. }
  4661. for (var i = 0, n = this.linkedMeshes.length; i < n; i++) {
  4662. var linkedMesh = this.linkedMeshes[i];
  4663. var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
  4664. if (skin == null)
  4665. throw new Error("Skin not found: " + linkedMesh.skin);
  4666. var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
  4667. if (parent_3 == null)
  4668. throw new Error("Parent mesh not found: " + linkedMesh.parent);
  4669. linkedMesh.mesh.setParentMesh(parent_3);
  4670. linkedMesh.mesh.updateUVs();
  4671. }
  4672. this.linkedMeshes.length = 0;
  4673. if (root.events) {
  4674. for (var eventName in root.events) {
  4675. var eventMap = root.events[eventName];
  4676. var data = new spine.EventData(eventName);
  4677. data.intValue = this.getValue(eventMap, "int", 0);
  4678. data.floatValue = this.getValue(eventMap, "float", 0);
  4679. data.stringValue = this.getValue(eventMap, "string", "");
  4680. data.audioPath = this.getValue(eventMap, "audio", null);
  4681. if (data.audioPath != null) {
  4682. data.volume = this.getValue(eventMap, "volume", 1);
  4683. data.balance = this.getValue(eventMap, "balance", 0);
  4684. }
  4685. skeletonData.events.push(data);
  4686. }
  4687. }
  4688. if (root.animations) {
  4689. for (var animationName in root.animations) {
  4690. var animationMap = root.animations[animationName];
  4691. this.readAnimation(animationMap, animationName, skeletonData);
  4692. }
  4693. }
  4694. return skeletonData;
  4695. };
  4696. SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) {
  4697. var scale = this.scale;
  4698. name = this.getValue(map, "name", name);
  4699. var type = this.getValue(map, "type", "region");
  4700. switch (type) {
  4701. case "region": {
  4702. var path = this.getValue(map, "path", name);
  4703. var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
  4704. if (region == null)
  4705. return null;
  4706. region.path = path;
  4707. region.x = this.getValue(map, "x", 0) * scale;
  4708. region.y = this.getValue(map, "y", 0) * scale;
  4709. region.scaleX = this.getValue(map, "scaleX", 1);
  4710. region.scaleY = this.getValue(map, "scaleY", 1);
  4711. region.rotation = this.getValue(map, "rotation", 0);
  4712. region.width = map.width * scale;
  4713. region.height = map.height * scale;
  4714. var color = this.getValue(map, "color", null);
  4715. if (color != null)
  4716. region.color.setFromString(color);
  4717. region.updateOffset();
  4718. return region;
  4719. }
  4720. case "boundingbox": {
  4721. var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
  4722. if (box == null)
  4723. return null;
  4724. this.readVertices(map, box, map.vertexCount << 1);
  4725. var color = this.getValue(map, "color", null);
  4726. if (color != null)
  4727. box.color.setFromString(color);
  4728. return box;
  4729. }
  4730. case "mesh":
  4731. case "linkedmesh": {
  4732. var path = this.getValue(map, "path", name);
  4733. var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
  4734. if (mesh == null)
  4735. return null;
  4736. mesh.path = path;
  4737. var color = this.getValue(map, "color", null);
  4738. if (color != null)
  4739. mesh.color.setFromString(color);
  4740. var parent_4 = this.getValue(map, "parent", null);
  4741. if (parent_4 != null) {
  4742. mesh.inheritDeform = this.getValue(map, "deform", true);
  4743. this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4));
  4744. return mesh;
  4745. }
  4746. var uvs = map.uvs;
  4747. this.readVertices(map, mesh, uvs.length);
  4748. mesh.triangles = map.triangles;
  4749. mesh.regionUVs = uvs;
  4750. mesh.updateUVs();
  4751. mesh.hullLength = this.getValue(map, "hull", 0) * 2;
  4752. return mesh;
  4753. }
  4754. case "path": {
  4755. var path = this.attachmentLoader.newPathAttachment(skin, name);
  4756. if (path == null)
  4757. return null;
  4758. path.closed = this.getValue(map, "closed", false);
  4759. path.constantSpeed = this.getValue(map, "constantSpeed", true);
  4760. var vertexCount = map.vertexCount;
  4761. this.readVertices(map, path, vertexCount << 1);
  4762. var lengths = spine.Utils.newArray(vertexCount / 3, 0);
  4763. for (var i = 0; i < map.lengths.length; i++)
  4764. lengths[i] = map.lengths[i] * scale;
  4765. path.lengths = lengths;
  4766. var color = this.getValue(map, "color", null);
  4767. if (color != null)
  4768. path.color.setFromString(color);
  4769. return path;
  4770. }
  4771. case "point": {
  4772. var point = this.attachmentLoader.newPointAttachment(skin, name);
  4773. if (point == null)
  4774. return null;
  4775. point.x = this.getValue(map, "x", 0) * scale;
  4776. point.y = this.getValue(map, "y", 0) * scale;
  4777. point.rotation = this.getValue(map, "rotation", 0);
  4778. var color = this.getValue(map, "color", null);
  4779. if (color != null)
  4780. point.color.setFromString(color);
  4781. return point;
  4782. }
  4783. case "clipping": {
  4784. var clip = this.attachmentLoader.newClippingAttachment(skin, name);
  4785. if (clip == null)
  4786. return null;
  4787. var end = this.getValue(map, "end", null);
  4788. if (end != null) {
  4789. var slot = skeletonData.findSlot(end);
  4790. if (slot == null)
  4791. throw new Error("Clipping end slot not found: " + end);
  4792. clip.endSlot = slot;
  4793. }
  4794. var vertexCount = map.vertexCount;
  4795. this.readVertices(map, clip, vertexCount << 1);
  4796. var color = this.getValue(map, "color", null);
  4797. if (color != null)
  4798. clip.color.setFromString(color);
  4799. return clip;
  4800. }
  4801. }
  4802. return null;
  4803. };
  4804. SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) {
  4805. var scale = this.scale;
  4806. attachment.worldVerticesLength = verticesLength;
  4807. var vertices = map.vertices;
  4808. if (verticesLength == vertices.length) {
  4809. var scaledVertices = spine.Utils.toFloatArray(vertices);
  4810. if (scale != 1) {
  4811. for (var i = 0, n = vertices.length; i < n; i++)
  4812. scaledVertices[i] *= scale;
  4813. }
  4814. attachment.vertices = scaledVertices;
  4815. return;
  4816. }
  4817. var weights = new Array();
  4818. var bones = new Array();
  4819. for (var i = 0, n = vertices.length; i < n;) {
  4820. var boneCount = vertices[i++];
  4821. bones.push(boneCount);
  4822. for (var nn = i + boneCount * 4; i < nn; i += 4) {
  4823. bones.push(vertices[i]);
  4824. weights.push(vertices[i + 1] * scale);
  4825. weights.push(vertices[i + 2] * scale);
  4826. weights.push(vertices[i + 3]);
  4827. }
  4828. }
  4829. attachment.bones = bones;
  4830. attachment.vertices = spine.Utils.toFloatArray(weights);
  4831. };
  4832. SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) {
  4833. var scale = this.scale;
  4834. var timelines = new Array();
  4835. var duration = 0;
  4836. if (map.slots) {
  4837. for (var slotName in map.slots) {
  4838. var slotMap = map.slots[slotName];
  4839. var slotIndex = skeletonData.findSlotIndex(slotName);
  4840. if (slotIndex == -1)
  4841. throw new Error("Slot not found: " + slotName);
  4842. for (var timelineName in slotMap) {
  4843. var timelineMap = slotMap[timelineName];
  4844. if (timelineName == "attachment") {
  4845. var timeline = new spine.AttachmentTimeline(timelineMap.length);
  4846. timeline.slotIndex = slotIndex;
  4847. var frameIndex = 0;
  4848. for (var i = 0; i < timelineMap.length; i++) {
  4849. var valueMap = timelineMap[i];
  4850. timeline.setFrame(frameIndex++, valueMap.time, valueMap.name);
  4851. }
  4852. timelines.push(timeline);
  4853. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  4854. }
  4855. else if (timelineName == "color") {
  4856. var timeline = new spine.ColorTimeline(timelineMap.length);
  4857. timeline.slotIndex = slotIndex;
  4858. var frameIndex = 0;
  4859. for (var i = 0; i < timelineMap.length; i++) {
  4860. var valueMap = timelineMap[i];
  4861. var color = new spine.Color();
  4862. color.setFromString(valueMap.color);
  4863. timeline.setFrame(frameIndex, valueMap.time, color.r, color.g, color.b, color.a);
  4864. this.readCurve(valueMap, timeline, frameIndex);
  4865. frameIndex++;
  4866. }
  4867. timelines.push(timeline);
  4868. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.ColorTimeline.ENTRIES]);
  4869. }
  4870. else if (timelineName == "twoColor") {
  4871. var timeline = new spine.TwoColorTimeline(timelineMap.length);
  4872. timeline.slotIndex = slotIndex;
  4873. var frameIndex = 0;
  4874. for (var i = 0; i < timelineMap.length; i++) {
  4875. var valueMap = timelineMap[i];
  4876. var light = new spine.Color();
  4877. var dark = new spine.Color();
  4878. light.setFromString(valueMap.light);
  4879. dark.setFromString(valueMap.dark);
  4880. timeline.setFrame(frameIndex, valueMap.time, light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b);
  4881. this.readCurve(valueMap, timeline, frameIndex);
  4882. frameIndex++;
  4883. }
  4884. timelines.push(timeline);
  4885. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TwoColorTimeline.ENTRIES]);
  4886. }
  4887. else
  4888. throw new Error("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")");
  4889. }
  4890. }
  4891. }
  4892. if (map.bones) {
  4893. for (var boneName in map.bones) {
  4894. var boneMap = map.bones[boneName];
  4895. var boneIndex = skeletonData.findBoneIndex(boneName);
  4896. if (boneIndex == -1)
  4897. throw new Error("Bone not found: " + boneName);
  4898. for (var timelineName in boneMap) {
  4899. var timelineMap = boneMap[timelineName];
  4900. if (timelineName === "rotate") {
  4901. var timeline = new spine.RotateTimeline(timelineMap.length);
  4902. timeline.boneIndex = boneIndex;
  4903. var frameIndex = 0;
  4904. for (var i = 0; i < timelineMap.length; i++) {
  4905. var valueMap = timelineMap[i];
  4906. timeline.setFrame(frameIndex, valueMap.time, valueMap.angle);
  4907. this.readCurve(valueMap, timeline, frameIndex);
  4908. frameIndex++;
  4909. }
  4910. timelines.push(timeline);
  4911. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.RotateTimeline.ENTRIES]);
  4912. }
  4913. else if (timelineName === "translate" || timelineName === "scale" || timelineName === "shear") {
  4914. var timeline = null;
  4915. var timelineScale = 1;
  4916. if (timelineName === "scale")
  4917. timeline = new spine.ScaleTimeline(timelineMap.length);
  4918. else if (timelineName === "shear")
  4919. timeline = new spine.ShearTimeline(timelineMap.length);
  4920. else {
  4921. timeline = new spine.TranslateTimeline(timelineMap.length);
  4922. timelineScale = scale;
  4923. }
  4924. timeline.boneIndex = boneIndex;
  4925. var frameIndex = 0;
  4926. for (var i = 0; i < timelineMap.length; i++) {
  4927. var valueMap = timelineMap[i];
  4928. var x = this.getValue(valueMap, "x", 0), y = this.getValue(valueMap, "y", 0);
  4929. timeline.setFrame(frameIndex, valueMap.time, x * timelineScale, y * timelineScale);
  4930. this.readCurve(valueMap, timeline, frameIndex);
  4931. frameIndex++;
  4932. }
  4933. timelines.push(timeline);
  4934. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TranslateTimeline.ENTRIES]);
  4935. }
  4936. else
  4937. throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
  4938. }
  4939. }
  4940. }
  4941. if (map.ik) {
  4942. for (var constraintName in map.ik) {
  4943. var constraintMap = map.ik[constraintName];
  4944. var constraint = skeletonData.findIkConstraint(constraintName);
  4945. var timeline = new spine.IkConstraintTimeline(constraintMap.length);
  4946. timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint);
  4947. var frameIndex = 0;
  4948. for (var i = 0; i < constraintMap.length; i++) {
  4949. var valueMap = constraintMap[i];
  4950. timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "bendPositive", true) ? 1 : -1, this.getValue(valueMap, "compress", false), this.getValue(valueMap, "stretch", false));
  4951. this.readCurve(valueMap, timeline, frameIndex);
  4952. frameIndex++;
  4953. }
  4954. timelines.push(timeline);
  4955. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.IkConstraintTimeline.ENTRIES]);
  4956. }
  4957. }
  4958. if (map.transform) {
  4959. for (var constraintName in map.transform) {
  4960. var constraintMap = map.transform[constraintName];
  4961. var constraint = skeletonData.findTransformConstraint(constraintName);
  4962. var timeline = new spine.TransformConstraintTimeline(constraintMap.length);
  4963. timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint);
  4964. var frameIndex = 0;
  4965. for (var i = 0; i < constraintMap.length; i++) {
  4966. var valueMap = constraintMap[i];
  4967. timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1));
  4968. this.readCurve(valueMap, timeline, frameIndex);
  4969. frameIndex++;
  4970. }
  4971. timelines.push(timeline);
  4972. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TransformConstraintTimeline.ENTRIES]);
  4973. }
  4974. }
  4975. if (map.paths) {
  4976. for (var constraintName in map.paths) {
  4977. var constraintMap = map.paths[constraintName];
  4978. var index = skeletonData.findPathConstraintIndex(constraintName);
  4979. if (index == -1)
  4980. throw new Error("Path constraint not found: " + constraintName);
  4981. var data = skeletonData.pathConstraints[index];
  4982. for (var timelineName in constraintMap) {
  4983. var timelineMap = constraintMap[timelineName];
  4984. if (timelineName === "position" || timelineName === "spacing") {
  4985. var timeline = null;
  4986. var timelineScale = 1;
  4987. if (timelineName === "spacing") {
  4988. timeline = new spine.PathConstraintSpacingTimeline(timelineMap.length);
  4989. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  4990. timelineScale = scale;
  4991. }
  4992. else {
  4993. timeline = new spine.PathConstraintPositionTimeline(timelineMap.length);
  4994. if (data.positionMode == spine.PositionMode.Fixed)
  4995. timelineScale = scale;
  4996. }
  4997. timeline.pathConstraintIndex = index;
  4998. var frameIndex = 0;
  4999. for (var i = 0; i < timelineMap.length; i++) {
  5000. var valueMap = timelineMap[i];
  5001. timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, timelineName, 0) * timelineScale);
  5002. this.readCurve(valueMap, timeline, frameIndex);
  5003. frameIndex++;
  5004. }
  5005. timelines.push(timeline);
  5006. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
  5007. }
  5008. else if (timelineName === "mix") {
  5009. var timeline = new spine.PathConstraintMixTimeline(timelineMap.length);
  5010. timeline.pathConstraintIndex = index;
  5011. var frameIndex = 0;
  5012. for (var i = 0; i < timelineMap.length; i++) {
  5013. var valueMap = timelineMap[i];
  5014. timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1));
  5015. this.readCurve(valueMap, timeline, frameIndex);
  5016. frameIndex++;
  5017. }
  5018. timelines.push(timeline);
  5019. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
  5020. }
  5021. }
  5022. }
  5023. }
  5024. if (map.deform) {
  5025. for (var deformName in map.deform) {
  5026. var deformMap = map.deform[deformName];
  5027. var skin = skeletonData.findSkin(deformName);
  5028. if (skin == null)
  5029. throw new Error("Skin not found: " + deformName);
  5030. for (var slotName in deformMap) {
  5031. var slotMap = deformMap[slotName];
  5032. var slotIndex = skeletonData.findSlotIndex(slotName);
  5033. if (slotIndex == -1)
  5034. throw new Error("Slot not found: " + slotMap.name);
  5035. for (var timelineName in slotMap) {
  5036. var timelineMap = slotMap[timelineName];
  5037. var attachment = skin.getAttachment(slotIndex, timelineName);
  5038. if (attachment == null)
  5039. // throw new Error("Deform attachment not found: " + timelineMap.name);
  5040. continue;
  5041. var weighted = attachment.bones != null;
  5042. var vertices = attachment.vertices;
  5043. var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
  5044. var timeline = new spine.DeformTimeline(timelineMap.length);
  5045. timeline.slotIndex = slotIndex;
  5046. timeline.attachment = attachment;
  5047. var frameIndex = 0;
  5048. for (var j = 0; j < timelineMap.length; j++) {
  5049. var valueMap = timelineMap[j];
  5050. var deform = void 0;
  5051. var verticesValue = this.getValue(valueMap, "vertices", null);
  5052. if (verticesValue == null)
  5053. deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
  5054. else {
  5055. deform = spine.Utils.newFloatArray(deformLength);
  5056. var start = this.getValue(valueMap, "offset", 0);
  5057. spine.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length);
  5058. if (scale != 1) {
  5059. for (var i = start, n = i + verticesValue.length; i < n; i++)
  5060. deform[i] *= scale;
  5061. }
  5062. if (!weighted) {
  5063. for (var i = 0; i < deformLength; i++)
  5064. deform[i] += vertices[i];
  5065. }
  5066. }
  5067. timeline.setFrame(frameIndex, valueMap.time, deform);
  5068. this.readCurve(valueMap, timeline, frameIndex);
  5069. frameIndex++;
  5070. }
  5071. timelines.push(timeline);
  5072. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  5073. }
  5074. }
  5075. }
  5076. }
  5077. var drawOrderNode = map.drawOrder;
  5078. if (drawOrderNode == null)
  5079. drawOrderNode = map.draworder;
  5080. if (drawOrderNode != null) {
  5081. var timeline = new spine.DrawOrderTimeline(drawOrderNode.length);
  5082. var slotCount = skeletonData.slots.length;
  5083. var frameIndex = 0;
  5084. for (var j = 0; j < drawOrderNode.length; j++) {
  5085. var drawOrderMap = drawOrderNode[j];
  5086. var drawOrder = null;
  5087. var offsets = this.getValue(drawOrderMap, "offsets", null);
  5088. if (offsets != null) {
  5089. drawOrder = spine.Utils.newArray(slotCount, -1);
  5090. var unchanged = spine.Utils.newArray(slotCount - offsets.length, 0);
  5091. var originalIndex = 0, unchangedIndex = 0;
  5092. for (var i = 0; i < offsets.length; i++) {
  5093. var offsetMap = offsets[i];
  5094. var slotIndex = skeletonData.findSlotIndex(offsetMap.slot);
  5095. if (slotIndex == -1)
  5096. throw new Error("Slot not found: " + offsetMap.slot);
  5097. while (originalIndex != slotIndex)
  5098. unchanged[unchangedIndex++] = originalIndex++;
  5099. drawOrder[originalIndex + offsetMap.offset] = originalIndex++;
  5100. }
  5101. while (originalIndex < slotCount)
  5102. unchanged[unchangedIndex++] = originalIndex++;
  5103. for (var i = slotCount - 1; i >= 0; i--)
  5104. if (drawOrder[i] == -1)
  5105. drawOrder[i] = unchanged[--unchangedIndex];
  5106. }
  5107. timeline.setFrame(frameIndex++, drawOrderMap.time, drawOrder);
  5108. }
  5109. timelines.push(timeline);
  5110. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  5111. }
  5112. if (map.events) {
  5113. var timeline = new spine.EventTimeline(map.events.length);
  5114. var frameIndex = 0;
  5115. for (var i = 0; i < map.events.length; i++) {
  5116. var eventMap = map.events[i];
  5117. var eventData = skeletonData.findEvent(eventMap.name);
  5118. if (eventData == null)
  5119. throw new Error("Event not found: " + eventMap.name);
  5120. var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData);
  5121. event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
  5122. event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
  5123. event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
  5124. if (event_5.data.audioPath != null) {
  5125. event_5.volume = this.getValue(eventMap, "volume", 1);
  5126. event_5.balance = this.getValue(eventMap, "balance", 0);
  5127. }
  5128. timeline.setFrame(frameIndex++, event_5);
  5129. }
  5130. timelines.push(timeline);
  5131. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  5132. }
  5133. if (isNaN(duration)) {
  5134. throw new Error("Error while parsing animation, duration is NaN");
  5135. }
  5136. skeletonData.animations.push(new spine.Animation(name, timelines, duration));
  5137. };
  5138. SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) {
  5139. if (!map.curve)
  5140. return;
  5141. if (map.curve === "stepped")
  5142. timeline.setStepped(frameIndex);
  5143. else if (Object.prototype.toString.call(map.curve) === '[object Array]') {
  5144. var curve = map.curve;
  5145. timeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]);
  5146. }
  5147. };
  5148. SkeletonJson.prototype.getValue = function (map, prop, defaultValue) {
  5149. return map[prop] !== undefined ? map[prop] : defaultValue;
  5150. };
  5151. SkeletonJson.blendModeFromString = function (str) {
  5152. str = str.toLowerCase();
  5153. if (str == "normal")
  5154. return spine.BlendMode.Normal;
  5155. if (str == "additive")
  5156. return spine.BlendMode.Additive;
  5157. if (str == "multiply")
  5158. return spine.BlendMode.Multiply;
  5159. if (str == "screen")
  5160. return spine.BlendMode.Screen;
  5161. throw new Error("Unknown blend mode: " + str);
  5162. };
  5163. SkeletonJson.positionModeFromString = function (str) {
  5164. str = str.toLowerCase();
  5165. if (str == "fixed")
  5166. return spine.PositionMode.Fixed;
  5167. if (str == "percent")
  5168. return spine.PositionMode.Percent;
  5169. throw new Error("Unknown position mode: " + str);
  5170. };
  5171. SkeletonJson.spacingModeFromString = function (str) {
  5172. str = str.toLowerCase();
  5173. if (str == "length")
  5174. return spine.SpacingMode.Length;
  5175. if (str == "fixed")
  5176. return spine.SpacingMode.Fixed;
  5177. if (str == "percent")
  5178. return spine.SpacingMode.Percent;
  5179. throw new Error("Unknown position mode: " + str);
  5180. };
  5181. SkeletonJson.rotateModeFromString = function (str) {
  5182. str = str.toLowerCase();
  5183. if (str == "tangent")
  5184. return spine.RotateMode.Tangent;
  5185. if (str == "chain")
  5186. return spine.RotateMode.Chain;
  5187. if (str == "chainscale")
  5188. return spine.RotateMode.ChainScale;
  5189. throw new Error("Unknown rotate mode: " + str);
  5190. };
  5191. SkeletonJson.transformModeFromString = function (str) {
  5192. str = str.toLowerCase();
  5193. if (str == "normal")
  5194. return spine.TransformMode.Normal;
  5195. if (str == "onlytranslation")
  5196. return spine.TransformMode.OnlyTranslation;
  5197. if (str == "norotationorreflection")
  5198. return spine.TransformMode.NoRotationOrReflection;
  5199. if (str == "noscale")
  5200. return spine.TransformMode.NoScale;
  5201. if (str == "noscaleorreflection")
  5202. return spine.TransformMode.NoScaleOrReflection;
  5203. throw new Error("Unknown transform mode: " + str);
  5204. };
  5205. return SkeletonJson;
  5206. }());
  5207. spine.SkeletonJson = SkeletonJson;
  5208. var LinkedMesh = (function () {
  5209. function LinkedMesh(mesh, skin, slotIndex, parent) {
  5210. this.mesh = mesh;
  5211. this.skin = skin;
  5212. this.slotIndex = slotIndex;
  5213. this.parent = parent;
  5214. }
  5215. return LinkedMesh;
  5216. }());
  5217. })(spine || (spine = {}));
  5218. var spine;
  5219. (function (spine) {
  5220. var Skin = (function () {
  5221. function Skin(name) {
  5222. this.attachments = new Array();
  5223. if (name == null)
  5224. throw new Error("name cannot be null.");
  5225. this.name = name;
  5226. }
  5227. Skin.prototype.addAttachment = function (slotIndex, name, attachment) {
  5228. if (attachment == null)
  5229. throw new Error("attachment cannot be null.");
  5230. var attachments = this.attachments;
  5231. if (slotIndex >= attachments.length)
  5232. attachments.length = slotIndex + 1;
  5233. if (!attachments[slotIndex])
  5234. attachments[slotIndex] = {};
  5235. attachments[slotIndex][name] = attachment;
  5236. };
  5237. Skin.prototype.getAttachment = function (slotIndex, name) {
  5238. var dictionary = this.attachments[slotIndex];
  5239. return dictionary ? dictionary[name] : null;
  5240. };
  5241. Skin.prototype.attachAll = function (skeleton, oldSkin) {
  5242. var slotIndex = 0;
  5243. for (var i = 0; i < skeleton.slots.length; i++) {
  5244. var slot = skeleton.slots[i];
  5245. var slotAttachment = slot.getAttachment();
  5246. if (slotAttachment && slotIndex < oldSkin.attachments.length) {
  5247. var dictionary = oldSkin.attachments[slotIndex];
  5248. for (var key in dictionary) {
  5249. var skinAttachment = dictionary[key];
  5250. if (slotAttachment == skinAttachment) {
  5251. var attachment = this.getAttachment(slotIndex, key);
  5252. if (attachment != null)
  5253. slot.setAttachment(attachment);
  5254. break;
  5255. }
  5256. }
  5257. }
  5258. slotIndex++;
  5259. }
  5260. };
  5261. return Skin;
  5262. }());
  5263. spine.Skin = Skin;
  5264. })(spine || (spine = {}));
  5265. var spine;
  5266. (function (spine) {
  5267. var Slot = (function () {
  5268. function Slot(data, bone) {
  5269. this.attachmentVertices = new Array();
  5270. if (data == null)
  5271. throw new Error("data cannot be null.");
  5272. if (bone == null)
  5273. throw new Error("bone cannot be null.");
  5274. this.data = data;
  5275. this.bone = bone;
  5276. this.color = new spine.Color();
  5277. this.darkColor = data.darkColor == null ? null : new spine.Color();
  5278. this.setToSetupPose();
  5279. }
  5280. Slot.prototype.getAttachment = function () {
  5281. return this.attachment;
  5282. };
  5283. Slot.prototype.setAttachment = function (attachment) {
  5284. if (this.attachment == attachment)
  5285. return;
  5286. this.attachment = attachment;
  5287. this.attachmentTime = this.bone.skeleton.time;
  5288. this.attachmentVertices.length = 0;
  5289. };
  5290. Slot.prototype.setAttachmentTime = function (time) {
  5291. this.attachmentTime = this.bone.skeleton.time - time;
  5292. };
  5293. Slot.prototype.getAttachmentTime = function () {
  5294. return this.bone.skeleton.time - this.attachmentTime;
  5295. };
  5296. Slot.prototype.setToSetupPose = function () {
  5297. this.color.setFromColor(this.data.color);
  5298. if (this.darkColor != null)
  5299. this.darkColor.setFromColor(this.data.darkColor);
  5300. if (this.data.attachmentName == null)
  5301. this.attachment = null;
  5302. else {
  5303. this.attachment = null;
  5304. this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName));
  5305. }
  5306. };
  5307. return Slot;
  5308. }());
  5309. spine.Slot = Slot;
  5310. })(spine || (spine = {}));
  5311. var spine;
  5312. (function (spine) {
  5313. var SlotData = (function () {
  5314. function SlotData(index, name, boneData) {
  5315. this.color = new spine.Color(1, 1, 1, 1);
  5316. if (index < 0)
  5317. throw new Error("index must be >= 0.");
  5318. if (name == null)
  5319. throw new Error("name cannot be null.");
  5320. if (boneData == null)
  5321. throw new Error("boneData cannot be null.");
  5322. this.index = index;
  5323. this.name = name;
  5324. this.boneData = boneData;
  5325. }
  5326. return SlotData;
  5327. }());
  5328. spine.SlotData = SlotData;
  5329. })(spine || (spine = {}));
  5330. var spine;
  5331. (function (spine) {
  5332. var Texture = (function () {
  5333. function Texture(image) {
  5334. this._image = image;
  5335. }
  5336. Texture.prototype.getImage = function () {
  5337. return this._image;
  5338. };
  5339. Texture.filterFromString = function (text) {
  5340. switch (text.toLowerCase()) {
  5341. case "nearest": return TextureFilter.Nearest;
  5342. case "linear": return TextureFilter.Linear;
  5343. case "mipmap": return TextureFilter.MipMap;
  5344. case "mipmapnearestnearest": return TextureFilter.MipMapNearestNearest;
  5345. case "mipmaplinearnearest": return TextureFilter.MipMapLinearNearest;
  5346. case "mipmapnearestlinear": return TextureFilter.MipMapNearestLinear;
  5347. case "mipmaplinearlinear": return TextureFilter.MipMapLinearLinear;
  5348. default: throw new Error("Unknown texture filter " + text);
  5349. }
  5350. };
  5351. Texture.wrapFromString = function (text) {
  5352. switch (text.toLowerCase()) {
  5353. case "mirroredtepeat": return TextureWrap.MirroredRepeat;
  5354. case "clamptoedge": return TextureWrap.ClampToEdge;
  5355. case "repeat": return TextureWrap.Repeat;
  5356. default: throw new Error("Unknown texture wrap " + text);
  5357. }
  5358. };
  5359. return Texture;
  5360. }());
  5361. spine.Texture = Texture;
  5362. var TextureFilter;
  5363. (function (TextureFilter) {
  5364. TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest";
  5365. TextureFilter[TextureFilter["Linear"] = 9729] = "Linear";
  5366. TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap";
  5367. TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest";
  5368. TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest";
  5369. TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear";
  5370. TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear";
  5371. })(TextureFilter = spine.TextureFilter || (spine.TextureFilter = {}));
  5372. var TextureWrap;
  5373. (function (TextureWrap) {
  5374. TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat";
  5375. TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge";
  5376. TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat";
  5377. })(TextureWrap = spine.TextureWrap || (spine.TextureWrap = {}));
  5378. var TextureRegion = (function () {
  5379. function TextureRegion() {
  5380. this.u = 0;
  5381. this.v = 0;
  5382. this.u2 = 0;
  5383. this.v2 = 0;
  5384. this.width = 0;
  5385. this.height = 0;
  5386. this.rotate = false;
  5387. this.offsetX = 0;
  5388. this.offsetY = 0;
  5389. this.originalWidth = 0;
  5390. this.originalHeight = 0;
  5391. }
  5392. return TextureRegion;
  5393. }());
  5394. spine.TextureRegion = TextureRegion;
  5395. var FakeTexture = (function (_super) {
  5396. __extends(FakeTexture, _super);
  5397. function FakeTexture() {
  5398. return _super !== null && _super.apply(this, arguments) || this;
  5399. }
  5400. FakeTexture.prototype.setFilters = function (minFilter, magFilter) { };
  5401. FakeTexture.prototype.setWraps = function (uWrap, vWrap) { };
  5402. FakeTexture.prototype.dispose = function () { };
  5403. return FakeTexture;
  5404. }(Texture));
  5405. spine.FakeTexture = FakeTexture;
  5406. })(spine || (spine = {}));
  5407. var spine;
  5408. (function (spine) {
  5409. var TextureAtlas = (function () {
  5410. function TextureAtlas(atlasText, textureLoader) {
  5411. this.pages = new Array();
  5412. this.regions = new Array();
  5413. this.load(atlasText, textureLoader);
  5414. }
  5415. TextureAtlas.prototype.load = function (atlasText, textureLoader) {
  5416. if (textureLoader == null)
  5417. throw new Error("textureLoader cannot be null.");
  5418. var reader = new TextureAtlasReader(atlasText);
  5419. var tuple = new Array(4);
  5420. var page = null;
  5421. while (true) {
  5422. var line = reader.readLine();
  5423. if (line == null)
  5424. break;
  5425. line = line.trim();
  5426. if (line.length == 0)
  5427. page = null;
  5428. else if (!page) {
  5429. page = new TextureAtlasPage();
  5430. page.name = line;
  5431. if (reader.readTuple(tuple) == 2) {
  5432. page.width = parseInt(tuple[0]);
  5433. page.height = parseInt(tuple[1]);
  5434. reader.readTuple(tuple);
  5435. }
  5436. reader.readTuple(tuple);
  5437. page.minFilter = spine.Texture.filterFromString(tuple[0]);
  5438. page.magFilter = spine.Texture.filterFromString(tuple[1]);
  5439. var direction = reader.readValue();
  5440. page.uWrap = spine.TextureWrap.ClampToEdge;
  5441. page.vWrap = spine.TextureWrap.ClampToEdge;
  5442. if (direction == "x")
  5443. page.uWrap = spine.TextureWrap.Repeat;
  5444. else if (direction == "y")
  5445. page.vWrap = spine.TextureWrap.Repeat;
  5446. else if (direction == "xy")
  5447. page.uWrap = page.vWrap = spine.TextureWrap.Repeat;
  5448. page.texture = textureLoader(line);
  5449. page.texture.setFilters(page.minFilter, page.magFilter);
  5450. page.texture.setWraps(page.uWrap, page.vWrap);
  5451. page.width = page.texture.getImage().width;
  5452. page.height = page.texture.getImage().height;
  5453. this.pages.push(page);
  5454. }
  5455. else {
  5456. var region = new TextureAtlasRegion();
  5457. region.name = line;
  5458. region.page = page;
  5459. region.rotate = reader.readValue() == "true";
  5460. reader.readTuple(tuple);
  5461. var x = parseInt(tuple[0]);
  5462. var y = parseInt(tuple[1]);
  5463. reader.readTuple(tuple);
  5464. var width = parseInt(tuple[0]);
  5465. var height = parseInt(tuple[1]);
  5466. region.u = x / page.width;
  5467. region.v = y / page.height;
  5468. if (region.rotate) {
  5469. region.u2 = (x + height) / page.width;
  5470. region.v2 = (y + width) / page.height;
  5471. }
  5472. else {
  5473. region.u2 = (x + width) / page.width;
  5474. region.v2 = (y + height) / page.height;
  5475. }
  5476. region.x = x;
  5477. region.y = y;
  5478. region.width = Math.abs(width);
  5479. region.height = Math.abs(height);
  5480. if (reader.readTuple(tuple) == 4) {
  5481. if (reader.readTuple(tuple) == 4) {
  5482. reader.readTuple(tuple);
  5483. }
  5484. }
  5485. region.originalWidth = parseInt(tuple[0]);
  5486. region.originalHeight = parseInt(tuple[1]);
  5487. reader.readTuple(tuple);
  5488. region.offsetX = parseInt(tuple[0]);
  5489. region.offsetY = parseInt(tuple[1]);
  5490. region.index = parseInt(reader.readValue());
  5491. region.texture = page.texture;
  5492. this.regions.push(region);
  5493. }
  5494. }
  5495. };
  5496. TextureAtlas.prototype.findRegion = function (name) {
  5497. for (var i = 0; i < this.regions.length; i++) {
  5498. if (this.regions[i].name == name) {
  5499. return this.regions[i];
  5500. }
  5501. }
  5502. return null;
  5503. };
  5504. TextureAtlas.prototype.dispose = function () {
  5505. for (var i = 0; i < this.pages.length; i++) {
  5506. this.pages[i].texture.dispose();
  5507. }
  5508. };
  5509. return TextureAtlas;
  5510. }());
  5511. spine.TextureAtlas = TextureAtlas;
  5512. var TextureAtlasReader = (function () {
  5513. function TextureAtlasReader(text) {
  5514. this.index = 0;
  5515. this.lines = text.split(/\r\n|\r|\n/);
  5516. }
  5517. TextureAtlasReader.prototype.readLine = function () {
  5518. if (this.index >= this.lines.length)
  5519. return null;
  5520. return this.lines[this.index++];
  5521. };
  5522. TextureAtlasReader.prototype.readValue = function () {
  5523. var line = this.readLine();
  5524. var colon = line.indexOf(":");
  5525. if (colon == -1)
  5526. throw new Error("Invalid line: " + line);
  5527. return line.substring(colon + 1).trim();
  5528. };
  5529. TextureAtlasReader.prototype.readTuple = function (tuple) {
  5530. var line = this.readLine();
  5531. var colon = line.indexOf(":");
  5532. if (colon == -1)
  5533. throw new Error("Invalid line: " + line);
  5534. var i = 0, lastMatch = colon + 1;
  5535. for (; i < 3; i++) {
  5536. var comma = line.indexOf(",", lastMatch);
  5537. if (comma == -1)
  5538. break;
  5539. tuple[i] = line.substr(lastMatch, comma - lastMatch).trim();
  5540. lastMatch = comma + 1;
  5541. }
  5542. tuple[i] = line.substring(lastMatch).trim();
  5543. return i + 1;
  5544. };
  5545. return TextureAtlasReader;
  5546. }());
  5547. var TextureAtlasPage = (function () {
  5548. function TextureAtlasPage() {
  5549. }
  5550. return TextureAtlasPage;
  5551. }());
  5552. spine.TextureAtlasPage = TextureAtlasPage;
  5553. var TextureAtlasRegion = (function (_super) {
  5554. __extends(TextureAtlasRegion, _super);
  5555. function TextureAtlasRegion() {
  5556. return _super !== null && _super.apply(this, arguments) || this;
  5557. }
  5558. return TextureAtlasRegion;
  5559. }(spine.TextureRegion));
  5560. spine.TextureAtlasRegion = TextureAtlasRegion;
  5561. })(spine || (spine = {}));
  5562. var spine;
  5563. (function (spine) {
  5564. var TransformConstraint = (function () {
  5565. function TransformConstraint(data, skeleton) {
  5566. this.rotateMix = 0;
  5567. this.translateMix = 0;
  5568. this.scaleMix = 0;
  5569. this.shearMix = 0;
  5570. this.temp = new spine.Vector2();
  5571. if (data == null)
  5572. throw new Error("data cannot be null.");
  5573. if (skeleton == null)
  5574. throw new Error("skeleton cannot be null.");
  5575. this.data = data;
  5576. this.rotateMix = data.rotateMix;
  5577. this.translateMix = data.translateMix;
  5578. this.scaleMix = data.scaleMix;
  5579. this.shearMix = data.shearMix;
  5580. this.bones = new Array();
  5581. for (var i = 0; i < data.bones.length; i++)
  5582. this.bones.push(skeleton.findBone(data.bones[i].name));
  5583. this.target = skeleton.findBone(data.target.name);
  5584. }
  5585. TransformConstraint.prototype.apply = function () {
  5586. this.update();
  5587. };
  5588. TransformConstraint.prototype.update = function () {
  5589. if (this.data.local) {
  5590. if (this.data.relative)
  5591. this.applyRelativeLocal();
  5592. else
  5593. this.applyAbsoluteLocal();
  5594. }
  5595. else {
  5596. if (this.data.relative)
  5597. this.applyRelativeWorld();
  5598. else
  5599. this.applyAbsoluteWorld();
  5600. }
  5601. };
  5602. TransformConstraint.prototype.applyAbsoluteWorld = function () {
  5603. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  5604. var target = this.target;
  5605. var ta = target.a, tb = target.b, tc = target.c, td = target.d;
  5606. var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  5607. var offsetRotation = this.data.offsetRotation * degRadReflect;
  5608. var offsetShearY = this.data.offsetShearY * degRadReflect;
  5609. var bones = this.bones;
  5610. for (var i = 0, n = bones.length; i < n; i++) {
  5611. var bone = bones[i];
  5612. var modified = false;
  5613. if (rotateMix != 0) {
  5614. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  5615. var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
  5616. if (r > spine.MathUtils.PI)
  5617. r -= spine.MathUtils.PI2;
  5618. else if (r < -spine.MathUtils.PI)
  5619. r += spine.MathUtils.PI2;
  5620. r *= rotateMix;
  5621. var cos = Math.cos(r), sin = Math.sin(r);
  5622. bone.a = cos * a - sin * c;
  5623. bone.b = cos * b - sin * d;
  5624. bone.c = sin * a + cos * c;
  5625. bone.d = sin * b + cos * d;
  5626. modified = true;
  5627. }
  5628. if (translateMix != 0) {
  5629. var temp = this.temp;
  5630. target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));
  5631. bone.worldX += (temp.x - bone.worldX) * translateMix;
  5632. bone.worldY += (temp.y - bone.worldY) * translateMix;
  5633. modified = true;
  5634. }
  5635. if (scaleMix > 0) {
  5636. var s = Math.sqrt(bone.a * bone.a + bone.c * bone.c);
  5637. var ts = Math.sqrt(ta * ta + tc * tc);
  5638. if (s > 0.00001)
  5639. s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s;
  5640. bone.a *= s;
  5641. bone.c *= s;
  5642. s = Math.sqrt(bone.b * bone.b + bone.d * bone.d);
  5643. ts = Math.sqrt(tb * tb + td * td);
  5644. if (s > 0.00001)
  5645. s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s;
  5646. bone.b *= s;
  5647. bone.d *= s;
  5648. modified = true;
  5649. }
  5650. if (shearMix > 0) {
  5651. var b = bone.b, d = bone.d;
  5652. var by = Math.atan2(d, b);
  5653. var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(bone.c, bone.a));
  5654. if (r > spine.MathUtils.PI)
  5655. r -= spine.MathUtils.PI2;
  5656. else if (r < -spine.MathUtils.PI)
  5657. r += spine.MathUtils.PI2;
  5658. r = by + (r + offsetShearY) * shearMix;
  5659. var s = Math.sqrt(b * b + d * d);
  5660. bone.b = Math.cos(r) * s;
  5661. bone.d = Math.sin(r) * s;
  5662. modified = true;
  5663. }
  5664. if (modified)
  5665. bone.appliedValid = false;
  5666. }
  5667. };
  5668. TransformConstraint.prototype.applyRelativeWorld = function () {
  5669. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  5670. var target = this.target;
  5671. var ta = target.a, tb = target.b, tc = target.c, td = target.d;
  5672. var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  5673. var offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect;
  5674. var bones = this.bones;
  5675. for (var i = 0, n = bones.length; i < n; i++) {
  5676. var bone = bones[i];
  5677. var modified = false;
  5678. if (rotateMix != 0) {
  5679. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  5680. var r = Math.atan2(tc, ta) + offsetRotation;
  5681. if (r > spine.MathUtils.PI)
  5682. r -= spine.MathUtils.PI2;
  5683. else if (r < -spine.MathUtils.PI)
  5684. r += spine.MathUtils.PI2;
  5685. r *= rotateMix;
  5686. var cos = Math.cos(r), sin = Math.sin(r);
  5687. bone.a = cos * a - sin * c;
  5688. bone.b = cos * b - sin * d;
  5689. bone.c = sin * a + cos * c;
  5690. bone.d = sin * b + cos * d;
  5691. modified = true;
  5692. }
  5693. if (translateMix != 0) {
  5694. var temp = this.temp;
  5695. target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));
  5696. bone.worldX += temp.x * translateMix;
  5697. bone.worldY += temp.y * translateMix;
  5698. modified = true;
  5699. }
  5700. if (scaleMix > 0) {
  5701. var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1;
  5702. bone.a *= s;
  5703. bone.c *= s;
  5704. s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1;
  5705. bone.b *= s;
  5706. bone.d *= s;
  5707. modified = true;
  5708. }
  5709. if (shearMix > 0) {
  5710. var r = Math.atan2(td, tb) - Math.atan2(tc, ta);
  5711. if (r > spine.MathUtils.PI)
  5712. r -= spine.MathUtils.PI2;
  5713. else if (r < -spine.MathUtils.PI)
  5714. r += spine.MathUtils.PI2;
  5715. var b = bone.b, d = bone.d;
  5716. r = Math.atan2(d, b) + (r - spine.MathUtils.PI / 2 + offsetShearY) * shearMix;
  5717. var s = Math.sqrt(b * b + d * d);
  5718. bone.b = Math.cos(r) * s;
  5719. bone.d = Math.sin(r) * s;
  5720. modified = true;
  5721. }
  5722. if (modified)
  5723. bone.appliedValid = false;
  5724. }
  5725. };
  5726. TransformConstraint.prototype.applyAbsoluteLocal = function () {
  5727. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  5728. var target = this.target;
  5729. if (!target.appliedValid)
  5730. target.updateAppliedTransform();
  5731. var bones = this.bones;
  5732. for (var i = 0, n = bones.length; i < n; i++) {
  5733. var bone = bones[i];
  5734. if (!bone.appliedValid)
  5735. bone.updateAppliedTransform();
  5736. var rotation = bone.arotation;
  5737. if (rotateMix != 0) {
  5738. var r = target.arotation - rotation + this.data.offsetRotation;
  5739. r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
  5740. rotation += r * rotateMix;
  5741. }
  5742. var x = bone.ax, y = bone.ay;
  5743. if (translateMix != 0) {
  5744. x += (target.ax - x + this.data.offsetX) * translateMix;
  5745. y += (target.ay - y + this.data.offsetY) * translateMix;
  5746. }
  5747. var scaleX = bone.ascaleX, scaleY = bone.ascaleY;
  5748. if (scaleMix != 0) {
  5749. if (scaleX > 0.00001)
  5750. scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX;
  5751. if (scaleY > 0.00001)
  5752. scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY;
  5753. }
  5754. var shearY = bone.ashearY;
  5755. if (shearMix != 0) {
  5756. var r = target.ashearY - shearY + this.data.offsetShearY;
  5757. r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
  5758. bone.shearY += r * shearMix;
  5759. }
  5760. bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
  5761. }
  5762. };
  5763. TransformConstraint.prototype.applyRelativeLocal = function () {
  5764. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  5765. var target = this.target;
  5766. if (!target.appliedValid)
  5767. target.updateAppliedTransform();
  5768. var bones = this.bones;
  5769. for (var i = 0, n = bones.length; i < n; i++) {
  5770. var bone = bones[i];
  5771. if (!bone.appliedValid)
  5772. bone.updateAppliedTransform();
  5773. var rotation = bone.arotation;
  5774. if (rotateMix != 0)
  5775. rotation += (target.arotation + this.data.offsetRotation) * rotateMix;
  5776. var x = bone.ax, y = bone.ay;
  5777. if (translateMix != 0) {
  5778. x += (target.ax + this.data.offsetX) * translateMix;
  5779. y += (target.ay + this.data.offsetY) * translateMix;
  5780. }
  5781. var scaleX = bone.ascaleX, scaleY = bone.ascaleY;
  5782. if (scaleMix != 0) {
  5783. if (scaleX > 0.00001)
  5784. scaleX *= ((target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix) + 1;
  5785. if (scaleY > 0.00001)
  5786. scaleY *= ((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1;
  5787. }
  5788. var shearY = bone.ashearY;
  5789. if (shearMix != 0)
  5790. shearY += (target.ashearY + this.data.offsetShearY) * shearMix;
  5791. bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
  5792. }
  5793. };
  5794. TransformConstraint.prototype.getOrder = function () {
  5795. return this.data.order;
  5796. };
  5797. return TransformConstraint;
  5798. }());
  5799. spine.TransformConstraint = TransformConstraint;
  5800. })(spine || (spine = {}));
  5801. var spine;
  5802. (function (spine) {
  5803. var TransformConstraintData = (function () {
  5804. function TransformConstraintData(name) {
  5805. this.order = 0;
  5806. this.bones = new Array();
  5807. this.rotateMix = 0;
  5808. this.translateMix = 0;
  5809. this.scaleMix = 0;
  5810. this.shearMix = 0;
  5811. this.offsetRotation = 0;
  5812. this.offsetX = 0;
  5813. this.offsetY = 0;
  5814. this.offsetScaleX = 0;
  5815. this.offsetScaleY = 0;
  5816. this.offsetShearY = 0;
  5817. this.relative = false;
  5818. this.local = false;
  5819. if (name == null)
  5820. throw new Error("name cannot be null.");
  5821. this.name = name;
  5822. }
  5823. return TransformConstraintData;
  5824. }());
  5825. spine.TransformConstraintData = TransformConstraintData;
  5826. })(spine || (spine = {}));
  5827. var spine;
  5828. (function (spine) {
  5829. var Triangulator = (function () {
  5830. function Triangulator() {
  5831. this.convexPolygons = new Array();
  5832. this.convexPolygonsIndices = new Array();
  5833. this.indicesArray = new Array();
  5834. this.isConcaveArray = new Array();
  5835. this.triangles = new Array();
  5836. this.polygonPool = new spine.Pool(function () {
  5837. return new Array();
  5838. });
  5839. this.polygonIndicesPool = new spine.Pool(function () {
  5840. return new Array();
  5841. });
  5842. }
  5843. Triangulator.prototype.triangulate = function (verticesArray) {
  5844. var vertices = verticesArray;
  5845. var vertexCount = verticesArray.length >> 1;
  5846. var indices = this.indicesArray;
  5847. indices.length = 0;
  5848. for (var i = 0; i < vertexCount; i++)
  5849. indices[i] = i;
  5850. var isConcave = this.isConcaveArray;
  5851. isConcave.length = 0;
  5852. for (var i = 0, n = vertexCount; i < n; ++i)
  5853. isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices);
  5854. var triangles = this.triangles;
  5855. triangles.length = 0;
  5856. while (vertexCount > 3) {
  5857. var previous = vertexCount - 1, i = 0, next = 1;
  5858. while (true) {
  5859. outer: if (!isConcave[i]) {
  5860. var p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1;
  5861. var p1x = vertices[p1], p1y = vertices[p1 + 1];
  5862. var p2x = vertices[p2], p2y = vertices[p2 + 1];
  5863. var p3x = vertices[p3], p3y = vertices[p3 + 1];
  5864. for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) {
  5865. if (!isConcave[ii])
  5866. continue;
  5867. var v = indices[ii] << 1;
  5868. var vx = vertices[v], vy = vertices[v + 1];
  5869. if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) {
  5870. if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) {
  5871. if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy))
  5872. break outer;
  5873. }
  5874. }
  5875. }
  5876. break;
  5877. }
  5878. if (next == 0) {
  5879. do {
  5880. if (!isConcave[i])
  5881. break;
  5882. i--;
  5883. } while (i > 0);
  5884. break;
  5885. }
  5886. previous = i;
  5887. i = next;
  5888. next = (next + 1) % vertexCount;
  5889. }
  5890. triangles.push(indices[(vertexCount + i - 1) % vertexCount]);
  5891. triangles.push(indices[i]);
  5892. triangles.push(indices[(i + 1) % vertexCount]);
  5893. indices.splice(i, 1);
  5894. isConcave.splice(i, 1);
  5895. vertexCount--;
  5896. var previousIndex = (vertexCount + i - 1) % vertexCount;
  5897. var nextIndex = i == vertexCount ? 0 : i;
  5898. isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices);
  5899. isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices);
  5900. }
  5901. if (vertexCount == 3) {
  5902. triangles.push(indices[2]);
  5903. triangles.push(indices[0]);
  5904. triangles.push(indices[1]);
  5905. }
  5906. return triangles;
  5907. };
  5908. Triangulator.prototype.decompose = function (verticesArray, triangles) {
  5909. var vertices = verticesArray;
  5910. var convexPolygons = this.convexPolygons;
  5911. this.polygonPool.freeAll(convexPolygons);
  5912. convexPolygons.length = 0;
  5913. var convexPolygonsIndices = this.convexPolygonsIndices;
  5914. this.polygonIndicesPool.freeAll(convexPolygonsIndices);
  5915. convexPolygonsIndices.length = 0;
  5916. var polygonIndices = this.polygonIndicesPool.obtain();
  5917. polygonIndices.length = 0;
  5918. var polygon = this.polygonPool.obtain();
  5919. polygon.length = 0;
  5920. var fanBaseIndex = -1, lastWinding = 0;
  5921. for (var i = 0, n = triangles.length; i < n; i += 3) {
  5922. var t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1;
  5923. var x1 = vertices[t1], y1 = vertices[t1 + 1];
  5924. var x2 = vertices[t2], y2 = vertices[t2 + 1];
  5925. var x3 = vertices[t3], y3 = vertices[t3 + 1];
  5926. var merged = false;
  5927. if (fanBaseIndex == t1) {
  5928. var o = polygon.length - 4;
  5929. var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3);
  5930. var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]);
  5931. if (winding1 == lastWinding && winding2 == lastWinding) {
  5932. polygon.push(x3);
  5933. polygon.push(y3);
  5934. polygonIndices.push(t3);
  5935. merged = true;
  5936. }
  5937. }
  5938. if (!merged) {
  5939. if (polygon.length > 0) {
  5940. convexPolygons.push(polygon);
  5941. convexPolygonsIndices.push(polygonIndices);
  5942. }
  5943. else {
  5944. this.polygonPool.free(polygon);
  5945. this.polygonIndicesPool.free(polygonIndices);
  5946. }
  5947. polygon = this.polygonPool.obtain();
  5948. polygon.length = 0;
  5949. polygon.push(x1);
  5950. polygon.push(y1);
  5951. polygon.push(x2);
  5952. polygon.push(y2);
  5953. polygon.push(x3);
  5954. polygon.push(y3);
  5955. polygonIndices = this.polygonIndicesPool.obtain();
  5956. polygonIndices.length = 0;
  5957. polygonIndices.push(t1);
  5958. polygonIndices.push(t2);
  5959. polygonIndices.push(t3);
  5960. lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3);
  5961. fanBaseIndex = t1;
  5962. }
  5963. }
  5964. if (polygon.length > 0) {
  5965. convexPolygons.push(polygon);
  5966. convexPolygonsIndices.push(polygonIndices);
  5967. }
  5968. for (var i = 0, n = convexPolygons.length; i < n; i++) {
  5969. polygonIndices = convexPolygonsIndices[i];
  5970. if (polygonIndices.length == 0)
  5971. continue;
  5972. var firstIndex = polygonIndices[0];
  5973. var lastIndex = polygonIndices[polygonIndices.length - 1];
  5974. polygon = convexPolygons[i];
  5975. var o = polygon.length - 4;
  5976. var prevPrevX = polygon[o], prevPrevY = polygon[o + 1];
  5977. var prevX = polygon[o + 2], prevY = polygon[o + 3];
  5978. var firstX = polygon[0], firstY = polygon[1];
  5979. var secondX = polygon[2], secondY = polygon[3];
  5980. var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY);
  5981. for (var ii = 0; ii < n; ii++) {
  5982. if (ii == i)
  5983. continue;
  5984. var otherIndices = convexPolygonsIndices[ii];
  5985. if (otherIndices.length != 3)
  5986. continue;
  5987. var otherFirstIndex = otherIndices[0];
  5988. var otherSecondIndex = otherIndices[1];
  5989. var otherLastIndex = otherIndices[2];
  5990. var otherPoly = convexPolygons[ii];
  5991. var x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1];
  5992. if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex)
  5993. continue;
  5994. var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3);
  5995. var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY);
  5996. if (winding1 == winding && winding2 == winding) {
  5997. otherPoly.length = 0;
  5998. otherIndices.length = 0;
  5999. polygon.push(x3);
  6000. polygon.push(y3);
  6001. polygonIndices.push(otherLastIndex);
  6002. prevPrevX = prevX;
  6003. prevPrevY = prevY;
  6004. prevX = x3;
  6005. prevY = y3;
  6006. ii = 0;
  6007. }
  6008. }
  6009. }
  6010. for (var i = convexPolygons.length - 1; i >= 0; i--) {
  6011. polygon = convexPolygons[i];
  6012. if (polygon.length == 0) {
  6013. convexPolygons.splice(i, 1);
  6014. this.polygonPool.free(polygon);
  6015. polygonIndices = convexPolygonsIndices[i];
  6016. convexPolygonsIndices.splice(i, 1);
  6017. this.polygonIndicesPool.free(polygonIndices);
  6018. }
  6019. }
  6020. return convexPolygons;
  6021. };
  6022. Triangulator.isConcave = function (index, vertexCount, vertices, indices) {
  6023. var previous = indices[(vertexCount + index - 1) % vertexCount] << 1;
  6024. var current = indices[index] << 1;
  6025. var next = indices[(index + 1) % vertexCount] << 1;
  6026. return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]);
  6027. };
  6028. Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) {
  6029. return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0;
  6030. };
  6031. Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) {
  6032. var px = p2x - p1x, py = p2y - p1y;
  6033. return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1;
  6034. };
  6035. return Triangulator;
  6036. }());
  6037. spine.Triangulator = Triangulator;
  6038. })(spine || (spine = {}));
  6039. var spine;
  6040. (function (spine) {
  6041. var IntSet = (function () {
  6042. function IntSet() {
  6043. this.array = new Array();
  6044. }
  6045. IntSet.prototype.add = function (value) {
  6046. var contains = this.contains(value);
  6047. this.array[value | 0] = value | 0;
  6048. return !contains;
  6049. };
  6050. IntSet.prototype.contains = function (value) {
  6051. return this.array[value | 0] != undefined;
  6052. };
  6053. IntSet.prototype.remove = function (value) {
  6054. this.array[value | 0] = undefined;
  6055. };
  6056. IntSet.prototype.clear = function () {
  6057. this.array.length = 0;
  6058. };
  6059. return IntSet;
  6060. }());
  6061. spine.IntSet = IntSet;
  6062. var Color = (function () {
  6063. function Color(r, g, b, a) {
  6064. if (r === void 0) { r = 0; }
  6065. if (g === void 0) { g = 0; }
  6066. if (b === void 0) { b = 0; }
  6067. if (a === void 0) { a = 0; }
  6068. this.r = r;
  6069. this.g = g;
  6070. this.b = b;
  6071. this.a = a;
  6072. }
  6073. Color.prototype.set = function (r, g, b, a) {
  6074. this.r = r;
  6075. this.g = g;
  6076. this.b = b;
  6077. this.a = a;
  6078. this.clamp();
  6079. return this;
  6080. };
  6081. Color.prototype.setFromColor = function (c) {
  6082. this.r = c.r;
  6083. this.g = c.g;
  6084. this.b = c.b;
  6085. this.a = c.a;
  6086. return this;
  6087. };
  6088. Color.prototype.setFromString = function (hex) {
  6089. hex = hex.charAt(0) == '#' ? hex.substr(1) : hex;
  6090. this.r = parseInt(hex.substr(0, 2), 16) / 255.0;
  6091. this.g = parseInt(hex.substr(2, 2), 16) / 255.0;
  6092. this.b = parseInt(hex.substr(4, 2), 16) / 255.0;
  6093. this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0;
  6094. return this;
  6095. };
  6096. Color.prototype.add = function (r, g, b, a) {
  6097. this.r += r;
  6098. this.g += g;
  6099. this.b += b;
  6100. this.a += a;
  6101. this.clamp();
  6102. return this;
  6103. };
  6104. Color.prototype.clamp = function () {
  6105. if (this.r < 0)
  6106. this.r = 0;
  6107. else if (this.r > 1)
  6108. this.r = 1;
  6109. if (this.g < 0)
  6110. this.g = 0;
  6111. else if (this.g > 1)
  6112. this.g = 1;
  6113. if (this.b < 0)
  6114. this.b = 0;
  6115. else if (this.b > 1)
  6116. this.b = 1;
  6117. if (this.a < 0)
  6118. this.a = 0;
  6119. else if (this.a > 1)
  6120. this.a = 1;
  6121. return this;
  6122. };
  6123. Color.WHITE = new Color(1, 1, 1, 1);
  6124. Color.RED = new Color(1, 0, 0, 1);
  6125. Color.GREEN = new Color(0, 1, 0, 1);
  6126. Color.BLUE = new Color(0, 0, 1, 1);
  6127. Color.MAGENTA = new Color(1, 0, 1, 1);
  6128. return Color;
  6129. }());
  6130. spine.Color = Color;
  6131. var MathUtils = (function () {
  6132. function MathUtils() {
  6133. }
  6134. MathUtils.clamp = function (value, min, max) {
  6135. if (value < min)
  6136. return min;
  6137. if (value > max)
  6138. return max;
  6139. return value;
  6140. };
  6141. MathUtils.cosDeg = function (degrees) {
  6142. return Math.cos(degrees * MathUtils.degRad);
  6143. };
  6144. MathUtils.sinDeg = function (degrees) {
  6145. return Math.sin(degrees * MathUtils.degRad);
  6146. };
  6147. MathUtils.signum = function (value) {
  6148. return value > 0 ? 1 : value < 0 ? -1 : 0;
  6149. };
  6150. MathUtils.toInt = function (x) {
  6151. return x > 0 ? Math.floor(x) : Math.ceil(x);
  6152. };
  6153. MathUtils.cbrt = function (x) {
  6154. var y = Math.pow(Math.abs(x), 1 / 3);
  6155. return x < 0 ? -y : y;
  6156. };
  6157. MathUtils.randomTriangular = function (min, max) {
  6158. return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
  6159. };
  6160. MathUtils.randomTriangularWith = function (min, max, mode) {
  6161. var u = Math.random();
  6162. var d = max - min;
  6163. if (u <= (mode - min) / d)
  6164. return min + Math.sqrt(u * d * (mode - min));
  6165. return max - Math.sqrt((1 - u) * d * (max - mode));
  6166. };
  6167. MathUtils.PI = 3.1415927;
  6168. MathUtils.PI2 = MathUtils.PI * 2;
  6169. MathUtils.radiansToDegrees = 180 / MathUtils.PI;
  6170. MathUtils.radDeg = MathUtils.radiansToDegrees;
  6171. MathUtils.degreesToRadians = MathUtils.PI / 180;
  6172. MathUtils.degRad = MathUtils.degreesToRadians;
  6173. return MathUtils;
  6174. }());
  6175. spine.MathUtils = MathUtils;
  6176. var Interpolation = (function () {
  6177. function Interpolation() {
  6178. }
  6179. Interpolation.prototype.apply = function (start, end, a) {
  6180. return start + (end - start) * this.applyInternal(a);
  6181. };
  6182. return Interpolation;
  6183. }());
  6184. spine.Interpolation = Interpolation;
  6185. var Pow = (function (_super) {
  6186. __extends(Pow, _super);
  6187. function Pow(power) {
  6188. var _this = _super.call(this) || this;
  6189. _this.power = 2;
  6190. _this.power = power;
  6191. return _this;
  6192. }
  6193. Pow.prototype.applyInternal = function (a) {
  6194. if (a <= 0.5)
  6195. return Math.pow(a * 2, this.power) / 2;
  6196. return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
  6197. };
  6198. return Pow;
  6199. }(Interpolation));
  6200. spine.Pow = Pow;
  6201. var PowOut = (function (_super) {
  6202. __extends(PowOut, _super);
  6203. function PowOut(power) {
  6204. return _super.call(this, power) || this;
  6205. }
  6206. PowOut.prototype.applyInternal = function (a) {
  6207. return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
  6208. };
  6209. return PowOut;
  6210. }(Pow));
  6211. spine.PowOut = PowOut;
  6212. var Utils = (function () {
  6213. function Utils() {
  6214. }
  6215. Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) {
  6216. for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) {
  6217. dest[j] = source[i];
  6218. }
  6219. };
  6220. Utils.setArraySize = function (array, size, value) {
  6221. if (value === void 0) { value = 0; }
  6222. var oldSize = array.length;
  6223. if (oldSize == size)
  6224. return array;
  6225. array.length = size;
  6226. if (oldSize < size) {
  6227. for (var i = oldSize; i < size; i++)
  6228. array[i] = value;
  6229. }
  6230. return array;
  6231. };
  6232. Utils.ensureArrayCapacity = function (array, size, value) {
  6233. if (value === void 0) { value = 0; }
  6234. if (array.length >= size)
  6235. return array;
  6236. return Utils.setArraySize(array, size, value);
  6237. };
  6238. Utils.newArray = function (size, defaultValue) {
  6239. var array = new Array(size);
  6240. for (var i = 0; i < size; i++)
  6241. array[i] = defaultValue;
  6242. return array;
  6243. };
  6244. Utils.newFloatArray = function (size) {
  6245. if (Utils.SUPPORTS_TYPED_ARRAYS) {
  6246. return new Float32Array(size);
  6247. }
  6248. else {
  6249. var array = new Array(size);
  6250. for (var i = 0; i < array.length; i++)
  6251. array[i] = 0;
  6252. return array;
  6253. }
  6254. };
  6255. Utils.newShortArray = function (size) {
  6256. if (Utils.SUPPORTS_TYPED_ARRAYS) {
  6257. return new Int16Array(size);
  6258. }
  6259. else {
  6260. var array = new Array(size);
  6261. for (var i = 0; i < array.length; i++)
  6262. array[i] = 0;
  6263. return array;
  6264. }
  6265. };
  6266. Utils.toFloatArray = function (array) {
  6267. return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
  6268. };
  6269. Utils.toSinglePrecision = function (value) {
  6270. return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
  6271. };
  6272. Utils.webkit602BugfixHelper = function (alpha, blend) {
  6273. };
  6274. Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";
  6275. return Utils;
  6276. }());
  6277. spine.Utils = Utils;
  6278. var DebugUtils = (function () {
  6279. function DebugUtils() {
  6280. }
  6281. DebugUtils.logBones = function (skeleton) {
  6282. for (var i = 0; i < skeleton.bones.length; i++) {
  6283. var bone = skeleton.bones[i];
  6284. console.log(bone.data.name + ", " + bone.a + ", " + bone.b + ", " + bone.c + ", " + bone.d + ", " + bone.worldX + ", " + bone.worldY);
  6285. }
  6286. };
  6287. return DebugUtils;
  6288. }());
  6289. spine.DebugUtils = DebugUtils;
  6290. var Pool = (function () {
  6291. function Pool(instantiator) {
  6292. this.items = new Array();
  6293. this.instantiator = instantiator;
  6294. }
  6295. Pool.prototype.obtain = function () {
  6296. return this.items.length > 0 ? this.items.pop() : this.instantiator();
  6297. };
  6298. Pool.prototype.free = function (item) {
  6299. if (item.reset)
  6300. item.reset();
  6301. this.items.push(item);
  6302. };
  6303. Pool.prototype.freeAll = function (items) {
  6304. for (var i = 0; i < items.length; i++) {
  6305. if (items[i].reset)
  6306. items[i].reset();
  6307. this.items[i] = items[i];
  6308. }
  6309. };
  6310. Pool.prototype.clear = function () {
  6311. this.items.length = 0;
  6312. };
  6313. return Pool;
  6314. }());
  6315. spine.Pool = Pool;
  6316. var Vector2 = (function () {
  6317. function Vector2(x, y) {
  6318. if (x === void 0) { x = 0; }
  6319. if (y === void 0) { y = 0; }
  6320. this.x = x;
  6321. this.y = y;
  6322. }
  6323. Vector2.prototype.set = function (x, y) {
  6324. this.x = x;
  6325. this.y = y;
  6326. return this;
  6327. };
  6328. Vector2.prototype.length = function () {
  6329. var x = this.x;
  6330. var y = this.y;
  6331. return Math.sqrt(x * x + y * y);
  6332. };
  6333. Vector2.prototype.normalize = function () {
  6334. var len = this.length();
  6335. if (len != 0) {
  6336. this.x /= len;
  6337. this.y /= len;
  6338. }
  6339. return this;
  6340. };
  6341. return Vector2;
  6342. }());
  6343. spine.Vector2 = Vector2;
  6344. var TimeKeeper = (function () {
  6345. function TimeKeeper() {
  6346. this.maxDelta = 0.064;
  6347. this.framesPerSecond = 0;
  6348. this.delta = 0;
  6349. this.totalTime = 0;
  6350. this.lastTime = Date.now() / 1000;
  6351. this.frameCount = 0;
  6352. this.frameTime = 0;
  6353. }
  6354. TimeKeeper.prototype.update = function () {
  6355. var now = Date.now() / 1000;
  6356. this.delta = now - this.lastTime;
  6357. this.frameTime += this.delta;
  6358. this.totalTime += this.delta;
  6359. if (this.delta > this.maxDelta)
  6360. this.delta = this.maxDelta;
  6361. this.lastTime = now;
  6362. this.frameCount++;
  6363. if (this.frameTime > 1) {
  6364. this.framesPerSecond = this.frameCount / this.frameTime;
  6365. this.frameTime = 0;
  6366. this.frameCount = 0;
  6367. }
  6368. };
  6369. return TimeKeeper;
  6370. }());
  6371. spine.TimeKeeper = TimeKeeper;
  6372. var WindowedMean = (function () {
  6373. function WindowedMean(windowSize) {
  6374. if (windowSize === void 0) { windowSize = 32; }
  6375. this.addedValues = 0;
  6376. this.lastValue = 0;
  6377. this.mean = 0;
  6378. this.dirty = true;
  6379. this.values = new Array(windowSize);
  6380. }
  6381. WindowedMean.prototype.hasEnoughData = function () {
  6382. return this.addedValues >= this.values.length;
  6383. };
  6384. WindowedMean.prototype.addValue = function (value) {
  6385. if (this.addedValues < this.values.length)
  6386. this.addedValues++;
  6387. this.values[this.lastValue++] = value;
  6388. if (this.lastValue > this.values.length - 1)
  6389. this.lastValue = 0;
  6390. this.dirty = true;
  6391. };
  6392. WindowedMean.prototype.getMean = function () {
  6393. if (this.hasEnoughData()) {
  6394. if (this.dirty) {
  6395. var mean = 0;
  6396. for (var i = 0; i < this.values.length; i++) {
  6397. mean += this.values[i];
  6398. }
  6399. this.mean = mean / this.values.length;
  6400. this.dirty = false;
  6401. }
  6402. return this.mean;
  6403. }
  6404. else {
  6405. return 0;
  6406. }
  6407. };
  6408. return WindowedMean;
  6409. }());
  6410. spine.WindowedMean = WindowedMean;
  6411. })(spine || (spine = {}));
  6412. (function () {
  6413. if (!Math.fround) {
  6414. Math.fround = (function (array) {
  6415. return function (x) {
  6416. return array[0] = x, array[0];
  6417. };
  6418. })(new Float32Array(1));
  6419. }
  6420. })();
  6421. var spine;
  6422. (function (spine) {
  6423. var Attachment = (function () {
  6424. function Attachment(name) {
  6425. if (name == null)
  6426. throw new Error("name cannot be null.");
  6427. this.name = name;
  6428. }
  6429. return Attachment;
  6430. }());
  6431. spine.Attachment = Attachment;
  6432. var VertexAttachment = (function (_super) {
  6433. __extends(VertexAttachment, _super);
  6434. function VertexAttachment(name) {
  6435. var _this = _super.call(this, name) || this;
  6436. _this.id = (VertexAttachment.nextID++ & 65535) << 11;
  6437. _this.worldVerticesLength = 0;
  6438. return _this;
  6439. }
  6440. VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
  6441. count = offset + (count >> 1) * stride;
  6442. var skeleton = slot.bone.skeleton;
  6443. var deformArray = slot.attachmentVertices;
  6444. var vertices = this.vertices;
  6445. var bones = this.bones;
  6446. if (bones == null) {
  6447. if (deformArray.length > 0)
  6448. vertices = deformArray;
  6449. var bone = slot.bone;
  6450. var x = bone.worldX;
  6451. var y = bone.worldY;
  6452. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  6453. for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) {
  6454. var vx = vertices[v_1], vy = vertices[v_1 + 1];
  6455. worldVertices[w] = vx * a + vy * b + x;
  6456. worldVertices[w + 1] = vx * c + vy * d + y;
  6457. }
  6458. return;
  6459. }
  6460. var v = 0, skip = 0;
  6461. for (var i = 0; i < start; i += 2) {
  6462. var n = bones[v];
  6463. v += n + 1;
  6464. skip += n;
  6465. }
  6466. var skeletonBones = skeleton.bones;
  6467. if (deformArray.length == 0) {
  6468. for (var w = offset, b = skip * 3; w < count; w += stride) {
  6469. var wx = 0, wy = 0;
  6470. var n = bones[v++];
  6471. n += v;
  6472. for (; v < n; v++, b += 3) {
  6473. var bone = skeletonBones[bones[v]];
  6474. var vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2];
  6475. wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
  6476. wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
  6477. }
  6478. worldVertices[w] = wx;
  6479. worldVertices[w + 1] = wy;
  6480. }
  6481. }
  6482. else {
  6483. var deform = deformArray;
  6484. for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) {
  6485. var wx = 0, wy = 0;
  6486. var n = bones[v++];
  6487. n += v;
  6488. for (; v < n; v++, b += 3, f += 2) {
  6489. var bone = skeletonBones[bones[v]];
  6490. var vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2];
  6491. wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
  6492. wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
  6493. }
  6494. worldVertices[w] = wx;
  6495. worldVertices[w + 1] = wy;
  6496. }
  6497. }
  6498. };
  6499. VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
  6500. return this == sourceAttachment;
  6501. };
  6502. VertexAttachment.nextID = 0;
  6503. return VertexAttachment;
  6504. }(Attachment));
  6505. spine.VertexAttachment = VertexAttachment;
  6506. })(spine || (spine = {}));
  6507. var spine;
  6508. (function (spine) {
  6509. var AttachmentType;
  6510. (function (AttachmentType) {
  6511. AttachmentType[AttachmentType["Region"] = 0] = "Region";
  6512. AttachmentType[AttachmentType["BoundingBox"] = 1] = "BoundingBox";
  6513. AttachmentType[AttachmentType["Mesh"] = 2] = "Mesh";
  6514. AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh";
  6515. AttachmentType[AttachmentType["Path"] = 4] = "Path";
  6516. AttachmentType[AttachmentType["Point"] = 5] = "Point";
  6517. })(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {}));
  6518. })(spine || (spine = {}));
  6519. var spine;
  6520. (function (spine) {
  6521. var BoundingBoxAttachment = (function (_super) {
  6522. __extends(BoundingBoxAttachment, _super);
  6523. function BoundingBoxAttachment(name) {
  6524. var _this = _super.call(this, name) || this;
  6525. _this.color = new spine.Color(1, 1, 1, 1);
  6526. return _this;
  6527. }
  6528. return BoundingBoxAttachment;
  6529. }(spine.VertexAttachment));
  6530. spine.BoundingBoxAttachment = BoundingBoxAttachment;
  6531. })(spine || (spine = {}));
  6532. var spine;
  6533. (function (spine) {
  6534. var ClippingAttachment = (function (_super) {
  6535. __extends(ClippingAttachment, _super);
  6536. function ClippingAttachment(name) {
  6537. var _this = _super.call(this, name) || this;
  6538. _this.color = new spine.Color(0.2275, 0.2275, 0.8078, 1);
  6539. return _this;
  6540. }
  6541. return ClippingAttachment;
  6542. }(spine.VertexAttachment));
  6543. spine.ClippingAttachment = ClippingAttachment;
  6544. })(spine || (spine = {}));
  6545. var spine;
  6546. (function (spine) {
  6547. var MeshAttachment = (function (_super) {
  6548. __extends(MeshAttachment, _super);
  6549. function MeshAttachment(name) {
  6550. var _this = _super.call(this, name) || this;
  6551. _this.color = new spine.Color(1, 1, 1, 1);
  6552. _this.inheritDeform = false;
  6553. _this.tempColor = new spine.Color(0, 0, 0, 0);
  6554. return _this;
  6555. }
  6556. MeshAttachment.prototype.updateUVs = function () {
  6557. var regionUVs = this.regionUVs;
  6558. if (this.uvs == null || this.uvs.length != regionUVs.length)
  6559. this.uvs = spine.Utils.newFloatArray(regionUVs.length);
  6560. var uvs = this.uvs;
  6561. var u = 0, v = 0, width = 0, height = 0;
  6562. if (this.region instanceof spine.TextureAtlasRegion) {
  6563. var region = this.region;
  6564. var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
  6565. if (region.rotate) {
  6566. u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
  6567. v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
  6568. width = region.originalHeight / textureWidth;
  6569. height = region.originalWidth / textureHeight;
  6570. for (var i = 0, n = uvs.length; i < n; i += 2) {
  6571. uvs[i] = u + regionUVs[i + 1] * width;
  6572. uvs[i + 1] = v + height - regionUVs[i] * height;
  6573. }
  6574. return;
  6575. }
  6576. u = region.u - region.offsetX / textureWidth;
  6577. v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
  6578. width = region.originalWidth / textureWidth;
  6579. height = region.originalHeight / textureHeight;
  6580. }
  6581. else if (this.region == null) {
  6582. u = v = 0;
  6583. width = height = 1;
  6584. }
  6585. else {
  6586. u = this.region.u;
  6587. v = this.region.v;
  6588. width = this.region.u2 - u;
  6589. height = this.region.v2 - v;
  6590. }
  6591. for (var i = 0, n = uvs.length; i < n; i += 2) {
  6592. uvs[i] = u + regionUVs[i] * width;
  6593. uvs[i + 1] = v + regionUVs[i + 1] * height;
  6594. }
  6595. };
  6596. MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
  6597. return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);
  6598. };
  6599. MeshAttachment.prototype.getParentMesh = function () {
  6600. return this.parentMesh;
  6601. };
  6602. MeshAttachment.prototype.setParentMesh = function (parentMesh) {
  6603. this.parentMesh = parentMesh;
  6604. if (parentMesh != null) {
  6605. this.bones = parentMesh.bones;
  6606. this.vertices = parentMesh.vertices;
  6607. this.worldVerticesLength = parentMesh.worldVerticesLength;
  6608. this.regionUVs = parentMesh.regionUVs;
  6609. this.triangles = parentMesh.triangles;
  6610. this.hullLength = parentMesh.hullLength;
  6611. this.worldVerticesLength = parentMesh.worldVerticesLength;
  6612. }
  6613. };
  6614. return MeshAttachment;
  6615. }(spine.VertexAttachment));
  6616. spine.MeshAttachment = MeshAttachment;
  6617. })(spine || (spine = {}));
  6618. var spine;
  6619. (function (spine) {
  6620. var PathAttachment = (function (_super) {
  6621. __extends(PathAttachment, _super);
  6622. function PathAttachment(name) {
  6623. var _this = _super.call(this, name) || this;
  6624. _this.closed = false;
  6625. _this.constantSpeed = false;
  6626. _this.color = new spine.Color(1, 1, 1, 1);
  6627. return _this;
  6628. }
  6629. return PathAttachment;
  6630. }(spine.VertexAttachment));
  6631. spine.PathAttachment = PathAttachment;
  6632. })(spine || (spine = {}));
  6633. var spine;
  6634. (function (spine) {
  6635. var PointAttachment = (function (_super) {
  6636. __extends(PointAttachment, _super);
  6637. function PointAttachment(name) {
  6638. var _this = _super.call(this, name) || this;
  6639. _this.color = new spine.Color(0.38, 0.94, 0, 1);
  6640. return _this;
  6641. }
  6642. PointAttachment.prototype.computeWorldPosition = function (bone, point) {
  6643. point.x = this.x * bone.a + this.y * bone.b + bone.worldX;
  6644. point.y = this.x * bone.c + this.y * bone.d + bone.worldY;
  6645. return point;
  6646. };
  6647. PointAttachment.prototype.computeWorldRotation = function (bone) {
  6648. var cos = spine.MathUtils.cosDeg(this.rotation), sin = spine.MathUtils.sinDeg(this.rotation);
  6649. var x = cos * bone.a + sin * bone.b;
  6650. var y = cos * bone.c + sin * bone.d;
  6651. return Math.atan2(y, x) * spine.MathUtils.radDeg;
  6652. };
  6653. return PointAttachment;
  6654. }(spine.VertexAttachment));
  6655. spine.PointAttachment = PointAttachment;
  6656. })(spine || (spine = {}));
  6657. var spine;
  6658. (function (spine) {
  6659. var RegionAttachment = (function (_super) {
  6660. __extends(RegionAttachment, _super);
  6661. function RegionAttachment(name) {
  6662. var _this = _super.call(this, name) || this;
  6663. _this.x = 0;
  6664. _this.y = 0;
  6665. _this.scaleX = 1;
  6666. _this.scaleY = 1;
  6667. _this.rotation = 0;
  6668. _this.width = 0;
  6669. _this.height = 0;
  6670. _this.color = new spine.Color(1, 1, 1, 1);
  6671. _this.offset = spine.Utils.newFloatArray(8);
  6672. _this.uvs = spine.Utils.newFloatArray(8);
  6673. _this.tempColor = new spine.Color(1, 1, 1, 1);
  6674. return _this;
  6675. }
  6676. RegionAttachment.prototype.updateOffset = function () {
  6677. var regionScaleX = this.width / this.region.originalWidth * this.scaleX;
  6678. var regionScaleY = this.height / this.region.originalHeight * this.scaleY;
  6679. var localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX;
  6680. var localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY;
  6681. var localX2 = localX + this.region.width * regionScaleX;
  6682. var localY2 = localY + this.region.height * regionScaleY;
  6683. var radians = this.rotation * Math.PI / 180;
  6684. var cos = Math.cos(radians);
  6685. var sin = Math.sin(radians);
  6686. var localXCos = localX * cos + this.x;
  6687. var localXSin = localX * sin;
  6688. var localYCos = localY * cos + this.y;
  6689. var localYSin = localY * sin;
  6690. var localX2Cos = localX2 * cos + this.x;
  6691. var localX2Sin = localX2 * sin;
  6692. var localY2Cos = localY2 * cos + this.y;
  6693. var localY2Sin = localY2 * sin;
  6694. var offset = this.offset;
  6695. offset[RegionAttachment.OX1] = localXCos - localYSin;
  6696. offset[RegionAttachment.OY1] = localYCos + localXSin;
  6697. offset[RegionAttachment.OX2] = localXCos - localY2Sin;
  6698. offset[RegionAttachment.OY2] = localY2Cos + localXSin;
  6699. offset[RegionAttachment.OX3] = localX2Cos - localY2Sin;
  6700. offset[RegionAttachment.OY3] = localY2Cos + localX2Sin;
  6701. offset[RegionAttachment.OX4] = localX2Cos - localYSin;
  6702. offset[RegionAttachment.OY4] = localYCos + localX2Sin;
  6703. };
  6704. RegionAttachment.prototype.setRegion = function (region) {
  6705. this.region = region;
  6706. var uvs = this.uvs;
  6707. if (region.rotate) {
  6708. uvs[2] = region.u;
  6709. uvs[3] = region.v2;
  6710. uvs[4] = region.u;
  6711. uvs[5] = region.v;
  6712. uvs[6] = region.u2;
  6713. uvs[7] = region.v;
  6714. uvs[0] = region.u2;
  6715. uvs[1] = region.v2;
  6716. }
  6717. else {
  6718. uvs[0] = region.u;
  6719. uvs[1] = region.v2;
  6720. uvs[2] = region.u;
  6721. uvs[3] = region.v;
  6722. uvs[4] = region.u2;
  6723. uvs[5] = region.v;
  6724. uvs[6] = region.u2;
  6725. uvs[7] = region.v2;
  6726. }
  6727. };
  6728. RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) {
  6729. var vertexOffset = this.offset;
  6730. var x = bone.worldX, y = bone.worldY;
  6731. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  6732. var offsetX = 0, offsetY = 0;
  6733. offsetX = vertexOffset[RegionAttachment.OX1];
  6734. offsetY = vertexOffset[RegionAttachment.OY1];
  6735. worldVertices[offset] = offsetX * a + offsetY * b + x;
  6736. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  6737. offset += stride;
  6738. offsetX = vertexOffset[RegionAttachment.OX2];
  6739. offsetY = vertexOffset[RegionAttachment.OY2];
  6740. worldVertices[offset] = offsetX * a + offsetY * b + x;
  6741. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  6742. offset += stride;
  6743. offsetX = vertexOffset[RegionAttachment.OX3];
  6744. offsetY = vertexOffset[RegionAttachment.OY3];
  6745. worldVertices[offset] = offsetX * a + offsetY * b + x;
  6746. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  6747. offset += stride;
  6748. offsetX = vertexOffset[RegionAttachment.OX4];
  6749. offsetY = vertexOffset[RegionAttachment.OY4];
  6750. worldVertices[offset] = offsetX * a + offsetY * b + x;
  6751. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  6752. };
  6753. RegionAttachment.OX1 = 0;
  6754. RegionAttachment.OY1 = 1;
  6755. RegionAttachment.OX2 = 2;
  6756. RegionAttachment.OY2 = 3;
  6757. RegionAttachment.OX3 = 4;
  6758. RegionAttachment.OY3 = 5;
  6759. RegionAttachment.OX4 = 6;
  6760. RegionAttachment.OY4 = 7;
  6761. RegionAttachment.X1 = 0;
  6762. RegionAttachment.Y1 = 1;
  6763. RegionAttachment.C1R = 2;
  6764. RegionAttachment.C1G = 3;
  6765. RegionAttachment.C1B = 4;
  6766. RegionAttachment.C1A = 5;
  6767. RegionAttachment.U1 = 6;
  6768. RegionAttachment.V1 = 7;
  6769. RegionAttachment.X2 = 8;
  6770. RegionAttachment.Y2 = 9;
  6771. RegionAttachment.C2R = 10;
  6772. RegionAttachment.C2G = 11;
  6773. RegionAttachment.C2B = 12;
  6774. RegionAttachment.C2A = 13;
  6775. RegionAttachment.U2 = 14;
  6776. RegionAttachment.V2 = 15;
  6777. RegionAttachment.X3 = 16;
  6778. RegionAttachment.Y3 = 17;
  6779. RegionAttachment.C3R = 18;
  6780. RegionAttachment.C3G = 19;
  6781. RegionAttachment.C3B = 20;
  6782. RegionAttachment.C3A = 21;
  6783. RegionAttachment.U3 = 22;
  6784. RegionAttachment.V3 = 23;
  6785. RegionAttachment.X4 = 24;
  6786. RegionAttachment.Y4 = 25;
  6787. RegionAttachment.C4R = 26;
  6788. RegionAttachment.C4G = 27;
  6789. RegionAttachment.C4B = 28;
  6790. RegionAttachment.C4A = 29;
  6791. RegionAttachment.U4 = 30;
  6792. RegionAttachment.V4 = 31;
  6793. return RegionAttachment;
  6794. }(spine.Attachment));
  6795. spine.RegionAttachment = RegionAttachment;
  6796. })(spine || (spine = {}));
  6797. var spine;
  6798. (function (spine) {
  6799. var JitterEffect = (function () {
  6800. function JitterEffect(jitterX, jitterY) {
  6801. this.jitterX = 0;
  6802. this.jitterY = 0;
  6803. this.jitterX = jitterX;
  6804. this.jitterY = jitterY;
  6805. }
  6806. JitterEffect.prototype.begin = function (skeleton) {
  6807. };
  6808. JitterEffect.prototype.transform = function (position, uv, light, dark) {
  6809. position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
  6810. position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
  6811. };
  6812. JitterEffect.prototype.end = function () {
  6813. };
  6814. return JitterEffect;
  6815. }());
  6816. spine.JitterEffect = JitterEffect;
  6817. })(spine || (spine = {}));
  6818. var spine;
  6819. (function (spine) {
  6820. var SwirlEffect = (function () {
  6821. function SwirlEffect(radius) {
  6822. this.centerX = 0;
  6823. this.centerY = 0;
  6824. this.radius = 0;
  6825. this.angle = 0;
  6826. this.worldX = 0;
  6827. this.worldY = 0;
  6828. this.radius = radius;
  6829. }
  6830. SwirlEffect.prototype.begin = function (skeleton) {
  6831. this.worldX = skeleton.x + this.centerX;
  6832. this.worldY = skeleton.y + this.centerY;
  6833. };
  6834. SwirlEffect.prototype.transform = function (position, uv, light, dark) {
  6835. var radAngle = this.angle * spine.MathUtils.degreesToRadians;
  6836. var x = position.x - this.worldX;
  6837. var y = position.y - this.worldY;
  6838. var dist = Math.sqrt(x * x + y * y);
  6839. if (dist < this.radius) {
  6840. var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
  6841. var cos = Math.cos(theta);
  6842. var sin = Math.sin(theta);
  6843. position.x = cos * x - sin * y + this.worldX;
  6844. position.y = sin * x + cos * y + this.worldY;
  6845. }
  6846. };
  6847. SwirlEffect.prototype.end = function () {
  6848. };
  6849. SwirlEffect.interpolation = new spine.PowOut(2);
  6850. return SwirlEffect;
  6851. }());
  6852. spine.SwirlEffect = SwirlEffect;
  6853. })(spine || (spine = {}));
  6854. var spine;
  6855. (function (spine) {
  6856. var webgl;
  6857. (function (webgl) {
  6858. var AssetManager = (function (_super) {
  6859. __extends(AssetManager, _super);
  6860. function AssetManager(context, pathPrefix) {
  6861. if (pathPrefix === void 0) { pathPrefix = ""; }
  6862. return _super.call(this, function (image) {
  6863. return new spine.webgl.GLTexture(context, image);
  6864. }, pathPrefix) || this;
  6865. }
  6866. return AssetManager;
  6867. }(spine.AssetManager));
  6868. webgl.AssetManager = AssetManager;
  6869. })(webgl = spine.webgl || (spine.webgl = {}));
  6870. })(spine || (spine = {}));
  6871. var spine;
  6872. (function (spine) {
  6873. var webgl;
  6874. (function (webgl) {
  6875. var OrthoCamera = (function () {
  6876. function OrthoCamera(viewportWidth, viewportHeight) {
  6877. this.position = new webgl.Vector3(0, 0, 0);
  6878. this.direction = new webgl.Vector3(0, 0, -1);
  6879. this.up = new webgl.Vector3(0, 1, 0);
  6880. this.near = 0;
  6881. this.far = 100;
  6882. this.zoom = 1;
  6883. this.viewportWidth = 0;
  6884. this.viewportHeight = 0;
  6885. this.projectionView = new webgl.Matrix4();
  6886. this.inverseProjectionView = new webgl.Matrix4();
  6887. this.projection = new webgl.Matrix4();
  6888. this.view = new webgl.Matrix4();
  6889. this.tmp = new webgl.Vector3();
  6890. this.viewportWidth = viewportWidth;
  6891. this.viewportHeight = viewportHeight;
  6892. this.update();
  6893. }
  6894. OrthoCamera.prototype.update = function () {
  6895. var projection = this.projection;
  6896. var view = this.view;
  6897. var projectionView = this.projectionView;
  6898. var inverseProjectionView = this.inverseProjectionView;
  6899. var zoom = this.zoom, viewportWidth = this.viewportWidth, viewportHeight = this.viewportHeight;
  6900. projection.ortho(zoom * (-viewportWidth / 2), zoom * (viewportWidth / 2), zoom * (-viewportHeight / 2), zoom * (viewportHeight / 2), this.near, this.far);
  6901. view.lookAt(this.position, this.direction, this.up);
  6902. projectionView.set(projection.values);
  6903. projectionView.multiply(view);
  6904. inverseProjectionView.set(projectionView.values).invert();
  6905. };
  6906. OrthoCamera.prototype.screenToWorld = function (screenCoords, screenWidth, screenHeight) {
  6907. var x = screenCoords.x, y = screenHeight - screenCoords.y - 1;
  6908. var tmp = this.tmp;
  6909. tmp.x = (2 * x) / screenWidth - 1;
  6910. tmp.y = (2 * y) / screenHeight - 1;
  6911. tmp.z = (2 * screenCoords.z) - 1;
  6912. tmp.project(this.inverseProjectionView);
  6913. screenCoords.set(tmp.x, tmp.y, tmp.z);
  6914. return screenCoords;
  6915. };
  6916. OrthoCamera.prototype.setViewport = function (viewportWidth, viewportHeight) {
  6917. this.viewportWidth = viewportWidth;
  6918. this.viewportHeight = viewportHeight;
  6919. };
  6920. return OrthoCamera;
  6921. }());
  6922. webgl.OrthoCamera = OrthoCamera;
  6923. })(webgl = spine.webgl || (spine.webgl = {}));
  6924. })(spine || (spine = {}));
  6925. var spine;
  6926. (function (spine) {
  6927. var webgl;
  6928. (function (webgl) {
  6929. var GLTexture = (function (_super) {
  6930. __extends(GLTexture, _super);
  6931. function GLTexture(context, image, useMipMaps) {
  6932. if (useMipMaps === void 0) { useMipMaps = false; }
  6933. var _this = _super.call(this, image) || this;
  6934. _this.texture = null;
  6935. _this.boundUnit = 0;
  6936. _this.useMipMaps = false;
  6937. _this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  6938. _this.useMipMaps = useMipMaps;
  6939. _this.restore();
  6940. _this.context.addRestorable(_this);
  6941. return _this;
  6942. }
  6943. GLTexture.prototype.setFilters = function (minFilter, magFilter) {
  6944. var gl = this.context.gl;
  6945. this.bind();
  6946. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
  6947. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
  6948. };
  6949. GLTexture.prototype.setWraps = function (uWrap, vWrap) {
  6950. var gl = this.context.gl;
  6951. this.bind();
  6952. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
  6953. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
  6954. };
  6955. GLTexture.prototype.update = function (useMipMaps) {
  6956. var gl = this.context.gl;
  6957. if (!this.texture) {
  6958. this.texture = this.context.gl.createTexture();
  6959. }
  6960. this.bind();
  6961. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
  6962. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  6963. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  6964. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  6965. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  6966. if (useMipMaps)
  6967. gl.generateMipmap(gl.TEXTURE_2D);
  6968. };
  6969. GLTexture.prototype.restore = function () {
  6970. this.texture = null;
  6971. this.update(this.useMipMaps);
  6972. };
  6973. GLTexture.prototype.bind = function (unit) {
  6974. if (unit === void 0) { unit = 0; }
  6975. var gl = this.context.gl;
  6976. this.boundUnit = unit;
  6977. gl.activeTexture(gl.TEXTURE0 + unit);
  6978. gl.bindTexture(gl.TEXTURE_2D, this.texture);
  6979. };
  6980. GLTexture.prototype.unbind = function () {
  6981. var gl = this.context.gl;
  6982. gl.activeTexture(gl.TEXTURE0 + this.boundUnit);
  6983. gl.bindTexture(gl.TEXTURE_2D, null);
  6984. };
  6985. GLTexture.prototype.dispose = function () {
  6986. this.context.removeRestorable(this);
  6987. var gl = this.context.gl;
  6988. gl.deleteTexture(this.texture);
  6989. };
  6990. return GLTexture;
  6991. }(spine.Texture));
  6992. webgl.GLTexture = GLTexture;
  6993. })(webgl = spine.webgl || (spine.webgl = {}));
  6994. })(spine || (spine = {}));
  6995. var spine;
  6996. (function (spine) {
  6997. var webgl;
  6998. (function (webgl) {
  6999. var Input = (function () {
  7000. function Input(element) {
  7001. this.lastX = 0;
  7002. this.lastY = 0;
  7003. this.buttonDown = false;
  7004. this.currTouch = null;
  7005. this.touchesPool = new spine.Pool(function () {
  7006. return new spine.webgl.Touch(0, 0, 0);
  7007. });
  7008. this.listeners = new Array();
  7009. this.element = element;
  7010. this.setupCallbacks(element);
  7011. }
  7012. Input.prototype.setupCallbacks = function (element) {
  7013. var _this = this;
  7014. var mouseDown = function (ev) {
  7015. if (ev instanceof MouseEvent) {
  7016. var rect = element.getBoundingClientRect();
  7017. var x = ev.clientX - rect.left;
  7018. var y = ev.clientY - rect.top;
  7019. var listeners = _this.listeners;
  7020. for (var i = 0; i < listeners.length; i++) {
  7021. listeners[i].down(x, y);
  7022. }
  7023. _this.lastX = x;
  7024. _this.lastY = y;
  7025. _this.buttonDown = true;
  7026. document.addEventListener("mousemove", mouseMove);
  7027. document.addEventListener("mouseup", mouseUp);
  7028. }
  7029. };
  7030. var mouseMove = function (ev) {
  7031. if (ev instanceof MouseEvent) {
  7032. var rect = element.getBoundingClientRect();
  7033. var x = ev.clientX - rect.left;
  7034. var y = ev.clientY - rect.top;
  7035. var listeners = _this.listeners;
  7036. for (var i = 0; i < listeners.length; i++) {
  7037. if (_this.buttonDown) {
  7038. listeners[i].dragged(x, y);
  7039. }
  7040. else {
  7041. listeners[i].moved(x, y);
  7042. }
  7043. }
  7044. _this.lastX = x;
  7045. _this.lastY = y;
  7046. }
  7047. };
  7048. var mouseUp = function (ev) {
  7049. if (ev instanceof MouseEvent) {
  7050. var rect = element.getBoundingClientRect();
  7051. var x = ev.clientX - rect.left;
  7052. var y = ev.clientY - rect.top;
  7053. var listeners = _this.listeners;
  7054. for (var i = 0; i < listeners.length; i++) {
  7055. listeners[i].up(x, y);
  7056. }
  7057. _this.lastX = x;
  7058. _this.lastY = y;
  7059. _this.buttonDown = false;
  7060. document.removeEventListener("mousemove", mouseMove);
  7061. document.removeEventListener("mouseup", mouseUp);
  7062. }
  7063. };
  7064. element.addEventListener("mousedown", mouseDown, true);
  7065. element.addEventListener("mousemove", mouseMove, true);
  7066. element.addEventListener("mouseup", mouseUp, true);
  7067. element.addEventListener("touchstart", function (ev) {
  7068. if (_this.currTouch != null)
  7069. return;
  7070. var touches = ev.changedTouches;
  7071. for (var i = 0; i < touches.length; i++) {
  7072. var touch = touches[i];
  7073. var rect = element.getBoundingClientRect();
  7074. var x = touch.clientX - rect.left;
  7075. var y = touch.clientY - rect.top;
  7076. _this.currTouch = _this.touchesPool.obtain();
  7077. _this.currTouch.identifier = touch.identifier;
  7078. _this.currTouch.x = x;
  7079. _this.currTouch.y = y;
  7080. break;
  7081. }
  7082. var listeners = _this.listeners;
  7083. for (var i_16 = 0; i_16 < listeners.length; i_16++) {
  7084. listeners[i_16].down(_this.currTouch.x, _this.currTouch.y);
  7085. }
  7086. console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y);
  7087. _this.lastX = _this.currTouch.x;
  7088. _this.lastY = _this.currTouch.y;
  7089. _this.buttonDown = true;
  7090. ev.preventDefault();
  7091. }, false);
  7092. element.addEventListener("touchend", function (ev) {
  7093. var touches = ev.changedTouches;
  7094. for (var i = 0; i < touches.length; i++) {
  7095. var touch = touches[i];
  7096. if (_this.currTouch.identifier === touch.identifier) {
  7097. var rect = element.getBoundingClientRect();
  7098. var x = _this.currTouch.x = touch.clientX - rect.left;
  7099. var y = _this.currTouch.y = touch.clientY - rect.top;
  7100. _this.touchesPool.free(_this.currTouch);
  7101. var listeners = _this.listeners;
  7102. for (var i_17 = 0; i_17 < listeners.length; i_17++) {
  7103. listeners[i_17].up(x, y);
  7104. }
  7105. console.log("End " + x + ", " + y);
  7106. _this.lastX = x;
  7107. _this.lastY = y;
  7108. _this.buttonDown = false;
  7109. _this.currTouch = null;
  7110. break;
  7111. }
  7112. }
  7113. ev.preventDefault();
  7114. }, false);
  7115. element.addEventListener("touchcancel", function (ev) {
  7116. var touches = ev.changedTouches;
  7117. for (var i = 0; i < touches.length; i++) {
  7118. var touch = touches[i];
  7119. if (_this.currTouch.identifier === touch.identifier) {
  7120. var rect = element.getBoundingClientRect();
  7121. var x = _this.currTouch.x = touch.clientX - rect.left;
  7122. var y = _this.currTouch.y = touch.clientY - rect.top;
  7123. _this.touchesPool.free(_this.currTouch);
  7124. var listeners = _this.listeners;
  7125. for (var i_18 = 0; i_18 < listeners.length; i_18++) {
  7126. listeners[i_18].up(x, y);
  7127. }
  7128. console.log("End " + x + ", " + y);
  7129. _this.lastX = x;
  7130. _this.lastY = y;
  7131. _this.buttonDown = false;
  7132. _this.currTouch = null;
  7133. break;
  7134. }
  7135. }
  7136. ev.preventDefault();
  7137. }, false);
  7138. element.addEventListener("touchmove", function (ev) {
  7139. if (_this.currTouch == null)
  7140. return;
  7141. var touches = ev.changedTouches;
  7142. for (var i = 0; i < touches.length; i++) {
  7143. var touch = touches[i];
  7144. if (_this.currTouch.identifier === touch.identifier) {
  7145. var rect = element.getBoundingClientRect();
  7146. var x = touch.clientX - rect.left;
  7147. var y = touch.clientY - rect.top;
  7148. var listeners = _this.listeners;
  7149. for (var i_19 = 0; i_19 < listeners.length; i_19++) {
  7150. listeners[i_19].dragged(x, y);
  7151. }
  7152. console.log("Drag " + x + ", " + y);
  7153. _this.lastX = _this.currTouch.x = x;
  7154. _this.lastY = _this.currTouch.y = y;
  7155. break;
  7156. }
  7157. }
  7158. ev.preventDefault();
  7159. }, false);
  7160. };
  7161. Input.prototype.addListener = function (listener) {
  7162. this.listeners.push(listener);
  7163. };
  7164. Input.prototype.removeListener = function (listener) {
  7165. var idx = this.listeners.indexOf(listener);
  7166. if (idx > -1) {
  7167. this.listeners.splice(idx, 1);
  7168. }
  7169. };
  7170. return Input;
  7171. }());
  7172. webgl.Input = Input;
  7173. var Touch = (function () {
  7174. function Touch(identifier, x, y) {
  7175. this.identifier = identifier;
  7176. this.x = x;
  7177. this.y = y;
  7178. }
  7179. return Touch;
  7180. }());
  7181. webgl.Touch = Touch;
  7182. })(webgl = spine.webgl || (spine.webgl = {}));
  7183. })(spine || (spine = {}));
  7184. var spine;
  7185. (function (spine) {
  7186. var webgl;
  7187. (function (webgl) {
  7188. var LoadingScreen = (function () {
  7189. function LoadingScreen(renderer) {
  7190. this.logo = null;
  7191. this.spinner = null;
  7192. this.angle = 0;
  7193. this.fadeOut = 0;
  7194. this.timeKeeper = new spine.TimeKeeper();
  7195. this.backgroundColor = new spine.Color(0.135, 0.135, 0.135, 1);
  7196. this.tempColor = new spine.Color();
  7197. this.firstDraw = 0;
  7198. this.renderer = renderer;
  7199. this.timeKeeper.maxDelta = 9;
  7200. if (LoadingScreen.logoImg === null) {
  7201. var isSafari = navigator.userAgent.indexOf("Safari") > -1;
  7202. LoadingScreen.logoImg = new Image();
  7203. LoadingScreen.logoImg.src = LoadingScreen.SPINE_LOGO_DATA;
  7204. if (!isSafari)
  7205. LoadingScreen.logoImg.crossOrigin = "anonymous";
  7206. LoadingScreen.logoImg.onload = function (ev) {
  7207. LoadingScreen.loaded++;
  7208. };
  7209. LoadingScreen.spinnerImg = new Image();
  7210. LoadingScreen.spinnerImg.src = LoadingScreen.SPINNER_DATA;
  7211. if (!isSafari)
  7212. LoadingScreen.spinnerImg.crossOrigin = "anonymous";
  7213. LoadingScreen.spinnerImg.onload = function (ev) {
  7214. LoadingScreen.loaded++;
  7215. };
  7216. }
  7217. }
  7218. LoadingScreen.prototype.draw = function (complete) {
  7219. if (complete === void 0) { complete = false; }
  7220. if (complete && this.fadeOut > LoadingScreen.FADE_SECONDS)
  7221. return;
  7222. this.timeKeeper.update();
  7223. var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75));
  7224. this.angle -= this.timeKeeper.delta / 1.4 * 360 * (1 + 1.5 * Math.pow(a, 5));
  7225. var renderer = this.renderer;
  7226. var canvas = renderer.canvas;
  7227. var gl = renderer.context.gl;
  7228. renderer.resize(webgl.ResizeMode.Stretch);
  7229. var oldX = renderer.camera.position.x, oldY = renderer.camera.position.y;
  7230. renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);
  7231. renderer.camera.viewportWidth = canvas.width;
  7232. renderer.camera.viewportHeight = canvas.height;
  7233. if (!complete) {
  7234. gl.clearColor(this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a);
  7235. gl.clear(gl.COLOR_BUFFER_BIT);
  7236. this.tempColor.a = 1;
  7237. }
  7238. else {
  7239. this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);
  7240. if (this.fadeOut > LoadingScreen.FADE_SECONDS) {
  7241. renderer.camera.position.set(oldX, oldY, 0);
  7242. return;
  7243. }
  7244. a = 1 - this.fadeOut / LoadingScreen.FADE_SECONDS;
  7245. this.tempColor.setFromColor(this.backgroundColor);
  7246. this.tempColor.a = 1 - (a - 1) * (a - 1);
  7247. renderer.begin();
  7248. renderer.quad(true, 0, 0, canvas.width, 0, canvas.width, canvas.height, 0, canvas.height, this.tempColor, this.tempColor, this.tempColor, this.tempColor);
  7249. renderer.end();
  7250. }
  7251. this.tempColor.set(1, 1, 1, this.tempColor.a);
  7252. if (LoadingScreen.loaded != 2)
  7253. return;
  7254. if (this.logo === null) {
  7255. this.logo = new webgl.GLTexture(renderer.context, LoadingScreen.logoImg);
  7256. this.spinner = new webgl.GLTexture(renderer.context, LoadingScreen.spinnerImg);
  7257. }
  7258. this.logo.update(false);
  7259. this.spinner.update(false);
  7260. var logoWidth = this.logo.getImage().width;
  7261. var logoHeight = this.logo.getImage().height;
  7262. var spinnerWidth = this.spinner.getImage().width;
  7263. var spinnerHeight = this.spinner.getImage().height;
  7264. renderer.batcher.setBlendMode(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
  7265. renderer.begin();
  7266. renderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, this.tempColor);
  7267. renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerWidth) / 2, (canvas.height - spinnerHeight) / 2, spinnerWidth, spinnerHeight, spinnerWidth / 2, spinnerHeight / 2, this.angle, this.tempColor);
  7268. renderer.end();
  7269. renderer.camera.position.set(oldX, oldY, 0);
  7270. };
  7271. LoadingScreen.FADE_SECONDS = 1;
  7272. LoadingScreen.loaded = 0;
  7273. LoadingScreen.spinnerImg = null;
  7274. LoadingScreen.logoImg = null;
  7275. 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=";
  7276. 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=";
  7277. return LoadingScreen;
  7278. }());
  7279. webgl.LoadingScreen = LoadingScreen;
  7280. })(webgl = spine.webgl || (spine.webgl = {}));
  7281. })(spine || (spine = {}));
  7282. var spine;
  7283. (function (spine) {
  7284. var webgl;
  7285. (function (webgl) {
  7286. webgl.M00 = 0;
  7287. webgl.M01 = 4;
  7288. webgl.M02 = 8;
  7289. webgl.M03 = 12;
  7290. webgl.M10 = 1;
  7291. webgl.M11 = 5;
  7292. webgl.M12 = 9;
  7293. webgl.M13 = 13;
  7294. webgl.M20 = 2;
  7295. webgl.M21 = 6;
  7296. webgl.M22 = 10;
  7297. webgl.M23 = 14;
  7298. webgl.M30 = 3;
  7299. webgl.M31 = 7;
  7300. webgl.M32 = 11;
  7301. webgl.M33 = 15;
  7302. var Matrix4 = (function () {
  7303. function Matrix4() {
  7304. this.temp = new Float32Array(16);
  7305. this.values = new Float32Array(16);
  7306. var v = this.values;
  7307. v[webgl.M00] = 1;
  7308. v[webgl.M11] = 1;
  7309. v[webgl.M22] = 1;
  7310. v[webgl.M33] = 1;
  7311. }
  7312. Matrix4.prototype.set = function (values) {
  7313. this.values.set(values);
  7314. return this;
  7315. };
  7316. Matrix4.prototype.transpose = function () {
  7317. var t = this.temp;
  7318. var v = this.values;
  7319. t[webgl.M00] = v[webgl.M00];
  7320. t[webgl.M01] = v[webgl.M10];
  7321. t[webgl.M02] = v[webgl.M20];
  7322. t[webgl.M03] = v[webgl.M30];
  7323. t[webgl.M10] = v[webgl.M01];
  7324. t[webgl.M11] = v[webgl.M11];
  7325. t[webgl.M12] = v[webgl.M21];
  7326. t[webgl.M13] = v[webgl.M31];
  7327. t[webgl.M20] = v[webgl.M02];
  7328. t[webgl.M21] = v[webgl.M12];
  7329. t[webgl.M22] = v[webgl.M22];
  7330. t[webgl.M23] = v[webgl.M32];
  7331. t[webgl.M30] = v[webgl.M03];
  7332. t[webgl.M31] = v[webgl.M13];
  7333. t[webgl.M32] = v[webgl.M23];
  7334. t[webgl.M33] = v[webgl.M33];
  7335. return this.set(t);
  7336. };
  7337. Matrix4.prototype.identity = function () {
  7338. var v = this.values;
  7339. v[webgl.M00] = 1;
  7340. v[webgl.M01] = 0;
  7341. v[webgl.M02] = 0;
  7342. v[webgl.M03] = 0;
  7343. v[webgl.M10] = 0;
  7344. v[webgl.M11] = 1;
  7345. v[webgl.M12] = 0;
  7346. v[webgl.M13] = 0;
  7347. v[webgl.M20] = 0;
  7348. v[webgl.M21] = 0;
  7349. v[webgl.M22] = 1;
  7350. v[webgl.M23] = 0;
  7351. v[webgl.M30] = 0;
  7352. v[webgl.M31] = 0;
  7353. v[webgl.M32] = 0;
  7354. v[webgl.M33] = 1;
  7355. return this;
  7356. };
  7357. Matrix4.prototype.invert = function () {
  7358. var v = this.values;
  7359. var t = this.temp;
  7360. 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]
  7361. + 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]
  7362. - 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]
  7363. - 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]
  7364. + 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]
  7365. + 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]
  7366. - 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]
  7367. - 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];
  7368. if (l_det == 0)
  7369. throw new Error("non-invertible matrix");
  7370. var inv_det = 1.0 / l_det;
  7371. 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]
  7372. - 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];
  7373. 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]
  7374. + 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];
  7375. 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]
  7376. - 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];
  7377. 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]
  7378. + 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];
  7379. 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]
  7380. + 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];
  7381. 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]
  7382. - 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];
  7383. 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]
  7384. + 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];
  7385. 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]
  7386. - 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];
  7387. 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]
  7388. - 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];
  7389. 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]
  7390. + 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];
  7391. 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]
  7392. - 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];
  7393. 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]
  7394. + 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];
  7395. 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]
  7396. + 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];
  7397. 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]
  7398. - 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];
  7399. 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]
  7400. + 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];
  7401. 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]
  7402. - 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];
  7403. v[webgl.M00] = t[webgl.M00] * inv_det;
  7404. v[webgl.M01] = t[webgl.M01] * inv_det;
  7405. v[webgl.M02] = t[webgl.M02] * inv_det;
  7406. v[webgl.M03] = t[webgl.M03] * inv_det;
  7407. v[webgl.M10] = t[webgl.M10] * inv_det;
  7408. v[webgl.M11] = t[webgl.M11] * inv_det;
  7409. v[webgl.M12] = t[webgl.M12] * inv_det;
  7410. v[webgl.M13] = t[webgl.M13] * inv_det;
  7411. v[webgl.M20] = t[webgl.M20] * inv_det;
  7412. v[webgl.M21] = t[webgl.M21] * inv_det;
  7413. v[webgl.M22] = t[webgl.M22] * inv_det;
  7414. v[webgl.M23] = t[webgl.M23] * inv_det;
  7415. v[webgl.M30] = t[webgl.M30] * inv_det;
  7416. v[webgl.M31] = t[webgl.M31] * inv_det;
  7417. v[webgl.M32] = t[webgl.M32] * inv_det;
  7418. v[webgl.M33] = t[webgl.M33] * inv_det;
  7419. return this;
  7420. };
  7421. Matrix4.prototype.determinant = function () {
  7422. var v = this.values;
  7423. 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]
  7424. + 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]
  7425. - 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]
  7426. - 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]
  7427. + 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]
  7428. + 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]
  7429. - 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]
  7430. - 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];
  7431. };
  7432. Matrix4.prototype.translate = function (x, y, z) {
  7433. var v = this.values;
  7434. v[webgl.M03] += x;
  7435. v[webgl.M13] += y;
  7436. v[webgl.M23] += z;
  7437. return this;
  7438. };
  7439. Matrix4.prototype.copy = function () {
  7440. return new Matrix4().set(this.values);
  7441. };
  7442. Matrix4.prototype.projection = function (near, far, fovy, aspectRatio) {
  7443. this.identity();
  7444. var l_fd = (1.0 / Math.tan((fovy * (Math.PI / 180)) / 2.0));
  7445. var l_a1 = (far + near) / (near - far);
  7446. var l_a2 = (2 * far * near) / (near - far);
  7447. var v = this.values;
  7448. v[webgl.M00] = l_fd / aspectRatio;
  7449. v[webgl.M10] = 0;
  7450. v[webgl.M20] = 0;
  7451. v[webgl.M30] = 0;
  7452. v[webgl.M01] = 0;
  7453. v[webgl.M11] = l_fd;
  7454. v[webgl.M21] = 0;
  7455. v[webgl.M31] = 0;
  7456. v[webgl.M02] = 0;
  7457. v[webgl.M12] = 0;
  7458. v[webgl.M22] = l_a1;
  7459. v[webgl.M32] = -1;
  7460. v[webgl.M03] = 0;
  7461. v[webgl.M13] = 0;
  7462. v[webgl.M23] = l_a2;
  7463. v[webgl.M33] = 0;
  7464. return this;
  7465. };
  7466. Matrix4.prototype.ortho2d = function (x, y, width, height) {
  7467. return this.ortho(x, x + width, y, y + height, 0, 1);
  7468. };
  7469. Matrix4.prototype.ortho = function (left, right, bottom, top, near, far) {
  7470. this.identity();
  7471. var x_orth = 2 / (right - left);
  7472. var y_orth = 2 / (top - bottom);
  7473. var z_orth = -2 / (far - near);
  7474. var tx = -(right + left) / (right - left);
  7475. var ty = -(top + bottom) / (top - bottom);
  7476. var tz = -(far + near) / (far - near);
  7477. var v = this.values;
  7478. v[webgl.M00] = x_orth;
  7479. v[webgl.M10] = 0;
  7480. v[webgl.M20] = 0;
  7481. v[webgl.M30] = 0;
  7482. v[webgl.M01] = 0;
  7483. v[webgl.M11] = y_orth;
  7484. v[webgl.M21] = 0;
  7485. v[webgl.M31] = 0;
  7486. v[webgl.M02] = 0;
  7487. v[webgl.M12] = 0;
  7488. v[webgl.M22] = z_orth;
  7489. v[webgl.M32] = 0;
  7490. v[webgl.M03] = tx;
  7491. v[webgl.M13] = ty;
  7492. v[webgl.M23] = tz;
  7493. v[webgl.M33] = 1;
  7494. return this;
  7495. };
  7496. Matrix4.prototype.multiply = function (matrix) {
  7497. var t = this.temp;
  7498. var v = this.values;
  7499. var m = matrix.values;
  7500. 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];
  7501. 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];
  7502. 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];
  7503. 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];
  7504. 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];
  7505. 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];
  7506. 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];
  7507. 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];
  7508. 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];
  7509. 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];
  7510. 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];
  7511. 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];
  7512. 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];
  7513. 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];
  7514. 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];
  7515. 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];
  7516. return this.set(this.temp);
  7517. };
  7518. Matrix4.prototype.multiplyLeft = function (matrix) {
  7519. var t = this.temp;
  7520. var v = this.values;
  7521. var m = matrix.values;
  7522. 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];
  7523. 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];
  7524. 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];
  7525. 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];
  7526. 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];
  7527. 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];
  7528. 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];
  7529. 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];
  7530. 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];
  7531. 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];
  7532. 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];
  7533. 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];
  7534. 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];
  7535. 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];
  7536. 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];
  7537. 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];
  7538. return this.set(this.temp);
  7539. };
  7540. Matrix4.prototype.lookAt = function (position, direction, up) {
  7541. Matrix4.initTemps();
  7542. var xAxis = Matrix4.xAxis, yAxis = Matrix4.yAxis, zAxis = Matrix4.zAxis;
  7543. zAxis.setFrom(direction).normalize();
  7544. xAxis.setFrom(direction).normalize();
  7545. xAxis.cross(up).normalize();
  7546. yAxis.setFrom(xAxis).cross(zAxis).normalize();
  7547. this.identity();
  7548. var val = this.values;
  7549. val[webgl.M00] = xAxis.x;
  7550. val[webgl.M01] = xAxis.y;
  7551. val[webgl.M02] = xAxis.z;
  7552. val[webgl.M10] = yAxis.x;
  7553. val[webgl.M11] = yAxis.y;
  7554. val[webgl.M12] = yAxis.z;
  7555. val[webgl.M20] = -zAxis.x;
  7556. val[webgl.M21] = -zAxis.y;
  7557. val[webgl.M22] = -zAxis.z;
  7558. Matrix4.tmpMatrix.identity();
  7559. Matrix4.tmpMatrix.values[webgl.M03] = -position.x;
  7560. Matrix4.tmpMatrix.values[webgl.M13] = -position.y;
  7561. Matrix4.tmpMatrix.values[webgl.M23] = -position.z;
  7562. this.multiply(Matrix4.tmpMatrix);
  7563. return this;
  7564. };
  7565. Matrix4.initTemps = function () {
  7566. if (Matrix4.xAxis === null)
  7567. Matrix4.xAxis = new webgl.Vector3();
  7568. if (Matrix4.yAxis === null)
  7569. Matrix4.yAxis = new webgl.Vector3();
  7570. if (Matrix4.zAxis === null)
  7571. Matrix4.zAxis = new webgl.Vector3();
  7572. };
  7573. Matrix4.xAxis = null;
  7574. Matrix4.yAxis = null;
  7575. Matrix4.zAxis = null;
  7576. Matrix4.tmpMatrix = new Matrix4();
  7577. return Matrix4;
  7578. }());
  7579. webgl.Matrix4 = Matrix4;
  7580. })(webgl = spine.webgl || (spine.webgl = {}));
  7581. })(spine || (spine = {}));
  7582. var spine;
  7583. (function (spine) {
  7584. var webgl;
  7585. (function (webgl) {
  7586. var Mesh = (function () {
  7587. function Mesh(context, attributes, maxVertices, maxIndices) {
  7588. this.attributes = attributes;
  7589. this.verticesLength = 0;
  7590. this.dirtyVertices = false;
  7591. this.indicesLength = 0;
  7592. this.dirtyIndices = false;
  7593. this.elementsPerVertex = 0;
  7594. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  7595. this.elementsPerVertex = 0;
  7596. for (var i = 0; i < attributes.length; i++) {
  7597. this.elementsPerVertex += attributes[i].numElements;
  7598. }
  7599. this.vertices = new Float32Array(maxVertices * this.elementsPerVertex);
  7600. this.indices = new Uint16Array(maxIndices);
  7601. this.context.addRestorable(this);
  7602. }
  7603. Mesh.prototype.getAttributes = function () { return this.attributes; };
  7604. Mesh.prototype.maxVertices = function () { return this.vertices.length / this.elementsPerVertex; };
  7605. Mesh.prototype.numVertices = function () { return this.verticesLength / this.elementsPerVertex; };
  7606. Mesh.prototype.setVerticesLength = function (length) {
  7607. this.dirtyVertices = true;
  7608. this.verticesLength = length;
  7609. };
  7610. Mesh.prototype.getVertices = function () { return this.vertices; };
  7611. Mesh.prototype.maxIndices = function () { return this.indices.length; };
  7612. Mesh.prototype.numIndices = function () { return this.indicesLength; };
  7613. Mesh.prototype.setIndicesLength = function (length) {
  7614. this.dirtyIndices = true;
  7615. this.indicesLength = length;
  7616. };
  7617. Mesh.prototype.getIndices = function () { return this.indices; };
  7618. ;
  7619. Mesh.prototype.getVertexSizeInFloats = function () {
  7620. var size = 0;
  7621. for (var i = 0; i < this.attributes.length; i++) {
  7622. var attribute = this.attributes[i];
  7623. size += attribute.numElements;
  7624. }
  7625. return size;
  7626. };
  7627. Mesh.prototype.setVertices = function (vertices) {
  7628. this.dirtyVertices = true;
  7629. if (vertices.length > this.vertices.length)
  7630. throw Error("Mesh can't store more than " + this.maxVertices() + " vertices");
  7631. this.vertices.set(vertices, 0);
  7632. this.verticesLength = vertices.length;
  7633. };
  7634. Mesh.prototype.setIndices = function (indices) {
  7635. this.dirtyIndices = true;
  7636. if (indices.length > this.indices.length)
  7637. throw Error("Mesh can't store more than " + this.maxIndices() + " indices");
  7638. this.indices.set(indices, 0);
  7639. this.indicesLength = indices.length;
  7640. };
  7641. Mesh.prototype.draw = function (shader, primitiveType) {
  7642. this.drawWithOffset(shader, primitiveType, 0, this.indicesLength > 0 ? this.indicesLength : this.verticesLength / this.elementsPerVertex);
  7643. };
  7644. Mesh.prototype.drawWithOffset = function (shader, primitiveType, offset, count) {
  7645. var gl = this.context.gl;
  7646. if (this.dirtyVertices || this.dirtyIndices)
  7647. this.update();
  7648. this.bind(shader);
  7649. if (this.indicesLength > 0) {
  7650. gl.drawElements(primitiveType, count, gl.UNSIGNED_SHORT, offset * 2);
  7651. }
  7652. else {
  7653. gl.drawArrays(primitiveType, offset, count);
  7654. }
  7655. this.unbind(shader);
  7656. };
  7657. Mesh.prototype.bind = function (shader) {
  7658. var gl = this.context.gl;
  7659. gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);
  7660. var offset = 0;
  7661. for (var i = 0; i < this.attributes.length; i++) {
  7662. var attrib = this.attributes[i];
  7663. var location_1 = shader.getAttributeLocation(attrib.name);
  7664. gl.enableVertexAttribArray(location_1);
  7665. gl.vertexAttribPointer(location_1, attrib.numElements, gl.FLOAT, false, this.elementsPerVertex * 4, offset * 4);
  7666. offset += attrib.numElements;
  7667. }
  7668. if (this.indicesLength > 0)
  7669. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
  7670. };
  7671. Mesh.prototype.unbind = function (shader) {
  7672. var gl = this.context.gl;
  7673. for (var i = 0; i < this.attributes.length; i++) {
  7674. var attrib = this.attributes[i];
  7675. var location_2 = shader.getAttributeLocation(attrib.name);
  7676. gl.disableVertexAttribArray(location_2);
  7677. }
  7678. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  7679. if (this.indicesLength > 0)
  7680. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
  7681. };
  7682. Mesh.prototype.update = function () {
  7683. var gl = this.context.gl;
  7684. if (this.dirtyVertices) {
  7685. if (!this.verticesBuffer) {
  7686. this.verticesBuffer = gl.createBuffer();
  7687. }
  7688. gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);
  7689. gl.bufferData(gl.ARRAY_BUFFER, this.vertices.subarray(0, this.verticesLength), gl.DYNAMIC_DRAW);
  7690. this.dirtyVertices = false;
  7691. }
  7692. if (this.dirtyIndices) {
  7693. if (!this.indicesBuffer) {
  7694. this.indicesBuffer = gl.createBuffer();
  7695. }
  7696. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
  7697. gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices.subarray(0, this.indicesLength), gl.DYNAMIC_DRAW);
  7698. this.dirtyIndices = false;
  7699. }
  7700. };
  7701. Mesh.prototype.restore = function () {
  7702. this.verticesBuffer = null;
  7703. this.indicesBuffer = null;
  7704. this.update();
  7705. };
  7706. Mesh.prototype.dispose = function () {
  7707. this.context.removeRestorable(this);
  7708. var gl = this.context.gl;
  7709. gl.deleteBuffer(this.verticesBuffer);
  7710. gl.deleteBuffer(this.indicesBuffer);
  7711. };
  7712. return Mesh;
  7713. }());
  7714. webgl.Mesh = Mesh;
  7715. var VertexAttribute = (function () {
  7716. function VertexAttribute(name, type, numElements) {
  7717. this.name = name;
  7718. this.type = type;
  7719. this.numElements = numElements;
  7720. }
  7721. return VertexAttribute;
  7722. }());
  7723. webgl.VertexAttribute = VertexAttribute;
  7724. var Position2Attribute = (function (_super) {
  7725. __extends(Position2Attribute, _super);
  7726. function Position2Attribute() {
  7727. return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 2) || this;
  7728. }
  7729. return Position2Attribute;
  7730. }(VertexAttribute));
  7731. webgl.Position2Attribute = Position2Attribute;
  7732. var Position3Attribute = (function (_super) {
  7733. __extends(Position3Attribute, _super);
  7734. function Position3Attribute() {
  7735. return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 3) || this;
  7736. }
  7737. return Position3Attribute;
  7738. }(VertexAttribute));
  7739. webgl.Position3Attribute = Position3Attribute;
  7740. var TexCoordAttribute = (function (_super) {
  7741. __extends(TexCoordAttribute, _super);
  7742. function TexCoordAttribute(unit) {
  7743. if (unit === void 0) { unit = 0; }
  7744. return _super.call(this, webgl.Shader.TEXCOORDS + (unit == 0 ? "" : unit), VertexAttributeType.Float, 2) || this;
  7745. }
  7746. return TexCoordAttribute;
  7747. }(VertexAttribute));
  7748. webgl.TexCoordAttribute = TexCoordAttribute;
  7749. var ColorAttribute = (function (_super) {
  7750. __extends(ColorAttribute, _super);
  7751. function ColorAttribute() {
  7752. return _super.call(this, webgl.Shader.COLOR, VertexAttributeType.Float, 4) || this;
  7753. }
  7754. return ColorAttribute;
  7755. }(VertexAttribute));
  7756. webgl.ColorAttribute = ColorAttribute;
  7757. var Color2Attribute = (function (_super) {
  7758. __extends(Color2Attribute, _super);
  7759. function Color2Attribute() {
  7760. return _super.call(this, webgl.Shader.COLOR2, VertexAttributeType.Float, 4) || this;
  7761. }
  7762. return Color2Attribute;
  7763. }(VertexAttribute));
  7764. webgl.Color2Attribute = Color2Attribute;
  7765. var VertexAttributeType;
  7766. (function (VertexAttributeType) {
  7767. VertexAttributeType[VertexAttributeType["Float"] = 0] = "Float";
  7768. })(VertexAttributeType = webgl.VertexAttributeType || (webgl.VertexAttributeType = {}));
  7769. })(webgl = spine.webgl || (spine.webgl = {}));
  7770. })(spine || (spine = {}));
  7771. var spine;
  7772. (function (spine) {
  7773. var webgl;
  7774. (function (webgl) {
  7775. var PolygonBatcher = (function () {
  7776. function PolygonBatcher(context, twoColorTint, maxVertices) {
  7777. if (twoColorTint === void 0) { twoColorTint = true; }
  7778. if (maxVertices === void 0) { maxVertices = 10920; }
  7779. this.isDrawing = false;
  7780. this.shader = null;
  7781. this.lastTexture = null;
  7782. this.verticesLength = 0;
  7783. this.indicesLength = 0;
  7784. if (maxVertices > 10920)
  7785. throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
  7786. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  7787. var attributes = twoColorTint ?
  7788. [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute(), new webgl.Color2Attribute()] :
  7789. [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute()];
  7790. this.mesh = new webgl.Mesh(context, attributes, maxVertices, maxVertices * 3);
  7791. this.srcBlend = this.context.gl.SRC_ALPHA;
  7792. this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;
  7793. }
  7794. PolygonBatcher.prototype.begin = function (shader) {
  7795. var gl = this.context.gl;
  7796. if (this.isDrawing)
  7797. throw new Error("PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()");
  7798. this.drawCalls = 0;
  7799. this.shader = shader;
  7800. this.lastTexture = null;
  7801. this.isDrawing = true;
  7802. gl.enable(gl.BLEND);
  7803. gl.blendFunc(this.srcBlend, this.dstBlend);
  7804. };
  7805. PolygonBatcher.prototype.setBlendMode = function (srcBlend, dstBlend) {
  7806. var gl = this.context.gl;
  7807. this.srcBlend = srcBlend;
  7808. this.dstBlend = dstBlend;
  7809. if (this.isDrawing) {
  7810. this.flush();
  7811. gl.blendFunc(this.srcBlend, this.dstBlend);
  7812. }
  7813. };
  7814. PolygonBatcher.prototype.draw = function (texture, vertices, indices) {
  7815. if (texture != this.lastTexture) {
  7816. this.flush();
  7817. this.lastTexture = texture;
  7818. }
  7819. else if (this.verticesLength + vertices.length > this.mesh.getVertices().length ||
  7820. this.indicesLength + indices.length > this.mesh.getIndices().length) {
  7821. this.flush();
  7822. }
  7823. var indexStart = this.mesh.numVertices();
  7824. this.mesh.getVertices().set(vertices, this.verticesLength);
  7825. this.verticesLength += vertices.length;
  7826. this.mesh.setVerticesLength(this.verticesLength);
  7827. var indicesArray = this.mesh.getIndices();
  7828. for (var i = this.indicesLength, j = 0; j < indices.length; i++, j++)
  7829. indicesArray[i] = indices[j] + indexStart;
  7830. this.indicesLength += indices.length;
  7831. this.mesh.setIndicesLength(this.indicesLength);
  7832. };
  7833. PolygonBatcher.prototype.flush = function () {
  7834. var gl = this.context.gl;
  7835. if (this.verticesLength == 0)
  7836. return;
  7837. this.lastTexture.bind();
  7838. this.mesh.draw(this.shader, gl.TRIANGLES);
  7839. this.verticesLength = 0;
  7840. this.indicesLength = 0;
  7841. this.mesh.setVerticesLength(0);
  7842. this.mesh.setIndicesLength(0);
  7843. this.drawCalls++;
  7844. };
  7845. PolygonBatcher.prototype.end = function () {
  7846. var gl = this.context.gl;
  7847. if (!this.isDrawing)
  7848. throw new Error("PolygonBatch is not drawing. Call PolygonBatch.begin() before calling PolygonBatch.end()");
  7849. if (this.verticesLength > 0 || this.indicesLength > 0)
  7850. this.flush();
  7851. this.shader = null;
  7852. this.lastTexture = null;
  7853. this.isDrawing = false;
  7854. gl.disable(gl.BLEND);
  7855. };
  7856. PolygonBatcher.prototype.getDrawCalls = function () { return this.drawCalls; };
  7857. PolygonBatcher.prototype.dispose = function () {
  7858. this.mesh.dispose();
  7859. };
  7860. return PolygonBatcher;
  7861. }());
  7862. webgl.PolygonBatcher = PolygonBatcher;
  7863. })(webgl = spine.webgl || (spine.webgl = {}));
  7864. })(spine || (spine = {}));
  7865. var spine;
  7866. (function (spine) {
  7867. var webgl;
  7868. (function (webgl) {
  7869. var SceneRenderer = (function () {
  7870. function SceneRenderer(canvas, context, twoColorTint) {
  7871. if (twoColorTint === void 0) { twoColorTint = true; }
  7872. this.twoColorTint = false;
  7873. this.activeRenderer = null;
  7874. this.QUAD = [
  7875. 0, 0, 1, 1, 1, 1, 0, 0,
  7876. 0, 0, 1, 1, 1, 1, 0, 0,
  7877. 0, 0, 1, 1, 1, 1, 0, 0,
  7878. 0, 0, 1, 1, 1, 1, 0, 0,
  7879. ];
  7880. this.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
  7881. this.WHITE = new spine.Color(1, 1, 1, 1);
  7882. this.canvas = canvas;
  7883. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  7884. this.twoColorTint = twoColorTint;
  7885. this.camera = new webgl.OrthoCamera(canvas.width, canvas.height);
  7886. this.batcherShader = twoColorTint ? webgl.Shader.newTwoColoredTextured(this.context) : webgl.Shader.newColoredTextured(this.context);
  7887. this.batcher = new webgl.PolygonBatcher(this.context, twoColorTint);
  7888. this.shapesShader = webgl.Shader.newColored(this.context);
  7889. this.shapes = new webgl.ShapeRenderer(this.context);
  7890. this.skeletonRenderer = new webgl.SkeletonRenderer(this.context, twoColorTint);
  7891. this.skeletonDebugRenderer = new webgl.SkeletonDebugRenderer(this.context);
  7892. }
  7893. SceneRenderer.prototype.begin = function () {
  7894. this.camera.update();
  7895. this.enableRenderer(this.batcher);
  7896. };
  7897. SceneRenderer.prototype.drawSkeleton = function (skeleton, premultipliedAlpha, slotRangeStart, slotRangeEnd) {
  7898. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  7899. if (slotRangeStart === void 0) { slotRangeStart = -1; }
  7900. if (slotRangeEnd === void 0) { slotRangeEnd = -1; }
  7901. this.enableRenderer(this.batcher);
  7902. this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
  7903. this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd);
  7904. };
  7905. SceneRenderer.prototype.drawSkeletonDebug = function (skeleton, premultipliedAlpha, ignoredBones) {
  7906. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  7907. if (ignoredBones === void 0) { ignoredBones = null; }
  7908. this.enableRenderer(this.shapes);
  7909. this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha;
  7910. this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones);
  7911. };
  7912. SceneRenderer.prototype.drawTexture = function (texture, x, y, width, height, color) {
  7913. if (color === void 0) { color = null; }
  7914. this.enableRenderer(this.batcher);
  7915. if (color === null)
  7916. color = this.WHITE;
  7917. var quad = this.QUAD;
  7918. var i = 0;
  7919. quad[i++] = x;
  7920. quad[i++] = y;
  7921. quad[i++] = color.r;
  7922. quad[i++] = color.g;
  7923. quad[i++] = color.b;
  7924. quad[i++] = color.a;
  7925. quad[i++] = 0;
  7926. quad[i++] = 1;
  7927. if (this.twoColorTint) {
  7928. quad[i++] = 0;
  7929. quad[i++] = 0;
  7930. quad[i++] = 0;
  7931. quad[i++] = 0;
  7932. }
  7933. quad[i++] = x + width;
  7934. quad[i++] = y;
  7935. quad[i++] = color.r;
  7936. quad[i++] = color.g;
  7937. quad[i++] = color.b;
  7938. quad[i++] = color.a;
  7939. quad[i++] = 1;
  7940. quad[i++] = 1;
  7941. if (this.twoColorTint) {
  7942. quad[i++] = 0;
  7943. quad[i++] = 0;
  7944. quad[i++] = 0;
  7945. quad[i++] = 0;
  7946. }
  7947. quad[i++] = x + width;
  7948. quad[i++] = y + height;
  7949. quad[i++] = color.r;
  7950. quad[i++] = color.g;
  7951. quad[i++] = color.b;
  7952. quad[i++] = color.a;
  7953. quad[i++] = 1;
  7954. quad[i++] = 0;
  7955. if (this.twoColorTint) {
  7956. quad[i++] = 0;
  7957. quad[i++] = 0;
  7958. quad[i++] = 0;
  7959. quad[i++] = 0;
  7960. }
  7961. quad[i++] = x;
  7962. quad[i++] = y + height;
  7963. quad[i++] = color.r;
  7964. quad[i++] = color.g;
  7965. quad[i++] = color.b;
  7966. quad[i++] = color.a;
  7967. quad[i++] = 0;
  7968. quad[i++] = 0;
  7969. if (this.twoColorTint) {
  7970. quad[i++] = 0;
  7971. quad[i++] = 0;
  7972. quad[i++] = 0;
  7973. quad[i++] = 0;
  7974. }
  7975. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  7976. };
  7977. SceneRenderer.prototype.drawTextureUV = function (texture, x, y, width, height, u, v, u2, v2, color) {
  7978. if (color === void 0) { color = null; }
  7979. this.enableRenderer(this.batcher);
  7980. if (color === null)
  7981. color = this.WHITE;
  7982. var quad = this.QUAD;
  7983. var i = 0;
  7984. quad[i++] = x;
  7985. quad[i++] = y;
  7986. quad[i++] = color.r;
  7987. quad[i++] = color.g;
  7988. quad[i++] = color.b;
  7989. quad[i++] = color.a;
  7990. quad[i++] = u;
  7991. quad[i++] = v;
  7992. if (this.twoColorTint) {
  7993. quad[i++] = 0;
  7994. quad[i++] = 0;
  7995. quad[i++] = 0;
  7996. quad[i++] = 0;
  7997. }
  7998. quad[i++] = x + width;
  7999. quad[i++] = y;
  8000. quad[i++] = color.r;
  8001. quad[i++] = color.g;
  8002. quad[i++] = color.b;
  8003. quad[i++] = color.a;
  8004. quad[i++] = u2;
  8005. quad[i++] = v;
  8006. if (this.twoColorTint) {
  8007. quad[i++] = 0;
  8008. quad[i++] = 0;
  8009. quad[i++] = 0;
  8010. quad[i++] = 0;
  8011. }
  8012. quad[i++] = x + width;
  8013. quad[i++] = y + height;
  8014. quad[i++] = color.r;
  8015. quad[i++] = color.g;
  8016. quad[i++] = color.b;
  8017. quad[i++] = color.a;
  8018. quad[i++] = u2;
  8019. quad[i++] = v2;
  8020. if (this.twoColorTint) {
  8021. quad[i++] = 0;
  8022. quad[i++] = 0;
  8023. quad[i++] = 0;
  8024. quad[i++] = 0;
  8025. }
  8026. quad[i++] = x;
  8027. quad[i++] = y + height;
  8028. quad[i++] = color.r;
  8029. quad[i++] = color.g;
  8030. quad[i++] = color.b;
  8031. quad[i++] = color.a;
  8032. quad[i++] = u;
  8033. quad[i++] = v2;
  8034. if (this.twoColorTint) {
  8035. quad[i++] = 0;
  8036. quad[i++] = 0;
  8037. quad[i++] = 0;
  8038. quad[i++] = 0;
  8039. }
  8040. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  8041. };
  8042. SceneRenderer.prototype.drawTextureRotated = function (texture, x, y, width, height, pivotX, pivotY, angle, color, premultipliedAlpha) {
  8043. if (color === void 0) { color = null; }
  8044. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  8045. this.enableRenderer(this.batcher);
  8046. if (color === null)
  8047. color = this.WHITE;
  8048. var quad = this.QUAD;
  8049. var worldOriginX = x + pivotX;
  8050. var worldOriginY = y + pivotY;
  8051. var fx = -pivotX;
  8052. var fy = -pivotY;
  8053. var fx2 = width - pivotX;
  8054. var fy2 = height - pivotY;
  8055. var p1x = fx;
  8056. var p1y = fy;
  8057. var p2x = fx;
  8058. var p2y = fy2;
  8059. var p3x = fx2;
  8060. var p3y = fy2;
  8061. var p4x = fx2;
  8062. var p4y = fy;
  8063. var x1 = 0;
  8064. var y1 = 0;
  8065. var x2 = 0;
  8066. var y2 = 0;
  8067. var x3 = 0;
  8068. var y3 = 0;
  8069. var x4 = 0;
  8070. var y4 = 0;
  8071. if (angle != 0) {
  8072. var cos = spine.MathUtils.cosDeg(angle);
  8073. var sin = spine.MathUtils.sinDeg(angle);
  8074. x1 = cos * p1x - sin * p1y;
  8075. y1 = sin * p1x + cos * p1y;
  8076. x4 = cos * p2x - sin * p2y;
  8077. y4 = sin * p2x + cos * p2y;
  8078. x3 = cos * p3x - sin * p3y;
  8079. y3 = sin * p3x + cos * p3y;
  8080. x2 = x3 + (x1 - x4);
  8081. y2 = y3 + (y1 - y4);
  8082. }
  8083. else {
  8084. x1 = p1x;
  8085. y1 = p1y;
  8086. x4 = p2x;
  8087. y4 = p2y;
  8088. x3 = p3x;
  8089. y3 = p3y;
  8090. x2 = p4x;
  8091. y2 = p4y;
  8092. }
  8093. x1 += worldOriginX;
  8094. y1 += worldOriginY;
  8095. x2 += worldOriginX;
  8096. y2 += worldOriginY;
  8097. x3 += worldOriginX;
  8098. y3 += worldOriginY;
  8099. x4 += worldOriginX;
  8100. y4 += worldOriginY;
  8101. var i = 0;
  8102. quad[i++] = x1;
  8103. quad[i++] = y1;
  8104. quad[i++] = color.r;
  8105. quad[i++] = color.g;
  8106. quad[i++] = color.b;
  8107. quad[i++] = color.a;
  8108. quad[i++] = 0;
  8109. quad[i++] = 1;
  8110. if (this.twoColorTint) {
  8111. quad[i++] = 0;
  8112. quad[i++] = 0;
  8113. quad[i++] = 0;
  8114. quad[i++] = 0;
  8115. }
  8116. quad[i++] = x2;
  8117. quad[i++] = y2;
  8118. quad[i++] = color.r;
  8119. quad[i++] = color.g;
  8120. quad[i++] = color.b;
  8121. quad[i++] = color.a;
  8122. quad[i++] = 1;
  8123. quad[i++] = 1;
  8124. if (this.twoColorTint) {
  8125. quad[i++] = 0;
  8126. quad[i++] = 0;
  8127. quad[i++] = 0;
  8128. quad[i++] = 0;
  8129. }
  8130. quad[i++] = x3;
  8131. quad[i++] = y3;
  8132. quad[i++] = color.r;
  8133. quad[i++] = color.g;
  8134. quad[i++] = color.b;
  8135. quad[i++] = color.a;
  8136. quad[i++] = 1;
  8137. quad[i++] = 0;
  8138. if (this.twoColorTint) {
  8139. quad[i++] = 0;
  8140. quad[i++] = 0;
  8141. quad[i++] = 0;
  8142. quad[i++] = 0;
  8143. }
  8144. quad[i++] = x4;
  8145. quad[i++] = y4;
  8146. quad[i++] = color.r;
  8147. quad[i++] = color.g;
  8148. quad[i++] = color.b;
  8149. quad[i++] = color.a;
  8150. quad[i++] = 0;
  8151. quad[i++] = 0;
  8152. if (this.twoColorTint) {
  8153. quad[i++] = 0;
  8154. quad[i++] = 0;
  8155. quad[i++] = 0;
  8156. quad[i++] = 0;
  8157. }
  8158. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  8159. };
  8160. SceneRenderer.prototype.drawRegion = function (region, x, y, width, height, color, premultipliedAlpha) {
  8161. if (color === void 0) { color = null; }
  8162. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  8163. this.enableRenderer(this.batcher);
  8164. if (color === null)
  8165. color = this.WHITE;
  8166. var quad = this.QUAD;
  8167. var i = 0;
  8168. quad[i++] = x;
  8169. quad[i++] = y;
  8170. quad[i++] = color.r;
  8171. quad[i++] = color.g;
  8172. quad[i++] = color.b;
  8173. quad[i++] = color.a;
  8174. quad[i++] = region.u;
  8175. quad[i++] = region.v2;
  8176. if (this.twoColorTint) {
  8177. quad[i++] = 0;
  8178. quad[i++] = 0;
  8179. quad[i++] = 0;
  8180. quad[i++] = 0;
  8181. }
  8182. quad[i++] = x + width;
  8183. quad[i++] = y;
  8184. quad[i++] = color.r;
  8185. quad[i++] = color.g;
  8186. quad[i++] = color.b;
  8187. quad[i++] = color.a;
  8188. quad[i++] = region.u2;
  8189. quad[i++] = region.v2;
  8190. if (this.twoColorTint) {
  8191. quad[i++] = 0;
  8192. quad[i++] = 0;
  8193. quad[i++] = 0;
  8194. quad[i++] = 0;
  8195. }
  8196. quad[i++] = x + width;
  8197. quad[i++] = y + height;
  8198. quad[i++] = color.r;
  8199. quad[i++] = color.g;
  8200. quad[i++] = color.b;
  8201. quad[i++] = color.a;
  8202. quad[i++] = region.u2;
  8203. quad[i++] = region.v;
  8204. if (this.twoColorTint) {
  8205. quad[i++] = 0;
  8206. quad[i++] = 0;
  8207. quad[i++] = 0;
  8208. quad[i++] = 0;
  8209. }
  8210. quad[i++] = x;
  8211. quad[i++] = y + height;
  8212. quad[i++] = color.r;
  8213. quad[i++] = color.g;
  8214. quad[i++] = color.b;
  8215. quad[i++] = color.a;
  8216. quad[i++] = region.u;
  8217. quad[i++] = region.v;
  8218. if (this.twoColorTint) {
  8219. quad[i++] = 0;
  8220. quad[i++] = 0;
  8221. quad[i++] = 0;
  8222. quad[i++] = 0;
  8223. }
  8224. this.batcher.draw(region.texture, quad, this.QUAD_TRIANGLES);
  8225. };
  8226. SceneRenderer.prototype.line = function (x, y, x2, y2, color, color2) {
  8227. if (color === void 0) { color = null; }
  8228. if (color2 === void 0) { color2 = null; }
  8229. this.enableRenderer(this.shapes);
  8230. this.shapes.line(x, y, x2, y2, color);
  8231. };
  8232. SceneRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {
  8233. if (color === void 0) { color = null; }
  8234. if (color2 === void 0) { color2 = null; }
  8235. if (color3 === void 0) { color3 = null; }
  8236. this.enableRenderer(this.shapes);
  8237. this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3);
  8238. };
  8239. SceneRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
  8240. if (color === void 0) { color = null; }
  8241. if (color2 === void 0) { color2 = null; }
  8242. if (color3 === void 0) { color3 = null; }
  8243. if (color4 === void 0) { color4 = null; }
  8244. this.enableRenderer(this.shapes);
  8245. this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4);
  8246. };
  8247. SceneRenderer.prototype.rect = function (filled, x, y, width, height, color) {
  8248. if (color === void 0) { color = null; }
  8249. this.enableRenderer(this.shapes);
  8250. this.shapes.rect(filled, x, y, width, height, color);
  8251. };
  8252. SceneRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) {
  8253. if (color === void 0) { color = null; }
  8254. this.enableRenderer(this.shapes);
  8255. this.shapes.rectLine(filled, x1, y1, x2, y2, width, color);
  8256. };
  8257. SceneRenderer.prototype.polygon = function (polygonVertices, offset, count, color) {
  8258. if (color === void 0) { color = null; }
  8259. this.enableRenderer(this.shapes);
  8260. this.shapes.polygon(polygonVertices, offset, count, color);
  8261. };
  8262. SceneRenderer.prototype.circle = function (filled, x, y, radius, color, segments) {
  8263. if (color === void 0) { color = null; }
  8264. if (segments === void 0) { segments = 0; }
  8265. this.enableRenderer(this.shapes);
  8266. this.shapes.circle(filled, x, y, radius, color, segments);
  8267. };
  8268. SceneRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
  8269. if (color === void 0) { color = null; }
  8270. this.enableRenderer(this.shapes);
  8271. this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color);
  8272. };
  8273. SceneRenderer.prototype.end = function () {
  8274. if (this.activeRenderer === this.batcher)
  8275. this.batcher.end();
  8276. else if (this.activeRenderer === this.shapes)
  8277. this.shapes.end();
  8278. this.activeRenderer = null;
  8279. };
  8280. SceneRenderer.prototype.resize = function (resizeMode) {
  8281. var canvas = this.canvas;
  8282. var w = canvas.clientWidth;
  8283. var h = canvas.clientHeight;
  8284. if (canvas.width != w || canvas.height != h) {
  8285. canvas.width = w;
  8286. canvas.height = h;
  8287. }
  8288. this.context.gl.viewport(0, 0, canvas.width, canvas.height);
  8289. if (resizeMode === ResizeMode.Stretch) {
  8290. }
  8291. else if (resizeMode === ResizeMode.Expand) {
  8292. this.camera.setViewport(w, h);
  8293. }
  8294. else if (resizeMode === ResizeMode.Fit) {
  8295. var sourceWidth = canvas.width, sourceHeight = canvas.height;
  8296. var targetWidth = this.camera.viewportWidth, targetHeight = this.camera.viewportHeight;
  8297. var targetRatio = targetHeight / targetWidth;
  8298. var sourceRatio = sourceHeight / sourceWidth;
  8299. var scale = targetRatio < sourceRatio ? targetWidth / sourceWidth : targetHeight / sourceHeight;
  8300. this.camera.viewportWidth = sourceWidth * scale;
  8301. this.camera.viewportHeight = sourceHeight * scale;
  8302. }
  8303. this.camera.update();
  8304. };
  8305. SceneRenderer.prototype.enableRenderer = function (renderer) {
  8306. if (this.activeRenderer === renderer)
  8307. return;
  8308. this.end();
  8309. if (renderer instanceof webgl.PolygonBatcher) {
  8310. this.batcherShader.bind();
  8311. this.batcherShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values);
  8312. this.batcherShader.setUniformi("u_texture", 0);
  8313. this.batcher.begin(this.batcherShader);
  8314. this.activeRenderer = this.batcher;
  8315. }
  8316. else if (renderer instanceof webgl.ShapeRenderer) {
  8317. this.shapesShader.bind();
  8318. this.shapesShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values);
  8319. this.shapes.begin(this.shapesShader);
  8320. this.activeRenderer = this.shapes;
  8321. }
  8322. else {
  8323. this.activeRenderer = this.skeletonDebugRenderer;
  8324. }
  8325. };
  8326. SceneRenderer.prototype.dispose = function () {
  8327. this.batcher.dispose();
  8328. this.batcherShader.dispose();
  8329. this.shapes.dispose();
  8330. this.shapesShader.dispose();
  8331. this.skeletonDebugRenderer.dispose();
  8332. };
  8333. return SceneRenderer;
  8334. }());
  8335. webgl.SceneRenderer = SceneRenderer;
  8336. var ResizeMode;
  8337. (function (ResizeMode) {
  8338. ResizeMode[ResizeMode["Stretch"] = 0] = "Stretch";
  8339. ResizeMode[ResizeMode["Expand"] = 1] = "Expand";
  8340. ResizeMode[ResizeMode["Fit"] = 2] = "Fit";
  8341. })(ResizeMode = webgl.ResizeMode || (webgl.ResizeMode = {}));
  8342. })(webgl = spine.webgl || (spine.webgl = {}));
  8343. })(spine || (spine = {}));
  8344. var spine;
  8345. (function (spine) {
  8346. var webgl;
  8347. (function (webgl) {
  8348. var Shader = (function () {
  8349. function Shader(context, vertexShader, fragmentShader) {
  8350. this.vertexShader = vertexShader;
  8351. this.fragmentShader = fragmentShader;
  8352. this.vs = null;
  8353. this.fs = null;
  8354. this.program = null;
  8355. this.tmp2x2 = new Float32Array(2 * 2);
  8356. this.tmp3x3 = new Float32Array(3 * 3);
  8357. this.tmp4x4 = new Float32Array(4 * 4);
  8358. this.vsSource = vertexShader;
  8359. this.fsSource = fragmentShader;
  8360. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  8361. this.context.addRestorable(this);
  8362. this.compile();
  8363. }
  8364. Shader.prototype.getProgram = function () { return this.program; };
  8365. Shader.prototype.getVertexShader = function () { return this.vertexShader; };
  8366. Shader.prototype.getFragmentShader = function () { return this.fragmentShader; };
  8367. Shader.prototype.getVertexShaderSource = function () { return this.vsSource; };
  8368. Shader.prototype.getFragmentSource = function () { return this.fsSource; };
  8369. Shader.prototype.compile = function () {
  8370. var gl = this.context.gl;
  8371. try {
  8372. this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader);
  8373. this.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader);
  8374. this.program = this.compileProgram(this.vs, this.fs);
  8375. }
  8376. catch (e) {
  8377. this.dispose();
  8378. throw e;
  8379. }
  8380. };
  8381. Shader.prototype.compileShader = function (type, source) {
  8382. var gl = this.context.gl;
  8383. var shader = gl.createShader(type);
  8384. gl.shaderSource(shader, source);
  8385. gl.compileShader(shader);
  8386. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  8387. var error = "Couldn't compile shader: " + gl.getShaderInfoLog(shader);
  8388. gl.deleteShader(shader);
  8389. if (!gl.isContextLost())
  8390. throw new Error(error);
  8391. }
  8392. return shader;
  8393. };
  8394. Shader.prototype.compileProgram = function (vs, fs) {
  8395. var gl = this.context.gl;
  8396. var program = gl.createProgram();
  8397. gl.attachShader(program, vs);
  8398. gl.attachShader(program, fs);
  8399. gl.linkProgram(program);
  8400. if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
  8401. var error = "Couldn't compile shader program: " + gl.getProgramInfoLog(program);
  8402. gl.deleteProgram(program);
  8403. if (!gl.isContextLost())
  8404. throw new Error(error);
  8405. }
  8406. return program;
  8407. };
  8408. Shader.prototype.restore = function () {
  8409. this.compile();
  8410. };
  8411. Shader.prototype.bind = function () {
  8412. this.context.gl.useProgram(this.program);
  8413. };
  8414. Shader.prototype.unbind = function () {
  8415. this.context.gl.useProgram(null);
  8416. };
  8417. Shader.prototype.setUniformi = function (uniform, value) {
  8418. this.context.gl.uniform1i(this.getUniformLocation(uniform), value);
  8419. };
  8420. Shader.prototype.setUniformf = function (uniform, value) {
  8421. this.context.gl.uniform1f(this.getUniformLocation(uniform), value);
  8422. };
  8423. Shader.prototype.setUniform2f = function (uniform, value, value2) {
  8424. this.context.gl.uniform2f(this.getUniformLocation(uniform), value, value2);
  8425. };
  8426. Shader.prototype.setUniform3f = function (uniform, value, value2, value3) {
  8427. this.context.gl.uniform3f(this.getUniformLocation(uniform), value, value2, value3);
  8428. };
  8429. Shader.prototype.setUniform4f = function (uniform, value, value2, value3, value4) {
  8430. this.context.gl.uniform4f(this.getUniformLocation(uniform), value, value2, value3, value4);
  8431. };
  8432. Shader.prototype.setUniform2x2f = function (uniform, value) {
  8433. var gl = this.context.gl;
  8434. this.tmp2x2.set(value);
  8435. gl.uniformMatrix2fv(this.getUniformLocation(uniform), false, this.tmp2x2);
  8436. };
  8437. Shader.prototype.setUniform3x3f = function (uniform, value) {
  8438. var gl = this.context.gl;
  8439. this.tmp3x3.set(value);
  8440. gl.uniformMatrix3fv(this.getUniformLocation(uniform), false, this.tmp3x3);
  8441. };
  8442. Shader.prototype.setUniform4x4f = function (uniform, value) {
  8443. var gl = this.context.gl;
  8444. this.tmp4x4.set(value);
  8445. gl.uniformMatrix4fv(this.getUniformLocation(uniform), false, this.tmp4x4);
  8446. };
  8447. Shader.prototype.getUniformLocation = function (uniform) {
  8448. var gl = this.context.gl;
  8449. var location = gl.getUniformLocation(this.program, uniform);
  8450. if (!location && !gl.isContextLost())
  8451. throw new Error("Couldn't find location for uniform " + uniform);
  8452. return location;
  8453. };
  8454. Shader.prototype.getAttributeLocation = function (attribute) {
  8455. var gl = this.context.gl;
  8456. var location = gl.getAttribLocation(this.program, attribute);
  8457. if (location == -1 && !gl.isContextLost())
  8458. throw new Error("Couldn't find location for attribute " + attribute);
  8459. return location;
  8460. };
  8461. Shader.prototype.dispose = function () {
  8462. this.context.removeRestorable(this);
  8463. var gl = this.context.gl;
  8464. if (this.vs) {
  8465. gl.deleteShader(this.vs);
  8466. this.vs = null;
  8467. }
  8468. if (this.fs) {
  8469. gl.deleteShader(this.fs);
  8470. this.fs = null;
  8471. }
  8472. if (this.program) {
  8473. gl.deleteProgram(this.program);
  8474. this.program = null;
  8475. }
  8476. };
  8477. Shader.newColoredTextured = function (context) {
  8478. 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";
  8479. 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";
  8480. return new Shader(context, vs, fs);
  8481. };
  8482. Shader.newTwoColoredTextured = function (context) {
  8483. 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";
  8484. 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";
  8485. return new Shader(context, vs, fs);
  8486. };
  8487. Shader.newColored = function (context) {
  8488. 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";
  8489. 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";
  8490. return new Shader(context, vs, fs);
  8491. };
  8492. Shader.MVP_MATRIX = "u_projTrans";
  8493. Shader.POSITION = "a_position";
  8494. Shader.COLOR = "a_color";
  8495. Shader.COLOR2 = "a_color2";
  8496. Shader.TEXCOORDS = "a_texCoords";
  8497. Shader.SAMPLER = "u_texture";
  8498. return Shader;
  8499. }());
  8500. webgl.Shader = Shader;
  8501. })(webgl = spine.webgl || (spine.webgl = {}));
  8502. })(spine || (spine = {}));
  8503. var spine;
  8504. (function (spine) {
  8505. var webgl;
  8506. (function (webgl) {
  8507. var ShapeRenderer = (function () {
  8508. function ShapeRenderer(context, maxVertices) {
  8509. if (maxVertices === void 0) { maxVertices = 10920; }
  8510. this.isDrawing = false;
  8511. this.shapeType = ShapeType.Filled;
  8512. this.color = new spine.Color(1, 1, 1, 1);
  8513. this.vertexIndex = 0;
  8514. this.tmp = new spine.Vector2();
  8515. if (maxVertices > 10920)
  8516. throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
  8517. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  8518. this.mesh = new webgl.Mesh(context, [new webgl.Position2Attribute(), new webgl.ColorAttribute()], maxVertices, 0);
  8519. this.srcBlend = this.context.gl.SRC_ALPHA;
  8520. this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;
  8521. }
  8522. ShapeRenderer.prototype.begin = function (shader) {
  8523. if (this.isDrawing)
  8524. throw new Error("ShapeRenderer.begin() has already been called");
  8525. this.shader = shader;
  8526. this.vertexIndex = 0;
  8527. this.isDrawing = true;
  8528. var gl = this.context.gl;
  8529. gl.enable(gl.BLEND);
  8530. gl.blendFunc(this.srcBlend, this.dstBlend);
  8531. };
  8532. ShapeRenderer.prototype.setBlendMode = function (srcBlend, dstBlend) {
  8533. var gl = this.context.gl;
  8534. this.srcBlend = srcBlend;
  8535. this.dstBlend = dstBlend;
  8536. if (this.isDrawing) {
  8537. this.flush();
  8538. gl.blendFunc(this.srcBlend, this.dstBlend);
  8539. }
  8540. };
  8541. ShapeRenderer.prototype.setColor = function (color) {
  8542. this.color.setFromColor(color);
  8543. };
  8544. ShapeRenderer.prototype.setColorWith = function (r, g, b, a) {
  8545. this.color.set(r, g, b, a);
  8546. };
  8547. ShapeRenderer.prototype.point = function (x, y, color) {
  8548. if (color === void 0) { color = null; }
  8549. this.check(ShapeType.Point, 1);
  8550. if (color === null)
  8551. color = this.color;
  8552. this.vertex(x, y, color);
  8553. };
  8554. ShapeRenderer.prototype.line = function (x, y, x2, y2, color) {
  8555. if (color === void 0) { color = null; }
  8556. this.check(ShapeType.Line, 2);
  8557. var vertices = this.mesh.getVertices();
  8558. var idx = this.vertexIndex;
  8559. if (color === null)
  8560. color = this.color;
  8561. this.vertex(x, y, color);
  8562. this.vertex(x2, y2, color);
  8563. };
  8564. ShapeRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {
  8565. if (color === void 0) { color = null; }
  8566. if (color2 === void 0) { color2 = null; }
  8567. if (color3 === void 0) { color3 = null; }
  8568. this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
  8569. var vertices = this.mesh.getVertices();
  8570. var idx = this.vertexIndex;
  8571. if (color === null)
  8572. color = this.color;
  8573. if (color2 === null)
  8574. color2 = this.color;
  8575. if (color3 === null)
  8576. color3 = this.color;
  8577. if (filled) {
  8578. this.vertex(x, y, color);
  8579. this.vertex(x2, y2, color2);
  8580. this.vertex(x3, y3, color3);
  8581. }
  8582. else {
  8583. this.vertex(x, y, color);
  8584. this.vertex(x2, y2, color2);
  8585. this.vertex(x2, y2, color);
  8586. this.vertex(x3, y3, color2);
  8587. this.vertex(x3, y3, color);
  8588. this.vertex(x, y, color2);
  8589. }
  8590. };
  8591. ShapeRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
  8592. if (color === void 0) { color = null; }
  8593. if (color2 === void 0) { color2 = null; }
  8594. if (color3 === void 0) { color3 = null; }
  8595. if (color4 === void 0) { color4 = null; }
  8596. this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
  8597. var vertices = this.mesh.getVertices();
  8598. var idx = this.vertexIndex;
  8599. if (color === null)
  8600. color = this.color;
  8601. if (color2 === null)
  8602. color2 = this.color;
  8603. if (color3 === null)
  8604. color3 = this.color;
  8605. if (color4 === null)
  8606. color4 = this.color;
  8607. if (filled) {
  8608. this.vertex(x, y, color);
  8609. this.vertex(x2, y2, color2);
  8610. this.vertex(x3, y3, color3);
  8611. this.vertex(x3, y3, color3);
  8612. this.vertex(x4, y4, color4);
  8613. this.vertex(x, y, color);
  8614. }
  8615. else {
  8616. this.vertex(x, y, color);
  8617. this.vertex(x2, y2, color2);
  8618. this.vertex(x2, y2, color2);
  8619. this.vertex(x3, y3, color3);
  8620. this.vertex(x3, y3, color3);
  8621. this.vertex(x4, y4, color4);
  8622. this.vertex(x4, y4, color4);
  8623. this.vertex(x, y, color);
  8624. }
  8625. };
  8626. ShapeRenderer.prototype.rect = function (filled, x, y, width, height, color) {
  8627. if (color === void 0) { color = null; }
  8628. this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color);
  8629. };
  8630. ShapeRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) {
  8631. if (color === void 0) { color = null; }
  8632. this.check(filled ? ShapeType.Filled : ShapeType.Line, 8);
  8633. if (color === null)
  8634. color = this.color;
  8635. var t = this.tmp.set(y2 - y1, x1 - x2);
  8636. t.normalize();
  8637. width *= 0.5;
  8638. var tx = t.x * width;
  8639. var ty = t.y * width;
  8640. if (!filled) {
  8641. this.vertex(x1 + tx, y1 + ty, color);
  8642. this.vertex(x1 - tx, y1 - ty, color);
  8643. this.vertex(x2 + tx, y2 + ty, color);
  8644. this.vertex(x2 - tx, y2 - ty, color);
  8645. this.vertex(x2 + tx, y2 + ty, color);
  8646. this.vertex(x1 + tx, y1 + ty, color);
  8647. this.vertex(x2 - tx, y2 - ty, color);
  8648. this.vertex(x1 - tx, y1 - ty, color);
  8649. }
  8650. else {
  8651. this.vertex(x1 + tx, y1 + ty, color);
  8652. this.vertex(x1 - tx, y1 - ty, color);
  8653. this.vertex(x2 + tx, y2 + ty, color);
  8654. this.vertex(x2 - tx, y2 - ty, color);
  8655. this.vertex(x2 + tx, y2 + ty, color);
  8656. this.vertex(x1 - tx, y1 - ty, color);
  8657. }
  8658. };
  8659. ShapeRenderer.prototype.x = function (x, y, size) {
  8660. this.line(x - size, y - size, x + size, y + size);
  8661. this.line(x - size, y + size, x + size, y - size);
  8662. };
  8663. ShapeRenderer.prototype.polygon = function (polygonVertices, offset, count, color) {
  8664. if (color === void 0) { color = null; }
  8665. if (count < 3)
  8666. throw new Error("Polygon must contain at least 3 vertices");
  8667. this.check(ShapeType.Line, count * 2);
  8668. if (color === null)
  8669. color = this.color;
  8670. var vertices = this.mesh.getVertices();
  8671. var idx = this.vertexIndex;
  8672. offset <<= 1;
  8673. count <<= 1;
  8674. var firstX = polygonVertices[offset];
  8675. var firstY = polygonVertices[offset + 1];
  8676. var last = offset + count;
  8677. for (var i = offset, n = offset + count - 2; i < n; i += 2) {
  8678. var x1 = polygonVertices[i];
  8679. var y1 = polygonVertices[i + 1];
  8680. var x2 = 0;
  8681. var y2 = 0;
  8682. if (i + 2 >= last) {
  8683. x2 = firstX;
  8684. y2 = firstY;
  8685. }
  8686. else {
  8687. x2 = polygonVertices[i + 2];
  8688. y2 = polygonVertices[i + 3];
  8689. }
  8690. this.vertex(x1, y1, color);
  8691. this.vertex(x2, y2, color);
  8692. }
  8693. };
  8694. ShapeRenderer.prototype.circle = function (filled, x, y, radius, color, segments) {
  8695. if (color === void 0) { color = null; }
  8696. if (segments === void 0) { segments = 0; }
  8697. if (segments === 0)
  8698. segments = Math.max(1, (6 * spine.MathUtils.cbrt(radius)) | 0);
  8699. if (segments <= 0)
  8700. throw new Error("segments must be > 0.");
  8701. if (color === null)
  8702. color = this.color;
  8703. var angle = 2 * spine.MathUtils.PI / segments;
  8704. var cos = Math.cos(angle);
  8705. var sin = Math.sin(angle);
  8706. var cx = radius, cy = 0;
  8707. if (!filled) {
  8708. this.check(ShapeType.Line, segments * 2 + 2);
  8709. for (var i = 0; i < segments; i++) {
  8710. this.vertex(x + cx, y + cy, color);
  8711. var temp_1 = cx;
  8712. cx = cos * cx - sin * cy;
  8713. cy = sin * temp_1 + cos * cy;
  8714. this.vertex(x + cx, y + cy, color);
  8715. }
  8716. this.vertex(x + cx, y + cy, color);
  8717. }
  8718. else {
  8719. this.check(ShapeType.Filled, segments * 3 + 3);
  8720. segments--;
  8721. for (var i = 0; i < segments; i++) {
  8722. this.vertex(x, y, color);
  8723. this.vertex(x + cx, y + cy, color);
  8724. var temp_2 = cx;
  8725. cx = cos * cx - sin * cy;
  8726. cy = sin * temp_2 + cos * cy;
  8727. this.vertex(x + cx, y + cy, color);
  8728. }
  8729. this.vertex(x, y, color);
  8730. this.vertex(x + cx, y + cy, color);
  8731. }
  8732. var temp = cx;
  8733. cx = radius;
  8734. cy = 0;
  8735. this.vertex(x + cx, y + cy, color);
  8736. };
  8737. ShapeRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
  8738. if (color === void 0) { color = null; }
  8739. this.check(ShapeType.Line, segments * 2 + 2);
  8740. if (color === null)
  8741. color = this.color;
  8742. var subdiv_step = 1 / segments;
  8743. var subdiv_step2 = subdiv_step * subdiv_step;
  8744. var subdiv_step3 = subdiv_step * subdiv_step * subdiv_step;
  8745. var pre1 = 3 * subdiv_step;
  8746. var pre2 = 3 * subdiv_step2;
  8747. var pre4 = 6 * subdiv_step2;
  8748. var pre5 = 6 * subdiv_step3;
  8749. var tmp1x = x1 - cx1 * 2 + cx2;
  8750. var tmp1y = y1 - cy1 * 2 + cy2;
  8751. var tmp2x = (cx1 - cx2) * 3 - x1 + x2;
  8752. var tmp2y = (cy1 - cy2) * 3 - y1 + y2;
  8753. var fx = x1;
  8754. var fy = y1;
  8755. var dfx = (cx1 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3;
  8756. var dfy = (cy1 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3;
  8757. var ddfx = tmp1x * pre4 + tmp2x * pre5;
  8758. var ddfy = tmp1y * pre4 + tmp2y * pre5;
  8759. var dddfx = tmp2x * pre5;
  8760. var dddfy = tmp2y * pre5;
  8761. while (segments-- > 0) {
  8762. this.vertex(fx, fy, color);
  8763. fx += dfx;
  8764. fy += dfy;
  8765. dfx += ddfx;
  8766. dfy += ddfy;
  8767. ddfx += dddfx;
  8768. ddfy += dddfy;
  8769. this.vertex(fx, fy, color);
  8770. }
  8771. this.vertex(fx, fy, color);
  8772. this.vertex(x2, y2, color);
  8773. };
  8774. ShapeRenderer.prototype.vertex = function (x, y, color) {
  8775. var idx = this.vertexIndex;
  8776. var vertices = this.mesh.getVertices();
  8777. vertices[idx++] = x;
  8778. vertices[idx++] = y;
  8779. vertices[idx++] = color.r;
  8780. vertices[idx++] = color.g;
  8781. vertices[idx++] = color.b;
  8782. vertices[idx++] = color.a;
  8783. this.vertexIndex = idx;
  8784. };
  8785. ShapeRenderer.prototype.end = function () {
  8786. if (!this.isDrawing)
  8787. throw new Error("ShapeRenderer.begin() has not been called");
  8788. this.flush();
  8789. this.context.gl.disable(this.context.gl.BLEND);
  8790. this.isDrawing = false;
  8791. };
  8792. ShapeRenderer.prototype.flush = function () {
  8793. if (this.vertexIndex == 0)
  8794. return;
  8795. this.mesh.setVerticesLength(this.vertexIndex);
  8796. this.mesh.draw(this.shader, this.shapeType);
  8797. this.vertexIndex = 0;
  8798. };
  8799. ShapeRenderer.prototype.check = function (shapeType, numVertices) {
  8800. if (!this.isDrawing)
  8801. throw new Error("ShapeRenderer.begin() has not been called");
  8802. if (this.shapeType == shapeType) {
  8803. if (this.mesh.maxVertices() - this.mesh.numVertices() < numVertices)
  8804. this.flush();
  8805. else
  8806. return;
  8807. }
  8808. else {
  8809. this.flush();
  8810. this.shapeType = shapeType;
  8811. }
  8812. };
  8813. ShapeRenderer.prototype.dispose = function () {
  8814. this.mesh.dispose();
  8815. };
  8816. return ShapeRenderer;
  8817. }());
  8818. webgl.ShapeRenderer = ShapeRenderer;
  8819. var ShapeType;
  8820. (function (ShapeType) {
  8821. ShapeType[ShapeType["Point"] = 0] = "Point";
  8822. ShapeType[ShapeType["Line"] = 1] = "Line";
  8823. ShapeType[ShapeType["Filled"] = 4] = "Filled";
  8824. })(ShapeType = webgl.ShapeType || (webgl.ShapeType = {}));
  8825. })(webgl = spine.webgl || (spine.webgl = {}));
  8826. })(spine || (spine = {}));
  8827. var spine;
  8828. (function (spine) {
  8829. var webgl;
  8830. (function (webgl) {
  8831. var SkeletonDebugRenderer = (function () {
  8832. function SkeletonDebugRenderer(context) {
  8833. this.boneLineColor = new spine.Color(1, 0, 0, 1);
  8834. this.boneOriginColor = new spine.Color(0, 1, 0, 1);
  8835. this.attachmentLineColor = new spine.Color(0, 0, 1, 0.5);
  8836. this.triangleLineColor = new spine.Color(1, 0.64, 0, 0.5);
  8837. this.pathColor = new spine.Color().setFromString("FF7F00");
  8838. this.clipColor = new spine.Color(0.8, 0, 0, 2);
  8839. this.aabbColor = new spine.Color(0, 1, 0, 0.5);
  8840. this.drawBones = true;
  8841. this.drawRegionAttachments = true;
  8842. this.drawBoundingBoxes = true;
  8843. this.drawMeshHull = true;
  8844. this.drawMeshTriangles = true;
  8845. this.drawPaths = true;
  8846. this.drawSkeletonXY = false;
  8847. this.drawClipping = true;
  8848. this.premultipliedAlpha = false;
  8849. this.scale = 1;
  8850. this.boneWidth = 2;
  8851. this.bounds = new spine.SkeletonBounds();
  8852. this.temp = new Array();
  8853. this.vertices = spine.Utils.newFloatArray(2 * 1024);
  8854. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  8855. }
  8856. SkeletonDebugRenderer.prototype.draw = function (shapes, skeleton, ignoredBones) {
  8857. if (ignoredBones === void 0) { ignoredBones = null; }
  8858. var skeletonX = skeleton.x;
  8859. var skeletonY = skeleton.y;
  8860. var gl = this.context.gl;
  8861. var srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;
  8862. shapes.setBlendMode(srcFunc, gl.ONE_MINUS_SRC_ALPHA);
  8863. var bones = skeleton.bones;
  8864. if (this.drawBones) {
  8865. shapes.setColor(this.boneLineColor);
  8866. for (var i = 0, n = bones.length; i < n; i++) {
  8867. var bone = bones[i];
  8868. if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)
  8869. continue;
  8870. if (bone.parent == null)
  8871. continue;
  8872. var x = skeletonX + bone.data.length * bone.a + bone.worldX;
  8873. var y = skeletonY + bone.data.length * bone.c + bone.worldY;
  8874. shapes.rectLine(true, skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, this.boneWidth * this.scale);
  8875. }
  8876. if (this.drawSkeletonXY)
  8877. shapes.x(skeletonX, skeletonY, 4 * this.scale);
  8878. }
  8879. if (this.drawRegionAttachments) {
  8880. shapes.setColor(this.attachmentLineColor);
  8881. var slots = skeleton.slots;
  8882. for (var i = 0, n = slots.length; i < n; i++) {
  8883. var slot = slots[i];
  8884. var attachment = slot.getAttachment();
  8885. if (attachment instanceof spine.RegionAttachment) {
  8886. var regionAttachment = attachment;
  8887. var vertices = this.vertices;
  8888. regionAttachment.computeWorldVertices(slot.bone, vertices, 0, 2);
  8889. shapes.line(vertices[0], vertices[1], vertices[2], vertices[3]);
  8890. shapes.line(vertices[2], vertices[3], vertices[4], vertices[5]);
  8891. shapes.line(vertices[4], vertices[5], vertices[6], vertices[7]);
  8892. shapes.line(vertices[6], vertices[7], vertices[0], vertices[1]);
  8893. }
  8894. }
  8895. }
  8896. if (this.drawMeshHull || this.drawMeshTriangles) {
  8897. var slots = skeleton.slots;
  8898. for (var i = 0, n = slots.length; i < n; i++) {
  8899. var slot = slots[i];
  8900. var attachment = slot.getAttachment();
  8901. if (!(attachment instanceof spine.MeshAttachment))
  8902. continue;
  8903. var mesh = attachment;
  8904. var vertices = this.vertices;
  8905. mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 2);
  8906. var triangles = mesh.triangles;
  8907. var hullLength = mesh.hullLength;
  8908. if (this.drawMeshTriangles) {
  8909. shapes.setColor(this.triangleLineColor);
  8910. for (var ii = 0, nn = triangles.length; ii < nn; ii += 3) {
  8911. var v1 = triangles[ii] * 2, v2 = triangles[ii + 1] * 2, v3 = triangles[ii + 2] * 2;
  8912. shapes.triangle(false, vertices[v1], vertices[v1 + 1], vertices[v2], vertices[v2 + 1], vertices[v3], vertices[v3 + 1]);
  8913. }
  8914. }
  8915. if (this.drawMeshHull && hullLength > 0) {
  8916. shapes.setColor(this.attachmentLineColor);
  8917. hullLength = (hullLength >> 1) * 2;
  8918. var lastX = vertices[hullLength - 2], lastY = vertices[hullLength - 1];
  8919. for (var ii = 0, nn = hullLength; ii < nn; ii += 2) {
  8920. var x = vertices[ii], y = vertices[ii + 1];
  8921. shapes.line(x, y, lastX, lastY);
  8922. lastX = x;
  8923. lastY = y;
  8924. }
  8925. }
  8926. }
  8927. }
  8928. if (this.drawBoundingBoxes) {
  8929. var bounds = this.bounds;
  8930. bounds.update(skeleton, true);
  8931. shapes.setColor(this.aabbColor);
  8932. shapes.rect(false, bounds.minX, bounds.minY, bounds.getWidth(), bounds.getHeight());
  8933. var polygons = bounds.polygons;
  8934. var boxes = bounds.boundingBoxes;
  8935. for (var i = 0, n = polygons.length; i < n; i++) {
  8936. var polygon = polygons[i];
  8937. shapes.setColor(boxes[i].color);
  8938. shapes.polygon(polygon, 0, polygon.length);
  8939. }
  8940. }
  8941. if (this.drawPaths) {
  8942. var slots = skeleton.slots;
  8943. for (var i = 0, n = slots.length; i < n; i++) {
  8944. var slot = slots[i];
  8945. var attachment = slot.getAttachment();
  8946. if (!(attachment instanceof spine.PathAttachment))
  8947. continue;
  8948. var path = attachment;
  8949. var nn = path.worldVerticesLength;
  8950. var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
  8951. path.computeWorldVertices(slot, 0, nn, world, 0, 2);
  8952. var color = this.pathColor;
  8953. var x1 = world[2], y1 = world[3], x2 = 0, y2 = 0;
  8954. if (path.closed) {
  8955. shapes.setColor(color);
  8956. var cx1 = world[0], cy1 = world[1], cx2 = world[nn - 2], cy2 = world[nn - 1];
  8957. x2 = world[nn - 4];
  8958. y2 = world[nn - 3];
  8959. shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);
  8960. shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);
  8961. shapes.line(x1, y1, cx1, cy1);
  8962. shapes.line(x2, y2, cx2, cy2);
  8963. }
  8964. nn -= 4;
  8965. for (var ii = 4; ii < nn; ii += 6) {
  8966. var cx1 = world[ii], cy1 = world[ii + 1], cx2 = world[ii + 2], cy2 = world[ii + 3];
  8967. x2 = world[ii + 4];
  8968. y2 = world[ii + 5];
  8969. shapes.setColor(color);
  8970. shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);
  8971. shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);
  8972. shapes.line(x1, y1, cx1, cy1);
  8973. shapes.line(x2, y2, cx2, cy2);
  8974. x1 = x2;
  8975. y1 = y2;
  8976. }
  8977. }
  8978. }
  8979. if (this.drawBones) {
  8980. shapes.setColor(this.boneOriginColor);
  8981. for (var i = 0, n = bones.length; i < n; i++) {
  8982. var bone = bones[i];
  8983. if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)
  8984. continue;
  8985. shapes.circle(true, skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * this.scale, SkeletonDebugRenderer.GREEN, 8);
  8986. }
  8987. }
  8988. if (this.drawClipping) {
  8989. var slots = skeleton.slots;
  8990. shapes.setColor(this.clipColor);
  8991. for (var i = 0, n = slots.length; i < n; i++) {
  8992. var slot = slots[i];
  8993. var attachment = slot.getAttachment();
  8994. if (!(attachment instanceof spine.ClippingAttachment))
  8995. continue;
  8996. var clip = attachment;
  8997. var nn = clip.worldVerticesLength;
  8998. var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
  8999. clip.computeWorldVertices(slot, 0, nn, world, 0, 2);
  9000. for (var i_20 = 0, n_2 = world.length; i_20 < n_2; i_20 += 2) {
  9001. var x = world[i_20];
  9002. var y = world[i_20 + 1];
  9003. var x2 = world[(i_20 + 2) % world.length];
  9004. var y2 = world[(i_20 + 3) % world.length];
  9005. shapes.line(x, y, x2, y2);
  9006. }
  9007. }
  9008. }
  9009. };
  9010. SkeletonDebugRenderer.prototype.dispose = function () {
  9011. };
  9012. SkeletonDebugRenderer.LIGHT_GRAY = new spine.Color(192 / 255, 192 / 255, 192 / 255, 1);
  9013. SkeletonDebugRenderer.GREEN = new spine.Color(0, 1, 0, 1);
  9014. return SkeletonDebugRenderer;
  9015. }());
  9016. webgl.SkeletonDebugRenderer = SkeletonDebugRenderer;
  9017. })(webgl = spine.webgl || (spine.webgl = {}));
  9018. })(spine || (spine = {}));
  9019. var spine;
  9020. (function (spine) {
  9021. var webgl;
  9022. (function (webgl) {
  9023. var Renderable = (function () {
  9024. function Renderable(vertices, numVertices, numFloats) {
  9025. this.vertices = vertices;
  9026. this.numVertices = numVertices;
  9027. this.numFloats = numFloats;
  9028. }
  9029. return Renderable;
  9030. }());
  9031. ;
  9032. var SkeletonRenderer = (function () {
  9033. function SkeletonRenderer(context, twoColorTint) {
  9034. if (twoColorTint === void 0) { twoColorTint = true; }
  9035. this.premultipliedAlpha = false;
  9036. this.vertexEffect = null;
  9037. this.tempColor = new spine.Color();
  9038. this.tempColor2 = new spine.Color();
  9039. this.vertexSize = 2 + 2 + 4;
  9040. this.twoColorTint = false;
  9041. this.renderable = new Renderable(null, 0, 0);
  9042. this.clipper = new spine.SkeletonClipping();
  9043. this.temp = new spine.Vector2();
  9044. this.temp2 = new spine.Vector2();
  9045. this.temp3 = new spine.Color();
  9046. this.temp4 = new spine.Color();
  9047. this.twoColorTint = twoColorTint;
  9048. if (twoColorTint)
  9049. this.vertexSize += 4;
  9050. this.vertices = spine.Utils.newFloatArray(this.vertexSize * 1024);
  9051. }
  9052. SkeletonRenderer.prototype.draw = function (batcher, skeleton, slotRangeStart, slotRangeEnd) {
  9053. if (slotRangeStart === void 0) { slotRangeStart = -1; }
  9054. if (slotRangeEnd === void 0) { slotRangeEnd = -1; }
  9055. var clipper = this.clipper;
  9056. var premultipliedAlpha = this.premultipliedAlpha;
  9057. var twoColorTint = this.twoColorTint;
  9058. var blendMode = null;
  9059. var tempPos = this.temp;
  9060. var tempUv = this.temp2;
  9061. var tempLight = this.temp3;
  9062. var tempDark = this.temp4;
  9063. var renderable = this.renderable;
  9064. var uvs = null;
  9065. var triangles = null;
  9066. var drawOrder = skeleton.drawOrder;
  9067. var attachmentColor = null;
  9068. var skeletonColor = skeleton.color;
  9069. var vertexSize = twoColorTint ? 12 : 8;
  9070. var inRange = false;
  9071. if (slotRangeStart == -1)
  9072. inRange = true;
  9073. for (var i = 0, n = drawOrder.length; i < n; i++) {
  9074. var clippedVertexSize = clipper.isClipping() ? 2 : vertexSize;
  9075. var slot = drawOrder[i];
  9076. if (slotRangeStart >= 0 && slotRangeStart == slot.data.index) {
  9077. inRange = true;
  9078. }
  9079. if (!inRange) {
  9080. clipper.clipEndWithSlot(slot);
  9081. continue;
  9082. }
  9083. if (slotRangeEnd >= 0 && slotRangeEnd == slot.data.index) {
  9084. inRange = false;
  9085. }
  9086. var attachment = slot.getAttachment();
  9087. var texture = null;
  9088. if (attachment instanceof spine.RegionAttachment) {
  9089. var region = attachment;
  9090. renderable.vertices = this.vertices;
  9091. renderable.numVertices = 4;
  9092. renderable.numFloats = clippedVertexSize << 2;
  9093. region.computeWorldVertices(slot.bone, renderable.vertices, 0, clippedVertexSize);
  9094. triangles = SkeletonRenderer.QUAD_TRIANGLES;
  9095. uvs = region.uvs;
  9096. texture = region.region.renderObject.texture;
  9097. attachmentColor = region.color;
  9098. }
  9099. else if (attachment instanceof spine.MeshAttachment) {
  9100. var mesh = attachment;
  9101. renderable.vertices = this.vertices;
  9102. renderable.numVertices = (mesh.worldVerticesLength >> 1);
  9103. renderable.numFloats = renderable.numVertices * clippedVertexSize;
  9104. if (renderable.numFloats > renderable.vertices.length) {
  9105. renderable.vertices = this.vertices = spine.Utils.newFloatArray(renderable.numFloats);
  9106. }
  9107. mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize);
  9108. triangles = mesh.triangles;
  9109. texture = mesh.region.renderObject.texture;
  9110. uvs = mesh.uvs;
  9111. attachmentColor = mesh.color;
  9112. }
  9113. else if (attachment instanceof spine.ClippingAttachment) {
  9114. var clip = (attachment);
  9115. clipper.clipStart(slot, clip);
  9116. continue;
  9117. }
  9118. else {
  9119. clipper.clipEndWithSlot(slot);
  9120. continue;
  9121. }
  9122. if (texture != null) {
  9123. var slotColor = slot.color;
  9124. var finalColor = this.tempColor;
  9125. finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r;
  9126. finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g;
  9127. finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;
  9128. finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a;
  9129. if (premultipliedAlpha) {
  9130. finalColor.r *= finalColor.a;
  9131. finalColor.g *= finalColor.a;
  9132. finalColor.b *= finalColor.a;
  9133. }
  9134. var darkColor = this.tempColor2;
  9135. if (slot.darkColor == null)
  9136. darkColor.set(0, 0, 0, 1.0);
  9137. else {
  9138. if (premultipliedAlpha) {
  9139. darkColor.r = slot.darkColor.r * finalColor.a;
  9140. darkColor.g = slot.darkColor.g * finalColor.a;
  9141. darkColor.b = slot.darkColor.b * finalColor.a;
  9142. }
  9143. else {
  9144. darkColor.setFromColor(slot.darkColor);
  9145. }
  9146. darkColor.a = premultipliedAlpha ? 1.0 : 0.0;
  9147. }
  9148. var slotBlendMode = slot.data.blendMode;
  9149. if (slotBlendMode != blendMode) {
  9150. blendMode = slotBlendMode;
  9151. batcher.setBlendMode(webgl.WebGLBlendModeConverter.getSourceGLBlendMode(blendMode, premultipliedAlpha), webgl.WebGLBlendModeConverter.getDestGLBlendMode(blendMode));
  9152. }
  9153. if (clipper.isClipping()) {
  9154. clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
  9155. var clippedVertices = new Float32Array(clipper.clippedVertices);
  9156. var clippedTriangles = clipper.clippedTriangles;
  9157. if (this.vertexEffect != null) {
  9158. var vertexEffect = this.vertexEffect;
  9159. var verts = clippedVertices;
  9160. if (!twoColorTint) {
  9161. for (var v = 0, n_3 = clippedVertices.length; v < n_3; v += vertexSize) {
  9162. tempPos.x = verts[v];
  9163. tempPos.y = verts[v + 1];
  9164. tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
  9165. tempUv.x = verts[v + 6];
  9166. tempUv.y = verts[v + 7];
  9167. tempDark.set(0, 0, 0, 0);
  9168. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  9169. verts[v] = tempPos.x;
  9170. verts[v + 1] = tempPos.y;
  9171. verts[v + 2] = tempLight.r;
  9172. verts[v + 3] = tempLight.g;
  9173. verts[v + 4] = tempLight.b;
  9174. verts[v + 5] = tempLight.a;
  9175. verts[v + 6] = tempUv.x;
  9176. verts[v + 7] = tempUv.y;
  9177. }
  9178. }
  9179. else {
  9180. for (var v = 0, n_4 = clippedVertices.length; v < n_4; v += vertexSize) {
  9181. tempPos.x = verts[v];
  9182. tempPos.y = verts[v + 1];
  9183. tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
  9184. tempUv.x = verts[v + 6];
  9185. tempUv.y = verts[v + 7];
  9186. tempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]);
  9187. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  9188. verts[v] = tempPos.x;
  9189. verts[v + 1] = tempPos.y;
  9190. verts[v + 2] = tempLight.r;
  9191. verts[v + 3] = tempLight.g;
  9192. verts[v + 4] = tempLight.b;
  9193. verts[v + 5] = tempLight.a;
  9194. verts[v + 6] = tempUv.x;
  9195. verts[v + 7] = tempUv.y;
  9196. verts[v + 8] = tempDark.r;
  9197. verts[v + 9] = tempDark.g;
  9198. verts[v + 10] = tempDark.b;
  9199. verts[v + 11] = tempDark.a;
  9200. }
  9201. }
  9202. }
  9203. batcher.draw(texture, clippedVertices, clippedTriangles);
  9204. }
  9205. else {
  9206. var verts = renderable.vertices;
  9207. if (this.vertexEffect != null) {
  9208. var vertexEffect = this.vertexEffect;
  9209. if (!twoColorTint) {
  9210. for (var v = 0, u = 0, n_5 = renderable.numFloats; v < n_5; v += vertexSize, u += 2) {
  9211. tempPos.x = verts[v];
  9212. tempPos.y = verts[v + 1];
  9213. tempUv.x = uvs[u];
  9214. tempUv.y = uvs[u + 1];
  9215. tempLight.setFromColor(finalColor);
  9216. tempDark.set(0, 0, 0, 0);
  9217. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  9218. verts[v] = tempPos.x;
  9219. verts[v + 1] = tempPos.y;
  9220. verts[v + 2] = tempLight.r;
  9221. verts[v + 3] = tempLight.g;
  9222. verts[v + 4] = tempLight.b;
  9223. verts[v + 5] = tempLight.a;
  9224. verts[v + 6] = tempUv.x;
  9225. verts[v + 7] = tempUv.y;
  9226. }
  9227. }
  9228. else {
  9229. for (var v = 0, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) {
  9230. tempPos.x = verts[v];
  9231. tempPos.y = verts[v + 1];
  9232. tempUv.x = uvs[u];
  9233. tempUv.y = uvs[u + 1];
  9234. tempLight.setFromColor(finalColor);
  9235. tempDark.setFromColor(darkColor);
  9236. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  9237. verts[v] = tempPos.x;
  9238. verts[v + 1] = tempPos.y;
  9239. verts[v + 2] = tempLight.r;
  9240. verts[v + 3] = tempLight.g;
  9241. verts[v + 4] = tempLight.b;
  9242. verts[v + 5] = tempLight.a;
  9243. verts[v + 6] = tempUv.x;
  9244. verts[v + 7] = tempUv.y;
  9245. verts[v + 8] = tempDark.r;
  9246. verts[v + 9] = tempDark.g;
  9247. verts[v + 10] = tempDark.b;
  9248. verts[v + 11] = tempDark.a;
  9249. }
  9250. }
  9251. }
  9252. else {
  9253. if (!twoColorTint) {
  9254. for (var v = 2, u = 0, n_7 = renderable.numFloats; v < n_7; v += vertexSize, u += 2) {
  9255. verts[v] = finalColor.r;
  9256. verts[v + 1] = finalColor.g;
  9257. verts[v + 2] = finalColor.b;
  9258. verts[v + 3] = finalColor.a;
  9259. verts[v + 4] = uvs[u];
  9260. verts[v + 5] = uvs[u + 1];
  9261. }
  9262. }
  9263. else {
  9264. for (var v = 2, u = 0, n_8 = renderable.numFloats; v < n_8; v += vertexSize, u += 2) {
  9265. verts[v] = finalColor.r;
  9266. verts[v + 1] = finalColor.g;
  9267. verts[v + 2] = finalColor.b;
  9268. verts[v + 3] = finalColor.a;
  9269. verts[v + 4] = uvs[u];
  9270. verts[v + 5] = uvs[u + 1];
  9271. verts[v + 6] = darkColor.r;
  9272. verts[v + 7] = darkColor.g;
  9273. verts[v + 8] = darkColor.b;
  9274. verts[v + 9] = darkColor.a;
  9275. }
  9276. }
  9277. }
  9278. var view = renderable.vertices.subarray(0, renderable.numFloats);
  9279. batcher.draw(texture, view, triangles);
  9280. }
  9281. }
  9282. clipper.clipEndWithSlot(slot);
  9283. }
  9284. clipper.clipEnd();
  9285. };
  9286. SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
  9287. return SkeletonRenderer;
  9288. }());
  9289. webgl.SkeletonRenderer = SkeletonRenderer;
  9290. })(webgl = spine.webgl || (spine.webgl = {}));
  9291. })(spine || (spine = {}));
  9292. var spine;
  9293. (function (spine) {
  9294. var webgl;
  9295. (function (webgl) {
  9296. var Vector3 = (function () {
  9297. function Vector3(x, y, z) {
  9298. if (x === void 0) { x = 0; }
  9299. if (y === void 0) { y = 0; }
  9300. if (z === void 0) { z = 0; }
  9301. this.x = 0;
  9302. this.y = 0;
  9303. this.z = 0;
  9304. this.x = x;
  9305. this.y = y;
  9306. this.z = z;
  9307. }
  9308. Vector3.prototype.setFrom = function (v) {
  9309. this.x = v.x;
  9310. this.y = v.y;
  9311. this.z = v.z;
  9312. return this;
  9313. };
  9314. Vector3.prototype.set = function (x, y, z) {
  9315. this.x = x;
  9316. this.y = y;
  9317. this.z = z;
  9318. return this;
  9319. };
  9320. Vector3.prototype.add = function (v) {
  9321. this.x += v.x;
  9322. this.y += v.y;
  9323. this.z += v.z;
  9324. return this;
  9325. };
  9326. Vector3.prototype.sub = function (v) {
  9327. this.x -= v.x;
  9328. this.y -= v.y;
  9329. this.z -= v.z;
  9330. return this;
  9331. };
  9332. Vector3.prototype.scale = function (s) {
  9333. this.x *= s;
  9334. this.y *= s;
  9335. this.z *= s;
  9336. return this;
  9337. };
  9338. Vector3.prototype.normalize = function () {
  9339. var len = this.length();
  9340. if (len == 0)
  9341. return this;
  9342. len = 1 / len;
  9343. this.x *= len;
  9344. this.y *= len;
  9345. this.z *= len;
  9346. return this;
  9347. };
  9348. Vector3.prototype.cross = function (v) {
  9349. 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);
  9350. };
  9351. Vector3.prototype.multiply = function (matrix) {
  9352. var l_mat = matrix.values;
  9353. 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]);
  9354. };
  9355. Vector3.prototype.project = function (matrix) {
  9356. var l_mat = matrix.values;
  9357. 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]);
  9358. 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);
  9359. };
  9360. Vector3.prototype.dot = function (v) {
  9361. return this.x * v.x + this.y * v.y + this.z * v.z;
  9362. };
  9363. Vector3.prototype.length = function () {
  9364. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  9365. };
  9366. Vector3.prototype.distance = function (v) {
  9367. var a = v.x - this.x;
  9368. var b = v.y - this.y;
  9369. var c = v.z - this.z;
  9370. return Math.sqrt(a * a + b * b + c * c);
  9371. };
  9372. return Vector3;
  9373. }());
  9374. webgl.Vector3 = Vector3;
  9375. })(webgl = spine.webgl || (spine.webgl = {}));
  9376. })(spine || (spine = {}));
  9377. var spine;
  9378. (function (spine) {
  9379. var webgl;
  9380. (function (webgl) {
  9381. var ManagedWebGLRenderingContext = (function () {
  9382. function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {
  9383. if (contextConfig === void 0) { contextConfig = { alpha: "true" }; }
  9384. var _this = this;
  9385. this.restorables = new Array();
  9386. if (canvasOrContext instanceof HTMLCanvasElement) {
  9387. var canvas = canvasOrContext;
  9388. this.gl = (canvas.getContext("webgl", contextConfig) || canvas.getContext("experimental-webgl", contextConfig));
  9389. this.canvas = canvas;
  9390. canvas.addEventListener("webglcontextlost", function (e) {
  9391. var event = e;
  9392. if (e) {
  9393. e.preventDefault();
  9394. }
  9395. });
  9396. canvas.addEventListener("webglcontextrestored", function (e) {
  9397. for (var i = 0, n = _this.restorables.length; i < n; i++) {
  9398. _this.restorables[i].restore();
  9399. }
  9400. });
  9401. }
  9402. else {
  9403. this.gl = canvasOrContext;
  9404. this.canvas = this.gl.canvas;
  9405. }
  9406. }
  9407. ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) {
  9408. this.restorables.push(restorable);
  9409. };
  9410. ManagedWebGLRenderingContext.prototype.removeRestorable = function (restorable) {
  9411. var index = this.restorables.indexOf(restorable);
  9412. if (index > -1)
  9413. this.restorables.splice(index, 1);
  9414. };
  9415. return ManagedWebGLRenderingContext;
  9416. }());
  9417. webgl.ManagedWebGLRenderingContext = ManagedWebGLRenderingContext;
  9418. var WebGLBlendModeConverter = (function () {
  9419. function WebGLBlendModeConverter() {
  9420. }
  9421. WebGLBlendModeConverter.getDestGLBlendMode = function (blendMode) {
  9422. switch (blendMode) {
  9423. case spine.BlendMode.Normal: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  9424. case spine.BlendMode.Additive: return WebGLBlendModeConverter.ONE;
  9425. case spine.BlendMode.Multiply: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  9426. case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  9427. default: throw new Error("Unknown blend mode: " + blendMode);
  9428. }
  9429. };
  9430. WebGLBlendModeConverter.getSourceGLBlendMode = function (blendMode, premultipliedAlpha) {
  9431. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9432. switch (blendMode) {
  9433. case spine.BlendMode.Normal: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA;
  9434. case spine.BlendMode.Additive: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA;
  9435. case spine.BlendMode.Multiply: return WebGLBlendModeConverter.DST_COLOR;
  9436. case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE;
  9437. default: throw new Error("Unknown blend mode: " + blendMode);
  9438. }
  9439. };
  9440. WebGLBlendModeConverter.ZERO = 0;
  9441. WebGLBlendModeConverter.ONE = 1;
  9442. WebGLBlendModeConverter.SRC_COLOR = 0x0300;
  9443. WebGLBlendModeConverter.ONE_MINUS_SRC_COLOR = 0x0301;
  9444. WebGLBlendModeConverter.SRC_ALPHA = 0x0302;
  9445. WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA = 0x0303;
  9446. WebGLBlendModeConverter.DST_ALPHA = 0x0304;
  9447. WebGLBlendModeConverter.ONE_MINUS_DST_ALPHA = 0x0305;
  9448. WebGLBlendModeConverter.DST_COLOR = 0x0306;
  9449. return WebGLBlendModeConverter;
  9450. }());
  9451. webgl.WebGLBlendModeConverter = WebGLBlendModeConverter;
  9452. })(webgl = spine.webgl || (spine.webgl = {}));
  9453. })(spine || (spine = {}));
  9454. module.exports = spine;