spine-webgl.js 413 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. var spine;
  15. (function (spine) {
  16. var Animation = (function () {
  17. function Animation(name, timelines, duration) {
  18. if (name == null)
  19. throw new Error("name cannot be null.");
  20. if (timelines == null)
  21. throw new Error("timelines cannot be null.");
  22. this.name = name;
  23. this.timelines = timelines;
  24. this.timelineIds = [];
  25. for (var i = 0; i < timelines.length; i++)
  26. this.timelineIds[timelines[i].getPropertyId()] = true;
  27. this.duration = duration;
  28. }
  29. Animation.prototype.hasTimeline = function (id) {
  30. return this.timelineIds[id] == true;
  31. };
  32. Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
  33. if (skeleton == null)
  34. throw new Error("skeleton cannot be null.");
  35. if (loop && this.duration != 0) {
  36. time %= this.duration;
  37. if (lastTime > 0)
  38. lastTime %= this.duration;
  39. }
  40. var timelines = this.timelines;
  41. for (var i = 0, n = timelines.length; i < n; i++)
  42. timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
  43. };
  44. Animation.binarySearch = function (values, target, step) {
  45. if (step === void 0) { step = 1; }
  46. var low = 0;
  47. var high = values.length / step - 2;
  48. if (high == 0)
  49. return step;
  50. var current = high >>> 1;
  51. while (true) {
  52. if (values[(current + 1) * step] <= target)
  53. low = current + 1;
  54. else
  55. high = current;
  56. if (low == high)
  57. return (low + 1) * step;
  58. current = (low + high) >>> 1;
  59. }
  60. };
  61. Animation.linearSearch = function (values, target, step) {
  62. for (var i = 0, last = values.length - step; i <= last; i += step)
  63. if (values[i] > target)
  64. return i;
  65. return -1;
  66. };
  67. return Animation;
  68. }());
  69. spine.Animation = Animation;
  70. var MixBlend;
  71. (function (MixBlend) {
  72. MixBlend[MixBlend["setup"] = 0] = "setup";
  73. MixBlend[MixBlend["first"] = 1] = "first";
  74. MixBlend[MixBlend["replace"] = 2] = "replace";
  75. MixBlend[MixBlend["add"] = 3] = "add";
  76. })(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
  77. var MixDirection;
  78. (function (MixDirection) {
  79. MixDirection[MixDirection["mixIn"] = 0] = "mixIn";
  80. MixDirection[MixDirection["mixOut"] = 1] = "mixOut";
  81. })(MixDirection = spine.MixDirection || (spine.MixDirection = {}));
  82. var TimelineType;
  83. (function (TimelineType) {
  84. TimelineType[TimelineType["rotate"] = 0] = "rotate";
  85. TimelineType[TimelineType["translate"] = 1] = "translate";
  86. TimelineType[TimelineType["scale"] = 2] = "scale";
  87. TimelineType[TimelineType["shear"] = 3] = "shear";
  88. TimelineType[TimelineType["attachment"] = 4] = "attachment";
  89. TimelineType[TimelineType["color"] = 5] = "color";
  90. TimelineType[TimelineType["deform"] = 6] = "deform";
  91. TimelineType[TimelineType["event"] = 7] = "event";
  92. TimelineType[TimelineType["drawOrder"] = 8] = "drawOrder";
  93. TimelineType[TimelineType["ikConstraint"] = 9] = "ikConstraint";
  94. TimelineType[TimelineType["transformConstraint"] = 10] = "transformConstraint";
  95. TimelineType[TimelineType["pathConstraintPosition"] = 11] = "pathConstraintPosition";
  96. TimelineType[TimelineType["pathConstraintSpacing"] = 12] = "pathConstraintSpacing";
  97. TimelineType[TimelineType["pathConstraintMix"] = 13] = "pathConstraintMix";
  98. TimelineType[TimelineType["twoColor"] = 14] = "twoColor";
  99. })(TimelineType = spine.TimelineType || (spine.TimelineType = {}));
  100. var CurveTimeline = (function () {
  101. function CurveTimeline(frameCount) {
  102. if (frameCount <= 0)
  103. throw new Error("frameCount must be > 0: " + frameCount);
  104. this.curves = spine.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);
  105. }
  106. CurveTimeline.prototype.getFrameCount = function () {
  107. return this.curves.length / CurveTimeline.BEZIER_SIZE + 1;
  108. };
  109. CurveTimeline.prototype.setLinear = function (frameIndex) {
  110. this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR;
  111. };
  112. CurveTimeline.prototype.setStepped = function (frameIndex) {
  113. this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED;
  114. };
  115. CurveTimeline.prototype.getCurveType = function (frameIndex) {
  116. var index = frameIndex * CurveTimeline.BEZIER_SIZE;
  117. if (index == this.curves.length)
  118. return CurveTimeline.LINEAR;
  119. var type = this.curves[index];
  120. if (type == CurveTimeline.LINEAR)
  121. return CurveTimeline.LINEAR;
  122. if (type == CurveTimeline.STEPPED)
  123. return CurveTimeline.STEPPED;
  124. return CurveTimeline.BEZIER;
  125. };
  126. CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) {
  127. var tmpx = (-cx1 * 2 + cx2) * 0.03, tmpy = (-cy1 * 2 + cy2) * 0.03;
  128. var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006;
  129. var ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy;
  130. var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667;
  131. var i = frameIndex * CurveTimeline.BEZIER_SIZE;
  132. var curves = this.curves;
  133. curves[i++] = CurveTimeline.BEZIER;
  134. var x = dfx, y = dfy;
  135. for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
  136. curves[i] = x;
  137. curves[i + 1] = y;
  138. dfx += ddfx;
  139. dfy += ddfy;
  140. ddfx += dddfx;
  141. ddfy += dddfy;
  142. x += dfx;
  143. y += dfy;
  144. }
  145. };
  146. CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) {
  147. percent = spine.MathUtils.clamp(percent, 0, 1);
  148. var curves = this.curves;
  149. var i = frameIndex * CurveTimeline.BEZIER_SIZE;
  150. var type = curves[i];
  151. if (type == CurveTimeline.LINEAR)
  152. return percent;
  153. if (type == CurveTimeline.STEPPED)
  154. return 0;
  155. i++;
  156. var x = 0;
  157. for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
  158. x = curves[i];
  159. if (x >= percent) {
  160. var prevX = void 0, prevY = void 0;
  161. if (i == start) {
  162. prevX = 0;
  163. prevY = 0;
  164. }
  165. else {
  166. prevX = curves[i - 2];
  167. prevY = curves[i - 1];
  168. }
  169. return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX);
  170. }
  171. }
  172. var y = curves[i - 1];
  173. return y + (1 - y) * (percent - x) / (1 - x);
  174. };
  175. CurveTimeline.LINEAR = 0;
  176. CurveTimeline.STEPPED = 1;
  177. CurveTimeline.BEZIER = 2;
  178. CurveTimeline.BEZIER_SIZE = 10 * 2 - 1;
  179. return CurveTimeline;
  180. }());
  181. spine.CurveTimeline = CurveTimeline;
  182. var RotateTimeline = (function (_super) {
  183. __extends(RotateTimeline, _super);
  184. function RotateTimeline(frameCount) {
  185. var _this = _super.call(this, frameCount) || this;
  186. _this.frames = spine.Utils.newFloatArray(frameCount << 1);
  187. return _this;
  188. }
  189. RotateTimeline.prototype.getPropertyId = function () {
  190. return (TimelineType.rotate << 24) + this.boneIndex;
  191. };
  192. RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) {
  193. frameIndex <<= 1;
  194. this.frames[frameIndex] = time;
  195. this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
  196. };
  197. RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  198. var frames = this.frames;
  199. var bone = skeleton.bones[this.boneIndex];
  200. if (!bone.active)
  201. return;
  202. if (time < frames[0]) {
  203. switch (blend) {
  204. case MixBlend.setup:
  205. bone.rotation = bone.data.rotation;
  206. return;
  207. case MixBlend.first:
  208. var r_1 = bone.data.rotation - bone.rotation;
  209. bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
  210. }
  211. return;
  212. }
  213. if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
  214. var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION];
  215. switch (blend) {
  216. case MixBlend.setup:
  217. bone.rotation = bone.data.rotation + r_2 * alpha;
  218. break;
  219. case MixBlend.first:
  220. case MixBlend.replace:
  221. r_2 += bone.data.rotation - bone.rotation;
  222. r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
  223. case MixBlend.add:
  224. bone.rotation += r_2 * alpha;
  225. }
  226. return;
  227. }
  228. var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES);
  229. var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
  230. var frameTime = frames[frame];
  231. var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
  232. var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
  233. r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
  234. switch (blend) {
  235. case MixBlend.setup:
  236. bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
  237. break;
  238. case MixBlend.first:
  239. case MixBlend.replace:
  240. r += bone.data.rotation - bone.rotation;
  241. case MixBlend.add:
  242. bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
  243. }
  244. };
  245. RotateTimeline.ENTRIES = 2;
  246. RotateTimeline.PREV_TIME = -2;
  247. RotateTimeline.PREV_ROTATION = -1;
  248. RotateTimeline.ROTATION = 1;
  249. return RotateTimeline;
  250. }(CurveTimeline));
  251. spine.RotateTimeline = RotateTimeline;
  252. var TranslateTimeline = (function (_super) {
  253. __extends(TranslateTimeline, _super);
  254. function TranslateTimeline(frameCount) {
  255. var _this = _super.call(this, frameCount) || this;
  256. _this.frames = spine.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES);
  257. return _this;
  258. }
  259. TranslateTimeline.prototype.getPropertyId = function () {
  260. return (TimelineType.translate << 24) + this.boneIndex;
  261. };
  262. TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) {
  263. frameIndex *= TranslateTimeline.ENTRIES;
  264. this.frames[frameIndex] = time;
  265. this.frames[frameIndex + TranslateTimeline.X] = x;
  266. this.frames[frameIndex + TranslateTimeline.Y] = y;
  267. };
  268. TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  269. var frames = this.frames;
  270. var bone = skeleton.bones[this.boneIndex];
  271. if (!bone.active)
  272. return;
  273. if (time < frames[0]) {
  274. switch (blend) {
  275. case MixBlend.setup:
  276. bone.x = bone.data.x;
  277. bone.y = bone.data.y;
  278. return;
  279. case MixBlend.first:
  280. bone.x += (bone.data.x - bone.x) * alpha;
  281. bone.y += (bone.data.y - bone.y) * alpha;
  282. }
  283. return;
  284. }
  285. var x = 0, y = 0;
  286. if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
  287. x = frames[frames.length + TranslateTimeline.PREV_X];
  288. y = frames[frames.length + TranslateTimeline.PREV_Y];
  289. }
  290. else {
  291. var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES);
  292. x = frames[frame + TranslateTimeline.PREV_X];
  293. y = frames[frame + TranslateTimeline.PREV_Y];
  294. var frameTime = frames[frame];
  295. var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime));
  296. x += (frames[frame + TranslateTimeline.X] - x) * percent;
  297. y += (frames[frame + TranslateTimeline.Y] - y) * percent;
  298. }
  299. switch (blend) {
  300. case MixBlend.setup:
  301. bone.x = bone.data.x + x * alpha;
  302. bone.y = bone.data.y + y * alpha;
  303. break;
  304. case MixBlend.first:
  305. case MixBlend.replace:
  306. bone.x += (bone.data.x + x - bone.x) * alpha;
  307. bone.y += (bone.data.y + y - bone.y) * alpha;
  308. break;
  309. case MixBlend.add:
  310. bone.x += x * alpha;
  311. bone.y += y * alpha;
  312. }
  313. };
  314. TranslateTimeline.ENTRIES = 3;
  315. TranslateTimeline.PREV_TIME = -3;
  316. TranslateTimeline.PREV_X = -2;
  317. TranslateTimeline.PREV_Y = -1;
  318. TranslateTimeline.X = 1;
  319. TranslateTimeline.Y = 2;
  320. return TranslateTimeline;
  321. }(CurveTimeline));
  322. spine.TranslateTimeline = TranslateTimeline;
  323. var ScaleTimeline = (function (_super) {
  324. __extends(ScaleTimeline, _super);
  325. function ScaleTimeline(frameCount) {
  326. return _super.call(this, frameCount) || this;
  327. }
  328. ScaleTimeline.prototype.getPropertyId = function () {
  329. return (TimelineType.scale << 24) + this.boneIndex;
  330. };
  331. ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  332. var frames = this.frames;
  333. var bone = skeleton.bones[this.boneIndex];
  334. if (!bone.active)
  335. return;
  336. if (time < frames[0]) {
  337. switch (blend) {
  338. case MixBlend.setup:
  339. bone.scaleX = bone.data.scaleX;
  340. bone.scaleY = bone.data.scaleY;
  341. return;
  342. case MixBlend.first:
  343. bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
  344. bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
  345. }
  346. return;
  347. }
  348. var x = 0, y = 0;
  349. if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
  350. x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
  351. y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY;
  352. }
  353. else {
  354. var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES);
  355. x = frames[frame + ScaleTimeline.PREV_X];
  356. y = frames[frame + ScaleTimeline.PREV_Y];
  357. var frameTime = frames[frame];
  358. var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime));
  359. x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX;
  360. y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
  361. }
  362. if (alpha == 1) {
  363. if (blend == MixBlend.add) {
  364. bone.scaleX += x - bone.data.scaleX;
  365. bone.scaleY += y - bone.data.scaleY;
  366. }
  367. else {
  368. bone.scaleX = x;
  369. bone.scaleY = y;
  370. }
  371. }
  372. else {
  373. var bx = 0, by = 0;
  374. if (direction == MixDirection.mixOut) {
  375. switch (blend) {
  376. case MixBlend.setup:
  377. bx = bone.data.scaleX;
  378. by = bone.data.scaleY;
  379. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
  380. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
  381. break;
  382. case MixBlend.first:
  383. case MixBlend.replace:
  384. bx = bone.scaleX;
  385. by = bone.scaleY;
  386. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
  387. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
  388. break;
  389. case MixBlend.add:
  390. bx = bone.scaleX;
  391. by = bone.scaleY;
  392. bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
  393. bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
  394. }
  395. }
  396. else {
  397. switch (blend) {
  398. case MixBlend.setup:
  399. bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
  400. by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
  401. bone.scaleX = bx + (x - bx) * alpha;
  402. bone.scaleY = by + (y - by) * alpha;
  403. break;
  404. case MixBlend.first:
  405. case MixBlend.replace:
  406. bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
  407. by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
  408. bone.scaleX = bx + (x - bx) * alpha;
  409. bone.scaleY = by + (y - by) * alpha;
  410. break;
  411. case MixBlend.add:
  412. bx = spine.MathUtils.signum(x);
  413. by = spine.MathUtils.signum(y);
  414. bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
  415. bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
  416. }
  417. }
  418. }
  419. };
  420. return ScaleTimeline;
  421. }(TranslateTimeline));
  422. spine.ScaleTimeline = ScaleTimeline;
  423. var ShearTimeline = (function (_super) {
  424. __extends(ShearTimeline, _super);
  425. function ShearTimeline(frameCount) {
  426. return _super.call(this, frameCount) || this;
  427. }
  428. ShearTimeline.prototype.getPropertyId = function () {
  429. return (TimelineType.shear << 24) + this.boneIndex;
  430. };
  431. ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  432. var frames = this.frames;
  433. var bone = skeleton.bones[this.boneIndex];
  434. if (!bone.active)
  435. return;
  436. if (time < frames[0]) {
  437. switch (blend) {
  438. case MixBlend.setup:
  439. bone.shearX = bone.data.shearX;
  440. bone.shearY = bone.data.shearY;
  441. return;
  442. case MixBlend.first:
  443. bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
  444. bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
  445. }
  446. return;
  447. }
  448. var x = 0, y = 0;
  449. if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
  450. x = frames[frames.length + ShearTimeline.PREV_X];
  451. y = frames[frames.length + ShearTimeline.PREV_Y];
  452. }
  453. else {
  454. var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES);
  455. x = frames[frame + ShearTimeline.PREV_X];
  456. y = frames[frame + ShearTimeline.PREV_Y];
  457. var frameTime = frames[frame];
  458. var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime));
  459. x = x + (frames[frame + ShearTimeline.X] - x) * percent;
  460. y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
  461. }
  462. switch (blend) {
  463. case MixBlend.setup:
  464. bone.shearX = bone.data.shearX + x * alpha;
  465. bone.shearY = bone.data.shearY + y * alpha;
  466. break;
  467. case MixBlend.first:
  468. case MixBlend.replace:
  469. bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
  470. bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
  471. break;
  472. case MixBlend.add:
  473. bone.shearX += x * alpha;
  474. bone.shearY += y * alpha;
  475. }
  476. };
  477. return ShearTimeline;
  478. }(TranslateTimeline));
  479. spine.ShearTimeline = ShearTimeline;
  480. var ColorTimeline = (function (_super) {
  481. __extends(ColorTimeline, _super);
  482. function ColorTimeline(frameCount) {
  483. var _this = _super.call(this, frameCount) || this;
  484. _this.frames = spine.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES);
  485. return _this;
  486. }
  487. ColorTimeline.prototype.getPropertyId = function () {
  488. return (TimelineType.color << 24) + this.slotIndex;
  489. };
  490. ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) {
  491. frameIndex *= ColorTimeline.ENTRIES;
  492. this.frames[frameIndex] = time;
  493. this.frames[frameIndex + ColorTimeline.R] = r;
  494. this.frames[frameIndex + ColorTimeline.G] = g;
  495. this.frames[frameIndex + ColorTimeline.B] = b;
  496. this.frames[frameIndex + ColorTimeline.A] = a;
  497. };
  498. ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  499. var slot = skeleton.slots[this.slotIndex];
  500. if (!slot.bone.active)
  501. return;
  502. var frames = this.frames;
  503. if (time < frames[0]) {
  504. switch (blend) {
  505. case MixBlend.setup:
  506. slot.color.setFromColor(slot.data.color);
  507. return;
  508. case MixBlend.first:
  509. var color = slot.color, setup = slot.data.color;
  510. color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
  511. }
  512. return;
  513. }
  514. var r = 0, g = 0, b = 0, a = 0;
  515. if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
  516. var i = frames.length;
  517. r = frames[i + ColorTimeline.PREV_R];
  518. g = frames[i + ColorTimeline.PREV_G];
  519. b = frames[i + ColorTimeline.PREV_B];
  520. a = frames[i + ColorTimeline.PREV_A];
  521. }
  522. else {
  523. var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES);
  524. r = frames[frame + ColorTimeline.PREV_R];
  525. g = frames[frame + ColorTimeline.PREV_G];
  526. b = frames[frame + ColorTimeline.PREV_B];
  527. a = frames[frame + ColorTimeline.PREV_A];
  528. var frameTime = frames[frame];
  529. var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime));
  530. r += (frames[frame + ColorTimeline.R] - r) * percent;
  531. g += (frames[frame + ColorTimeline.G] - g) * percent;
  532. b += (frames[frame + ColorTimeline.B] - b) * percent;
  533. a += (frames[frame + ColorTimeline.A] - a) * percent;
  534. }
  535. if (alpha == 1)
  536. slot.color.set(r, g, b, a);
  537. else {
  538. var color = slot.color;
  539. if (blend == MixBlend.setup)
  540. color.setFromColor(slot.data.color);
  541. color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
  542. }
  543. };
  544. ColorTimeline.ENTRIES = 5;
  545. ColorTimeline.PREV_TIME = -5;
  546. ColorTimeline.PREV_R = -4;
  547. ColorTimeline.PREV_G = -3;
  548. ColorTimeline.PREV_B = -2;
  549. ColorTimeline.PREV_A = -1;
  550. ColorTimeline.R = 1;
  551. ColorTimeline.G = 2;
  552. ColorTimeline.B = 3;
  553. ColorTimeline.A = 4;
  554. return ColorTimeline;
  555. }(CurveTimeline));
  556. spine.ColorTimeline = ColorTimeline;
  557. var TwoColorTimeline = (function (_super) {
  558. __extends(TwoColorTimeline, _super);
  559. function TwoColorTimeline(frameCount) {
  560. var _this = _super.call(this, frameCount) || this;
  561. _this.frames = spine.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES);
  562. return _this;
  563. }
  564. TwoColorTimeline.prototype.getPropertyId = function () {
  565. return (TimelineType.twoColor << 24) + this.slotIndex;
  566. };
  567. TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) {
  568. frameIndex *= TwoColorTimeline.ENTRIES;
  569. this.frames[frameIndex] = time;
  570. this.frames[frameIndex + TwoColorTimeline.R] = r;
  571. this.frames[frameIndex + TwoColorTimeline.G] = g;
  572. this.frames[frameIndex + TwoColorTimeline.B] = b;
  573. this.frames[frameIndex + TwoColorTimeline.A] = a;
  574. this.frames[frameIndex + TwoColorTimeline.R2] = r2;
  575. this.frames[frameIndex + TwoColorTimeline.G2] = g2;
  576. this.frames[frameIndex + TwoColorTimeline.B2] = b2;
  577. };
  578. TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  579. var slot = skeleton.slots[this.slotIndex];
  580. if (!slot.bone.active)
  581. return;
  582. var frames = this.frames;
  583. if (time < frames[0]) {
  584. switch (blend) {
  585. case MixBlend.setup:
  586. slot.color.setFromColor(slot.data.color);
  587. slot.darkColor.setFromColor(slot.data.darkColor);
  588. return;
  589. case MixBlend.first:
  590. var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
  591. light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
  592. dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
  593. }
  594. return;
  595. }
  596. var r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0;
  597. if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) {
  598. var i = frames.length;
  599. r = frames[i + TwoColorTimeline.PREV_R];
  600. g = frames[i + TwoColorTimeline.PREV_G];
  601. b = frames[i + TwoColorTimeline.PREV_B];
  602. a = frames[i + TwoColorTimeline.PREV_A];
  603. r2 = frames[i + TwoColorTimeline.PREV_R2];
  604. g2 = frames[i + TwoColorTimeline.PREV_G2];
  605. b2 = frames[i + TwoColorTimeline.PREV_B2];
  606. }
  607. else {
  608. var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES);
  609. r = frames[frame + TwoColorTimeline.PREV_R];
  610. g = frames[frame + TwoColorTimeline.PREV_G];
  611. b = frames[frame + TwoColorTimeline.PREV_B];
  612. a = frames[frame + TwoColorTimeline.PREV_A];
  613. r2 = frames[frame + TwoColorTimeline.PREV_R2];
  614. g2 = frames[frame + TwoColorTimeline.PREV_G2];
  615. b2 = frames[frame + TwoColorTimeline.PREV_B2];
  616. var frameTime = frames[frame];
  617. var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime));
  618. r += (frames[frame + TwoColorTimeline.R] - r) * percent;
  619. g += (frames[frame + TwoColorTimeline.G] - g) * percent;
  620. b += (frames[frame + TwoColorTimeline.B] - b) * percent;
  621. a += (frames[frame + TwoColorTimeline.A] - a) * percent;
  622. r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent;
  623. g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent;
  624. b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent;
  625. }
  626. if (alpha == 1) {
  627. slot.color.set(r, g, b, a);
  628. slot.darkColor.set(r2, g2, b2, 1);
  629. }
  630. else {
  631. var light = slot.color, dark = slot.darkColor;
  632. if (blend == MixBlend.setup) {
  633. light.setFromColor(slot.data.color);
  634. dark.setFromColor(slot.data.darkColor);
  635. }
  636. light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha);
  637. dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0);
  638. }
  639. };
  640. TwoColorTimeline.ENTRIES = 8;
  641. TwoColorTimeline.PREV_TIME = -8;
  642. TwoColorTimeline.PREV_R = -7;
  643. TwoColorTimeline.PREV_G = -6;
  644. TwoColorTimeline.PREV_B = -5;
  645. TwoColorTimeline.PREV_A = -4;
  646. TwoColorTimeline.PREV_R2 = -3;
  647. TwoColorTimeline.PREV_G2 = -2;
  648. TwoColorTimeline.PREV_B2 = -1;
  649. TwoColorTimeline.R = 1;
  650. TwoColorTimeline.G = 2;
  651. TwoColorTimeline.B = 3;
  652. TwoColorTimeline.A = 4;
  653. TwoColorTimeline.R2 = 5;
  654. TwoColorTimeline.G2 = 6;
  655. TwoColorTimeline.B2 = 7;
  656. return TwoColorTimeline;
  657. }(CurveTimeline));
  658. spine.TwoColorTimeline = TwoColorTimeline;
  659. var AttachmentTimeline = (function () {
  660. function AttachmentTimeline(frameCount) {
  661. this.frames = spine.Utils.newFloatArray(frameCount);
  662. this.attachmentNames = new Array(frameCount);
  663. }
  664. AttachmentTimeline.prototype.getPropertyId = function () {
  665. return (TimelineType.attachment << 24) + this.slotIndex;
  666. };
  667. AttachmentTimeline.prototype.getFrameCount = function () {
  668. return this.frames.length;
  669. };
  670. AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) {
  671. this.frames[frameIndex] = time;
  672. this.attachmentNames[frameIndex] = attachmentName;
  673. };
  674. AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
  675. var slot = skeleton.slots[this.slotIndex];
  676. if (!slot.bone.active)
  677. return;
  678. if (direction == MixDirection.mixOut) {
  679. if (blend == MixBlend.setup)
  680. this.setAttachment(skeleton, slot, slot.data.attachmentName);
  681. return;
  682. }
  683. var frames = this.frames;
  684. if (time < frames[0]) {
  685. if (blend == MixBlend.setup || blend == MixBlend.first)
  686. this.setAttachment(skeleton, slot, slot.data.attachmentName);
  687. return;
  688. }
  689. var frameIndex = 0;
  690. if (time >= frames[frames.length - 1])
  691. frameIndex = frames.length - 1;
  692. else
  693. frameIndex = Animation.binarySearch(frames, time, 1) - 1;
  694. var attachmentName = this.attachmentNames[frameIndex];
  695. skeleton.slots[this.slotIndex]
  696. .setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
  697. };
  698. AttachmentTimeline.prototype.setAttachment = function (skeleton, slot, attachmentName) {
  699. slot.attachment = attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName);
  700. };
  701. return AttachmentTimeline;
  702. }());
  703. spine.AttachmentTimeline = AttachmentTimeline;
  704. var zeros = null;
  705. var DeformTimeline = (function (_super) {
  706. __extends(DeformTimeline, _super);
  707. function DeformTimeline(frameCount) {
  708. var _this = _super.call(this, frameCount) || this;
  709. _this.frames = spine.Utils.newFloatArray(frameCount);
  710. _this.frameVertices = new Array(frameCount);
  711. if (zeros == null)
  712. zeros = spine.Utils.newFloatArray(64);
  713. return _this;
  714. }
  715. DeformTimeline.prototype.getPropertyId = function () {
  716. return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
  717. };
  718. DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
  719. this.frames[frameIndex] = time;
  720. this.frameVertices[frameIndex] = vertices;
  721. };
  722. DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  723. var slot = skeleton.slots[this.slotIndex];
  724. if (!slot.bone.active)
  725. return;
  726. var slotAttachment = slot.getAttachment();
  727. if (!(slotAttachment instanceof spine.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment))
  728. return;
  729. var deformArray = slot.deform;
  730. if (deformArray.length == 0)
  731. blend = MixBlend.setup;
  732. var frameVertices = this.frameVertices;
  733. var vertexCount = frameVertices[0].length;
  734. var frames = this.frames;
  735. if (time < frames[0]) {
  736. var vertexAttachment = slotAttachment;
  737. switch (blend) {
  738. case MixBlend.setup:
  739. deformArray.length = 0;
  740. return;
  741. case MixBlend.first:
  742. if (alpha == 1) {
  743. deformArray.length = 0;
  744. break;
  745. }
  746. var deform_1 = spine.Utils.setArraySize(deformArray, vertexCount);
  747. if (vertexAttachment.bones == null) {
  748. var setupVertices = vertexAttachment.vertices;
  749. for (var i = 0; i < vertexCount; i++)
  750. deform_1[i] += (setupVertices[i] - deform_1[i]) * alpha;
  751. }
  752. else {
  753. alpha = 1 - alpha;
  754. for (var i = 0; i < vertexCount; i++)
  755. deform_1[i] *= alpha;
  756. }
  757. }
  758. return;
  759. }
  760. var deform = spine.Utils.setArraySize(deformArray, vertexCount);
  761. if (time >= frames[frames.length - 1]) {
  762. var lastVertices = frameVertices[frames.length - 1];
  763. if (alpha == 1) {
  764. if (blend == MixBlend.add) {
  765. var vertexAttachment = slotAttachment;
  766. if (vertexAttachment.bones == null) {
  767. var setupVertices = vertexAttachment.vertices;
  768. for (var i_1 = 0; i_1 < vertexCount; i_1++) {
  769. deform[i_1] += lastVertices[i_1] - setupVertices[i_1];
  770. }
  771. }
  772. else {
  773. for (var i_2 = 0; i_2 < vertexCount; i_2++)
  774. deform[i_2] += lastVertices[i_2];
  775. }
  776. }
  777. else {
  778. spine.Utils.arrayCopy(lastVertices, 0, deform, 0, vertexCount);
  779. }
  780. }
  781. else {
  782. switch (blend) {
  783. case MixBlend.setup: {
  784. var vertexAttachment_1 = slotAttachment;
  785. if (vertexAttachment_1.bones == null) {
  786. var setupVertices = vertexAttachment_1.vertices;
  787. for (var i_3 = 0; i_3 < vertexCount; i_3++) {
  788. var setup = setupVertices[i_3];
  789. deform[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
  790. }
  791. }
  792. else {
  793. for (var i_4 = 0; i_4 < vertexCount; i_4++)
  794. deform[i_4] = lastVertices[i_4] * alpha;
  795. }
  796. break;
  797. }
  798. case MixBlend.first:
  799. case MixBlend.replace:
  800. for (var i_5 = 0; i_5 < vertexCount; i_5++)
  801. deform[i_5] += (lastVertices[i_5] - deform[i_5]) * alpha;
  802. break;
  803. case MixBlend.add:
  804. var vertexAttachment = slotAttachment;
  805. if (vertexAttachment.bones == null) {
  806. var setupVertices = vertexAttachment.vertices;
  807. for (var i_6 = 0; i_6 < vertexCount; i_6++) {
  808. deform[i_6] += (lastVertices[i_6] - setupVertices[i_6]) * alpha;
  809. }
  810. }
  811. else {
  812. for (var i_7 = 0; i_7 < vertexCount; i_7++)
  813. deform[i_7] += lastVertices[i_7] * alpha;
  814. }
  815. }
  816. }
  817. return;
  818. }
  819. var frame = Animation.binarySearch(frames, time);
  820. var prevVertices = frameVertices[frame - 1];
  821. var nextVertices = frameVertices[frame];
  822. var frameTime = frames[frame];
  823. var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
  824. if (alpha == 1) {
  825. if (blend == MixBlend.add) {
  826. var vertexAttachment = slotAttachment;
  827. if (vertexAttachment.bones == null) {
  828. var setupVertices = vertexAttachment.vertices;
  829. for (var i_8 = 0; i_8 < vertexCount; i_8++) {
  830. var prev = prevVertices[i_8];
  831. deform[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices[i_8];
  832. }
  833. }
  834. else {
  835. for (var i_9 = 0; i_9 < vertexCount; i_9++) {
  836. var prev = prevVertices[i_9];
  837. deform[i_9] += prev + (nextVertices[i_9] - prev) * percent;
  838. }
  839. }
  840. }
  841. else {
  842. for (var i_10 = 0; i_10 < vertexCount; i_10++) {
  843. var prev = prevVertices[i_10];
  844. deform[i_10] = prev + (nextVertices[i_10] - prev) * percent;
  845. }
  846. }
  847. }
  848. else {
  849. switch (blend) {
  850. case MixBlend.setup: {
  851. var vertexAttachment_2 = slotAttachment;
  852. if (vertexAttachment_2.bones == null) {
  853. var setupVertices = vertexAttachment_2.vertices;
  854. for (var i_11 = 0; i_11 < vertexCount; i_11++) {
  855. var prev = prevVertices[i_11], setup = setupVertices[i_11];
  856. deform[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
  857. }
  858. }
  859. else {
  860. for (var i_12 = 0; i_12 < vertexCount; i_12++) {
  861. var prev = prevVertices[i_12];
  862. deform[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
  863. }
  864. }
  865. break;
  866. }
  867. case MixBlend.first:
  868. case MixBlend.replace:
  869. for (var i_13 = 0; i_13 < vertexCount; i_13++) {
  870. var prev = prevVertices[i_13];
  871. deform[i_13] += (prev + (nextVertices[i_13] - prev) * percent - deform[i_13]) * alpha;
  872. }
  873. break;
  874. case MixBlend.add:
  875. var vertexAttachment = slotAttachment;
  876. if (vertexAttachment.bones == null) {
  877. var setupVertices = vertexAttachment.vertices;
  878. for (var i_14 = 0; i_14 < vertexCount; i_14++) {
  879. var prev = prevVertices[i_14];
  880. deform[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices[i_14]) * alpha;
  881. }
  882. }
  883. else {
  884. for (var i_15 = 0; i_15 < vertexCount; i_15++) {
  885. var prev = prevVertices[i_15];
  886. deform[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
  887. }
  888. }
  889. }
  890. }
  891. };
  892. return DeformTimeline;
  893. }(CurveTimeline));
  894. spine.DeformTimeline = DeformTimeline;
  895. var EventTimeline = (function () {
  896. function EventTimeline(frameCount) {
  897. this.frames = spine.Utils.newFloatArray(frameCount);
  898. this.events = new Array(frameCount);
  899. }
  900. EventTimeline.prototype.getPropertyId = function () {
  901. return TimelineType.event << 24;
  902. };
  903. EventTimeline.prototype.getFrameCount = function () {
  904. return this.frames.length;
  905. };
  906. EventTimeline.prototype.setFrame = function (frameIndex, event) {
  907. this.frames[frameIndex] = event.time;
  908. this.events[frameIndex] = event;
  909. };
  910. EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  911. if (firedEvents == null)
  912. return;
  913. var frames = this.frames;
  914. var frameCount = this.frames.length;
  915. if (lastTime > time) {
  916. this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
  917. lastTime = -1;
  918. }
  919. else if (lastTime >= frames[frameCount - 1])
  920. return;
  921. if (time < frames[0])
  922. return;
  923. var frame = 0;
  924. if (lastTime < frames[0])
  925. frame = 0;
  926. else {
  927. frame = Animation.binarySearch(frames, lastTime);
  928. var frameTime = frames[frame];
  929. while (frame > 0) {
  930. if (frames[frame - 1] != frameTime)
  931. break;
  932. frame--;
  933. }
  934. }
  935. for (; frame < frameCount && time >= frames[frame]; frame++)
  936. firedEvents.push(this.events[frame]);
  937. };
  938. return EventTimeline;
  939. }());
  940. spine.EventTimeline = EventTimeline;
  941. var DrawOrderTimeline = (function () {
  942. function DrawOrderTimeline(frameCount) {
  943. this.frames = spine.Utils.newFloatArray(frameCount);
  944. this.drawOrders = new Array(frameCount);
  945. }
  946. DrawOrderTimeline.prototype.getPropertyId = function () {
  947. return TimelineType.drawOrder << 24;
  948. };
  949. DrawOrderTimeline.prototype.getFrameCount = function () {
  950. return this.frames.length;
  951. };
  952. DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
  953. this.frames[frameIndex] = time;
  954. this.drawOrders[frameIndex] = drawOrder;
  955. };
  956. DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  957. var drawOrder = skeleton.drawOrder;
  958. var slots = skeleton.slots;
  959. if (direction == MixDirection.mixOut) {
  960. if (blend == MixBlend.setup)
  961. spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
  962. return;
  963. }
  964. var frames = this.frames;
  965. if (time < frames[0]) {
  966. if (blend == MixBlend.setup || blend == MixBlend.first)
  967. spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
  968. return;
  969. }
  970. var frame = 0;
  971. if (time >= frames[frames.length - 1])
  972. frame = frames.length - 1;
  973. else
  974. frame = Animation.binarySearch(frames, time) - 1;
  975. var drawOrderToSetupIndex = this.drawOrders[frame];
  976. if (drawOrderToSetupIndex == null)
  977. spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
  978. else {
  979. for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
  980. drawOrder[i] = slots[drawOrderToSetupIndex[i]];
  981. }
  982. };
  983. return DrawOrderTimeline;
  984. }());
  985. spine.DrawOrderTimeline = DrawOrderTimeline;
  986. var IkConstraintTimeline = (function (_super) {
  987. __extends(IkConstraintTimeline, _super);
  988. function IkConstraintTimeline(frameCount) {
  989. var _this = _super.call(this, frameCount) || this;
  990. _this.frames = spine.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES);
  991. return _this;
  992. }
  993. IkConstraintTimeline.prototype.getPropertyId = function () {
  994. return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex;
  995. };
  996. IkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, softness, bendDirection, compress, stretch) {
  997. frameIndex *= IkConstraintTimeline.ENTRIES;
  998. this.frames[frameIndex] = time;
  999. this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
  1000. this.frames[frameIndex + IkConstraintTimeline.SOFTNESS] = softness;
  1001. this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
  1002. this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress ? 1 : 0;
  1003. this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch ? 1 : 0;
  1004. };
  1005. IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1006. var frames = this.frames;
  1007. var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
  1008. if (!constraint.active)
  1009. return;
  1010. if (time < frames[0]) {
  1011. switch (blend) {
  1012. case MixBlend.setup:
  1013. constraint.mix = constraint.data.mix;
  1014. constraint.softness = constraint.data.softness;
  1015. constraint.bendDirection = constraint.data.bendDirection;
  1016. constraint.compress = constraint.data.compress;
  1017. constraint.stretch = constraint.data.stretch;
  1018. return;
  1019. case MixBlend.first:
  1020. constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
  1021. constraint.softness += (constraint.data.softness - constraint.softness) * alpha;
  1022. constraint.bendDirection = constraint.data.bendDirection;
  1023. constraint.compress = constraint.data.compress;
  1024. constraint.stretch = constraint.data.stretch;
  1025. }
  1026. return;
  1027. }
  1028. if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
  1029. if (blend == MixBlend.setup) {
  1030. constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
  1031. constraint.softness = constraint.data.softness
  1032. + (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.data.softness) * alpha;
  1033. if (direction == MixDirection.mixOut) {
  1034. constraint.bendDirection = constraint.data.bendDirection;
  1035. constraint.compress = constraint.data.compress;
  1036. constraint.stretch = constraint.data.stretch;
  1037. }
  1038. else {
  1039. constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1040. constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1041. constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0;
  1042. }
  1043. }
  1044. else {
  1045. constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
  1046. constraint.softness += (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.softness) * alpha;
  1047. if (direction == MixDirection.mixIn) {
  1048. constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1049. constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1050. constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0;
  1051. }
  1052. }
  1053. return;
  1054. }
  1055. var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES);
  1056. var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
  1057. var softness = frames[frame + IkConstraintTimeline.PREV_SOFTNESS];
  1058. var frameTime = frames[frame];
  1059. var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
  1060. if (blend == MixBlend.setup) {
  1061. constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
  1062. constraint.softness = constraint.data.softness
  1063. + (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.data.softness) * alpha;
  1064. if (direction == MixDirection.mixOut) {
  1065. constraint.bendDirection = constraint.data.bendDirection;
  1066. constraint.compress = constraint.data.compress;
  1067. constraint.stretch = constraint.data.stretch;
  1068. }
  1069. else {
  1070. constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1071. constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1072. constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0;
  1073. }
  1074. }
  1075. else {
  1076. constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
  1077. constraint.softness += (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.softness) * alpha;
  1078. if (direction == MixDirection.mixIn) {
  1079. constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
  1080. constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0;
  1081. constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0;
  1082. }
  1083. }
  1084. };
  1085. IkConstraintTimeline.ENTRIES = 6;
  1086. IkConstraintTimeline.PREV_TIME = -6;
  1087. IkConstraintTimeline.PREV_MIX = -5;
  1088. IkConstraintTimeline.PREV_SOFTNESS = -4;
  1089. IkConstraintTimeline.PREV_BEND_DIRECTION = -3;
  1090. IkConstraintTimeline.PREV_COMPRESS = -2;
  1091. IkConstraintTimeline.PREV_STRETCH = -1;
  1092. IkConstraintTimeline.MIX = 1;
  1093. IkConstraintTimeline.SOFTNESS = 2;
  1094. IkConstraintTimeline.BEND_DIRECTION = 3;
  1095. IkConstraintTimeline.COMPRESS = 4;
  1096. IkConstraintTimeline.STRETCH = 5;
  1097. return IkConstraintTimeline;
  1098. }(CurveTimeline));
  1099. spine.IkConstraintTimeline = IkConstraintTimeline;
  1100. var TransformConstraintTimeline = (function (_super) {
  1101. __extends(TransformConstraintTimeline, _super);
  1102. function TransformConstraintTimeline(frameCount) {
  1103. var _this = _super.call(this, frameCount) || this;
  1104. _this.frames = spine.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES);
  1105. return _this;
  1106. }
  1107. TransformConstraintTimeline.prototype.getPropertyId = function () {
  1108. return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex;
  1109. };
  1110. TransformConstraintTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) {
  1111. frameIndex *= TransformConstraintTimeline.ENTRIES;
  1112. this.frames[frameIndex] = time;
  1113. this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix;
  1114. this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix;
  1115. this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
  1116. this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
  1117. };
  1118. TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1119. var frames = this.frames;
  1120. var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
  1121. if (!constraint.active)
  1122. return;
  1123. if (time < frames[0]) {
  1124. var data = constraint.data;
  1125. switch (blend) {
  1126. case MixBlend.setup:
  1127. constraint.rotateMix = data.rotateMix;
  1128. constraint.translateMix = data.translateMix;
  1129. constraint.scaleMix = data.scaleMix;
  1130. constraint.shearMix = data.shearMix;
  1131. return;
  1132. case MixBlend.first:
  1133. constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
  1134. constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
  1135. constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
  1136. constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
  1137. }
  1138. return;
  1139. }
  1140. var rotate = 0, translate = 0, scale = 0, shear = 0;
  1141. if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
  1142. var i = frames.length;
  1143. rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE];
  1144. translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE];
  1145. scale = frames[i + TransformConstraintTimeline.PREV_SCALE];
  1146. shear = frames[i + TransformConstraintTimeline.PREV_SHEAR];
  1147. }
  1148. else {
  1149. var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES);
  1150. rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE];
  1151. translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE];
  1152. scale = frames[frame + TransformConstraintTimeline.PREV_SCALE];
  1153. shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR];
  1154. var frameTime = frames[frame];
  1155. var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime));
  1156. rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent;
  1157. translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent;
  1158. scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
  1159. shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
  1160. }
  1161. if (blend == MixBlend.setup) {
  1162. var data = constraint.data;
  1163. constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
  1164. constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
  1165. constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;
  1166. constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha;
  1167. }
  1168. else {
  1169. constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
  1170. constraint.translateMix += (translate - constraint.translateMix) * alpha;
  1171. constraint.scaleMix += (scale - constraint.scaleMix) * alpha;
  1172. constraint.shearMix += (shear - constraint.shearMix) * alpha;
  1173. }
  1174. };
  1175. TransformConstraintTimeline.ENTRIES = 5;
  1176. TransformConstraintTimeline.PREV_TIME = -5;
  1177. TransformConstraintTimeline.PREV_ROTATE = -4;
  1178. TransformConstraintTimeline.PREV_TRANSLATE = -3;
  1179. TransformConstraintTimeline.PREV_SCALE = -2;
  1180. TransformConstraintTimeline.PREV_SHEAR = -1;
  1181. TransformConstraintTimeline.ROTATE = 1;
  1182. TransformConstraintTimeline.TRANSLATE = 2;
  1183. TransformConstraintTimeline.SCALE = 3;
  1184. TransformConstraintTimeline.SHEAR = 4;
  1185. return TransformConstraintTimeline;
  1186. }(CurveTimeline));
  1187. spine.TransformConstraintTimeline = TransformConstraintTimeline;
  1188. var PathConstraintPositionTimeline = (function (_super) {
  1189. __extends(PathConstraintPositionTimeline, _super);
  1190. function PathConstraintPositionTimeline(frameCount) {
  1191. var _this = _super.call(this, frameCount) || this;
  1192. _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES);
  1193. return _this;
  1194. }
  1195. PathConstraintPositionTimeline.prototype.getPropertyId = function () {
  1196. return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex;
  1197. };
  1198. PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) {
  1199. frameIndex *= PathConstraintPositionTimeline.ENTRIES;
  1200. this.frames[frameIndex] = time;
  1201. this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
  1202. };
  1203. PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1204. var frames = this.frames;
  1205. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1206. if (!constraint.active)
  1207. return;
  1208. if (time < frames[0]) {
  1209. switch (blend) {
  1210. case MixBlend.setup:
  1211. constraint.position = constraint.data.position;
  1212. return;
  1213. case MixBlend.first:
  1214. constraint.position += (constraint.data.position - constraint.position) * alpha;
  1215. }
  1216. return;
  1217. }
  1218. var position = 0;
  1219. if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
  1220. position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
  1221. else {
  1222. var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES);
  1223. position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE];
  1224. var frameTime = frames[frame];
  1225. var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
  1226. position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
  1227. }
  1228. if (blend == MixBlend.setup)
  1229. constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
  1230. else
  1231. constraint.position += (position - constraint.position) * alpha;
  1232. };
  1233. PathConstraintPositionTimeline.ENTRIES = 2;
  1234. PathConstraintPositionTimeline.PREV_TIME = -2;
  1235. PathConstraintPositionTimeline.PREV_VALUE = -1;
  1236. PathConstraintPositionTimeline.VALUE = 1;
  1237. return PathConstraintPositionTimeline;
  1238. }(CurveTimeline));
  1239. spine.PathConstraintPositionTimeline = PathConstraintPositionTimeline;
  1240. var PathConstraintSpacingTimeline = (function (_super) {
  1241. __extends(PathConstraintSpacingTimeline, _super);
  1242. function PathConstraintSpacingTimeline(frameCount) {
  1243. return _super.call(this, frameCount) || this;
  1244. }
  1245. PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
  1246. return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
  1247. };
  1248. PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1249. var frames = this.frames;
  1250. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1251. if (!constraint.active)
  1252. return;
  1253. if (time < frames[0]) {
  1254. switch (blend) {
  1255. case MixBlend.setup:
  1256. constraint.spacing = constraint.data.spacing;
  1257. return;
  1258. case MixBlend.first:
  1259. constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
  1260. }
  1261. return;
  1262. }
  1263. var spacing = 0;
  1264. if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
  1265. spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
  1266. else {
  1267. var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES);
  1268. spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE];
  1269. var frameTime = frames[frame];
  1270. var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
  1271. spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
  1272. }
  1273. if (blend == MixBlend.setup)
  1274. constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
  1275. else
  1276. constraint.spacing += (spacing - constraint.spacing) * alpha;
  1277. };
  1278. return PathConstraintSpacingTimeline;
  1279. }(PathConstraintPositionTimeline));
  1280. spine.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline;
  1281. var PathConstraintMixTimeline = (function (_super) {
  1282. __extends(PathConstraintMixTimeline, _super);
  1283. function PathConstraintMixTimeline(frameCount) {
  1284. var _this = _super.call(this, frameCount) || this;
  1285. _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES);
  1286. return _this;
  1287. }
  1288. PathConstraintMixTimeline.prototype.getPropertyId = function () {
  1289. return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex;
  1290. };
  1291. PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) {
  1292. frameIndex *= PathConstraintMixTimeline.ENTRIES;
  1293. this.frames[frameIndex] = time;
  1294. this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
  1295. this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
  1296. };
  1297. PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
  1298. var frames = this.frames;
  1299. var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
  1300. if (!constraint.active)
  1301. return;
  1302. if (time < frames[0]) {
  1303. switch (blend) {
  1304. case MixBlend.setup:
  1305. constraint.rotateMix = constraint.data.rotateMix;
  1306. constraint.translateMix = constraint.data.translateMix;
  1307. return;
  1308. case MixBlend.first:
  1309. constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
  1310. constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
  1311. }
  1312. return;
  1313. }
  1314. var rotate = 0, translate = 0;
  1315. if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
  1316. rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
  1317. translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE];
  1318. }
  1319. else {
  1320. var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES);
  1321. rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE];
  1322. translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE];
  1323. var frameTime = frames[frame];
  1324. var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime));
  1325. rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
  1326. translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
  1327. }
  1328. if (blend == MixBlend.setup) {
  1329. constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
  1330. constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
  1331. }
  1332. else {
  1333. constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
  1334. constraint.translateMix += (translate - constraint.translateMix) * alpha;
  1335. }
  1336. };
  1337. PathConstraintMixTimeline.ENTRIES = 3;
  1338. PathConstraintMixTimeline.PREV_TIME = -3;
  1339. PathConstraintMixTimeline.PREV_ROTATE = -2;
  1340. PathConstraintMixTimeline.PREV_TRANSLATE = -1;
  1341. PathConstraintMixTimeline.ROTATE = 1;
  1342. PathConstraintMixTimeline.TRANSLATE = 2;
  1343. return PathConstraintMixTimeline;
  1344. }(CurveTimeline));
  1345. spine.PathConstraintMixTimeline = PathConstraintMixTimeline;
  1346. })(spine || (spine = {}));
  1347. var spine;
  1348. (function (spine) {
  1349. var AnimationState = (function () {
  1350. function AnimationState(data) {
  1351. this.tracks = new Array();
  1352. this.timeScale = 1;
  1353. this.unkeyedState = 0;
  1354. this.events = new Array();
  1355. this.listeners = new Array();
  1356. this.queue = new EventQueue(this);
  1357. this.propertyIDs = new spine.IntSet();
  1358. this.animationsChanged = false;
  1359. this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
  1360. this.data = data;
  1361. }
  1362. AnimationState.prototype.update = function (delta) {
  1363. delta *= this.timeScale;
  1364. var tracks = this.tracks;
  1365. for (var i = 0, n = tracks.length; i < n; i++) {
  1366. var current = tracks[i];
  1367. if (current == null)
  1368. continue;
  1369. current.animationLast = current.nextAnimationLast;
  1370. current.trackLast = current.nextTrackLast;
  1371. var currentDelta = delta * current.timeScale;
  1372. if (current.delay > 0) {
  1373. current.delay -= currentDelta;
  1374. if (current.delay > 0)
  1375. continue;
  1376. currentDelta = -current.delay;
  1377. current.delay = 0;
  1378. }
  1379. var next = current.next;
  1380. if (next != null) {
  1381. var nextTime = current.trackLast - next.delay;
  1382. if (nextTime >= 0) {
  1383. next.delay = 0;
  1384. next.trackTime += current.timeScale == 0 ? 0 : (nextTime / current.timeScale + delta) * next.timeScale;
  1385. current.trackTime += currentDelta;
  1386. this.setCurrent(i, next, true);
  1387. while (next.mixingFrom != null) {
  1388. next.mixTime += delta;
  1389. next = next.mixingFrom;
  1390. }
  1391. continue;
  1392. }
  1393. }
  1394. else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) {
  1395. tracks[i] = null;
  1396. this.queue.end(current);
  1397. this.disposeNext(current);
  1398. continue;
  1399. }
  1400. if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) {
  1401. var from = current.mixingFrom;
  1402. current.mixingFrom = null;
  1403. if (from != null)
  1404. from.mixingTo = null;
  1405. while (from != null) {
  1406. this.queue.end(from);
  1407. from = from.mixingFrom;
  1408. }
  1409. }
  1410. current.trackTime += currentDelta;
  1411. }
  1412. this.queue.drain();
  1413. };
  1414. AnimationState.prototype.updateMixingFrom = function (to, delta) {
  1415. var from = to.mixingFrom;
  1416. if (from == null)
  1417. return true;
  1418. var finished = this.updateMixingFrom(from, delta);
  1419. from.animationLast = from.nextAnimationLast;
  1420. from.trackLast = from.nextTrackLast;
  1421. if (to.mixTime > 0 && to.mixTime >= to.mixDuration) {
  1422. if (from.totalAlpha == 0 || to.mixDuration == 0) {
  1423. to.mixingFrom = from.mixingFrom;
  1424. if (from.mixingFrom != null)
  1425. from.mixingFrom.mixingTo = to;
  1426. to.interruptAlpha = from.interruptAlpha;
  1427. this.queue.end(from);
  1428. }
  1429. return finished;
  1430. }
  1431. from.trackTime += delta * from.timeScale;
  1432. to.mixTime += delta;
  1433. return false;
  1434. };
  1435. AnimationState.prototype.apply = function (skeleton) {
  1436. if (skeleton == null)
  1437. throw new Error("skeleton cannot be null.");
  1438. if (this.animationsChanged)
  1439. this._animationsChanged();
  1440. var events = this.events;
  1441. var tracks = this.tracks;
  1442. var applied = false;
  1443. for (var i_16 = 0, n_1 = tracks.length; i_16 < n_1; i_16++) {
  1444. var current = tracks[i_16];
  1445. if (current == null || current.delay > 0)
  1446. continue;
  1447. applied = true;
  1448. var blend = i_16 == 0 ? spine.MixBlend.first : current.mixBlend;
  1449. var mix = current.alpha;
  1450. if (current.mixingFrom != null)
  1451. mix *= this.applyMixingFrom(current, skeleton, blend);
  1452. else if (current.trackTime >= current.trackEnd && current.next == null)
  1453. mix = 0;
  1454. var animationLast = current.animationLast, animationTime = current.getAnimationTime();
  1455. var timelineCount = current.animation.timelines.length;
  1456. var timelines = current.animation.timelines;
  1457. if ((i_16 == 0 && mix == 1) || blend == spine.MixBlend.add) {
  1458. for (var ii = 0; ii < timelineCount; ii++) {
  1459. spine.Utils.webkit602BugfixHelper(mix, blend);
  1460. var timeline = timelines[ii];
  1461. if (timeline instanceof spine.AttachmentTimeline)
  1462. this.applyAttachmentTimeline(timeline, skeleton, animationTime, blend, true);
  1463. else
  1464. timeline.apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection.mixIn);
  1465. }
  1466. }
  1467. else {
  1468. var timelineMode = current.timelineMode;
  1469. var firstFrame = current.timelinesRotation.length == 0;
  1470. if (firstFrame)
  1471. spine.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null);
  1472. var timelinesRotation = current.timelinesRotation;
  1473. for (var ii = 0; ii < timelineCount; ii++) {
  1474. var timeline_1 = timelines[ii];
  1475. var timelineBlend = timelineMode[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
  1476. if (timeline_1 instanceof spine.RotateTimeline) {
  1477. this.applyRotateTimeline(timeline_1, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
  1478. }
  1479. else if (timeline_1 instanceof spine.AttachmentTimeline) {
  1480. this.applyAttachmentTimeline(timeline_1, skeleton, animationTime, blend, true);
  1481. }
  1482. else {
  1483. spine.Utils.webkit602BugfixHelper(mix, blend);
  1484. timeline_1.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection.mixIn);
  1485. }
  1486. }
  1487. }
  1488. this.queueEvents(current, animationTime);
  1489. events.length = 0;
  1490. current.nextAnimationLast = animationTime;
  1491. current.nextTrackLast = current.trackTime;
  1492. }
  1493. var setupState = this.unkeyedState + AnimationState.SETUP;
  1494. var slots = skeleton.slots;
  1495. for (var i = 0, n = skeleton.slots.length; i < n; i++) {
  1496. var slot = slots[i];
  1497. if (slot.attachmentState == setupState) {
  1498. var attachmentName = slot.data.attachmentName;
  1499. slot.attachment = (attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName));
  1500. }
  1501. }
  1502. this.unkeyedState += 2;
  1503. this.queue.drain();
  1504. return applied;
  1505. };
  1506. AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
  1507. var from = to.mixingFrom;
  1508. if (from.mixingFrom != null)
  1509. this.applyMixingFrom(from, skeleton, blend);
  1510. var mix = 0;
  1511. if (to.mixDuration == 0) {
  1512. mix = 1;
  1513. if (blend == spine.MixBlend.first)
  1514. blend = spine.MixBlend.setup;
  1515. }
  1516. else {
  1517. mix = to.mixTime / to.mixDuration;
  1518. if (mix > 1)
  1519. mix = 1;
  1520. if (blend != spine.MixBlend.first)
  1521. blend = from.mixBlend;
  1522. }
  1523. var events = mix < from.eventThreshold ? this.events : null;
  1524. var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
  1525. var animationLast = from.animationLast, animationTime = from.getAnimationTime();
  1526. var timelineCount = from.animation.timelines.length;
  1527. var timelines = from.animation.timelines;
  1528. var alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix);
  1529. if (blend == spine.MixBlend.add) {
  1530. for (var i = 0; i < timelineCount; i++)
  1531. timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.mixOut);
  1532. }
  1533. else {
  1534. var timelineMode = from.timelineMode;
  1535. var timelineHoldMix = from.timelineHoldMix;
  1536. var firstFrame = from.timelinesRotation.length == 0;
  1537. if (firstFrame)
  1538. spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
  1539. var timelinesRotation = from.timelinesRotation;
  1540. from.totalAlpha = 0;
  1541. for (var i = 0; i < timelineCount; i++) {
  1542. var timeline = timelines[i];
  1543. var direction = spine.MixDirection.mixOut;
  1544. var timelineBlend = void 0;
  1545. var alpha = 0;
  1546. switch (timelineMode[i]) {
  1547. case AnimationState.SUBSEQUENT:
  1548. if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
  1549. continue;
  1550. timelineBlend = blend;
  1551. alpha = alphaMix;
  1552. break;
  1553. case AnimationState.FIRST:
  1554. timelineBlend = spine.MixBlend.setup;
  1555. alpha = alphaMix;
  1556. break;
  1557. case AnimationState.HOLD_SUBSEQUENT:
  1558. timelineBlend = blend;
  1559. alpha = alphaHold;
  1560. break;
  1561. case AnimationState.HOLD_FIRST:
  1562. timelineBlend = spine.MixBlend.setup;
  1563. alpha = alphaHold;
  1564. break;
  1565. default:
  1566. timelineBlend = spine.MixBlend.setup;
  1567. var holdMix = timelineHoldMix[i];
  1568. alpha = alphaHold * Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration);
  1569. break;
  1570. }
  1571. from.totalAlpha += alpha;
  1572. if (timeline instanceof spine.RotateTimeline)
  1573. this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
  1574. else if (timeline instanceof spine.AttachmentTimeline)
  1575. this.applyAttachmentTimeline(timeline, skeleton, animationTime, timelineBlend, attachments);
  1576. else {
  1577. spine.Utils.webkit602BugfixHelper(alpha, blend);
  1578. if (drawOrder && timeline instanceof spine.DrawOrderTimeline && timelineBlend == spine.MixBlend.setup)
  1579. direction = spine.MixDirection.mixIn;
  1580. timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction);
  1581. }
  1582. }
  1583. }
  1584. if (to.mixDuration > 0)
  1585. this.queueEvents(from, animationTime);
  1586. this.events.length = 0;
  1587. from.nextAnimationLast = animationTime;
  1588. from.nextTrackLast = from.trackTime;
  1589. return mix;
  1590. };
  1591. AnimationState.prototype.applyAttachmentTimeline = function (timeline, skeleton, time, blend, attachments) {
  1592. var slot = skeleton.slots[timeline.slotIndex];
  1593. if (!slot.bone.active)
  1594. return;
  1595. var frames = timeline.frames;
  1596. if (time < frames[0]) {
  1597. if (blend == spine.MixBlend.setup || blend == spine.MixBlend.first)
  1598. this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments);
  1599. }
  1600. else {
  1601. var frameIndex;
  1602. if (time >= frames[frames.length - 1])
  1603. frameIndex = frames.length - 1;
  1604. else
  1605. frameIndex = spine.Animation.binarySearch(frames, time) - 1;
  1606. this.setAttachment(skeleton, slot, timeline.attachmentNames[frameIndex], attachments);
  1607. }
  1608. if (slot.attachmentState <= this.unkeyedState)
  1609. slot.attachmentState = this.unkeyedState + AnimationState.SETUP;
  1610. };
  1611. AnimationState.prototype.setAttachment = function (skeleton, slot, attachmentName, attachments) {
  1612. slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName));
  1613. if (attachments)
  1614. slot.attachmentState = this.unkeyedState + AnimationState.CURRENT;
  1615. };
  1616. AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
  1617. if (firstFrame)
  1618. timelinesRotation[i] = 0;
  1619. if (alpha == 1) {
  1620. timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection.mixIn);
  1621. return;
  1622. }
  1623. var rotateTimeline = timeline;
  1624. var frames = rotateTimeline.frames;
  1625. var bone = skeleton.bones[rotateTimeline.boneIndex];
  1626. if (!bone.active)
  1627. return;
  1628. var r1 = 0, r2 = 0;
  1629. if (time < frames[0]) {
  1630. switch (blend) {
  1631. case spine.MixBlend.setup:
  1632. bone.rotation = bone.data.rotation;
  1633. default:
  1634. return;
  1635. case spine.MixBlend.first:
  1636. r1 = bone.rotation;
  1637. r2 = bone.data.rotation;
  1638. }
  1639. }
  1640. else {
  1641. r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
  1642. if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])
  1643. r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];
  1644. else {
  1645. var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);
  1646. var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];
  1647. var frameTime = frames[frame];
  1648. var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));
  1649. r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;
  1650. r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
  1651. r2 = prevRotation + r2 * percent + bone.data.rotation;
  1652. r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
  1653. }
  1654. }
  1655. var total = 0, diff = r2 - r1;
  1656. diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
  1657. if (diff == 0) {
  1658. total = timelinesRotation[i];
  1659. }
  1660. else {
  1661. var lastTotal = 0, lastDiff = 0;
  1662. if (firstFrame) {
  1663. lastTotal = 0;
  1664. lastDiff = diff;
  1665. }
  1666. else {
  1667. lastTotal = timelinesRotation[i];
  1668. lastDiff = timelinesRotation[i + 1];
  1669. }
  1670. var current = diff > 0, dir = lastTotal >= 0;
  1671. if (spine.MathUtils.signum(lastDiff) != spine.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) {
  1672. if (Math.abs(lastTotal) > 180)
  1673. lastTotal += 360 * spine.MathUtils.signum(lastTotal);
  1674. dir = current;
  1675. }
  1676. total = diff + lastTotal - lastTotal % 360;
  1677. if (dir != current)
  1678. total += 360 * spine.MathUtils.signum(lastTotal);
  1679. timelinesRotation[i] = total;
  1680. }
  1681. timelinesRotation[i + 1] = diff;
  1682. r1 += total * alpha;
  1683. bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360;
  1684. };
  1685. AnimationState.prototype.queueEvents = function (entry, animationTime) {
  1686. var animationStart = entry.animationStart, animationEnd = entry.animationEnd;
  1687. var duration = animationEnd - animationStart;
  1688. var trackLastWrapped = entry.trackLast % duration;
  1689. var events = this.events;
  1690. var i = 0, n = events.length;
  1691. for (; i < n; i++) {
  1692. var event_1 = events[i];
  1693. if (event_1.time < trackLastWrapped)
  1694. break;
  1695. if (event_1.time > animationEnd)
  1696. continue;
  1697. this.queue.event(entry, event_1);
  1698. }
  1699. var complete = false;
  1700. if (entry.loop)
  1701. complete = duration == 0 || trackLastWrapped > entry.trackTime % duration;
  1702. else
  1703. complete = animationTime >= animationEnd && entry.animationLast < animationEnd;
  1704. if (complete)
  1705. this.queue.complete(entry);
  1706. for (; i < n; i++) {
  1707. var event_2 = events[i];
  1708. if (event_2.time < animationStart)
  1709. continue;
  1710. this.queue.event(entry, events[i]);
  1711. }
  1712. };
  1713. AnimationState.prototype.clearTracks = function () {
  1714. var oldDrainDisabled = this.queue.drainDisabled;
  1715. this.queue.drainDisabled = true;
  1716. for (var i = 0, n = this.tracks.length; i < n; i++)
  1717. this.clearTrack(i);
  1718. this.tracks.length = 0;
  1719. this.queue.drainDisabled = oldDrainDisabled;
  1720. this.queue.drain();
  1721. };
  1722. AnimationState.prototype.clearTrack = function (trackIndex) {
  1723. if (trackIndex >= this.tracks.length)
  1724. return;
  1725. var current = this.tracks[trackIndex];
  1726. if (current == null)
  1727. return;
  1728. this.queue.end(current);
  1729. this.disposeNext(current);
  1730. var entry = current;
  1731. while (true) {
  1732. var from = entry.mixingFrom;
  1733. if (from == null)
  1734. break;
  1735. this.queue.end(from);
  1736. entry.mixingFrom = null;
  1737. entry.mixingTo = null;
  1738. entry = from;
  1739. }
  1740. this.tracks[current.trackIndex] = null;
  1741. this.queue.drain();
  1742. };
  1743. AnimationState.prototype.setCurrent = function (index, current, interrupt) {
  1744. var from = this.expandToIndex(index);
  1745. this.tracks[index] = current;
  1746. if (from != null) {
  1747. if (interrupt)
  1748. this.queue.interrupt(from);
  1749. current.mixingFrom = from;
  1750. from.mixingTo = current;
  1751. current.mixTime = 0;
  1752. if (from.mixingFrom != null && from.mixDuration > 0)
  1753. current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration);
  1754. from.timelinesRotation.length = 0;
  1755. }
  1756. this.queue.start(current);
  1757. };
  1758. AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) {
  1759. var animation = this.data.skeletonData.findAnimation(animationName);
  1760. if (animation == null)
  1761. throw new Error("Animation not found: " + animationName);
  1762. return this.setAnimationWith(trackIndex, animation, loop);
  1763. };
  1764. AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) {
  1765. if (animation == null)
  1766. throw new Error("animation cannot be null.");
  1767. var interrupt = true;
  1768. var current = this.expandToIndex(trackIndex);
  1769. if (current != null) {
  1770. if (current.nextTrackLast == -1) {
  1771. this.tracks[trackIndex] = current.mixingFrom;
  1772. this.queue.interrupt(current);
  1773. this.queue.end(current);
  1774. this.disposeNext(current);
  1775. current = current.mixingFrom;
  1776. interrupt = false;
  1777. }
  1778. else
  1779. this.disposeNext(current);
  1780. }
  1781. var entry = this.trackEntry(trackIndex, animation, loop, current);
  1782. this.setCurrent(trackIndex, entry, interrupt);
  1783. this.queue.drain();
  1784. return entry;
  1785. };
  1786. AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) {
  1787. var animation = this.data.skeletonData.findAnimation(animationName);
  1788. if (animation == null)
  1789. throw new Error("Animation not found: " + animationName);
  1790. return this.addAnimationWith(trackIndex, animation, loop, delay);
  1791. };
  1792. AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) {
  1793. if (animation == null)
  1794. throw new Error("animation cannot be null.");
  1795. var last = this.expandToIndex(trackIndex);
  1796. if (last != null) {
  1797. while (last.next != null)
  1798. last = last.next;
  1799. }
  1800. var entry = this.trackEntry(trackIndex, animation, loop, last);
  1801. if (last == null) {
  1802. this.setCurrent(trackIndex, entry, true);
  1803. this.queue.drain();
  1804. }
  1805. else {
  1806. last.next = entry;
  1807. if (delay <= 0) {
  1808. var duration = last.animationEnd - last.animationStart;
  1809. if (duration != 0) {
  1810. if (last.loop)
  1811. delay += duration * (1 + ((last.trackTime / duration) | 0));
  1812. else
  1813. delay += Math.max(duration, last.trackTime);
  1814. delay -= this.data.getMix(last.animation, animation);
  1815. }
  1816. else
  1817. delay = last.trackTime;
  1818. }
  1819. }
  1820. entry.delay = delay;
  1821. return entry;
  1822. };
  1823. AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) {
  1824. var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false);
  1825. entry.mixDuration = mixDuration;
  1826. entry.trackEnd = mixDuration;
  1827. return entry;
  1828. };
  1829. AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) {
  1830. if (delay <= 0)
  1831. delay -= mixDuration;
  1832. var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay);
  1833. entry.mixDuration = mixDuration;
  1834. entry.trackEnd = mixDuration;
  1835. return entry;
  1836. };
  1837. AnimationState.prototype.setEmptyAnimations = function (mixDuration) {
  1838. var oldDrainDisabled = this.queue.drainDisabled;
  1839. this.queue.drainDisabled = true;
  1840. for (var i = 0, n = this.tracks.length; i < n; i++) {
  1841. var current = this.tracks[i];
  1842. if (current != null)
  1843. this.setEmptyAnimation(current.trackIndex, mixDuration);
  1844. }
  1845. this.queue.drainDisabled = oldDrainDisabled;
  1846. this.queue.drain();
  1847. };
  1848. AnimationState.prototype.expandToIndex = function (index) {
  1849. if (index < this.tracks.length)
  1850. return this.tracks[index];
  1851. spine.Utils.ensureArrayCapacity(this.tracks, index + 1, null);
  1852. this.tracks.length = index + 1;
  1853. return null;
  1854. };
  1855. AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) {
  1856. var entry = this.trackEntryPool.obtain();
  1857. entry.trackIndex = trackIndex;
  1858. entry.animation = animation;
  1859. entry.loop = loop;
  1860. entry.holdPrevious = false;
  1861. entry.eventThreshold = 0;
  1862. entry.attachmentThreshold = 0;
  1863. entry.drawOrderThreshold = 0;
  1864. entry.animationStart = 0;
  1865. entry.animationEnd = animation.duration;
  1866. entry.animationLast = -1;
  1867. entry.nextAnimationLast = -1;
  1868. entry.delay = 0;
  1869. entry.trackTime = 0;
  1870. entry.trackLast = -1;
  1871. entry.nextTrackLast = -1;
  1872. entry.trackEnd = Number.MAX_VALUE;
  1873. entry.timeScale = 1;
  1874. entry.alpha = 1;
  1875. entry.interruptAlpha = 1;
  1876. entry.mixTime = 0;
  1877. entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation);
  1878. entry.mixBlend = spine.MixBlend.replace;
  1879. return entry;
  1880. };
  1881. AnimationState.prototype.disposeNext = function (entry) {
  1882. var next = entry.next;
  1883. while (next != null) {
  1884. this.queue.dispose(next);
  1885. next = next.next;
  1886. }
  1887. entry.next = null;
  1888. };
  1889. AnimationState.prototype._animationsChanged = function () {
  1890. this.animationsChanged = false;
  1891. this.propertyIDs.clear();
  1892. for (var i = 0, n = this.tracks.length; i < n; i++) {
  1893. var entry = this.tracks[i];
  1894. if (entry == null)
  1895. continue;
  1896. while (entry.mixingFrom != null)
  1897. entry = entry.mixingFrom;
  1898. do {
  1899. if (entry.mixingFrom == null || entry.mixBlend != spine.MixBlend.add)
  1900. this.computeHold(entry);
  1901. entry = entry.mixingTo;
  1902. } while (entry != null);
  1903. }
  1904. };
  1905. AnimationState.prototype.computeHold = function (entry) {
  1906. var to = entry.mixingTo;
  1907. var timelines = entry.animation.timelines;
  1908. var timelinesCount = entry.animation.timelines.length;
  1909. var timelineMode = spine.Utils.setArraySize(entry.timelineMode, timelinesCount);
  1910. entry.timelineHoldMix.length = 0;
  1911. var timelineDipMix = spine.Utils.setArraySize(entry.timelineHoldMix, timelinesCount);
  1912. var propertyIDs = this.propertyIDs;
  1913. if (to != null && to.holdPrevious) {
  1914. for (var i = 0; i < timelinesCount; i++) {
  1915. timelineMode[i] = propertyIDs.add(timelines[i].getPropertyId()) ? AnimationState.HOLD_FIRST : AnimationState.HOLD_SUBSEQUENT;
  1916. }
  1917. return;
  1918. }
  1919. outer: for (var i = 0; i < timelinesCount; i++) {
  1920. var timeline = timelines[i];
  1921. var id = timeline.getPropertyId();
  1922. if (!propertyIDs.add(id))
  1923. timelineMode[i] = AnimationState.SUBSEQUENT;
  1924. else if (to == null || timeline instanceof spine.AttachmentTimeline || timeline instanceof spine.DrawOrderTimeline
  1925. || timeline instanceof spine.EventTimeline || !to.animation.hasTimeline(id)) {
  1926. timelineMode[i] = AnimationState.FIRST;
  1927. }
  1928. else {
  1929. for (var next = to.mixingTo; next != null; next = next.mixingTo) {
  1930. if (next.animation.hasTimeline(id))
  1931. continue;
  1932. if (entry.mixDuration > 0) {
  1933. timelineMode[i] = AnimationState.HOLD_MIX;
  1934. timelineDipMix[i] = next;
  1935. continue outer;
  1936. }
  1937. break;
  1938. }
  1939. timelineMode[i] = AnimationState.HOLD_FIRST;
  1940. }
  1941. }
  1942. };
  1943. AnimationState.prototype.getCurrent = function (trackIndex) {
  1944. if (trackIndex >= this.tracks.length)
  1945. return null;
  1946. return this.tracks[trackIndex];
  1947. };
  1948. AnimationState.prototype.addListener = function (listener) {
  1949. if (listener == null)
  1950. throw new Error("listener cannot be null.");
  1951. this.listeners.push(listener);
  1952. };
  1953. AnimationState.prototype.removeListener = function (listener) {
  1954. var index = this.listeners.indexOf(listener);
  1955. if (index >= 0)
  1956. this.listeners.splice(index, 1);
  1957. };
  1958. AnimationState.prototype.clearListeners = function () {
  1959. this.listeners.length = 0;
  1960. };
  1961. AnimationState.prototype.clearListenerNotifications = function () {
  1962. this.queue.clear();
  1963. };
  1964. AnimationState.emptyAnimation = new spine.Animation("<empty>", [], 0);
  1965. AnimationState.SUBSEQUENT = 0;
  1966. AnimationState.FIRST = 1;
  1967. AnimationState.HOLD_SUBSEQUENT = 2;
  1968. AnimationState.HOLD_FIRST = 3;
  1969. AnimationState.HOLD_MIX = 4;
  1970. AnimationState.SETUP = 1;
  1971. AnimationState.CURRENT = 2;
  1972. return AnimationState;
  1973. }());
  1974. spine.AnimationState = AnimationState;
  1975. var TrackEntry = (function () {
  1976. function TrackEntry() {
  1977. this.mixBlend = spine.MixBlend.replace;
  1978. this.timelineMode = new Array();
  1979. this.timelineHoldMix = new Array();
  1980. this.timelinesRotation = new Array();
  1981. }
  1982. TrackEntry.prototype.reset = function () {
  1983. this.next = null;
  1984. this.mixingFrom = null;
  1985. this.mixingTo = null;
  1986. this.animation = null;
  1987. this.listener = null;
  1988. this.timelineMode.length = 0;
  1989. this.timelineHoldMix.length = 0;
  1990. this.timelinesRotation.length = 0;
  1991. };
  1992. TrackEntry.prototype.getAnimationTime = function () {
  1993. if (this.loop) {
  1994. var duration = this.animationEnd - this.animationStart;
  1995. if (duration == 0)
  1996. return this.animationStart;
  1997. return (this.trackTime % duration) + this.animationStart;
  1998. }
  1999. return Math.min(this.trackTime + this.animationStart, this.animationEnd);
  2000. };
  2001. TrackEntry.prototype.setAnimationLast = function (animationLast) {
  2002. this.animationLast = animationLast;
  2003. this.nextAnimationLast = animationLast;
  2004. };
  2005. TrackEntry.prototype.isComplete = function () {
  2006. return this.trackTime >= this.animationEnd - this.animationStart;
  2007. };
  2008. TrackEntry.prototype.resetRotationDirections = function () {
  2009. this.timelinesRotation.length = 0;
  2010. };
  2011. return TrackEntry;
  2012. }());
  2013. spine.TrackEntry = TrackEntry;
  2014. var EventQueue = (function () {
  2015. function EventQueue(animState) {
  2016. this.objects = [];
  2017. this.drainDisabled = false;
  2018. this.animState = animState;
  2019. }
  2020. EventQueue.prototype.start = function (entry) {
  2021. this.objects.push(EventType.start);
  2022. this.objects.push(entry);
  2023. this.animState.animationsChanged = true;
  2024. };
  2025. EventQueue.prototype.interrupt = function (entry) {
  2026. this.objects.push(EventType.interrupt);
  2027. this.objects.push(entry);
  2028. };
  2029. EventQueue.prototype.end = function (entry) {
  2030. this.objects.push(EventType.end);
  2031. this.objects.push(entry);
  2032. this.animState.animationsChanged = true;
  2033. };
  2034. EventQueue.prototype.dispose = function (entry) {
  2035. this.objects.push(EventType.dispose);
  2036. this.objects.push(entry);
  2037. };
  2038. EventQueue.prototype.complete = function (entry) {
  2039. this.objects.push(EventType.complete);
  2040. this.objects.push(entry);
  2041. };
  2042. EventQueue.prototype.event = function (entry, event) {
  2043. this.objects.push(EventType.event);
  2044. this.objects.push(entry);
  2045. this.objects.push(event);
  2046. };
  2047. EventQueue.prototype.drain = function () {
  2048. if (this.drainDisabled)
  2049. return;
  2050. this.drainDisabled = true;
  2051. var objects = this.objects;
  2052. var listeners = this.animState.listeners;
  2053. for (var i = 0; i < objects.length; i += 2) {
  2054. var type = objects[i];
  2055. var entry = objects[i + 1];
  2056. switch (type) {
  2057. case EventType.start:
  2058. if (entry.listener != null && entry.listener.start)
  2059. entry.listener.start(entry);
  2060. for (var ii = 0; ii < listeners.length; ii++)
  2061. if (listeners[ii].start)
  2062. listeners[ii].start(entry);
  2063. break;
  2064. case EventType.interrupt:
  2065. if (entry.listener != null && entry.listener.interrupt)
  2066. entry.listener.interrupt(entry);
  2067. for (var ii = 0; ii < listeners.length; ii++)
  2068. if (listeners[ii].interrupt)
  2069. listeners[ii].interrupt(entry);
  2070. break;
  2071. case EventType.end:
  2072. if (entry.listener != null && entry.listener.end)
  2073. entry.listener.end(entry);
  2074. for (var ii = 0; ii < listeners.length; ii++)
  2075. if (listeners[ii].end)
  2076. listeners[ii].end(entry);
  2077. case EventType.dispose:
  2078. if (entry.listener != null && entry.listener.dispose)
  2079. entry.listener.dispose(entry);
  2080. for (var ii = 0; ii < listeners.length; ii++)
  2081. if (listeners[ii].dispose)
  2082. listeners[ii].dispose(entry);
  2083. this.animState.trackEntryPool.free(entry);
  2084. break;
  2085. case EventType.complete:
  2086. if (entry.listener != null && entry.listener.complete)
  2087. entry.listener.complete(entry);
  2088. for (var ii = 0; ii < listeners.length; ii++)
  2089. if (listeners[ii].complete)
  2090. listeners[ii].complete(entry);
  2091. break;
  2092. case EventType.event:
  2093. var event_3 = objects[i++ + 2];
  2094. if (entry.listener != null && entry.listener.event)
  2095. entry.listener.event(entry, event_3);
  2096. for (var ii = 0; ii < listeners.length; ii++)
  2097. if (listeners[ii].event)
  2098. listeners[ii].event(entry, event_3);
  2099. break;
  2100. }
  2101. }
  2102. this.clear();
  2103. this.drainDisabled = false;
  2104. };
  2105. EventQueue.prototype.clear = function () {
  2106. this.objects.length = 0;
  2107. };
  2108. return EventQueue;
  2109. }());
  2110. spine.EventQueue = EventQueue;
  2111. var EventType;
  2112. (function (EventType) {
  2113. EventType[EventType["start"] = 0] = "start";
  2114. EventType[EventType["interrupt"] = 1] = "interrupt";
  2115. EventType[EventType["end"] = 2] = "end";
  2116. EventType[EventType["dispose"] = 3] = "dispose";
  2117. EventType[EventType["complete"] = 4] = "complete";
  2118. EventType[EventType["event"] = 5] = "event";
  2119. })(EventType = spine.EventType || (spine.EventType = {}));
  2120. var AnimationStateAdapter = (function () {
  2121. function AnimationStateAdapter() {
  2122. }
  2123. AnimationStateAdapter.prototype.start = function (entry) {
  2124. };
  2125. AnimationStateAdapter.prototype.interrupt = function (entry) {
  2126. };
  2127. AnimationStateAdapter.prototype.end = function (entry) {
  2128. };
  2129. AnimationStateAdapter.prototype.dispose = function (entry) {
  2130. };
  2131. AnimationStateAdapter.prototype.complete = function (entry) {
  2132. };
  2133. AnimationStateAdapter.prototype.event = function (entry, event) {
  2134. };
  2135. return AnimationStateAdapter;
  2136. }());
  2137. spine.AnimationStateAdapter = AnimationStateAdapter;
  2138. })(spine || (spine = {}));
  2139. var spine;
  2140. (function (spine) {
  2141. var AnimationStateData = (function () {
  2142. function AnimationStateData(skeletonData) {
  2143. this.animationToMixTime = {};
  2144. this.defaultMix = 0;
  2145. if (skeletonData == null)
  2146. throw new Error("skeletonData cannot be null.");
  2147. this.skeletonData = skeletonData;
  2148. }
  2149. AnimationStateData.prototype.setMix = function (fromName, toName, duration) {
  2150. var from = this.skeletonData.findAnimation(fromName);
  2151. if (from == null)
  2152. throw new Error("Animation not found: " + fromName);
  2153. var to = this.skeletonData.findAnimation(toName);
  2154. if (to == null)
  2155. throw new Error("Animation not found: " + toName);
  2156. this.setMixWith(from, to, duration);
  2157. };
  2158. AnimationStateData.prototype.setMixWith = function (from, to, duration) {
  2159. if (from == null)
  2160. throw new Error("from cannot be null.");
  2161. if (to == null)
  2162. throw new Error("to cannot be null.");
  2163. var key = from.name + "." + to.name;
  2164. this.animationToMixTime[key] = duration;
  2165. };
  2166. AnimationStateData.prototype.getMix = function (from, to) {
  2167. var key = from.name + "." + to.name;
  2168. var value = this.animationToMixTime[key];
  2169. return value === undefined ? this.defaultMix : value;
  2170. };
  2171. return AnimationStateData;
  2172. }());
  2173. spine.AnimationStateData = AnimationStateData;
  2174. })(spine || (spine = {}));
  2175. var spine;
  2176. (function (spine) {
  2177. var AssetManager = (function () {
  2178. function AssetManager(textureLoader, pathPrefix) {
  2179. if (pathPrefix === void 0) { pathPrefix = ""; }
  2180. this.assets = {};
  2181. this.errors = {};
  2182. this.toLoad = 0;
  2183. this.loaded = 0;
  2184. this.rawDataUris = {};
  2185. this.textureLoader = textureLoader;
  2186. this.pathPrefix = pathPrefix;
  2187. }
  2188. AssetManager.prototype.downloadText = function (url, success, error) {
  2189. var request = new XMLHttpRequest();
  2190. request.overrideMimeType("text/html");
  2191. if (this.rawDataUris[url])
  2192. url = this.rawDataUris[url];
  2193. request.open("GET", url, true);
  2194. request.onload = function () {
  2195. if (request.status == 200) {
  2196. success(request.responseText);
  2197. }
  2198. else {
  2199. error(request.status, request.responseText);
  2200. }
  2201. };
  2202. request.onerror = function () {
  2203. error(request.status, request.responseText);
  2204. };
  2205. request.send();
  2206. };
  2207. AssetManager.prototype.downloadBinary = function (url, success, error) {
  2208. var request = new XMLHttpRequest();
  2209. if (this.rawDataUris[url])
  2210. url = this.rawDataUris[url];
  2211. request.open("GET", url, true);
  2212. request.responseType = "arraybuffer";
  2213. request.onload = function () {
  2214. if (request.status == 200) {
  2215. success(new Uint8Array(request.response));
  2216. }
  2217. else {
  2218. error(request.status, request.responseText);
  2219. }
  2220. };
  2221. request.onerror = function () {
  2222. error(request.status, request.responseText);
  2223. };
  2224. request.send();
  2225. };
  2226. AssetManager.prototype.setRawDataURI = function (path, data) {
  2227. this.rawDataUris[this.pathPrefix + path] = data;
  2228. };
  2229. AssetManager.prototype.loadBinary = function (path, success, error) {
  2230. var _this = this;
  2231. if (success === void 0) { success = null; }
  2232. if (error === void 0) { error = null; }
  2233. path = this.pathPrefix + path;
  2234. this.toLoad++;
  2235. this.downloadBinary(path, function (data) {
  2236. _this.assets[path] = data;
  2237. if (success)
  2238. success(path, data);
  2239. _this.toLoad--;
  2240. _this.loaded++;
  2241. }, function (state, responseText) {
  2242. _this.errors[path] = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
  2243. if (error)
  2244. error(path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
  2245. _this.toLoad--;
  2246. _this.loaded++;
  2247. });
  2248. };
  2249. AssetManager.prototype.loadText = function (path, success, error) {
  2250. var _this = this;
  2251. if (success === void 0) { success = null; }
  2252. if (error === void 0) { error = null; }
  2253. path = this.pathPrefix + path;
  2254. this.toLoad++;
  2255. this.downloadText(path, function (data) {
  2256. _this.assets[path] = data;
  2257. if (success)
  2258. success(path, data);
  2259. _this.toLoad--;
  2260. _this.loaded++;
  2261. }, function (state, responseText) {
  2262. _this.errors[path] = "Couldn't load text " + path + ": status " + status + ", " + responseText;
  2263. if (error)
  2264. error(path, "Couldn't load text " + path + ": status " + status + ", " + responseText);
  2265. _this.toLoad--;
  2266. _this.loaded++;
  2267. });
  2268. };
  2269. AssetManager.prototype.loadTexture = function (path, success, error) {
  2270. var _this = this;
  2271. if (success === void 0) { success = null; }
  2272. if (error === void 0) { error = null; }
  2273. path = this.pathPrefix + path;
  2274. var storagePath = path;
  2275. this.toLoad++;
  2276. var img = new Image();
  2277. img.crossOrigin = "anonymous";
  2278. img.onload = function (ev) {
  2279. var texture = _this.textureLoader(img);
  2280. _this.assets[storagePath] = texture;
  2281. _this.toLoad--;
  2282. _this.loaded++;
  2283. if (success)
  2284. success(path, img);
  2285. };
  2286. img.onerror = function (ev) {
  2287. _this.errors[path] = "Couldn't load image " + path;
  2288. _this.toLoad--;
  2289. _this.loaded++;
  2290. if (error)
  2291. error(path, "Couldn't load image " + path);
  2292. };
  2293. if (this.rawDataUris[path])
  2294. path = this.rawDataUris[path];
  2295. img.src = path;
  2296. };
  2297. AssetManager.prototype.loadTextureAtlas = function (path, success, error) {
  2298. var _this = this;
  2299. if (success === void 0) { success = null; }
  2300. if (error === void 0) { error = null; }
  2301. var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
  2302. path = this.pathPrefix + path;
  2303. this.toLoad++;
  2304. this.downloadText(path, function (atlasData) {
  2305. var pagesLoaded = { count: 0 };
  2306. var atlasPages = new Array();
  2307. try {
  2308. var atlas = new spine.TextureAtlas(atlasData, function (path) {
  2309. atlasPages.push(parent == "" ? path : parent + "/" + path);
  2310. var image = document.createElement("img");
  2311. image.width = 16;
  2312. image.height = 16;
  2313. return new spine.FakeTexture(image);
  2314. });
  2315. }
  2316. catch (e) {
  2317. var ex = e;
  2318. _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message;
  2319. if (error)
  2320. error(path, "Couldn't load texture atlas " + path + ": " + ex.message);
  2321. _this.toLoad--;
  2322. _this.loaded++;
  2323. return;
  2324. }
  2325. var _loop_1 = function (atlasPage) {
  2326. var pageLoadError = false;
  2327. _this.loadTexture(atlasPage, function (imagePath, image) {
  2328. pagesLoaded.count++;
  2329. if (pagesLoaded.count == atlasPages.length) {
  2330. if (!pageLoadError) {
  2331. try {
  2332. var atlas = new spine.TextureAtlas(atlasData, function (path) {
  2333. return _this.get(parent == "" ? path : parent + "/" + path);
  2334. });
  2335. _this.assets[path] = atlas;
  2336. if (success)
  2337. success(path, atlas);
  2338. _this.toLoad--;
  2339. _this.loaded++;
  2340. }
  2341. catch (e) {
  2342. var ex = e;
  2343. _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message;
  2344. if (error)
  2345. error(path, "Couldn't load texture atlas " + path + ": " + ex.message);
  2346. _this.toLoad--;
  2347. _this.loaded++;
  2348. }
  2349. }
  2350. else {
  2351. _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path;
  2352. if (error)
  2353. error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path);
  2354. _this.toLoad--;
  2355. _this.loaded++;
  2356. }
  2357. }
  2358. }, function (imagePath, errorMessage) {
  2359. pageLoadError = true;
  2360. pagesLoaded.count++;
  2361. if (pagesLoaded.count == atlasPages.length) {
  2362. _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path;
  2363. if (error)
  2364. error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path);
  2365. _this.toLoad--;
  2366. _this.loaded++;
  2367. }
  2368. });
  2369. };
  2370. for (var _i = 0, atlasPages_1 = atlasPages; _i < atlasPages_1.length; _i++) {
  2371. var atlasPage = atlasPages_1[_i];
  2372. _loop_1(atlasPage);
  2373. }
  2374. }, function (state, responseText) {
  2375. _this.errors[path] = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
  2376. if (error)
  2377. error(path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText);
  2378. _this.toLoad--;
  2379. _this.loaded++;
  2380. });
  2381. };
  2382. AssetManager.prototype.get = function (path) {
  2383. path = this.pathPrefix + path;
  2384. return this.assets[path];
  2385. };
  2386. AssetManager.prototype.remove = function (path) {
  2387. path = this.pathPrefix + path;
  2388. var asset = this.assets[path];
  2389. if (asset.dispose)
  2390. asset.dispose();
  2391. this.assets[path] = null;
  2392. };
  2393. AssetManager.prototype.removeAll = function () {
  2394. for (var key in this.assets) {
  2395. var asset = this.assets[key];
  2396. if (asset.dispose)
  2397. asset.dispose();
  2398. }
  2399. this.assets = {};
  2400. };
  2401. AssetManager.prototype.isLoadingComplete = function () {
  2402. return this.toLoad == 0;
  2403. };
  2404. AssetManager.prototype.getToLoad = function () {
  2405. return this.toLoad;
  2406. };
  2407. AssetManager.prototype.getLoaded = function () {
  2408. return this.loaded;
  2409. };
  2410. AssetManager.prototype.dispose = function () {
  2411. this.removeAll();
  2412. };
  2413. AssetManager.prototype.hasErrors = function () {
  2414. return Object.keys(this.errors).length > 0;
  2415. };
  2416. AssetManager.prototype.getErrors = function () {
  2417. return this.errors;
  2418. };
  2419. return AssetManager;
  2420. }());
  2421. spine.AssetManager = AssetManager;
  2422. })(spine || (spine = {}));
  2423. var spine;
  2424. (function (spine) {
  2425. var AtlasAttachmentLoader = (function () {
  2426. function AtlasAttachmentLoader(atlas) {
  2427. this.atlas = atlas;
  2428. }
  2429. AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) {
  2430. var region = this.atlas.findRegion(path);
  2431. if (region == null)
  2432. // throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")");
  2433. return null;
  2434. region.renderObject = region;
  2435. var attachment = new spine.RegionAttachment(name);
  2436. attachment.setRegion(region);
  2437. return attachment;
  2438. };
  2439. AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) {
  2440. var region = this.atlas.findRegion(path);
  2441. if (region == null)
  2442. // throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
  2443. return null;
  2444. region.renderObject = region;
  2445. var attachment = new spine.MeshAttachment(name);
  2446. attachment.region = region;
  2447. return attachment;
  2448. };
  2449. AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) {
  2450. return new spine.BoundingBoxAttachment(name);
  2451. };
  2452. AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) {
  2453. return new spine.PathAttachment(name);
  2454. };
  2455. AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) {
  2456. return new spine.PointAttachment(name);
  2457. };
  2458. AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) {
  2459. return new spine.ClippingAttachment(name);
  2460. };
  2461. return AtlasAttachmentLoader;
  2462. }());
  2463. spine.AtlasAttachmentLoader = AtlasAttachmentLoader;
  2464. })(spine || (spine = {}));
  2465. var spine;
  2466. (function (spine) {
  2467. var BlendMode;
  2468. (function (BlendMode) {
  2469. BlendMode[BlendMode["Normal"] = 0] = "Normal";
  2470. BlendMode[BlendMode["Additive"] = 1] = "Additive";
  2471. BlendMode[BlendMode["Multiply"] = 2] = "Multiply";
  2472. BlendMode[BlendMode["Screen"] = 3] = "Screen";
  2473. })(BlendMode = spine.BlendMode || (spine.BlendMode = {}));
  2474. })(spine || (spine = {}));
  2475. var spine;
  2476. (function (spine) {
  2477. var Bone = (function () {
  2478. function Bone(data, skeleton, parent) {
  2479. this.children = new Array();
  2480. this.x = 0;
  2481. this.y = 0;
  2482. this.rotation = 0;
  2483. this.scaleX = 0;
  2484. this.scaleY = 0;
  2485. this.shearX = 0;
  2486. this.shearY = 0;
  2487. this.ax = 0;
  2488. this.ay = 0;
  2489. this.arotation = 0;
  2490. this.ascaleX = 0;
  2491. this.ascaleY = 0;
  2492. this.ashearX = 0;
  2493. this.ashearY = 0;
  2494. this.appliedValid = false;
  2495. this.a = 0;
  2496. this.b = 0;
  2497. this.c = 0;
  2498. this.d = 0;
  2499. this.worldY = 0;
  2500. this.worldX = 0;
  2501. this.sorted = false;
  2502. this.active = false;
  2503. if (data == null)
  2504. throw new Error("data cannot be null.");
  2505. if (skeleton == null)
  2506. throw new Error("skeleton cannot be null.");
  2507. this.data = data;
  2508. this.skeleton = skeleton;
  2509. this.parent = parent;
  2510. this.setToSetupPose();
  2511. }
  2512. Bone.prototype.isActive = function () {
  2513. return this.active;
  2514. };
  2515. Bone.prototype.update = function () {
  2516. this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);
  2517. };
  2518. Bone.prototype.updateWorldTransform = function () {
  2519. this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);
  2520. };
  2521. Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) {
  2522. this.ax = x;
  2523. this.ay = y;
  2524. this.arotation = rotation;
  2525. this.ascaleX = scaleX;
  2526. this.ascaleY = scaleY;
  2527. this.ashearX = shearX;
  2528. this.ashearY = shearY;
  2529. this.appliedValid = true;
  2530. var parent = this.parent;
  2531. if (parent == null) {
  2532. var skeleton = this.skeleton;
  2533. var rotationY = rotation + 90 + shearY;
  2534. var sx = skeleton.scaleX;
  2535. var sy = skeleton.scaleY;
  2536. this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
  2537. this.b = spine.MathUtils.cosDeg(rotationY) * scaleY * sx;
  2538. this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX * sy;
  2539. this.d = spine.MathUtils.sinDeg(rotationY) * scaleY * sy;
  2540. this.worldX = x * sx + skeleton.x;
  2541. this.worldY = y * sy + skeleton.y;
  2542. return;
  2543. }
  2544. var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
  2545. this.worldX = pa * x + pb * y + parent.worldX;
  2546. this.worldY = pc * x + pd * y + parent.worldY;
  2547. switch (this.data.transformMode) {
  2548. case spine.TransformMode.Normal: {
  2549. var rotationY = rotation + 90 + shearY;
  2550. var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;
  2551. var lb = spine.MathUtils.cosDeg(rotationY) * scaleY;
  2552. var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;
  2553. var ld = spine.MathUtils.sinDeg(rotationY) * scaleY;
  2554. this.a = pa * la + pb * lc;
  2555. this.b = pa * lb + pb * ld;
  2556. this.c = pc * la + pd * lc;
  2557. this.d = pc * lb + pd * ld;
  2558. return;
  2559. }
  2560. case spine.TransformMode.OnlyTranslation: {
  2561. var rotationY = rotation + 90 + shearY;
  2562. this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;
  2563. this.b = spine.MathUtils.cosDeg(rotationY) * scaleY;
  2564. this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;
  2565. this.d = spine.MathUtils.sinDeg(rotationY) * scaleY;
  2566. break;
  2567. }
  2568. case spine.TransformMode.NoRotationOrReflection: {
  2569. var s = pa * pa + pc * pc;
  2570. var prx = 0;
  2571. if (s > 0.0001) {
  2572. s = Math.abs(pa * pd - pb * pc) / s;
  2573. pa /= this.skeleton.scaleX;
  2574. pc /= this.skeleton.scaleY;
  2575. pb = pc * s;
  2576. pd = pa * s;
  2577. prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
  2578. }
  2579. else {
  2580. pa = 0;
  2581. pc = 0;
  2582. prx = 90 - Math.atan2(pd, pb) * spine.MathUtils.radDeg;
  2583. }
  2584. var rx = rotation + shearX - prx;
  2585. var ry = rotation + shearY - prx + 90;
  2586. var la = spine.MathUtils.cosDeg(rx) * scaleX;
  2587. var lb = spine.MathUtils.cosDeg(ry) * scaleY;
  2588. var lc = spine.MathUtils.sinDeg(rx) * scaleX;
  2589. var ld = spine.MathUtils.sinDeg(ry) * scaleY;
  2590. this.a = pa * la - pb * lc;
  2591. this.b = pa * lb - pb * ld;
  2592. this.c = pc * la + pd * lc;
  2593. this.d = pc * lb + pd * ld;
  2594. break;
  2595. }
  2596. case spine.TransformMode.NoScale:
  2597. case spine.TransformMode.NoScaleOrReflection: {
  2598. var cos = spine.MathUtils.cosDeg(rotation);
  2599. var sin = spine.MathUtils.sinDeg(rotation);
  2600. var za = (pa * cos + pb * sin) / this.skeleton.scaleX;
  2601. var zc = (pc * cos + pd * sin) / this.skeleton.scaleY;
  2602. var s = Math.sqrt(za * za + zc * zc);
  2603. if (s > 0.00001)
  2604. s = 1 / s;
  2605. za *= s;
  2606. zc *= s;
  2607. s = Math.sqrt(za * za + zc * zc);
  2608. if (this.data.transformMode == spine.TransformMode.NoScale
  2609. && (pa * pd - pb * pc < 0) != (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0))
  2610. s = -s;
  2611. var r = Math.PI / 2 + Math.atan2(zc, za);
  2612. var zb = Math.cos(r) * s;
  2613. var zd = Math.sin(r) * s;
  2614. var la = spine.MathUtils.cosDeg(shearX) * scaleX;
  2615. var lb = spine.MathUtils.cosDeg(90 + shearY) * scaleY;
  2616. var lc = spine.MathUtils.sinDeg(shearX) * scaleX;
  2617. var ld = spine.MathUtils.sinDeg(90 + shearY) * scaleY;
  2618. this.a = za * la + zb * lc;
  2619. this.b = za * lb + zb * ld;
  2620. this.c = zc * la + zd * lc;
  2621. this.d = zc * lb + zd * ld;
  2622. break;
  2623. }
  2624. }
  2625. this.a *= this.skeleton.scaleX;
  2626. this.b *= this.skeleton.scaleX;
  2627. this.c *= this.skeleton.scaleY;
  2628. this.d *= this.skeleton.scaleY;
  2629. };
  2630. Bone.prototype.setToSetupPose = function () {
  2631. var data = this.data;
  2632. this.x = data.x;
  2633. this.y = data.y;
  2634. this.rotation = data.rotation;
  2635. this.scaleX = data.scaleX;
  2636. this.scaleY = data.scaleY;
  2637. this.shearX = data.shearX;
  2638. this.shearY = data.shearY;
  2639. };
  2640. Bone.prototype.getWorldRotationX = function () {
  2641. return Math.atan2(this.c, this.a) * spine.MathUtils.radDeg;
  2642. };
  2643. Bone.prototype.getWorldRotationY = function () {
  2644. return Math.atan2(this.d, this.b) * spine.MathUtils.radDeg;
  2645. };
  2646. Bone.prototype.getWorldScaleX = function () {
  2647. return Math.sqrt(this.a * this.a + this.c * this.c);
  2648. };
  2649. Bone.prototype.getWorldScaleY = function () {
  2650. return Math.sqrt(this.b * this.b + this.d * this.d);
  2651. };
  2652. Bone.prototype.updateAppliedTransform = function () {
  2653. this.appliedValid = true;
  2654. var parent = this.parent;
  2655. if (parent == null) {
  2656. this.ax = this.worldX;
  2657. this.ay = this.worldY;
  2658. this.arotation = Math.atan2(this.c, this.a) * spine.MathUtils.radDeg;
  2659. this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c);
  2660. this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d);
  2661. this.ashearX = 0;
  2662. this.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * spine.MathUtils.radDeg;
  2663. return;
  2664. }
  2665. var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
  2666. var pid = 1 / (pa * pd - pb * pc);
  2667. var dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY;
  2668. this.ax = (dx * pd * pid - dy * pb * pid);
  2669. this.ay = (dy * pa * pid - dx * pc * pid);
  2670. var ia = pid * pd;
  2671. var id = pid * pa;
  2672. var ib = pid * pb;
  2673. var ic = pid * pc;
  2674. var ra = ia * this.a - ib * this.c;
  2675. var rb = ia * this.b - ib * this.d;
  2676. var rc = id * this.c - ic * this.a;
  2677. var rd = id * this.d - ic * this.b;
  2678. this.ashearX = 0;
  2679. this.ascaleX = Math.sqrt(ra * ra + rc * rc);
  2680. if (this.ascaleX > 0.0001) {
  2681. var det = ra * rd - rb * rc;
  2682. this.ascaleY = det / this.ascaleX;
  2683. this.ashearY = Math.atan2(ra * rb + rc * rd, det) * spine.MathUtils.radDeg;
  2684. this.arotation = Math.atan2(rc, ra) * spine.MathUtils.radDeg;
  2685. }
  2686. else {
  2687. this.ascaleX = 0;
  2688. this.ascaleY = Math.sqrt(rb * rb + rd * rd);
  2689. this.ashearY = 0;
  2690. this.arotation = 90 - Math.atan2(rd, rb) * spine.MathUtils.radDeg;
  2691. }
  2692. };
  2693. Bone.prototype.worldToLocal = function (world) {
  2694. var a = this.a, b = this.b, c = this.c, d = this.d;
  2695. var invDet = 1 / (a * d - b * c);
  2696. var x = world.x - this.worldX, y = world.y - this.worldY;
  2697. world.x = (x * d * invDet - y * b * invDet);
  2698. world.y = (y * a * invDet - x * c * invDet);
  2699. return world;
  2700. };
  2701. Bone.prototype.localToWorld = function (local) {
  2702. var x = local.x, y = local.y;
  2703. local.x = x * this.a + y * this.b + this.worldX;
  2704. local.y = x * this.c + y * this.d + this.worldY;
  2705. return local;
  2706. };
  2707. Bone.prototype.worldToLocalRotation = function (worldRotation) {
  2708. var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
  2709. return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
  2710. };
  2711. Bone.prototype.localToWorldRotation = function (localRotation) {
  2712. localRotation -= this.rotation - this.shearX;
  2713. var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
  2714. return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
  2715. };
  2716. Bone.prototype.rotateWorld = function (degrees) {
  2717. var a = this.a, b = this.b, c = this.c, d = this.d;
  2718. var cos = spine.MathUtils.cosDeg(degrees), sin = spine.MathUtils.sinDeg(degrees);
  2719. this.a = cos * a - sin * c;
  2720. this.b = cos * b - sin * d;
  2721. this.c = sin * a + cos * c;
  2722. this.d = sin * b + cos * d;
  2723. this.appliedValid = false;
  2724. };
  2725. return Bone;
  2726. }());
  2727. spine.Bone = Bone;
  2728. })(spine || (spine = {}));
  2729. var spine;
  2730. (function (spine) {
  2731. var BoneData = (function () {
  2732. function BoneData(index, name, parent) {
  2733. this.x = 0;
  2734. this.y = 0;
  2735. this.rotation = 0;
  2736. this.scaleX = 1;
  2737. this.scaleY = 1;
  2738. this.shearX = 0;
  2739. this.shearY = 0;
  2740. this.transformMode = TransformMode.Normal;
  2741. this.skinRequired = false;
  2742. this.color = new spine.Color();
  2743. if (index < 0)
  2744. throw new Error("index must be >= 0.");
  2745. if (name == null)
  2746. throw new Error("name cannot be null.");
  2747. this.index = index;
  2748. this.name = name;
  2749. this.parent = parent;
  2750. }
  2751. return BoneData;
  2752. }());
  2753. spine.BoneData = BoneData;
  2754. var TransformMode;
  2755. (function (TransformMode) {
  2756. TransformMode[TransformMode["Normal"] = 0] = "Normal";
  2757. TransformMode[TransformMode["OnlyTranslation"] = 1] = "OnlyTranslation";
  2758. TransformMode[TransformMode["NoRotationOrReflection"] = 2] = "NoRotationOrReflection";
  2759. TransformMode[TransformMode["NoScale"] = 3] = "NoScale";
  2760. TransformMode[TransformMode["NoScaleOrReflection"] = 4] = "NoScaleOrReflection";
  2761. })(TransformMode = spine.TransformMode || (spine.TransformMode = {}));
  2762. })(spine || (spine = {}));
  2763. var spine;
  2764. (function (spine) {
  2765. var ConstraintData = (function () {
  2766. function ConstraintData(name, order, skinRequired) {
  2767. this.name = name;
  2768. this.order = order;
  2769. this.skinRequired = skinRequired;
  2770. }
  2771. return ConstraintData;
  2772. }());
  2773. spine.ConstraintData = ConstraintData;
  2774. })(spine || (spine = {}));
  2775. var spine;
  2776. (function (spine) {
  2777. var Event = (function () {
  2778. function Event(time, data) {
  2779. if (data == null)
  2780. throw new Error("data cannot be null.");
  2781. this.time = time;
  2782. this.data = data;
  2783. }
  2784. return Event;
  2785. }());
  2786. spine.Event = Event;
  2787. })(spine || (spine = {}));
  2788. var spine;
  2789. (function (spine) {
  2790. var EventData = (function () {
  2791. function EventData(name) {
  2792. this.name = name;
  2793. }
  2794. return EventData;
  2795. }());
  2796. spine.EventData = EventData;
  2797. })(spine || (spine = {}));
  2798. var spine;
  2799. (function (spine) {
  2800. var IkConstraint = (function () {
  2801. function IkConstraint(data, skeleton) {
  2802. this.bendDirection = 0;
  2803. this.compress = false;
  2804. this.stretch = false;
  2805. this.mix = 1;
  2806. this.softness = 0;
  2807. this.active = false;
  2808. if (data == null)
  2809. throw new Error("data cannot be null.");
  2810. if (skeleton == null)
  2811. throw new Error("skeleton cannot be null.");
  2812. this.data = data;
  2813. this.mix = data.mix;
  2814. this.softness = data.softness;
  2815. this.bendDirection = data.bendDirection;
  2816. this.compress = data.compress;
  2817. this.stretch = data.stretch;
  2818. this.bones = new Array();
  2819. for (var i = 0; i < data.bones.length; i++)
  2820. this.bones.push(skeleton.findBone(data.bones[i].name));
  2821. this.target = skeleton.findBone(data.target.name);
  2822. }
  2823. IkConstraint.prototype.isActive = function () {
  2824. return this.active;
  2825. };
  2826. IkConstraint.prototype.apply = function () {
  2827. this.update();
  2828. };
  2829. IkConstraint.prototype.update = function () {
  2830. var target = this.target;
  2831. var bones = this.bones;
  2832. switch (bones.length) {
  2833. case 1:
  2834. this.apply1(bones[0], target.worldX, target.worldY, this.compress, this.stretch, this.data.uniform, this.mix);
  2835. break;
  2836. case 2:
  2837. this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.stretch, this.softness, this.mix);
  2838. break;
  2839. }
  2840. };
  2841. IkConstraint.prototype.apply1 = function (bone, targetX, targetY, compress, stretch, uniform, alpha) {
  2842. if (!bone.appliedValid)
  2843. bone.updateAppliedTransform();
  2844. var p = bone.parent;
  2845. var pa = p.a, pb = p.b, pc = p.c, pd = p.d;
  2846. var rotationIK = -bone.ashearX - bone.arotation, tx = 0, ty = 0;
  2847. switch (bone.data.transformMode) {
  2848. case spine.TransformMode.OnlyTranslation:
  2849. tx = targetX - bone.worldX;
  2850. ty = targetY - bone.worldY;
  2851. break;
  2852. case spine.TransformMode.NoRotationOrReflection:
  2853. var s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
  2854. var sa = pa / bone.skeleton.scaleX;
  2855. var sc = pc / bone.skeleton.scaleY;
  2856. pb = -sc * s * bone.skeleton.scaleX;
  2857. pd = sa * s * bone.skeleton.scaleY;
  2858. rotationIK += Math.atan2(sc, sa) * spine.MathUtils.radDeg;
  2859. default:
  2860. var x = targetX - p.worldX, y = targetY - p.worldY;
  2861. var d = pa * pd - pb * pc;
  2862. tx = (x * pd - y * pb) / d - bone.ax;
  2863. ty = (y * pa - x * pc) / d - bone.ay;
  2864. }
  2865. rotationIK += Math.atan2(ty, tx) * spine.MathUtils.radDeg;
  2866. if (bone.ascaleX < 0)
  2867. rotationIK += 180;
  2868. if (rotationIK > 180)
  2869. rotationIK -= 360;
  2870. else if (rotationIK < -180)
  2871. rotationIK += 360;
  2872. var sx = bone.ascaleX, sy = bone.ascaleY;
  2873. if (compress || stretch) {
  2874. switch (bone.data.transformMode) {
  2875. case spine.TransformMode.NoScale:
  2876. case spine.TransformMode.NoScaleOrReflection:
  2877. tx = targetX - bone.worldX;
  2878. ty = targetY - bone.worldY;
  2879. }
  2880. var b = bone.data.length * sx, dd = Math.sqrt(tx * tx + ty * ty);
  2881. if ((compress && dd < b) || (stretch && dd > b) && b > 0.0001) {
  2882. var s = (dd / b - 1) * alpha + 1;
  2883. sx *= s;
  2884. if (uniform)
  2885. sy *= s;
  2886. }
  2887. }
  2888. bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, sx, sy, bone.ashearX, bone.ashearY);
  2889. };
  2890. IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, stretch, softness, alpha) {
  2891. if (alpha == 0) {
  2892. child.updateWorldTransform();
  2893. return;
  2894. }
  2895. if (!parent.appliedValid)
  2896. parent.updateAppliedTransform();
  2897. if (!child.appliedValid)
  2898. child.updateAppliedTransform();
  2899. var px = parent.ax, py = parent.ay, psx = parent.ascaleX, sx = psx, psy = parent.ascaleY, csx = child.ascaleX;
  2900. var os1 = 0, os2 = 0, s2 = 0;
  2901. if (psx < 0) {
  2902. psx = -psx;
  2903. os1 = 180;
  2904. s2 = -1;
  2905. }
  2906. else {
  2907. os1 = 0;
  2908. s2 = 1;
  2909. }
  2910. if (psy < 0) {
  2911. psy = -psy;
  2912. s2 = -s2;
  2913. }
  2914. if (csx < 0) {
  2915. csx = -csx;
  2916. os2 = 180;
  2917. }
  2918. else
  2919. os2 = 0;
  2920. var cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d;
  2921. var u = Math.abs(psx - psy) <= 0.0001;
  2922. if (!u) {
  2923. cy = 0;
  2924. cwx = a * cx + parent.worldX;
  2925. cwy = c * cx + parent.worldY;
  2926. }
  2927. else {
  2928. cy = child.ay;
  2929. cwx = a * cx + b * cy + parent.worldX;
  2930. cwy = c * cx + d * cy + parent.worldY;
  2931. }
  2932. var pp = parent.parent;
  2933. a = pp.a;
  2934. b = pp.b;
  2935. c = pp.c;
  2936. d = pp.d;
  2937. var id = 1 / (a * d - b * c), x = cwx - pp.worldX, y = cwy - pp.worldY;
  2938. var dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
  2939. var l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
  2940. if (l1 < 0.0001) {
  2941. this.apply1(parent, targetX, targetY, false, stretch, false, alpha);
  2942. child.updateWorldTransformWith(cx, cy, 0, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY);
  2943. return;
  2944. }
  2945. x = targetX - pp.worldX;
  2946. y = targetY - pp.worldY;
  2947. var tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py;
  2948. var dd = tx * tx + ty * ty;
  2949. if (softness != 0) {
  2950. softness *= psx * (csx + 1) / 2;
  2951. var td = Math.sqrt(dd), sd = td - l1 - l2 * psx + softness;
  2952. if (sd > 0) {
  2953. var p = Math.min(1, sd / (softness * 2)) - 1;
  2954. p = (sd - softness * (1 - p * p)) / td;
  2955. tx -= p * tx;
  2956. ty -= p * ty;
  2957. dd = tx * tx + ty * ty;
  2958. }
  2959. }
  2960. outer: if (u) {
  2961. l2 *= psx;
  2962. var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2);
  2963. if (cos < -1)
  2964. cos = -1;
  2965. else if (cos > 1) {
  2966. cos = 1;
  2967. if (stretch)
  2968. sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1;
  2969. }
  2970. a2 = Math.acos(cos) * bendDir;
  2971. a = l1 + l2 * cos;
  2972. b = l2 * Math.sin(a2);
  2973. a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b);
  2974. }
  2975. else {
  2976. a = psx * l2;
  2977. b = psy * l2;
  2978. var aa = a * a, bb = b * b, ta = Math.atan2(ty, tx);
  2979. c = bb * l1 * l1 + aa * dd - aa * bb;
  2980. var c1 = -2 * bb * l1, c2 = bb - aa;
  2981. d = c1 * c1 - 4 * c2 * c;
  2982. if (d >= 0) {
  2983. var q = Math.sqrt(d);
  2984. if (c1 < 0)
  2985. q = -q;
  2986. q = -(c1 + q) / 2;
  2987. var r0 = q / c2, r1 = c / q;
  2988. var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
  2989. if (r * r <= dd) {
  2990. y = Math.sqrt(dd - r * r) * bendDir;
  2991. a1 = ta - Math.atan2(y, r);
  2992. a2 = Math.atan2(y / psy, (r - l1) / psx);
  2993. break outer;
  2994. }
  2995. }
  2996. var minAngle = spine.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0;
  2997. var maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0;
  2998. c = -a * l1 / (aa - bb);
  2999. if (c >= -1 && c <= 1) {
  3000. c = Math.acos(c);
  3001. x = a * Math.cos(c) + l1;
  3002. y = b * Math.sin(c);
  3003. d = x * x + y * y;
  3004. if (d < minDist) {
  3005. minAngle = c;
  3006. minDist = d;
  3007. minX = x;
  3008. minY = y;
  3009. }
  3010. if (d > maxDist) {
  3011. maxAngle = c;
  3012. maxDist = d;
  3013. maxX = x;
  3014. maxY = y;
  3015. }
  3016. }
  3017. if (dd <= (minDist + maxDist) / 2) {
  3018. a1 = ta - Math.atan2(minY * bendDir, minX);
  3019. a2 = minAngle * bendDir;
  3020. }
  3021. else {
  3022. a1 = ta - Math.atan2(maxY * bendDir, maxX);
  3023. a2 = maxAngle * bendDir;
  3024. }
  3025. }
  3026. var os = Math.atan2(cy, cx) * s2;
  3027. var rotation = parent.arotation;
  3028. a1 = (a1 - os) * spine.MathUtils.radDeg + os1 - rotation;
  3029. if (a1 > 180)
  3030. a1 -= 360;
  3031. else if (a1 < -180)
  3032. a1 += 360;
  3033. parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0);
  3034. rotation = child.arotation;
  3035. a2 = ((a2 + os) * spine.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation;
  3036. if (a2 > 180)
  3037. a2 -= 360;
  3038. else if (a2 < -180)
  3039. a2 += 360;
  3040. child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY);
  3041. };
  3042. return IkConstraint;
  3043. }());
  3044. spine.IkConstraint = IkConstraint;
  3045. })(spine || (spine = {}));
  3046. var spine;
  3047. (function (spine) {
  3048. var IkConstraintData = (function (_super) {
  3049. __extends(IkConstraintData, _super);
  3050. function IkConstraintData(name) {
  3051. var _this = _super.call(this, name, 0, false) || this;
  3052. _this.bones = new Array();
  3053. _this.bendDirection = 1;
  3054. _this.compress = false;
  3055. _this.stretch = false;
  3056. _this.uniform = false;
  3057. _this.mix = 1;
  3058. _this.softness = 0;
  3059. return _this;
  3060. }
  3061. return IkConstraintData;
  3062. }(spine.ConstraintData));
  3063. spine.IkConstraintData = IkConstraintData;
  3064. })(spine || (spine = {}));
  3065. var spine;
  3066. (function (spine) {
  3067. var PathConstraint = (function () {
  3068. function PathConstraint(data, skeleton) {
  3069. this.position = 0;
  3070. this.spacing = 0;
  3071. this.rotateMix = 0;
  3072. this.translateMix = 0;
  3073. this.spaces = new Array();
  3074. this.positions = new Array();
  3075. this.world = new Array();
  3076. this.curves = new Array();
  3077. this.lengths = new Array();
  3078. this.segments = new Array();
  3079. this.active = false;
  3080. if (data == null)
  3081. throw new Error("data cannot be null.");
  3082. if (skeleton == null)
  3083. throw new Error("skeleton cannot be null.");
  3084. this.data = data;
  3085. this.bones = new Array();
  3086. for (var i = 0, n = data.bones.length; i < n; i++)
  3087. this.bones.push(skeleton.findBone(data.bones[i].name));
  3088. this.target = skeleton.findSlot(data.target.name);
  3089. this.position = data.position;
  3090. this.spacing = data.spacing;
  3091. this.rotateMix = data.rotateMix;
  3092. this.translateMix = data.translateMix;
  3093. }
  3094. PathConstraint.prototype.isActive = function () {
  3095. return this.active;
  3096. };
  3097. PathConstraint.prototype.apply = function () {
  3098. this.update();
  3099. };
  3100. PathConstraint.prototype.update = function () {
  3101. var attachment = this.target.getAttachment();
  3102. if (!(attachment instanceof spine.PathAttachment))
  3103. return;
  3104. var rotateMix = this.rotateMix, translateMix = this.translateMix;
  3105. var translate = translateMix > 0, rotate = rotateMix > 0;
  3106. if (!translate && !rotate)
  3107. return;
  3108. var data = this.data;
  3109. var percentSpacing = data.spacingMode == spine.SpacingMode.Percent;
  3110. var rotateMode = data.rotateMode;
  3111. var tangents = rotateMode == spine.RotateMode.Tangent, scale = rotateMode == spine.RotateMode.ChainScale;
  3112. var boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1;
  3113. var bones = this.bones;
  3114. var spaces = spine.Utils.setArraySize(this.spaces, spacesCount), lengths = null;
  3115. var spacing = this.spacing;
  3116. if (scale || !percentSpacing) {
  3117. if (scale)
  3118. lengths = spine.Utils.setArraySize(this.lengths, boneCount);
  3119. var lengthSpacing = data.spacingMode == spine.SpacingMode.Length;
  3120. for (var i = 0, n = spacesCount - 1; i < n;) {
  3121. var bone = bones[i];
  3122. var setupLength = bone.data.length;
  3123. if (setupLength < PathConstraint.epsilon) {
  3124. if (scale)
  3125. lengths[i] = 0;
  3126. spaces[++i] = 0;
  3127. }
  3128. else if (percentSpacing) {
  3129. if (scale) {
  3130. var x = setupLength * bone.a, y = setupLength * bone.c;
  3131. var length_1 = Math.sqrt(x * x + y * y);
  3132. lengths[i] = length_1;
  3133. }
  3134. spaces[++i] = spacing;
  3135. }
  3136. else {
  3137. var x = setupLength * bone.a, y = setupLength * bone.c;
  3138. var length_2 = Math.sqrt(x * x + y * y);
  3139. if (scale)
  3140. lengths[i] = length_2;
  3141. spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_2 / setupLength;
  3142. }
  3143. }
  3144. }
  3145. else {
  3146. for (var i = 1; i < spacesCount; i++)
  3147. spaces[i] = spacing;
  3148. }
  3149. var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, percentSpacing);
  3150. var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
  3151. var tip = false;
  3152. if (offsetRotation == 0)
  3153. tip = rotateMode == spine.RotateMode.Chain;
  3154. else {
  3155. tip = false;
  3156. var p = this.target.bone;
  3157. offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  3158. }
  3159. for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
  3160. var bone = bones[i];
  3161. bone.worldX += (boneX - bone.worldX) * translateMix;
  3162. bone.worldY += (boneY - bone.worldY) * translateMix;
  3163. var x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY;
  3164. if (scale) {
  3165. var length_3 = lengths[i];
  3166. if (length_3 != 0) {
  3167. var s = (Math.sqrt(dx * dx + dy * dy) / length_3 - 1) * rotateMix + 1;
  3168. bone.a *= s;
  3169. bone.c *= s;
  3170. }
  3171. }
  3172. boneX = x;
  3173. boneY = y;
  3174. if (rotate) {
  3175. var a = bone.a, b = bone.b, c = bone.c, d = bone.d, r = 0, cos = 0, sin = 0;
  3176. if (tangents)
  3177. r = positions[p - 1];
  3178. else if (spaces[i + 1] == 0)
  3179. r = positions[p + 2];
  3180. else
  3181. r = Math.atan2(dy, dx);
  3182. r -= Math.atan2(c, a);
  3183. if (tip) {
  3184. cos = Math.cos(r);
  3185. sin = Math.sin(r);
  3186. var length_4 = bone.data.length;
  3187. boneX += (length_4 * (cos * a - sin * c) - dx) * rotateMix;
  3188. boneY += (length_4 * (sin * a + cos * c) - dy) * rotateMix;
  3189. }
  3190. else {
  3191. r += offsetRotation;
  3192. }
  3193. if (r > spine.MathUtils.PI)
  3194. r -= spine.MathUtils.PI2;
  3195. else if (r < -spine.MathUtils.PI)
  3196. r += spine.MathUtils.PI2;
  3197. r *= rotateMix;
  3198. cos = Math.cos(r);
  3199. sin = Math.sin(r);
  3200. bone.a = cos * a - sin * c;
  3201. bone.b = cos * b - sin * d;
  3202. bone.c = sin * a + cos * c;
  3203. bone.d = sin * b + cos * d;
  3204. }
  3205. bone.appliedValid = false;
  3206. }
  3207. };
  3208. PathConstraint.prototype.computeWorldPositions = function (path, spacesCount, tangents, percentPosition, percentSpacing) {
  3209. var target = this.target;
  3210. var position = this.position;
  3211. var spaces = this.spaces, out = spine.Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null;
  3212. var closed = path.closed;
  3213. var verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE;
  3214. if (!path.constantSpeed) {
  3215. var lengths = path.lengths;
  3216. curveCount -= closed ? 1 : 2;
  3217. var pathLength_1 = lengths[curveCount];
  3218. if (percentPosition)
  3219. position *= pathLength_1;
  3220. if (percentSpacing) {
  3221. for (var i = 1; i < spacesCount; i++)
  3222. spaces[i] *= pathLength_1;
  3223. }
  3224. world = spine.Utils.setArraySize(this.world, 8);
  3225. for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) {
  3226. var space = spaces[i];
  3227. position += space;
  3228. var p = position;
  3229. if (closed) {
  3230. p %= pathLength_1;
  3231. if (p < 0)
  3232. p += pathLength_1;
  3233. curve = 0;
  3234. }
  3235. else if (p < 0) {
  3236. if (prevCurve != PathConstraint.BEFORE) {
  3237. prevCurve = PathConstraint.BEFORE;
  3238. path.computeWorldVertices(target, 2, 4, world, 0, 2);
  3239. }
  3240. this.addBeforePosition(p, world, 0, out, o);
  3241. continue;
  3242. }
  3243. else if (p > pathLength_1) {
  3244. if (prevCurve != PathConstraint.AFTER) {
  3245. prevCurve = PathConstraint.AFTER;
  3246. path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2);
  3247. }
  3248. this.addAfterPosition(p - pathLength_1, world, 0, out, o);
  3249. continue;
  3250. }
  3251. for (;; curve++) {
  3252. var length_5 = lengths[curve];
  3253. if (p > length_5)
  3254. continue;
  3255. if (curve == 0)
  3256. p /= length_5;
  3257. else {
  3258. var prev = lengths[curve - 1];
  3259. p = (p - prev) / (length_5 - prev);
  3260. }
  3261. break;
  3262. }
  3263. if (curve != prevCurve) {
  3264. prevCurve = curve;
  3265. if (closed && curve == curveCount) {
  3266. path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2);
  3267. path.computeWorldVertices(target, 0, 4, world, 4, 2);
  3268. }
  3269. else
  3270. path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2);
  3271. }
  3272. 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));
  3273. }
  3274. return out;
  3275. }
  3276. if (closed) {
  3277. verticesLength += 2;
  3278. world = spine.Utils.setArraySize(this.world, verticesLength);
  3279. path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);
  3280. path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);
  3281. world[verticesLength - 2] = world[0];
  3282. world[verticesLength - 1] = world[1];
  3283. }
  3284. else {
  3285. curveCount--;
  3286. verticesLength -= 4;
  3287. world = spine.Utils.setArraySize(this.world, verticesLength);
  3288. path.computeWorldVertices(target, 2, verticesLength, world, 0, 2);
  3289. }
  3290. var curves = spine.Utils.setArraySize(this.curves, curveCount);
  3291. var pathLength = 0;
  3292. var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;
  3293. var tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0;
  3294. for (var i = 0, w = 2; i < curveCount; i++, w += 6) {
  3295. cx1 = world[w];
  3296. cy1 = world[w + 1];
  3297. cx2 = world[w + 2];
  3298. cy2 = world[w + 3];
  3299. x2 = world[w + 4];
  3300. y2 = world[w + 5];
  3301. tmpx = (x1 - cx1 * 2 + cx2) * 0.1875;
  3302. tmpy = (y1 - cy1 * 2 + cy2) * 0.1875;
  3303. dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375;
  3304. dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375;
  3305. ddfx = tmpx * 2 + dddfx;
  3306. ddfy = tmpy * 2 + dddfy;
  3307. dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667;
  3308. dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667;
  3309. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3310. dfx += ddfx;
  3311. dfy += ddfy;
  3312. ddfx += dddfx;
  3313. ddfy += dddfy;
  3314. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3315. dfx += ddfx;
  3316. dfy += ddfy;
  3317. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3318. dfx += ddfx + dddfx;
  3319. dfy += ddfy + dddfy;
  3320. pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3321. curves[i] = pathLength;
  3322. x1 = x2;
  3323. y1 = y2;
  3324. }
  3325. if (percentPosition)
  3326. position *= pathLength;
  3327. else
  3328. position *= pathLength / path.lengths[curveCount - 1];
  3329. if (percentSpacing) {
  3330. for (var i = 1; i < spacesCount; i++)
  3331. spaces[i] *= pathLength;
  3332. }
  3333. var segments = this.segments;
  3334. var curveLength = 0;
  3335. for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) {
  3336. var space = spaces[i];
  3337. position += space;
  3338. var p = position;
  3339. if (closed) {
  3340. p %= pathLength;
  3341. if (p < 0)
  3342. p += pathLength;
  3343. curve = 0;
  3344. }
  3345. else if (p < 0) {
  3346. this.addBeforePosition(p, world, 0, out, o);
  3347. continue;
  3348. }
  3349. else if (p > pathLength) {
  3350. this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o);
  3351. continue;
  3352. }
  3353. for (;; curve++) {
  3354. var length_6 = curves[curve];
  3355. if (p > length_6)
  3356. continue;
  3357. if (curve == 0)
  3358. p /= length_6;
  3359. else {
  3360. var prev = curves[curve - 1];
  3361. p = (p - prev) / (length_6 - prev);
  3362. }
  3363. break;
  3364. }
  3365. if (curve != prevCurve) {
  3366. prevCurve = curve;
  3367. var ii = curve * 6;
  3368. x1 = world[ii];
  3369. y1 = world[ii + 1];
  3370. cx1 = world[ii + 2];
  3371. cy1 = world[ii + 3];
  3372. cx2 = world[ii + 4];
  3373. cy2 = world[ii + 5];
  3374. x2 = world[ii + 6];
  3375. y2 = world[ii + 7];
  3376. tmpx = (x1 - cx1 * 2 + cx2) * 0.03;
  3377. tmpy = (y1 - cy1 * 2 + cy2) * 0.03;
  3378. dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006;
  3379. dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006;
  3380. ddfx = tmpx * 2 + dddfx;
  3381. ddfy = tmpy * 2 + dddfy;
  3382. dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667;
  3383. dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667;
  3384. curveLength = Math.sqrt(dfx * dfx + dfy * dfy);
  3385. segments[0] = curveLength;
  3386. for (ii = 1; ii < 8; ii++) {
  3387. dfx += ddfx;
  3388. dfy += ddfy;
  3389. ddfx += dddfx;
  3390. ddfy += dddfy;
  3391. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3392. segments[ii] = curveLength;
  3393. }
  3394. dfx += ddfx;
  3395. dfy += ddfy;
  3396. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3397. segments[8] = curveLength;
  3398. dfx += ddfx + dddfx;
  3399. dfy += ddfy + dddfy;
  3400. curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
  3401. segments[9] = curveLength;
  3402. segment = 0;
  3403. }
  3404. p *= curveLength;
  3405. for (;; segment++) {
  3406. var length_7 = segments[segment];
  3407. if (p > length_7)
  3408. continue;
  3409. if (segment == 0)
  3410. p /= length_7;
  3411. else {
  3412. var prev = segments[segment - 1];
  3413. p = segment + (p - prev) / (length_7 - prev);
  3414. }
  3415. break;
  3416. }
  3417. this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0));
  3418. }
  3419. return out;
  3420. };
  3421. PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) {
  3422. var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx);
  3423. out[o] = x1 + p * Math.cos(r);
  3424. out[o + 1] = y1 + p * Math.sin(r);
  3425. out[o + 2] = r;
  3426. };
  3427. PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) {
  3428. var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx);
  3429. out[o] = x1 + p * Math.cos(r);
  3430. out[o + 1] = y1 + p * Math.sin(r);
  3431. out[o + 2] = r;
  3432. };
  3433. PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) {
  3434. if (p == 0 || isNaN(p)) {
  3435. out[o] = x1;
  3436. out[o + 1] = y1;
  3437. out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1);
  3438. return;
  3439. }
  3440. var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;
  3441. var ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;
  3442. var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
  3443. out[o] = x;
  3444. out[o + 1] = y;
  3445. if (tangents) {
  3446. if (p < 0.001)
  3447. out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1);
  3448. else
  3449. out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
  3450. }
  3451. };
  3452. PathConstraint.NONE = -1;
  3453. PathConstraint.BEFORE = -2;
  3454. PathConstraint.AFTER = -3;
  3455. PathConstraint.epsilon = 0.00001;
  3456. return PathConstraint;
  3457. }());
  3458. spine.PathConstraint = PathConstraint;
  3459. })(spine || (spine = {}));
  3460. var spine;
  3461. (function (spine) {
  3462. var PathConstraintData = (function (_super) {
  3463. __extends(PathConstraintData, _super);
  3464. function PathConstraintData(name) {
  3465. var _this = _super.call(this, name, 0, false) || this;
  3466. _this.bones = new Array();
  3467. return _this;
  3468. }
  3469. return PathConstraintData;
  3470. }(spine.ConstraintData));
  3471. spine.PathConstraintData = PathConstraintData;
  3472. var PositionMode;
  3473. (function (PositionMode) {
  3474. PositionMode[PositionMode["Fixed"] = 0] = "Fixed";
  3475. PositionMode[PositionMode["Percent"] = 1] = "Percent";
  3476. })(PositionMode = spine.PositionMode || (spine.PositionMode = {}));
  3477. var SpacingMode;
  3478. (function (SpacingMode) {
  3479. SpacingMode[SpacingMode["Length"] = 0] = "Length";
  3480. SpacingMode[SpacingMode["Fixed"] = 1] = "Fixed";
  3481. SpacingMode[SpacingMode["Percent"] = 2] = "Percent";
  3482. })(SpacingMode = spine.SpacingMode || (spine.SpacingMode = {}));
  3483. var RotateMode;
  3484. (function (RotateMode) {
  3485. RotateMode[RotateMode["Tangent"] = 0] = "Tangent";
  3486. RotateMode[RotateMode["Chain"] = 1] = "Chain";
  3487. RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
  3488. })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
  3489. })(spine || (spine = {}));
  3490. var spine;
  3491. (function (spine) {
  3492. var Assets = (function () {
  3493. function Assets(clientId) {
  3494. this.toLoad = new Array();
  3495. this.assets = {};
  3496. this.clientId = clientId;
  3497. }
  3498. Assets.prototype.loaded = function () {
  3499. var i = 0;
  3500. for (var v in this.assets)
  3501. i++;
  3502. return i;
  3503. };
  3504. return Assets;
  3505. }());
  3506. var SharedAssetManager = (function () {
  3507. function SharedAssetManager(pathPrefix) {
  3508. if (pathPrefix === void 0) { pathPrefix = ""; }
  3509. this.clientAssets = {};
  3510. this.queuedAssets = {};
  3511. this.rawAssets = {};
  3512. this.errors = {};
  3513. this.pathPrefix = pathPrefix;
  3514. }
  3515. SharedAssetManager.prototype.queueAsset = function (clientId, textureLoader, path) {
  3516. var clientAssets = this.clientAssets[clientId];
  3517. if (clientAssets === null || clientAssets === undefined) {
  3518. clientAssets = new Assets(clientId);
  3519. this.clientAssets[clientId] = clientAssets;
  3520. }
  3521. if (textureLoader !== null)
  3522. clientAssets.textureLoader = textureLoader;
  3523. clientAssets.toLoad.push(path);
  3524. if (this.queuedAssets[path] === path) {
  3525. return false;
  3526. }
  3527. else {
  3528. this.queuedAssets[path] = path;
  3529. return true;
  3530. }
  3531. };
  3532. SharedAssetManager.prototype.loadText = function (clientId, path) {
  3533. var _this = this;
  3534. path = this.pathPrefix + path;
  3535. if (!this.queueAsset(clientId, null, path))
  3536. return;
  3537. var request = new XMLHttpRequest();
  3538. request.overrideMimeType("text/html");
  3539. request.onreadystatechange = function () {
  3540. if (request.readyState == XMLHttpRequest.DONE) {
  3541. if (request.status >= 200 && request.status < 300) {
  3542. _this.rawAssets[path] = request.responseText;
  3543. }
  3544. else {
  3545. _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
  3546. }
  3547. }
  3548. };
  3549. request.open("GET", path, true);
  3550. request.send();
  3551. };
  3552. SharedAssetManager.prototype.loadJson = function (clientId, path) {
  3553. var _this = this;
  3554. path = this.pathPrefix + path;
  3555. if (!this.queueAsset(clientId, null, path))
  3556. return;
  3557. var request = new XMLHttpRequest();
  3558. request.overrideMimeType("text/html");
  3559. request.onreadystatechange = function () {
  3560. if (request.readyState == XMLHttpRequest.DONE) {
  3561. if (request.status >= 200 && request.status < 300) {
  3562. _this.rawAssets[path] = JSON.parse(request.responseText);
  3563. }
  3564. else {
  3565. _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
  3566. }
  3567. }
  3568. };
  3569. request.open("GET", path, true);
  3570. request.send();
  3571. };
  3572. SharedAssetManager.prototype.loadTexture = function (clientId, textureLoader, path) {
  3573. var _this = this;
  3574. path = this.pathPrefix + path;
  3575. if (!this.queueAsset(clientId, textureLoader, path))
  3576. return;
  3577. var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
  3578. var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
  3579. if (isWebWorker) {
  3580. var options = { mode: "cors" };
  3581. fetch(path, options).then(function (response) {
  3582. if (!response.ok) {
  3583. _this.errors[path] = "Couldn't load image " + path;
  3584. }
  3585. return response.blob();
  3586. }).then(function (blob) {
  3587. return createImageBitmap(blob, {
  3588. premultiplyAlpha: 'none',
  3589. colorSpaceConversion: 'none'
  3590. });
  3591. }).then(function (bitmap) {
  3592. _this.rawAssets[path] = bitmap;
  3593. });
  3594. }
  3595. else {
  3596. var img_1 = new Image();
  3597. img_1.crossOrigin = "anonymous";
  3598. img_1.onload = function (ev) {
  3599. _this.rawAssets[path] = img_1;
  3600. };
  3601. img_1.onerror = function (ev) {
  3602. _this.errors[path] = "Couldn't load image " + path;
  3603. };
  3604. img_1.src = path;
  3605. }
  3606. };
  3607. SharedAssetManager.prototype.get = function (clientId, path) {
  3608. path = this.pathPrefix + path;
  3609. var clientAssets = this.clientAssets[clientId];
  3610. if (clientAssets === null || clientAssets === undefined)
  3611. return true;
  3612. return clientAssets.assets[path];
  3613. };
  3614. SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
  3615. var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
  3616. var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
  3617. for (var i = 0; i < clientAssets.toLoad.length; i++) {
  3618. var path = clientAssets.toLoad[i];
  3619. var asset = clientAssets.assets[path];
  3620. if (asset === null || asset === undefined) {
  3621. var rawAsset = this.rawAssets[path];
  3622. if (rawAsset === null || rawAsset === undefined)
  3623. continue;
  3624. if (isWebWorker) {
  3625. if (rawAsset instanceof ImageBitmap) {
  3626. clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
  3627. }
  3628. else {
  3629. clientAssets.assets[path] = rawAsset;
  3630. }
  3631. }
  3632. else {
  3633. if (rawAsset instanceof HTMLImageElement) {
  3634. clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
  3635. }
  3636. else {
  3637. clientAssets.assets[path] = rawAsset;
  3638. }
  3639. }
  3640. }
  3641. }
  3642. };
  3643. SharedAssetManager.prototype.isLoadingComplete = function (clientId) {
  3644. var clientAssets = this.clientAssets[clientId];
  3645. if (clientAssets === null || clientAssets === undefined)
  3646. return true;
  3647. this.updateClientAssets(clientAssets);
  3648. return clientAssets.toLoad.length == clientAssets.loaded();
  3649. };
  3650. SharedAssetManager.prototype.dispose = function () {
  3651. };
  3652. SharedAssetManager.prototype.hasErrors = function () {
  3653. return Object.keys(this.errors).length > 0;
  3654. };
  3655. SharedAssetManager.prototype.getErrors = function () {
  3656. return this.errors;
  3657. };
  3658. return SharedAssetManager;
  3659. }());
  3660. spine.SharedAssetManager = SharedAssetManager;
  3661. })(spine || (spine = {}));
  3662. var spine;
  3663. (function (spine) {
  3664. var Skeleton = (function () {
  3665. function Skeleton(data) {
  3666. this._updateCache = new Array();
  3667. this.updateCacheReset = new Array();
  3668. this.time = 0;
  3669. this.scaleX = 1;
  3670. this.scaleY = 1;
  3671. this.x = 0;
  3672. this.y = 0;
  3673. if (data == null)
  3674. throw new Error("data cannot be null.");
  3675. this.data = data;
  3676. this.bones = new Array();
  3677. for (var i = 0; i < data.bones.length; i++) {
  3678. var boneData = data.bones[i];
  3679. var bone = void 0;
  3680. if (boneData.parent == null)
  3681. bone = new spine.Bone(boneData, this, null);
  3682. else {
  3683. var parent_1 = this.bones[boneData.parent.index];
  3684. bone = new spine.Bone(boneData, this, parent_1);
  3685. parent_1.children.push(bone);
  3686. }
  3687. this.bones.push(bone);
  3688. }
  3689. this.slots = new Array();
  3690. this.drawOrder = new Array();
  3691. for (var i = 0; i < data.slots.length; i++) {
  3692. var slotData = data.slots[i];
  3693. var bone = this.bones[slotData.boneData.index];
  3694. var slot = new spine.Slot(slotData, bone);
  3695. this.slots.push(slot);
  3696. this.drawOrder.push(slot);
  3697. }
  3698. this.ikConstraints = new Array();
  3699. for (var i = 0; i < data.ikConstraints.length; i++) {
  3700. var ikConstraintData = data.ikConstraints[i];
  3701. this.ikConstraints.push(new spine.IkConstraint(ikConstraintData, this));
  3702. }
  3703. this.transformConstraints = new Array();
  3704. for (var i = 0; i < data.transformConstraints.length; i++) {
  3705. var transformConstraintData = data.transformConstraints[i];
  3706. this.transformConstraints.push(new spine.TransformConstraint(transformConstraintData, this));
  3707. }
  3708. this.pathConstraints = new Array();
  3709. for (var i = 0; i < data.pathConstraints.length; i++) {
  3710. var pathConstraintData = data.pathConstraints[i];
  3711. this.pathConstraints.push(new spine.PathConstraint(pathConstraintData, this));
  3712. }
  3713. this.color = new spine.Color(1, 1, 1, 1);
  3714. this.updateCache();
  3715. }
  3716. Skeleton.prototype.updateCache = function () {
  3717. var updateCache = this._updateCache;
  3718. updateCache.length = 0;
  3719. this.updateCacheReset.length = 0;
  3720. var bones = this.bones;
  3721. for (var i = 0, n = bones.length; i < n; i++) {
  3722. var bone = bones[i];
  3723. bone.sorted = bone.data.skinRequired;
  3724. bone.active = !bone.sorted;
  3725. }
  3726. if (this.skin != null) {
  3727. var skinBones = this.skin.bones;
  3728. for (var i = 0, n = this.skin.bones.length; i < n; i++) {
  3729. var bone = this.bones[skinBones[i].index];
  3730. do {
  3731. bone.sorted = false;
  3732. bone.active = true;
  3733. bone = bone.parent;
  3734. } while (bone != null);
  3735. }
  3736. }
  3737. var ikConstraints = this.ikConstraints;
  3738. var transformConstraints = this.transformConstraints;
  3739. var pathConstraints = this.pathConstraints;
  3740. var ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length;
  3741. var constraintCount = ikCount + transformCount + pathCount;
  3742. outer: for (var i = 0; i < constraintCount; i++) {
  3743. for (var ii = 0; ii < ikCount; ii++) {
  3744. var constraint = ikConstraints[ii];
  3745. if (constraint.data.order == i) {
  3746. this.sortIkConstraint(constraint);
  3747. continue outer;
  3748. }
  3749. }
  3750. for (var ii = 0; ii < transformCount; ii++) {
  3751. var constraint = transformConstraints[ii];
  3752. if (constraint.data.order == i) {
  3753. this.sortTransformConstraint(constraint);
  3754. continue outer;
  3755. }
  3756. }
  3757. for (var ii = 0; ii < pathCount; ii++) {
  3758. var constraint = pathConstraints[ii];
  3759. if (constraint.data.order == i) {
  3760. this.sortPathConstraint(constraint);
  3761. continue outer;
  3762. }
  3763. }
  3764. }
  3765. for (var i = 0, n = bones.length; i < n; i++)
  3766. this.sortBone(bones[i]);
  3767. };
  3768. Skeleton.prototype.sortIkConstraint = function (constraint) {
  3769. constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || (this.skin != null && spine.Utils.contains(this.skin.constraints, constraint.data, true)));
  3770. if (!constraint.active)
  3771. return;
  3772. var target = constraint.target;
  3773. this.sortBone(target);
  3774. var constrained = constraint.bones;
  3775. var parent = constrained[0];
  3776. this.sortBone(parent);
  3777. if (constrained.length > 1) {
  3778. var child = constrained[constrained.length - 1];
  3779. if (!(this._updateCache.indexOf(child) > -1))
  3780. this.updateCacheReset.push(child);
  3781. }
  3782. this._updateCache.push(constraint);
  3783. this.sortReset(parent.children);
  3784. constrained[constrained.length - 1].sorted = true;
  3785. };
  3786. Skeleton.prototype.sortPathConstraint = function (constraint) {
  3787. constraint.active = constraint.target.bone.isActive() && (!constraint.data.skinRequired || (this.skin != null && spine.Utils.contains(this.skin.constraints, constraint.data, true)));
  3788. if (!constraint.active)
  3789. return;
  3790. var slot = constraint.target;
  3791. var slotIndex = slot.data.index;
  3792. var slotBone = slot.bone;
  3793. if (this.skin != null)
  3794. this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone);
  3795. if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin)
  3796. this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone);
  3797. for (var i = 0, n = this.data.skins.length; i < n; i++)
  3798. this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone);
  3799. var attachment = slot.getAttachment();
  3800. if (attachment instanceof spine.PathAttachment)
  3801. this.sortPathConstraintAttachmentWith(attachment, slotBone);
  3802. var constrained = constraint.bones;
  3803. var boneCount = constrained.length;
  3804. for (var i = 0; i < boneCount; i++)
  3805. this.sortBone(constrained[i]);
  3806. this._updateCache.push(constraint);
  3807. for (var i = 0; i < boneCount; i++)
  3808. this.sortReset(constrained[i].children);
  3809. for (var i = 0; i < boneCount; i++)
  3810. constrained[i].sorted = true;
  3811. };
  3812. Skeleton.prototype.sortTransformConstraint = function (constraint) {
  3813. constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || (this.skin != null && spine.Utils.contains(this.skin.constraints, constraint.data, true)));
  3814. if (!constraint.active)
  3815. return;
  3816. this.sortBone(constraint.target);
  3817. var constrained = constraint.bones;
  3818. var boneCount = constrained.length;
  3819. if (constraint.data.local) {
  3820. for (var i = 0; i < boneCount; i++) {
  3821. var child = constrained[i];
  3822. this.sortBone(child.parent);
  3823. if (!(this._updateCache.indexOf(child) > -1))
  3824. this.updateCacheReset.push(child);
  3825. }
  3826. }
  3827. else {
  3828. for (var i = 0; i < boneCount; i++) {
  3829. this.sortBone(constrained[i]);
  3830. }
  3831. }
  3832. this._updateCache.push(constraint);
  3833. for (var ii = 0; ii < boneCount; ii++)
  3834. this.sortReset(constrained[ii].children);
  3835. for (var ii = 0; ii < boneCount; ii++)
  3836. constrained[ii].sorted = true;
  3837. };
  3838. Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) {
  3839. var attachments = skin.attachments[slotIndex];
  3840. if (!attachments)
  3841. return;
  3842. for (var key in attachments) {
  3843. this.sortPathConstraintAttachmentWith(attachments[key], slotBone);
  3844. }
  3845. };
  3846. Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) {
  3847. if (!(attachment instanceof spine.PathAttachment))
  3848. return;
  3849. var pathBones = attachment.bones;
  3850. if (pathBones == null)
  3851. this.sortBone(slotBone);
  3852. else {
  3853. var bones = this.bones;
  3854. var i = 0;
  3855. while (i < pathBones.length) {
  3856. var boneCount = pathBones[i++];
  3857. for (var n = i + boneCount; i < n; i++) {
  3858. var boneIndex = pathBones[i];
  3859. this.sortBone(bones[boneIndex]);
  3860. }
  3861. }
  3862. }
  3863. };
  3864. Skeleton.prototype.sortBone = function (bone) {
  3865. if (bone.sorted)
  3866. return;
  3867. var parent = bone.parent;
  3868. if (parent != null)
  3869. this.sortBone(parent);
  3870. bone.sorted = true;
  3871. this._updateCache.push(bone);
  3872. };
  3873. Skeleton.prototype.sortReset = function (bones) {
  3874. for (var i = 0, n = bones.length; i < n; i++) {
  3875. var bone = bones[i];
  3876. if (!bone.active)
  3877. continue;
  3878. if (bone.sorted)
  3879. this.sortReset(bone.children);
  3880. bone.sorted = false;
  3881. }
  3882. };
  3883. Skeleton.prototype.updateWorldTransform = function () {
  3884. var updateCacheReset = this.updateCacheReset;
  3885. for (var i = 0, n = updateCacheReset.length; i < n; i++) {
  3886. var bone = updateCacheReset[i];
  3887. bone.ax = bone.x;
  3888. bone.ay = bone.y;
  3889. bone.arotation = bone.rotation;
  3890. bone.ascaleX = bone.scaleX;
  3891. bone.ascaleY = bone.scaleY;
  3892. bone.ashearX = bone.shearX;
  3893. bone.ashearY = bone.shearY;
  3894. bone.appliedValid = true;
  3895. }
  3896. var updateCache = this._updateCache;
  3897. for (var i = 0, n = updateCache.length; i < n; i++)
  3898. updateCache[i].update();
  3899. };
  3900. Skeleton.prototype.setToSetupPose = function () {
  3901. this.setBonesToSetupPose();
  3902. this.setSlotsToSetupPose();
  3903. };
  3904. Skeleton.prototype.setBonesToSetupPose = function () {
  3905. var bones = this.bones;
  3906. for (var i = 0, n = bones.length; i < n; i++)
  3907. bones[i].setToSetupPose();
  3908. var ikConstraints = this.ikConstraints;
  3909. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  3910. var constraint = ikConstraints[i];
  3911. constraint.mix = constraint.data.mix;
  3912. constraint.softness = constraint.data.softness;
  3913. constraint.bendDirection = constraint.data.bendDirection;
  3914. constraint.compress = constraint.data.compress;
  3915. constraint.stretch = constraint.data.stretch;
  3916. }
  3917. var transformConstraints = this.transformConstraints;
  3918. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  3919. var constraint = transformConstraints[i];
  3920. var data = constraint.data;
  3921. constraint.rotateMix = data.rotateMix;
  3922. constraint.translateMix = data.translateMix;
  3923. constraint.scaleMix = data.scaleMix;
  3924. constraint.shearMix = data.shearMix;
  3925. }
  3926. var pathConstraints = this.pathConstraints;
  3927. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  3928. var constraint = pathConstraints[i];
  3929. var data = constraint.data;
  3930. constraint.position = data.position;
  3931. constraint.spacing = data.spacing;
  3932. constraint.rotateMix = data.rotateMix;
  3933. constraint.translateMix = data.translateMix;
  3934. }
  3935. };
  3936. Skeleton.prototype.setSlotsToSetupPose = function () {
  3937. var slots = this.slots;
  3938. spine.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length);
  3939. for (var i = 0, n = slots.length; i < n; i++)
  3940. slots[i].setToSetupPose();
  3941. };
  3942. Skeleton.prototype.getRootBone = function () {
  3943. if (this.bones.length == 0)
  3944. return null;
  3945. return this.bones[0];
  3946. };
  3947. Skeleton.prototype.findBone = function (boneName) {
  3948. if (boneName == null)
  3949. throw new Error("boneName cannot be null.");
  3950. var bones = this.bones;
  3951. for (var i = 0, n = bones.length; i < n; i++) {
  3952. var bone = bones[i];
  3953. if (bone.data.name == boneName)
  3954. return bone;
  3955. }
  3956. return null;
  3957. };
  3958. Skeleton.prototype.findBoneIndex = function (boneName) {
  3959. if (boneName == null)
  3960. throw new Error("boneName cannot be null.");
  3961. var bones = this.bones;
  3962. for (var i = 0, n = bones.length; i < n; i++)
  3963. if (bones[i].data.name == boneName)
  3964. return i;
  3965. return -1;
  3966. };
  3967. Skeleton.prototype.findSlot = function (slotName) {
  3968. if (slotName == null)
  3969. throw new Error("slotName cannot be null.");
  3970. var slots = this.slots;
  3971. for (var i = 0, n = slots.length; i < n; i++) {
  3972. var slot = slots[i];
  3973. if (slot.data.name == slotName)
  3974. return slot;
  3975. }
  3976. return null;
  3977. };
  3978. Skeleton.prototype.findSlotIndex = function (slotName) {
  3979. if (slotName == null)
  3980. throw new Error("slotName cannot be null.");
  3981. var slots = this.slots;
  3982. for (var i = 0, n = slots.length; i < n; i++)
  3983. if (slots[i].data.name == slotName)
  3984. return i;
  3985. return -1;
  3986. };
  3987. Skeleton.prototype.setSkinByName = function (skinName) {
  3988. var skin = this.data.findSkin(skinName);
  3989. if (skin == null)
  3990. throw new Error("Skin not found: " + skinName);
  3991. this.setSkin(skin);
  3992. };
  3993. Skeleton.prototype.setSkin = function (newSkin) {
  3994. if (newSkin == this.skin)
  3995. return;
  3996. if (newSkin != null) {
  3997. if (this.skin != null)
  3998. newSkin.attachAll(this, this.skin);
  3999. else {
  4000. var slots = this.slots;
  4001. for (var i = 0, n = slots.length; i < n; i++) {
  4002. var slot = slots[i];
  4003. var name_1 = slot.data.attachmentName;
  4004. if (name_1 != null) {
  4005. var attachment = newSkin.getAttachment(i, name_1);
  4006. if (attachment != null)
  4007. slot.setAttachment(attachment);
  4008. }
  4009. }
  4010. }
  4011. }
  4012. this.skin = newSkin;
  4013. this.updateCache();
  4014. };
  4015. Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) {
  4016. return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName);
  4017. };
  4018. Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) {
  4019. if (attachmentName == null)
  4020. throw new Error("attachmentName cannot be null.");
  4021. if (this.skin != null) {
  4022. var attachment = this.skin.getAttachment(slotIndex, attachmentName);
  4023. if (attachment != null)
  4024. return attachment;
  4025. }
  4026. if (this.data.defaultSkin != null)
  4027. return this.data.defaultSkin.getAttachment(slotIndex, attachmentName);
  4028. return null;
  4029. };
  4030. Skeleton.prototype.setAttachment = function (slotName, attachmentName) {
  4031. if (slotName == null)
  4032. throw new Error("slotName cannot be null.");
  4033. var slots = this.slots;
  4034. for (var i = 0, n = slots.length; i < n; i++) {
  4035. var slot = slots[i];
  4036. if (slot.data.name == slotName) {
  4037. var attachment = null;
  4038. if (attachmentName != null) {
  4039. attachment = this.getAttachment(i, attachmentName);
  4040. if (attachment == null)
  4041. throw new Error("Attachment not found: " + attachmentName + ", for slot: " + slotName);
  4042. }
  4043. slot.setAttachment(attachment);
  4044. return;
  4045. }
  4046. }
  4047. throw new Error("Slot not found: " + slotName);
  4048. };
  4049. Skeleton.prototype.findIkConstraint = function (constraintName) {
  4050. if (constraintName == null)
  4051. throw new Error("constraintName cannot be null.");
  4052. var ikConstraints = this.ikConstraints;
  4053. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  4054. var ikConstraint = ikConstraints[i];
  4055. if (ikConstraint.data.name == constraintName)
  4056. return ikConstraint;
  4057. }
  4058. return null;
  4059. };
  4060. Skeleton.prototype.findTransformConstraint = function (constraintName) {
  4061. if (constraintName == null)
  4062. throw new Error("constraintName cannot be null.");
  4063. var transformConstraints = this.transformConstraints;
  4064. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  4065. var constraint = transformConstraints[i];
  4066. if (constraint.data.name == constraintName)
  4067. return constraint;
  4068. }
  4069. return null;
  4070. };
  4071. Skeleton.prototype.findPathConstraint = function (constraintName) {
  4072. if (constraintName == null)
  4073. throw new Error("constraintName cannot be null.");
  4074. var pathConstraints = this.pathConstraints;
  4075. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  4076. var constraint = pathConstraints[i];
  4077. if (constraint.data.name == constraintName)
  4078. return constraint;
  4079. }
  4080. return null;
  4081. };
  4082. Skeleton.prototype.getBounds = function (offset, size, temp) {
  4083. if (temp === void 0) { temp = new Array(2); }
  4084. if (offset == null)
  4085. throw new Error("offset cannot be null.");
  4086. if (size == null)
  4087. throw new Error("size cannot be null.");
  4088. var drawOrder = this.drawOrder;
  4089. var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;
  4090. for (var i = 0, n = drawOrder.length; i < n; i++) {
  4091. var slot = drawOrder[i];
  4092. if (!slot.bone.active)
  4093. continue;
  4094. var verticesLength = 0;
  4095. var vertices = null;
  4096. var attachment = slot.getAttachment();
  4097. if (attachment instanceof spine.RegionAttachment) {
  4098. verticesLength = 8;
  4099. vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
  4100. attachment.computeWorldVertices(slot.bone, vertices, 0, 2);
  4101. }
  4102. else if (attachment instanceof spine.MeshAttachment) {
  4103. var mesh = attachment;
  4104. verticesLength = mesh.worldVerticesLength;
  4105. vertices = spine.Utils.setArraySize(temp, verticesLength, 0);
  4106. mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
  4107. }
  4108. if (vertices != null) {
  4109. for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
  4110. var x = vertices[ii], y = vertices[ii + 1];
  4111. minX = Math.min(minX, x);
  4112. minY = Math.min(minY, y);
  4113. maxX = Math.max(maxX, x);
  4114. maxY = Math.max(maxY, y);
  4115. }
  4116. }
  4117. }
  4118. offset.set(minX, minY);
  4119. size.set(maxX - minX, maxY - minY);
  4120. };
  4121. Skeleton.prototype.update = function (delta) {
  4122. this.time += delta;
  4123. };
  4124. return Skeleton;
  4125. }());
  4126. spine.Skeleton = Skeleton;
  4127. })(spine || (spine = {}));
  4128. var spine;
  4129. (function (spine) {
  4130. var SkeletonBinary = (function () {
  4131. function SkeletonBinary(attachmentLoader) {
  4132. this.scale = 1;
  4133. this.linkedMeshes = new Array();
  4134. this.attachmentLoader = attachmentLoader;
  4135. }
  4136. SkeletonBinary.prototype.readSkeletonData = function (binary) {
  4137. var scale = this.scale;
  4138. var skeletonData = new spine.SkeletonData();
  4139. skeletonData.name = "";
  4140. var input = new BinaryInput(binary);
  4141. skeletonData.hash = input.readString();
  4142. skeletonData.version = input.readString();
  4143. // if ("3.8.75" == skeletonData.version)
  4144. // throw new Error("Unsupported skeleton data, please export with a newer version of Spine.");
  4145. skeletonData.x = input.readFloat();
  4146. skeletonData.y = input.readFloat();
  4147. skeletonData.width = input.readFloat();
  4148. skeletonData.height = input.readFloat();
  4149. var nonessential = input.readBoolean();
  4150. if (nonessential) {
  4151. skeletonData.fps = input.readFloat();
  4152. skeletonData.imagesPath = input.readString();
  4153. skeletonData.audioPath = input.readString();
  4154. }
  4155. var n = 0;
  4156. n = input.readInt(true);
  4157. for (var i = 0; i < n; i++)
  4158. input.strings.push(input.readString());
  4159. n = input.readInt(true);
  4160. for (var i = 0; i < n; i++) {
  4161. var name_2 = input.readString();
  4162. var parent_2 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
  4163. var data = new spine.BoneData(i, name_2, parent_2);
  4164. data.rotation = input.readFloat();
  4165. data.x = input.readFloat() * scale;
  4166. data.y = input.readFloat() * scale;
  4167. data.scaleX = input.readFloat();
  4168. data.scaleY = input.readFloat();
  4169. data.shearX = input.readFloat();
  4170. data.shearY = input.readFloat();
  4171. data.length = input.readFloat() * scale;
  4172. data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)];
  4173. data.skinRequired = input.readBoolean();
  4174. if (nonessential)
  4175. spine.Color.rgba8888ToColor(data.color, input.readInt32());
  4176. skeletonData.bones.push(data);
  4177. }
  4178. n = input.readInt(true);
  4179. for (var i = 0; i < n; i++) {
  4180. var slotName = input.readString();
  4181. var boneData = skeletonData.bones[input.readInt(true)];
  4182. var data = new spine.SlotData(i, slotName, boneData);
  4183. spine.Color.rgba8888ToColor(data.color, input.readInt32());
  4184. var darkColor = input.readInt32();
  4185. if (darkColor != -1)
  4186. spine.Color.rgb888ToColor(data.darkColor = new spine.Color(), darkColor);
  4187. data.attachmentName = input.readStringRef();
  4188. data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
  4189. skeletonData.slots.push(data);
  4190. }
  4191. n = input.readInt(true);
  4192. for (var i = 0, nn = void 0; i < n; i++) {
  4193. var data = new spine.IkConstraintData(input.readString());
  4194. data.order = input.readInt(true);
  4195. data.skinRequired = input.readBoolean();
  4196. nn = input.readInt(true);
  4197. for (var ii = 0; ii < nn; ii++)
  4198. data.bones.push(skeletonData.bones[input.readInt(true)]);
  4199. data.target = skeletonData.bones[input.readInt(true)];
  4200. data.mix = input.readFloat();
  4201. data.softness = input.readFloat() * scale;
  4202. data.bendDirection = input.readByte();
  4203. data.compress = input.readBoolean();
  4204. data.stretch = input.readBoolean();
  4205. data.uniform = input.readBoolean();
  4206. skeletonData.ikConstraints.push(data);
  4207. }
  4208. n = input.readInt(true);
  4209. for (var i = 0, nn = void 0; i < n; i++) {
  4210. var data = new spine.TransformConstraintData(input.readString());
  4211. data.order = input.readInt(true);
  4212. data.skinRequired = input.readBoolean();
  4213. nn = input.readInt(true);
  4214. for (var ii = 0; ii < nn; ii++)
  4215. data.bones.push(skeletonData.bones[input.readInt(true)]);
  4216. data.target = skeletonData.bones[input.readInt(true)];
  4217. data.local = input.readBoolean();
  4218. data.relative = input.readBoolean();
  4219. data.offsetRotation = input.readFloat();
  4220. data.offsetX = input.readFloat() * scale;
  4221. data.offsetY = input.readFloat() * scale;
  4222. data.offsetScaleX = input.readFloat();
  4223. data.offsetScaleY = input.readFloat();
  4224. data.offsetShearY = input.readFloat();
  4225. data.rotateMix = input.readFloat();
  4226. data.translateMix = input.readFloat();
  4227. data.scaleMix = input.readFloat();
  4228. data.shearMix = input.readFloat();
  4229. skeletonData.transformConstraints.push(data);
  4230. }
  4231. n = input.readInt(true);
  4232. for (var i = 0, nn = void 0; i < n; i++) {
  4233. var data = new spine.PathConstraintData(input.readString());
  4234. data.order = input.readInt(true);
  4235. data.skinRequired = input.readBoolean();
  4236. nn = input.readInt(true);
  4237. for (var ii = 0; ii < nn; ii++)
  4238. data.bones.push(skeletonData.bones[input.readInt(true)]);
  4239. data.target = skeletonData.slots[input.readInt(true)];
  4240. data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)];
  4241. data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
  4242. data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
  4243. data.offsetRotation = input.readFloat();
  4244. data.position = input.readFloat();
  4245. if (data.positionMode == spine.PositionMode.Fixed)
  4246. data.position *= scale;
  4247. data.spacing = input.readFloat();
  4248. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  4249. data.spacing *= scale;
  4250. data.rotateMix = input.readFloat();
  4251. data.translateMix = input.readFloat();
  4252. skeletonData.pathConstraints.push(data);
  4253. }
  4254. var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
  4255. if (defaultSkin != null) {
  4256. skeletonData.defaultSkin = defaultSkin;
  4257. skeletonData.skins.push(defaultSkin);
  4258. }
  4259. {
  4260. var i = skeletonData.skins.length;
  4261. spine.Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
  4262. for (; i < n; i++)
  4263. skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
  4264. }
  4265. n = this.linkedMeshes.length;
  4266. for (var i = 0; i < n; i++) {
  4267. var linkedMesh = this.linkedMeshes[i];
  4268. var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
  4269. if (skin == null)
  4270. throw new Error("Skin not found: " + linkedMesh.skin);
  4271. var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
  4272. if (parent_3 == null)
  4273. throw new Error("Parent mesh not found: " + linkedMesh.parent);
  4274. linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh;
  4275. linkedMesh.mesh.setParentMesh(parent_3);
  4276. linkedMesh.mesh.updateUVs();
  4277. }
  4278. this.linkedMeshes.length = 0;
  4279. n = input.readInt(true);
  4280. for (var i = 0; i < n; i++) {
  4281. var data = new spine.EventData(input.readStringRef());
  4282. data.intValue = input.readInt(false);
  4283. data.floatValue = input.readFloat();
  4284. data.stringValue = input.readString();
  4285. data.audioPath = input.readString();
  4286. if (data.audioPath != null) {
  4287. data.volume = input.readFloat();
  4288. data.balance = input.readFloat();
  4289. }
  4290. skeletonData.events.push(data);
  4291. }
  4292. n = input.readInt(true);
  4293. for (var i = 0; i < n; i++)
  4294. skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
  4295. return skeletonData;
  4296. };
  4297. SkeletonBinary.prototype.readSkin = function (input, skeletonData, defaultSkin, nonessential) {
  4298. var skin = null;
  4299. var slotCount = 0;
  4300. if (defaultSkin) {
  4301. slotCount = input.readInt(true);
  4302. if (slotCount == 0)
  4303. return null;
  4304. skin = new spine.Skin("default");
  4305. }
  4306. else {
  4307. skin = new spine.Skin(input.readStringRef());
  4308. skin.bones.length = input.readInt(true);
  4309. for (var i = 0, n = skin.bones.length; i < n; i++)
  4310. skin.bones[i] = skeletonData.bones[input.readInt(true)];
  4311. for (var i = 0, n = input.readInt(true); i < n; i++)
  4312. skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]);
  4313. for (var i = 0, n = input.readInt(true); i < n; i++)
  4314. skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]);
  4315. for (var i = 0, n = input.readInt(true); i < n; i++)
  4316. skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]);
  4317. slotCount = input.readInt(true);
  4318. }
  4319. for (var i = 0; i < slotCount; i++) {
  4320. var slotIndex = input.readInt(true);
  4321. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4322. var name_3 = input.readStringRef();
  4323. var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential);
  4324. if (attachment != null)
  4325. skin.setAttachment(slotIndex, name_3, attachment);
  4326. }
  4327. }
  4328. return skin;
  4329. };
  4330. SkeletonBinary.prototype.readAttachment = function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) {
  4331. var scale = this.scale;
  4332. var name = input.readStringRef();
  4333. if (name == null)
  4334. name = attachmentName;
  4335. var typeIndex = input.readByte();
  4336. var type = SkeletonBinary.AttachmentTypeValues[typeIndex];
  4337. switch (type) {
  4338. case spine.AttachmentType.Region: {
  4339. var path = input.readStringRef();
  4340. var rotation = input.readFloat();
  4341. var x = input.readFloat();
  4342. var y = input.readFloat();
  4343. var scaleX = input.readFloat();
  4344. var scaleY = input.readFloat();
  4345. var width = input.readFloat();
  4346. var height = input.readFloat();
  4347. var color = input.readInt32();
  4348. if (path == null)
  4349. path = name;
  4350. var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
  4351. if (region == null)
  4352. return null;
  4353. region.path = path;
  4354. region.x = x * scale;
  4355. region.y = y * scale;
  4356. region.scaleX = scaleX;
  4357. region.scaleY = scaleY;
  4358. region.rotation = rotation;
  4359. region.width = width * scale;
  4360. region.height = height * scale;
  4361. spine.Color.rgba8888ToColor(region.color, color);
  4362. region.updateOffset();
  4363. return region;
  4364. }
  4365. case spine.AttachmentType.BoundingBox: {
  4366. var vertexCount = input.readInt(true);
  4367. var vertices = this.readVertices(input, vertexCount);
  4368. var color = nonessential ? input.readInt32() : 0;
  4369. var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
  4370. if (box == null)
  4371. return null;
  4372. box.worldVerticesLength = vertexCount << 1;
  4373. box.vertices = vertices.vertices;
  4374. box.bones = vertices.bones;
  4375. if (nonessential)
  4376. spine.Color.rgba8888ToColor(box.color, color);
  4377. return box;
  4378. }
  4379. case spine.AttachmentType.Mesh: {
  4380. var path = input.readStringRef();
  4381. var color = input.readInt32();
  4382. var vertexCount = input.readInt(true);
  4383. var uvs = this.readFloatArray(input, vertexCount << 1, 1);
  4384. var triangles = this.readShortArray(input);
  4385. var vertices = this.readVertices(input, vertexCount);
  4386. var hullLength = input.readInt(true);
  4387. var edges = null;
  4388. var width = 0, height = 0;
  4389. if (nonessential) {
  4390. edges = this.readShortArray(input);
  4391. width = input.readFloat();
  4392. height = input.readFloat();
  4393. }
  4394. if (path == null)
  4395. path = name;
  4396. var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
  4397. if (mesh == null)
  4398. return null;
  4399. mesh.path = path;
  4400. spine.Color.rgba8888ToColor(mesh.color, color);
  4401. mesh.bones = vertices.bones;
  4402. mesh.vertices = vertices.vertices;
  4403. mesh.worldVerticesLength = vertexCount << 1;
  4404. mesh.triangles = triangles;
  4405. mesh.regionUVs = uvs;
  4406. mesh.updateUVs();
  4407. mesh.hullLength = hullLength << 1;
  4408. if (nonessential) {
  4409. mesh.edges = edges;
  4410. mesh.width = width * scale;
  4411. mesh.height = height * scale;
  4412. }
  4413. return mesh;
  4414. }
  4415. case spine.AttachmentType.LinkedMesh: {
  4416. var path = input.readStringRef();
  4417. var color = input.readInt32();
  4418. var skinName = input.readStringRef();
  4419. var parent_4 = input.readStringRef();
  4420. var inheritDeform = input.readBoolean();
  4421. var width = 0, height = 0;
  4422. if (nonessential) {
  4423. width = input.readFloat();
  4424. height = input.readFloat();
  4425. }
  4426. if (path == null)
  4427. path = name;
  4428. var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
  4429. if (mesh == null)
  4430. return null;
  4431. mesh.path = path;
  4432. spine.Color.rgba8888ToColor(mesh.color, color);
  4433. if (nonessential) {
  4434. mesh.width = width * scale;
  4435. mesh.height = height * scale;
  4436. }
  4437. this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform));
  4438. return mesh;
  4439. }
  4440. case spine.AttachmentType.Path: {
  4441. var closed_1 = input.readBoolean();
  4442. var constantSpeed = input.readBoolean();
  4443. var vertexCount = input.readInt(true);
  4444. var vertices = this.readVertices(input, vertexCount);
  4445. var lengths = spine.Utils.newArray(vertexCount / 3, 0);
  4446. for (var i = 0, n = lengths.length; i < n; i++)
  4447. lengths[i] = input.readFloat() * scale;
  4448. var color = nonessential ? input.readInt32() : 0;
  4449. var path = this.attachmentLoader.newPathAttachment(skin, name);
  4450. if (path == null)
  4451. return null;
  4452. path.closed = closed_1;
  4453. path.constantSpeed = constantSpeed;
  4454. path.worldVerticesLength = vertexCount << 1;
  4455. path.vertices = vertices.vertices;
  4456. path.bones = vertices.bones;
  4457. path.lengths = lengths;
  4458. if (nonessential)
  4459. spine.Color.rgba8888ToColor(path.color, color);
  4460. return path;
  4461. }
  4462. case spine.AttachmentType.Point: {
  4463. var rotation = input.readFloat();
  4464. var x = input.readFloat();
  4465. var y = input.readFloat();
  4466. var color = nonessential ? input.readInt32() : 0;
  4467. var point = this.attachmentLoader.newPointAttachment(skin, name);
  4468. if (point == null)
  4469. return null;
  4470. point.x = x * scale;
  4471. point.y = y * scale;
  4472. point.rotation = rotation;
  4473. if (nonessential)
  4474. spine.Color.rgba8888ToColor(point.color, color);
  4475. return point;
  4476. }
  4477. case spine.AttachmentType.Clipping: {
  4478. var endSlotIndex = input.readInt(true);
  4479. var vertexCount = input.readInt(true);
  4480. var vertices = this.readVertices(input, vertexCount);
  4481. var color = nonessential ? input.readInt32() : 0;
  4482. var clip = this.attachmentLoader.newClippingAttachment(skin, name);
  4483. if (clip == null)
  4484. return null;
  4485. clip.endSlot = skeletonData.slots[endSlotIndex];
  4486. clip.worldVerticesLength = vertexCount << 1;
  4487. clip.vertices = vertices.vertices;
  4488. clip.bones = vertices.bones;
  4489. if (nonessential)
  4490. spine.Color.rgba8888ToColor(clip.color, color);
  4491. return clip;
  4492. }
  4493. }
  4494. return null;
  4495. };
  4496. SkeletonBinary.prototype.readVertices = function (input, vertexCount) {
  4497. var verticesLength = vertexCount << 1;
  4498. var vertices = new Vertices();
  4499. var scale = this.scale;
  4500. if (!input.readBoolean()) {
  4501. vertices.vertices = this.readFloatArray(input, verticesLength, scale);
  4502. return vertices;
  4503. }
  4504. var weights = new Array();
  4505. var bonesArray = new Array();
  4506. for (var i = 0; i < vertexCount; i++) {
  4507. var boneCount = input.readInt(true);
  4508. bonesArray.push(boneCount);
  4509. for (var ii = 0; ii < boneCount; ii++) {
  4510. bonesArray.push(input.readInt(true));
  4511. weights.push(input.readFloat() * scale);
  4512. weights.push(input.readFloat() * scale);
  4513. weights.push(input.readFloat());
  4514. }
  4515. }
  4516. vertices.vertices = spine.Utils.toFloatArray(weights);
  4517. vertices.bones = bonesArray;
  4518. return vertices;
  4519. };
  4520. SkeletonBinary.prototype.readFloatArray = function (input, n, scale) {
  4521. var array = new Array(n);
  4522. if (scale == 1) {
  4523. for (var i = 0; i < n; i++)
  4524. array[i] = input.readFloat();
  4525. }
  4526. else {
  4527. for (var i = 0; i < n; i++)
  4528. array[i] = input.readFloat() * scale;
  4529. }
  4530. return array;
  4531. };
  4532. SkeletonBinary.prototype.readShortArray = function (input) {
  4533. var n = input.readInt(true);
  4534. var array = new Array(n);
  4535. for (var i = 0; i < n; i++)
  4536. array[i] = input.readShort();
  4537. return array;
  4538. };
  4539. SkeletonBinary.prototype.readAnimation = function (input, name, skeletonData) {
  4540. var timelines = new Array();
  4541. var scale = this.scale;
  4542. var duration = 0;
  4543. var tempColor1 = new spine.Color();
  4544. var tempColor2 = new spine.Color();
  4545. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4546. var slotIndex = input.readInt(true);
  4547. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4548. var timelineType = input.readByte();
  4549. var frameCount = input.readInt(true);
  4550. switch (timelineType) {
  4551. case SkeletonBinary.SLOT_ATTACHMENT: {
  4552. var timeline = new spine.AttachmentTimeline(frameCount);
  4553. timeline.slotIndex = slotIndex;
  4554. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++)
  4555. timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef());
  4556. timelines.push(timeline);
  4557. duration = Math.max(duration, timeline.frames[frameCount - 1]);
  4558. break;
  4559. }
  4560. case SkeletonBinary.SLOT_COLOR: {
  4561. var timeline = new spine.ColorTimeline(frameCount);
  4562. timeline.slotIndex = slotIndex;
  4563. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4564. var time = input.readFloat();
  4565. spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
  4566. timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
  4567. if (frameIndex < frameCount - 1)
  4568. this.readCurve(input, frameIndex, timeline);
  4569. }
  4570. timelines.push(timeline);
  4571. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.ColorTimeline.ENTRIES]);
  4572. break;
  4573. }
  4574. case SkeletonBinary.SLOT_TWO_COLOR: {
  4575. var timeline = new spine.TwoColorTimeline(frameCount);
  4576. timeline.slotIndex = slotIndex;
  4577. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4578. var time = input.readFloat();
  4579. spine.Color.rgba8888ToColor(tempColor1, input.readInt32());
  4580. spine.Color.rgb888ToColor(tempColor2, input.readInt32());
  4581. timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
  4582. if (frameIndex < frameCount - 1)
  4583. this.readCurve(input, frameIndex, timeline);
  4584. }
  4585. timelines.push(timeline);
  4586. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TwoColorTimeline.ENTRIES]);
  4587. break;
  4588. }
  4589. }
  4590. }
  4591. }
  4592. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4593. var boneIndex = input.readInt(true);
  4594. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4595. var timelineType = input.readByte();
  4596. var frameCount = input.readInt(true);
  4597. switch (timelineType) {
  4598. case SkeletonBinary.BONE_ROTATE: {
  4599. var timeline = new spine.RotateTimeline(frameCount);
  4600. timeline.boneIndex = boneIndex;
  4601. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4602. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
  4603. if (frameIndex < frameCount - 1)
  4604. this.readCurve(input, frameIndex, timeline);
  4605. }
  4606. timelines.push(timeline);
  4607. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.RotateTimeline.ENTRIES]);
  4608. break;
  4609. }
  4610. case SkeletonBinary.BONE_TRANSLATE:
  4611. case SkeletonBinary.BONE_SCALE:
  4612. case SkeletonBinary.BONE_SHEAR: {
  4613. var timeline = void 0;
  4614. var timelineScale = 1;
  4615. if (timelineType == SkeletonBinary.BONE_SCALE)
  4616. timeline = new spine.ScaleTimeline(frameCount);
  4617. else if (timelineType == SkeletonBinary.BONE_SHEAR)
  4618. timeline = new spine.ShearTimeline(frameCount);
  4619. else {
  4620. timeline = new spine.TranslateTimeline(frameCount);
  4621. timelineScale = scale;
  4622. }
  4623. timeline.boneIndex = boneIndex;
  4624. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4625. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
  4626. if (frameIndex < frameCount - 1)
  4627. this.readCurve(input, frameIndex, timeline);
  4628. }
  4629. timelines.push(timeline);
  4630. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TranslateTimeline.ENTRIES]);
  4631. break;
  4632. }
  4633. }
  4634. }
  4635. }
  4636. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4637. var index = input.readInt(true);
  4638. var frameCount = input.readInt(true);
  4639. var timeline = new spine.IkConstraintTimeline(frameCount);
  4640. timeline.ikConstraintIndex = index;
  4641. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4642. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat() * scale, input.readByte(), input.readBoolean(), input.readBoolean());
  4643. if (frameIndex < frameCount - 1)
  4644. this.readCurve(input, frameIndex, timeline);
  4645. }
  4646. timelines.push(timeline);
  4647. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.IkConstraintTimeline.ENTRIES]);
  4648. }
  4649. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4650. var index = input.readInt(true);
  4651. var frameCount = input.readInt(true);
  4652. var timeline = new spine.TransformConstraintTimeline(frameCount);
  4653. timeline.transformConstraintIndex = index;
  4654. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4655. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
  4656. if (frameIndex < frameCount - 1)
  4657. this.readCurve(input, frameIndex, timeline);
  4658. }
  4659. timelines.push(timeline);
  4660. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.TransformConstraintTimeline.ENTRIES]);
  4661. }
  4662. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4663. var index = input.readInt(true);
  4664. var data = skeletonData.pathConstraints[index];
  4665. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4666. var timelineType = input.readByte();
  4667. var frameCount = input.readInt(true);
  4668. switch (timelineType) {
  4669. case SkeletonBinary.PATH_POSITION:
  4670. case SkeletonBinary.PATH_SPACING: {
  4671. var timeline = void 0;
  4672. var timelineScale = 1;
  4673. if (timelineType == SkeletonBinary.PATH_SPACING) {
  4674. timeline = new spine.PathConstraintSpacingTimeline(frameCount);
  4675. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  4676. timelineScale = scale;
  4677. }
  4678. else {
  4679. timeline = new spine.PathConstraintPositionTimeline(frameCount);
  4680. if (data.positionMode == spine.PositionMode.Fixed)
  4681. timelineScale = scale;
  4682. }
  4683. timeline.pathConstraintIndex = index;
  4684. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4685. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
  4686. if (frameIndex < frameCount - 1)
  4687. this.readCurve(input, frameIndex, timeline);
  4688. }
  4689. timelines.push(timeline);
  4690. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
  4691. break;
  4692. }
  4693. case SkeletonBinary.PATH_MIX: {
  4694. var timeline = new spine.PathConstraintMixTimeline(frameCount);
  4695. timeline.pathConstraintIndex = index;
  4696. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4697. timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
  4698. if (frameIndex < frameCount - 1)
  4699. this.readCurve(input, frameIndex, timeline);
  4700. }
  4701. timelines.push(timeline);
  4702. duration = Math.max(duration, timeline.frames[(frameCount - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
  4703. break;
  4704. }
  4705. }
  4706. }
  4707. }
  4708. for (var i = 0, n = input.readInt(true); i < n; i++) {
  4709. var skin = skeletonData.skins[input.readInt(true)];
  4710. for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
  4711. var slotIndex = input.readInt(true);
  4712. for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
  4713. var attachment = skin.getAttachment(slotIndex, input.readStringRef());
  4714. var weighted = attachment.bones != null;
  4715. var vertices = attachment.vertices;
  4716. var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
  4717. var frameCount = input.readInt(true);
  4718. var timeline = new spine.DeformTimeline(frameCount);
  4719. timeline.slotIndex = slotIndex;
  4720. timeline.attachment = attachment;
  4721. for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
  4722. var time = input.readFloat();
  4723. var deform = void 0;
  4724. var end = input.readInt(true);
  4725. if (end == 0)
  4726. deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
  4727. else {
  4728. deform = spine.Utils.newFloatArray(deformLength);
  4729. var start = input.readInt(true);
  4730. end += start;
  4731. if (scale == 1) {
  4732. for (var v = start; v < end; v++)
  4733. deform[v] = input.readFloat();
  4734. }
  4735. else {
  4736. for (var v = start; v < end; v++)
  4737. deform[v] = input.readFloat() * scale;
  4738. }
  4739. if (!weighted) {
  4740. for (var v = 0, vn = deform.length; v < vn; v++)
  4741. deform[v] += vertices[v];
  4742. }
  4743. }
  4744. timeline.setFrame(frameIndex, time, deform);
  4745. if (frameIndex < frameCount - 1)
  4746. this.readCurve(input, frameIndex, timeline);
  4747. }
  4748. timelines.push(timeline);
  4749. duration = Math.max(duration, timeline.frames[frameCount - 1]);
  4750. }
  4751. }
  4752. }
  4753. var drawOrderCount = input.readInt(true);
  4754. if (drawOrderCount > 0) {
  4755. var timeline = new spine.DrawOrderTimeline(drawOrderCount);
  4756. var slotCount = skeletonData.slots.length;
  4757. for (var i = 0; i < drawOrderCount; i++) {
  4758. var time = input.readFloat();
  4759. var offsetCount = input.readInt(true);
  4760. var drawOrder = spine.Utils.newArray(slotCount, 0);
  4761. for (var ii = slotCount - 1; ii >= 0; ii--)
  4762. drawOrder[ii] = -1;
  4763. var unchanged = spine.Utils.newArray(slotCount - offsetCount, 0);
  4764. var originalIndex = 0, unchangedIndex = 0;
  4765. for (var ii = 0; ii < offsetCount; ii++) {
  4766. var slotIndex = input.readInt(true);
  4767. while (originalIndex != slotIndex)
  4768. unchanged[unchangedIndex++] = originalIndex++;
  4769. drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
  4770. }
  4771. while (originalIndex < slotCount)
  4772. unchanged[unchangedIndex++] = originalIndex++;
  4773. for (var ii = slotCount - 1; ii >= 0; ii--)
  4774. if (drawOrder[ii] == -1)
  4775. drawOrder[ii] = unchanged[--unchangedIndex];
  4776. timeline.setFrame(i, time, drawOrder);
  4777. }
  4778. timelines.push(timeline);
  4779. duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
  4780. }
  4781. var eventCount = input.readInt(true);
  4782. if (eventCount > 0) {
  4783. var timeline = new spine.EventTimeline(eventCount);
  4784. for (var i = 0; i < eventCount; i++) {
  4785. var time = input.readFloat();
  4786. var eventData = skeletonData.events[input.readInt(true)];
  4787. var event_4 = new spine.Event(time, eventData);
  4788. event_4.intValue = input.readInt(false);
  4789. event_4.floatValue = input.readFloat();
  4790. event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue;
  4791. if (event_4.data.audioPath != null) {
  4792. event_4.volume = input.readFloat();
  4793. event_4.balance = input.readFloat();
  4794. }
  4795. timeline.setFrame(i, event_4);
  4796. }
  4797. timelines.push(timeline);
  4798. duration = Math.max(duration, timeline.frames[eventCount - 1]);
  4799. }
  4800. return new spine.Animation(name, timelines, duration);
  4801. };
  4802. SkeletonBinary.prototype.readCurve = function (input, frameIndex, timeline) {
  4803. switch (input.readByte()) {
  4804. case SkeletonBinary.CURVE_STEPPED:
  4805. timeline.setStepped(frameIndex);
  4806. break;
  4807. case SkeletonBinary.CURVE_BEZIER:
  4808. this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
  4809. break;
  4810. }
  4811. };
  4812. SkeletonBinary.prototype.setCurve = function (timeline, frameIndex, cx1, cy1, cx2, cy2) {
  4813. timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2);
  4814. };
  4815. SkeletonBinary.AttachmentTypeValues = [0, 1, 2, 3, 4, 5, 6];
  4816. SkeletonBinary.TransformModeValues = [spine.TransformMode.Normal, spine.TransformMode.OnlyTranslation, spine.TransformMode.NoRotationOrReflection, spine.TransformMode.NoScale, spine.TransformMode.NoScaleOrReflection];
  4817. SkeletonBinary.PositionModeValues = [spine.PositionMode.Fixed, spine.PositionMode.Percent];
  4818. SkeletonBinary.SpacingModeValues = [spine.SpacingMode.Length, spine.SpacingMode.Fixed, spine.SpacingMode.Percent];
  4819. SkeletonBinary.RotateModeValues = [spine.RotateMode.Tangent, spine.RotateMode.Chain, spine.RotateMode.ChainScale];
  4820. SkeletonBinary.BlendModeValues = [spine.BlendMode.Normal, spine.BlendMode.Additive, spine.BlendMode.Multiply, spine.BlendMode.Screen];
  4821. SkeletonBinary.BONE_ROTATE = 0;
  4822. SkeletonBinary.BONE_TRANSLATE = 1;
  4823. SkeletonBinary.BONE_SCALE = 2;
  4824. SkeletonBinary.BONE_SHEAR = 3;
  4825. SkeletonBinary.SLOT_ATTACHMENT = 0;
  4826. SkeletonBinary.SLOT_COLOR = 1;
  4827. SkeletonBinary.SLOT_TWO_COLOR = 2;
  4828. SkeletonBinary.PATH_POSITION = 0;
  4829. SkeletonBinary.PATH_SPACING = 1;
  4830. SkeletonBinary.PATH_MIX = 2;
  4831. SkeletonBinary.CURVE_LINEAR = 0;
  4832. SkeletonBinary.CURVE_STEPPED = 1;
  4833. SkeletonBinary.CURVE_BEZIER = 2;
  4834. return SkeletonBinary;
  4835. }());
  4836. spine.SkeletonBinary = SkeletonBinary;
  4837. var BinaryInput = (function () {
  4838. function BinaryInput(data, strings, index, buffer) {
  4839. if (strings === void 0) { strings = new Array(); }
  4840. if (index === void 0) { index = 0; }
  4841. if (buffer === void 0) { buffer = new DataView(data.buffer); }
  4842. this.strings = strings;
  4843. this.index = index;
  4844. this.buffer = buffer;
  4845. }
  4846. BinaryInput.prototype.readByte = function () {
  4847. return this.buffer.getInt8(this.index++);
  4848. };
  4849. BinaryInput.prototype.readShort = function () {
  4850. var value = this.buffer.getInt16(this.index);
  4851. this.index += 2;
  4852. return value;
  4853. };
  4854. BinaryInput.prototype.readInt32 = function () {
  4855. var value = this.buffer.getInt32(this.index);
  4856. this.index += 4;
  4857. return value;
  4858. };
  4859. BinaryInput.prototype.readInt = function (optimizePositive) {
  4860. var b = this.readByte();
  4861. var result = b & 0x7F;
  4862. if ((b & 0x80) != 0) {
  4863. b = this.readByte();
  4864. result |= (b & 0x7F) << 7;
  4865. if ((b & 0x80) != 0) {
  4866. b = this.readByte();
  4867. result |= (b & 0x7F) << 14;
  4868. if ((b & 0x80) != 0) {
  4869. b = this.readByte();
  4870. result |= (b & 0x7F) << 21;
  4871. if ((b & 0x80) != 0) {
  4872. b = this.readByte();
  4873. result |= (b & 0x7F) << 28;
  4874. }
  4875. }
  4876. }
  4877. }
  4878. return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
  4879. };
  4880. BinaryInput.prototype.readStringRef = function () {
  4881. var index = this.readInt(true);
  4882. return index == 0 ? null : this.strings[index - 1];
  4883. };
  4884. BinaryInput.prototype.readString = function () {
  4885. var byteCount = this.readInt(true);
  4886. switch (byteCount) {
  4887. case 0:
  4888. return null;
  4889. case 1:
  4890. return "";
  4891. }
  4892. byteCount--;
  4893. var chars = "";
  4894. var charCount = 0;
  4895. for (var i = 0; i < byteCount;) {
  4896. var b = this.readByte();
  4897. switch (b >> 4) {
  4898. case 12:
  4899. case 13:
  4900. chars += String.fromCharCode(((b & 0x1F) << 6 | this.readByte() & 0x3F));
  4901. i += 2;
  4902. break;
  4903. case 14:
  4904. chars += String.fromCharCode(((b & 0x0F) << 12 | (this.readByte() & 0x3F) << 6 | this.readByte() & 0x3F));
  4905. i += 3;
  4906. break;
  4907. default:
  4908. chars += String.fromCharCode(b);
  4909. i++;
  4910. }
  4911. }
  4912. return chars;
  4913. };
  4914. BinaryInput.prototype.readFloat = function () {
  4915. var value = this.buffer.getFloat32(this.index);
  4916. this.index += 4;
  4917. return value;
  4918. };
  4919. BinaryInput.prototype.readBoolean = function () {
  4920. return this.readByte() != 0;
  4921. };
  4922. return BinaryInput;
  4923. }());
  4924. var LinkedMesh = (function () {
  4925. function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
  4926. this.mesh = mesh;
  4927. this.skin = skin;
  4928. this.slotIndex = slotIndex;
  4929. this.parent = parent;
  4930. this.inheritDeform = inheritDeform;
  4931. }
  4932. return LinkedMesh;
  4933. }());
  4934. var Vertices = (function () {
  4935. function Vertices(bones, vertices) {
  4936. if (bones === void 0) { bones = null; }
  4937. if (vertices === void 0) { vertices = null; }
  4938. this.bones = bones;
  4939. this.vertices = vertices;
  4940. }
  4941. return Vertices;
  4942. }());
  4943. })(spine || (spine = {}));
  4944. var spine;
  4945. (function (spine) {
  4946. var SkeletonBounds = (function () {
  4947. function SkeletonBounds() {
  4948. this.minX = 0;
  4949. this.minY = 0;
  4950. this.maxX = 0;
  4951. this.maxY = 0;
  4952. this.boundingBoxes = new Array();
  4953. this.polygons = new Array();
  4954. this.polygonPool = new spine.Pool(function () {
  4955. return spine.Utils.newFloatArray(16);
  4956. });
  4957. }
  4958. SkeletonBounds.prototype.update = function (skeleton, updateAabb) {
  4959. if (skeleton == null)
  4960. throw new Error("skeleton cannot be null.");
  4961. var boundingBoxes = this.boundingBoxes;
  4962. var polygons = this.polygons;
  4963. var polygonPool = this.polygonPool;
  4964. var slots = skeleton.slots;
  4965. var slotCount = slots.length;
  4966. boundingBoxes.length = 0;
  4967. polygonPool.freeAll(polygons);
  4968. polygons.length = 0;
  4969. for (var i = 0; i < slotCount; i++) {
  4970. var slot = slots[i];
  4971. if (!slot.bone.active)
  4972. continue;
  4973. var attachment = slot.getAttachment();
  4974. if (attachment instanceof spine.BoundingBoxAttachment) {
  4975. var boundingBox = attachment;
  4976. boundingBoxes.push(boundingBox);
  4977. var polygon = polygonPool.obtain();
  4978. if (polygon.length != boundingBox.worldVerticesLength) {
  4979. polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength);
  4980. }
  4981. polygons.push(polygon);
  4982. boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2);
  4983. }
  4984. }
  4985. if (updateAabb) {
  4986. this.aabbCompute();
  4987. }
  4988. else {
  4989. this.minX = Number.POSITIVE_INFINITY;
  4990. this.minY = Number.POSITIVE_INFINITY;
  4991. this.maxX = Number.NEGATIVE_INFINITY;
  4992. this.maxY = Number.NEGATIVE_INFINITY;
  4993. }
  4994. };
  4995. SkeletonBounds.prototype.aabbCompute = function () {
  4996. var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;
  4997. var polygons = this.polygons;
  4998. for (var i = 0, n = polygons.length; i < n; i++) {
  4999. var polygon = polygons[i];
  5000. var vertices = polygon;
  5001. for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) {
  5002. var x = vertices[ii];
  5003. var y = vertices[ii + 1];
  5004. minX = Math.min(minX, x);
  5005. minY = Math.min(minY, y);
  5006. maxX = Math.max(maxX, x);
  5007. maxY = Math.max(maxY, y);
  5008. }
  5009. }
  5010. this.minX = minX;
  5011. this.minY = minY;
  5012. this.maxX = maxX;
  5013. this.maxY = maxY;
  5014. };
  5015. SkeletonBounds.prototype.aabbContainsPoint = function (x, y) {
  5016. return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY;
  5017. };
  5018. SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) {
  5019. var minX = this.minX;
  5020. var minY = this.minY;
  5021. var maxX = this.maxX;
  5022. var maxY = this.maxY;
  5023. if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY))
  5024. return false;
  5025. var m = (y2 - y1) / (x2 - x1);
  5026. var y = m * (minX - x1) + y1;
  5027. if (y > minY && y < maxY)
  5028. return true;
  5029. y = m * (maxX - x1) + y1;
  5030. if (y > minY && y < maxY)
  5031. return true;
  5032. var x = (minY - y1) / m + x1;
  5033. if (x > minX && x < maxX)
  5034. return true;
  5035. x = (maxY - y1) / m + x1;
  5036. if (x > minX && x < maxX)
  5037. return true;
  5038. return false;
  5039. };
  5040. SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) {
  5041. return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY;
  5042. };
  5043. SkeletonBounds.prototype.containsPoint = function (x, y) {
  5044. var polygons = this.polygons;
  5045. for (var i = 0, n = polygons.length; i < n; i++)
  5046. if (this.containsPointPolygon(polygons[i], x, y))
  5047. return this.boundingBoxes[i];
  5048. return null;
  5049. };
  5050. SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) {
  5051. var vertices = polygon;
  5052. var nn = polygon.length;
  5053. var prevIndex = nn - 2;
  5054. var inside = false;
  5055. for (var ii = 0; ii < nn; ii += 2) {
  5056. var vertexY = vertices[ii + 1];
  5057. var prevY = vertices[prevIndex + 1];
  5058. if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) {
  5059. var vertexX = vertices[ii];
  5060. if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x)
  5061. inside = !inside;
  5062. }
  5063. prevIndex = ii;
  5064. }
  5065. return inside;
  5066. };
  5067. SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) {
  5068. var polygons = this.polygons;
  5069. for (var i = 0, n = polygons.length; i < n; i++)
  5070. if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2))
  5071. return this.boundingBoxes[i];
  5072. return null;
  5073. };
  5074. SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) {
  5075. var vertices = polygon;
  5076. var nn = polygon.length;
  5077. var width12 = x1 - x2, height12 = y1 - y2;
  5078. var det1 = x1 * y2 - y1 * x2;
  5079. var x3 = vertices[nn - 2], y3 = vertices[nn - 1];
  5080. for (var ii = 0; ii < nn; ii += 2) {
  5081. var x4 = vertices[ii], y4 = vertices[ii + 1];
  5082. var det2 = x3 * y4 - y3 * x4;
  5083. var width34 = x3 - x4, height34 = y3 - y4;
  5084. var det3 = width12 * height34 - height12 * width34;
  5085. var x = (det1 * width34 - width12 * det2) / det3;
  5086. if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {
  5087. var y = (det1 * height34 - height12 * det2) / det3;
  5088. if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1)))
  5089. return true;
  5090. }
  5091. x3 = x4;
  5092. y3 = y4;
  5093. }
  5094. return false;
  5095. };
  5096. SkeletonBounds.prototype.getPolygon = function (boundingBox) {
  5097. if (boundingBox == null)
  5098. throw new Error("boundingBox cannot be null.");
  5099. var index = this.boundingBoxes.indexOf(boundingBox);
  5100. return index == -1 ? null : this.polygons[index];
  5101. };
  5102. SkeletonBounds.prototype.getWidth = function () {
  5103. return this.maxX - this.minX;
  5104. };
  5105. SkeletonBounds.prototype.getHeight = function () {
  5106. return this.maxY - this.minY;
  5107. };
  5108. return SkeletonBounds;
  5109. }());
  5110. spine.SkeletonBounds = SkeletonBounds;
  5111. })(spine || (spine = {}));
  5112. var spine;
  5113. (function (spine) {
  5114. var SkeletonClipping = (function () {
  5115. function SkeletonClipping() {
  5116. this.triangulator = new spine.Triangulator();
  5117. this.clippingPolygon = new Array();
  5118. this.clipOutput = new Array();
  5119. this.clippedVertices = new Array();
  5120. this.clippedTriangles = new Array();
  5121. this.scratch = new Array();
  5122. }
  5123. SkeletonClipping.prototype.clipStart = function (slot, clip) {
  5124. if (this.clipAttachment != null)
  5125. return 0;
  5126. this.clipAttachment = clip;
  5127. var n = clip.worldVerticesLength;
  5128. var vertices = spine.Utils.setArraySize(this.clippingPolygon, n);
  5129. clip.computeWorldVertices(slot, 0, n, vertices, 0, 2);
  5130. var clippingPolygon = this.clippingPolygon;
  5131. SkeletonClipping.makeClockwise(clippingPolygon);
  5132. var clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon));
  5133. for (var i = 0, n_2 = clippingPolygons.length; i < n_2; i++) {
  5134. var polygon = clippingPolygons[i];
  5135. SkeletonClipping.makeClockwise(polygon);
  5136. polygon.push(polygon[0]);
  5137. polygon.push(polygon[1]);
  5138. }
  5139. return clippingPolygons.length;
  5140. };
  5141. SkeletonClipping.prototype.clipEndWithSlot = function (slot) {
  5142. if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data)
  5143. this.clipEnd();
  5144. };
  5145. SkeletonClipping.prototype.clipEnd = function () {
  5146. if (this.clipAttachment == null)
  5147. return;
  5148. this.clipAttachment = null;
  5149. this.clippingPolygons = null;
  5150. this.clippedVertices.length = 0;
  5151. this.clippedTriangles.length = 0;
  5152. this.clippingPolygon.length = 0;
  5153. };
  5154. SkeletonClipping.prototype.isClipping = function () {
  5155. return this.clipAttachment != null;
  5156. };
  5157. SkeletonClipping.prototype.clipTriangles = function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) {
  5158. var clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
  5159. var clippedTriangles = this.clippedTriangles;
  5160. var polygons = this.clippingPolygons;
  5161. var polygonsCount = this.clippingPolygons.length;
  5162. var vertexSize = twoColor ? 12 : 8;
  5163. var index = 0;
  5164. clippedVertices.length = 0;
  5165. clippedTriangles.length = 0;
  5166. outer: for (var i = 0; i < trianglesLength; i += 3) {
  5167. var vertexOffset = triangles[i] << 1;
  5168. var x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
  5169. var u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
  5170. vertexOffset = triangles[i + 1] << 1;
  5171. var x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
  5172. var u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];
  5173. vertexOffset = triangles[i + 2] << 1;
  5174. var x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
  5175. var u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
  5176. for (var p = 0; p < polygonsCount; p++) {
  5177. var s = clippedVertices.length;
  5178. if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {
  5179. var clipOutputLength = clipOutput.length;
  5180. if (clipOutputLength == 0)
  5181. continue;
  5182. var d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
  5183. var d = 1 / (d0 * d2 + d1 * (y1 - y3));
  5184. var clipOutputCount = clipOutputLength >> 1;
  5185. var clipOutputItems = this.clipOutput;
  5186. var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize);
  5187. for (var ii = 0; ii < clipOutputLength; ii += 2) {
  5188. var x = clipOutputItems[ii], y = clipOutputItems[ii + 1];
  5189. clippedVerticesItems[s] = x;
  5190. clippedVerticesItems[s + 1] = y;
  5191. clippedVerticesItems[s + 2] = light.r;
  5192. clippedVerticesItems[s + 3] = light.g;
  5193. clippedVerticesItems[s + 4] = light.b;
  5194. clippedVerticesItems[s + 5] = light.a;
  5195. var c0 = x - x3, c1 = y - y3;
  5196. var a = (d0 * c0 + d1 * c1) * d;
  5197. var b = (d4 * c0 + d2 * c1) * d;
  5198. var c = 1 - a - b;
  5199. clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c;
  5200. clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
  5201. if (twoColor) {
  5202. clippedVerticesItems[s + 8] = dark.r;
  5203. clippedVerticesItems[s + 9] = dark.g;
  5204. clippedVerticesItems[s + 10] = dark.b;
  5205. clippedVerticesItems[s + 11] = dark.a;
  5206. }
  5207. s += vertexSize;
  5208. }
  5209. s = clippedTriangles.length;
  5210. var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2));
  5211. clipOutputCount--;
  5212. for (var ii = 1; ii < clipOutputCount; ii++) {
  5213. clippedTrianglesItems[s] = index;
  5214. clippedTrianglesItems[s + 1] = (index + ii);
  5215. clippedTrianglesItems[s + 2] = (index + ii + 1);
  5216. s += 3;
  5217. }
  5218. index += clipOutputCount + 1;
  5219. }
  5220. else {
  5221. var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + 3 * vertexSize);
  5222. clippedVerticesItems[s] = x1;
  5223. clippedVerticesItems[s + 1] = y1;
  5224. clippedVerticesItems[s + 2] = light.r;
  5225. clippedVerticesItems[s + 3] = light.g;
  5226. clippedVerticesItems[s + 4] = light.b;
  5227. clippedVerticesItems[s + 5] = light.a;
  5228. if (!twoColor) {
  5229. clippedVerticesItems[s + 6] = u1;
  5230. clippedVerticesItems[s + 7] = v1;
  5231. clippedVerticesItems[s + 8] = x2;
  5232. clippedVerticesItems[s + 9] = y2;
  5233. clippedVerticesItems[s + 10] = light.r;
  5234. clippedVerticesItems[s + 11] = light.g;
  5235. clippedVerticesItems[s + 12] = light.b;
  5236. clippedVerticesItems[s + 13] = light.a;
  5237. clippedVerticesItems[s + 14] = u2;
  5238. clippedVerticesItems[s + 15] = v2;
  5239. clippedVerticesItems[s + 16] = x3;
  5240. clippedVerticesItems[s + 17] = y3;
  5241. clippedVerticesItems[s + 18] = light.r;
  5242. clippedVerticesItems[s + 19] = light.g;
  5243. clippedVerticesItems[s + 20] = light.b;
  5244. clippedVerticesItems[s + 21] = light.a;
  5245. clippedVerticesItems[s + 22] = u3;
  5246. clippedVerticesItems[s + 23] = v3;
  5247. }
  5248. else {
  5249. clippedVerticesItems[s + 6] = u1;
  5250. clippedVerticesItems[s + 7] = v1;
  5251. clippedVerticesItems[s + 8] = dark.r;
  5252. clippedVerticesItems[s + 9] = dark.g;
  5253. clippedVerticesItems[s + 10] = dark.b;
  5254. clippedVerticesItems[s + 11] = dark.a;
  5255. clippedVerticesItems[s + 12] = x2;
  5256. clippedVerticesItems[s + 13] = y2;
  5257. clippedVerticesItems[s + 14] = light.r;
  5258. clippedVerticesItems[s + 15] = light.g;
  5259. clippedVerticesItems[s + 16] = light.b;
  5260. clippedVerticesItems[s + 17] = light.a;
  5261. clippedVerticesItems[s + 18] = u2;
  5262. clippedVerticesItems[s + 19] = v2;
  5263. clippedVerticesItems[s + 20] = dark.r;
  5264. clippedVerticesItems[s + 21] = dark.g;
  5265. clippedVerticesItems[s + 22] = dark.b;
  5266. clippedVerticesItems[s + 23] = dark.a;
  5267. clippedVerticesItems[s + 24] = x3;
  5268. clippedVerticesItems[s + 25] = y3;
  5269. clippedVerticesItems[s + 26] = light.r;
  5270. clippedVerticesItems[s + 27] = light.g;
  5271. clippedVerticesItems[s + 28] = light.b;
  5272. clippedVerticesItems[s + 29] = light.a;
  5273. clippedVerticesItems[s + 30] = u3;
  5274. clippedVerticesItems[s + 31] = v3;
  5275. clippedVerticesItems[s + 32] = dark.r;
  5276. clippedVerticesItems[s + 33] = dark.g;
  5277. clippedVerticesItems[s + 34] = dark.b;
  5278. clippedVerticesItems[s + 35] = dark.a;
  5279. }
  5280. s = clippedTriangles.length;
  5281. var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3);
  5282. clippedTrianglesItems[s] = index;
  5283. clippedTrianglesItems[s + 1] = (index + 1);
  5284. clippedTrianglesItems[s + 2] = (index + 2);
  5285. index += 3;
  5286. continue outer;
  5287. }
  5288. }
  5289. }
  5290. };
  5291. SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) {
  5292. var originalOutput = output;
  5293. var clipped = false;
  5294. var input = null;
  5295. if (clippingArea.length % 4 >= 2) {
  5296. input = output;
  5297. output = this.scratch;
  5298. }
  5299. else
  5300. input = this.scratch;
  5301. input.length = 0;
  5302. input.push(x1);
  5303. input.push(y1);
  5304. input.push(x2);
  5305. input.push(y2);
  5306. input.push(x3);
  5307. input.push(y3);
  5308. input.push(x1);
  5309. input.push(y1);
  5310. output.length = 0;
  5311. var clippingVertices = clippingArea;
  5312. var clippingVerticesLast = clippingArea.length - 4;
  5313. for (var i = 0;; i += 2) {
  5314. var edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1];
  5315. var edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3];
  5316. var deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
  5317. var inputVertices = input;
  5318. var inputVerticesLength = input.length - 2, outputStart = output.length;
  5319. for (var ii = 0; ii < inputVerticesLength; ii += 2) {
  5320. var inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
  5321. var inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
  5322. var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0;
  5323. if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) {
  5324. if (side2) {
  5325. output.push(inputX2);
  5326. output.push(inputY2);
  5327. continue;
  5328. }
  5329. var c0 = inputY2 - inputY, c2 = inputX2 - inputX;
  5330. var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
  5331. if (Math.abs(s) > 0.000001) {
  5332. var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s;
  5333. output.push(edgeX + (edgeX2 - edgeX) * ua);
  5334. output.push(edgeY + (edgeY2 - edgeY) * ua);
  5335. }
  5336. else {
  5337. output.push(edgeX);
  5338. output.push(edgeY);
  5339. }
  5340. }
  5341. else if (side2) {
  5342. var c0 = inputY2 - inputY, c2 = inputX2 - inputX;
  5343. var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
  5344. if (Math.abs(s) > 0.000001) {
  5345. var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s;
  5346. output.push(edgeX + (edgeX2 - edgeX) * ua);
  5347. output.push(edgeY + (edgeY2 - edgeY) * ua);
  5348. }
  5349. else {
  5350. output.push(edgeX);
  5351. output.push(edgeY);
  5352. }
  5353. output.push(inputX2);
  5354. output.push(inputY2);
  5355. }
  5356. clipped = true;
  5357. }
  5358. if (outputStart == output.length) {
  5359. originalOutput.length = 0;
  5360. return true;
  5361. }
  5362. output.push(output[0]);
  5363. output.push(output[1]);
  5364. if (i == clippingVerticesLast)
  5365. break;
  5366. var temp = output;
  5367. output = input;
  5368. output.length = 0;
  5369. input = temp;
  5370. }
  5371. if (originalOutput != output) {
  5372. originalOutput.length = 0;
  5373. for (var i = 0, n = output.length - 2; i < n; i++)
  5374. originalOutput[i] = output[i];
  5375. }
  5376. else
  5377. originalOutput.length = originalOutput.length - 2;
  5378. return clipped;
  5379. };
  5380. SkeletonClipping.makeClockwise = function (polygon) {
  5381. var vertices = polygon;
  5382. var verticeslength = polygon.length;
  5383. var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0;
  5384. for (var i = 0, n = verticeslength - 3; i < n; i += 2) {
  5385. p1x = vertices[i];
  5386. p1y = vertices[i + 1];
  5387. p2x = vertices[i + 2];
  5388. p2y = vertices[i + 3];
  5389. area += p1x * p2y - p2x * p1y;
  5390. }
  5391. if (area < 0)
  5392. return;
  5393. for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) {
  5394. var x = vertices[i], y = vertices[i + 1];
  5395. var other = lastX - i;
  5396. vertices[i] = vertices[other];
  5397. vertices[i + 1] = vertices[other + 1];
  5398. vertices[other] = x;
  5399. vertices[other + 1] = y;
  5400. }
  5401. };
  5402. return SkeletonClipping;
  5403. }());
  5404. spine.SkeletonClipping = SkeletonClipping;
  5405. })(spine || (spine = {}));
  5406. var spine;
  5407. (function (spine) {
  5408. var SkeletonData = (function () {
  5409. function SkeletonData() {
  5410. this.bones = new Array();
  5411. this.slots = new Array();
  5412. this.skins = new Array();
  5413. this.events = new Array();
  5414. this.animations = new Array();
  5415. this.ikConstraints = new Array();
  5416. this.transformConstraints = new Array();
  5417. this.pathConstraints = new Array();
  5418. this.fps = 0;
  5419. }
  5420. SkeletonData.prototype.findBone = function (boneName) {
  5421. if (boneName == null)
  5422. throw new Error("boneName cannot be null.");
  5423. var bones = this.bones;
  5424. for (var i = 0, n = bones.length; i < n; i++) {
  5425. var bone = bones[i];
  5426. if (bone.name == boneName)
  5427. return bone;
  5428. }
  5429. return null;
  5430. };
  5431. SkeletonData.prototype.findBoneIndex = function (boneName) {
  5432. if (boneName == null)
  5433. throw new Error("boneName cannot be null.");
  5434. var bones = this.bones;
  5435. for (var i = 0, n = bones.length; i < n; i++)
  5436. if (bones[i].name == boneName)
  5437. return i;
  5438. return -1;
  5439. };
  5440. SkeletonData.prototype.findSlot = function (slotName) {
  5441. if (slotName == null)
  5442. throw new Error("slotName cannot be null.");
  5443. var slots = this.slots;
  5444. for (var i = 0, n = slots.length; i < n; i++) {
  5445. var slot = slots[i];
  5446. if (slot.name == slotName)
  5447. return slot;
  5448. }
  5449. return null;
  5450. };
  5451. SkeletonData.prototype.findSlotIndex = function (slotName) {
  5452. if (slotName == null)
  5453. throw new Error("slotName cannot be null.");
  5454. var slots = this.slots;
  5455. for (var i = 0, n = slots.length; i < n; i++)
  5456. if (slots[i].name == slotName)
  5457. return i;
  5458. return -1;
  5459. };
  5460. SkeletonData.prototype.findSkin = function (skinName) {
  5461. if (skinName == null)
  5462. throw new Error("skinName cannot be null.");
  5463. var skins = this.skins;
  5464. for (var i = 0, n = skins.length; i < n; i++) {
  5465. var skin = skins[i];
  5466. if (skin.name == skinName)
  5467. return skin;
  5468. }
  5469. return null;
  5470. };
  5471. SkeletonData.prototype.findEvent = function (eventDataName) {
  5472. if (eventDataName == null)
  5473. throw new Error("eventDataName cannot be null.");
  5474. var events = this.events;
  5475. for (var i = 0, n = events.length; i < n; i++) {
  5476. var event_5 = events[i];
  5477. if (event_5.name == eventDataName)
  5478. return event_5;
  5479. }
  5480. return null;
  5481. };
  5482. SkeletonData.prototype.findAnimation = function (animationName) {
  5483. if (animationName == null)
  5484. throw new Error("animationName cannot be null.");
  5485. var animations = this.animations;
  5486. for (var i = 0, n = animations.length; i < n; i++) {
  5487. var animation = animations[i];
  5488. if (animation.name == animationName)
  5489. return animation;
  5490. }
  5491. return null;
  5492. };
  5493. SkeletonData.prototype.findIkConstraint = function (constraintName) {
  5494. if (constraintName == null)
  5495. throw new Error("constraintName cannot be null.");
  5496. var ikConstraints = this.ikConstraints;
  5497. for (var i = 0, n = ikConstraints.length; i < n; i++) {
  5498. var constraint = ikConstraints[i];
  5499. if (constraint.name == constraintName)
  5500. return constraint;
  5501. }
  5502. return null;
  5503. };
  5504. SkeletonData.prototype.findTransformConstraint = function (constraintName) {
  5505. if (constraintName == null)
  5506. throw new Error("constraintName cannot be null.");
  5507. var transformConstraints = this.transformConstraints;
  5508. for (var i = 0, n = transformConstraints.length; i < n; i++) {
  5509. var constraint = transformConstraints[i];
  5510. if (constraint.name == constraintName)
  5511. return constraint;
  5512. }
  5513. return null;
  5514. };
  5515. SkeletonData.prototype.findPathConstraint = function (constraintName) {
  5516. if (constraintName == null)
  5517. throw new Error("constraintName cannot be null.");
  5518. var pathConstraints = this.pathConstraints;
  5519. for (var i = 0, n = pathConstraints.length; i < n; i++) {
  5520. var constraint = pathConstraints[i];
  5521. if (constraint.name == constraintName)
  5522. return constraint;
  5523. }
  5524. return null;
  5525. };
  5526. SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) {
  5527. if (pathConstraintName == null)
  5528. throw new Error("pathConstraintName cannot be null.");
  5529. var pathConstraints = this.pathConstraints;
  5530. for (var i = 0, n = pathConstraints.length; i < n; i++)
  5531. if (pathConstraints[i].name == pathConstraintName)
  5532. return i;
  5533. return -1;
  5534. };
  5535. return SkeletonData;
  5536. }());
  5537. spine.SkeletonData = SkeletonData;
  5538. })(spine || (spine = {}));
  5539. var spine;
  5540. (function (spine) {
  5541. var SkeletonJson = (function () {
  5542. function SkeletonJson(attachmentLoader) {
  5543. this.scale = 1;
  5544. this.linkedMeshes = new Array();
  5545. this.attachmentLoader = attachmentLoader;
  5546. }
  5547. SkeletonJson.prototype.readSkeletonData = function (json) {
  5548. var scale = this.scale;
  5549. var skeletonData = new spine.SkeletonData();
  5550. var root = typeof (json) === "string" ? JSON.parse(json) : json;
  5551. var skeletonMap = root.skeleton;
  5552. if (skeletonMap != null) {
  5553. skeletonData.hash = skeletonMap.hash;
  5554. skeletonData.version = skeletonMap.spine;
  5555. // if ("3.8.75" == skeletonData.version)
  5556. // throw new Error("Unsupported skeleton data, please export with a newer version of Spine.");
  5557. skeletonData.x = skeletonMap.x;
  5558. skeletonData.y = skeletonMap.y;
  5559. skeletonData.width = skeletonMap.width;
  5560. skeletonData.height = skeletonMap.height;
  5561. skeletonData.fps = skeletonMap.fps;
  5562. skeletonData.imagesPath = skeletonMap.images;
  5563. }
  5564. if (root.bones) {
  5565. for (var i = 0; i < root.bones.length; i++) {
  5566. var boneMap = root.bones[i];
  5567. var parent_5 = null;
  5568. var parentName = this.getValue(boneMap, "parent", null);
  5569. if (parentName != null) {
  5570. parent_5 = skeletonData.findBone(parentName);
  5571. if (parent_5 == null)
  5572. throw new Error("Parent bone not found: " + parentName);
  5573. }
  5574. var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_5);
  5575. data.length = this.getValue(boneMap, "length", 0) * scale;
  5576. data.x = this.getValue(boneMap, "x", 0) * scale;
  5577. data.y = this.getValue(boneMap, "y", 0) * scale;
  5578. data.rotation = this.getValue(boneMap, "rotation", 0);
  5579. data.scaleX = this.getValue(boneMap, "scaleX", 1);
  5580. data.scaleY = this.getValue(boneMap, "scaleY", 1);
  5581. data.shearX = this.getValue(boneMap, "shearX", 0);
  5582. data.shearY = this.getValue(boneMap, "shearY", 0);
  5583. data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal"));
  5584. data.skinRequired = this.getValue(boneMap, "skin", false);
  5585. skeletonData.bones.push(data);
  5586. }
  5587. }
  5588. if (root.slots) {
  5589. for (var i = 0; i < root.slots.length; i++) {
  5590. var slotMap = root.slots[i];
  5591. var slotName = slotMap.name;
  5592. var boneName = slotMap.bone;
  5593. var boneData = skeletonData.findBone(boneName);
  5594. if (boneData == null)
  5595. throw new Error("Slot bone not found: " + boneName);
  5596. var data = new spine.SlotData(skeletonData.slots.length, slotName, boneData);
  5597. var color = this.getValue(slotMap, "color", null);
  5598. if (color != null)
  5599. data.color.setFromString(color);
  5600. var dark = this.getValue(slotMap, "dark", null);
  5601. if (dark != null) {
  5602. data.darkColor = new spine.Color(1, 1, 1, 1);
  5603. data.darkColor.setFromString(dark);
  5604. }
  5605. data.attachmentName = this.getValue(slotMap, "attachment", null);
  5606. data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal"));
  5607. skeletonData.slots.push(data);
  5608. }
  5609. }
  5610. if (root.ik) {
  5611. for (var i = 0; i < root.ik.length; i++) {
  5612. var constraintMap = root.ik[i];
  5613. var data = new spine.IkConstraintData(constraintMap.name);
  5614. data.order = this.getValue(constraintMap, "order", 0);
  5615. data.skinRequired = this.getValue(constraintMap, "skin", false);
  5616. for (var j = 0; j < constraintMap.bones.length; j++) {
  5617. var boneName = constraintMap.bones[j];
  5618. var bone = skeletonData.findBone(boneName);
  5619. if (bone == null)
  5620. throw new Error("IK bone not found: " + boneName);
  5621. data.bones.push(bone);
  5622. }
  5623. var targetName = constraintMap.target;
  5624. data.target = skeletonData.findBone(targetName);
  5625. if (data.target == null)
  5626. throw new Error("IK target bone not found: " + targetName);
  5627. data.mix = this.getValue(constraintMap, "mix", 1);
  5628. data.softness = this.getValue(constraintMap, "softness", 0) * scale;
  5629. data.bendDirection = this.getValue(constraintMap, "bendPositive", true) ? 1 : -1;
  5630. data.compress = this.getValue(constraintMap, "compress", false);
  5631. data.stretch = this.getValue(constraintMap, "stretch", false);
  5632. data.uniform = this.getValue(constraintMap, "uniform", false);
  5633. skeletonData.ikConstraints.push(data);
  5634. }
  5635. }
  5636. if (root.transform) {
  5637. for (var i = 0; i < root.transform.length; i++) {
  5638. var constraintMap = root.transform[i];
  5639. var data = new spine.TransformConstraintData(constraintMap.name);
  5640. data.order = this.getValue(constraintMap, "order", 0);
  5641. data.skinRequired = this.getValue(constraintMap, "skin", false);
  5642. for (var j = 0; j < constraintMap.bones.length; j++) {
  5643. var boneName = constraintMap.bones[j];
  5644. var bone = skeletonData.findBone(boneName);
  5645. if (bone == null)
  5646. throw new Error("Transform constraint bone not found: " + boneName);
  5647. data.bones.push(bone);
  5648. }
  5649. var targetName = constraintMap.target;
  5650. data.target = skeletonData.findBone(targetName);
  5651. if (data.target == null)
  5652. throw new Error("Transform constraint target bone not found: " + targetName);
  5653. data.local = this.getValue(constraintMap, "local", false);
  5654. data.relative = this.getValue(constraintMap, "relative", false);
  5655. data.offsetRotation = this.getValue(constraintMap, "rotation", 0);
  5656. data.offsetX = this.getValue(constraintMap, "x", 0) * scale;
  5657. data.offsetY = this.getValue(constraintMap, "y", 0) * scale;
  5658. data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0);
  5659. data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0);
  5660. data.offsetShearY = this.getValue(constraintMap, "shearY", 0);
  5661. data.rotateMix = this.getValue(constraintMap, "rotateMix", 1);
  5662. data.translateMix = this.getValue(constraintMap, "translateMix", 1);
  5663. data.scaleMix = this.getValue(constraintMap, "scaleMix", 1);
  5664. data.shearMix = this.getValue(constraintMap, "shearMix", 1);
  5665. skeletonData.transformConstraints.push(data);
  5666. }
  5667. }
  5668. if (root.path) {
  5669. for (var i = 0; i < root.path.length; i++) {
  5670. var constraintMap = root.path[i];
  5671. var data = new spine.PathConstraintData(constraintMap.name);
  5672. data.order = this.getValue(constraintMap, "order", 0);
  5673. data.skinRequired = this.getValue(constraintMap, "skin", false);
  5674. for (var j = 0; j < constraintMap.bones.length; j++) {
  5675. var boneName = constraintMap.bones[j];
  5676. var bone = skeletonData.findBone(boneName);
  5677. if (bone == null)
  5678. throw new Error("Transform constraint bone not found: " + boneName);
  5679. data.bones.push(bone);
  5680. }
  5681. var targetName = constraintMap.target;
  5682. data.target = skeletonData.findSlot(targetName);
  5683. if (data.target == null)
  5684. throw new Error("Path target slot not found: " + targetName);
  5685. data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent"));
  5686. data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length"));
  5687. data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent"));
  5688. data.offsetRotation = this.getValue(constraintMap, "rotation", 0);
  5689. data.position = this.getValue(constraintMap, "position", 0);
  5690. if (data.positionMode == spine.PositionMode.Fixed)
  5691. data.position *= scale;
  5692. data.spacing = this.getValue(constraintMap, "spacing", 0);
  5693. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  5694. data.spacing *= scale;
  5695. data.rotateMix = this.getValue(constraintMap, "rotateMix", 1);
  5696. data.translateMix = this.getValue(constraintMap, "translateMix", 1);
  5697. skeletonData.pathConstraints.push(data);
  5698. }
  5699. }
  5700. if (root.skins) {
  5701. var skins = root.skins;
  5702. var isArray = skins instanceof Array;
  5703. if (!isArray) {
  5704. var skinArray = [];
  5705. for (var skinName in skins) {
  5706. skinArray.push({ name: skinName, attachments: skins[skinName] });
  5707. }
  5708. skins = skinArray;
  5709. }
  5710. for (var i = 0; i < skins.length; i++) {
  5711. var skinMap = skins[i];
  5712. var skin = new spine.Skin(skinMap.name);
  5713. if (skinMap.bones) {
  5714. for (var ii = 0; ii < skinMap.bones.length; ii++) {
  5715. var bone = skeletonData.findBone(skinMap.bones[ii]);
  5716. if (bone == null)
  5717. throw new Error("Skin bone not found: " + skinMap.bones[i]);
  5718. skin.bones.push(bone);
  5719. }
  5720. }
  5721. if (skinMap.ik) {
  5722. for (var ii = 0; ii < skinMap.ik.length; ii++) {
  5723. var constraint = skeletonData.findIkConstraint(skinMap.ik[ii]);
  5724. if (constraint == null)
  5725. throw new Error("Skin IK constraint not found: " + skinMap.ik[i]);
  5726. skin.constraints.push(constraint);
  5727. }
  5728. }
  5729. if (skinMap.transform) {
  5730. for (var ii = 0; ii < skinMap.transform.length; ii++) {
  5731. var constraint = skeletonData.findTransformConstraint(skinMap.transform[ii]);
  5732. if (constraint == null)
  5733. throw new Error("Skin transform constraint not found: " + skinMap.transform[i]);
  5734. skin.constraints.push(constraint);
  5735. }
  5736. }
  5737. if (skinMap.path) {
  5738. for (var ii = 0; ii < skinMap.path.length; ii++) {
  5739. var constraint = skeletonData.findPathConstraint(skinMap.path[ii]);
  5740. if (constraint == null)
  5741. throw new Error("Skin path constraint not found: " + skinMap.path[i]);
  5742. skin.constraints.push(constraint);
  5743. }
  5744. }
  5745. for (var slotName in skinMap.attachments) {
  5746. var slot = skeletonData.findSlot(slotName);
  5747. if (slot == null)
  5748. throw new Error("Slot not found: " + slotName);
  5749. var slotMap = skinMap.attachments[slotName];
  5750. for (var entryName in slotMap) {
  5751. var attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData);
  5752. if (attachment != null)
  5753. skin.setAttachment(slot.index, entryName, attachment);
  5754. }
  5755. }
  5756. skeletonData.skins.push(skin);
  5757. if (skin.name == "default")
  5758. skeletonData.defaultSkin = skin;
  5759. }
  5760. }
  5761. for (var i = 0, n = this.linkedMeshes.length; i < n; i++) {
  5762. var linkedMesh = this.linkedMeshes[i];
  5763. var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
  5764. if (skin == null)
  5765. throw new Error("Skin not found: " + linkedMesh.skin);
  5766. var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
  5767. if (parent_6 == null)
  5768. throw new Error("Parent mesh not found: " + linkedMesh.parent);
  5769. linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh;
  5770. linkedMesh.mesh.setParentMesh(parent_6);
  5771. linkedMesh.mesh.updateUVs();
  5772. }
  5773. this.linkedMeshes.length = 0;
  5774. if (root.events) {
  5775. for (var eventName in root.events) {
  5776. var eventMap = root.events[eventName];
  5777. var data = new spine.EventData(eventName);
  5778. data.intValue = this.getValue(eventMap, "int", 0);
  5779. data.floatValue = this.getValue(eventMap, "float", 0);
  5780. data.stringValue = this.getValue(eventMap, "string", "");
  5781. data.audioPath = this.getValue(eventMap, "audio", null);
  5782. if (data.audioPath != null) {
  5783. data.volume = this.getValue(eventMap, "volume", 1);
  5784. data.balance = this.getValue(eventMap, "balance", 0);
  5785. }
  5786. skeletonData.events.push(data);
  5787. }
  5788. }
  5789. if (root.animations) {
  5790. for (var animationName in root.animations) {
  5791. var animationMap = root.animations[animationName];
  5792. this.readAnimation(animationMap, animationName, skeletonData);
  5793. }
  5794. }
  5795. return skeletonData;
  5796. };
  5797. SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) {
  5798. var scale = this.scale;
  5799. name = this.getValue(map, "name", name);
  5800. var type = this.getValue(map, "type", "region");
  5801. switch (type) {
  5802. case "region": {
  5803. var path = this.getValue(map, "path", name);
  5804. var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
  5805. if (region == null)
  5806. return null;
  5807. region.path = path;
  5808. region.x = this.getValue(map, "x", 0) * scale;
  5809. region.y = this.getValue(map, "y", 0) * scale;
  5810. region.scaleX = this.getValue(map, "scaleX", 1);
  5811. region.scaleY = this.getValue(map, "scaleY", 1);
  5812. region.rotation = this.getValue(map, "rotation", 0);
  5813. region.width = map.width * scale;
  5814. region.height = map.height * scale;
  5815. var color = this.getValue(map, "color", null);
  5816. if (color != null)
  5817. region.color.setFromString(color);
  5818. region.updateOffset();
  5819. return region;
  5820. }
  5821. case "boundingbox": {
  5822. var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
  5823. if (box == null)
  5824. return null;
  5825. this.readVertices(map, box, map.vertexCount << 1);
  5826. var color = this.getValue(map, "color", null);
  5827. if (color != null)
  5828. box.color.setFromString(color);
  5829. return box;
  5830. }
  5831. case "mesh":
  5832. case "linkedmesh": {
  5833. var path = this.getValue(map, "path", name);
  5834. var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
  5835. if (mesh == null)
  5836. return null;
  5837. mesh.path = path;
  5838. var color = this.getValue(map, "color", null);
  5839. if (color != null)
  5840. mesh.color.setFromString(color);
  5841. mesh.width = this.getValue(map, "width", 0) * scale;
  5842. mesh.height = this.getValue(map, "height", 0) * scale;
  5843. var parent_7 = this.getValue(map, "parent", null);
  5844. if (parent_7 != null) {
  5845. this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_7, this.getValue(map, "deform", true)));
  5846. return mesh;
  5847. }
  5848. var uvs = map.uvs;
  5849. this.readVertices(map, mesh, uvs.length);
  5850. mesh.triangles = map.triangles;
  5851. mesh.regionUVs = uvs;
  5852. mesh.updateUVs();
  5853. mesh.edges = this.getValue(map, "edges", null);
  5854. mesh.hullLength = this.getValue(map, "hull", 0) * 2;
  5855. return mesh;
  5856. }
  5857. case "path": {
  5858. var path = this.attachmentLoader.newPathAttachment(skin, name);
  5859. if (path == null)
  5860. return null;
  5861. path.closed = this.getValue(map, "closed", false);
  5862. path.constantSpeed = this.getValue(map, "constantSpeed", true);
  5863. var vertexCount = map.vertexCount;
  5864. this.readVertices(map, path, vertexCount << 1);
  5865. var lengths = spine.Utils.newArray(vertexCount / 3, 0);
  5866. for (var i = 0; i < map.lengths.length; i++)
  5867. lengths[i] = map.lengths[i] * scale;
  5868. path.lengths = lengths;
  5869. var color = this.getValue(map, "color", null);
  5870. if (color != null)
  5871. path.color.setFromString(color);
  5872. return path;
  5873. }
  5874. case "point": {
  5875. var point = this.attachmentLoader.newPointAttachment(skin, name);
  5876. if (point == null)
  5877. return null;
  5878. point.x = this.getValue(map, "x", 0) * scale;
  5879. point.y = this.getValue(map, "y", 0) * scale;
  5880. point.rotation = this.getValue(map, "rotation", 0);
  5881. var color = this.getValue(map, "color", null);
  5882. if (color != null)
  5883. point.color.setFromString(color);
  5884. return point;
  5885. }
  5886. case "clipping": {
  5887. var clip = this.attachmentLoader.newClippingAttachment(skin, name);
  5888. if (clip == null)
  5889. return null;
  5890. var end = this.getValue(map, "end", null);
  5891. if (end != null) {
  5892. var slot = skeletonData.findSlot(end);
  5893. if (slot == null)
  5894. throw new Error("Clipping end slot not found: " + end);
  5895. clip.endSlot = slot;
  5896. }
  5897. var vertexCount = map.vertexCount;
  5898. this.readVertices(map, clip, vertexCount << 1);
  5899. var color = this.getValue(map, "color", null);
  5900. if (color != null)
  5901. clip.color.setFromString(color);
  5902. return clip;
  5903. }
  5904. }
  5905. return null;
  5906. };
  5907. SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) {
  5908. var scale = this.scale;
  5909. attachment.worldVerticesLength = verticesLength;
  5910. var vertices = map.vertices;
  5911. if (verticesLength == vertices.length) {
  5912. var scaledVertices = spine.Utils.toFloatArray(vertices);
  5913. if (scale != 1) {
  5914. for (var i = 0, n = vertices.length; i < n; i++)
  5915. scaledVertices[i] *= scale;
  5916. }
  5917. attachment.vertices = scaledVertices;
  5918. return;
  5919. }
  5920. var weights = new Array();
  5921. var bones = new Array();
  5922. for (var i = 0, n = vertices.length; i < n;) {
  5923. var boneCount = vertices[i++];
  5924. bones.push(boneCount);
  5925. for (var nn = i + boneCount * 4; i < nn; i += 4) {
  5926. bones.push(vertices[i]);
  5927. weights.push(vertices[i + 1] * scale);
  5928. weights.push(vertices[i + 2] * scale);
  5929. weights.push(vertices[i + 3]);
  5930. }
  5931. }
  5932. attachment.bones = bones;
  5933. attachment.vertices = spine.Utils.toFloatArray(weights);
  5934. };
  5935. SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) {
  5936. var scale = this.scale;
  5937. var timelines = new Array();
  5938. var duration = 0;
  5939. if (map.slots) {
  5940. for (var slotName in map.slots) {
  5941. var slotMap = map.slots[slotName];
  5942. var slotIndex = skeletonData.findSlotIndex(slotName);
  5943. if (slotIndex == -1)
  5944. throw new Error("Slot not found: " + slotName);
  5945. for (var timelineName in slotMap) {
  5946. var timelineMap = slotMap[timelineName];
  5947. if (timelineName == "attachment") {
  5948. var timeline = new spine.AttachmentTimeline(timelineMap.length);
  5949. timeline.slotIndex = slotIndex;
  5950. var frameIndex = 0;
  5951. for (var i = 0; i < timelineMap.length; i++) {
  5952. var valueMap = timelineMap[i];
  5953. timeline.setFrame(frameIndex++, this.getValue(valueMap, "time", 0), valueMap.name);
  5954. }
  5955. timelines.push(timeline);
  5956. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  5957. }
  5958. else if (timelineName == "color") {
  5959. var timeline = new spine.ColorTimeline(timelineMap.length);
  5960. timeline.slotIndex = slotIndex;
  5961. var frameIndex = 0;
  5962. for (var i = 0; i < timelineMap.length; i++) {
  5963. var valueMap = timelineMap[i];
  5964. var color = new spine.Color();
  5965. color.setFromString(valueMap.color);
  5966. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), color.r, color.g, color.b, color.a);
  5967. this.readCurve(valueMap, timeline, frameIndex);
  5968. frameIndex++;
  5969. }
  5970. timelines.push(timeline);
  5971. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.ColorTimeline.ENTRIES]);
  5972. }
  5973. else if (timelineName == "twoColor") {
  5974. var timeline = new spine.TwoColorTimeline(timelineMap.length);
  5975. timeline.slotIndex = slotIndex;
  5976. var frameIndex = 0;
  5977. for (var i = 0; i < timelineMap.length; i++) {
  5978. var valueMap = timelineMap[i];
  5979. var light = new spine.Color();
  5980. var dark = new spine.Color();
  5981. light.setFromString(valueMap.light);
  5982. dark.setFromString(valueMap.dark);
  5983. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b);
  5984. this.readCurve(valueMap, timeline, frameIndex);
  5985. frameIndex++;
  5986. }
  5987. timelines.push(timeline);
  5988. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TwoColorTimeline.ENTRIES]);
  5989. }
  5990. else
  5991. throw new Error("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")");
  5992. }
  5993. }
  5994. }
  5995. if (map.bones) {
  5996. for (var boneName in map.bones) {
  5997. var boneMap = map.bones[boneName];
  5998. var boneIndex = skeletonData.findBoneIndex(boneName);
  5999. if (boneIndex == -1)
  6000. throw new Error("Bone not found: " + boneName);
  6001. for (var timelineName in boneMap) {
  6002. var timelineMap = boneMap[timelineName];
  6003. if (timelineName === "rotate") {
  6004. var timeline = new spine.RotateTimeline(timelineMap.length);
  6005. timeline.boneIndex = boneIndex;
  6006. var frameIndex = 0;
  6007. for (var i = 0; i < timelineMap.length; i++) {
  6008. var valueMap = timelineMap[i];
  6009. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "angle", 0));
  6010. this.readCurve(valueMap, timeline, frameIndex);
  6011. frameIndex++;
  6012. }
  6013. timelines.push(timeline);
  6014. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.RotateTimeline.ENTRIES]);
  6015. }
  6016. else if (timelineName === "translate" || timelineName === "scale" || timelineName === "shear") {
  6017. var timeline = null;
  6018. var timelineScale = 1, defaultValue = 0;
  6019. if (timelineName === "scale") {
  6020. timeline = new spine.ScaleTimeline(timelineMap.length);
  6021. defaultValue = 1;
  6022. }
  6023. else if (timelineName === "shear")
  6024. timeline = new spine.ShearTimeline(timelineMap.length);
  6025. else {
  6026. timeline = new spine.TranslateTimeline(timelineMap.length);
  6027. timelineScale = scale;
  6028. }
  6029. timeline.boneIndex = boneIndex;
  6030. var frameIndex = 0;
  6031. for (var i = 0; i < timelineMap.length; i++) {
  6032. var valueMap = timelineMap[i];
  6033. var x = this.getValue(valueMap, "x", defaultValue), y = this.getValue(valueMap, "y", defaultValue);
  6034. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), x * timelineScale, y * timelineScale);
  6035. this.readCurve(valueMap, timeline, frameIndex);
  6036. frameIndex++;
  6037. }
  6038. timelines.push(timeline);
  6039. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TranslateTimeline.ENTRIES]);
  6040. }
  6041. else
  6042. throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
  6043. }
  6044. }
  6045. }
  6046. if (map.ik) {
  6047. for (var constraintName in map.ik) {
  6048. var constraintMap = map.ik[constraintName];
  6049. var constraint = skeletonData.findIkConstraint(constraintName);
  6050. var timeline = new spine.IkConstraintTimeline(constraintMap.length);
  6051. timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint);
  6052. var frameIndex = 0;
  6053. for (var i = 0; i < constraintMap.length; i++) {
  6054. var valueMap = constraintMap[i];
  6055. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "softness", 0) * scale, this.getValue(valueMap, "bendPositive", true) ? 1 : -1, this.getValue(valueMap, "compress", false), this.getValue(valueMap, "stretch", false));
  6056. this.readCurve(valueMap, timeline, frameIndex);
  6057. frameIndex++;
  6058. }
  6059. timelines.push(timeline);
  6060. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.IkConstraintTimeline.ENTRIES]);
  6061. }
  6062. }
  6063. if (map.transform) {
  6064. for (var constraintName in map.transform) {
  6065. var constraintMap = map.transform[constraintName];
  6066. var constraint = skeletonData.findTransformConstraint(constraintName);
  6067. var timeline = new spine.TransformConstraintTimeline(constraintMap.length);
  6068. timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint);
  6069. var frameIndex = 0;
  6070. for (var i = 0; i < constraintMap.length; i++) {
  6071. var valueMap = constraintMap[i];
  6072. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1));
  6073. this.readCurve(valueMap, timeline, frameIndex);
  6074. frameIndex++;
  6075. }
  6076. timelines.push(timeline);
  6077. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TransformConstraintTimeline.ENTRIES]);
  6078. }
  6079. }
  6080. if (map.path) {
  6081. for (var constraintName in map.path) {
  6082. var constraintMap = map.path[constraintName];
  6083. var index = skeletonData.findPathConstraintIndex(constraintName);
  6084. if (index == -1)
  6085. throw new Error("Path constraint not found: " + constraintName);
  6086. var data = skeletonData.pathConstraints[index];
  6087. for (var timelineName in constraintMap) {
  6088. var timelineMap = constraintMap[timelineName];
  6089. if (timelineName === "position" || timelineName === "spacing") {
  6090. var timeline = null;
  6091. var timelineScale = 1;
  6092. if (timelineName === "spacing") {
  6093. timeline = new spine.PathConstraintSpacingTimeline(timelineMap.length);
  6094. if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)
  6095. timelineScale = scale;
  6096. }
  6097. else {
  6098. timeline = new spine.PathConstraintPositionTimeline(timelineMap.length);
  6099. if (data.positionMode == spine.PositionMode.Fixed)
  6100. timelineScale = scale;
  6101. }
  6102. timeline.pathConstraintIndex = index;
  6103. var frameIndex = 0;
  6104. for (var i = 0; i < timelineMap.length; i++) {
  6105. var valueMap = timelineMap[i];
  6106. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, timelineName, 0) * timelineScale);
  6107. this.readCurve(valueMap, timeline, frameIndex);
  6108. frameIndex++;
  6109. }
  6110. timelines.push(timeline);
  6111. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);
  6112. }
  6113. else if (timelineName === "mix") {
  6114. var timeline = new spine.PathConstraintMixTimeline(timelineMap.length);
  6115. timeline.pathConstraintIndex = index;
  6116. var frameIndex = 0;
  6117. for (var i = 0; i < timelineMap.length; i++) {
  6118. var valueMap = timelineMap[i];
  6119. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1));
  6120. this.readCurve(valueMap, timeline, frameIndex);
  6121. frameIndex++;
  6122. }
  6123. timelines.push(timeline);
  6124. duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintMixTimeline.ENTRIES]);
  6125. }
  6126. }
  6127. }
  6128. }
  6129. if (map.deform) {
  6130. for (var deformName in map.deform) {
  6131. var deformMap = map.deform[deformName];
  6132. var skin = skeletonData.findSkin(deformName);
  6133. if (skin == null)
  6134. throw new Error("Skin not found: " + deformName);
  6135. for (var slotName in deformMap) {
  6136. var slotMap = deformMap[slotName];
  6137. var slotIndex = skeletonData.findSlotIndex(slotName);
  6138. if (slotIndex == -1)
  6139. throw new Error("Slot not found: " + slotMap.name);
  6140. for (var timelineName in slotMap) {
  6141. var timelineMap = slotMap[timelineName];
  6142. var attachment = skin.getAttachment(slotIndex, timelineName);
  6143. if (attachment == null)
  6144. // throw new Error("Deform attachment not found: " + timelineMap.name);
  6145. continue;
  6146. var weighted = attachment.bones != null;
  6147. var vertices = attachment.vertices;
  6148. var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
  6149. var timeline = new spine.DeformTimeline(timelineMap.length);
  6150. timeline.slotIndex = slotIndex;
  6151. timeline.attachment = attachment;
  6152. var frameIndex = 0;
  6153. for (var j = 0; j < timelineMap.length; j++) {
  6154. var valueMap = timelineMap[j];
  6155. var deform = void 0;
  6156. var verticesValue = this.getValue(valueMap, "vertices", null);
  6157. if (verticesValue == null)
  6158. deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;
  6159. else {
  6160. deform = spine.Utils.newFloatArray(deformLength);
  6161. var start = this.getValue(valueMap, "offset", 0);
  6162. spine.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length);
  6163. if (scale != 1) {
  6164. for (var i = start, n = i + verticesValue.length; i < n; i++)
  6165. deform[i] *= scale;
  6166. }
  6167. if (!weighted) {
  6168. for (var i = 0; i < deformLength; i++)
  6169. deform[i] += vertices[i];
  6170. }
  6171. }
  6172. timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), deform);
  6173. this.readCurve(valueMap, timeline, frameIndex);
  6174. frameIndex++;
  6175. }
  6176. timelines.push(timeline);
  6177. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  6178. }
  6179. }
  6180. }
  6181. }
  6182. var drawOrderNode = map.drawOrder;
  6183. if (drawOrderNode == null)
  6184. drawOrderNode = map.draworder;
  6185. if (drawOrderNode != null) {
  6186. var timeline = new spine.DrawOrderTimeline(drawOrderNode.length);
  6187. var slotCount = skeletonData.slots.length;
  6188. var frameIndex = 0;
  6189. for (var j = 0; j < drawOrderNode.length; j++) {
  6190. var drawOrderMap = drawOrderNode[j];
  6191. var drawOrder = null;
  6192. var offsets = this.getValue(drawOrderMap, "offsets", null);
  6193. if (offsets != null) {
  6194. drawOrder = spine.Utils.newArray(slotCount, -1);
  6195. var unchanged = spine.Utils.newArray(slotCount - offsets.length, 0);
  6196. var originalIndex = 0, unchangedIndex = 0;
  6197. for (var i = 0; i < offsets.length; i++) {
  6198. var offsetMap = offsets[i];
  6199. var slotIndex = skeletonData.findSlotIndex(offsetMap.slot);
  6200. if (slotIndex == -1)
  6201. throw new Error("Slot not found: " + offsetMap.slot);
  6202. while (originalIndex != slotIndex)
  6203. unchanged[unchangedIndex++] = originalIndex++;
  6204. drawOrder[originalIndex + offsetMap.offset] = originalIndex++;
  6205. }
  6206. while (originalIndex < slotCount)
  6207. unchanged[unchangedIndex++] = originalIndex++;
  6208. for (var i = slotCount - 1; i >= 0; i--)
  6209. if (drawOrder[i] == -1)
  6210. drawOrder[i] = unchanged[--unchangedIndex];
  6211. }
  6212. timeline.setFrame(frameIndex++, this.getValue(drawOrderMap, "time", 0), drawOrder);
  6213. }
  6214. timelines.push(timeline);
  6215. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  6216. }
  6217. if (map.events) {
  6218. var timeline = new spine.EventTimeline(map.events.length);
  6219. var frameIndex = 0;
  6220. for (var i = 0; i < map.events.length; i++) {
  6221. var eventMap = map.events[i];
  6222. var eventData = skeletonData.findEvent(eventMap.name);
  6223. if (eventData == null)
  6224. throw new Error("Event not found: " + eventMap.name);
  6225. var event_6 = new spine.Event(spine.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
  6226. event_6.intValue = this.getValue(eventMap, "int", eventData.intValue);
  6227. event_6.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
  6228. event_6.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
  6229. if (event_6.data.audioPath != null) {
  6230. event_6.volume = this.getValue(eventMap, "volume", 1);
  6231. event_6.balance = this.getValue(eventMap, "balance", 0);
  6232. }
  6233. timeline.setFrame(frameIndex++, event_6);
  6234. }
  6235. timelines.push(timeline);
  6236. duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
  6237. }
  6238. if (isNaN(duration)) {
  6239. throw new Error("Error while parsing animation, duration is NaN");
  6240. }
  6241. skeletonData.animations.push(new spine.Animation(name, timelines, duration));
  6242. };
  6243. SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) {
  6244. if (!map.hasOwnProperty("curve"))
  6245. return;
  6246. if (map.curve == "stepped")
  6247. timeline.setStepped(frameIndex);
  6248. else {
  6249. var curve = map.curve;
  6250. timeline.setCurve(frameIndex, curve, this.getValue(map, "c2", 0), this.getValue(map, "c3", 1), this.getValue(map, "c4", 1));
  6251. }
  6252. };
  6253. SkeletonJson.prototype.getValue = function (map, prop, defaultValue) {
  6254. return map[prop] !== undefined ? map[prop] : defaultValue;
  6255. };
  6256. SkeletonJson.blendModeFromString = function (str) {
  6257. str = str.toLowerCase();
  6258. if (str == "normal")
  6259. return spine.BlendMode.Normal;
  6260. if (str == "additive")
  6261. return spine.BlendMode.Additive;
  6262. if (str == "multiply")
  6263. return spine.BlendMode.Multiply;
  6264. if (str == "screen")
  6265. return spine.BlendMode.Screen;
  6266. throw new Error("Unknown blend mode: " + str);
  6267. };
  6268. SkeletonJson.positionModeFromString = function (str) {
  6269. str = str.toLowerCase();
  6270. if (str == "fixed")
  6271. return spine.PositionMode.Fixed;
  6272. if (str == "percent")
  6273. return spine.PositionMode.Percent;
  6274. throw new Error("Unknown position mode: " + str);
  6275. };
  6276. SkeletonJson.spacingModeFromString = function (str) {
  6277. str = str.toLowerCase();
  6278. if (str == "length")
  6279. return spine.SpacingMode.Length;
  6280. if (str == "fixed")
  6281. return spine.SpacingMode.Fixed;
  6282. if (str == "percent")
  6283. return spine.SpacingMode.Percent;
  6284. throw new Error("Unknown position mode: " + str);
  6285. };
  6286. SkeletonJson.rotateModeFromString = function (str) {
  6287. str = str.toLowerCase();
  6288. if (str == "tangent")
  6289. return spine.RotateMode.Tangent;
  6290. if (str == "chain")
  6291. return spine.RotateMode.Chain;
  6292. if (str == "chainscale")
  6293. return spine.RotateMode.ChainScale;
  6294. throw new Error("Unknown rotate mode: " + str);
  6295. };
  6296. SkeletonJson.transformModeFromString = function (str) {
  6297. str = str.toLowerCase();
  6298. if (str == "normal")
  6299. return spine.TransformMode.Normal;
  6300. if (str == "onlytranslation")
  6301. return spine.TransformMode.OnlyTranslation;
  6302. if (str == "norotationorreflection")
  6303. return spine.TransformMode.NoRotationOrReflection;
  6304. if (str == "noscale")
  6305. return spine.TransformMode.NoScale;
  6306. if (str == "noscaleorreflection")
  6307. return spine.TransformMode.NoScaleOrReflection;
  6308. throw new Error("Unknown transform mode: " + str);
  6309. };
  6310. return SkeletonJson;
  6311. }());
  6312. spine.SkeletonJson = SkeletonJson;
  6313. var LinkedMesh = (function () {
  6314. function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
  6315. this.mesh = mesh;
  6316. this.skin = skin;
  6317. this.slotIndex = slotIndex;
  6318. this.parent = parent;
  6319. this.inheritDeform = inheritDeform;
  6320. }
  6321. return LinkedMesh;
  6322. }());
  6323. })(spine || (spine = {}));
  6324. var spine;
  6325. (function (spine) {
  6326. var SkinEntry = (function () {
  6327. function SkinEntry(slotIndex, name, attachment) {
  6328. this.slotIndex = slotIndex;
  6329. this.name = name;
  6330. this.attachment = attachment;
  6331. }
  6332. return SkinEntry;
  6333. }());
  6334. spine.SkinEntry = SkinEntry;
  6335. var Skin = (function () {
  6336. function Skin(name) {
  6337. this.attachments = new Array();
  6338. this.bones = Array();
  6339. this.constraints = new Array();
  6340. if (name == null)
  6341. throw new Error("name cannot be null.");
  6342. this.name = name;
  6343. }
  6344. Skin.prototype.setAttachment = function (slotIndex, name, attachment) {
  6345. if (attachment == null)
  6346. throw new Error("attachment cannot be null.");
  6347. var attachments = this.attachments;
  6348. if (slotIndex >= attachments.length)
  6349. attachments.length = slotIndex + 1;
  6350. if (!attachments[slotIndex])
  6351. attachments[slotIndex] = {};
  6352. attachments[slotIndex][name] = attachment;
  6353. };
  6354. Skin.prototype.addSkin = function (skin) {
  6355. for (var i = 0; i < skin.bones.length; i++) {
  6356. var bone = skin.bones[i];
  6357. var contained = false;
  6358. for (var j = 0; j < this.bones.length; j++) {
  6359. if (this.bones[j] == bone) {
  6360. contained = true;
  6361. break;
  6362. }
  6363. }
  6364. if (!contained)
  6365. this.bones.push(bone);
  6366. }
  6367. for (var i = 0; i < skin.constraints.length; i++) {
  6368. var constraint = skin.constraints[i];
  6369. var contained = false;
  6370. for (var j = 0; j < this.constraints.length; j++) {
  6371. if (this.constraints[j] == constraint) {
  6372. contained = true;
  6373. break;
  6374. }
  6375. }
  6376. if (!contained)
  6377. this.constraints.push(constraint);
  6378. }
  6379. var attachments = skin.getAttachments();
  6380. for (var i = 0; i < attachments.length; i++) {
  6381. var attachment = attachments[i];
  6382. this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
  6383. }
  6384. };
  6385. Skin.prototype.copySkin = function (skin) {
  6386. for (var i = 0; i < skin.bones.length; i++) {
  6387. var bone = skin.bones[i];
  6388. var contained = false;
  6389. for (var j = 0; j < this.bones.length; j++) {
  6390. if (this.bones[j] == bone) {
  6391. contained = true;
  6392. break;
  6393. }
  6394. }
  6395. if (!contained)
  6396. this.bones.push(bone);
  6397. }
  6398. for (var i = 0; i < skin.constraints.length; i++) {
  6399. var constraint = skin.constraints[i];
  6400. var contained = false;
  6401. for (var j = 0; j < this.constraints.length; j++) {
  6402. if (this.constraints[j] == constraint) {
  6403. contained = true;
  6404. break;
  6405. }
  6406. }
  6407. if (!contained)
  6408. this.constraints.push(constraint);
  6409. }
  6410. var attachments = skin.getAttachments();
  6411. for (var i = 0; i < attachments.length; i++) {
  6412. var attachment = attachments[i];
  6413. if (attachment.attachment == null)
  6414. continue;
  6415. if (attachment.attachment instanceof spine.MeshAttachment) {
  6416. attachment.attachment = attachment.attachment.newLinkedMesh();
  6417. this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
  6418. }
  6419. else {
  6420. attachment.attachment = attachment.attachment.copy();
  6421. this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
  6422. }
  6423. }
  6424. };
  6425. Skin.prototype.getAttachment = function (slotIndex, name) {
  6426. var dictionary = this.attachments[slotIndex];
  6427. return dictionary ? dictionary[name] : null;
  6428. };
  6429. Skin.prototype.removeAttachment = function (slotIndex, name) {
  6430. var dictionary = this.attachments[slotIndex];
  6431. if (dictionary)
  6432. dictionary[name] = null;
  6433. };
  6434. Skin.prototype.getAttachments = function () {
  6435. var entries = new Array();
  6436. for (var i = 0; i < this.attachments.length; i++) {
  6437. var slotAttachments = this.attachments[i];
  6438. if (slotAttachments) {
  6439. for (var name_4 in slotAttachments) {
  6440. var attachment = slotAttachments[name_4];
  6441. if (attachment)
  6442. entries.push(new SkinEntry(i, name_4, attachment));
  6443. }
  6444. }
  6445. }
  6446. return entries;
  6447. };
  6448. Skin.prototype.getAttachmentsForSlot = function (slotIndex, attachments) {
  6449. var slotAttachments = this.attachments[slotIndex];
  6450. if (slotAttachments) {
  6451. for (var name_5 in slotAttachments) {
  6452. var attachment = slotAttachments[name_5];
  6453. if (attachment)
  6454. attachments.push(new SkinEntry(slotIndex, name_5, attachment));
  6455. }
  6456. }
  6457. };
  6458. Skin.prototype.clear = function () {
  6459. this.attachments.length = 0;
  6460. this.bones.length = 0;
  6461. this.constraints.length = 0;
  6462. };
  6463. Skin.prototype.attachAll = function (skeleton, oldSkin) {
  6464. var slotIndex = 0;
  6465. for (var i = 0; i < skeleton.slots.length; i++) {
  6466. var slot = skeleton.slots[i];
  6467. var slotAttachment = slot.getAttachment();
  6468. if (slotAttachment && slotIndex < oldSkin.attachments.length) {
  6469. var dictionary = oldSkin.attachments[slotIndex];
  6470. for (var key in dictionary) {
  6471. var skinAttachment = dictionary[key];
  6472. if (slotAttachment == skinAttachment) {
  6473. var attachment = this.getAttachment(slotIndex, key);
  6474. if (attachment != null)
  6475. slot.setAttachment(attachment);
  6476. break;
  6477. }
  6478. }
  6479. }
  6480. slotIndex++;
  6481. }
  6482. };
  6483. return Skin;
  6484. }());
  6485. spine.Skin = Skin;
  6486. })(spine || (spine = {}));
  6487. var spine;
  6488. (function (spine) {
  6489. var Slot = (function () {
  6490. function Slot(data, bone) {
  6491. this.deform = new Array();
  6492. if (data == null)
  6493. throw new Error("data cannot be null.");
  6494. if (bone == null)
  6495. throw new Error("bone cannot be null.");
  6496. this.data = data;
  6497. this.bone = bone;
  6498. this.color = new spine.Color();
  6499. this.darkColor = data.darkColor == null ? null : new spine.Color();
  6500. this.setToSetupPose();
  6501. }
  6502. Slot.prototype.getSkeleton = function () {
  6503. return this.bone.skeleton;
  6504. };
  6505. Slot.prototype.getAttachment = function () {
  6506. return this.attachment;
  6507. };
  6508. Slot.prototype.setAttachment = function (attachment) {
  6509. if (this.attachment == attachment)
  6510. return;
  6511. this.attachment = attachment;
  6512. this.attachmentTime = this.bone.skeleton.time;
  6513. this.deform.length = 0;
  6514. };
  6515. Slot.prototype.setAttachmentTime = function (time) {
  6516. this.attachmentTime = this.bone.skeleton.time - time;
  6517. };
  6518. Slot.prototype.getAttachmentTime = function () {
  6519. return this.bone.skeleton.time - this.attachmentTime;
  6520. };
  6521. Slot.prototype.setToSetupPose = function () {
  6522. this.color.setFromColor(this.data.color);
  6523. if (this.darkColor != null)
  6524. this.darkColor.setFromColor(this.data.darkColor);
  6525. if (this.data.attachmentName == null)
  6526. this.attachment = null;
  6527. else {
  6528. this.attachment = null;
  6529. this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName));
  6530. }
  6531. };
  6532. return Slot;
  6533. }());
  6534. spine.Slot = Slot;
  6535. })(spine || (spine = {}));
  6536. var spine;
  6537. (function (spine) {
  6538. var SlotData = (function () {
  6539. function SlotData(index, name, boneData) {
  6540. this.color = new spine.Color(1, 1, 1, 1);
  6541. if (index < 0)
  6542. throw new Error("index must be >= 0.");
  6543. if (name == null)
  6544. throw new Error("name cannot be null.");
  6545. if (boneData == null)
  6546. throw new Error("boneData cannot be null.");
  6547. this.index = index;
  6548. this.name = name;
  6549. this.boneData = boneData;
  6550. }
  6551. return SlotData;
  6552. }());
  6553. spine.SlotData = SlotData;
  6554. })(spine || (spine = {}));
  6555. var spine;
  6556. (function (spine) {
  6557. var Texture = (function () {
  6558. function Texture(image) {
  6559. this._image = image;
  6560. }
  6561. Texture.prototype.getImage = function () {
  6562. return this._image;
  6563. };
  6564. Texture.filterFromString = function (text) {
  6565. switch (text.toLowerCase()) {
  6566. case "nearest": return TextureFilter.Nearest;
  6567. case "linear": return TextureFilter.Linear;
  6568. case "mipmap": return TextureFilter.MipMap;
  6569. case "mipmapnearestnearest": return TextureFilter.MipMapNearestNearest;
  6570. case "mipmaplinearnearest": return TextureFilter.MipMapLinearNearest;
  6571. case "mipmapnearestlinear": return TextureFilter.MipMapNearestLinear;
  6572. case "mipmaplinearlinear": return TextureFilter.MipMapLinearLinear;
  6573. default: throw new Error("Unknown texture filter " + text);
  6574. }
  6575. };
  6576. Texture.wrapFromString = function (text) {
  6577. switch (text.toLowerCase()) {
  6578. case "mirroredtepeat": return TextureWrap.MirroredRepeat;
  6579. case "clamptoedge": return TextureWrap.ClampToEdge;
  6580. case "repeat": return TextureWrap.Repeat;
  6581. default: throw new Error("Unknown texture wrap " + text);
  6582. }
  6583. };
  6584. return Texture;
  6585. }());
  6586. spine.Texture = Texture;
  6587. var TextureFilter;
  6588. (function (TextureFilter) {
  6589. TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest";
  6590. TextureFilter[TextureFilter["Linear"] = 9729] = "Linear";
  6591. TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap";
  6592. TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest";
  6593. TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest";
  6594. TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear";
  6595. TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear";
  6596. })(TextureFilter = spine.TextureFilter || (spine.TextureFilter = {}));
  6597. var TextureWrap;
  6598. (function (TextureWrap) {
  6599. TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat";
  6600. TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge";
  6601. TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat";
  6602. })(TextureWrap = spine.TextureWrap || (spine.TextureWrap = {}));
  6603. var TextureRegion = (function () {
  6604. function TextureRegion() {
  6605. this.u = 0;
  6606. this.v = 0;
  6607. this.u2 = 0;
  6608. this.v2 = 0;
  6609. this.width = 0;
  6610. this.height = 0;
  6611. this.rotate = false;
  6612. this.offsetX = 0;
  6613. this.offsetY = 0;
  6614. this.originalWidth = 0;
  6615. this.originalHeight = 0;
  6616. }
  6617. return TextureRegion;
  6618. }());
  6619. spine.TextureRegion = TextureRegion;
  6620. var FakeTexture = (function (_super) {
  6621. __extends(FakeTexture, _super);
  6622. function FakeTexture() {
  6623. return _super !== null && _super.apply(this, arguments) || this;
  6624. }
  6625. FakeTexture.prototype.setFilters = function (minFilter, magFilter) { };
  6626. FakeTexture.prototype.setWraps = function (uWrap, vWrap) { };
  6627. FakeTexture.prototype.dispose = function () { };
  6628. return FakeTexture;
  6629. }(Texture));
  6630. spine.FakeTexture = FakeTexture;
  6631. })(spine || (spine = {}));
  6632. var spine;
  6633. (function (spine) {
  6634. var TextureAtlas = (function () {
  6635. function TextureAtlas(atlasText, textureLoader) {
  6636. this.pages = new Array();
  6637. this.regions = new Array();
  6638. this.load(atlasText, textureLoader);
  6639. }
  6640. TextureAtlas.prototype.load = function (atlasText, textureLoader) {
  6641. if (textureLoader == null)
  6642. throw new Error("textureLoader cannot be null.");
  6643. var reader = new TextureAtlasReader(atlasText);
  6644. var tuple = new Array(4);
  6645. var page = null;
  6646. while (true) {
  6647. var line = reader.readLine();
  6648. if (line == null)
  6649. break;
  6650. line = line.trim();
  6651. if (line.length == 0)
  6652. page = null;
  6653. else if (!page) {
  6654. page = new TextureAtlasPage();
  6655. page.name = line;
  6656. if (reader.readTuple(tuple) == 2) {
  6657. page.width = parseInt(tuple[0]);
  6658. page.height = parseInt(tuple[1]);
  6659. reader.readTuple(tuple);
  6660. }
  6661. reader.readTuple(tuple);
  6662. page.minFilter = spine.Texture.filterFromString(tuple[0]);
  6663. page.magFilter = spine.Texture.filterFromString(tuple[1]);
  6664. var direction = reader.readValue();
  6665. page.uWrap = spine.TextureWrap.ClampToEdge;
  6666. page.vWrap = spine.TextureWrap.ClampToEdge;
  6667. if (direction == "x")
  6668. page.uWrap = spine.TextureWrap.Repeat;
  6669. else if (direction == "y")
  6670. page.vWrap = spine.TextureWrap.Repeat;
  6671. else if (direction == "xy")
  6672. page.uWrap = page.vWrap = spine.TextureWrap.Repeat;
  6673. page.texture = textureLoader(line);
  6674. page.texture.setFilters(page.minFilter, page.magFilter);
  6675. page.texture.setWraps(page.uWrap, page.vWrap);
  6676. page.width = page.texture.getImage().width;
  6677. page.height = page.texture.getImage().height;
  6678. this.pages.push(page);
  6679. }
  6680. else {
  6681. var region = new TextureAtlasRegion();
  6682. region.name = line;
  6683. region.page = page;
  6684. var rotateValue = reader.readValue();
  6685. if (rotateValue.toLocaleLowerCase() == "true") {
  6686. region.degrees = 90;
  6687. }
  6688. else if (rotateValue.toLocaleLowerCase() == "false") {
  6689. region.degrees = 0;
  6690. }
  6691. else {
  6692. region.degrees = parseFloat(rotateValue);
  6693. }
  6694. region.rotate = region.degrees == 90;
  6695. reader.readTuple(tuple);
  6696. var x = parseInt(tuple[0]);
  6697. var y = parseInt(tuple[1]);
  6698. reader.readTuple(tuple);
  6699. var width = parseInt(tuple[0]);
  6700. var height = parseInt(tuple[1]);
  6701. region.u = x / page.width;
  6702. region.v = y / page.height;
  6703. if (region.rotate) {
  6704. region.u2 = (x + height) / page.width;
  6705. region.v2 = (y + width) / page.height;
  6706. }
  6707. else {
  6708. region.u2 = (x + width) / page.width;
  6709. region.v2 = (y + height) / page.height;
  6710. }
  6711. region.x = x;
  6712. region.y = y;
  6713. region.width = Math.abs(width);
  6714. region.height = Math.abs(height);
  6715. if (reader.readTuple(tuple) == 4) {
  6716. if (reader.readTuple(tuple) == 4) {
  6717. reader.readTuple(tuple);
  6718. }
  6719. }
  6720. region.originalWidth = parseInt(tuple[0]);
  6721. region.originalHeight = parseInt(tuple[1]);
  6722. reader.readTuple(tuple);
  6723. region.offsetX = parseInt(tuple[0]);
  6724. region.offsetY = parseInt(tuple[1]);
  6725. region.index = parseInt(reader.readValue());
  6726. region.texture = page.texture;
  6727. this.regions.push(region);
  6728. }
  6729. }
  6730. };
  6731. TextureAtlas.prototype.findRegion = function (name) {
  6732. for (var i = 0; i < this.regions.length; i++) {
  6733. if (this.regions[i].name == name) {
  6734. return this.regions[i];
  6735. }
  6736. }
  6737. return null;
  6738. };
  6739. TextureAtlas.prototype.dispose = function () {
  6740. for (var i = 0; i < this.pages.length; i++) {
  6741. this.pages[i].texture.dispose();
  6742. }
  6743. };
  6744. return TextureAtlas;
  6745. }());
  6746. spine.TextureAtlas = TextureAtlas;
  6747. var TextureAtlasReader = (function () {
  6748. function TextureAtlasReader(text) {
  6749. this.index = 0;
  6750. this.lines = text.split(/\r\n|\r|\n/);
  6751. }
  6752. TextureAtlasReader.prototype.readLine = function () {
  6753. if (this.index >= this.lines.length)
  6754. return null;
  6755. return this.lines[this.index++];
  6756. };
  6757. TextureAtlasReader.prototype.readValue = function () {
  6758. var line = this.readLine();
  6759. var colon = line.indexOf(":");
  6760. if (colon == -1)
  6761. throw new Error("Invalid line: " + line);
  6762. return line.substring(colon + 1).trim();
  6763. };
  6764. TextureAtlasReader.prototype.readTuple = function (tuple) {
  6765. var line = this.readLine();
  6766. var colon = line.indexOf(":");
  6767. if (colon == -1)
  6768. throw new Error("Invalid line: " + line);
  6769. var i = 0, lastMatch = colon + 1;
  6770. for (; i < 3; i++) {
  6771. var comma = line.indexOf(",", lastMatch);
  6772. if (comma == -1)
  6773. break;
  6774. tuple[i] = line.substr(lastMatch, comma - lastMatch).trim();
  6775. lastMatch = comma + 1;
  6776. }
  6777. tuple[i] = line.substring(lastMatch).trim();
  6778. return i + 1;
  6779. };
  6780. return TextureAtlasReader;
  6781. }());
  6782. var TextureAtlasPage = (function () {
  6783. function TextureAtlasPage() {
  6784. }
  6785. return TextureAtlasPage;
  6786. }());
  6787. spine.TextureAtlasPage = TextureAtlasPage;
  6788. var TextureAtlasRegion = (function (_super) {
  6789. __extends(TextureAtlasRegion, _super);
  6790. function TextureAtlasRegion() {
  6791. return _super !== null && _super.apply(this, arguments) || this;
  6792. }
  6793. return TextureAtlasRegion;
  6794. }(spine.TextureRegion));
  6795. spine.TextureAtlasRegion = TextureAtlasRegion;
  6796. })(spine || (spine = {}));
  6797. var spine;
  6798. (function (spine) {
  6799. var TransformConstraint = (function () {
  6800. function TransformConstraint(data, skeleton) {
  6801. this.rotateMix = 0;
  6802. this.translateMix = 0;
  6803. this.scaleMix = 0;
  6804. this.shearMix = 0;
  6805. this.temp = new spine.Vector2();
  6806. this.active = false;
  6807. if (data == null)
  6808. throw new Error("data cannot be null.");
  6809. if (skeleton == null)
  6810. throw new Error("skeleton cannot be null.");
  6811. this.data = data;
  6812. this.rotateMix = data.rotateMix;
  6813. this.translateMix = data.translateMix;
  6814. this.scaleMix = data.scaleMix;
  6815. this.shearMix = data.shearMix;
  6816. this.bones = new Array();
  6817. for (var i = 0; i < data.bones.length; i++)
  6818. this.bones.push(skeleton.findBone(data.bones[i].name));
  6819. this.target = skeleton.findBone(data.target.name);
  6820. }
  6821. TransformConstraint.prototype.isActive = function () {
  6822. return this.active;
  6823. };
  6824. TransformConstraint.prototype.apply = function () {
  6825. this.update();
  6826. };
  6827. TransformConstraint.prototype.update = function () {
  6828. if (this.data.local) {
  6829. if (this.data.relative)
  6830. this.applyRelativeLocal();
  6831. else
  6832. this.applyAbsoluteLocal();
  6833. }
  6834. else {
  6835. if (this.data.relative)
  6836. this.applyRelativeWorld();
  6837. else
  6838. this.applyAbsoluteWorld();
  6839. }
  6840. };
  6841. TransformConstraint.prototype.applyAbsoluteWorld = function () {
  6842. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  6843. var target = this.target;
  6844. var ta = target.a, tb = target.b, tc = target.c, td = target.d;
  6845. var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  6846. var offsetRotation = this.data.offsetRotation * degRadReflect;
  6847. var offsetShearY = this.data.offsetShearY * degRadReflect;
  6848. var bones = this.bones;
  6849. for (var i = 0, n = bones.length; i < n; i++) {
  6850. var bone = bones[i];
  6851. var modified = false;
  6852. if (rotateMix != 0) {
  6853. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  6854. var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
  6855. if (r > spine.MathUtils.PI)
  6856. r -= spine.MathUtils.PI2;
  6857. else if (r < -spine.MathUtils.PI)
  6858. r += spine.MathUtils.PI2;
  6859. r *= rotateMix;
  6860. var cos = Math.cos(r), sin = Math.sin(r);
  6861. bone.a = cos * a - sin * c;
  6862. bone.b = cos * b - sin * d;
  6863. bone.c = sin * a + cos * c;
  6864. bone.d = sin * b + cos * d;
  6865. modified = true;
  6866. }
  6867. if (translateMix != 0) {
  6868. var temp = this.temp;
  6869. target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));
  6870. bone.worldX += (temp.x - bone.worldX) * translateMix;
  6871. bone.worldY += (temp.y - bone.worldY) * translateMix;
  6872. modified = true;
  6873. }
  6874. if (scaleMix > 0) {
  6875. var s = Math.sqrt(bone.a * bone.a + bone.c * bone.c);
  6876. var ts = Math.sqrt(ta * ta + tc * tc);
  6877. if (s > 0.00001)
  6878. s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s;
  6879. bone.a *= s;
  6880. bone.c *= s;
  6881. s = Math.sqrt(bone.b * bone.b + bone.d * bone.d);
  6882. ts = Math.sqrt(tb * tb + td * td);
  6883. if (s > 0.00001)
  6884. s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s;
  6885. bone.b *= s;
  6886. bone.d *= s;
  6887. modified = true;
  6888. }
  6889. if (shearMix > 0) {
  6890. var b = bone.b, d = bone.d;
  6891. var by = Math.atan2(d, b);
  6892. var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(bone.c, bone.a));
  6893. if (r > spine.MathUtils.PI)
  6894. r -= spine.MathUtils.PI2;
  6895. else if (r < -spine.MathUtils.PI)
  6896. r += spine.MathUtils.PI2;
  6897. r = by + (r + offsetShearY) * shearMix;
  6898. var s = Math.sqrt(b * b + d * d);
  6899. bone.b = Math.cos(r) * s;
  6900. bone.d = Math.sin(r) * s;
  6901. modified = true;
  6902. }
  6903. if (modified)
  6904. bone.appliedValid = false;
  6905. }
  6906. };
  6907. TransformConstraint.prototype.applyRelativeWorld = function () {
  6908. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  6909. var target = this.target;
  6910. var ta = target.a, tb = target.b, tc = target.c, td = target.d;
  6911. var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
  6912. var offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect;
  6913. var bones = this.bones;
  6914. for (var i = 0, n = bones.length; i < n; i++) {
  6915. var bone = bones[i];
  6916. var modified = false;
  6917. if (rotateMix != 0) {
  6918. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  6919. var r = Math.atan2(tc, ta) + offsetRotation;
  6920. if (r > spine.MathUtils.PI)
  6921. r -= spine.MathUtils.PI2;
  6922. else if (r < -spine.MathUtils.PI)
  6923. r += spine.MathUtils.PI2;
  6924. r *= rotateMix;
  6925. var cos = Math.cos(r), sin = Math.sin(r);
  6926. bone.a = cos * a - sin * c;
  6927. bone.b = cos * b - sin * d;
  6928. bone.c = sin * a + cos * c;
  6929. bone.d = sin * b + cos * d;
  6930. modified = true;
  6931. }
  6932. if (translateMix != 0) {
  6933. var temp = this.temp;
  6934. target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));
  6935. bone.worldX += temp.x * translateMix;
  6936. bone.worldY += temp.y * translateMix;
  6937. modified = true;
  6938. }
  6939. if (scaleMix > 0) {
  6940. var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1;
  6941. bone.a *= s;
  6942. bone.c *= s;
  6943. s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1;
  6944. bone.b *= s;
  6945. bone.d *= s;
  6946. modified = true;
  6947. }
  6948. if (shearMix > 0) {
  6949. var r = Math.atan2(td, tb) - Math.atan2(tc, ta);
  6950. if (r > spine.MathUtils.PI)
  6951. r -= spine.MathUtils.PI2;
  6952. else if (r < -spine.MathUtils.PI)
  6953. r += spine.MathUtils.PI2;
  6954. var b = bone.b, d = bone.d;
  6955. r = Math.atan2(d, b) + (r - spine.MathUtils.PI / 2 + offsetShearY) * shearMix;
  6956. var s = Math.sqrt(b * b + d * d);
  6957. bone.b = Math.cos(r) * s;
  6958. bone.d = Math.sin(r) * s;
  6959. modified = true;
  6960. }
  6961. if (modified)
  6962. bone.appliedValid = false;
  6963. }
  6964. };
  6965. TransformConstraint.prototype.applyAbsoluteLocal = function () {
  6966. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  6967. var target = this.target;
  6968. if (!target.appliedValid)
  6969. target.updateAppliedTransform();
  6970. var bones = this.bones;
  6971. for (var i = 0, n = bones.length; i < n; i++) {
  6972. var bone = bones[i];
  6973. if (!bone.appliedValid)
  6974. bone.updateAppliedTransform();
  6975. var rotation = bone.arotation;
  6976. if (rotateMix != 0) {
  6977. var r = target.arotation - rotation + this.data.offsetRotation;
  6978. r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
  6979. rotation += r * rotateMix;
  6980. }
  6981. var x = bone.ax, y = bone.ay;
  6982. if (translateMix != 0) {
  6983. x += (target.ax - x + this.data.offsetX) * translateMix;
  6984. y += (target.ay - y + this.data.offsetY) * translateMix;
  6985. }
  6986. var scaleX = bone.ascaleX, scaleY = bone.ascaleY;
  6987. if (scaleMix != 0) {
  6988. if (scaleX > 0.00001)
  6989. scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX;
  6990. if (scaleY > 0.00001)
  6991. scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY;
  6992. }
  6993. var shearY = bone.ashearY;
  6994. if (shearMix != 0) {
  6995. var r = target.ashearY - shearY + this.data.offsetShearY;
  6996. r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
  6997. bone.shearY += r * shearMix;
  6998. }
  6999. bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
  7000. }
  7001. };
  7002. TransformConstraint.prototype.applyRelativeLocal = function () {
  7003. var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
  7004. var target = this.target;
  7005. if (!target.appliedValid)
  7006. target.updateAppliedTransform();
  7007. var bones = this.bones;
  7008. for (var i = 0, n = bones.length; i < n; i++) {
  7009. var bone = bones[i];
  7010. if (!bone.appliedValid)
  7011. bone.updateAppliedTransform();
  7012. var rotation = bone.arotation;
  7013. if (rotateMix != 0)
  7014. rotation += (target.arotation + this.data.offsetRotation) * rotateMix;
  7015. var x = bone.ax, y = bone.ay;
  7016. if (translateMix != 0) {
  7017. x += (target.ax + this.data.offsetX) * translateMix;
  7018. y += (target.ay + this.data.offsetY) * translateMix;
  7019. }
  7020. var scaleX = bone.ascaleX, scaleY = bone.ascaleY;
  7021. if (scaleMix != 0) {
  7022. if (scaleX > 0.00001)
  7023. scaleX *= ((target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix) + 1;
  7024. if (scaleY > 0.00001)
  7025. scaleY *= ((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1;
  7026. }
  7027. var shearY = bone.ashearY;
  7028. if (shearMix != 0)
  7029. shearY += (target.ashearY + this.data.offsetShearY) * shearMix;
  7030. bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
  7031. }
  7032. };
  7033. return TransformConstraint;
  7034. }());
  7035. spine.TransformConstraint = TransformConstraint;
  7036. })(spine || (spine = {}));
  7037. var spine;
  7038. (function (spine) {
  7039. var TransformConstraintData = (function (_super) {
  7040. __extends(TransformConstraintData, _super);
  7041. function TransformConstraintData(name) {
  7042. var _this = _super.call(this, name, 0, false) || this;
  7043. _this.bones = new Array();
  7044. _this.rotateMix = 0;
  7045. _this.translateMix = 0;
  7046. _this.scaleMix = 0;
  7047. _this.shearMix = 0;
  7048. _this.offsetRotation = 0;
  7049. _this.offsetX = 0;
  7050. _this.offsetY = 0;
  7051. _this.offsetScaleX = 0;
  7052. _this.offsetScaleY = 0;
  7053. _this.offsetShearY = 0;
  7054. _this.relative = false;
  7055. _this.local = false;
  7056. return _this;
  7057. }
  7058. return TransformConstraintData;
  7059. }(spine.ConstraintData));
  7060. spine.TransformConstraintData = TransformConstraintData;
  7061. })(spine || (spine = {}));
  7062. var spine;
  7063. (function (spine) {
  7064. var Triangulator = (function () {
  7065. function Triangulator() {
  7066. this.convexPolygons = new Array();
  7067. this.convexPolygonsIndices = new Array();
  7068. this.indicesArray = new Array();
  7069. this.isConcaveArray = new Array();
  7070. this.triangles = new Array();
  7071. this.polygonPool = new spine.Pool(function () {
  7072. return new Array();
  7073. });
  7074. this.polygonIndicesPool = new spine.Pool(function () {
  7075. return new Array();
  7076. });
  7077. }
  7078. Triangulator.prototype.triangulate = function (verticesArray) {
  7079. var vertices = verticesArray;
  7080. var vertexCount = verticesArray.length >> 1;
  7081. var indices = this.indicesArray;
  7082. indices.length = 0;
  7083. for (var i = 0; i < vertexCount; i++)
  7084. indices[i] = i;
  7085. var isConcave = this.isConcaveArray;
  7086. isConcave.length = 0;
  7087. for (var i = 0, n = vertexCount; i < n; ++i)
  7088. isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices);
  7089. var triangles = this.triangles;
  7090. triangles.length = 0;
  7091. while (vertexCount > 3) {
  7092. var previous = vertexCount - 1, i = 0, next = 1;
  7093. while (true) {
  7094. outer: if (!isConcave[i]) {
  7095. var p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1;
  7096. var p1x = vertices[p1], p1y = vertices[p1 + 1];
  7097. var p2x = vertices[p2], p2y = vertices[p2 + 1];
  7098. var p3x = vertices[p3], p3y = vertices[p3 + 1];
  7099. for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) {
  7100. if (!isConcave[ii])
  7101. continue;
  7102. var v = indices[ii] << 1;
  7103. var vx = vertices[v], vy = vertices[v + 1];
  7104. if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) {
  7105. if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) {
  7106. if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy))
  7107. break outer;
  7108. }
  7109. }
  7110. }
  7111. break;
  7112. }
  7113. if (next == 0) {
  7114. do {
  7115. if (!isConcave[i])
  7116. break;
  7117. i--;
  7118. } while (i > 0);
  7119. break;
  7120. }
  7121. previous = i;
  7122. i = next;
  7123. next = (next + 1) % vertexCount;
  7124. }
  7125. triangles.push(indices[(vertexCount + i - 1) % vertexCount]);
  7126. triangles.push(indices[i]);
  7127. triangles.push(indices[(i + 1) % vertexCount]);
  7128. indices.splice(i, 1);
  7129. isConcave.splice(i, 1);
  7130. vertexCount--;
  7131. var previousIndex = (vertexCount + i - 1) % vertexCount;
  7132. var nextIndex = i == vertexCount ? 0 : i;
  7133. isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices);
  7134. isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices);
  7135. }
  7136. if (vertexCount == 3) {
  7137. triangles.push(indices[2]);
  7138. triangles.push(indices[0]);
  7139. triangles.push(indices[1]);
  7140. }
  7141. return triangles;
  7142. };
  7143. Triangulator.prototype.decompose = function (verticesArray, triangles) {
  7144. var vertices = verticesArray;
  7145. var convexPolygons = this.convexPolygons;
  7146. this.polygonPool.freeAll(convexPolygons);
  7147. convexPolygons.length = 0;
  7148. var convexPolygonsIndices = this.convexPolygonsIndices;
  7149. this.polygonIndicesPool.freeAll(convexPolygonsIndices);
  7150. convexPolygonsIndices.length = 0;
  7151. var polygonIndices = this.polygonIndicesPool.obtain();
  7152. polygonIndices.length = 0;
  7153. var polygon = this.polygonPool.obtain();
  7154. polygon.length = 0;
  7155. var fanBaseIndex = -1, lastWinding = 0;
  7156. for (var i = 0, n = triangles.length; i < n; i += 3) {
  7157. var t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1;
  7158. var x1 = vertices[t1], y1 = vertices[t1 + 1];
  7159. var x2 = vertices[t2], y2 = vertices[t2 + 1];
  7160. var x3 = vertices[t3], y3 = vertices[t3 + 1];
  7161. var merged = false;
  7162. if (fanBaseIndex == t1) {
  7163. var o = polygon.length - 4;
  7164. var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3);
  7165. var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]);
  7166. if (winding1 == lastWinding && winding2 == lastWinding) {
  7167. polygon.push(x3);
  7168. polygon.push(y3);
  7169. polygonIndices.push(t3);
  7170. merged = true;
  7171. }
  7172. }
  7173. if (!merged) {
  7174. if (polygon.length > 0) {
  7175. convexPolygons.push(polygon);
  7176. convexPolygonsIndices.push(polygonIndices);
  7177. }
  7178. else {
  7179. this.polygonPool.free(polygon);
  7180. this.polygonIndicesPool.free(polygonIndices);
  7181. }
  7182. polygon = this.polygonPool.obtain();
  7183. polygon.length = 0;
  7184. polygon.push(x1);
  7185. polygon.push(y1);
  7186. polygon.push(x2);
  7187. polygon.push(y2);
  7188. polygon.push(x3);
  7189. polygon.push(y3);
  7190. polygonIndices = this.polygonIndicesPool.obtain();
  7191. polygonIndices.length = 0;
  7192. polygonIndices.push(t1);
  7193. polygonIndices.push(t2);
  7194. polygonIndices.push(t3);
  7195. lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3);
  7196. fanBaseIndex = t1;
  7197. }
  7198. }
  7199. if (polygon.length > 0) {
  7200. convexPolygons.push(polygon);
  7201. convexPolygonsIndices.push(polygonIndices);
  7202. }
  7203. for (var i = 0, n = convexPolygons.length; i < n; i++) {
  7204. polygonIndices = convexPolygonsIndices[i];
  7205. if (polygonIndices.length == 0)
  7206. continue;
  7207. var firstIndex = polygonIndices[0];
  7208. var lastIndex = polygonIndices[polygonIndices.length - 1];
  7209. polygon = convexPolygons[i];
  7210. var o = polygon.length - 4;
  7211. var prevPrevX = polygon[o], prevPrevY = polygon[o + 1];
  7212. var prevX = polygon[o + 2], prevY = polygon[o + 3];
  7213. var firstX = polygon[0], firstY = polygon[1];
  7214. var secondX = polygon[2], secondY = polygon[3];
  7215. var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY);
  7216. for (var ii = 0; ii < n; ii++) {
  7217. if (ii == i)
  7218. continue;
  7219. var otherIndices = convexPolygonsIndices[ii];
  7220. if (otherIndices.length != 3)
  7221. continue;
  7222. var otherFirstIndex = otherIndices[0];
  7223. var otherSecondIndex = otherIndices[1];
  7224. var otherLastIndex = otherIndices[2];
  7225. var otherPoly = convexPolygons[ii];
  7226. var x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1];
  7227. if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex)
  7228. continue;
  7229. var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3);
  7230. var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY);
  7231. if (winding1 == winding && winding2 == winding) {
  7232. otherPoly.length = 0;
  7233. otherIndices.length = 0;
  7234. polygon.push(x3);
  7235. polygon.push(y3);
  7236. polygonIndices.push(otherLastIndex);
  7237. prevPrevX = prevX;
  7238. prevPrevY = prevY;
  7239. prevX = x3;
  7240. prevY = y3;
  7241. ii = 0;
  7242. }
  7243. }
  7244. }
  7245. for (var i = convexPolygons.length - 1; i >= 0; i--) {
  7246. polygon = convexPolygons[i];
  7247. if (polygon.length == 0) {
  7248. convexPolygons.splice(i, 1);
  7249. this.polygonPool.free(polygon);
  7250. polygonIndices = convexPolygonsIndices[i];
  7251. convexPolygonsIndices.splice(i, 1);
  7252. this.polygonIndicesPool.free(polygonIndices);
  7253. }
  7254. }
  7255. return convexPolygons;
  7256. };
  7257. Triangulator.isConcave = function (index, vertexCount, vertices, indices) {
  7258. var previous = indices[(vertexCount + index - 1) % vertexCount] << 1;
  7259. var current = indices[index] << 1;
  7260. var next = indices[(index + 1) % vertexCount] << 1;
  7261. return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]);
  7262. };
  7263. Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) {
  7264. return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0;
  7265. };
  7266. Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) {
  7267. var px = p2x - p1x, py = p2y - p1y;
  7268. return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1;
  7269. };
  7270. return Triangulator;
  7271. }());
  7272. spine.Triangulator = Triangulator;
  7273. })(spine || (spine = {}));
  7274. var spine;
  7275. (function (spine) {
  7276. var IntSet = (function () {
  7277. function IntSet() {
  7278. this.array = new Array();
  7279. }
  7280. IntSet.prototype.add = function (value) {
  7281. var contains = this.contains(value);
  7282. this.array[value | 0] = value | 0;
  7283. return !contains;
  7284. };
  7285. IntSet.prototype.contains = function (value) {
  7286. return this.array[value | 0] != undefined;
  7287. };
  7288. IntSet.prototype.remove = function (value) {
  7289. this.array[value | 0] = undefined;
  7290. };
  7291. IntSet.prototype.clear = function () {
  7292. this.array.length = 0;
  7293. };
  7294. return IntSet;
  7295. }());
  7296. spine.IntSet = IntSet;
  7297. var Color = (function () {
  7298. function Color(r, g, b, a) {
  7299. if (r === void 0) { r = 0; }
  7300. if (g === void 0) { g = 0; }
  7301. if (b === void 0) { b = 0; }
  7302. if (a === void 0) { a = 0; }
  7303. this.r = r;
  7304. this.g = g;
  7305. this.b = b;
  7306. this.a = a;
  7307. }
  7308. Color.prototype.set = function (r, g, b, a) {
  7309. this.r = r;
  7310. this.g = g;
  7311. this.b = b;
  7312. this.a = a;
  7313. this.clamp();
  7314. return this;
  7315. };
  7316. Color.prototype.setFromColor = function (c) {
  7317. this.r = c.r;
  7318. this.g = c.g;
  7319. this.b = c.b;
  7320. this.a = c.a;
  7321. return this;
  7322. };
  7323. Color.prototype.setFromString = function (hex) {
  7324. hex = hex.charAt(0) == '#' ? hex.substr(1) : hex;
  7325. this.r = parseInt(hex.substr(0, 2), 16) / 255.0;
  7326. this.g = parseInt(hex.substr(2, 2), 16) / 255.0;
  7327. this.b = parseInt(hex.substr(4, 2), 16) / 255.0;
  7328. this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0;
  7329. return this;
  7330. };
  7331. Color.prototype.add = function (r, g, b, a) {
  7332. this.r += r;
  7333. this.g += g;
  7334. this.b += b;
  7335. this.a += a;
  7336. this.clamp();
  7337. return this;
  7338. };
  7339. Color.prototype.clamp = function () {
  7340. if (this.r < 0)
  7341. this.r = 0;
  7342. else if (this.r > 1)
  7343. this.r = 1;
  7344. if (this.g < 0)
  7345. this.g = 0;
  7346. else if (this.g > 1)
  7347. this.g = 1;
  7348. if (this.b < 0)
  7349. this.b = 0;
  7350. else if (this.b > 1)
  7351. this.b = 1;
  7352. if (this.a < 0)
  7353. this.a = 0;
  7354. else if (this.a > 1)
  7355. this.a = 1;
  7356. return this;
  7357. };
  7358. Color.rgba8888ToColor = function (color, value) {
  7359. color.r = ((value & 0xff000000) >>> 24) / 255;
  7360. color.g = ((value & 0x00ff0000) >>> 16) / 255;
  7361. color.b = ((value & 0x0000ff00) >>> 8) / 255;
  7362. color.a = ((value & 0x000000ff)) / 255;
  7363. };
  7364. Color.rgb888ToColor = function (color, value) {
  7365. color.r = ((value & 0x00ff0000) >>> 16) / 255;
  7366. color.g = ((value & 0x0000ff00) >>> 8) / 255;
  7367. color.b = ((value & 0x000000ff)) / 255;
  7368. };
  7369. Color.WHITE = new Color(1, 1, 1, 1);
  7370. Color.RED = new Color(1, 0, 0, 1);
  7371. Color.GREEN = new Color(0, 1, 0, 1);
  7372. Color.BLUE = new Color(0, 0, 1, 1);
  7373. Color.MAGENTA = new Color(1, 0, 1, 1);
  7374. return Color;
  7375. }());
  7376. spine.Color = Color;
  7377. var MathUtils = (function () {
  7378. function MathUtils() {
  7379. }
  7380. MathUtils.clamp = function (value, min, max) {
  7381. if (value < min)
  7382. return min;
  7383. if (value > max)
  7384. return max;
  7385. return value;
  7386. };
  7387. MathUtils.cosDeg = function (degrees) {
  7388. return Math.cos(degrees * MathUtils.degRad);
  7389. };
  7390. MathUtils.sinDeg = function (degrees) {
  7391. return Math.sin(degrees * MathUtils.degRad);
  7392. };
  7393. MathUtils.signum = function (value) {
  7394. return value > 0 ? 1 : value < 0 ? -1 : 0;
  7395. };
  7396. MathUtils.toInt = function (x) {
  7397. return x > 0 ? Math.floor(x) : Math.ceil(x);
  7398. };
  7399. MathUtils.cbrt = function (x) {
  7400. var y = Math.pow(Math.abs(x), 1 / 3);
  7401. return x < 0 ? -y : y;
  7402. };
  7403. MathUtils.randomTriangular = function (min, max) {
  7404. return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
  7405. };
  7406. MathUtils.randomTriangularWith = function (min, max, mode) {
  7407. var u = Math.random();
  7408. var d = max - min;
  7409. if (u <= (mode - min) / d)
  7410. return min + Math.sqrt(u * d * (mode - min));
  7411. return max - Math.sqrt((1 - u) * d * (max - mode));
  7412. };
  7413. MathUtils.PI = 3.1415927;
  7414. MathUtils.PI2 = MathUtils.PI * 2;
  7415. MathUtils.radiansToDegrees = 180 / MathUtils.PI;
  7416. MathUtils.radDeg = MathUtils.radiansToDegrees;
  7417. MathUtils.degreesToRadians = MathUtils.PI / 180;
  7418. MathUtils.degRad = MathUtils.degreesToRadians;
  7419. return MathUtils;
  7420. }());
  7421. spine.MathUtils = MathUtils;
  7422. var Interpolation = (function () {
  7423. function Interpolation() {
  7424. }
  7425. Interpolation.prototype.apply = function (start, end, a) {
  7426. return start + (end - start) * this.applyInternal(a);
  7427. };
  7428. return Interpolation;
  7429. }());
  7430. spine.Interpolation = Interpolation;
  7431. var Pow = (function (_super) {
  7432. __extends(Pow, _super);
  7433. function Pow(power) {
  7434. var _this = _super.call(this) || this;
  7435. _this.power = 2;
  7436. _this.power = power;
  7437. return _this;
  7438. }
  7439. Pow.prototype.applyInternal = function (a) {
  7440. if (a <= 0.5)
  7441. return Math.pow(a * 2, this.power) / 2;
  7442. return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
  7443. };
  7444. return Pow;
  7445. }(Interpolation));
  7446. spine.Pow = Pow;
  7447. var PowOut = (function (_super) {
  7448. __extends(PowOut, _super);
  7449. function PowOut(power) {
  7450. return _super.call(this, power) || this;
  7451. }
  7452. PowOut.prototype.applyInternal = function (a) {
  7453. return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
  7454. };
  7455. return PowOut;
  7456. }(Pow));
  7457. spine.PowOut = PowOut;
  7458. var Utils = (function () {
  7459. function Utils() {
  7460. }
  7461. Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) {
  7462. for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) {
  7463. dest[j] = source[i];
  7464. }
  7465. };
  7466. Utils.setArraySize = function (array, size, value) {
  7467. if (value === void 0) { value = 0; }
  7468. var oldSize = array.length;
  7469. if (oldSize == size)
  7470. return array;
  7471. array.length = size;
  7472. if (oldSize < size) {
  7473. for (var i = oldSize; i < size; i++)
  7474. array[i] = value;
  7475. }
  7476. return array;
  7477. };
  7478. Utils.ensureArrayCapacity = function (array, size, value) {
  7479. if (value === void 0) { value = 0; }
  7480. if (array.length >= size)
  7481. return array;
  7482. return Utils.setArraySize(array, size, value);
  7483. };
  7484. Utils.newArray = function (size, defaultValue) {
  7485. var array = new Array(size);
  7486. for (var i = 0; i < size; i++)
  7487. array[i] = defaultValue;
  7488. return array;
  7489. };
  7490. Utils.newFloatArray = function (size) {
  7491. if (Utils.SUPPORTS_TYPED_ARRAYS) {
  7492. return new Float32Array(size);
  7493. }
  7494. else {
  7495. var array = new Array(size);
  7496. for (var i = 0; i < array.length; i++)
  7497. array[i] = 0;
  7498. return array;
  7499. }
  7500. };
  7501. Utils.newShortArray = function (size) {
  7502. if (Utils.SUPPORTS_TYPED_ARRAYS) {
  7503. return new Int16Array(size);
  7504. }
  7505. else {
  7506. var array = new Array(size);
  7507. for (var i = 0; i < array.length; i++)
  7508. array[i] = 0;
  7509. return array;
  7510. }
  7511. };
  7512. Utils.toFloatArray = function (array) {
  7513. return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
  7514. };
  7515. Utils.toSinglePrecision = function (value) {
  7516. return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
  7517. };
  7518. Utils.webkit602BugfixHelper = function (alpha, blend) {
  7519. };
  7520. Utils.contains = function (array, element, identity) {
  7521. if (identity === void 0) { identity = true; }
  7522. for (var i = 0; i < array.length; i++) {
  7523. if (array[i] == element)
  7524. return true;
  7525. }
  7526. return false;
  7527. };
  7528. Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";
  7529. return Utils;
  7530. }());
  7531. spine.Utils = Utils;
  7532. var DebugUtils = (function () {
  7533. function DebugUtils() {
  7534. }
  7535. DebugUtils.logBones = function (skeleton) {
  7536. for (var i = 0; i < skeleton.bones.length; i++) {
  7537. var bone = skeleton.bones[i];
  7538. console.log(bone.data.name + ", " + bone.a + ", " + bone.b + ", " + bone.c + ", " + bone.d + ", " + bone.worldX + ", " + bone.worldY);
  7539. }
  7540. };
  7541. return DebugUtils;
  7542. }());
  7543. spine.DebugUtils = DebugUtils;
  7544. var Pool = (function () {
  7545. function Pool(instantiator) {
  7546. this.items = new Array();
  7547. this.instantiator = instantiator;
  7548. }
  7549. Pool.prototype.obtain = function () {
  7550. return this.items.length > 0 ? this.items.pop() : this.instantiator();
  7551. };
  7552. Pool.prototype.free = function (item) {
  7553. if (item.reset)
  7554. item.reset();
  7555. this.items.push(item);
  7556. };
  7557. Pool.prototype.freeAll = function (items) {
  7558. for (var i = 0; i < items.length; i++) {
  7559. this.free(items[i]);
  7560. }
  7561. };
  7562. Pool.prototype.clear = function () {
  7563. this.items.length = 0;
  7564. };
  7565. return Pool;
  7566. }());
  7567. spine.Pool = Pool;
  7568. var Vector2 = (function () {
  7569. function Vector2(x, y) {
  7570. if (x === void 0) { x = 0; }
  7571. if (y === void 0) { y = 0; }
  7572. this.x = x;
  7573. this.y = y;
  7574. }
  7575. Vector2.prototype.set = function (x, y) {
  7576. this.x = x;
  7577. this.y = y;
  7578. return this;
  7579. };
  7580. Vector2.prototype.length = function () {
  7581. var x = this.x;
  7582. var y = this.y;
  7583. return Math.sqrt(x * x + y * y);
  7584. };
  7585. Vector2.prototype.normalize = function () {
  7586. var len = this.length();
  7587. if (len != 0) {
  7588. this.x /= len;
  7589. this.y /= len;
  7590. }
  7591. return this;
  7592. };
  7593. return Vector2;
  7594. }());
  7595. spine.Vector2 = Vector2;
  7596. var TimeKeeper = (function () {
  7597. function TimeKeeper() {
  7598. this.maxDelta = 0.064;
  7599. this.framesPerSecond = 0;
  7600. this.delta = 0;
  7601. this.totalTime = 0;
  7602. this.lastTime = Date.now() / 1000;
  7603. this.frameCount = 0;
  7604. this.frameTime = 0;
  7605. }
  7606. TimeKeeper.prototype.update = function () {
  7607. var now = Date.now() / 1000;
  7608. this.delta = now - this.lastTime;
  7609. this.frameTime += this.delta;
  7610. this.totalTime += this.delta;
  7611. if (this.delta > this.maxDelta)
  7612. this.delta = this.maxDelta;
  7613. this.lastTime = now;
  7614. this.frameCount++;
  7615. if (this.frameTime > 1) {
  7616. this.framesPerSecond = this.frameCount / this.frameTime;
  7617. this.frameTime = 0;
  7618. this.frameCount = 0;
  7619. }
  7620. };
  7621. return TimeKeeper;
  7622. }());
  7623. spine.TimeKeeper = TimeKeeper;
  7624. var WindowedMean = (function () {
  7625. function WindowedMean(windowSize) {
  7626. if (windowSize === void 0) { windowSize = 32; }
  7627. this.addedValues = 0;
  7628. this.lastValue = 0;
  7629. this.mean = 0;
  7630. this.dirty = true;
  7631. this.values = new Array(windowSize);
  7632. }
  7633. WindowedMean.prototype.hasEnoughData = function () {
  7634. return this.addedValues >= this.values.length;
  7635. };
  7636. WindowedMean.prototype.addValue = function (value) {
  7637. if (this.addedValues < this.values.length)
  7638. this.addedValues++;
  7639. this.values[this.lastValue++] = value;
  7640. if (this.lastValue > this.values.length - 1)
  7641. this.lastValue = 0;
  7642. this.dirty = true;
  7643. };
  7644. WindowedMean.prototype.getMean = function () {
  7645. if (this.hasEnoughData()) {
  7646. if (this.dirty) {
  7647. var mean = 0;
  7648. for (var i = 0; i < this.values.length; i++) {
  7649. mean += this.values[i];
  7650. }
  7651. this.mean = mean / this.values.length;
  7652. this.dirty = false;
  7653. }
  7654. return this.mean;
  7655. }
  7656. else {
  7657. return 0;
  7658. }
  7659. };
  7660. return WindowedMean;
  7661. }());
  7662. spine.WindowedMean = WindowedMean;
  7663. })(spine || (spine = {}));
  7664. (function () {
  7665. if (!Math.fround) {
  7666. Math.fround = (function (array) {
  7667. return function (x) {
  7668. return array[0] = x, array[0];
  7669. };
  7670. })(new Float32Array(1));
  7671. }
  7672. })();
  7673. var spine;
  7674. (function (spine) {
  7675. var Attachment = (function () {
  7676. function Attachment(name) {
  7677. if (name == null)
  7678. throw new Error("name cannot be null.");
  7679. this.name = name;
  7680. }
  7681. return Attachment;
  7682. }());
  7683. spine.Attachment = Attachment;
  7684. var VertexAttachment = (function (_super) {
  7685. __extends(VertexAttachment, _super);
  7686. function VertexAttachment(name) {
  7687. var _this = _super.call(this, name) || this;
  7688. _this.id = (VertexAttachment.nextID++ & 65535) << 11;
  7689. _this.worldVerticesLength = 0;
  7690. _this.deformAttachment = _this;
  7691. return _this;
  7692. }
  7693. VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
  7694. count = offset + (count >> 1) * stride;
  7695. var skeleton = slot.bone.skeleton;
  7696. var deformArray = slot.deform;
  7697. var vertices = this.vertices;
  7698. var bones = this.bones;
  7699. if (bones == null) {
  7700. if (deformArray.length > 0)
  7701. vertices = deformArray;
  7702. var bone = slot.bone;
  7703. var x = bone.worldX;
  7704. var y = bone.worldY;
  7705. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  7706. for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) {
  7707. var vx = vertices[v_1], vy = vertices[v_1 + 1];
  7708. worldVertices[w] = vx * a + vy * b + x;
  7709. worldVertices[w + 1] = vx * c + vy * d + y;
  7710. }
  7711. return;
  7712. }
  7713. var v = 0, skip = 0;
  7714. for (var i = 0; i < start; i += 2) {
  7715. var n = bones[v];
  7716. v += n + 1;
  7717. skip += n;
  7718. }
  7719. var skeletonBones = skeleton.bones;
  7720. if (deformArray.length == 0) {
  7721. for (var w = offset, b = skip * 3; w < count; w += stride) {
  7722. var wx = 0, wy = 0;
  7723. var n = bones[v++];
  7724. n += v;
  7725. for (; v < n; v++, b += 3) {
  7726. var bone = skeletonBones[bones[v]];
  7727. var vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2];
  7728. wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
  7729. wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
  7730. }
  7731. worldVertices[w] = wx;
  7732. worldVertices[w + 1] = wy;
  7733. }
  7734. }
  7735. else {
  7736. var deform = deformArray;
  7737. for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) {
  7738. var wx = 0, wy = 0;
  7739. var n = bones[v++];
  7740. n += v;
  7741. for (; v < n; v++, b += 3, f += 2) {
  7742. var bone = skeletonBones[bones[v]];
  7743. var vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2];
  7744. wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
  7745. wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
  7746. }
  7747. worldVertices[w] = wx;
  7748. worldVertices[w + 1] = wy;
  7749. }
  7750. }
  7751. };
  7752. VertexAttachment.prototype.copyTo = function (attachment) {
  7753. if (this.bones != null) {
  7754. attachment.bones = new Array(this.bones.length);
  7755. spine.Utils.arrayCopy(this.bones, 0, attachment.bones, 0, this.bones.length);
  7756. }
  7757. else
  7758. attachment.bones = null;
  7759. if (this.vertices != null) {
  7760. attachment.vertices = spine.Utils.newFloatArray(this.vertices.length);
  7761. spine.Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length);
  7762. }
  7763. else
  7764. attachment.vertices = null;
  7765. attachment.worldVerticesLength = this.worldVerticesLength;
  7766. attachment.deformAttachment = this.deformAttachment;
  7767. };
  7768. VertexAttachment.nextID = 0;
  7769. return VertexAttachment;
  7770. }(Attachment));
  7771. spine.VertexAttachment = VertexAttachment;
  7772. })(spine || (spine = {}));
  7773. var spine;
  7774. (function (spine) {
  7775. var AttachmentType;
  7776. (function (AttachmentType) {
  7777. AttachmentType[AttachmentType["Region"] = 0] = "Region";
  7778. AttachmentType[AttachmentType["BoundingBox"] = 1] = "BoundingBox";
  7779. AttachmentType[AttachmentType["Mesh"] = 2] = "Mesh";
  7780. AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh";
  7781. AttachmentType[AttachmentType["Path"] = 4] = "Path";
  7782. AttachmentType[AttachmentType["Point"] = 5] = "Point";
  7783. AttachmentType[AttachmentType["Clipping"] = 6] = "Clipping";
  7784. })(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {}));
  7785. })(spine || (spine = {}));
  7786. var spine;
  7787. (function (spine) {
  7788. var BoundingBoxAttachment = (function (_super) {
  7789. __extends(BoundingBoxAttachment, _super);
  7790. function BoundingBoxAttachment(name) {
  7791. var _this = _super.call(this, name) || this;
  7792. _this.color = new spine.Color(1, 1, 1, 1);
  7793. return _this;
  7794. }
  7795. BoundingBoxAttachment.prototype.copy = function () {
  7796. var copy = new BoundingBoxAttachment(this.name);
  7797. this.copyTo(copy);
  7798. copy.color.setFromColor(this.color);
  7799. return copy;
  7800. };
  7801. return BoundingBoxAttachment;
  7802. }(spine.VertexAttachment));
  7803. spine.BoundingBoxAttachment = BoundingBoxAttachment;
  7804. })(spine || (spine = {}));
  7805. var spine;
  7806. (function (spine) {
  7807. var ClippingAttachment = (function (_super) {
  7808. __extends(ClippingAttachment, _super);
  7809. function ClippingAttachment(name) {
  7810. var _this = _super.call(this, name) || this;
  7811. _this.color = new spine.Color(0.2275, 0.2275, 0.8078, 1);
  7812. return _this;
  7813. }
  7814. ClippingAttachment.prototype.copy = function () {
  7815. var copy = new ClippingAttachment(this.name);
  7816. this.copyTo(copy);
  7817. copy.endSlot = this.endSlot;
  7818. copy.color.setFromColor(this.color);
  7819. return copy;
  7820. };
  7821. return ClippingAttachment;
  7822. }(spine.VertexAttachment));
  7823. spine.ClippingAttachment = ClippingAttachment;
  7824. })(spine || (spine = {}));
  7825. var spine;
  7826. (function (spine) {
  7827. var MeshAttachment = (function (_super) {
  7828. __extends(MeshAttachment, _super);
  7829. function MeshAttachment(name) {
  7830. var _this = _super.call(this, name) || this;
  7831. _this.color = new spine.Color(1, 1, 1, 1);
  7832. _this.tempColor = new spine.Color(0, 0, 0, 0);
  7833. return _this;
  7834. }
  7835. MeshAttachment.prototype.updateUVs = function () {
  7836. var regionUVs = this.regionUVs;
  7837. if (this.uvs == null || this.uvs.length != regionUVs.length)
  7838. this.uvs = spine.Utils.newFloatArray(regionUVs.length);
  7839. var uvs = this.uvs;
  7840. var n = this.uvs.length;
  7841. var u = this.region.u, v = this.region.v, width = 0, height = 0;
  7842. if (this.region instanceof spine.TextureAtlasRegion) {
  7843. var region = this.region;
  7844. var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
  7845. switch (region.degrees) {
  7846. case 90:
  7847. u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
  7848. v -= (region.originalWidth - region.offsetX - region.width) / textureHeight;
  7849. width = region.originalHeight / textureWidth;
  7850. height = region.originalWidth / textureHeight;
  7851. for (var i = 0; i < n; i += 2) {
  7852. uvs[i] = u + regionUVs[i + 1] * width;
  7853. uvs[i + 1] = v + (1 - regionUVs[i]) * height;
  7854. }
  7855. return;
  7856. case 180:
  7857. u -= (region.originalWidth - region.offsetX - region.width) / textureWidth;
  7858. v -= region.offsetY / textureHeight;
  7859. width = region.originalWidth / textureWidth;
  7860. height = region.originalHeight / textureHeight;
  7861. for (var i = 0; i < n; i += 2) {
  7862. uvs[i] = u + (1 - regionUVs[i]) * width;
  7863. uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
  7864. }
  7865. return;
  7866. case 270:
  7867. u -= region.offsetY / textureWidth;
  7868. v -= region.offsetX / textureHeight;
  7869. width = region.originalHeight / textureWidth;
  7870. height = region.originalWidth / textureHeight;
  7871. for (var i = 0; i < n; i += 2) {
  7872. uvs[i] = u + (1 - regionUVs[i + 1]) * width;
  7873. uvs[i + 1] = v + regionUVs[i] * height;
  7874. }
  7875. return;
  7876. }
  7877. u -= region.offsetX / textureWidth;
  7878. v -= (region.originalHeight - region.offsetY - region.height) / textureHeight;
  7879. width = region.originalWidth / textureWidth;
  7880. height = region.originalHeight / textureHeight;
  7881. }
  7882. else if (this.region == null) {
  7883. u = v = 0;
  7884. width = height = 1;
  7885. }
  7886. else {
  7887. width = this.region.u2 - u;
  7888. height = this.region.v2 - v;
  7889. }
  7890. for (var i = 0; i < n; i += 2) {
  7891. uvs[i] = u + regionUVs[i] * width;
  7892. uvs[i + 1] = v + regionUVs[i + 1] * height;
  7893. }
  7894. };
  7895. MeshAttachment.prototype.getParentMesh = function () {
  7896. return this.parentMesh;
  7897. };
  7898. MeshAttachment.prototype.setParentMesh = function (parentMesh) {
  7899. this.parentMesh = parentMesh;
  7900. if (parentMesh != null) {
  7901. this.bones = parentMesh.bones;
  7902. this.vertices = parentMesh.vertices;
  7903. this.worldVerticesLength = parentMesh.worldVerticesLength;
  7904. this.regionUVs = parentMesh.regionUVs;
  7905. this.triangles = parentMesh.triangles;
  7906. this.hullLength = parentMesh.hullLength;
  7907. this.worldVerticesLength = parentMesh.worldVerticesLength;
  7908. }
  7909. };
  7910. MeshAttachment.prototype.copy = function () {
  7911. if (this.parentMesh != null)
  7912. return this.newLinkedMesh();
  7913. var copy = new MeshAttachment(this.name);
  7914. copy.region = this.region;
  7915. copy.path = this.path;
  7916. copy.color.setFromColor(this.color);
  7917. this.copyTo(copy);
  7918. copy.regionUVs = new Array(this.regionUVs.length);
  7919. spine.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
  7920. copy.uvs = new Array(this.uvs.length);
  7921. spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
  7922. copy.triangles = new Array(this.triangles.length);
  7923. spine.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
  7924. copy.hullLength = this.hullLength;
  7925. if (this.edges != null) {
  7926. copy.edges = new Array(this.edges.length);
  7927. spine.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
  7928. }
  7929. copy.width = this.width;
  7930. copy.height = this.height;
  7931. return copy;
  7932. };
  7933. MeshAttachment.prototype.newLinkedMesh = function () {
  7934. var copy = new MeshAttachment(this.name);
  7935. copy.region = this.region;
  7936. copy.path = this.path;
  7937. copy.color.setFromColor(this.color);
  7938. copy.deformAttachment = this.deformAttachment;
  7939. copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
  7940. copy.updateUVs();
  7941. return copy;
  7942. };
  7943. return MeshAttachment;
  7944. }(spine.VertexAttachment));
  7945. spine.MeshAttachment = MeshAttachment;
  7946. })(spine || (spine = {}));
  7947. var spine;
  7948. (function (spine) {
  7949. var PathAttachment = (function (_super) {
  7950. __extends(PathAttachment, _super);
  7951. function PathAttachment(name) {
  7952. var _this = _super.call(this, name) || this;
  7953. _this.closed = false;
  7954. _this.constantSpeed = false;
  7955. _this.color = new spine.Color(1, 1, 1, 1);
  7956. return _this;
  7957. }
  7958. PathAttachment.prototype.copy = function () {
  7959. var copy = new PathAttachment(this.name);
  7960. this.copyTo(copy);
  7961. copy.lengths = new Array(this.lengths.length);
  7962. spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
  7963. copy.closed = closed;
  7964. copy.constantSpeed = this.constantSpeed;
  7965. copy.color.setFromColor(this.color);
  7966. return copy;
  7967. };
  7968. return PathAttachment;
  7969. }(spine.VertexAttachment));
  7970. spine.PathAttachment = PathAttachment;
  7971. })(spine || (spine = {}));
  7972. var spine;
  7973. (function (spine) {
  7974. var PointAttachment = (function (_super) {
  7975. __extends(PointAttachment, _super);
  7976. function PointAttachment(name) {
  7977. var _this = _super.call(this, name) || this;
  7978. _this.color = new spine.Color(0.38, 0.94, 0, 1);
  7979. return _this;
  7980. }
  7981. PointAttachment.prototype.computeWorldPosition = function (bone, point) {
  7982. point.x = this.x * bone.a + this.y * bone.b + bone.worldX;
  7983. point.y = this.x * bone.c + this.y * bone.d + bone.worldY;
  7984. return point;
  7985. };
  7986. PointAttachment.prototype.computeWorldRotation = function (bone) {
  7987. var cos = spine.MathUtils.cosDeg(this.rotation), sin = spine.MathUtils.sinDeg(this.rotation);
  7988. var x = cos * bone.a + sin * bone.b;
  7989. var y = cos * bone.c + sin * bone.d;
  7990. return Math.atan2(y, x) * spine.MathUtils.radDeg;
  7991. };
  7992. PointAttachment.prototype.copy = function () {
  7993. var copy = new PointAttachment(this.name);
  7994. copy.x = this.x;
  7995. copy.y = this.y;
  7996. copy.rotation = this.rotation;
  7997. copy.color.setFromColor(this.color);
  7998. return copy;
  7999. };
  8000. return PointAttachment;
  8001. }(spine.VertexAttachment));
  8002. spine.PointAttachment = PointAttachment;
  8003. })(spine || (spine = {}));
  8004. var spine;
  8005. (function (spine) {
  8006. var RegionAttachment = (function (_super) {
  8007. __extends(RegionAttachment, _super);
  8008. function RegionAttachment(name) {
  8009. var _this = _super.call(this, name) || this;
  8010. _this.x = 0;
  8011. _this.y = 0;
  8012. _this.scaleX = 1;
  8013. _this.scaleY = 1;
  8014. _this.rotation = 0;
  8015. _this.width = 0;
  8016. _this.height = 0;
  8017. _this.color = new spine.Color(1, 1, 1, 1);
  8018. _this.offset = spine.Utils.newFloatArray(8);
  8019. _this.uvs = spine.Utils.newFloatArray(8);
  8020. _this.tempColor = new spine.Color(1, 1, 1, 1);
  8021. return _this;
  8022. }
  8023. RegionAttachment.prototype.updateOffset = function () {
  8024. var regionScaleX = this.width / this.region.originalWidth * this.scaleX;
  8025. var regionScaleY = this.height / this.region.originalHeight * this.scaleY;
  8026. var localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX;
  8027. var localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY;
  8028. var localX2 = localX + this.region.width * regionScaleX;
  8029. var localY2 = localY + this.region.height * regionScaleY;
  8030. var radians = this.rotation * Math.PI / 180;
  8031. var cos = Math.cos(radians);
  8032. var sin = Math.sin(radians);
  8033. var localXCos = localX * cos + this.x;
  8034. var localXSin = localX * sin;
  8035. var localYCos = localY * cos + this.y;
  8036. var localYSin = localY * sin;
  8037. var localX2Cos = localX2 * cos + this.x;
  8038. var localX2Sin = localX2 * sin;
  8039. var localY2Cos = localY2 * cos + this.y;
  8040. var localY2Sin = localY2 * sin;
  8041. var offset = this.offset;
  8042. offset[RegionAttachment.OX1] = localXCos - localYSin;
  8043. offset[RegionAttachment.OY1] = localYCos + localXSin;
  8044. offset[RegionAttachment.OX2] = localXCos - localY2Sin;
  8045. offset[RegionAttachment.OY2] = localY2Cos + localXSin;
  8046. offset[RegionAttachment.OX3] = localX2Cos - localY2Sin;
  8047. offset[RegionAttachment.OY3] = localY2Cos + localX2Sin;
  8048. offset[RegionAttachment.OX4] = localX2Cos - localYSin;
  8049. offset[RegionAttachment.OY4] = localYCos + localX2Sin;
  8050. };
  8051. RegionAttachment.prototype.setRegion = function (region) {
  8052. this.region = region;
  8053. var uvs = this.uvs;
  8054. if (region.rotate) {
  8055. uvs[2] = region.u;
  8056. uvs[3] = region.v2;
  8057. uvs[4] = region.u;
  8058. uvs[5] = region.v;
  8059. uvs[6] = region.u2;
  8060. uvs[7] = region.v;
  8061. uvs[0] = region.u2;
  8062. uvs[1] = region.v2;
  8063. }
  8064. else {
  8065. uvs[0] = region.u;
  8066. uvs[1] = region.v2;
  8067. uvs[2] = region.u;
  8068. uvs[3] = region.v;
  8069. uvs[4] = region.u2;
  8070. uvs[5] = region.v;
  8071. uvs[6] = region.u2;
  8072. uvs[7] = region.v2;
  8073. }
  8074. };
  8075. RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) {
  8076. var vertexOffset = this.offset;
  8077. var x = bone.worldX, y = bone.worldY;
  8078. var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
  8079. var offsetX = 0, offsetY = 0;
  8080. offsetX = vertexOffset[RegionAttachment.OX1];
  8081. offsetY = vertexOffset[RegionAttachment.OY1];
  8082. worldVertices[offset] = offsetX * a + offsetY * b + x;
  8083. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  8084. offset += stride;
  8085. offsetX = vertexOffset[RegionAttachment.OX2];
  8086. offsetY = vertexOffset[RegionAttachment.OY2];
  8087. worldVertices[offset] = offsetX * a + offsetY * b + x;
  8088. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  8089. offset += stride;
  8090. offsetX = vertexOffset[RegionAttachment.OX3];
  8091. offsetY = vertexOffset[RegionAttachment.OY3];
  8092. worldVertices[offset] = offsetX * a + offsetY * b + x;
  8093. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  8094. offset += stride;
  8095. offsetX = vertexOffset[RegionAttachment.OX4];
  8096. offsetY = vertexOffset[RegionAttachment.OY4];
  8097. worldVertices[offset] = offsetX * a + offsetY * b + x;
  8098. worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
  8099. };
  8100. RegionAttachment.prototype.copy = function () {
  8101. var copy = new RegionAttachment(this.name);
  8102. copy.region = this.region;
  8103. copy.rendererObject = this.rendererObject;
  8104. copy.path = this.path;
  8105. copy.x = this.x;
  8106. copy.y = this.y;
  8107. copy.scaleX = this.scaleX;
  8108. copy.scaleY = this.scaleY;
  8109. copy.rotation = this.rotation;
  8110. copy.width = this.width;
  8111. copy.height = this.height;
  8112. spine.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, 8);
  8113. spine.Utils.arrayCopy(this.offset, 0, copy.offset, 0, 8);
  8114. copy.color.setFromColor(this.color);
  8115. return copy;
  8116. };
  8117. RegionAttachment.OX1 = 0;
  8118. RegionAttachment.OY1 = 1;
  8119. RegionAttachment.OX2 = 2;
  8120. RegionAttachment.OY2 = 3;
  8121. RegionAttachment.OX3 = 4;
  8122. RegionAttachment.OY3 = 5;
  8123. RegionAttachment.OX4 = 6;
  8124. RegionAttachment.OY4 = 7;
  8125. RegionAttachment.X1 = 0;
  8126. RegionAttachment.Y1 = 1;
  8127. RegionAttachment.C1R = 2;
  8128. RegionAttachment.C1G = 3;
  8129. RegionAttachment.C1B = 4;
  8130. RegionAttachment.C1A = 5;
  8131. RegionAttachment.U1 = 6;
  8132. RegionAttachment.V1 = 7;
  8133. RegionAttachment.X2 = 8;
  8134. RegionAttachment.Y2 = 9;
  8135. RegionAttachment.C2R = 10;
  8136. RegionAttachment.C2G = 11;
  8137. RegionAttachment.C2B = 12;
  8138. RegionAttachment.C2A = 13;
  8139. RegionAttachment.U2 = 14;
  8140. RegionAttachment.V2 = 15;
  8141. RegionAttachment.X3 = 16;
  8142. RegionAttachment.Y3 = 17;
  8143. RegionAttachment.C3R = 18;
  8144. RegionAttachment.C3G = 19;
  8145. RegionAttachment.C3B = 20;
  8146. RegionAttachment.C3A = 21;
  8147. RegionAttachment.U3 = 22;
  8148. RegionAttachment.V3 = 23;
  8149. RegionAttachment.X4 = 24;
  8150. RegionAttachment.Y4 = 25;
  8151. RegionAttachment.C4R = 26;
  8152. RegionAttachment.C4G = 27;
  8153. RegionAttachment.C4B = 28;
  8154. RegionAttachment.C4A = 29;
  8155. RegionAttachment.U4 = 30;
  8156. RegionAttachment.V4 = 31;
  8157. return RegionAttachment;
  8158. }(spine.Attachment));
  8159. spine.RegionAttachment = RegionAttachment;
  8160. })(spine || (spine = {}));
  8161. var spine;
  8162. (function (spine) {
  8163. var JitterEffect = (function () {
  8164. function JitterEffect(jitterX, jitterY) {
  8165. this.jitterX = 0;
  8166. this.jitterY = 0;
  8167. this.jitterX = jitterX;
  8168. this.jitterY = jitterY;
  8169. }
  8170. JitterEffect.prototype.begin = function (skeleton) {
  8171. };
  8172. JitterEffect.prototype.transform = function (position, uv, light, dark) {
  8173. position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
  8174. position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
  8175. };
  8176. JitterEffect.prototype.end = function () {
  8177. };
  8178. return JitterEffect;
  8179. }());
  8180. spine.JitterEffect = JitterEffect;
  8181. })(spine || (spine = {}));
  8182. var spine;
  8183. (function (spine) {
  8184. var SwirlEffect = (function () {
  8185. function SwirlEffect(radius) {
  8186. this.centerX = 0;
  8187. this.centerY = 0;
  8188. this.radius = 0;
  8189. this.angle = 0;
  8190. this.worldX = 0;
  8191. this.worldY = 0;
  8192. this.radius = radius;
  8193. }
  8194. SwirlEffect.prototype.begin = function (skeleton) {
  8195. this.worldX = skeleton.x + this.centerX;
  8196. this.worldY = skeleton.y + this.centerY;
  8197. };
  8198. SwirlEffect.prototype.transform = function (position, uv, light, dark) {
  8199. var radAngle = this.angle * spine.MathUtils.degreesToRadians;
  8200. var x = position.x - this.worldX;
  8201. var y = position.y - this.worldY;
  8202. var dist = Math.sqrt(x * x + y * y);
  8203. if (dist < this.radius) {
  8204. var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
  8205. var cos = Math.cos(theta);
  8206. var sin = Math.sin(theta);
  8207. position.x = cos * x - sin * y + this.worldX;
  8208. position.y = sin * x + cos * y + this.worldY;
  8209. }
  8210. };
  8211. SwirlEffect.prototype.end = function () {
  8212. };
  8213. SwirlEffect.interpolation = new spine.PowOut(2);
  8214. return SwirlEffect;
  8215. }());
  8216. spine.SwirlEffect = SwirlEffect;
  8217. })(spine || (spine = {}));
  8218. var spine;
  8219. (function (spine) {
  8220. var webgl;
  8221. (function (webgl) {
  8222. var AssetManager = (function (_super) {
  8223. __extends(AssetManager, _super);
  8224. function AssetManager(context, pathPrefix) {
  8225. if (pathPrefix === void 0) { pathPrefix = ""; }
  8226. return _super.call(this, function (image) {
  8227. return new spine.webgl.GLTexture(context, image);
  8228. }, pathPrefix) || this;
  8229. }
  8230. return AssetManager;
  8231. }(spine.AssetManager));
  8232. webgl.AssetManager = AssetManager;
  8233. })(webgl = spine.webgl || (spine.webgl = {}));
  8234. })(spine || (spine = {}));
  8235. var spine;
  8236. (function (spine) {
  8237. var webgl;
  8238. (function (webgl) {
  8239. var OrthoCamera = (function () {
  8240. function OrthoCamera(viewportWidth, viewportHeight) {
  8241. this.position = new webgl.Vector3(0, 0, 0);
  8242. this.direction = new webgl.Vector3(0, 0, -1);
  8243. this.up = new webgl.Vector3(0, 1, 0);
  8244. this.near = 0;
  8245. this.far = 100;
  8246. this.zoom = 1;
  8247. this.viewportWidth = 0;
  8248. this.viewportHeight = 0;
  8249. this.projectionView = new webgl.Matrix4();
  8250. this.inverseProjectionView = new webgl.Matrix4();
  8251. this.projection = new webgl.Matrix4();
  8252. this.view = new webgl.Matrix4();
  8253. this.tmp = new webgl.Vector3();
  8254. this.viewportWidth = viewportWidth;
  8255. this.viewportHeight = viewportHeight;
  8256. this.update();
  8257. }
  8258. OrthoCamera.prototype.update = function () {
  8259. var projection = this.projection;
  8260. var view = this.view;
  8261. var projectionView = this.projectionView;
  8262. var inverseProjectionView = this.inverseProjectionView;
  8263. var zoom = this.zoom, viewportWidth = this.viewportWidth, viewportHeight = this.viewportHeight;
  8264. projection.ortho(zoom * (-viewportWidth / 2), zoom * (viewportWidth / 2), zoom * (-viewportHeight / 2), zoom * (viewportHeight / 2), this.near, this.far);
  8265. view.lookAt(this.position, this.direction, this.up);
  8266. projectionView.set(projection.values);
  8267. projectionView.multiply(view);
  8268. inverseProjectionView.set(projectionView.values).invert();
  8269. };
  8270. OrthoCamera.prototype.screenToWorld = function (screenCoords, screenWidth, screenHeight) {
  8271. var x = screenCoords.x, y = screenHeight - screenCoords.y - 1;
  8272. var tmp = this.tmp;
  8273. tmp.x = (2 * x) / screenWidth - 1;
  8274. tmp.y = (2 * y) / screenHeight - 1;
  8275. tmp.z = (2 * screenCoords.z) - 1;
  8276. tmp.project(this.inverseProjectionView);
  8277. screenCoords.set(tmp.x, tmp.y, tmp.z);
  8278. return screenCoords;
  8279. };
  8280. OrthoCamera.prototype.setViewport = function (viewportWidth, viewportHeight) {
  8281. this.viewportWidth = viewportWidth;
  8282. this.viewportHeight = viewportHeight;
  8283. };
  8284. return OrthoCamera;
  8285. }());
  8286. webgl.OrthoCamera = OrthoCamera;
  8287. })(webgl = spine.webgl || (spine.webgl = {}));
  8288. })(spine || (spine = {}));
  8289. var spine;
  8290. (function (spine) {
  8291. var webgl;
  8292. (function (webgl) {
  8293. var GLTexture = (function (_super) {
  8294. __extends(GLTexture, _super);
  8295. function GLTexture(context, image, useMipMaps) {
  8296. if (useMipMaps === void 0) { useMipMaps = false; }
  8297. var _this = _super.call(this, image) || this;
  8298. _this.texture = null;
  8299. _this.boundUnit = 0;
  8300. _this.useMipMaps = false;
  8301. _this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  8302. _this.useMipMaps = useMipMaps;
  8303. _this.restore();
  8304. _this.context.addRestorable(_this);
  8305. return _this;
  8306. }
  8307. GLTexture.prototype.setFilters = function (minFilter, magFilter) {
  8308. var gl = this.context.gl;
  8309. this.bind();
  8310. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
  8311. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, GLTexture.validateMagFilter(magFilter));
  8312. };
  8313. GLTexture.validateMagFilter = function (magFilter) {
  8314. switch (magFilter) {
  8315. case spine.TextureFilter.MipMap:
  8316. case spine.TextureFilter.MipMapLinearLinear:
  8317. case spine.TextureFilter.MipMapLinearNearest:
  8318. case spine.TextureFilter.MipMapNearestLinear:
  8319. case spine.TextureFilter.MipMapNearestNearest:
  8320. return spine.TextureFilter.Linear;
  8321. default:
  8322. return magFilter;
  8323. }
  8324. };
  8325. GLTexture.prototype.setWraps = function (uWrap, vWrap) {
  8326. var gl = this.context.gl;
  8327. this.bind();
  8328. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
  8329. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
  8330. };
  8331. GLTexture.prototype.update = function (useMipMaps) {
  8332. var gl = this.context.gl;
  8333. if (!this.texture) {
  8334. this.texture = this.context.gl.createTexture();
  8335. }
  8336. this.bind();
  8337. if (GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL)
  8338. gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
  8339. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
  8340. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  8341. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  8342. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  8343. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  8344. if (useMipMaps)
  8345. gl.generateMipmap(gl.TEXTURE_2D);
  8346. };
  8347. GLTexture.prototype.restore = function () {
  8348. this.texture = null;
  8349. this.update(this.useMipMaps);
  8350. };
  8351. GLTexture.prototype.bind = function (unit) {
  8352. if (unit === void 0) { unit = 0; }
  8353. var gl = this.context.gl;
  8354. this.boundUnit = unit;
  8355. gl.activeTexture(gl.TEXTURE0 + unit);
  8356. gl.bindTexture(gl.TEXTURE_2D, this.texture);
  8357. };
  8358. GLTexture.prototype.unbind = function () {
  8359. var gl = this.context.gl;
  8360. gl.activeTexture(gl.TEXTURE0 + this.boundUnit);
  8361. gl.bindTexture(gl.TEXTURE_2D, null);
  8362. };
  8363. GLTexture.prototype.dispose = function () {
  8364. this.context.removeRestorable(this);
  8365. var gl = this.context.gl;
  8366. gl.deleteTexture(this.texture);
  8367. };
  8368. GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL = false;
  8369. return GLTexture;
  8370. }(spine.Texture));
  8371. webgl.GLTexture = GLTexture;
  8372. })(webgl = spine.webgl || (spine.webgl = {}));
  8373. })(spine || (spine = {}));
  8374. var spine;
  8375. (function (spine) {
  8376. var webgl;
  8377. (function (webgl) {
  8378. var Input = (function () {
  8379. function Input(element) {
  8380. this.lastX = 0;
  8381. this.lastY = 0;
  8382. this.buttonDown = false;
  8383. this.currTouch = null;
  8384. this.touchesPool = new spine.Pool(function () {
  8385. return new spine.webgl.Touch(0, 0, 0);
  8386. });
  8387. this.listeners = new Array();
  8388. this.element = element;
  8389. this.setupCallbacks(element);
  8390. }
  8391. Input.prototype.setupCallbacks = function (element) {
  8392. var _this = this;
  8393. var mouseDown = function (ev) {
  8394. if (ev instanceof MouseEvent) {
  8395. var rect = element.getBoundingClientRect();
  8396. var x = ev.clientX - rect.left;
  8397. var y = ev.clientY - rect.top;
  8398. var listeners = _this.listeners;
  8399. for (var i = 0; i < listeners.length; i++) {
  8400. if (listeners[i].down)
  8401. listeners[i].down(x, y);
  8402. }
  8403. _this.lastX = x;
  8404. _this.lastY = y;
  8405. _this.buttonDown = true;
  8406. document.addEventListener("mousemove", mouseMove);
  8407. document.addEventListener("mouseup", mouseUp);
  8408. }
  8409. };
  8410. var mouseMove = function (ev) {
  8411. if (ev instanceof MouseEvent) {
  8412. var rect = element.getBoundingClientRect();
  8413. var x = ev.clientX - rect.left;
  8414. var y = ev.clientY - rect.top;
  8415. var listeners = _this.listeners;
  8416. for (var i = 0; i < listeners.length; i++) {
  8417. if (_this.buttonDown) {
  8418. if (listeners[i].dragged)
  8419. listeners[i].dragged(x, y);
  8420. }
  8421. else {
  8422. if (listeners[i].moved)
  8423. listeners[i].moved(x, y);
  8424. }
  8425. }
  8426. _this.lastX = x;
  8427. _this.lastY = y;
  8428. }
  8429. };
  8430. var mouseUp = function (ev) {
  8431. if (ev instanceof MouseEvent) {
  8432. var rect = element.getBoundingClientRect();
  8433. var x = ev.clientX - rect.left;
  8434. var y = ev.clientY - rect.top;
  8435. var listeners = _this.listeners;
  8436. for (var i = 0; i < listeners.length; i++) {
  8437. if (listeners[i].up)
  8438. listeners[i].up(x, y);
  8439. }
  8440. _this.lastX = x;
  8441. _this.lastY = y;
  8442. _this.buttonDown = false;
  8443. document.removeEventListener("mousemove", mouseMove);
  8444. document.removeEventListener("mouseup", mouseUp);
  8445. }
  8446. };
  8447. element.addEventListener("mousedown", mouseDown, true);
  8448. element.addEventListener("mousemove", mouseMove, true);
  8449. element.addEventListener("mouseup", mouseUp, true);
  8450. element.addEventListener("touchstart", function (ev) {
  8451. if (_this.currTouch != null)
  8452. return;
  8453. var touches = ev.changedTouches;
  8454. for (var i = 0; i < touches.length; i++) {
  8455. var touch = touches[i];
  8456. var rect = element.getBoundingClientRect();
  8457. var x = touch.clientX - rect.left;
  8458. var y = touch.clientY - rect.top;
  8459. _this.currTouch = _this.touchesPool.obtain();
  8460. _this.currTouch.identifier = touch.identifier;
  8461. _this.currTouch.x = x;
  8462. _this.currTouch.y = y;
  8463. break;
  8464. }
  8465. var listeners = _this.listeners;
  8466. for (var i_17 = 0; i_17 < listeners.length; i_17++) {
  8467. if (listeners[i_17].down)
  8468. listeners[i_17].down(_this.currTouch.x, _this.currTouch.y);
  8469. }
  8470. _this.lastX = _this.currTouch.x;
  8471. _this.lastY = _this.currTouch.y;
  8472. _this.buttonDown = true;
  8473. ev.preventDefault();
  8474. }, false);
  8475. element.addEventListener("touchend", function (ev) {
  8476. var touches = ev.changedTouches;
  8477. for (var i = 0; i < touches.length; i++) {
  8478. var touch = touches[i];
  8479. if (_this.currTouch.identifier === touch.identifier) {
  8480. var rect = element.getBoundingClientRect();
  8481. var x = _this.currTouch.x = touch.clientX - rect.left;
  8482. var y = _this.currTouch.y = touch.clientY - rect.top;
  8483. _this.touchesPool.free(_this.currTouch);
  8484. var listeners = _this.listeners;
  8485. for (var i_18 = 0; i_18 < listeners.length; i_18++) {
  8486. if (listeners[i_18].up)
  8487. listeners[i_18].up(x, y);
  8488. }
  8489. _this.lastX = x;
  8490. _this.lastY = y;
  8491. _this.buttonDown = false;
  8492. _this.currTouch = null;
  8493. break;
  8494. }
  8495. }
  8496. ev.preventDefault();
  8497. }, false);
  8498. element.addEventListener("touchcancel", function (ev) {
  8499. var touches = ev.changedTouches;
  8500. for (var i = 0; i < touches.length; i++) {
  8501. var touch = touches[i];
  8502. if (_this.currTouch.identifier === touch.identifier) {
  8503. var rect = element.getBoundingClientRect();
  8504. var x = _this.currTouch.x = touch.clientX - rect.left;
  8505. var y = _this.currTouch.y = touch.clientY - rect.top;
  8506. _this.touchesPool.free(_this.currTouch);
  8507. var listeners = _this.listeners;
  8508. for (var i_19 = 0; i_19 < listeners.length; i_19++) {
  8509. if (listeners[i_19].up)
  8510. listeners[i_19].up(x, y);
  8511. }
  8512. _this.lastX = x;
  8513. _this.lastY = y;
  8514. _this.buttonDown = false;
  8515. _this.currTouch = null;
  8516. break;
  8517. }
  8518. }
  8519. ev.preventDefault();
  8520. }, false);
  8521. element.addEventListener("touchmove", function (ev) {
  8522. if (_this.currTouch == null)
  8523. return;
  8524. var touches = ev.changedTouches;
  8525. for (var i = 0; i < touches.length; i++) {
  8526. var touch = touches[i];
  8527. if (_this.currTouch.identifier === touch.identifier) {
  8528. var rect = element.getBoundingClientRect();
  8529. var x = touch.clientX - rect.left;
  8530. var y = touch.clientY - rect.top;
  8531. var listeners = _this.listeners;
  8532. for (var i_20 = 0; i_20 < listeners.length; i_20++) {
  8533. if (listeners[i_20].dragged)
  8534. listeners[i_20].dragged(x, y);
  8535. }
  8536. _this.lastX = _this.currTouch.x = x;
  8537. _this.lastY = _this.currTouch.y = y;
  8538. break;
  8539. }
  8540. }
  8541. ev.preventDefault();
  8542. }, false);
  8543. };
  8544. Input.prototype.addListener = function (listener) {
  8545. this.listeners.push(listener);
  8546. };
  8547. Input.prototype.removeListener = function (listener) {
  8548. var idx = this.listeners.indexOf(listener);
  8549. if (idx > -1) {
  8550. this.listeners.splice(idx, 1);
  8551. }
  8552. };
  8553. return Input;
  8554. }());
  8555. webgl.Input = Input;
  8556. var Touch = (function () {
  8557. function Touch(identifier, x, y) {
  8558. this.identifier = identifier;
  8559. this.x = x;
  8560. this.y = y;
  8561. }
  8562. return Touch;
  8563. }());
  8564. webgl.Touch = Touch;
  8565. })(webgl = spine.webgl || (spine.webgl = {}));
  8566. })(spine || (spine = {}));
  8567. var spine;
  8568. (function (spine) {
  8569. var webgl;
  8570. (function (webgl) {
  8571. var LoadingScreen = (function () {
  8572. function LoadingScreen(renderer) {
  8573. this.logo = null;
  8574. this.spinner = null;
  8575. this.angle = 0;
  8576. this.fadeOut = 0;
  8577. this.timeKeeper = new spine.TimeKeeper();
  8578. this.backgroundColor = new spine.Color(0.135, 0.135, 0.135, 1);
  8579. this.tempColor = new spine.Color();
  8580. this.firstDraw = 0;
  8581. this.renderer = renderer;
  8582. this.timeKeeper.maxDelta = 9;
  8583. if (LoadingScreen.logoImg === null) {
  8584. var isSafari = navigator.userAgent.indexOf("Safari") > -1;
  8585. LoadingScreen.logoImg = new Image();
  8586. LoadingScreen.logoImg.src = LoadingScreen.SPINE_LOGO_DATA;
  8587. if (!isSafari)
  8588. LoadingScreen.logoImg.crossOrigin = "anonymous";
  8589. LoadingScreen.logoImg.onload = function (ev) {
  8590. LoadingScreen.loaded++;
  8591. };
  8592. LoadingScreen.spinnerImg = new Image();
  8593. LoadingScreen.spinnerImg.src = LoadingScreen.SPINNER_DATA;
  8594. if (!isSafari)
  8595. LoadingScreen.spinnerImg.crossOrigin = "anonymous";
  8596. LoadingScreen.spinnerImg.onload = function (ev) {
  8597. LoadingScreen.loaded++;
  8598. };
  8599. }
  8600. }
  8601. LoadingScreen.prototype.draw = function (complete) {
  8602. if (complete === void 0) { complete = false; }
  8603. if (complete && this.fadeOut > LoadingScreen.FADE_SECONDS)
  8604. return;
  8605. this.timeKeeper.update();
  8606. var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75));
  8607. this.angle -= this.timeKeeper.delta / 1.4 * 360 * (1 + 1.5 * Math.pow(a, 5));
  8608. var renderer = this.renderer;
  8609. var canvas = renderer.canvas;
  8610. var gl = renderer.context.gl;
  8611. renderer.resize(webgl.ResizeMode.Stretch);
  8612. var oldX = renderer.camera.position.x, oldY = renderer.camera.position.y;
  8613. renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);
  8614. renderer.camera.viewportWidth = canvas.width;
  8615. renderer.camera.viewportHeight = canvas.height;
  8616. if (!complete) {
  8617. gl.clearColor(this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a);
  8618. gl.clear(gl.COLOR_BUFFER_BIT);
  8619. this.tempColor.a = 1;
  8620. }
  8621. else {
  8622. this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);
  8623. if (this.fadeOut > LoadingScreen.FADE_SECONDS) {
  8624. renderer.camera.position.set(oldX, oldY, 0);
  8625. return;
  8626. }
  8627. a = 1 - this.fadeOut / LoadingScreen.FADE_SECONDS;
  8628. this.tempColor.setFromColor(this.backgroundColor);
  8629. this.tempColor.a = 1 - (a - 1) * (a - 1);
  8630. renderer.begin();
  8631. renderer.quad(true, 0, 0, canvas.width, 0, canvas.width, canvas.height, 0, canvas.height, this.tempColor, this.tempColor, this.tempColor, this.tempColor);
  8632. renderer.end();
  8633. }
  8634. this.tempColor.set(1, 1, 1, this.tempColor.a);
  8635. if (LoadingScreen.loaded != 2)
  8636. return;
  8637. if (this.logo === null) {
  8638. this.logo = new webgl.GLTexture(renderer.context, LoadingScreen.logoImg);
  8639. this.spinner = new webgl.GLTexture(renderer.context, LoadingScreen.spinnerImg);
  8640. }
  8641. this.logo.update(false);
  8642. this.spinner.update(false);
  8643. var logoWidth = this.logo.getImage().width;
  8644. var logoHeight = this.logo.getImage().height;
  8645. var spinnerWidth = this.spinner.getImage().width;
  8646. var spinnerHeight = this.spinner.getImage().height;
  8647. renderer.batcher.setBlendMode(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
  8648. renderer.begin();
  8649. renderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, this.tempColor);
  8650. renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerWidth) / 2, (canvas.height - spinnerHeight) / 2, spinnerWidth, spinnerHeight, spinnerWidth / 2, spinnerHeight / 2, this.angle, this.tempColor);
  8651. renderer.end();
  8652. renderer.camera.position.set(oldX, oldY, 0);
  8653. };
  8654. LoadingScreen.FADE_SECONDS = 1;
  8655. LoadingScreen.loaded = 0;
  8656. LoadingScreen.spinnerImg = null;
  8657. LoadingScreen.logoImg = null;
  8658. 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=";
  8659. 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=";
  8660. return LoadingScreen;
  8661. }());
  8662. webgl.LoadingScreen = LoadingScreen;
  8663. })(webgl = spine.webgl || (spine.webgl = {}));
  8664. })(spine || (spine = {}));
  8665. var spine;
  8666. (function (spine) {
  8667. var webgl;
  8668. (function (webgl) {
  8669. webgl.M00 = 0;
  8670. webgl.M01 = 4;
  8671. webgl.M02 = 8;
  8672. webgl.M03 = 12;
  8673. webgl.M10 = 1;
  8674. webgl.M11 = 5;
  8675. webgl.M12 = 9;
  8676. webgl.M13 = 13;
  8677. webgl.M20 = 2;
  8678. webgl.M21 = 6;
  8679. webgl.M22 = 10;
  8680. webgl.M23 = 14;
  8681. webgl.M30 = 3;
  8682. webgl.M31 = 7;
  8683. webgl.M32 = 11;
  8684. webgl.M33 = 15;
  8685. var Matrix4 = (function () {
  8686. function Matrix4() {
  8687. this.temp = new Float32Array(16);
  8688. this.values = new Float32Array(16);
  8689. var v = this.values;
  8690. v[webgl.M00] = 1;
  8691. v[webgl.M11] = 1;
  8692. v[webgl.M22] = 1;
  8693. v[webgl.M33] = 1;
  8694. }
  8695. Matrix4.prototype.set = function (values) {
  8696. this.values.set(values);
  8697. return this;
  8698. };
  8699. Matrix4.prototype.transpose = function () {
  8700. var t = this.temp;
  8701. var v = this.values;
  8702. t[webgl.M00] = v[webgl.M00];
  8703. t[webgl.M01] = v[webgl.M10];
  8704. t[webgl.M02] = v[webgl.M20];
  8705. t[webgl.M03] = v[webgl.M30];
  8706. t[webgl.M10] = v[webgl.M01];
  8707. t[webgl.M11] = v[webgl.M11];
  8708. t[webgl.M12] = v[webgl.M21];
  8709. t[webgl.M13] = v[webgl.M31];
  8710. t[webgl.M20] = v[webgl.M02];
  8711. t[webgl.M21] = v[webgl.M12];
  8712. t[webgl.M22] = v[webgl.M22];
  8713. t[webgl.M23] = v[webgl.M32];
  8714. t[webgl.M30] = v[webgl.M03];
  8715. t[webgl.M31] = v[webgl.M13];
  8716. t[webgl.M32] = v[webgl.M23];
  8717. t[webgl.M33] = v[webgl.M33];
  8718. return this.set(t);
  8719. };
  8720. Matrix4.prototype.identity = function () {
  8721. var v = this.values;
  8722. v[webgl.M00] = 1;
  8723. v[webgl.M01] = 0;
  8724. v[webgl.M02] = 0;
  8725. v[webgl.M03] = 0;
  8726. v[webgl.M10] = 0;
  8727. v[webgl.M11] = 1;
  8728. v[webgl.M12] = 0;
  8729. v[webgl.M13] = 0;
  8730. v[webgl.M20] = 0;
  8731. v[webgl.M21] = 0;
  8732. v[webgl.M22] = 1;
  8733. v[webgl.M23] = 0;
  8734. v[webgl.M30] = 0;
  8735. v[webgl.M31] = 0;
  8736. v[webgl.M32] = 0;
  8737. v[webgl.M33] = 1;
  8738. return this;
  8739. };
  8740. Matrix4.prototype.invert = function () {
  8741. var v = this.values;
  8742. var t = this.temp;
  8743. 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]
  8744. + 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]
  8745. - 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]
  8746. - 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]
  8747. + 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]
  8748. + 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]
  8749. - 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]
  8750. - 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];
  8751. if (l_det == 0)
  8752. throw new Error("non-invertible matrix");
  8753. var inv_det = 1.0 / l_det;
  8754. 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]
  8755. - 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];
  8756. 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]
  8757. + 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];
  8758. 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]
  8759. - 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];
  8760. 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]
  8761. + 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];
  8762. 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]
  8763. + 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];
  8764. 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]
  8765. - 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];
  8766. 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]
  8767. + 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];
  8768. 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]
  8769. - 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];
  8770. 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]
  8771. - 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];
  8772. 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]
  8773. + 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];
  8774. 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]
  8775. - 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];
  8776. 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]
  8777. + 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];
  8778. 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]
  8779. + 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];
  8780. 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]
  8781. - 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];
  8782. 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]
  8783. + 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];
  8784. 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]
  8785. - 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];
  8786. v[webgl.M00] = t[webgl.M00] * inv_det;
  8787. v[webgl.M01] = t[webgl.M01] * inv_det;
  8788. v[webgl.M02] = t[webgl.M02] * inv_det;
  8789. v[webgl.M03] = t[webgl.M03] * inv_det;
  8790. v[webgl.M10] = t[webgl.M10] * inv_det;
  8791. v[webgl.M11] = t[webgl.M11] * inv_det;
  8792. v[webgl.M12] = t[webgl.M12] * inv_det;
  8793. v[webgl.M13] = t[webgl.M13] * inv_det;
  8794. v[webgl.M20] = t[webgl.M20] * inv_det;
  8795. v[webgl.M21] = t[webgl.M21] * inv_det;
  8796. v[webgl.M22] = t[webgl.M22] * inv_det;
  8797. v[webgl.M23] = t[webgl.M23] * inv_det;
  8798. v[webgl.M30] = t[webgl.M30] * inv_det;
  8799. v[webgl.M31] = t[webgl.M31] * inv_det;
  8800. v[webgl.M32] = t[webgl.M32] * inv_det;
  8801. v[webgl.M33] = t[webgl.M33] * inv_det;
  8802. return this;
  8803. };
  8804. Matrix4.prototype.determinant = function () {
  8805. var v = this.values;
  8806. 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]
  8807. + 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]
  8808. - 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]
  8809. - 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]
  8810. + 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]
  8811. + 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]
  8812. - 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]
  8813. - 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];
  8814. };
  8815. Matrix4.prototype.translate = function (x, y, z) {
  8816. var v = this.values;
  8817. v[webgl.M03] += x;
  8818. v[webgl.M13] += y;
  8819. v[webgl.M23] += z;
  8820. return this;
  8821. };
  8822. Matrix4.prototype.copy = function () {
  8823. return new Matrix4().set(this.values);
  8824. };
  8825. Matrix4.prototype.projection = function (near, far, fovy, aspectRatio) {
  8826. this.identity();
  8827. var l_fd = (1.0 / Math.tan((fovy * (Math.PI / 180)) / 2.0));
  8828. var l_a1 = (far + near) / (near - far);
  8829. var l_a2 = (2 * far * near) / (near - far);
  8830. var v = this.values;
  8831. v[webgl.M00] = l_fd / aspectRatio;
  8832. v[webgl.M10] = 0;
  8833. v[webgl.M20] = 0;
  8834. v[webgl.M30] = 0;
  8835. v[webgl.M01] = 0;
  8836. v[webgl.M11] = l_fd;
  8837. v[webgl.M21] = 0;
  8838. v[webgl.M31] = 0;
  8839. v[webgl.M02] = 0;
  8840. v[webgl.M12] = 0;
  8841. v[webgl.M22] = l_a1;
  8842. v[webgl.M32] = -1;
  8843. v[webgl.M03] = 0;
  8844. v[webgl.M13] = 0;
  8845. v[webgl.M23] = l_a2;
  8846. v[webgl.M33] = 0;
  8847. return this;
  8848. };
  8849. Matrix4.prototype.ortho2d = function (x, y, width, height) {
  8850. return this.ortho(x, x + width, y, y + height, 0, 1);
  8851. };
  8852. Matrix4.prototype.ortho = function (left, right, bottom, top, near, far) {
  8853. this.identity();
  8854. var x_orth = 2 / (right - left);
  8855. var y_orth = 2 / (top - bottom);
  8856. var z_orth = -2 / (far - near);
  8857. var tx = -(right + left) / (right - left);
  8858. var ty = -(top + bottom) / (top - bottom);
  8859. var tz = -(far + near) / (far - near);
  8860. var v = this.values;
  8861. v[webgl.M00] = x_orth;
  8862. v[webgl.M10] = 0;
  8863. v[webgl.M20] = 0;
  8864. v[webgl.M30] = 0;
  8865. v[webgl.M01] = 0;
  8866. v[webgl.M11] = y_orth;
  8867. v[webgl.M21] = 0;
  8868. v[webgl.M31] = 0;
  8869. v[webgl.M02] = 0;
  8870. v[webgl.M12] = 0;
  8871. v[webgl.M22] = z_orth;
  8872. v[webgl.M32] = 0;
  8873. v[webgl.M03] = tx;
  8874. v[webgl.M13] = ty;
  8875. v[webgl.M23] = tz;
  8876. v[webgl.M33] = 1;
  8877. return this;
  8878. };
  8879. Matrix4.prototype.multiply = function (matrix) {
  8880. var t = this.temp;
  8881. var v = this.values;
  8882. var m = matrix.values;
  8883. 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];
  8884. 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];
  8885. 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];
  8886. 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];
  8887. 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];
  8888. 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];
  8889. 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];
  8890. 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];
  8891. 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];
  8892. 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];
  8893. 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];
  8894. 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];
  8895. 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];
  8896. 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];
  8897. 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];
  8898. 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];
  8899. return this.set(this.temp);
  8900. };
  8901. Matrix4.prototype.multiplyLeft = function (matrix) {
  8902. var t = this.temp;
  8903. var v = this.values;
  8904. var m = matrix.values;
  8905. 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];
  8906. 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];
  8907. 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];
  8908. 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];
  8909. 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];
  8910. 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];
  8911. 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];
  8912. 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];
  8913. 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];
  8914. 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];
  8915. 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];
  8916. 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];
  8917. 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];
  8918. 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];
  8919. 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];
  8920. 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];
  8921. return this.set(this.temp);
  8922. };
  8923. Matrix4.prototype.lookAt = function (position, direction, up) {
  8924. Matrix4.initTemps();
  8925. var xAxis = Matrix4.xAxis, yAxis = Matrix4.yAxis, zAxis = Matrix4.zAxis;
  8926. zAxis.setFrom(direction).normalize();
  8927. xAxis.setFrom(direction).normalize();
  8928. xAxis.cross(up).normalize();
  8929. yAxis.setFrom(xAxis).cross(zAxis).normalize();
  8930. this.identity();
  8931. var val = this.values;
  8932. val[webgl.M00] = xAxis.x;
  8933. val[webgl.M01] = xAxis.y;
  8934. val[webgl.M02] = xAxis.z;
  8935. val[webgl.M10] = yAxis.x;
  8936. val[webgl.M11] = yAxis.y;
  8937. val[webgl.M12] = yAxis.z;
  8938. val[webgl.M20] = -zAxis.x;
  8939. val[webgl.M21] = -zAxis.y;
  8940. val[webgl.M22] = -zAxis.z;
  8941. Matrix4.tmpMatrix.identity();
  8942. Matrix4.tmpMatrix.values[webgl.M03] = -position.x;
  8943. Matrix4.tmpMatrix.values[webgl.M13] = -position.y;
  8944. Matrix4.tmpMatrix.values[webgl.M23] = -position.z;
  8945. this.multiply(Matrix4.tmpMatrix);
  8946. return this;
  8947. };
  8948. Matrix4.initTemps = function () {
  8949. if (Matrix4.xAxis === null)
  8950. Matrix4.xAxis = new webgl.Vector3();
  8951. if (Matrix4.yAxis === null)
  8952. Matrix4.yAxis = new webgl.Vector3();
  8953. if (Matrix4.zAxis === null)
  8954. Matrix4.zAxis = new webgl.Vector3();
  8955. };
  8956. Matrix4.xAxis = null;
  8957. Matrix4.yAxis = null;
  8958. Matrix4.zAxis = null;
  8959. Matrix4.tmpMatrix = new Matrix4();
  8960. return Matrix4;
  8961. }());
  8962. webgl.Matrix4 = Matrix4;
  8963. })(webgl = spine.webgl || (spine.webgl = {}));
  8964. })(spine || (spine = {}));
  8965. var spine;
  8966. (function (spine) {
  8967. var webgl;
  8968. (function (webgl) {
  8969. var Mesh = (function () {
  8970. function Mesh(context, attributes, maxVertices, maxIndices) {
  8971. this.attributes = attributes;
  8972. this.verticesLength = 0;
  8973. this.dirtyVertices = false;
  8974. this.indicesLength = 0;
  8975. this.dirtyIndices = false;
  8976. this.elementsPerVertex = 0;
  8977. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  8978. this.elementsPerVertex = 0;
  8979. for (var i = 0; i < attributes.length; i++) {
  8980. this.elementsPerVertex += attributes[i].numElements;
  8981. }
  8982. this.vertices = new Float32Array(maxVertices * this.elementsPerVertex);
  8983. this.indices = new Uint16Array(maxIndices);
  8984. this.context.addRestorable(this);
  8985. }
  8986. Mesh.prototype.getAttributes = function () { return this.attributes; };
  8987. Mesh.prototype.maxVertices = function () { return this.vertices.length / this.elementsPerVertex; };
  8988. Mesh.prototype.numVertices = function () { return this.verticesLength / this.elementsPerVertex; };
  8989. Mesh.prototype.setVerticesLength = function (length) {
  8990. this.dirtyVertices = true;
  8991. this.verticesLength = length;
  8992. };
  8993. Mesh.prototype.getVertices = function () { return this.vertices; };
  8994. Mesh.prototype.maxIndices = function () { return this.indices.length; };
  8995. Mesh.prototype.numIndices = function () { return this.indicesLength; };
  8996. Mesh.prototype.setIndicesLength = function (length) {
  8997. this.dirtyIndices = true;
  8998. this.indicesLength = length;
  8999. };
  9000. Mesh.prototype.getIndices = function () { return this.indices; };
  9001. ;
  9002. Mesh.prototype.getVertexSizeInFloats = function () {
  9003. var size = 0;
  9004. for (var i = 0; i < this.attributes.length; i++) {
  9005. var attribute = this.attributes[i];
  9006. size += attribute.numElements;
  9007. }
  9008. return size;
  9009. };
  9010. Mesh.prototype.setVertices = function (vertices) {
  9011. this.dirtyVertices = true;
  9012. if (vertices.length > this.vertices.length)
  9013. throw Error("Mesh can't store more than " + this.maxVertices() + " vertices");
  9014. this.vertices.set(vertices, 0);
  9015. this.verticesLength = vertices.length;
  9016. };
  9017. Mesh.prototype.setIndices = function (indices) {
  9018. this.dirtyIndices = true;
  9019. if (indices.length > this.indices.length)
  9020. throw Error("Mesh can't store more than " + this.maxIndices() + " indices");
  9021. this.indices.set(indices, 0);
  9022. this.indicesLength = indices.length;
  9023. };
  9024. Mesh.prototype.draw = function (shader, primitiveType) {
  9025. this.drawWithOffset(shader, primitiveType, 0, this.indicesLength > 0 ? this.indicesLength : this.verticesLength / this.elementsPerVertex);
  9026. };
  9027. Mesh.prototype.drawWithOffset = function (shader, primitiveType, offset, count) {
  9028. var gl = this.context.gl;
  9029. if (this.dirtyVertices || this.dirtyIndices)
  9030. this.update();
  9031. this.bind(shader);
  9032. if (this.indicesLength > 0) {
  9033. gl.drawElements(primitiveType, count, gl.UNSIGNED_SHORT, offset * 2);
  9034. }
  9035. else {
  9036. gl.drawArrays(primitiveType, offset, count);
  9037. }
  9038. this.unbind(shader);
  9039. };
  9040. Mesh.prototype.bind = function (shader) {
  9041. var gl = this.context.gl;
  9042. gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);
  9043. var offset = 0;
  9044. for (var i = 0; i < this.attributes.length; i++) {
  9045. var attrib = this.attributes[i];
  9046. var location_1 = shader.getAttributeLocation(attrib.name);
  9047. gl.enableVertexAttribArray(location_1);
  9048. gl.vertexAttribPointer(location_1, attrib.numElements, gl.FLOAT, false, this.elementsPerVertex * 4, offset * 4);
  9049. offset += attrib.numElements;
  9050. }
  9051. if (this.indicesLength > 0)
  9052. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
  9053. };
  9054. Mesh.prototype.unbind = function (shader) {
  9055. var gl = this.context.gl;
  9056. for (var i = 0; i < this.attributes.length; i++) {
  9057. var attrib = this.attributes[i];
  9058. var location_2 = shader.getAttributeLocation(attrib.name);
  9059. gl.disableVertexAttribArray(location_2);
  9060. }
  9061. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  9062. if (this.indicesLength > 0)
  9063. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
  9064. };
  9065. Mesh.prototype.update = function () {
  9066. var gl = this.context.gl;
  9067. if (this.dirtyVertices) {
  9068. if (!this.verticesBuffer) {
  9069. this.verticesBuffer = gl.createBuffer();
  9070. }
  9071. gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);
  9072. gl.bufferData(gl.ARRAY_BUFFER, this.vertices.subarray(0, this.verticesLength), gl.DYNAMIC_DRAW);
  9073. this.dirtyVertices = false;
  9074. }
  9075. if (this.dirtyIndices) {
  9076. if (!this.indicesBuffer) {
  9077. this.indicesBuffer = gl.createBuffer();
  9078. }
  9079. gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
  9080. gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices.subarray(0, this.indicesLength), gl.DYNAMIC_DRAW);
  9081. this.dirtyIndices = false;
  9082. }
  9083. };
  9084. Mesh.prototype.restore = function () {
  9085. this.verticesBuffer = null;
  9086. this.indicesBuffer = null;
  9087. this.update();
  9088. };
  9089. Mesh.prototype.dispose = function () {
  9090. this.context.removeRestorable(this);
  9091. var gl = this.context.gl;
  9092. gl.deleteBuffer(this.verticesBuffer);
  9093. gl.deleteBuffer(this.indicesBuffer);
  9094. };
  9095. return Mesh;
  9096. }());
  9097. webgl.Mesh = Mesh;
  9098. var VertexAttribute = (function () {
  9099. function VertexAttribute(name, type, numElements) {
  9100. this.name = name;
  9101. this.type = type;
  9102. this.numElements = numElements;
  9103. }
  9104. return VertexAttribute;
  9105. }());
  9106. webgl.VertexAttribute = VertexAttribute;
  9107. var Position2Attribute = (function (_super) {
  9108. __extends(Position2Attribute, _super);
  9109. function Position2Attribute() {
  9110. return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 2) || this;
  9111. }
  9112. return Position2Attribute;
  9113. }(VertexAttribute));
  9114. webgl.Position2Attribute = Position2Attribute;
  9115. var Position3Attribute = (function (_super) {
  9116. __extends(Position3Attribute, _super);
  9117. function Position3Attribute() {
  9118. return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 3) || this;
  9119. }
  9120. return Position3Attribute;
  9121. }(VertexAttribute));
  9122. webgl.Position3Attribute = Position3Attribute;
  9123. var TexCoordAttribute = (function (_super) {
  9124. __extends(TexCoordAttribute, _super);
  9125. function TexCoordAttribute(unit) {
  9126. if (unit === void 0) { unit = 0; }
  9127. return _super.call(this, webgl.Shader.TEXCOORDS + (unit == 0 ? "" : unit), VertexAttributeType.Float, 2) || this;
  9128. }
  9129. return TexCoordAttribute;
  9130. }(VertexAttribute));
  9131. webgl.TexCoordAttribute = TexCoordAttribute;
  9132. var ColorAttribute = (function (_super) {
  9133. __extends(ColorAttribute, _super);
  9134. function ColorAttribute() {
  9135. return _super.call(this, webgl.Shader.COLOR, VertexAttributeType.Float, 4) || this;
  9136. }
  9137. return ColorAttribute;
  9138. }(VertexAttribute));
  9139. webgl.ColorAttribute = ColorAttribute;
  9140. var Color2Attribute = (function (_super) {
  9141. __extends(Color2Attribute, _super);
  9142. function Color2Attribute() {
  9143. return _super.call(this, webgl.Shader.COLOR2, VertexAttributeType.Float, 4) || this;
  9144. }
  9145. return Color2Attribute;
  9146. }(VertexAttribute));
  9147. webgl.Color2Attribute = Color2Attribute;
  9148. var VertexAttributeType;
  9149. (function (VertexAttributeType) {
  9150. VertexAttributeType[VertexAttributeType["Float"] = 0] = "Float";
  9151. })(VertexAttributeType = webgl.VertexAttributeType || (webgl.VertexAttributeType = {}));
  9152. })(webgl = spine.webgl || (spine.webgl = {}));
  9153. })(spine || (spine = {}));
  9154. var spine;
  9155. (function (spine) {
  9156. var webgl;
  9157. (function (webgl) {
  9158. var PolygonBatcher = (function () {
  9159. function PolygonBatcher(context, twoColorTint, maxVertices) {
  9160. if (twoColorTint === void 0) { twoColorTint = true; }
  9161. if (maxVertices === void 0) { maxVertices = 10920; }
  9162. this.isDrawing = false;
  9163. this.shader = null;
  9164. this.lastTexture = null;
  9165. this.verticesLength = 0;
  9166. this.indicesLength = 0;
  9167. if (maxVertices > 10920)
  9168. throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
  9169. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  9170. var attributes = twoColorTint ?
  9171. [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute(), new webgl.Color2Attribute()] :
  9172. [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute()];
  9173. this.mesh = new webgl.Mesh(context, attributes, maxVertices, maxVertices * 3);
  9174. this.srcBlend = this.context.gl.SRC_ALPHA;
  9175. this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;
  9176. }
  9177. PolygonBatcher.prototype.begin = function (shader) {
  9178. var gl = this.context.gl;
  9179. if (this.isDrawing)
  9180. throw new Error("PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()");
  9181. this.drawCalls = 0;
  9182. this.shader = shader;
  9183. this.lastTexture = null;
  9184. this.isDrawing = true;
  9185. gl.enable(gl.BLEND);
  9186. gl.blendFunc(this.srcBlend, this.dstBlend);
  9187. };
  9188. PolygonBatcher.prototype.setBlendMode = function (srcBlend, dstBlend) {
  9189. var gl = this.context.gl;
  9190. this.srcBlend = srcBlend;
  9191. this.dstBlend = dstBlend;
  9192. if (this.isDrawing) {
  9193. this.flush();
  9194. gl.blendFunc(this.srcBlend, this.dstBlend);
  9195. }
  9196. };
  9197. PolygonBatcher.prototype.draw = function (texture, vertices, indices) {
  9198. if (texture != this.lastTexture) {
  9199. this.flush();
  9200. this.lastTexture = texture;
  9201. }
  9202. else if (this.verticesLength + vertices.length > this.mesh.getVertices().length ||
  9203. this.indicesLength + indices.length > this.mesh.getIndices().length) {
  9204. this.flush();
  9205. }
  9206. var indexStart = this.mesh.numVertices();
  9207. this.mesh.getVertices().set(vertices, this.verticesLength);
  9208. this.verticesLength += vertices.length;
  9209. this.mesh.setVerticesLength(this.verticesLength);
  9210. var indicesArray = this.mesh.getIndices();
  9211. for (var i = this.indicesLength, j = 0; j < indices.length; i++, j++)
  9212. indicesArray[i] = indices[j] + indexStart;
  9213. this.indicesLength += indices.length;
  9214. this.mesh.setIndicesLength(this.indicesLength);
  9215. };
  9216. PolygonBatcher.prototype.flush = function () {
  9217. var gl = this.context.gl;
  9218. if (this.verticesLength == 0)
  9219. return;
  9220. this.lastTexture.bind();
  9221. this.mesh.draw(this.shader, gl.TRIANGLES);
  9222. this.verticesLength = 0;
  9223. this.indicesLength = 0;
  9224. this.mesh.setVerticesLength(0);
  9225. this.mesh.setIndicesLength(0);
  9226. this.drawCalls++;
  9227. };
  9228. PolygonBatcher.prototype.end = function () {
  9229. var gl = this.context.gl;
  9230. if (!this.isDrawing)
  9231. throw new Error("PolygonBatch is not drawing. Call PolygonBatch.begin() before calling PolygonBatch.end()");
  9232. if (this.verticesLength > 0 || this.indicesLength > 0)
  9233. this.flush();
  9234. this.shader = null;
  9235. this.lastTexture = null;
  9236. this.isDrawing = false;
  9237. gl.disable(gl.BLEND);
  9238. };
  9239. PolygonBatcher.prototype.getDrawCalls = function () { return this.drawCalls; };
  9240. PolygonBatcher.prototype.dispose = function () {
  9241. this.mesh.dispose();
  9242. };
  9243. return PolygonBatcher;
  9244. }());
  9245. webgl.PolygonBatcher = PolygonBatcher;
  9246. })(webgl = spine.webgl || (spine.webgl = {}));
  9247. })(spine || (spine = {}));
  9248. var spine;
  9249. (function (spine) {
  9250. var webgl;
  9251. (function (webgl) {
  9252. var SceneRenderer = (function () {
  9253. function SceneRenderer(canvas, context, twoColorTint) {
  9254. if (twoColorTint === void 0) { twoColorTint = true; }
  9255. this.twoColorTint = false;
  9256. this.activeRenderer = null;
  9257. this.QUAD = [
  9258. 0, 0, 1, 1, 1, 1, 0, 0,
  9259. 0, 0, 1, 1, 1, 1, 0, 0,
  9260. 0, 0, 1, 1, 1, 1, 0, 0,
  9261. 0, 0, 1, 1, 1, 1, 0, 0,
  9262. ];
  9263. this.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
  9264. this.WHITE = new spine.Color(1, 1, 1, 1);
  9265. this.canvas = canvas;
  9266. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  9267. this.twoColorTint = twoColorTint;
  9268. this.camera = new webgl.OrthoCamera(canvas.width, canvas.height);
  9269. this.batcherShader = twoColorTint ? webgl.Shader.newTwoColoredTextured(this.context) : webgl.Shader.newColoredTextured(this.context);
  9270. this.batcher = new webgl.PolygonBatcher(this.context, twoColorTint);
  9271. this.shapesShader = webgl.Shader.newColored(this.context);
  9272. this.shapes = new webgl.ShapeRenderer(this.context);
  9273. this.skeletonRenderer = new webgl.SkeletonRenderer(this.context, twoColorTint);
  9274. this.skeletonDebugRenderer = new webgl.SkeletonDebugRenderer(this.context);
  9275. }
  9276. SceneRenderer.prototype.begin = function () {
  9277. this.camera.update();
  9278. this.enableRenderer(this.batcher);
  9279. };
  9280. SceneRenderer.prototype.drawSkeleton = function (skeleton, premultipliedAlpha, slotRangeStart, slotRangeEnd) {
  9281. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9282. if (slotRangeStart === void 0) { slotRangeStart = -1; }
  9283. if (slotRangeEnd === void 0) { slotRangeEnd = -1; }
  9284. this.enableRenderer(this.batcher);
  9285. this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
  9286. this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd);
  9287. };
  9288. SceneRenderer.prototype.drawSkeletonDebug = function (skeleton, premultipliedAlpha, ignoredBones) {
  9289. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9290. if (ignoredBones === void 0) { ignoredBones = null; }
  9291. this.enableRenderer(this.shapes);
  9292. this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha;
  9293. this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones);
  9294. };
  9295. SceneRenderer.prototype.drawTexture = function (texture, x, y, width, height, color) {
  9296. if (color === void 0) { color = null; }
  9297. this.enableRenderer(this.batcher);
  9298. if (color === null)
  9299. color = this.WHITE;
  9300. var quad = this.QUAD;
  9301. var i = 0;
  9302. quad[i++] = x;
  9303. quad[i++] = y;
  9304. quad[i++] = color.r;
  9305. quad[i++] = color.g;
  9306. quad[i++] = color.b;
  9307. quad[i++] = color.a;
  9308. quad[i++] = 0;
  9309. quad[i++] = 1;
  9310. if (this.twoColorTint) {
  9311. quad[i++] = 0;
  9312. quad[i++] = 0;
  9313. quad[i++] = 0;
  9314. quad[i++] = 0;
  9315. }
  9316. quad[i++] = x + width;
  9317. quad[i++] = y;
  9318. quad[i++] = color.r;
  9319. quad[i++] = color.g;
  9320. quad[i++] = color.b;
  9321. quad[i++] = color.a;
  9322. quad[i++] = 1;
  9323. quad[i++] = 1;
  9324. if (this.twoColorTint) {
  9325. quad[i++] = 0;
  9326. quad[i++] = 0;
  9327. quad[i++] = 0;
  9328. quad[i++] = 0;
  9329. }
  9330. quad[i++] = x + width;
  9331. quad[i++] = y + height;
  9332. quad[i++] = color.r;
  9333. quad[i++] = color.g;
  9334. quad[i++] = color.b;
  9335. quad[i++] = color.a;
  9336. quad[i++] = 1;
  9337. quad[i++] = 0;
  9338. if (this.twoColorTint) {
  9339. quad[i++] = 0;
  9340. quad[i++] = 0;
  9341. quad[i++] = 0;
  9342. quad[i++] = 0;
  9343. }
  9344. quad[i++] = x;
  9345. quad[i++] = y + height;
  9346. quad[i++] = color.r;
  9347. quad[i++] = color.g;
  9348. quad[i++] = color.b;
  9349. quad[i++] = color.a;
  9350. quad[i++] = 0;
  9351. quad[i++] = 0;
  9352. if (this.twoColorTint) {
  9353. quad[i++] = 0;
  9354. quad[i++] = 0;
  9355. quad[i++] = 0;
  9356. quad[i++] = 0;
  9357. }
  9358. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  9359. };
  9360. SceneRenderer.prototype.drawTextureUV = function (texture, x, y, width, height, u, v, u2, v2, color) {
  9361. if (color === void 0) { color = null; }
  9362. this.enableRenderer(this.batcher);
  9363. if (color === null)
  9364. color = this.WHITE;
  9365. var quad = this.QUAD;
  9366. var i = 0;
  9367. quad[i++] = x;
  9368. quad[i++] = y;
  9369. quad[i++] = color.r;
  9370. quad[i++] = color.g;
  9371. quad[i++] = color.b;
  9372. quad[i++] = color.a;
  9373. quad[i++] = u;
  9374. quad[i++] = v;
  9375. if (this.twoColorTint) {
  9376. quad[i++] = 0;
  9377. quad[i++] = 0;
  9378. quad[i++] = 0;
  9379. quad[i++] = 0;
  9380. }
  9381. quad[i++] = x + width;
  9382. quad[i++] = y;
  9383. quad[i++] = color.r;
  9384. quad[i++] = color.g;
  9385. quad[i++] = color.b;
  9386. quad[i++] = color.a;
  9387. quad[i++] = u2;
  9388. quad[i++] = v;
  9389. if (this.twoColorTint) {
  9390. quad[i++] = 0;
  9391. quad[i++] = 0;
  9392. quad[i++] = 0;
  9393. quad[i++] = 0;
  9394. }
  9395. quad[i++] = x + width;
  9396. quad[i++] = y + height;
  9397. quad[i++] = color.r;
  9398. quad[i++] = color.g;
  9399. quad[i++] = color.b;
  9400. quad[i++] = color.a;
  9401. quad[i++] = u2;
  9402. quad[i++] = v2;
  9403. if (this.twoColorTint) {
  9404. quad[i++] = 0;
  9405. quad[i++] = 0;
  9406. quad[i++] = 0;
  9407. quad[i++] = 0;
  9408. }
  9409. quad[i++] = x;
  9410. quad[i++] = y + height;
  9411. quad[i++] = color.r;
  9412. quad[i++] = color.g;
  9413. quad[i++] = color.b;
  9414. quad[i++] = color.a;
  9415. quad[i++] = u;
  9416. quad[i++] = v2;
  9417. if (this.twoColorTint) {
  9418. quad[i++] = 0;
  9419. quad[i++] = 0;
  9420. quad[i++] = 0;
  9421. quad[i++] = 0;
  9422. }
  9423. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  9424. };
  9425. SceneRenderer.prototype.drawTextureRotated = function (texture, x, y, width, height, pivotX, pivotY, angle, color, premultipliedAlpha) {
  9426. if (color === void 0) { color = null; }
  9427. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9428. this.enableRenderer(this.batcher);
  9429. if (color === null)
  9430. color = this.WHITE;
  9431. var quad = this.QUAD;
  9432. var worldOriginX = x + pivotX;
  9433. var worldOriginY = y + pivotY;
  9434. var fx = -pivotX;
  9435. var fy = -pivotY;
  9436. var fx2 = width - pivotX;
  9437. var fy2 = height - pivotY;
  9438. var p1x = fx;
  9439. var p1y = fy;
  9440. var p2x = fx;
  9441. var p2y = fy2;
  9442. var p3x = fx2;
  9443. var p3y = fy2;
  9444. var p4x = fx2;
  9445. var p4y = fy;
  9446. var x1 = 0;
  9447. var y1 = 0;
  9448. var x2 = 0;
  9449. var y2 = 0;
  9450. var x3 = 0;
  9451. var y3 = 0;
  9452. var x4 = 0;
  9453. var y4 = 0;
  9454. if (angle != 0) {
  9455. var cos = spine.MathUtils.cosDeg(angle);
  9456. var sin = spine.MathUtils.sinDeg(angle);
  9457. x1 = cos * p1x - sin * p1y;
  9458. y1 = sin * p1x + cos * p1y;
  9459. x4 = cos * p2x - sin * p2y;
  9460. y4 = sin * p2x + cos * p2y;
  9461. x3 = cos * p3x - sin * p3y;
  9462. y3 = sin * p3x + cos * p3y;
  9463. x2 = x3 + (x1 - x4);
  9464. y2 = y3 + (y1 - y4);
  9465. }
  9466. else {
  9467. x1 = p1x;
  9468. y1 = p1y;
  9469. x4 = p2x;
  9470. y4 = p2y;
  9471. x3 = p3x;
  9472. y3 = p3y;
  9473. x2 = p4x;
  9474. y2 = p4y;
  9475. }
  9476. x1 += worldOriginX;
  9477. y1 += worldOriginY;
  9478. x2 += worldOriginX;
  9479. y2 += worldOriginY;
  9480. x3 += worldOriginX;
  9481. y3 += worldOriginY;
  9482. x4 += worldOriginX;
  9483. y4 += worldOriginY;
  9484. var i = 0;
  9485. quad[i++] = x1;
  9486. quad[i++] = y1;
  9487. quad[i++] = color.r;
  9488. quad[i++] = color.g;
  9489. quad[i++] = color.b;
  9490. quad[i++] = color.a;
  9491. quad[i++] = 0;
  9492. quad[i++] = 1;
  9493. if (this.twoColorTint) {
  9494. quad[i++] = 0;
  9495. quad[i++] = 0;
  9496. quad[i++] = 0;
  9497. quad[i++] = 0;
  9498. }
  9499. quad[i++] = x2;
  9500. quad[i++] = y2;
  9501. quad[i++] = color.r;
  9502. quad[i++] = color.g;
  9503. quad[i++] = color.b;
  9504. quad[i++] = color.a;
  9505. quad[i++] = 1;
  9506. quad[i++] = 1;
  9507. if (this.twoColorTint) {
  9508. quad[i++] = 0;
  9509. quad[i++] = 0;
  9510. quad[i++] = 0;
  9511. quad[i++] = 0;
  9512. }
  9513. quad[i++] = x3;
  9514. quad[i++] = y3;
  9515. quad[i++] = color.r;
  9516. quad[i++] = color.g;
  9517. quad[i++] = color.b;
  9518. quad[i++] = color.a;
  9519. quad[i++] = 1;
  9520. quad[i++] = 0;
  9521. if (this.twoColorTint) {
  9522. quad[i++] = 0;
  9523. quad[i++] = 0;
  9524. quad[i++] = 0;
  9525. quad[i++] = 0;
  9526. }
  9527. quad[i++] = x4;
  9528. quad[i++] = y4;
  9529. quad[i++] = color.r;
  9530. quad[i++] = color.g;
  9531. quad[i++] = color.b;
  9532. quad[i++] = color.a;
  9533. quad[i++] = 0;
  9534. quad[i++] = 0;
  9535. if (this.twoColorTint) {
  9536. quad[i++] = 0;
  9537. quad[i++] = 0;
  9538. quad[i++] = 0;
  9539. quad[i++] = 0;
  9540. }
  9541. this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
  9542. };
  9543. SceneRenderer.prototype.drawRegion = function (region, x, y, width, height, color, premultipliedAlpha) {
  9544. if (color === void 0) { color = null; }
  9545. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  9546. this.enableRenderer(this.batcher);
  9547. if (color === null)
  9548. color = this.WHITE;
  9549. var quad = this.QUAD;
  9550. var i = 0;
  9551. quad[i++] = x;
  9552. quad[i++] = y;
  9553. quad[i++] = color.r;
  9554. quad[i++] = color.g;
  9555. quad[i++] = color.b;
  9556. quad[i++] = color.a;
  9557. quad[i++] = region.u;
  9558. quad[i++] = region.v2;
  9559. if (this.twoColorTint) {
  9560. quad[i++] = 0;
  9561. quad[i++] = 0;
  9562. quad[i++] = 0;
  9563. quad[i++] = 0;
  9564. }
  9565. quad[i++] = x + width;
  9566. quad[i++] = y;
  9567. quad[i++] = color.r;
  9568. quad[i++] = color.g;
  9569. quad[i++] = color.b;
  9570. quad[i++] = color.a;
  9571. quad[i++] = region.u2;
  9572. quad[i++] = region.v2;
  9573. if (this.twoColorTint) {
  9574. quad[i++] = 0;
  9575. quad[i++] = 0;
  9576. quad[i++] = 0;
  9577. quad[i++] = 0;
  9578. }
  9579. quad[i++] = x + width;
  9580. quad[i++] = y + height;
  9581. quad[i++] = color.r;
  9582. quad[i++] = color.g;
  9583. quad[i++] = color.b;
  9584. quad[i++] = color.a;
  9585. quad[i++] = region.u2;
  9586. quad[i++] = region.v;
  9587. if (this.twoColorTint) {
  9588. quad[i++] = 0;
  9589. quad[i++] = 0;
  9590. quad[i++] = 0;
  9591. quad[i++] = 0;
  9592. }
  9593. quad[i++] = x;
  9594. quad[i++] = y + height;
  9595. quad[i++] = color.r;
  9596. quad[i++] = color.g;
  9597. quad[i++] = color.b;
  9598. quad[i++] = color.a;
  9599. quad[i++] = region.u;
  9600. quad[i++] = region.v;
  9601. if (this.twoColorTint) {
  9602. quad[i++] = 0;
  9603. quad[i++] = 0;
  9604. quad[i++] = 0;
  9605. quad[i++] = 0;
  9606. }
  9607. this.batcher.draw(region.texture, quad, this.QUAD_TRIANGLES);
  9608. };
  9609. SceneRenderer.prototype.line = function (x, y, x2, y2, color, color2) {
  9610. if (color === void 0) { color = null; }
  9611. if (color2 === void 0) { color2 = null; }
  9612. this.enableRenderer(this.shapes);
  9613. this.shapes.line(x, y, x2, y2, color);
  9614. };
  9615. SceneRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {
  9616. if (color === void 0) { color = null; }
  9617. if (color2 === void 0) { color2 = null; }
  9618. if (color3 === void 0) { color3 = null; }
  9619. this.enableRenderer(this.shapes);
  9620. this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3);
  9621. };
  9622. SceneRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
  9623. if (color === void 0) { color = null; }
  9624. if (color2 === void 0) { color2 = null; }
  9625. if (color3 === void 0) { color3 = null; }
  9626. if (color4 === void 0) { color4 = null; }
  9627. this.enableRenderer(this.shapes);
  9628. this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4);
  9629. };
  9630. SceneRenderer.prototype.rect = function (filled, x, y, width, height, color) {
  9631. if (color === void 0) { color = null; }
  9632. this.enableRenderer(this.shapes);
  9633. this.shapes.rect(filled, x, y, width, height, color);
  9634. };
  9635. SceneRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) {
  9636. if (color === void 0) { color = null; }
  9637. this.enableRenderer(this.shapes);
  9638. this.shapes.rectLine(filled, x1, y1, x2, y2, width, color);
  9639. };
  9640. SceneRenderer.prototype.polygon = function (polygonVertices, offset, count, color) {
  9641. if (color === void 0) { color = null; }
  9642. this.enableRenderer(this.shapes);
  9643. this.shapes.polygon(polygonVertices, offset, count, color);
  9644. };
  9645. SceneRenderer.prototype.circle = function (filled, x, y, radius, color, segments) {
  9646. if (color === void 0) { color = null; }
  9647. if (segments === void 0) { segments = 0; }
  9648. this.enableRenderer(this.shapes);
  9649. this.shapes.circle(filled, x, y, radius, color, segments);
  9650. };
  9651. SceneRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
  9652. if (color === void 0) { color = null; }
  9653. this.enableRenderer(this.shapes);
  9654. this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color);
  9655. };
  9656. SceneRenderer.prototype.end = function () {
  9657. if (this.activeRenderer === this.batcher)
  9658. this.batcher.end();
  9659. else if (this.activeRenderer === this.shapes)
  9660. this.shapes.end();
  9661. this.activeRenderer = null;
  9662. };
  9663. SceneRenderer.prototype.resize = function (resizeMode) {
  9664. var canvas = this.canvas;
  9665. var w = canvas.clientWidth;
  9666. var h = canvas.clientHeight;
  9667. if (canvas.width != w || canvas.height != h) {
  9668. canvas.width = w;
  9669. canvas.height = h;
  9670. }
  9671. this.context.gl.viewport(0, 0, canvas.width, canvas.height);
  9672. if (resizeMode === ResizeMode.Stretch) {
  9673. }
  9674. else if (resizeMode === ResizeMode.Expand) {
  9675. this.camera.setViewport(w, h);
  9676. }
  9677. else if (resizeMode === ResizeMode.Fit) {
  9678. var sourceWidth = canvas.width, sourceHeight = canvas.height;
  9679. var targetWidth = this.camera.viewportWidth, targetHeight = this.camera.viewportHeight;
  9680. var targetRatio = targetHeight / targetWidth;
  9681. var sourceRatio = sourceHeight / sourceWidth;
  9682. var scale = targetRatio < sourceRatio ? targetWidth / sourceWidth : targetHeight / sourceHeight;
  9683. this.camera.viewportWidth = sourceWidth * scale;
  9684. this.camera.viewportHeight = sourceHeight * scale;
  9685. }
  9686. this.camera.update();
  9687. };
  9688. SceneRenderer.prototype.enableRenderer = function (renderer) {
  9689. if (this.activeRenderer === renderer)
  9690. return;
  9691. this.end();
  9692. if (renderer instanceof webgl.PolygonBatcher) {
  9693. this.batcherShader.bind();
  9694. this.batcherShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values);
  9695. this.batcherShader.setUniformi("u_texture", 0);
  9696. this.batcher.begin(this.batcherShader);
  9697. this.activeRenderer = this.batcher;
  9698. }
  9699. else if (renderer instanceof webgl.ShapeRenderer) {
  9700. this.shapesShader.bind();
  9701. this.shapesShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values);
  9702. this.shapes.begin(this.shapesShader);
  9703. this.activeRenderer = this.shapes;
  9704. }
  9705. else {
  9706. this.activeRenderer = this.skeletonDebugRenderer;
  9707. }
  9708. };
  9709. SceneRenderer.prototype.dispose = function () {
  9710. this.batcher.dispose();
  9711. this.batcherShader.dispose();
  9712. this.shapes.dispose();
  9713. this.shapesShader.dispose();
  9714. this.skeletonDebugRenderer.dispose();
  9715. };
  9716. return SceneRenderer;
  9717. }());
  9718. webgl.SceneRenderer = SceneRenderer;
  9719. var ResizeMode;
  9720. (function (ResizeMode) {
  9721. ResizeMode[ResizeMode["Stretch"] = 0] = "Stretch";
  9722. ResizeMode[ResizeMode["Expand"] = 1] = "Expand";
  9723. ResizeMode[ResizeMode["Fit"] = 2] = "Fit";
  9724. })(ResizeMode = webgl.ResizeMode || (webgl.ResizeMode = {}));
  9725. })(webgl = spine.webgl || (spine.webgl = {}));
  9726. })(spine || (spine = {}));
  9727. var spine;
  9728. (function (spine) {
  9729. var webgl;
  9730. (function (webgl) {
  9731. var Shader = (function () {
  9732. function Shader(context, vertexShader, fragmentShader) {
  9733. this.vertexShader = vertexShader;
  9734. this.fragmentShader = fragmentShader;
  9735. this.vs = null;
  9736. this.fs = null;
  9737. this.program = null;
  9738. this.tmp2x2 = new Float32Array(2 * 2);
  9739. this.tmp3x3 = new Float32Array(3 * 3);
  9740. this.tmp4x4 = new Float32Array(4 * 4);
  9741. this.vsSource = vertexShader;
  9742. this.fsSource = fragmentShader;
  9743. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  9744. this.context.addRestorable(this);
  9745. this.compile();
  9746. }
  9747. Shader.prototype.getProgram = function () { return this.program; };
  9748. Shader.prototype.getVertexShader = function () { return this.vertexShader; };
  9749. Shader.prototype.getFragmentShader = function () { return this.fragmentShader; };
  9750. Shader.prototype.getVertexShaderSource = function () { return this.vsSource; };
  9751. Shader.prototype.getFragmentSource = function () { return this.fsSource; };
  9752. Shader.prototype.compile = function () {
  9753. var gl = this.context.gl;
  9754. try {
  9755. this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader);
  9756. this.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader);
  9757. this.program = this.compileProgram(this.vs, this.fs);
  9758. }
  9759. catch (e) {
  9760. this.dispose();
  9761. throw e;
  9762. }
  9763. };
  9764. Shader.prototype.compileShader = function (type, source) {
  9765. var gl = this.context.gl;
  9766. var shader = gl.createShader(type);
  9767. gl.shaderSource(shader, source);
  9768. gl.compileShader(shader);
  9769. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  9770. var error = "Couldn't compile shader: " + gl.getShaderInfoLog(shader);
  9771. gl.deleteShader(shader);
  9772. if (!gl.isContextLost())
  9773. throw new Error(error);
  9774. }
  9775. return shader;
  9776. };
  9777. Shader.prototype.compileProgram = function (vs, fs) {
  9778. var gl = this.context.gl;
  9779. var program = gl.createProgram();
  9780. gl.attachShader(program, vs);
  9781. gl.attachShader(program, fs);
  9782. gl.linkProgram(program);
  9783. if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
  9784. var error = "Couldn't compile shader program: " + gl.getProgramInfoLog(program);
  9785. gl.deleteProgram(program);
  9786. if (!gl.isContextLost())
  9787. throw new Error(error);
  9788. }
  9789. return program;
  9790. };
  9791. Shader.prototype.restore = function () {
  9792. this.compile();
  9793. };
  9794. Shader.prototype.bind = function () {
  9795. this.context.gl.useProgram(this.program);
  9796. };
  9797. Shader.prototype.unbind = function () {
  9798. this.context.gl.useProgram(null);
  9799. };
  9800. Shader.prototype.setUniformi = function (uniform, value) {
  9801. this.context.gl.uniform1i(this.getUniformLocation(uniform), value);
  9802. };
  9803. Shader.prototype.setUniformf = function (uniform, value) {
  9804. this.context.gl.uniform1f(this.getUniformLocation(uniform), value);
  9805. };
  9806. Shader.prototype.setUniform2f = function (uniform, value, value2) {
  9807. this.context.gl.uniform2f(this.getUniformLocation(uniform), value, value2);
  9808. };
  9809. Shader.prototype.setUniform3f = function (uniform, value, value2, value3) {
  9810. this.context.gl.uniform3f(this.getUniformLocation(uniform), value, value2, value3);
  9811. };
  9812. Shader.prototype.setUniform4f = function (uniform, value, value2, value3, value4) {
  9813. this.context.gl.uniform4f(this.getUniformLocation(uniform), value, value2, value3, value4);
  9814. };
  9815. Shader.prototype.setUniform2x2f = function (uniform, value) {
  9816. var gl = this.context.gl;
  9817. this.tmp2x2.set(value);
  9818. gl.uniformMatrix2fv(this.getUniformLocation(uniform), false, this.tmp2x2);
  9819. };
  9820. Shader.prototype.setUniform3x3f = function (uniform, value) {
  9821. var gl = this.context.gl;
  9822. this.tmp3x3.set(value);
  9823. gl.uniformMatrix3fv(this.getUniformLocation(uniform), false, this.tmp3x3);
  9824. };
  9825. Shader.prototype.setUniform4x4f = function (uniform, value) {
  9826. var gl = this.context.gl;
  9827. this.tmp4x4.set(value);
  9828. gl.uniformMatrix4fv(this.getUniformLocation(uniform), false, this.tmp4x4);
  9829. };
  9830. Shader.prototype.getUniformLocation = function (uniform) {
  9831. var gl = this.context.gl;
  9832. var location = gl.getUniformLocation(this.program, uniform);
  9833. if (!location && !gl.isContextLost())
  9834. throw new Error("Couldn't find location for uniform " + uniform);
  9835. return location;
  9836. };
  9837. Shader.prototype.getAttributeLocation = function (attribute) {
  9838. var gl = this.context.gl;
  9839. var location = gl.getAttribLocation(this.program, attribute);
  9840. if (location == -1 && !gl.isContextLost())
  9841. throw new Error("Couldn't find location for attribute " + attribute);
  9842. return location;
  9843. };
  9844. Shader.prototype.dispose = function () {
  9845. this.context.removeRestorable(this);
  9846. var gl = this.context.gl;
  9847. if (this.vs) {
  9848. gl.deleteShader(this.vs);
  9849. this.vs = null;
  9850. }
  9851. if (this.fs) {
  9852. gl.deleteShader(this.fs);
  9853. this.fs = null;
  9854. }
  9855. if (this.program) {
  9856. gl.deleteProgram(this.program);
  9857. this.program = null;
  9858. }
  9859. };
  9860. Shader.newColoredTextured = function (context) {
  9861. 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";
  9862. 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";
  9863. return new Shader(context, vs, fs);
  9864. };
  9865. Shader.newTwoColoredTextured = function (context) {
  9866. 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";
  9867. 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";
  9868. return new Shader(context, vs, fs);
  9869. };
  9870. Shader.newColored = function (context) {
  9871. 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";
  9872. 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";
  9873. return new Shader(context, vs, fs);
  9874. };
  9875. Shader.MVP_MATRIX = "u_projTrans";
  9876. Shader.POSITION = "a_position";
  9877. Shader.COLOR = "a_color";
  9878. Shader.COLOR2 = "a_color2";
  9879. Shader.TEXCOORDS = "a_texCoords";
  9880. Shader.SAMPLER = "u_texture";
  9881. return Shader;
  9882. }());
  9883. webgl.Shader = Shader;
  9884. })(webgl = spine.webgl || (spine.webgl = {}));
  9885. })(spine || (spine = {}));
  9886. var spine;
  9887. (function (spine) {
  9888. var webgl;
  9889. (function (webgl) {
  9890. var ShapeRenderer = (function () {
  9891. function ShapeRenderer(context, maxVertices) {
  9892. if (maxVertices === void 0) { maxVertices = 10920; }
  9893. this.isDrawing = false;
  9894. this.shapeType = ShapeType.Filled;
  9895. this.color = new spine.Color(1, 1, 1, 1);
  9896. this.vertexIndex = 0;
  9897. this.tmp = new spine.Vector2();
  9898. if (maxVertices > 10920)
  9899. throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
  9900. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  9901. this.mesh = new webgl.Mesh(context, [new webgl.Position2Attribute(), new webgl.ColorAttribute()], maxVertices, 0);
  9902. this.srcBlend = this.context.gl.SRC_ALPHA;
  9903. this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;
  9904. }
  9905. ShapeRenderer.prototype.begin = function (shader) {
  9906. if (this.isDrawing)
  9907. throw new Error("ShapeRenderer.begin() has already been called");
  9908. this.shader = shader;
  9909. this.vertexIndex = 0;
  9910. this.isDrawing = true;
  9911. var gl = this.context.gl;
  9912. gl.enable(gl.BLEND);
  9913. gl.blendFunc(this.srcBlend, this.dstBlend);
  9914. };
  9915. ShapeRenderer.prototype.setBlendMode = function (srcBlend, dstBlend) {
  9916. var gl = this.context.gl;
  9917. this.srcBlend = srcBlend;
  9918. this.dstBlend = dstBlend;
  9919. if (this.isDrawing) {
  9920. this.flush();
  9921. gl.blendFunc(this.srcBlend, this.dstBlend);
  9922. }
  9923. };
  9924. ShapeRenderer.prototype.setColor = function (color) {
  9925. this.color.setFromColor(color);
  9926. };
  9927. ShapeRenderer.prototype.setColorWith = function (r, g, b, a) {
  9928. this.color.set(r, g, b, a);
  9929. };
  9930. ShapeRenderer.prototype.point = function (x, y, color) {
  9931. if (color === void 0) { color = null; }
  9932. this.check(ShapeType.Point, 1);
  9933. if (color === null)
  9934. color = this.color;
  9935. this.vertex(x, y, color);
  9936. };
  9937. ShapeRenderer.prototype.line = function (x, y, x2, y2, color) {
  9938. if (color === void 0) { color = null; }
  9939. this.check(ShapeType.Line, 2);
  9940. var vertices = this.mesh.getVertices();
  9941. var idx = this.vertexIndex;
  9942. if (color === null)
  9943. color = this.color;
  9944. this.vertex(x, y, color);
  9945. this.vertex(x2, y2, color);
  9946. };
  9947. ShapeRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {
  9948. if (color === void 0) { color = null; }
  9949. if (color2 === void 0) { color2 = null; }
  9950. if (color3 === void 0) { color3 = null; }
  9951. this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
  9952. var vertices = this.mesh.getVertices();
  9953. var idx = this.vertexIndex;
  9954. if (color === null)
  9955. color = this.color;
  9956. if (color2 === null)
  9957. color2 = this.color;
  9958. if (color3 === null)
  9959. color3 = this.color;
  9960. if (filled) {
  9961. this.vertex(x, y, color);
  9962. this.vertex(x2, y2, color2);
  9963. this.vertex(x3, y3, color3);
  9964. }
  9965. else {
  9966. this.vertex(x, y, color);
  9967. this.vertex(x2, y2, color2);
  9968. this.vertex(x2, y2, color);
  9969. this.vertex(x3, y3, color2);
  9970. this.vertex(x3, y3, color);
  9971. this.vertex(x, y, color2);
  9972. }
  9973. };
  9974. ShapeRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
  9975. if (color === void 0) { color = null; }
  9976. if (color2 === void 0) { color2 = null; }
  9977. if (color3 === void 0) { color3 = null; }
  9978. if (color4 === void 0) { color4 = null; }
  9979. this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
  9980. var vertices = this.mesh.getVertices();
  9981. var idx = this.vertexIndex;
  9982. if (color === null)
  9983. color = this.color;
  9984. if (color2 === null)
  9985. color2 = this.color;
  9986. if (color3 === null)
  9987. color3 = this.color;
  9988. if (color4 === null)
  9989. color4 = this.color;
  9990. if (filled) {
  9991. this.vertex(x, y, color);
  9992. this.vertex(x2, y2, color2);
  9993. this.vertex(x3, y3, color3);
  9994. this.vertex(x3, y3, color3);
  9995. this.vertex(x4, y4, color4);
  9996. this.vertex(x, y, color);
  9997. }
  9998. else {
  9999. this.vertex(x, y, color);
  10000. this.vertex(x2, y2, color2);
  10001. this.vertex(x2, y2, color2);
  10002. this.vertex(x3, y3, color3);
  10003. this.vertex(x3, y3, color3);
  10004. this.vertex(x4, y4, color4);
  10005. this.vertex(x4, y4, color4);
  10006. this.vertex(x, y, color);
  10007. }
  10008. };
  10009. ShapeRenderer.prototype.rect = function (filled, x, y, width, height, color) {
  10010. if (color === void 0) { color = null; }
  10011. this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color);
  10012. };
  10013. ShapeRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) {
  10014. if (color === void 0) { color = null; }
  10015. this.check(filled ? ShapeType.Filled : ShapeType.Line, 8);
  10016. if (color === null)
  10017. color = this.color;
  10018. var t = this.tmp.set(y2 - y1, x1 - x2);
  10019. t.normalize();
  10020. width *= 0.5;
  10021. var tx = t.x * width;
  10022. var ty = t.y * width;
  10023. if (!filled) {
  10024. this.vertex(x1 + tx, y1 + ty, color);
  10025. this.vertex(x1 - tx, y1 - ty, color);
  10026. this.vertex(x2 + tx, y2 + ty, color);
  10027. this.vertex(x2 - tx, y2 - ty, color);
  10028. this.vertex(x2 + tx, y2 + ty, color);
  10029. this.vertex(x1 + tx, y1 + ty, color);
  10030. this.vertex(x2 - tx, y2 - ty, color);
  10031. this.vertex(x1 - tx, y1 - ty, color);
  10032. }
  10033. else {
  10034. this.vertex(x1 + tx, y1 + ty, color);
  10035. this.vertex(x1 - tx, y1 - ty, color);
  10036. this.vertex(x2 + tx, y2 + ty, color);
  10037. this.vertex(x2 - tx, y2 - ty, color);
  10038. this.vertex(x2 + tx, y2 + ty, color);
  10039. this.vertex(x1 - tx, y1 - ty, color);
  10040. }
  10041. };
  10042. ShapeRenderer.prototype.x = function (x, y, size) {
  10043. this.line(x - size, y - size, x + size, y + size);
  10044. this.line(x - size, y + size, x + size, y - size);
  10045. };
  10046. ShapeRenderer.prototype.polygon = function (polygonVertices, offset, count, color) {
  10047. if (color === void 0) { color = null; }
  10048. if (count < 3)
  10049. throw new Error("Polygon must contain at least 3 vertices");
  10050. this.check(ShapeType.Line, count * 2);
  10051. if (color === null)
  10052. color = this.color;
  10053. var vertices = this.mesh.getVertices();
  10054. var idx = this.vertexIndex;
  10055. offset <<= 1;
  10056. count <<= 1;
  10057. var firstX = polygonVertices[offset];
  10058. var firstY = polygonVertices[offset + 1];
  10059. var last = offset + count;
  10060. for (var i = offset, n = offset + count - 2; i < n; i += 2) {
  10061. var x1 = polygonVertices[i];
  10062. var y1 = polygonVertices[i + 1];
  10063. var x2 = 0;
  10064. var y2 = 0;
  10065. if (i + 2 >= last) {
  10066. x2 = firstX;
  10067. y2 = firstY;
  10068. }
  10069. else {
  10070. x2 = polygonVertices[i + 2];
  10071. y2 = polygonVertices[i + 3];
  10072. }
  10073. this.vertex(x1, y1, color);
  10074. this.vertex(x2, y2, color);
  10075. }
  10076. };
  10077. ShapeRenderer.prototype.circle = function (filled, x, y, radius, color, segments) {
  10078. if (color === void 0) { color = null; }
  10079. if (segments === void 0) { segments = 0; }
  10080. if (segments === 0)
  10081. segments = Math.max(1, (6 * spine.MathUtils.cbrt(radius)) | 0);
  10082. if (segments <= 0)
  10083. throw new Error("segments must be > 0.");
  10084. if (color === null)
  10085. color = this.color;
  10086. var angle = 2 * spine.MathUtils.PI / segments;
  10087. var cos = Math.cos(angle);
  10088. var sin = Math.sin(angle);
  10089. var cx = radius, cy = 0;
  10090. if (!filled) {
  10091. this.check(ShapeType.Line, segments * 2 + 2);
  10092. for (var i = 0; i < segments; i++) {
  10093. this.vertex(x + cx, y + cy, color);
  10094. var temp_1 = cx;
  10095. cx = cos * cx - sin * cy;
  10096. cy = sin * temp_1 + cos * cy;
  10097. this.vertex(x + cx, y + cy, color);
  10098. }
  10099. this.vertex(x + cx, y + cy, color);
  10100. }
  10101. else {
  10102. this.check(ShapeType.Filled, segments * 3 + 3);
  10103. segments--;
  10104. for (var i = 0; i < segments; i++) {
  10105. this.vertex(x, y, color);
  10106. this.vertex(x + cx, y + cy, color);
  10107. var temp_2 = cx;
  10108. cx = cos * cx - sin * cy;
  10109. cy = sin * temp_2 + cos * cy;
  10110. this.vertex(x + cx, y + cy, color);
  10111. }
  10112. this.vertex(x, y, color);
  10113. this.vertex(x + cx, y + cy, color);
  10114. }
  10115. var temp = cx;
  10116. cx = radius;
  10117. cy = 0;
  10118. this.vertex(x + cx, y + cy, color);
  10119. };
  10120. ShapeRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
  10121. if (color === void 0) { color = null; }
  10122. this.check(ShapeType.Line, segments * 2 + 2);
  10123. if (color === null)
  10124. color = this.color;
  10125. var subdiv_step = 1 / segments;
  10126. var subdiv_step2 = subdiv_step * subdiv_step;
  10127. var subdiv_step3 = subdiv_step * subdiv_step * subdiv_step;
  10128. var pre1 = 3 * subdiv_step;
  10129. var pre2 = 3 * subdiv_step2;
  10130. var pre4 = 6 * subdiv_step2;
  10131. var pre5 = 6 * subdiv_step3;
  10132. var tmp1x = x1 - cx1 * 2 + cx2;
  10133. var tmp1y = y1 - cy1 * 2 + cy2;
  10134. var tmp2x = (cx1 - cx2) * 3 - x1 + x2;
  10135. var tmp2y = (cy1 - cy2) * 3 - y1 + y2;
  10136. var fx = x1;
  10137. var fy = y1;
  10138. var dfx = (cx1 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3;
  10139. var dfy = (cy1 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3;
  10140. var ddfx = tmp1x * pre4 + tmp2x * pre5;
  10141. var ddfy = tmp1y * pre4 + tmp2y * pre5;
  10142. var dddfx = tmp2x * pre5;
  10143. var dddfy = tmp2y * pre5;
  10144. while (segments-- > 0) {
  10145. this.vertex(fx, fy, color);
  10146. fx += dfx;
  10147. fy += dfy;
  10148. dfx += ddfx;
  10149. dfy += ddfy;
  10150. ddfx += dddfx;
  10151. ddfy += dddfy;
  10152. this.vertex(fx, fy, color);
  10153. }
  10154. this.vertex(fx, fy, color);
  10155. this.vertex(x2, y2, color);
  10156. };
  10157. ShapeRenderer.prototype.vertex = function (x, y, color) {
  10158. var idx = this.vertexIndex;
  10159. var vertices = this.mesh.getVertices();
  10160. vertices[idx++] = x;
  10161. vertices[idx++] = y;
  10162. vertices[idx++] = color.r;
  10163. vertices[idx++] = color.g;
  10164. vertices[idx++] = color.b;
  10165. vertices[idx++] = color.a;
  10166. this.vertexIndex = idx;
  10167. };
  10168. ShapeRenderer.prototype.end = function () {
  10169. if (!this.isDrawing)
  10170. throw new Error("ShapeRenderer.begin() has not been called");
  10171. this.flush();
  10172. this.context.gl.disable(this.context.gl.BLEND);
  10173. this.isDrawing = false;
  10174. };
  10175. ShapeRenderer.prototype.flush = function () {
  10176. if (this.vertexIndex == 0)
  10177. return;
  10178. this.mesh.setVerticesLength(this.vertexIndex);
  10179. this.mesh.draw(this.shader, this.shapeType);
  10180. this.vertexIndex = 0;
  10181. };
  10182. ShapeRenderer.prototype.check = function (shapeType, numVertices) {
  10183. if (!this.isDrawing)
  10184. throw new Error("ShapeRenderer.begin() has not been called");
  10185. if (this.shapeType == shapeType) {
  10186. if (this.mesh.maxVertices() - this.mesh.numVertices() < numVertices)
  10187. this.flush();
  10188. else
  10189. return;
  10190. }
  10191. else {
  10192. this.flush();
  10193. this.shapeType = shapeType;
  10194. }
  10195. };
  10196. ShapeRenderer.prototype.dispose = function () {
  10197. this.mesh.dispose();
  10198. };
  10199. return ShapeRenderer;
  10200. }());
  10201. webgl.ShapeRenderer = ShapeRenderer;
  10202. var ShapeType;
  10203. (function (ShapeType) {
  10204. ShapeType[ShapeType["Point"] = 0] = "Point";
  10205. ShapeType[ShapeType["Line"] = 1] = "Line";
  10206. ShapeType[ShapeType["Filled"] = 4] = "Filled";
  10207. })(ShapeType = webgl.ShapeType || (webgl.ShapeType = {}));
  10208. })(webgl = spine.webgl || (spine.webgl = {}));
  10209. })(spine || (spine = {}));
  10210. var spine;
  10211. (function (spine) {
  10212. var webgl;
  10213. (function (webgl) {
  10214. var SkeletonDebugRenderer = (function () {
  10215. function SkeletonDebugRenderer(context) {
  10216. this.boneLineColor = new spine.Color(1, 0, 0, 1);
  10217. this.boneOriginColor = new spine.Color(0, 1, 0, 1);
  10218. this.attachmentLineColor = new spine.Color(0, 0, 1, 0.5);
  10219. this.triangleLineColor = new spine.Color(1, 0.64, 0, 0.5);
  10220. this.pathColor = new spine.Color().setFromString("FF7F00");
  10221. this.clipColor = new spine.Color(0.8, 0, 0, 2);
  10222. this.aabbColor = new spine.Color(0, 1, 0, 0.5);
  10223. this.drawBones = true;
  10224. this.drawRegionAttachments = true;
  10225. this.drawBoundingBoxes = true;
  10226. this.drawMeshHull = true;
  10227. this.drawMeshTriangles = true;
  10228. this.drawPaths = true;
  10229. this.drawSkeletonXY = false;
  10230. this.drawClipping = true;
  10231. this.premultipliedAlpha = false;
  10232. this.scale = 1;
  10233. this.boneWidth = 2;
  10234. this.bounds = new spine.SkeletonBounds();
  10235. this.temp = new Array();
  10236. this.vertices = spine.Utils.newFloatArray(2 * 1024);
  10237. this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);
  10238. }
  10239. SkeletonDebugRenderer.prototype.draw = function (shapes, skeleton, ignoredBones) {
  10240. if (ignoredBones === void 0) { ignoredBones = null; }
  10241. var skeletonX = skeleton.x;
  10242. var skeletonY = skeleton.y;
  10243. var gl = this.context.gl;
  10244. var srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;
  10245. shapes.setBlendMode(srcFunc, gl.ONE_MINUS_SRC_ALPHA);
  10246. var bones = skeleton.bones;
  10247. if (this.drawBones) {
  10248. shapes.setColor(this.boneLineColor);
  10249. for (var i = 0, n = bones.length; i < n; i++) {
  10250. var bone = bones[i];
  10251. if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)
  10252. continue;
  10253. if (bone.parent == null)
  10254. continue;
  10255. var x = skeletonX + bone.data.length * bone.a + bone.worldX;
  10256. var y = skeletonY + bone.data.length * bone.c + bone.worldY;
  10257. shapes.rectLine(true, skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, this.boneWidth * this.scale);
  10258. }
  10259. if (this.drawSkeletonXY)
  10260. shapes.x(skeletonX, skeletonY, 4 * this.scale);
  10261. }
  10262. if (this.drawRegionAttachments) {
  10263. shapes.setColor(this.attachmentLineColor);
  10264. var slots = skeleton.slots;
  10265. for (var i = 0, n = slots.length; i < n; i++) {
  10266. var slot = slots[i];
  10267. var attachment = slot.getAttachment();
  10268. if (attachment instanceof spine.RegionAttachment) {
  10269. var regionAttachment = attachment;
  10270. var vertices = this.vertices;
  10271. regionAttachment.computeWorldVertices(slot.bone, vertices, 0, 2);
  10272. shapes.line(vertices[0], vertices[1], vertices[2], vertices[3]);
  10273. shapes.line(vertices[2], vertices[3], vertices[4], vertices[5]);
  10274. shapes.line(vertices[4], vertices[5], vertices[6], vertices[7]);
  10275. shapes.line(vertices[6], vertices[7], vertices[0], vertices[1]);
  10276. }
  10277. }
  10278. }
  10279. if (this.drawMeshHull || this.drawMeshTriangles) {
  10280. var slots = skeleton.slots;
  10281. for (var i = 0, n = slots.length; i < n; i++) {
  10282. var slot = slots[i];
  10283. if (!slot.bone.active)
  10284. continue;
  10285. var attachment = slot.getAttachment();
  10286. if (!(attachment instanceof spine.MeshAttachment))
  10287. continue;
  10288. var mesh = attachment;
  10289. var vertices = this.vertices;
  10290. mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 2);
  10291. var triangles = mesh.triangles;
  10292. var hullLength = mesh.hullLength;
  10293. if (this.drawMeshTriangles) {
  10294. shapes.setColor(this.triangleLineColor);
  10295. for (var ii = 0, nn = triangles.length; ii < nn; ii += 3) {
  10296. var v1 = triangles[ii] * 2, v2 = triangles[ii + 1] * 2, v3 = triangles[ii + 2] * 2;
  10297. shapes.triangle(false, vertices[v1], vertices[v1 + 1], vertices[v2], vertices[v2 + 1], vertices[v3], vertices[v3 + 1]);
  10298. }
  10299. }
  10300. if (this.drawMeshHull && hullLength > 0) {
  10301. shapes.setColor(this.attachmentLineColor);
  10302. hullLength = (hullLength >> 1) * 2;
  10303. var lastX = vertices[hullLength - 2], lastY = vertices[hullLength - 1];
  10304. for (var ii = 0, nn = hullLength; ii < nn; ii += 2) {
  10305. var x = vertices[ii], y = vertices[ii + 1];
  10306. shapes.line(x, y, lastX, lastY);
  10307. lastX = x;
  10308. lastY = y;
  10309. }
  10310. }
  10311. }
  10312. }
  10313. if (this.drawBoundingBoxes) {
  10314. var bounds = this.bounds;
  10315. bounds.update(skeleton, true);
  10316. shapes.setColor(this.aabbColor);
  10317. shapes.rect(false, bounds.minX, bounds.minY, bounds.getWidth(), bounds.getHeight());
  10318. var polygons = bounds.polygons;
  10319. var boxes = bounds.boundingBoxes;
  10320. for (var i = 0, n = polygons.length; i < n; i++) {
  10321. var polygon = polygons[i];
  10322. shapes.setColor(boxes[i].color);
  10323. shapes.polygon(polygon, 0, polygon.length);
  10324. }
  10325. }
  10326. if (this.drawPaths) {
  10327. var slots = skeleton.slots;
  10328. for (var i = 0, n = slots.length; i < n; i++) {
  10329. var slot = slots[i];
  10330. if (!slot.bone.active)
  10331. continue;
  10332. var attachment = slot.getAttachment();
  10333. if (!(attachment instanceof spine.PathAttachment))
  10334. continue;
  10335. var path = attachment;
  10336. var nn = path.worldVerticesLength;
  10337. var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
  10338. path.computeWorldVertices(slot, 0, nn, world, 0, 2);
  10339. var color = this.pathColor;
  10340. var x1 = world[2], y1 = world[3], x2 = 0, y2 = 0;
  10341. if (path.closed) {
  10342. shapes.setColor(color);
  10343. var cx1 = world[0], cy1 = world[1], cx2 = world[nn - 2], cy2 = world[nn - 1];
  10344. x2 = world[nn - 4];
  10345. y2 = world[nn - 3];
  10346. shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);
  10347. shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);
  10348. shapes.line(x1, y1, cx1, cy1);
  10349. shapes.line(x2, y2, cx2, cy2);
  10350. }
  10351. nn -= 4;
  10352. for (var ii = 4; ii < nn; ii += 6) {
  10353. var cx1 = world[ii], cy1 = world[ii + 1], cx2 = world[ii + 2], cy2 = world[ii + 3];
  10354. x2 = world[ii + 4];
  10355. y2 = world[ii + 5];
  10356. shapes.setColor(color);
  10357. shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);
  10358. shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);
  10359. shapes.line(x1, y1, cx1, cy1);
  10360. shapes.line(x2, y2, cx2, cy2);
  10361. x1 = x2;
  10362. y1 = y2;
  10363. }
  10364. }
  10365. }
  10366. if (this.drawBones) {
  10367. shapes.setColor(this.boneOriginColor);
  10368. for (var i = 0, n = bones.length; i < n; i++) {
  10369. var bone = bones[i];
  10370. if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)
  10371. continue;
  10372. shapes.circle(true, skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * this.scale, SkeletonDebugRenderer.GREEN, 8);
  10373. }
  10374. }
  10375. if (this.drawClipping) {
  10376. var slots = skeleton.slots;
  10377. shapes.setColor(this.clipColor);
  10378. for (var i = 0, n = slots.length; i < n; i++) {
  10379. var slot = slots[i];
  10380. if (!slot.bone.active)
  10381. continue;
  10382. var attachment = slot.getAttachment();
  10383. if (!(attachment instanceof spine.ClippingAttachment))
  10384. continue;
  10385. var clip = attachment;
  10386. var nn = clip.worldVerticesLength;
  10387. var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
  10388. clip.computeWorldVertices(slot, 0, nn, world, 0, 2);
  10389. for (var i_21 = 0, n_3 = world.length; i_21 < n_3; i_21 += 2) {
  10390. var x = world[i_21];
  10391. var y = world[i_21 + 1];
  10392. var x2 = world[(i_21 + 2) % world.length];
  10393. var y2 = world[(i_21 + 3) % world.length];
  10394. shapes.line(x, y, x2, y2);
  10395. }
  10396. }
  10397. }
  10398. };
  10399. SkeletonDebugRenderer.prototype.dispose = function () {
  10400. };
  10401. SkeletonDebugRenderer.LIGHT_GRAY = new spine.Color(192 / 255, 192 / 255, 192 / 255, 1);
  10402. SkeletonDebugRenderer.GREEN = new spine.Color(0, 1, 0, 1);
  10403. return SkeletonDebugRenderer;
  10404. }());
  10405. webgl.SkeletonDebugRenderer = SkeletonDebugRenderer;
  10406. })(webgl = spine.webgl || (spine.webgl = {}));
  10407. })(spine || (spine = {}));
  10408. var spine;
  10409. (function (spine) {
  10410. var webgl;
  10411. (function (webgl) {
  10412. var Renderable = (function () {
  10413. function Renderable(vertices, numVertices, numFloats) {
  10414. this.vertices = vertices;
  10415. this.numVertices = numVertices;
  10416. this.numFloats = numFloats;
  10417. }
  10418. return Renderable;
  10419. }());
  10420. ;
  10421. var SkeletonRenderer = (function () {
  10422. function SkeletonRenderer(context, twoColorTint) {
  10423. if (twoColorTint === void 0) { twoColorTint = true; }
  10424. this.premultipliedAlpha = false;
  10425. this.vertexEffect = null;
  10426. this.tempColor = new spine.Color();
  10427. this.tempColor2 = new spine.Color();
  10428. this.vertexSize = 2 + 2 + 4;
  10429. this.twoColorTint = false;
  10430. this.renderable = new Renderable(null, 0, 0);
  10431. this.clipper = new spine.SkeletonClipping();
  10432. this.temp = new spine.Vector2();
  10433. this.temp2 = new spine.Vector2();
  10434. this.temp3 = new spine.Color();
  10435. this.temp4 = new spine.Color();
  10436. this.twoColorTint = twoColorTint;
  10437. if (twoColorTint)
  10438. this.vertexSize += 4;
  10439. this.vertices = spine.Utils.newFloatArray(this.vertexSize * 1024);
  10440. }
  10441. SkeletonRenderer.prototype.draw = function (batcher, skeleton, slotRangeStart, slotRangeEnd) {
  10442. if (slotRangeStart === void 0) { slotRangeStart = -1; }
  10443. if (slotRangeEnd === void 0) { slotRangeEnd = -1; }
  10444. var clipper = this.clipper;
  10445. var premultipliedAlpha = this.premultipliedAlpha;
  10446. var twoColorTint = this.twoColorTint;
  10447. var blendMode = null;
  10448. var tempPos = this.temp;
  10449. var tempUv = this.temp2;
  10450. var tempLight = this.temp3;
  10451. var tempDark = this.temp4;
  10452. var renderable = this.renderable;
  10453. var uvs = null;
  10454. var triangles = null;
  10455. var drawOrder = skeleton.drawOrder;
  10456. var attachmentColor = null;
  10457. var skeletonColor = skeleton.color;
  10458. var vertexSize = twoColorTint ? 12 : 8;
  10459. var inRange = false;
  10460. if (slotRangeStart == -1)
  10461. inRange = true;
  10462. for (var i = 0, n = drawOrder.length; i < n; i++) {
  10463. var clippedVertexSize = clipper.isClipping() ? 2 : vertexSize;
  10464. var slot = drawOrder[i];
  10465. if (!slot.bone.active) {
  10466. clipper.clipEndWithSlot(slot);
  10467. continue;
  10468. }
  10469. if (slotRangeStart >= 0 && slotRangeStart == slot.data.index) {
  10470. inRange = true;
  10471. }
  10472. if (!inRange) {
  10473. clipper.clipEndWithSlot(slot);
  10474. continue;
  10475. }
  10476. if (slotRangeEnd >= 0 && slotRangeEnd == slot.data.index) {
  10477. inRange = false;
  10478. }
  10479. var attachment = slot.getAttachment();
  10480. var texture = null;
  10481. if (attachment instanceof spine.RegionAttachment) {
  10482. var region = attachment;
  10483. renderable.vertices = this.vertices;
  10484. renderable.numVertices = 4;
  10485. renderable.numFloats = clippedVertexSize << 2;
  10486. region.computeWorldVertices(slot.bone, renderable.vertices, 0, clippedVertexSize);
  10487. triangles = SkeletonRenderer.QUAD_TRIANGLES;
  10488. uvs = region.uvs;
  10489. texture = region.region.renderObject.texture;
  10490. attachmentColor = region.color;
  10491. }
  10492. else if (attachment instanceof spine.MeshAttachment) {
  10493. var mesh = attachment;
  10494. renderable.vertices = this.vertices;
  10495. renderable.numVertices = (mesh.worldVerticesLength >> 1);
  10496. renderable.numFloats = renderable.numVertices * clippedVertexSize;
  10497. if (renderable.numFloats > renderable.vertices.length) {
  10498. renderable.vertices = this.vertices = spine.Utils.newFloatArray(renderable.numFloats);
  10499. }
  10500. mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize);
  10501. triangles = mesh.triangles;
  10502. texture = mesh.region.renderObject.texture;
  10503. uvs = mesh.uvs;
  10504. attachmentColor = mesh.color;
  10505. }
  10506. else if (attachment instanceof spine.ClippingAttachment) {
  10507. var clip = (attachment);
  10508. clipper.clipStart(slot, clip);
  10509. continue;
  10510. }
  10511. else {
  10512. clipper.clipEndWithSlot(slot);
  10513. continue;
  10514. }
  10515. if (texture != null) {
  10516. var slotColor = slot.color;
  10517. var finalColor = this.tempColor;
  10518. finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r;
  10519. finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g;
  10520. finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;
  10521. finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a;
  10522. if (premultipliedAlpha) {
  10523. finalColor.r *= finalColor.a;
  10524. finalColor.g *= finalColor.a;
  10525. finalColor.b *= finalColor.a;
  10526. }
  10527. var darkColor = this.tempColor2;
  10528. if (slot.darkColor == null)
  10529. darkColor.set(0, 0, 0, 1.0);
  10530. else {
  10531. if (premultipliedAlpha) {
  10532. darkColor.r = slot.darkColor.r * finalColor.a;
  10533. darkColor.g = slot.darkColor.g * finalColor.a;
  10534. darkColor.b = slot.darkColor.b * finalColor.a;
  10535. }
  10536. else {
  10537. darkColor.setFromColor(slot.darkColor);
  10538. }
  10539. darkColor.a = premultipliedAlpha ? 1.0 : 0.0;
  10540. }
  10541. var slotBlendMode = slot.data.blendMode;
  10542. if (slotBlendMode != blendMode) {
  10543. blendMode = slotBlendMode;
  10544. batcher.setBlendMode(webgl.WebGLBlendModeConverter.getSourceGLBlendMode(blendMode, premultipliedAlpha), webgl.WebGLBlendModeConverter.getDestGLBlendMode(blendMode));
  10545. }
  10546. if (clipper.isClipping()) {
  10547. clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
  10548. var clippedVertices = new Float32Array(clipper.clippedVertices);
  10549. var clippedTriangles = clipper.clippedTriangles;
  10550. if (this.vertexEffect != null) {
  10551. var vertexEffect = this.vertexEffect;
  10552. var verts = clippedVertices;
  10553. if (!twoColorTint) {
  10554. for (var v = 0, n_4 = clippedVertices.length; v < n_4; v += vertexSize) {
  10555. tempPos.x = verts[v];
  10556. tempPos.y = verts[v + 1];
  10557. tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
  10558. tempUv.x = verts[v + 6];
  10559. tempUv.y = verts[v + 7];
  10560. tempDark.set(0, 0, 0, 0);
  10561. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  10562. verts[v] = tempPos.x;
  10563. verts[v + 1] = tempPos.y;
  10564. verts[v + 2] = tempLight.r;
  10565. verts[v + 3] = tempLight.g;
  10566. verts[v + 4] = tempLight.b;
  10567. verts[v + 5] = tempLight.a;
  10568. verts[v + 6] = tempUv.x;
  10569. verts[v + 7] = tempUv.y;
  10570. }
  10571. }
  10572. else {
  10573. for (var v = 0, n_5 = clippedVertices.length; v < n_5; v += vertexSize) {
  10574. tempPos.x = verts[v];
  10575. tempPos.y = verts[v + 1];
  10576. tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
  10577. tempUv.x = verts[v + 6];
  10578. tempUv.y = verts[v + 7];
  10579. tempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]);
  10580. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  10581. verts[v] = tempPos.x;
  10582. verts[v + 1] = tempPos.y;
  10583. verts[v + 2] = tempLight.r;
  10584. verts[v + 3] = tempLight.g;
  10585. verts[v + 4] = tempLight.b;
  10586. verts[v + 5] = tempLight.a;
  10587. verts[v + 6] = tempUv.x;
  10588. verts[v + 7] = tempUv.y;
  10589. verts[v + 8] = tempDark.r;
  10590. verts[v + 9] = tempDark.g;
  10591. verts[v + 10] = tempDark.b;
  10592. verts[v + 11] = tempDark.a;
  10593. }
  10594. }
  10595. }
  10596. batcher.draw(texture, clippedVertices, clippedTriangles);
  10597. }
  10598. else {
  10599. var verts = renderable.vertices;
  10600. if (this.vertexEffect != null) {
  10601. var vertexEffect = this.vertexEffect;
  10602. if (!twoColorTint) {
  10603. for (var v = 0, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) {
  10604. tempPos.x = verts[v];
  10605. tempPos.y = verts[v + 1];
  10606. tempUv.x = uvs[u];
  10607. tempUv.y = uvs[u + 1];
  10608. tempLight.setFromColor(finalColor);
  10609. tempDark.set(0, 0, 0, 0);
  10610. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  10611. verts[v] = tempPos.x;
  10612. verts[v + 1] = tempPos.y;
  10613. verts[v + 2] = tempLight.r;
  10614. verts[v + 3] = tempLight.g;
  10615. verts[v + 4] = tempLight.b;
  10616. verts[v + 5] = tempLight.a;
  10617. verts[v + 6] = tempUv.x;
  10618. verts[v + 7] = tempUv.y;
  10619. }
  10620. }
  10621. else {
  10622. for (var v = 0, u = 0, n_7 = renderable.numFloats; v < n_7; v += vertexSize, u += 2) {
  10623. tempPos.x = verts[v];
  10624. tempPos.y = verts[v + 1];
  10625. tempUv.x = uvs[u];
  10626. tempUv.y = uvs[u + 1];
  10627. tempLight.setFromColor(finalColor);
  10628. tempDark.setFromColor(darkColor);
  10629. vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
  10630. verts[v] = tempPos.x;
  10631. verts[v + 1] = tempPos.y;
  10632. verts[v + 2] = tempLight.r;
  10633. verts[v + 3] = tempLight.g;
  10634. verts[v + 4] = tempLight.b;
  10635. verts[v + 5] = tempLight.a;
  10636. verts[v + 6] = tempUv.x;
  10637. verts[v + 7] = tempUv.y;
  10638. verts[v + 8] = tempDark.r;
  10639. verts[v + 9] = tempDark.g;
  10640. verts[v + 10] = tempDark.b;
  10641. verts[v + 11] = tempDark.a;
  10642. }
  10643. }
  10644. }
  10645. else {
  10646. if (!twoColorTint) {
  10647. for (var v = 2, u = 0, n_8 = renderable.numFloats; v < n_8; v += vertexSize, u += 2) {
  10648. verts[v] = finalColor.r;
  10649. verts[v + 1] = finalColor.g;
  10650. verts[v + 2] = finalColor.b;
  10651. verts[v + 3] = finalColor.a;
  10652. verts[v + 4] = uvs[u];
  10653. verts[v + 5] = uvs[u + 1];
  10654. }
  10655. }
  10656. else {
  10657. for (var v = 2, u = 0, n_9 = renderable.numFloats; v < n_9; v += vertexSize, u += 2) {
  10658. verts[v] = finalColor.r;
  10659. verts[v + 1] = finalColor.g;
  10660. verts[v + 2] = finalColor.b;
  10661. verts[v + 3] = finalColor.a;
  10662. verts[v + 4] = uvs[u];
  10663. verts[v + 5] = uvs[u + 1];
  10664. verts[v + 6] = darkColor.r;
  10665. verts[v + 7] = darkColor.g;
  10666. verts[v + 8] = darkColor.b;
  10667. verts[v + 9] = darkColor.a;
  10668. }
  10669. }
  10670. }
  10671. var view = renderable.vertices.subarray(0, renderable.numFloats);
  10672. batcher.draw(texture, view, triangles);
  10673. }
  10674. }
  10675. clipper.clipEndWithSlot(slot);
  10676. }
  10677. clipper.clipEnd();
  10678. };
  10679. SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
  10680. return SkeletonRenderer;
  10681. }());
  10682. webgl.SkeletonRenderer = SkeletonRenderer;
  10683. })(webgl = spine.webgl || (spine.webgl = {}));
  10684. })(spine || (spine = {}));
  10685. var spine;
  10686. (function (spine) {
  10687. var webgl;
  10688. (function (webgl) {
  10689. var Vector3 = (function () {
  10690. function Vector3(x, y, z) {
  10691. if (x === void 0) { x = 0; }
  10692. if (y === void 0) { y = 0; }
  10693. if (z === void 0) { z = 0; }
  10694. this.x = 0;
  10695. this.y = 0;
  10696. this.z = 0;
  10697. this.x = x;
  10698. this.y = y;
  10699. this.z = z;
  10700. }
  10701. Vector3.prototype.setFrom = function (v) {
  10702. this.x = v.x;
  10703. this.y = v.y;
  10704. this.z = v.z;
  10705. return this;
  10706. };
  10707. Vector3.prototype.set = function (x, y, z) {
  10708. this.x = x;
  10709. this.y = y;
  10710. this.z = z;
  10711. return this;
  10712. };
  10713. Vector3.prototype.add = function (v) {
  10714. this.x += v.x;
  10715. this.y += v.y;
  10716. this.z += v.z;
  10717. return this;
  10718. };
  10719. Vector3.prototype.sub = function (v) {
  10720. this.x -= v.x;
  10721. this.y -= v.y;
  10722. this.z -= v.z;
  10723. return this;
  10724. };
  10725. Vector3.prototype.scale = function (s) {
  10726. this.x *= s;
  10727. this.y *= s;
  10728. this.z *= s;
  10729. return this;
  10730. };
  10731. Vector3.prototype.normalize = function () {
  10732. var len = this.length();
  10733. if (len == 0)
  10734. return this;
  10735. len = 1 / len;
  10736. this.x *= len;
  10737. this.y *= len;
  10738. this.z *= len;
  10739. return this;
  10740. };
  10741. Vector3.prototype.cross = function (v) {
  10742. 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);
  10743. };
  10744. Vector3.prototype.multiply = function (matrix) {
  10745. var l_mat = matrix.values;
  10746. 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]);
  10747. };
  10748. Vector3.prototype.project = function (matrix) {
  10749. var l_mat = matrix.values;
  10750. 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]);
  10751. 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);
  10752. };
  10753. Vector3.prototype.dot = function (v) {
  10754. return this.x * v.x + this.y * v.y + this.z * v.z;
  10755. };
  10756. Vector3.prototype.length = function () {
  10757. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  10758. };
  10759. Vector3.prototype.distance = function (v) {
  10760. var a = v.x - this.x;
  10761. var b = v.y - this.y;
  10762. var c = v.z - this.z;
  10763. return Math.sqrt(a * a + b * b + c * c);
  10764. };
  10765. return Vector3;
  10766. }());
  10767. webgl.Vector3 = Vector3;
  10768. })(webgl = spine.webgl || (spine.webgl = {}));
  10769. })(spine || (spine = {}));
  10770. var spine;
  10771. (function (spine) {
  10772. var webgl;
  10773. (function (webgl) {
  10774. var ManagedWebGLRenderingContext = (function () {
  10775. function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {
  10776. if (contextConfig === void 0) { contextConfig = { alpha: "true" }; }
  10777. this.restorables = new Array();
  10778. if (!((canvasOrContext instanceof WebGLRenderingContext) || (canvasOrContext instanceof WebGL2RenderingContext))) {
  10779. this.setupCanvas(canvasOrContext, contextConfig);
  10780. }
  10781. else {
  10782. this.gl = canvasOrContext;
  10783. this.canvas = this.gl.canvas;
  10784. }
  10785. }
  10786. ManagedWebGLRenderingContext.prototype.setupCanvas = function (canvas, contextConfig) {
  10787. var _this = this;
  10788. this.gl = (canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig));
  10789. this.canvas = canvas;
  10790. canvas.addEventListener("webglcontextlost", function (e) {
  10791. var event = e;
  10792. if (e) {
  10793. e.preventDefault();
  10794. }
  10795. });
  10796. canvas.addEventListener("webglcontextrestored", function (e) {
  10797. for (var i = 0, n = _this.restorables.length; i < n; i++) {
  10798. _this.restorables[i].restore();
  10799. }
  10800. });
  10801. };
  10802. ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) {
  10803. this.restorables.push(restorable);
  10804. };
  10805. ManagedWebGLRenderingContext.prototype.removeRestorable = function (restorable) {
  10806. var index = this.restorables.indexOf(restorable);
  10807. if (index > -1)
  10808. this.restorables.splice(index, 1);
  10809. };
  10810. return ManagedWebGLRenderingContext;
  10811. }());
  10812. webgl.ManagedWebGLRenderingContext = ManagedWebGLRenderingContext;
  10813. var WebGLBlendModeConverter = (function () {
  10814. function WebGLBlendModeConverter() {
  10815. }
  10816. WebGLBlendModeConverter.getDestGLBlendMode = function (blendMode) {
  10817. switch (blendMode) {
  10818. case spine.BlendMode.Normal: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  10819. case spine.BlendMode.Additive: return WebGLBlendModeConverter.ONE;
  10820. case spine.BlendMode.Multiply: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  10821. case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
  10822. default: throw new Error("Unknown blend mode: " + blendMode);
  10823. }
  10824. };
  10825. WebGLBlendModeConverter.getSourceGLBlendMode = function (blendMode, premultipliedAlpha) {
  10826. if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
  10827. switch (blendMode) {
  10828. case spine.BlendMode.Normal: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA;
  10829. case spine.BlendMode.Additive: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA;
  10830. case spine.BlendMode.Multiply: return WebGLBlendModeConverter.DST_COLOR;
  10831. case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE;
  10832. default: throw new Error("Unknown blend mode: " + blendMode);
  10833. }
  10834. };
  10835. WebGLBlendModeConverter.ZERO = 0;
  10836. WebGLBlendModeConverter.ONE = 1;
  10837. WebGLBlendModeConverter.SRC_COLOR = 0x0300;
  10838. WebGLBlendModeConverter.ONE_MINUS_SRC_COLOR = 0x0301;
  10839. WebGLBlendModeConverter.SRC_ALPHA = 0x0302;
  10840. WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA = 0x0303;
  10841. WebGLBlendModeConverter.DST_ALPHA = 0x0304;
  10842. WebGLBlendModeConverter.ONE_MINUS_DST_ALPHA = 0x0305;
  10843. WebGLBlendModeConverter.DST_COLOR = 0x0306;
  10844. return WebGLBlendModeConverter;
  10845. }());
  10846. webgl.WebGLBlendModeConverter = WebGLBlendModeConverter;
  10847. })(webgl = spine.webgl || (spine.webgl = {}));
  10848. })(spine || (spine = {}));
  10849. module.exports = spine;