jsb-engine.js 176 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589
  1. (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. "use strict";
  3. cc.Assembler2D.prototype.updateWorldVerts = function (comp) {
  4. var local = this._local;
  5. var verts = this._renderData.vDatas[0];
  6. var vl = local[0],
  7. vr = local[2],
  8. vb = local[1],
  9. vt = local[3];
  10. var floatsPerVert = this.floatsPerVert;
  11. var vertexOffset = 0; // left bottom
  12. verts[vertexOffset] = vl;
  13. verts[vertexOffset + 1] = vb;
  14. vertexOffset += floatsPerVert; // right bottom
  15. verts[vertexOffset] = vr;
  16. verts[vertexOffset + 1] = vb;
  17. vertexOffset += floatsPerVert; // left top
  18. verts[vertexOffset] = vl;
  19. verts[vertexOffset + 1] = vt;
  20. vertexOffset += floatsPerVert; // right top
  21. verts[vertexOffset] = vr;
  22. verts[vertexOffset + 1] = vt;
  23. };
  24. var _updateColor = cc.Assembler2D.prototype.updateColor;
  25. cc.Assembler2D.prototype.updateColor = function (comp, color) {
  26. this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_OPACITY_CHANGED;
  27. _updateColor.call(this, comp, color);
  28. };
  29. },{}],2:[function(require,module,exports){
  30. "use strict";
  31. (function () {
  32. if (!cc.Assembler3D) return;
  33. cc.Assembler3D.updateWorldVerts = function (comp) {
  34. var local = this._local;
  35. var world = this._renderData.vDatas[0];
  36. var vl = local[0],
  37. vr = local[2],
  38. vb = local[1],
  39. vt = local[3]; // left bottom
  40. var floatsPerVert = this.floatsPerVert;
  41. var offset = 0;
  42. world[offset] = vl;
  43. world[offset + 1] = vb;
  44. world[offset + 2] = 0;
  45. offset += floatsPerVert; // right bottom
  46. world[offset] = vr;
  47. world[offset + 1] = vb;
  48. world[offset + 2] = 0;
  49. offset += floatsPerVert; // left top
  50. world[offset] = vl;
  51. world[offset + 1] = vt;
  52. world[offset + 2] = 0;
  53. offset += floatsPerVert; // right top
  54. world[offset] = vr;
  55. world[offset + 1] = vt;
  56. world[offset + 2] = 0;
  57. };
  58. })();
  59. },{}],3:[function(require,module,exports){
  60. "use strict";
  61. /****************************************************************************
  62. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  63. http://www.cocos.com
  64. Permission is hereby granted, free of charge, to any person obtaining a copy
  65. of this software and associated engine source code (the "Software"), a limited,
  66. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  67. to use Cocos Creator solely to develop games on your target platforms. You shall
  68. not use Cocos Creator software for developing other software or tools that's
  69. used for developing games. You are not granted to publish, distribute,
  70. sublicense, and/or sell copies of Cocos Creator.
  71. The software or tools in this License Agreement are licensed, not sold.
  72. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  73. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  74. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  75. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  76. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  77. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  78. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  79. THE SOFTWARE.
  80. ****************************************************************************/
  81. var RenderFlow = cc.RenderFlow;
  82. var originInit = cc.Assembler.prototype.init;
  83. var FLAG_VERTICES_OPACITY_CHANGED = 1 << 0;
  84. var FLAG_VERTICES_DIRTY = 1 << 1;
  85. var Assembler = {
  86. _ctor: function _ctor() {
  87. this._dirtyPtr = new Uint32Array(1);
  88. this.setDirty(this._dirtyPtr);
  89. this.initVertexFormat();
  90. },
  91. destroy: function destroy() {
  92. this._renderComp = null;
  93. this._effect = null;
  94. },
  95. clear: function clear() {
  96. this._renderData.clear();
  97. },
  98. _extendNative: function _extendNative() {
  99. renderer.Assembler.prototype.ctor.call(this);
  100. },
  101. initVertexFormat: function initVertexFormat() {
  102. var vfmt = this.getVfmt();
  103. if (!vfmt) return;
  104. this.setVertexFormat(vfmt._nativeObj);
  105. },
  106. init: function init(renderComp) {
  107. this._effect = [];
  108. originInit.call(this, renderComp);
  109. if (renderComp.node && renderComp.node._proxy) {
  110. renderComp.node._proxy.setAssembler(this);
  111. }
  112. },
  113. _updateRenderData: function _updateRenderData() {
  114. if (!this._renderComp || !this._renderComp.isValid) return;
  115. this.updateRenderData(this._renderComp);
  116. var materials = this._renderComp._materials;
  117. for (var i = 0; i < materials.length; i++) {
  118. var m = materials[i]; // TODO: find why material can be null
  119. if (!m) continue;
  120. m.getHash();
  121. this.updateMaterial(i, m);
  122. }
  123. },
  124. updateRenderData: function updateRenderData(comp) {
  125. comp._assembler.updateMaterial(0, comp._materials[0]);
  126. },
  127. updateMaterial: function updateMaterial(iaIndex, material) {
  128. var effect = material && material.effect;
  129. if (this._effect[iaIndex] !== effect) {
  130. this._effect[iaIndex] = effect;
  131. this.updateEffect(iaIndex, effect ? effect._nativeObj : null);
  132. }
  133. },
  134. updateColor: function updateColor(comp, color) {
  135. this._dirtyPtr[0] |= FLAG_VERTICES_OPACITY_CHANGED;
  136. },
  137. updateIADatas: function updateIADatas(iaIndex, meshIndex) {
  138. // When the MeshBuffer is switched, it is necessary to synchronize the iaData of the native assembler.
  139. this.updateMeshIndex(iaIndex, meshIndex);
  140. var materials = this._renderComp._materials;
  141. var material = materials[iaIndex] || materials[0];
  142. this.updateMaterial(iaIndex, material);
  143. }
  144. };
  145. cc.Assembler.FLAG_VERTICES_OPACITY_CHANGED = FLAG_VERTICES_OPACITY_CHANGED;
  146. cc.Assembler.FLAG_VERTICES_DIRTY = FLAG_VERTICES_DIRTY;
  147. Object.setPrototypeOf(cc.Assembler.prototype, renderer.Assembler.prototype);
  148. cc.js.mixin(cc.Assembler.prototype, Assembler);
  149. module.exports = Assembler;
  150. },{}],4:[function(require,module,exports){
  151. "use strict";
  152. var proto = cc.Graphics.__assembler__.prototype;
  153. var _init = proto.init;
  154. proto.init = function (renderComp) {
  155. _init.call(this, renderComp);
  156. this.ignoreOpacityFlag();
  157. };
  158. proto.genBuffer = function (graphics, cverts) {
  159. var buffers = this.getBuffers();
  160. var buffer = buffers[this._bufferOffset];
  161. var meshbuffer = buffer.meshbuffer;
  162. meshbuffer.requestStatic(cverts, cverts * 3);
  163. this._buffer = buffer;
  164. meshbuffer.setNativeAssembler(this);
  165. return buffer;
  166. };
  167. var _stroke = proto.stroke;
  168. proto.stroke = function (graphics) {
  169. _stroke.call(this, graphics);
  170. var buffer = this._buffer;
  171. buffer.meshbuffer.used(buffer.vertexStart, buffer.indiceStart);
  172. };
  173. var _fill = proto.fill;
  174. proto.fill = function (graphics) {
  175. _fill.call(this, graphics);
  176. var buffer = this._buffer;
  177. buffer.meshbuffer.used(buffer.vertexStart, buffer.indiceStart);
  178. };
  179. var _updateIADatas = proto.updateIADatas;
  180. proto.updateIADatas = function (iaIndex, meshIndex) {
  181. _updateIADatas.call(this, iaIndex, meshIndex); // Reset vertexStart and indiceStart when buffer is switched.
  182. this._buffer.vertexStart = 0;
  183. this._buffer.indiceStart = 0;
  184. };
  185. },{}],5:[function(require,module,exports){
  186. "use strict";
  187. /****************************************************************************
  188. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  189. http://www.cocos.com
  190. Permission is hereby granted, free of charge, to any person obtaining a copy
  191. of this software and associated engine source code (the "Software"), a limited,
  192. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  193. to use Cocos Creator solely to develop games on your target platforms. You shall
  194. not use Cocos Creator software for developing other software or tools that's
  195. used for developing games. You are not granted to publish, distribute,
  196. sublicense, and/or sell copies of Cocos Creator.
  197. The software or tools in this License Agreement are licensed, not sold.
  198. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  199. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  200. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  201. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  202. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  203. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  204. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  205. THE SOFTWARE.
  206. ****************************************************************************/
  207. var originReserveQuads = cc.Label.__assembler__.Bmfont.prototype._reserveQuads;
  208. Object.assign(cc.Label.__assembler__.Bmfont.prototype, {
  209. updateWorldVerts: function updateWorldVerts(comp) {
  210. var local = this._local;
  211. var world = this._renderData.vDatas[0];
  212. var floatsPerVert = this.floatsPerVert;
  213. for (var offset = 0, l = local.length; offset < l; offset += floatsPerVert) {
  214. world[offset] = local[offset];
  215. world[offset + 1] = local[offset + 1];
  216. }
  217. }
  218. });
  219. },{}],6:[function(require,module,exports){
  220. "use strict";
  221. (function () {
  222. if (!cc.Label.__assembler__.Bmfont3D) return;
  223. var proto = cc.Label.__assembler__.Bmfont3D.prototype;
  224. Object.assign(proto, {
  225. updateWorldVerts: function updateWorldVerts(comp) {
  226. var local = this._local;
  227. var world = this._renderData.vDatas[0];
  228. var floatsPerVert = this.floatsPerVert;
  229. for (var offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
  230. world[offset] = local[offset];
  231. world[offset + 1] = local[offset + 1];
  232. world[offset + 2] = 0;
  233. }
  234. }
  235. });
  236. })();
  237. },{}],7:[function(require,module,exports){
  238. "use strict";
  239. (function () {
  240. if (!cc.Label.__assembler__.Letter3D) return;
  241. var proto = cc.Label.__assembler__.Letter3D.prototype;
  242. Object.assign(proto, {
  243. updateWorldVerts: function updateWorldVerts(comp) {
  244. var local = this._local;
  245. var world = this._renderData.vDatas[0];
  246. var floatsPerVert = this.floatsPerVert;
  247. for (var offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
  248. world[offset] = local[offset];
  249. world[offset + 1] = local[offset + 1];
  250. world[offset + 2] = 0;
  251. }
  252. }
  253. });
  254. })();
  255. },{}],8:[function(require,module,exports){
  256. "use strict";
  257. (function () {
  258. if (!cc.Label.__assembler__.TTF3D) return;
  259. var proto = cc.Label.__assembler__.TTF3D.prototype;
  260. Object.assign(proto, {
  261. updateWorldVerts: cc.Assembler3D.updateWorldVerts
  262. });
  263. })();
  264. },{}],9:[function(require,module,exports){
  265. "use strict";
  266. /****************************************************************************
  267. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  268. http://www.cocos.com
  269. Permission is hereby granted, free of charge, to any person obtaining a copy
  270. of this software and associated engine source code (the "Software"), a limited,
  271. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  272. to use Cocos Creator solely to develop games on your target platforms. You shall
  273. not use Cocos Creator software for developing other software or tools that's
  274. used for developing games. You are not granted to publish, distribute,
  275. sublicense, and/or sell copies of Cocos Creator.
  276. The software or tools in this License Agreement are licensed, not sold.
  277. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  278. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  279. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  280. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  281. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  282. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  283. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  284. THE SOFTWARE.
  285. ****************************************************************************/
  286. require('./2d/bmfont.js');
  287. require('./3d/bmfont.js');
  288. require('./3d/ttf.js');
  289. require('./3d/letter.js');
  290. },{"./2d/bmfont.js":5,"./3d/bmfont.js":6,"./3d/letter.js":7,"./3d/ttf.js":8}],10:[function(require,module,exports){
  291. "use strict";
  292. /****************************************************************************
  293. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  294. http://www.cocos.com
  295. Permission is hereby granted, free of charge, to any person obtaining a copy
  296. of this software and associated engine source code (the "Software"), a limited,
  297. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  298. to use Cocos Creator solely to develop games on your target platforms. You shall
  299. not use Cocos Creator software for developing other software or tools that's
  300. used for developing games. You are not granted to publish, distribute,
  301. sublicense, and/or sell copies of Cocos Creator.
  302. The software or tools in this License Agreement are licensed, not sold.
  303. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  304. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  305. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  306. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  307. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  308. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  309. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  310. THE SOFTWARE.
  311. ****************************************************************************/
  312. var Mask = cc.Mask;
  313. var RenderFlow = cc.RenderFlow;
  314. var spriteAssembler = cc.Sprite.__assembler__.Simple.prototype;
  315. var graphicsAssembler = cc.Graphics.__assembler__.prototype;
  316. var proto = cc.Mask.__assembler__.prototype;
  317. var _updateRenderData = proto.updateRenderData; // Avoid constructor being overridden.
  318. renderer.MaskAssembler.prototype.constructor = cc.Mask.__assembler__;
  319. cc.js.mixin(proto, {
  320. _extendNative: function _extendNative() {
  321. renderer.MaskAssembler.prototype.ctor.call(this);
  322. },
  323. initLocal: function initLocal() {
  324. this._local = new Float32Array(4);
  325. renderer.MaskAssembler.prototype.setLocalData.call(this, this._local);
  326. },
  327. updateRenderData: function updateRenderData(mask) {
  328. _updateRenderData.call(this, mask);
  329. mask._clearGraphics._assembler.updateMaterial(0, mask._clearMaterial);
  330. this.setMaskInverted(mask.inverted);
  331. this.setUseModel(mask._type !== Mask.Type.IMAGE_STENCIL);
  332. this.setImageStencil(mask._type === Mask.Type.IMAGE_STENCIL);
  333. if (mask._graphics) {
  334. mask._graphics._assembler.setUseModel(mask._type !== Mask.Type.IMAGE_STENCIL);
  335. }
  336. mask.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA;
  337. }
  338. }, renderer.MaskAssembler.prototype);
  339. var originCreateGraphics = cc.Mask.prototype._createGraphics;
  340. var originRemoveGraphics = cc.Mask.prototype._removeGraphics;
  341. cc.js.mixin(cc.Mask.prototype, {
  342. _createGraphics: function _createGraphics() {
  343. originCreateGraphics.call(this);
  344. if (this._graphics) {
  345. this._assembler.setRenderSubHandle(this._graphics._assembler);
  346. } // TODO: remove clearGraphics
  347. if (!this._clearGraphics) {
  348. this._clearGraphics = new cc.Graphics();
  349. cc.Assembler.init(this._clearGraphics);
  350. this._clearGraphics.node = new cc.Node();
  351. this._clearGraphics._activateMaterial();
  352. this._clearGraphics.lineWidth = 0;
  353. this._clearGraphics.rect(-1, -1, 2, 2);
  354. this._clearGraphics.fill();
  355. this._clearGraphics._assembler.ignoreWorldMatrix();
  356. this._assembler.setClearSubHandle(this._clearGraphics._assembler);
  357. }
  358. },
  359. _removeGraphics: function _removeGraphics() {
  360. originRemoveGraphics.call(this); // TODO: remove clearGraphics
  361. if (this._clearGraphics) {
  362. this._clearGraphics.destroy();
  363. this._clearGraphics = null;
  364. }
  365. }
  366. });
  367. },{}],11:[function(require,module,exports){
  368. "use strict";
  369. (function () {
  370. var Mesh = cc.MeshRenderer;
  371. if (Mesh === undefined) return;
  372. var proto = cc.MeshRenderer.__assembler__.prototype;
  373. var _init = proto.init;
  374. cc.js.mixin(proto, {
  375. initVertexFormat: function initVertexFormat() {},
  376. _extendNative: function _extendNative() {
  377. renderer.MeshAssembler.prototype.ctor.call(this);
  378. },
  379. init: function init(comp) {
  380. _init.call(this, comp);
  381. this.updateMeshData(true);
  382. },
  383. setRenderNode: function setRenderNode(node) {
  384. this.setNode(node._proxy);
  385. },
  386. updateRenderData: function updateRenderData(comp) {
  387. this.updateMeshData();
  388. comp.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA;
  389. },
  390. updateMeshData: function updateMeshData(force) {
  391. var comp = this._renderComp;
  392. var mesh = comp.mesh;
  393. if (!mesh || !mesh.loaded) return;
  394. var subdatas = comp.mesh.subDatas;
  395. for (var i = 0, len = subdatas.length; i < len; i++) {
  396. var data = subdatas[i];
  397. if (force || data.vDirty || data.iDirty) {
  398. this.updateIAData(i, data.vfm._nativeObj, data.vData, data.iData);
  399. data.vDirty = false;
  400. data.iDirty = false;
  401. }
  402. }
  403. }
  404. }, renderer.MeshAssembler.prototype);
  405. })();
  406. },{}],12:[function(require,module,exports){
  407. "use strict";
  408. var proto = cc.MotionStreak.__assembler__.prototype;
  409. var _init = proto.init;
  410. var _update = proto.update;
  411. cc.js.mixin(proto, {
  412. init: function init(comp) {
  413. _init.call(this, comp);
  414. this.setUseModel(false);
  415. this.ignoreWorldMatrix();
  416. this.ignoreOpacityFlag();
  417. },
  418. update: function update(comp, dt) {
  419. comp.node._updateWorldMatrix();
  420. _update.call(this, comp, dt);
  421. var _this$_renderData$_fl = this._renderData._flexBuffer,
  422. iData = _this$_renderData$_fl.iData,
  423. usedVertices = _this$_renderData$_fl.usedVertices;
  424. var indiceOffset = 0;
  425. for (var i = 0, l = usedVertices; i < l; i += 2) {
  426. iData[indiceOffset++] = i;
  427. iData[indiceOffset++] = i + 2;
  428. iData[indiceOffset++] = i + 1;
  429. iData[indiceOffset++] = i + 1;
  430. iData[indiceOffset++] = i + 2;
  431. iData[indiceOffset++] = i + 3;
  432. }
  433. }
  434. });
  435. },{}],13:[function(require,module,exports){
  436. "use strict";
  437. (function () {
  438. var PS = cc.ParticleSystem3D;
  439. if (PS === undefined) return;
  440. var proto = PS.__assembler__.prototype;
  441. var _init = proto.init;
  442. var _updateRenderData = proto.updateRenderData;
  443. cc.js.mixin(proto, {
  444. initVertexFormat: function initVertexFormat() {},
  445. _extendNative: function _extendNative() {
  446. renderer.Particle3DAssembler.prototype.ctor.call(this);
  447. },
  448. init: function init(comp) {
  449. _init.call(this, comp);
  450. this._renderDataList = new renderer.RenderDataList();
  451. this.setRenderDataList(this._renderDataList);
  452. this.ignoreOpacityFlag();
  453. this.updateMeshData();
  454. this.setUseModel(true);
  455. },
  456. updateRenderData: function updateRenderData(comp) {
  457. _updateRenderData.call(this, comp);
  458. if (comp._vertsDirty) {
  459. this.updateMeshData();
  460. comp._vertsDirty = false;
  461. }
  462. },
  463. setRenderNode: function setRenderNode(node) {
  464. this.setNode(node._proxy);
  465. },
  466. updateMeshData: function updateMeshData() {
  467. if (!this._model) {
  468. return;
  469. }
  470. var subdatas = this._model._subDatas;
  471. for (var i = 0, len = subdatas.length; i < len; i++) {
  472. var data = subdatas[i];
  473. if (data.vDirty && data.enable) {
  474. this._renderDataList.updateMesh(i, data.vData, data.iData);
  475. }
  476. }
  477. this.setVertexFormat(subdatas[0].vfm._nativeObj);
  478. this.setSimulationSpace(this._particleSystem.simulationSpace);
  479. if (subdatas[1] && subdatas[1].enable) {
  480. this.setTrailVertexFormat(subdatas[1].vfm._nativeObj);
  481. this.setTrailModuleSpace(this._particleSystem.trailModule.space);
  482. }
  483. },
  484. setSimulationSpace: function setSimulationSpace(space) {
  485. this.setParticleSpace(space);
  486. },
  487. setTrailModuleSpace: function setTrailModuleSpace(space) {
  488. this.setTrailSpace(space);
  489. },
  490. updateIA: function updateIA(index, count, vDirty, iDirty) {
  491. this.updateIndicesRange(index, 0, count);
  492. }
  493. }, renderer.Particle3DAssembler.prototype);
  494. })();
  495. },{}],14:[function(require,module,exports){
  496. "use strict";
  497. /****************************************************************************
  498. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  499. http://www.cocos.com
  500. Permission is hereby granted, free of charge, to any person obtaining a copy
  501. of this software and associated engine source code (the "Software"), a limited,
  502. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  503. to use Cocos Creator solely to develop games on your target platforms. You shall
  504. not use Cocos Creator software for developing other software or tools that's
  505. used for developing games. You are not granted to publish, distribute,
  506. sublicense, and/or sell copies of Cocos Creator.
  507. The software or tools in this License Agreement are licensed, not sold.
  508. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  509. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  510. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  511. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  512. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  513. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  514. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  515. THE SOFTWARE.
  516. ****************************************************************************/
  517. Object.assign(cc.Sprite.__assembler__.Mesh.prototype, {
  518. updateWorldVerts: function updateWorldVerts(sprite) {
  519. var local = this._local;
  520. var world = this._renderData.vDatas[0];
  521. var floatsPerVert = this.floatsPerVert;
  522. for (var i = 0, l = local.length / 2; i < l; i++) {
  523. world[i * floatsPerVert] = local[i * 2];
  524. world[i * floatsPerVert + 1] = local[i * 2 + 1];
  525. }
  526. }
  527. });
  528. },{}],15:[function(require,module,exports){
  529. "use strict";
  530. /****************************************************************************
  531. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  532. http://www.cocos.com
  533. Permission is hereby granted, free of charge, to any person obtaining a copy
  534. of this software and associated engine source code (the "Software"), a limited,
  535. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  536. to use Cocos Creator solely to develop games on your target platforms. You shall
  537. not use Cocos Creator software for developing other software or tools that's
  538. used for developing games. You are not granted to publish, distribute,
  539. sublicense, and/or sell copies of Cocos Creator.
  540. The software or tools in this License Agreement are licensed, not sold.
  541. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  542. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  543. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  544. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  545. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  546. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  547. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  548. THE SOFTWARE.
  549. ****************************************************************************/
  550. Object.assign(cc.Sprite.__assembler__.RadialFilled.prototype, {
  551. updateWorldVerts: function updateWorldVerts(sprite) {
  552. var local = this._local;
  553. var world = this._renderData.vDatas[0];
  554. var floatsPerVert = this.floatsPerVert;
  555. for (var offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
  556. world[offset] = local[offset];
  557. world[offset + 1] = local[offset + 1];
  558. }
  559. }
  560. });
  561. },{}],16:[function(require,module,exports){
  562. "use strict";
  563. /****************************************************************************
  564. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  565. http://www.cocos.com
  566. Permission is hereby granted, free of charge, to any person obtaining a copy
  567. of this software and associated engine source code (the "Software"), a limited,
  568. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  569. to use Cocos Creator solely to develop games on your target platforms. You shall
  570. not use Cocos Creator software for developing other software or tools that's
  571. used for developing games. You are not granted to publish, distribute,
  572. sublicense, and/or sell copies of Cocos Creator.
  573. The software or tools in this License Agreement are licensed, not sold.
  574. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  575. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  576. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  577. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  578. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  579. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  580. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  581. THE SOFTWARE.
  582. ****************************************************************************/
  583. var proto = cc.Sprite.__assembler__.Simple.prototype;
  584. var nativeProto = renderer.SimpleSprite2D.prototype;
  585. proto.updateWorldVerts = function (comp) {
  586. this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_DIRTY;
  587. };
  588. proto._extendNative = function () {
  589. nativeProto.ctor.call(this);
  590. };
  591. proto.initLocal = function () {
  592. this._local = new Float32Array(4);
  593. nativeProto.setLocalData.call(this, this._local);
  594. };
  595. },{}],17:[function(require,module,exports){
  596. "use strict";
  597. /****************************************************************************
  598. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  599. http://www.cocos.com
  600. Permission is hereby granted, free of charge, to any person obtaining a copy
  601. of this software and associated engine source code (the "Software"), a limited,
  602. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  603. to use Cocos Creator solely to develop games on your target platforms. You shall
  604. not use Cocos Creator software for developing other software or tools that's
  605. used for developing games. You are not granted to publish, distribute,
  606. sublicense, and/or sell copies of Cocos Creator.
  607. The software or tools in this License Agreement are licensed, not sold.
  608. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  609. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  610. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  611. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  612. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  613. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  614. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  615. THE SOFTWARE.
  616. ****************************************************************************/
  617. var proto = cc.Sprite.__assembler__.Sliced.prototype;
  618. var nativeProto = renderer.SlicedSprite2D.prototype;
  619. proto.updateWorldVerts = function (comp) {
  620. this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_DIRTY;
  621. };
  622. proto._extendNative = function () {
  623. nativeProto.ctor.call(this);
  624. };
  625. proto.initLocal = function () {
  626. this._local = new Float32Array(8);
  627. nativeProto.setLocalData.call(this, this._local);
  628. };
  629. },{}],18:[function(require,module,exports){
  630. "use strict";
  631. /****************************************************************************
  632. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  633. http://www.cocos.com
  634. Permission is hereby granted, free of charge, to any person obtaining a copy
  635. of this software and associated engine source code (the "Software"), a limited,
  636. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  637. to use Cocos Creator solely to develop games on your target platforms. You shall
  638. not use Cocos Creator software for developing other software or tools that's
  639. used for developing games. You are not granted to publish, distribute,
  640. sublicense, and/or sell copies of Cocos Creator.
  641. The software or tools in this License Agreement are licensed, not sold.
  642. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  643. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  644. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  645. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  646. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  647. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  648. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  649. THE SOFTWARE.
  650. ****************************************************************************/
  651. Object.assign(cc.Sprite.__assembler__.Tiled.prototype, {
  652. updateWorldVerts: function updateWorldVerts(sprite) {
  653. var renderData = this._renderData;
  654. var local = this._local;
  655. var localX = local.x,
  656. localY = local.y;
  657. var world = renderData.vDatas[0];
  658. var row = this.row,
  659. col = this.col;
  660. var x, x1, y, y1;
  661. var floatsPerVert = this.floatsPerVert;
  662. var vertexOffset = 0;
  663. for (var yindex = 0, ylength = row; yindex < ylength; ++yindex) {
  664. y = localY[yindex];
  665. y1 = localY[yindex + 1];
  666. for (var xindex = 0, xlength = col; xindex < xlength; ++xindex) {
  667. x = localX[xindex];
  668. x1 = localX[xindex + 1]; // lb
  669. world[vertexOffset] = x;
  670. world[vertexOffset + 1] = y;
  671. vertexOffset += floatsPerVert; // rb
  672. world[vertexOffset] = x1;
  673. world[vertexOffset + 1] = y;
  674. vertexOffset += floatsPerVert; // lt
  675. world[vertexOffset] = x;
  676. world[vertexOffset + 1] = y1;
  677. vertexOffset += floatsPerVert; // rt
  678. world[vertexOffset] = x1;
  679. world[vertexOffset + 1] = y1;
  680. vertexOffset += floatsPerVert;
  681. }
  682. }
  683. }
  684. });
  685. },{}],19:[function(require,module,exports){
  686. "use strict";
  687. (function () {
  688. if (!cc.Sprite.__assembler__.BarFilled3D) return;
  689. var proto = cc.Sprite.__assembler__.BarFilled3D.prototype;
  690. Object.assign(proto, {
  691. updateWorldVerts: cc.Assembler3D.updateWorldVerts
  692. });
  693. })();
  694. },{}],20:[function(require,module,exports){
  695. "use strict";
  696. (function () {
  697. if (!cc.Sprite.__assembler__.Mesh3D) return;
  698. var proto = cc.Sprite.__assembler__.Mesh3D.prototype;
  699. Object.assign(proto, {
  700. updateWorldVerts: function updateWorldVerts(sprite) {
  701. var local = this._local;
  702. var world = this._renderData.vDatas[0];
  703. var floatsPerVert = this.floatsPerVert,
  704. offset = 0;
  705. for (var i = 0, j = 0, l = local.length / 2; i < l; i++, offset += floatsPerVert) {
  706. j = i * 2;
  707. world[offset] = local[j];
  708. world[offset + 1] = local[j + 1];
  709. world[offset + 2] = 0;
  710. }
  711. }
  712. });
  713. })();
  714. },{}],21:[function(require,module,exports){
  715. "use strict";
  716. (function () {
  717. if (!cc.Sprite.__assembler__.RadialFilled3D) return;
  718. var proto = cc.Sprite.__assembler__.RadialFilled3D.prototype;
  719. Object.assign(proto, {
  720. updateWorldVerts: function updateWorldVerts(sprite) {
  721. var local = this._local;
  722. var world = this._renderData.vDatas[0];
  723. var floatsPerVert = this.floatsPerVert;
  724. for (var offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
  725. world[offset] = local[offset];
  726. world[offset + 1] = local[offset + 1];
  727. world[offset + 2] = 0;
  728. }
  729. }
  730. });
  731. })();
  732. },{}],22:[function(require,module,exports){
  733. "use strict";
  734. (function () {
  735. if (!cc.Sprite.__assembler__.Simple3D) return;
  736. var proto = cc.Sprite.__assembler__.Simple3D.prototype;
  737. var nativeProto = renderer.SimpleSprite3D.prototype;
  738. Object.assign(proto, {
  739. _extendNative: nativeProto.ctor
  740. });
  741. })();
  742. },{}],23:[function(require,module,exports){
  743. "use strict";
  744. (function () {
  745. if (!cc.Sprite.__assembler__.Sliced3D) return;
  746. var proto = cc.Sprite.__assembler__.Sliced3D.prototype;
  747. var nativeProto = renderer.SlicedSprite3D.prototype;
  748. Object.assign(proto, {
  749. _extendNative: nativeProto.ctor
  750. });
  751. })();
  752. },{}],24:[function(require,module,exports){
  753. "use strict";
  754. (function () {
  755. if (!cc.Sprite.__assembler__.Tiled3D) return;
  756. var proto = cc.Sprite.__assembler__.Tiled3D.prototype;
  757. Object.assign(proto, {
  758. updateWorldVerts: function updateWorldVerts(sprite) {
  759. var local = this._local;
  760. var localX = local.x,
  761. localY = local.y;
  762. var world = this._renderData.vDatas[0];
  763. var row = this.row,
  764. col = this.col;
  765. var x, x1, y, y1;
  766. var vertexOffset = 0;
  767. for (var yindex = 0, ylength = row; yindex < ylength; ++yindex) {
  768. y = localY[yindex];
  769. y1 = localY[yindex + 1];
  770. for (var xindex = 0, xlength = col; xindex < xlength; ++xindex) {
  771. x = localX[xindex];
  772. x1 = localX[xindex + 1]; // left bottom
  773. var padding = 6;
  774. world[vertexOffset] = x;
  775. world[vertexOffset + 1] = y;
  776. world[vertexOffset + 2] = 0;
  777. vertexOffset += padding; // right bottom
  778. world[vertexOffset] = x1;
  779. world[vertexOffset + 1] = y;
  780. world[vertexOffset + 2] = 0;
  781. vertexOffset += padding; // left top
  782. world[vertexOffset] = x;
  783. world[vertexOffset + 1] = y1;
  784. world[vertexOffset + 2] = 0;
  785. vertexOffset += padding; // right top
  786. world[vertexOffset] = x1;
  787. world[vertexOffset + 1] = y1;
  788. world[vertexOffset + 2] = 0;
  789. vertexOffset += padding;
  790. }
  791. }
  792. }
  793. });
  794. })();
  795. },{}],25:[function(require,module,exports){
  796. "use strict";
  797. /****************************************************************************
  798. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  799. http://www.cocos.com
  800. Permission is hereby granted, free of charge, to any person obtaining a copy
  801. of this software and associated engine source code (the "Software"), a limited,
  802. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  803. to use Cocos Creator solely to develop games on your target platforms. You shall
  804. not use Cocos Creator software for developing other software or tools that's
  805. used for developing games. You are not granted to publish, distribute,
  806. sublicense, and/or sell copies of Cocos Creator.
  807. The software or tools in this License Agreement are licensed, not sold.
  808. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  809. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  810. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  811. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  812. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  813. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  814. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  815. THE SOFTWARE.
  816. ****************************************************************************/
  817. require('./2d/sliced.js');
  818. require('./2d/tiled.js');
  819. require('./2d/radial-filled.js');
  820. require('./2d/simple.js');
  821. require('./2d/mesh.js');
  822. require('./3d/sliced.js');
  823. require('./3d/simple.js');
  824. require('./3d/tiled.js');
  825. require('./3d/mesh.js');
  826. require('./3d/bar-filled.js');
  827. require('./3d/radial-filled.js');
  828. },{"./2d/mesh.js":14,"./2d/radial-filled.js":15,"./2d/simple.js":16,"./2d/sliced.js":17,"./2d/tiled.js":18,"./3d/bar-filled.js":19,"./3d/mesh.js":20,"./3d/radial-filled.js":21,"./3d/simple.js":22,"./3d/sliced.js":23,"./3d/tiled.js":24}],26:[function(require,module,exports){
  829. "use strict";
  830. /****************************************************************************
  831. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  832. http://www.cocos.com
  833. Permission is hereby granted, free of charge, to any person obtaining a copy
  834. of this software and associated engine source code (the "Software"), a limited,
  835. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  836. to use Cocos Creator solely to develop games on your target platforms. You shall
  837. not use Cocos Creator software for developing other software or tools that's
  838. used for developing games. You are not granted to publish, distribute,
  839. sublicense, and/or sell copies of Cocos Creator.
  840. The software or tools in this License Agreement are licensed, not sold.
  841. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  842. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  843. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  844. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  845. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  846. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  847. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  848. THE SOFTWARE.
  849. ****************************************************************************/
  850. require('./jsb-sys.js');
  851. require('./jsb-game.js');
  852. require('./jsb-videoplayer.js');
  853. require('./jsb-webview.js');
  854. require('./jsb-audio.js');
  855. require('./jsb-loader.js');
  856. require('./jsb-editbox.js');
  857. require('./jsb-reflection.js');
  858. require('./jsb-assets-manager.js');
  859. require('./jsb-safearea.js');
  860. if (CC_NATIVERENDERER) {
  861. require('./jsb-effect.js');
  862. require('./jsb-effect-variant.js');
  863. require('./scene/camera.js');
  864. require('./scene/light.js');
  865. require('./scene/node-proxy.js');
  866. require('./scene/render-flow.js'); // must be required after render flow
  867. require('./scene/node.js');
  868. cc.game.on(cc.game.EVENT_ENGINE_INITED, function () {
  869. require('./scene/mesh-buffer.js');
  870. require('./scene/quad-buffer.js');
  871. require('./scene/render-data.js');
  872. require('./assemblers/assembler.js');
  873. require('./assemblers/assembler-2d.js');
  874. require('./assemblers/assembler-3d.js');
  875. require('./assemblers/sprite/index.js');
  876. require('./assemblers/label/index.js');
  877. require('./assemblers/mask-assembler.js');
  878. require('./assemblers/graphics-assembler.js');
  879. require('./assemblers/motion-streak.js');
  880. require('./assemblers/mesh-renderer.js');
  881. require('./assemblers/particle-3d-assembler.js');
  882. require('./jsb-dragonbones.js');
  883. require('./jsb-spine-skeleton.js');
  884. require('./jsb-particle.js');
  885. require('./jsb-tiledmap.js');
  886. require('./jsb-skin-mesh.js');
  887. });
  888. }
  889. },{"./assemblers/assembler-2d.js":1,"./assemblers/assembler-3d.js":2,"./assemblers/assembler.js":3,"./assemblers/graphics-assembler.js":4,"./assemblers/label/index.js":9,"./assemblers/mask-assembler.js":10,"./assemblers/mesh-renderer.js":11,"./assemblers/motion-streak.js":12,"./assemblers/particle-3d-assembler.js":13,"./assemblers/sprite/index.js":25,"./jsb-assets-manager.js":27,"./jsb-audio.js":28,"./jsb-dragonbones.js":undefined,"./jsb-editbox.js":30,"./jsb-effect-variant.js":31,"./jsb-effect.js":32,"./jsb-game.js":34,"./jsb-loader.js":35,"./jsb-particle.js":36,"./jsb-reflection.js":37,"./jsb-safearea.js":38,"./jsb-skin-mesh.js":39,"./jsb-spine-skeleton.js":40,"./jsb-sys.js":41,"./jsb-tiledmap.js":42,"./jsb-videoplayer.js":43,"./jsb-webview.js":44,"./scene/camera.js":45,"./scene/light.js":46,"./scene/mesh-buffer.js":47,"./scene/node-proxy.js":48,"./scene/node.js":49,"./scene/quad-buffer.js":50,"./scene/render-data.js":51,"./scene/render-flow.js":52}],27:[function(require,module,exports){
  890. "use strict";
  891. /*
  892. * Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  893. *
  894. * Permission is hereby granted, free of charge, to any person obtaining a copy
  895. * of this software and associated documentation files (the "Software"), to deal
  896. * in the Software without restriction, including without limitation the rights
  897. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  898. * copies of the Software, and to permit persons to whom the Software is
  899. * furnished to do so, subject to the following conditions:
  900. *
  901. * The above copyright notice and this permission notice shall be included in
  902. * all copies or substantial portions of the Software.
  903. *
  904. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  905. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  906. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  907. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  908. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  909. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  910. * THE SOFTWARE.
  911. */
  912. if (jsb.AssetsManager) {
  913. jsb.AssetsManager.State = {
  914. UNINITED: 0,
  915. UNCHECKED: 1,
  916. PREDOWNLOAD_VERSION: 2,
  917. DOWNLOADING_VERSION: 3,
  918. VERSION_LOADED: 4,
  919. PREDOWNLOAD_MANIFEST: 5,
  920. DOWNLOADING_MANIFEST: 6,
  921. MANIFEST_LOADED: 7,
  922. NEED_UPDATE: 8,
  923. READY_TO_UPDATE: 9,
  924. UPDATING: 10,
  925. UNZIPPING: 11,
  926. UP_TO_DATE: 12,
  927. FAIL_TO_UPDATE: 13
  928. };
  929. jsb.Manifest.DownloadState = {
  930. UNSTARTED: 0,
  931. DOWNLOADING: 1,
  932. SUCCESSED: 2,
  933. UNMARKED: 3
  934. };
  935. jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST = 0;
  936. jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST = 1;
  937. jsb.EventAssetsManager.ERROR_PARSE_MANIFEST = 2;
  938. jsb.EventAssetsManager.NEW_VERSION_FOUND = 3;
  939. jsb.EventAssetsManager.ALREADY_UP_TO_DATE = 4;
  940. jsb.EventAssetsManager.UPDATE_PROGRESSION = 5;
  941. jsb.EventAssetsManager.ASSET_UPDATED = 6;
  942. jsb.EventAssetsManager.ERROR_UPDATING = 7;
  943. jsb.EventAssetsManager.UPDATE_FINISHED = 8;
  944. jsb.EventAssetsManager.UPDATE_FAILED = 9;
  945. jsb.EventAssetsManager.ERROR_DECOMPRESS = 10;
  946. }
  947. },{}],28:[function(require,module,exports){
  948. "use strict";
  949. /****************************************************************************
  950. Copyright (c) 2013-2016 Chukong Technologies Inc.
  951. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  952. http://www.cocos.com
  953. Permission is hereby granted, free of charge, to any person obtaining a copy
  954. of this software and associated engine source code (the "Software"), a limited,
  955. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  956. to use Cocos Creator solely to develop games on your target platforms. You shall
  957. not use Cocos Creator software for developing other software or tools that's
  958. used for developing games. You are not granted to publish, distribute,
  959. sublicense, and/or sell copies of Cocos Creator.
  960. The software or tools in this License Agreement are licensed, not sold.
  961. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  962. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  963. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  964. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  965. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  966. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  967. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  968. THE SOFTWARE.
  969. ****************************************************************************/
  970. var cacheManager = require('./jsb-cache-manager');
  971. var Audio = cc._Audio = function (src) {
  972. this.src = src;
  973. this.volume = 1;
  974. this.loop = false;
  975. this.id = -1;
  976. };
  977. var handleVolume = function handleVolume(volume) {
  978. if (volume === undefined) {
  979. // set default volume as 1
  980. volume = 1;
  981. } else if (typeof volume === 'string') {
  982. volume = Number.parseFloat(volume);
  983. }
  984. return volume;
  985. };
  986. (function (proto, audioEngine) {
  987. if (!audioEngine) return; // Using the new audioEngine
  988. cc.audioEngine = audioEngine;
  989. audioEngine.setMaxWebAudioSize = function () {};
  990. Audio.State = audioEngine.AudioState;
  991. proto.play = function () {
  992. audioEngine.stop(this.id);
  993. var clip = this.src;
  994. this.id = audioEngine.play(clip, this.loop, this.volume);
  995. };
  996. proto.pause = function () {
  997. audioEngine.pause(this.id);
  998. };
  999. proto.resume = function () {
  1000. audioEngine.resume(this.id);
  1001. };
  1002. proto.stop = function () {
  1003. audioEngine.stop(this.id);
  1004. };
  1005. proto.destroy = function () {};
  1006. proto.setLoop = function (loop) {
  1007. this.loop = loop;
  1008. audioEngine.setLoop(this.id, loop);
  1009. };
  1010. proto.getLoop = function () {
  1011. return this.loop;
  1012. };
  1013. proto.setVolume = function (volume) {
  1014. volume = handleVolume(volume);
  1015. this.volume = volume;
  1016. return audioEngine.setVolume(this.id, volume);
  1017. };
  1018. proto.getVolume = function () {
  1019. return this.volume;
  1020. };
  1021. proto.setCurrentTime = function (time) {
  1022. audioEngine.setCurrentTime(this.id, time);
  1023. };
  1024. proto.getCurrentTime = function () {
  1025. return audioEngine.getCurrentTime(this.id);
  1026. };
  1027. proto.getDuration = function () {
  1028. return audioEngine.getDuration(this.id);
  1029. };
  1030. proto.getState = function () {
  1031. return audioEngine.getState(this.id);
  1032. }; // polyfill audioEngine
  1033. var _music = {
  1034. id: -1,
  1035. clip: '',
  1036. loop: false,
  1037. volume: 1
  1038. };
  1039. var _effect = {
  1040. volume: 1
  1041. };
  1042. audioEngine.play = function (clip, loop, volume) {
  1043. if (typeof volume !== 'number') {
  1044. volume = 1;
  1045. }
  1046. var audioFilePath;
  1047. if (typeof clip === 'string') {
  1048. // backward compatibility since 1.10
  1049. cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
  1050. audioFilePath = clip;
  1051. } else {
  1052. if (clip.loaded) {
  1053. audioFilePath = clip._nativeAsset;
  1054. } else {
  1055. // audio delay loading
  1056. clip._nativeAsset = audioFilePath = cacheManager.getCache(clip.nativeUrl) || clip.nativeUrl;
  1057. clip.loaded = true;
  1058. }
  1059. }
  1060. return audioEngine.play2d(audioFilePath, loop, volume);
  1061. };
  1062. audioEngine.playMusic = function (clip, loop) {
  1063. audioEngine.stop(_music.id);
  1064. _music.id = audioEngine.play(clip, loop, _music.volume);
  1065. _music.loop = loop;
  1066. _music.clip = clip;
  1067. return _music.id;
  1068. };
  1069. audioEngine.stopMusic = function () {
  1070. audioEngine.stop(_music.id);
  1071. };
  1072. audioEngine.pauseMusic = function () {
  1073. audioEngine.pause(_music.id);
  1074. return _music.id;
  1075. };
  1076. audioEngine.resumeMusic = function () {
  1077. audioEngine.resume(_music.id);
  1078. return _music.id;
  1079. };
  1080. audioEngine.getMusicVolume = function () {
  1081. return _music.volume;
  1082. };
  1083. audioEngine.setMusicVolume = function (volume) {
  1084. _music.volume = handleVolume(volume);
  1085. audioEngine.setVolume(_music.id, _music.volume);
  1086. return volume;
  1087. };
  1088. audioEngine.isMusicPlaying = function () {
  1089. return audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
  1090. };
  1091. audioEngine.playEffect = function (filePath, loop) {
  1092. return audioEngine.play(filePath, loop || false, _effect.volume);
  1093. };
  1094. audioEngine.setEffectsVolume = function (volume) {
  1095. _effect.volume = handleVolume(volume);
  1096. };
  1097. audioEngine.getEffectsVolume = function () {
  1098. return _effect.volume;
  1099. };
  1100. audioEngine.pauseEffect = function (audioID) {
  1101. return audioEngine.pause(audioID);
  1102. };
  1103. audioEngine.pauseAllEffects = function () {
  1104. var musicPlay = audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
  1105. audioEngine.pauseAll();
  1106. if (musicPlay) {
  1107. audioEngine.resume(_music.id);
  1108. }
  1109. };
  1110. audioEngine.resumeEffect = function (id) {
  1111. audioEngine.resume(id);
  1112. };
  1113. audioEngine.resumeAllEffects = function () {
  1114. var musicPaused = audioEngine.getState(_music.id) === audioEngine.AudioState.PAUSED;
  1115. audioEngine.resumeAll();
  1116. if (musicPaused && audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING) {
  1117. audioEngine.pause(_music.id);
  1118. }
  1119. };
  1120. audioEngine.stopEffect = function (id) {
  1121. return audioEngine.stop(id);
  1122. };
  1123. audioEngine.stopAllEffects = function () {
  1124. var musicPlaying = audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
  1125. var currentTime = audioEngine.getCurrentTime(_music.id);
  1126. audioEngine.stopAll();
  1127. if (musicPlaying) {
  1128. _music.id = audioEngine.play(_music.clip, _music.loop);
  1129. audioEngine.setCurrentTime(_music.id, currentTime);
  1130. }
  1131. }; // Unnecessary on native platform
  1132. audioEngine._break = function () {};
  1133. audioEngine._restore = function () {}; // deprecated
  1134. audioEngine._uncache = audioEngine.uncache;
  1135. audioEngine.uncache = function (clip) {
  1136. var path;
  1137. if (typeof clip === 'string') {
  1138. // backward compatibility since 1.10
  1139. cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
  1140. path = clip;
  1141. } else {
  1142. if (!clip) {
  1143. return;
  1144. }
  1145. path = clip._nativeAsset;
  1146. }
  1147. audioEngine._uncache(path);
  1148. };
  1149. audioEngine._preload = audioEngine.preload;
  1150. audioEngine.preload = function (filePath, callback) {
  1151. cc.warn('`cc.audioEngine.preload` is deprecated, use `cc.assetManager.loadRes(url, cc.AudioClip)` instead please.');
  1152. audioEngine._preload(filePath, callback);
  1153. };
  1154. })(Audio.prototype, jsb.AudioEngine);
  1155. },{"./jsb-cache-manager":29}],29:[function(require,module,exports){
  1156. "use strict";
  1157. /****************************************************************************
  1158. Copyright (c) 2019 Xiamen Yaji Software Co., Ltd.
  1159. https://www.cocos.com/
  1160. Permission is hereby granted, free of charge, to any person obtaining a copy
  1161. of cache-manager software and associated engine source code (the "Software"), a limited,
  1162. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1163. to use Cocos Creator solely to develop games on your target platforms. You shall
  1164. not use Cocos Creator software for developing other software or tools that's
  1165. used for developing games. You are not granted to publish, distribute,
  1166. sublicense, and/or sell copies of Cocos Creator.
  1167. The software or tools in cache-manager License Agreement are licensed, not sold.
  1168. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1169. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1170. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1171. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1172. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1173. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1174. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1175. THE SOFTWARE.
  1176. ****************************************************************************/
  1177. var _require = require('./jsb-fs-utils'),
  1178. getUserDataPath = _require.getUserDataPath,
  1179. readJsonSync = _require.readJsonSync,
  1180. makeDirSync = _require.makeDirSync,
  1181. writeFileSync = _require.writeFileSync,
  1182. writeFile = _require.writeFile,
  1183. deleteFile = _require.deleteFile,
  1184. rmdirSync = _require.rmdirSync;
  1185. var writeCacheFileList = null;
  1186. var startWrite = false;
  1187. var nextCallbacks = [];
  1188. var callbacks = [];
  1189. var cleaning = false;
  1190. var REGEX = /^\w+:\/\/.*/;
  1191. var cacheManager = {
  1192. cacheDir: 'gamecaches',
  1193. cachedFileName: 'cacheList.json',
  1194. deleteInterval: 500,
  1195. writeFileInterval: 2000,
  1196. cachedFiles: null,
  1197. version: '1.1',
  1198. getCache: function getCache(url) {
  1199. this.updateLastTime(url);
  1200. return this.cachedFiles.has(url) ? "".concat(this.cacheDir, "/").concat(this.cachedFiles.get(url).url) : '';
  1201. },
  1202. getTemp: function getTemp(url) {
  1203. return '';
  1204. },
  1205. init: function init() {
  1206. this.cacheDir = getUserDataPath() + '/' + this.cacheDir;
  1207. var cacheFilePath = this.cacheDir + '/' + this.cachedFileName;
  1208. var result = readJsonSync(cacheFilePath);
  1209. if (result instanceof Error || !result.version || result.version !== this.version) {
  1210. if (!(result instanceof Error)) rmdirSync(this.cacheDir, true);
  1211. this.cachedFiles = new cc.AssetManager.Cache();
  1212. makeDirSync(this.cacheDir, true);
  1213. writeFileSync(cacheFilePath, JSON.stringify({
  1214. files: this.cachedFiles._map,
  1215. version: this.version
  1216. }), 'utf8');
  1217. } else {
  1218. this.cachedFiles = new cc.AssetManager.Cache(result.files);
  1219. }
  1220. },
  1221. updateLastTime: function updateLastTime(url) {
  1222. if (this.cachedFiles.has(url)) {
  1223. var cache = this.cachedFiles.get(url);
  1224. cache.lastTime = Date.now();
  1225. }
  1226. },
  1227. _write: function _write() {
  1228. writeCacheFileList = null;
  1229. startWrite = true;
  1230. writeFile(this.cacheDir + '/' + this.cachedFileName, JSON.stringify({
  1231. files: this.cachedFiles._map,
  1232. version: this.version
  1233. }), 'utf8', function () {
  1234. startWrite = false;
  1235. for (var i = 0, j = callbacks.length; i < j; i++) {
  1236. callbacks[i]();
  1237. }
  1238. callbacks.length = 0;
  1239. callbacks.push.apply(callbacks, nextCallbacks);
  1240. nextCallbacks.length = 0;
  1241. });
  1242. },
  1243. writeCacheFile: function writeCacheFile(cb) {
  1244. if (!writeCacheFileList) {
  1245. writeCacheFileList = setTimeout(this._write.bind(this), this.writeFileInterval);
  1246. if (startWrite === true) {
  1247. cb && nextCallbacks.push(cb);
  1248. } else {
  1249. cb && callbacks.push(cb);
  1250. }
  1251. } else {
  1252. cb && callbacks.push(cb);
  1253. }
  1254. },
  1255. cacheFile: function cacheFile(id, url, cacheBundleRoot) {
  1256. this.cachedFiles.add(id, {
  1257. bundle: cacheBundleRoot,
  1258. url: url,
  1259. lastTime: Date.now()
  1260. });
  1261. this.writeCacheFile();
  1262. },
  1263. clearCache: function clearCache() {
  1264. var _this = this;
  1265. rmdirSync(this.cacheDir, true);
  1266. this.cachedFiles = new cc.AssetManager.Cache();
  1267. makeDirSync(this.cacheDir, true);
  1268. var cacheFilePath = this.cacheDir + '/' + this.cachedFileName;
  1269. writeFileSync(cacheFilePath, JSON.stringify({
  1270. files: this.cachedFiles._map,
  1271. version: this.version
  1272. }), 'utf8');
  1273. cc.assetManager.bundles.forEach(function (bundle) {
  1274. if (REGEX.test(bundle.base)) _this.makeBundleFolder(bundle.name);
  1275. });
  1276. },
  1277. clearLRU: function clearLRU() {
  1278. var _this2 = this;
  1279. if (cleaning) return;
  1280. cleaning = true;
  1281. var caches = [];
  1282. var self = this;
  1283. this.cachedFiles.forEach(function (val, key) {
  1284. if (val.bundle === 'internal') return;
  1285. caches.push({
  1286. originUrl: key,
  1287. url: _this2.getCache(key),
  1288. lastTime: val.lastTime
  1289. });
  1290. });
  1291. caches.sort(function (a, b) {
  1292. return a.lastTime - b.lastTime;
  1293. });
  1294. caches.length = Math.floor(this.cachedFiles.count / 3);
  1295. if (caches.length === 0) return;
  1296. for (var i = 0, l = caches.length; i < l; i++) {
  1297. this.cachedFiles.remove(caches[i].originUrl);
  1298. }
  1299. this.writeCacheFile(function () {
  1300. function deferredDelete() {
  1301. var item = caches.pop();
  1302. deleteFile(item.url);
  1303. if (caches.length > 0) {
  1304. setTimeout(deferredDelete, self.deleteInterval);
  1305. } else {
  1306. cleaning = false;
  1307. }
  1308. }
  1309. setTimeout(deferredDelete, self.deleteInterval);
  1310. });
  1311. },
  1312. removeCache: function removeCache(url) {
  1313. if (this.cachedFiles.has(url)) {
  1314. var path = this.getCache(url);
  1315. this.cachedFiles.remove(url);
  1316. this.writeCacheFile(function () {
  1317. deleteFile(path);
  1318. });
  1319. }
  1320. },
  1321. makeBundleFolder: function makeBundleFolder(bundleName) {
  1322. makeDirSync(this.cacheDir + '/' + bundleName, true);
  1323. }
  1324. };
  1325. cc.assetManager.cacheManager = module.exports = cacheManager;
  1326. },{"./jsb-fs-utils":33}],30:[function(require,module,exports){
  1327. "use strict";
  1328. /****************************************************************************
  1329. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  1330. http://www.cocos.com
  1331. Permission is hereby granted, free of charge, to any person obtaining a copy
  1332. of this software and associated engine source code (the "Software"), a limited,
  1333. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1334. to use Cocos Creator solely to develop games on your target platforms. You shall
  1335. not use Cocos Creator software for developing other software or tools that's
  1336. used for developing games. You are not granted to publish, distribute,
  1337. sublicense, and/or sell copies of Cocos Creator.
  1338. The software or tools in this License Agreement are licensed, not sold.
  1339. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1340. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1341. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1342. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1343. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1344. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1345. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1346. THE SOFTWARE.
  1347. ****************************************************************************/
  1348. (function () {
  1349. if (!(cc && cc.EditBox)) {
  1350. return;
  1351. }
  1352. var EditBox = cc.EditBox;
  1353. var js = cc.js;
  1354. var KeyboardReturnType = EditBox.KeyboardReturnType;
  1355. var InputMode = EditBox.InputMode;
  1356. var InputFlag = EditBox.InputFlag;
  1357. var MAX_VALUE = 65535;
  1358. var worldMat = new cc.Mat4(),
  1359. cameraMat = new cc.Mat4();
  1360. function getInputType(type) {
  1361. switch (type) {
  1362. case InputMode.EMAIL_ADDR:
  1363. return 'email';
  1364. case InputMode.NUMERIC:
  1365. case InputMode.DECIMAL:
  1366. return 'number';
  1367. case InputMode.PHONE_NUMBER:
  1368. return 'phone';
  1369. case InputMode.URL:
  1370. return 'url';
  1371. case InputMode.SINGLE_LINE:
  1372. case InputMode.ANY:
  1373. default:
  1374. return 'text';
  1375. }
  1376. }
  1377. function getKeyboardReturnType(type) {
  1378. switch (type) {
  1379. case KeyboardReturnType.DEFAULT:
  1380. case KeyboardReturnType.DONE:
  1381. return 'done';
  1382. case KeyboardReturnType.SEND:
  1383. return 'send';
  1384. case KeyboardReturnType.SEARCH:
  1385. return 'search';
  1386. case KeyboardReturnType.GO:
  1387. return 'go';
  1388. case KeyboardReturnType.NEXT:
  1389. return 'next';
  1390. }
  1391. return 'done';
  1392. }
  1393. var BaseClass = EditBox._ImplClass;
  1394. function JsbEditBoxImpl() {
  1395. BaseClass.call(this);
  1396. }
  1397. js.extend(JsbEditBoxImpl, BaseClass);
  1398. EditBox._ImplClass = JsbEditBoxImpl;
  1399. Object.assign(JsbEditBoxImpl.prototype, {
  1400. init: function init(delegate) {
  1401. if (!delegate) {
  1402. cc.error('EditBox init failed');
  1403. return;
  1404. }
  1405. this._delegate = delegate;
  1406. },
  1407. _onResize: function _onResize() {
  1408. var _this$_getRect = this._getRect(),
  1409. x = _this$_getRect.x,
  1410. y = _this$_getRect.y,
  1411. width = _this$_getRect.width,
  1412. height = _this$_getRect.height;
  1413. jsb.inputBox.updateRect(x, y, width, height);
  1414. },
  1415. beginEditing: function beginEditing() {
  1416. var self = this;
  1417. var delegate = this._delegate;
  1418. var multiline = delegate.inputMode === InputMode.ANY;
  1419. var rect = this._getRect();
  1420. var maxLength = delegate.maxLength < 0 ? MAX_VALUE : delegate.maxLength;
  1421. var inputTypeString = getInputType(delegate.inputMode);
  1422. if (delegate.inputFlag === InputFlag.PASSWORD) {
  1423. inputTypeString = 'password';
  1424. }
  1425. function onConfirm(res) {
  1426. delegate.editBoxEditingReturn();
  1427. }
  1428. function onInput(res) {
  1429. if (delegate._string !== res.value) {
  1430. delegate.editBoxTextChanged(res.value);
  1431. }
  1432. }
  1433. function onComplete(res) {
  1434. self.endEditing();
  1435. }
  1436. jsb.inputBox.onInput(onInput);
  1437. jsb.inputBox.onConfirm(onConfirm);
  1438. jsb.inputBox.onComplete(onComplete);
  1439. if (!cc.sys.isMobile) {
  1440. this._delegate._hideLabels();
  1441. }
  1442. jsb.inputBox.show({
  1443. defaultValue: delegate._string,
  1444. maxLength: maxLength,
  1445. multiple: multiline,
  1446. confirmHold: false,
  1447. confirmType: getKeyboardReturnType(delegate.returnType),
  1448. inputType: inputTypeString,
  1449. originX: rect.x,
  1450. originY: rect.y,
  1451. width: rect.width,
  1452. height: rect.height
  1453. });
  1454. this._editing = true;
  1455. delegate.editBoxEditingDidBegan();
  1456. if (!cc.sys.isMobile) {
  1457. cc.view.on('canvas-resize', this._onResize, this);
  1458. }
  1459. },
  1460. endEditing: function endEditing() {
  1461. jsb.inputBox.offConfirm();
  1462. jsb.inputBox.offInput();
  1463. jsb.inputBox.offComplete();
  1464. this._editing = false;
  1465. if (!cc.sys.isMobile) {
  1466. this._delegate._showLabels();
  1467. }
  1468. jsb.inputBox.hide();
  1469. this._delegate.editBoxEditingDidEnded();
  1470. if (!cc.sys.isMobile) {
  1471. cc.view.off('canvas-resize', this._onResize, this);
  1472. }
  1473. },
  1474. _getRect: function _getRect() {
  1475. var node = this._delegate.node,
  1476. viewScaleX = cc.view._scaleX,
  1477. viewScaleY = cc.view._scaleY;
  1478. var dpr = cc.view._devicePixelRatio;
  1479. node.getWorldMatrix(worldMat);
  1480. var camera = cc.Camera.findCamera(node);
  1481. if (!camera) {
  1482. return new cc.Rect();
  1483. }
  1484. camera.getWorldToScreenMatrix2D(cameraMat);
  1485. cc.Mat4.multiply(cameraMat, cameraMat, worldMat);
  1486. var contentSize = node._contentSize;
  1487. var vec3 = cc.v3();
  1488. vec3.x = -node._anchorPoint.x * contentSize.width;
  1489. vec3.y = -node._anchorPoint.y * contentSize.height;
  1490. cc.Mat4.translate(cameraMat, cameraMat, vec3);
  1491. viewScaleX /= dpr;
  1492. viewScaleY /= dpr;
  1493. var finalScaleX = cameraMat.m[0] * viewScaleX;
  1494. var finaleScaleY = cameraMat.m[5] * viewScaleY;
  1495. var viewportRect = cc.view._viewportRect;
  1496. var offsetX = viewportRect.x / dpr,
  1497. offsetY = viewportRect.y / dpr;
  1498. return {
  1499. x: cameraMat.m[12] * viewScaleX + offsetX,
  1500. y: cameraMat.m[13] * viewScaleY + offsetY,
  1501. width: contentSize.width * finalScaleX,
  1502. height: contentSize.height * finaleScaleY
  1503. };
  1504. }
  1505. });
  1506. })();
  1507. },{}],31:[function(require,module,exports){
  1508. "use strict";
  1509. // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  1510. (function () {
  1511. if (!cc.EffectVariant) return;
  1512. var EffectVariant = cc.EffectVariant;
  1513. var _init = EffectVariant.prototype.init;
  1514. Object.assign(EffectVariant.prototype, {
  1515. init: function init(effect) {
  1516. _init.call(this, effect);
  1517. this._nativeObj = new renderer.EffectVariant(effect._nativeObj);
  1518. },
  1519. _onEffectChanged: function _onEffectChanged() {
  1520. var nativeEffect = this._effect ? this._effect._nativeObj : null;
  1521. this._nativeObj.setEffect(nativeEffect);
  1522. },
  1523. updateHash: function updateHash(hash) {
  1524. this._nativeObj.updateHash(hash);
  1525. }
  1526. });
  1527. })();
  1528. },{}],32:[function(require,module,exports){
  1529. "use strict";
  1530. // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  1531. var gfx = window.gfx; // Effect
  1532. var Effect = cc.Effect;
  1533. var _init = Effect.prototype.init;
  1534. var _clone = Effect.prototype.clone;
  1535. var _switchTechnique = Effect.prototype.switchTechnique;
  1536. Object.assign(Effect.prototype, {
  1537. init: function init(name, techniques, techniqueIndex, asset, createNative) {
  1538. _init.call(this, name, techniques, techniqueIndex, asset);
  1539. if (createNative) {
  1540. this._nativeObj = new renderer.EffectNative();
  1541. this._nativeObj.init(techniques);
  1542. this._nativePtr = this._nativeObj.self();
  1543. }
  1544. },
  1545. clone: function clone() {
  1546. var effect = _clone.call(this);
  1547. effect._nativeObj = new renderer.EffectNative();
  1548. effect._nativeObj.copy(this._nativeObj);
  1549. effect._nativePtr = effect._nativeObj.self();
  1550. return effect;
  1551. },
  1552. switchTechnique: function switchTechnique(techniqueIndex) {
  1553. _switchTechnique.call(this, techniqueIndex);
  1554. this._nativeObj.switchTechnique(techniqueIndex);
  1555. }
  1556. }); // EffectBase
  1557. var EffectBase = cc.EffectBase;
  1558. var _setCullMode = EffectBase.prototype.setCullMode;
  1559. var _setBlend = EffectBase.prototype.setBlend;
  1560. var _setStencilEnabled = EffectBase.prototype.setStencilEnabled;
  1561. var _setStencil = EffectBase.prototype.setStencil;
  1562. var _setDepth = EffectBase.prototype.setDepth;
  1563. var _define = EffectBase.prototype.define;
  1564. var _setProperty = EffectBase.prototype.setProperty;
  1565. Object.assign(EffectBase.prototype, {
  1566. setCullMode: function setCullMode() {
  1567. var cullMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gfx.CULL_BACK;
  1568. var passIdx = arguments.length > 1 ? arguments[1] : undefined;
  1569. _setCullMode.call(this, cullMode, passIdx);
  1570. this._nativeObj.setCullMode(cullMode, passIdx === undefined ? -1 : passIdx);
  1571. },
  1572. setBlend: function setBlend() {
  1573. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1574. var blendEq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gfx.BLEND_FUNC_ADD;
  1575. var blendSrc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : gfx.BLEND_SRC_ALPHA;
  1576. var blendDst = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : gfx.BLEND_ONE_MINUS_SRC_ALPHA;
  1577. var blendAlphaEq = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : gfx.BLEND_FUNC_ADD;
  1578. var blendSrcAlpha = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : gfx.BLEND_SRC_ALPHA;
  1579. var blendDstAlpha = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : gfx.BLEND_ONE_MINUS_SRC_ALPHA;
  1580. var blendColor = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0xffffffff;
  1581. var passIdx = arguments.length > 8 ? arguments[8] : undefined;
  1582. _setBlend.call(this, enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx);
  1583. this._nativeObj.setBlend(enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx === undefined ? -1 : passIdx);
  1584. },
  1585. setDepth: function setDepth(depthTest, depthWrite, depthFunc, passIdx) {
  1586. _setDepth.call(this, depthTest, depthWrite, depthFunc, passIdx);
  1587. this._nativeObj.setDepth(depthTest, depthWrite, depthFunc, passIdx === undefined ? -1 : passIdx);
  1588. },
  1589. setStencilEnabled: function setStencilEnabled(enabled, passIdx) {
  1590. _setStencilEnabled.call(this, enabled, passIdx);
  1591. this._nativeObj.setStencilTest(enabled, passIdx === undefined ? -1 : passIdx);
  1592. },
  1593. setStencil: function setStencil() {
  1594. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gfx.STENCIL_INHERIT;
  1595. var stencilFunc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gfx.DS_FUNC_ALWAYS;
  1596. var stencilRef = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  1597. var stencilMask = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0xff;
  1598. var stencilFailOp = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : gfx.STENCIL_OP_KEEP;
  1599. var stencilZFailOp = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : gfx.STENCIL_OP_KEEP;
  1600. var stencilZPassOp = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : gfx.STENCIL_OP_KEEP;
  1601. var stencilWriteMask = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0xff;
  1602. var passIdx = arguments.length > 8 ? arguments[8] : undefined;
  1603. _setStencil.call(this, enabled, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx);
  1604. this._nativeObj.setStencil(stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx === undefined ? -1 : passIdx);
  1605. },
  1606. define: function define(name, value, passIdx, force) {
  1607. _define.call(this, name, value, passIdx, force);
  1608. this._nativeObj.define(name, value, passIdx === undefined ? -1 : passIdx);
  1609. },
  1610. updateHash: function updateHash(hash) {
  1611. this._nativeObj.updateHash(hash);
  1612. },
  1613. setProperty: function setProperty(name, val, passIdx, directly) {
  1614. _setProperty.call(this, name, val, passIdx);
  1615. var prop = this.getProperty(name);
  1616. if (prop !== undefined) {
  1617. this._nativeObj.setProperty(name, prop, passIdx === undefined ? -1 : passIdx, directly);
  1618. }
  1619. }
  1620. });
  1621. },{}],33:[function(require,module,exports){
  1622. "use strict";
  1623. /****************************************************************************
  1624. Copyright (c) 2017-2019 Xiamen Yaji Software Co., Ltd.
  1625. https://www.cocos.com/
  1626. Permission is hereby granted, free of charge, to any person obtaining a copy
  1627. of fsUtils software and associated engine source code (the "Software"), a limited,
  1628. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1629. to use Cocos Creator solely to develop games on your target platforms. You shall
  1630. not use Cocos Creator software for developing other software or tools that's
  1631. used for developing games. You are not granted to publish, distribute,
  1632. sublicense, and/or sell copies of Cocos Creator.
  1633. The software or tools in fsUtils License Agreement are licensed, not sold.
  1634. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1635. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1636. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1637. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1638. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1639. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1640. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1641. THE SOFTWARE.
  1642. ****************************************************************************/
  1643. var fs = jsb.fileUtils;
  1644. var jsb_downloader = null;
  1645. var downloading = new cc.AssetManager.Cache();
  1646. var tempDir = '';
  1647. var fsUtils = {
  1648. fs: fs,
  1649. initJsbDownloader: function initJsbDownloader(jsbDownloaderMaxTasks, jsbDownloaderTimeout) {
  1650. jsb_downloader = new jsb.Downloader({
  1651. countOfMaxProcessingTasks: jsbDownloaderMaxTasks || 32,
  1652. timeoutInSeconds: jsbDownloaderTimeout || 30,
  1653. tempFileNameSuffix: '.tmp'
  1654. });
  1655. tempDir = fsUtils.getUserDataPath() + '/temp';
  1656. !fs.isDirectoryExist(tempDir) && fs.createDirectory(tempDir);
  1657. jsb_downloader.setOnFileTaskSuccess(function (task) {
  1658. if (!downloading.has(task.requestURL)) return;
  1659. var _downloading$remove = downloading.remove(task.requestURL),
  1660. onComplete = _downloading$remove.onComplete;
  1661. onComplete && onComplete(null, task.storagePath);
  1662. });
  1663. jsb_downloader.setOnTaskError(function (task, errorCode, errorCodeInternal, errorStr) {
  1664. if (!downloading.has(task.requestURL)) return;
  1665. var _downloading$remove2 = downloading.remove(task.requestURL),
  1666. onComplete = _downloading$remove2.onComplete;
  1667. cc.error("Download file failed: path: ".concat(task.requestURL, " message: ").concat(errorStr, ", ").concat(errorCode));
  1668. onComplete(new Error(errorStr), null);
  1669. });
  1670. jsb_downloader.setOnTaskProgress(function (task, bytesReceived, totalBytesReceived, totalBytesExpected) {
  1671. if (!downloading.has(task.requestURL)) return;
  1672. var _downloading$get = downloading.get(task.requestURL),
  1673. onProgress = _downloading$get.onProgress;
  1674. onProgress && onProgress(totalBytesReceived, totalBytesExpected);
  1675. });
  1676. },
  1677. getUserDataPath: function getUserDataPath() {
  1678. return fs.getWritablePath().replace(/[\/\\]*$/, '');
  1679. },
  1680. checkFsValid: function checkFsValid() {
  1681. if (!fs) {
  1682. cc.warn('can not get the file system!');
  1683. return false;
  1684. }
  1685. return true;
  1686. },
  1687. deleteFile: function deleteFile(filePath, onComplete) {
  1688. var result = fs.removeFile(filePath);
  1689. if (result === true) {
  1690. onComplete && onComplete(null);
  1691. } else {
  1692. cc.warn("Delete file failed: path: ".concat(filePath));
  1693. onComplete && onComplete(new Error('delete file failed'));
  1694. }
  1695. },
  1696. downloadFile: function downloadFile(remoteUrl, filePath, header, onProgress, onComplete) {
  1697. downloading.add(remoteUrl, {
  1698. onProgress: onProgress,
  1699. onComplete: onComplete
  1700. });
  1701. var storagePath = filePath;
  1702. if (!storagePath) storagePath = tempDir + '/' + performance.now() + cc.path.extname(remoteUrl);
  1703. jsb_downloader.createDownloadFileTask(remoteUrl, storagePath, header);
  1704. },
  1705. saveFile: function saveFile(srcPath, destPath, onComplete) {
  1706. var err = null;
  1707. var result = fs.writeDataToFile(fs.getDataFromFile(srcPath), destPath);
  1708. fs.removeFile(srcPath);
  1709. if (!result) {
  1710. err = new Error("Save file failed: path: ".concat(srcPath));
  1711. cc.warn(err.message);
  1712. }
  1713. onComplete && onComplete(err);
  1714. },
  1715. copyFile: function copyFile(srcPath, destPath, onComplete) {
  1716. var err = null;
  1717. var result = fs.writeDataToFile(fs.getDataFromFile(srcPath), destPath);
  1718. if (!result) {
  1719. err = new Error("Copy file failed: path: ".concat(srcPath));
  1720. cc.warn(err.message);
  1721. }
  1722. onComplete && onComplete(err);
  1723. },
  1724. writeFile: function writeFile(path, data, encoding, onComplete) {
  1725. var result = null;
  1726. var err = null;
  1727. if (encoding === 'utf-8' || encoding === 'utf8') {
  1728. result = fs.writeStringToFile(data, path);
  1729. } else {
  1730. result = fs.writeDataToFile(data, path);
  1731. }
  1732. if (!result) {
  1733. err = new Error("Write file failed: path: ".concat(path));
  1734. cc.warn(err.message);
  1735. }
  1736. onComplete && onComplete(err);
  1737. },
  1738. writeFileSync: function writeFileSync(path, data, encoding) {
  1739. var result = null;
  1740. if (encoding === 'utf-8' || encoding === 'utf8') {
  1741. result = fs.writeStringToFile(data, path);
  1742. } else {
  1743. result = fs.writeDataToFile(data, path);
  1744. }
  1745. if (!result) {
  1746. cc.warn("Write file failed: path: ".concat(path));
  1747. return new Error("Write file failed: path: ".concat(path));
  1748. }
  1749. },
  1750. readFile: function readFile(filePath, encoding, onComplete) {
  1751. var content = null,
  1752. err = null;
  1753. if (encoding === 'utf-8' || encoding === 'utf8') {
  1754. content = fs.getStringFromFile(filePath);
  1755. } else {
  1756. content = fs.getDataFromFile(filePath);
  1757. }
  1758. if (!content) {
  1759. err = new Error("Read file failed: path: ".concat(filePath));
  1760. cc.warn(err.message);
  1761. }
  1762. onComplete && onComplete(err, content);
  1763. },
  1764. readDir: function readDir(filePath, onComplete) {
  1765. var files = null,
  1766. err = null;
  1767. try {
  1768. files = fs.listFiles(filePath);
  1769. } catch (e) {
  1770. cc.warn("Read dir failed: path: ".concat(filePath, " message: ").concat(e.message));
  1771. err = new Error(e.message);
  1772. }
  1773. onComplete && onComplete(err, files);
  1774. },
  1775. readText: function readText(filePath, onComplete) {
  1776. fsUtils.readFile(filePath, 'utf8', onComplete);
  1777. },
  1778. readArrayBuffer: function readArrayBuffer(filePath, onComplete) {
  1779. fsUtils.readFile(filePath, '', onComplete);
  1780. },
  1781. readJson: function readJson(filePath, onComplete) {
  1782. fsUtils.readFile(filePath, 'utf8', function (err, text) {
  1783. var out = null;
  1784. if (!err) {
  1785. try {
  1786. out = JSON.parse(text);
  1787. } catch (e) {
  1788. cc.warn("Read json failed: path: ".concat(filePath, " message: ").concat(e.message));
  1789. err = new Error(e.message);
  1790. }
  1791. }
  1792. onComplete && onComplete(err, out);
  1793. });
  1794. },
  1795. readJsonSync: function readJsonSync(path) {
  1796. try {
  1797. var str = fs.getStringFromFile(path);
  1798. return JSON.parse(str);
  1799. } catch (e) {
  1800. cc.warn("Read json failed: path: ".concat(path, " message: ").concat(e.message));
  1801. return new Error(e.message);
  1802. }
  1803. },
  1804. makeDirSync: function makeDirSync(path, recursive) {
  1805. var result = fs.createDirectory(path);
  1806. if (!result) {
  1807. cc.warn("Make directory failed: path: ".concat(path));
  1808. return new Error("Make directory failed: path: ".concat(path));
  1809. }
  1810. },
  1811. rmdirSync: function rmdirSync(dirPath, recursive) {
  1812. var result = fs.removeDirectory(dirPath);
  1813. if (!result) {
  1814. cc.warn("rm directory failed: path: ".concat(dirPath));
  1815. return new Error("rm directory failed: path: ".concat(dirPath));
  1816. }
  1817. },
  1818. exists: function exists(filePath, onComplete) {
  1819. var result = fs.isFileExist(filePath);
  1820. onComplete && onComplete(result);
  1821. },
  1822. loadSubpackage: function loadSubpackage(name, onProgress, onComplete) {
  1823. throw new Error('not implement');
  1824. }
  1825. };
  1826. window.fsUtils = module.exports = fsUtils;
  1827. },{}],34:[function(require,module,exports){
  1828. "use strict";
  1829. /****************************************************************************
  1830. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  1831. http://www.cocos.com
  1832. Permission is hereby granted, free of charge, to any person obtaining a copy
  1833. of this software and associated engine source code (the "Software"), a limited,
  1834. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1835. to use Cocos Creator solely to develop games on your target platforms. You shall
  1836. not use Cocos Creator software for developing other software or tools that's
  1837. used for developing games. You are not granted to publish, distribute,
  1838. sublicense, and/or sell copies of Cocos Creator.
  1839. The software or tools in this License Agreement are licensed, not sold.
  1840. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1841. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1842. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1843. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1844. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1845. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1846. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1847. THE SOFTWARE.
  1848. ****************************************************************************/
  1849. cc.game.restart = function () {
  1850. // Need to clear scene, or native object destructor won't be invoke.
  1851. cc.director.getScene().destroy();
  1852. cc.Object._deferredDestroy();
  1853. cc.game.pause();
  1854. __restartVM();
  1855. };
  1856. jsb.onError(function (location, message, stack) {
  1857. console.error(location, message, stack);
  1858. });
  1859. jsb.onPause = function () {
  1860. cc.game.emit(cc.game.EVENT_HIDE);
  1861. };
  1862. jsb.onResume = function () {
  1863. cc.game.emit(cc.game.EVENT_SHOW);
  1864. };
  1865. jsb.onResize = function (size) {
  1866. if (size.width === 0 || size.height === 0) return;
  1867. size.width /= window.devicePixelRatio;
  1868. size.height /= window.devicePixelRatio;
  1869. window.resize(size.width, size.height);
  1870. };
  1871. },{}],35:[function(require,module,exports){
  1872. /****************************************************************************
  1873. Copyright (c) 2013-2016 Chukong Technologies Inc.
  1874. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  1875. http://www.cocos.com
  1876. Permission is hereby granted, free of charge, to any person obtaining a copy
  1877. of this software and associated engine source code (the "Software"), a limited,
  1878. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1879. to use Cocos Creator solely to develop games on your target platforms. You shall
  1880. not use Cocos Creator software for developing other software or tools that's
  1881. used for developing games. You are not granted to publish, distribute,
  1882. sublicense, and/or sell copies of Cocos Creator.
  1883. The software or tools in this License Agreement are licensed, not sold.
  1884. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1885. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1886. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1887. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1888. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1889. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1890. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1891. THE SOFTWARE.
  1892. ****************************************************************************/
  1893. 'use strict';
  1894. var cacheManager = require('./jsb-cache-manager');
  1895. var _require = require('./jsb-fs-utils'),
  1896. downloadFile = _require.downloadFile,
  1897. readText = _require.readText,
  1898. readArrayBuffer = _require.readArrayBuffer,
  1899. readJson = _require.readJson,
  1900. getUserDataPath = _require.getUserDataPath,
  1901. initJsbDownloader = _require.initJsbDownloader;
  1902. var REGEX = /^\w+:\/\/.*/;
  1903. var downloader = cc.assetManager.downloader;
  1904. var parser = cc.assetManager.parser;
  1905. var presets = cc.assetManager.presets;
  1906. downloader.maxConcurrency = 30;
  1907. downloader.maxRequestsPerFrame = 60;
  1908. presets['preload'].maxConcurrency = 15;
  1909. presets['preload'].maxRequestsPerFrame = 30;
  1910. presets['scene'].maxConcurrency = 32;
  1911. presets['scene'].maxRequestsPerFrame = 64;
  1912. presets['bundle'].maxConcurrency = 32;
  1913. presets['bundle'].maxRequestsPerFrame = 64;
  1914. var suffix = 0;
  1915. var REMOTE_SERVER_ROOT = '';
  1916. var remoteBundles = {};
  1917. var failureMap = {};
  1918. var maxRetryCountFromBreakpoint = 5;
  1919. var loadedScripts = {};
  1920. function downloadScript(url, options, onComplete) {
  1921. if (typeof options === 'function') {
  1922. onComplete = options;
  1923. options = null;
  1924. }
  1925. if (loadedScripts[url]) return onComplete && onComplete();
  1926. download(url, function (src, options, onComplete) {
  1927. window.require(src);
  1928. loadedScripts[url] = true;
  1929. onComplete && onComplete(null);
  1930. }, options, options.onFileProgress, onComplete);
  1931. }
  1932. function download(url, func, options, onFileProgress, onComplete) {
  1933. var result = transformUrl(url, options);
  1934. if (result.inLocal) {
  1935. func(result.url, options, onComplete);
  1936. } else if (result.inCache) {
  1937. cacheManager.updateLastTime(url);
  1938. func(result.url, options, function (err, data) {
  1939. if (err) {
  1940. cacheManager.removeCache(url);
  1941. }
  1942. onComplete(err, data);
  1943. });
  1944. } else {
  1945. var time = Date.now();
  1946. var storagePath = '';
  1947. var failureRecord = failureMap[url];
  1948. if (failureRecord) {
  1949. storagePath = failureRecord.storagePath;
  1950. } else if (options.__cacheBundleRoot__) {
  1951. storagePath = "".concat(options.__cacheBundleRoot__, "/").concat(time).concat(suffix++).concat(cc.path.extname(url));
  1952. } else {
  1953. storagePath = "".concat(time).concat(suffix++).concat(cc.path.extname(url));
  1954. }
  1955. downloadFile(url, "".concat(cacheManager.cacheDir, "/").concat(storagePath), options.header, onFileProgress, function (err, path) {
  1956. if (err) {
  1957. if (failureRecord) {
  1958. failureRecord.retryCount++;
  1959. if (failureRecord.retryCount >= maxRetryCountFromBreakpoint) {
  1960. delete failureMap[url];
  1961. }
  1962. } else {
  1963. failureMap[url] = {
  1964. retryCount: 0,
  1965. storagePath: storagePath
  1966. };
  1967. }
  1968. onComplete(err, null);
  1969. return;
  1970. }
  1971. delete failureMap[url];
  1972. func(path, options, function (err, data) {
  1973. if (!err) {
  1974. cacheManager.cacheFile(url, storagePath, options.__cacheBundleRoot__);
  1975. }
  1976. onComplete(err, data);
  1977. });
  1978. });
  1979. }
  1980. }
  1981. function transformUrl(url, options) {
  1982. var inLocal = false;
  1983. var inCache = false;
  1984. if (REGEX.test(url)) {
  1985. if (options.reload) {
  1986. return {
  1987. url: url
  1988. };
  1989. } else {
  1990. var cache = cacheManager.getCache(url);
  1991. if (cache) {
  1992. inCache = true;
  1993. url = cache;
  1994. }
  1995. }
  1996. } else {
  1997. inLocal = true;
  1998. }
  1999. return {
  2000. url: url,
  2001. inLocal: inLocal,
  2002. inCache: inCache
  2003. };
  2004. }
  2005. function doNothing(content, options, onComplete) {
  2006. onComplete(null, content);
  2007. }
  2008. function downloadAsset(url, options, onComplete) {
  2009. download(url, doNothing, options, options.onFileProgress, onComplete);
  2010. }
  2011. function _getFontFamily(fontHandle) {
  2012. var ttfIndex = fontHandle.lastIndexOf(".ttf");
  2013. if (ttfIndex === -1) return fontHandle;
  2014. var slashPos = fontHandle.lastIndexOf("/");
  2015. var fontFamilyName;
  2016. if (slashPos === -1) {
  2017. fontFamilyName = fontHandle.substring(0, ttfIndex) + "_LABEL";
  2018. } else {
  2019. fontFamilyName = fontHandle.substring(slashPos + 1, ttfIndex) + "_LABEL";
  2020. }
  2021. if (fontFamilyName.indexOf(' ') !== -1) {
  2022. fontFamilyName = '"' + fontFamilyName + '"';
  2023. }
  2024. return fontFamilyName;
  2025. }
  2026. function parseText(url, options, onComplete) {
  2027. readText(url, onComplete);
  2028. }
  2029. function parseJson(url, options, onComplete) {
  2030. readJson(url, onComplete);
  2031. }
  2032. function downloadText(url, options, onComplete) {
  2033. download(url, parseText, options, options.onFileProgress, onComplete);
  2034. }
  2035. function parseArrayBuffer(url, options, onComplete) {
  2036. readArrayBuffer(url, onComplete);
  2037. }
  2038. function downloadJson(url, options, onComplete) {
  2039. download(url, parseJson, options, options.onFileProgress, onComplete);
  2040. }
  2041. function downloadBundle(nameOrUrl, options, onComplete) {
  2042. var bundleName = cc.path.basename(nameOrUrl);
  2043. var version = options.version || cc.assetManager.downloader.bundleVers[bundleName];
  2044. var url;
  2045. if (REGEX.test(nameOrUrl) || nameOrUrl.startsWith(getUserDataPath())) {
  2046. url = nameOrUrl;
  2047. cacheManager.makeBundleFolder(bundleName);
  2048. } else {
  2049. if (remoteBundles[bundleName]) {
  2050. url = "".concat(REMOTE_SERVER_ROOT, "remote/").concat(bundleName);
  2051. cacheManager.makeBundleFolder(bundleName);
  2052. } else {
  2053. url = "assets/".concat(bundleName);
  2054. }
  2055. }
  2056. var config = "".concat(url, "/config.").concat(version ? version + '.' : '', "json");
  2057. options.__cacheBundleRoot__ = bundleName;
  2058. downloadJson(config, options, function (err, response) {
  2059. if (err) {
  2060. return onComplete(err, null);
  2061. }
  2062. var out = response;
  2063. out && (out.base = url + '/');
  2064. var js = "".concat(url, "/index.").concat(version ? version + '.' : '').concat(out.encrypted ? 'jsc' : "js");
  2065. downloadScript(js, options, function (err) {
  2066. if (err) {
  2067. return onComplete(err, null);
  2068. }
  2069. onComplete(err, out);
  2070. });
  2071. });
  2072. }
  2073. ;
  2074. function loadFont(url, options, onComplete) {
  2075. var fontFamilyName = _getFontFamily(url);
  2076. var fontFace = new FontFace(fontFamilyName, "url('" + url + "')");
  2077. document.fonts.add(fontFace);
  2078. fontFace.load();
  2079. fontFace.loaded.then(function () {
  2080. onComplete(null, fontFamilyName);
  2081. }, function () {
  2082. cc.warnID(4933, fontFamilyName);
  2083. onComplete(null, fontFamilyName);
  2084. });
  2085. }
  2086. function parsePlist(url, options, onComplete) {
  2087. readText(url, function (err, file) {
  2088. var result = null;
  2089. if (!err) {
  2090. result = cc.plistParser.parse(file);
  2091. if (!result) err = new Error('parse failed');
  2092. }
  2093. onComplete && onComplete(err, result);
  2094. });
  2095. }
  2096. parser.parsePVRTex = downloader.downloadDomImage;
  2097. parser.parsePKMTex = downloader.downloadDomImage;
  2098. downloader.downloadScript = downloadScript;
  2099. downloader.register({
  2100. // JS
  2101. '.js': downloadScript,
  2102. '.jsc': downloadScript,
  2103. // Images
  2104. '.png': downloadAsset,
  2105. '.jpg': downloadAsset,
  2106. '.bmp': downloadAsset,
  2107. '.jpeg': downloadAsset,
  2108. '.gif': downloadAsset,
  2109. '.ico': downloadAsset,
  2110. '.tiff': downloadAsset,
  2111. '.webp': downloadAsset,
  2112. '.image': downloadAsset,
  2113. '.pvr': downloadAsset,
  2114. '.pkm': downloadAsset,
  2115. // Audio
  2116. '.mp3': downloadAsset,
  2117. '.ogg': downloadAsset,
  2118. '.wav': downloadAsset,
  2119. '.m4a': downloadAsset,
  2120. // Video
  2121. '.mp4': downloadAsset,
  2122. '.avi': downloadAsset,
  2123. '.mov': downloadAsset,
  2124. '.mpg': downloadAsset,
  2125. '.mpeg': downloadAsset,
  2126. '.rm': downloadAsset,
  2127. '.rmvb': downloadAsset,
  2128. // Text
  2129. '.txt': downloadAsset,
  2130. '.xml': downloadAsset,
  2131. '.vsh': downloadAsset,
  2132. '.fsh': downloadAsset,
  2133. '.atlas': downloadAsset,
  2134. '.tmx': downloadAsset,
  2135. '.tsx': downloadAsset,
  2136. '.fnt': downloadAsset,
  2137. '.plist': downloadAsset,
  2138. '.json': downloadJson,
  2139. '.ExportJson': downloadAsset,
  2140. '.binary': downloadAsset,
  2141. '.bin': downloadAsset,
  2142. '.dbbin': downloadAsset,
  2143. '.skel': downloadAsset,
  2144. // Font
  2145. '.font': downloadAsset,
  2146. '.eot': downloadAsset,
  2147. '.ttf': downloadAsset,
  2148. '.woff': downloadAsset,
  2149. '.svg': downloadAsset,
  2150. '.ttc': downloadAsset,
  2151. 'bundle': downloadBundle,
  2152. 'default': downloadText
  2153. });
  2154. parser.register({
  2155. // Images
  2156. '.png': downloader.downloadDomImage,
  2157. '.jpg': downloader.downloadDomImage,
  2158. '.bmp': downloader.downloadDomImage,
  2159. '.jpeg': downloader.downloadDomImage,
  2160. '.gif': downloader.downloadDomImage,
  2161. '.ico': downloader.downloadDomImage,
  2162. '.tiff': downloader.downloadDomImage,
  2163. '.webp': downloader.downloadDomImage,
  2164. '.image': downloader.downloadDomImage,
  2165. // compressed texture
  2166. '.pvr': downloader.downloadDomImage,
  2167. '.pkm': downloader.downloadDomImage,
  2168. '.binary': parseArrayBuffer,
  2169. '.bin': parseArrayBuffer,
  2170. '.dbbin': parseArrayBuffer,
  2171. '.skel': parseArrayBuffer,
  2172. // Text
  2173. '.txt': parseText,
  2174. '.xml': parseText,
  2175. '.vsh': parseText,
  2176. '.fsh': parseText,
  2177. '.atlas': parseText,
  2178. '.tmx': parseText,
  2179. '.tsx': parseText,
  2180. '.fnt': parseText,
  2181. '.plist': parsePlist,
  2182. // Font
  2183. '.font': loadFont,
  2184. '.eot': loadFont,
  2185. '.ttf': loadFont,
  2186. '.woff': loadFont,
  2187. '.svg': loadFont,
  2188. '.ttc': loadFont,
  2189. '.ExportJson': parseJson
  2190. });
  2191. cc.assetManager.transformPipeline.append(function (task) {
  2192. var input = task.output = task.input;
  2193. for (var i = 0, l = input.length; i < l; i++) {
  2194. var item = input[i];
  2195. if (item.config) {
  2196. item.options.__cacheBundleRoot__ = item.config.name;
  2197. }
  2198. }
  2199. });
  2200. var originInit = cc.assetManager.init;
  2201. cc.assetManager.init = function (options) {
  2202. originInit.call(cc.assetManager, options);
  2203. options.remoteBundles && options.remoteBundles.forEach(function (x) {
  2204. return remoteBundles[x] = true;
  2205. });
  2206. REMOTE_SERVER_ROOT = options.server || '';
  2207. if (REMOTE_SERVER_ROOT && !REMOTE_SERVER_ROOT.endsWith('/')) REMOTE_SERVER_ROOT += '/';
  2208. initJsbDownloader(options.jsbDownloaderMaxTasks, options.jsbDownloaderTimeout);
  2209. cacheManager.init();
  2210. };
  2211. },{"./jsb-cache-manager":29,"./jsb-fs-utils":33}],36:[function(require,module,exports){
  2212. "use strict";
  2213. /****************************************************************************
  2214. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  2215. http://www.cocos.com
  2216. Permission is hereby granted, free of charge, to any person obtaining a copy
  2217. of this software and associated engine source code (the "Software"), a limited,
  2218. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  2219. to use Cocos Creator solely to develop games on your target platforms. You shall
  2220. not use Cocos Creator software for developing other software or tools that's
  2221. used for developing games. You are not granted to publish, distribute,
  2222. sublicense, and/or sell copies of Cocos Creator.
  2223. The software or tools in this License Agreement are licensed, not sold.
  2224. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  2225. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2226. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2227. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2228. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2229. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2230. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2231. THE SOFTWARE.
  2232. ****************************************************************************/
  2233. (function () {
  2234. if (window.middleware === undefined) return;
  2235. var ParticleSystem = cc.ParticleSystem;
  2236. if (ParticleSystem === undefined) return;
  2237. var PSProto = ParticleSystem.prototype;
  2238. PSProto.initProperties = function () {
  2239. this._simulator = new middleware.ParticleSimulator();
  2240. this._previewTimer = null;
  2241. this._focused = false;
  2242. this._texture = null;
  2243. this._renderData = null;
  2244. this._simulator.__particleSystem__ = this;
  2245. this._simulator.setFinishedCallback(function () {
  2246. var self = this.__particleSystem__;
  2247. self._finishedSimulation();
  2248. });
  2249. this._simulator.setStopCallback(function () {
  2250. var self = this.__particleSystem__;
  2251. self.stopSystem();
  2252. });
  2253. this._initProperties();
  2254. }; // value type properties
  2255. var propertiesList = ["positionType", "emissionRate", "totalParticles", "duration", "emitterMode", "life", "lifeVar", "startSize", "startSizeVar", "endSize", "endSizeVar", "startSpin", "startSpinVar", "endSpin", "endSpinVar", "angle", "angleVar", "speed", "speedVar", "radialAccel", "radialAccelVar", "tangentialAccel", "tangentialAccelVar", "rotationIsDir", "startRadius", "startRadiusVar", "endRadius", "endRadiusVar", "rotatePerS", "rotatePerSVar"];
  2256. propertiesList.forEach(function (getSetName) {
  2257. var varName = "_" + getSetName;
  2258. Object.defineProperty(PSProto, getSetName, {
  2259. get: function get() {
  2260. this[varName] === undefined && (this[varName] = 0);
  2261. return this[varName];
  2262. },
  2263. set: function set(val) {
  2264. this[varName] = val;
  2265. this._simulator && (this._simulator[getSetName] = val);
  2266. }
  2267. });
  2268. }); // object type properties
  2269. var objPropList = ['gravity', 'sourcePos', 'posVar', 'startColor', 'startColorVar', 'endColor', 'endColorVar'];
  2270. PSProto._initProperties = function () {
  2271. // init properties
  2272. for (var key in propertiesList) {
  2273. var propName = propertiesList[key];
  2274. this[propName] = this[propName];
  2275. }
  2276. for (var _key in objPropList) {
  2277. var _propName = objPropList[_key];
  2278. this[_propName] = this[_propName];
  2279. }
  2280. }, Object.defineProperty(PSProto, 'gravity', {
  2281. get: function get() {
  2282. !this._gravity && (this._gravity = cc.v2(0, 0));
  2283. return this._gravity;
  2284. },
  2285. set: function set(val) {
  2286. if (!val) return;
  2287. !this._gravity && (this._gravity = cc.v2(0, 0));
  2288. this.gravity.x = val.x;
  2289. this.gravity.y = val.y;
  2290. this._simulator && this._simulator.setGravity(val.x, val.y, 0);
  2291. }
  2292. });
  2293. Object.defineProperty(PSProto, 'sourcePos', {
  2294. get: function get() {
  2295. !this._sourcePos && (this._sourcePos = cc.v2(0, 0));
  2296. return this._sourcePos;
  2297. },
  2298. set: function set(val) {
  2299. if (!val) return;
  2300. !this._sourcePos && (this._sourcePos = cc.v2(0, 0));
  2301. this._sourcePos.x = val.x;
  2302. this._sourcePos.y = val.y;
  2303. this._simulator && this._simulator.setSourcePos(val.x, val.y, 0);
  2304. }
  2305. });
  2306. Object.defineProperty(PSProto, 'posVar', {
  2307. get: function get() {
  2308. !this._posVar && (this._posVar = cc.v2(0, 0));
  2309. return this._posVar;
  2310. },
  2311. set: function set(val) {
  2312. if (!val) return;
  2313. !this._posVar && (this._posVar = cc.v2(0, 0));
  2314. this._posVar.x = val.x;
  2315. this._posVar.y = val.y;
  2316. this._simulator && this._simulator.setPosVar(val.x, val.y, 0);
  2317. }
  2318. });
  2319. Object.defineProperty(PSProto, 'startColor', {
  2320. get: function get() {
  2321. !this._startColor && (this._startColor = cc.color(255, 255, 255, 255));
  2322. return this._startColor;
  2323. },
  2324. set: function set(val) {
  2325. if (!val) return;
  2326. !this._startColor && (this._startColor = cc.color(255, 255, 255, 255));
  2327. this._startColor.r = val.r;
  2328. this._startColor.g = val.g;
  2329. this._startColor.b = val.b;
  2330. this._startColor.a = val.a;
  2331. this._simulator && this._simulator.setStartColor(val.r, val.g, val.b, val.a);
  2332. }
  2333. });
  2334. Object.defineProperty(PSProto, 'startColorVar', {
  2335. get: function get() {
  2336. !this._startColorVar && (this._startColorVar = cc.color(0, 0, 0, 0));
  2337. return this._startColorVar;
  2338. },
  2339. set: function set(val) {
  2340. if (!val) return;
  2341. !this._startColorVar && (this._startColorVar = cc.color(0, 0, 0, 0));
  2342. this._startColorVar.r = val.r;
  2343. this._startColorVar.g = val.g;
  2344. this._startColorVar.b = val.b;
  2345. this._startColorVar.a = val.a;
  2346. this._simulator && this._simulator.setStartColorVar(val.r, val.g, val.b, val.a);
  2347. }
  2348. });
  2349. Object.defineProperty(PSProto, 'endColor', {
  2350. get: function get() {
  2351. !this._endColor && (this._endColor = cc.color(255, 255, 255, 0));
  2352. return this._endColor;
  2353. },
  2354. set: function set(val) {
  2355. if (!val) return;
  2356. !this._endColor && (this._endColor = cc.color(255, 255, 255, 0));
  2357. this._endColor.r = val.r;
  2358. this._endColor.g = val.g;
  2359. this._endColor.b = val.b;
  2360. this._endColor.a = val.a;
  2361. this._simulator && this._simulator.setEndColor(val.r, val.g, val.b, val.a);
  2362. }
  2363. });
  2364. Object.defineProperty(PSProto, 'endColorVar', {
  2365. get: function get() {
  2366. !this._endColorVar && (this._endColorVar = cc.color(0, 0, 0, 0));
  2367. return this._endColorVar;
  2368. },
  2369. set: function set(val) {
  2370. if (!val) return;
  2371. !this._endColorVar && (this._endColorVar = cc.color(0, 0, 0, 0));
  2372. this._endColorVar.r = val.r;
  2373. this._endColorVar.g = val.g;
  2374. this._endColorVar.b = val.b;
  2375. this._endColorVar.a = val.a;
  2376. this._simulator && this._simulator.setEndColorVar(val.r, val.g, val.b, val.a);
  2377. }
  2378. });
  2379. Object.defineProperty(PSProto, 'particleCount', {
  2380. get: function get() {
  2381. if (!this._simulator) {
  2382. return 0;
  2383. }
  2384. return this._simulator.getParticleCount();
  2385. }
  2386. });
  2387. Object.defineProperty(PSProto, 'active', {
  2388. get: function get() {
  2389. if (!this._simulator) {
  2390. return false;
  2391. }
  2392. return this._simulator.active();
  2393. }
  2394. });
  2395. PSProto.onLoad = function () {
  2396. this._simulator.bindNodeProxy(this.node._proxy);
  2397. }; // shield in native
  2398. PSProto.update = null;
  2399. PSProto.lateUpdate = null;
  2400. PSProto._resetAssembler = function () {
  2401. this._assembler = new renderer.CustomAssembler();
  2402. this._assembler.setUseModel(true);
  2403. this.node._proxy.setAssembler(this._assembler);
  2404. };
  2405. var _onEnable = PSProto.onEnable;
  2406. PSProto.onEnable = function () {
  2407. _onEnable.call(this);
  2408. if (this._simulator) {
  2409. this._simulator.onEnable();
  2410. }
  2411. };
  2412. var _onDisable = PSProto.onDisable;
  2413. PSProto.onDisable = function () {
  2414. _onDisable.call(this);
  2415. if (this._simulator) {
  2416. this._simulator.onDisable();
  2417. }
  2418. };
  2419. PSProto._onTextureLoaded = function () {
  2420. this._simulator.updateUVs(this._renderSpriteFrame.uv);
  2421. this._syncAspect();
  2422. this._simulator.aspectRatio = this._aspectRatio || 1.0;
  2423. this._updateMaterial();
  2424. this.markForRender(true);
  2425. };
  2426. var _updateMaterial = PSProto._updateMaterial;
  2427. PSProto._updateMaterial = function () {
  2428. _updateMaterial.call(this);
  2429. var material = this._materials[0];
  2430. material && this._simulator.setEffect(material.effect._nativeObj); // upload hash value to native
  2431. material && material.getHash();
  2432. };
  2433. var _initWithDictionary = PSProto._initWithDictionary;
  2434. PSProto._initWithDictionary = function (content) {
  2435. _initWithDictionary.call(this, content);
  2436. this._initProperties();
  2437. };
  2438. var __preload = PSProto.__preload;
  2439. PSProto.__preload = function () {
  2440. __preload.call(this);
  2441. this._initProperties();
  2442. };
  2443. })();
  2444. },{}],37:[function(require,module,exports){
  2445. "use strict";
  2446. /****************************************************************************
  2447. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  2448. http://www.cocos.com
  2449. Permission is hereby granted, free of charge, to any person obtaining a copy
  2450. of this software and associated engine source code (the "Software"), a limited,
  2451. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  2452. to use Cocos Creator solely to develop games on your target platforms. You shall
  2453. not use Cocos Creator software for developing other software or tools that's
  2454. used for developing games. You are not granted to publish, distribute,
  2455. sublicense, and/or sell copies of Cocos Creator.
  2456. The software or tools in this License Agreement are licensed, not sold.
  2457. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  2458. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2459. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2460. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2461. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2462. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2463. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2464. THE SOFTWARE.
  2465. ****************************************************************************/
  2466. // JS to Native bridges
  2467. if (window.JavascriptJavaBridge && cc.sys.os == cc.sys.OS_ANDROID) {
  2468. jsb.reflection = new JavascriptJavaBridge();
  2469. cc.sys.capabilities["keyboard"] = true;
  2470. } else if (window.JavaScriptObjCBridge && (cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_OSX)) {
  2471. jsb.reflection = new JavaScriptObjCBridge();
  2472. }
  2473. },{}],38:[function(require,module,exports){
  2474. "use strict";
  2475. var SafeArea = cc.SafeArea;
  2476. if (SafeArea) {
  2477. var _onEnable = SafeArea.prototype.onEnable;
  2478. var _onDisable = SafeArea.prototype.onDisable;
  2479. Object.assign(SafeArea.prototype, {
  2480. onEnable: function onEnable() {
  2481. _onEnable.call(this);
  2482. this._adaptSafeAreaChangeWithThis = this.adaptSafeAreaChange.bind(this);
  2483. this._updateAreaWithThis = this.adaptSafeAreaChange.bind(this);
  2484. window.addEventListener('orientationchange', this._adaptSafeAreaChangeWithThis);
  2485. window.addEventListener('safearea-change', this._updateAreaWithThis);
  2486. },
  2487. onDisable: function onDisable() {
  2488. _onDisable.call(this);
  2489. window.removeEventListener('orientationchange', this._adaptSafeAreaChangeWithThis);
  2490. window.removeEventListener('safearea-change', this._updateAreaWithThis);
  2491. },
  2492. adaptSafeAreaChange: function adaptSafeAreaChange() {
  2493. var _this = this;
  2494. if (CC_JSB && (cc.sys.os === cc.sys.OS_IOS || cc.sys.os === cc.sys.OS_ANDROID)) {
  2495. setTimeout(function () {
  2496. _this.updateArea();
  2497. }, 200);
  2498. }
  2499. }
  2500. });
  2501. }
  2502. },{}],39:[function(require,module,exports){
  2503. "use strict";
  2504. (function () {
  2505. if (!cc.SkinnedMeshRenderer) return;
  2506. var SkinnedMeshAssembler = cc.SkinnedMeshRenderer.__assembler__.prototype;
  2507. cc.js.mixin(SkinnedMeshAssembler, {
  2508. updateRenderData: function updateRenderData(comp) {
  2509. comp.calcJointMatrix();
  2510. comp.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA;
  2511. }
  2512. });
  2513. })();
  2514. },{}],40:[function(require,module,exports){
  2515. "use strict";
  2516. /****************************************************************************
  2517. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  2518. http://www.cocos.com
  2519. Permission is hereby granted, free of charge, to any person obtaining a copy
  2520. of this software and associated engine source code (the "Software"), a limited,
  2521. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  2522. to use Cocos Creator solely to develop games on your target platforms. You shall
  2523. not use Cocos Creator software for developing other software or tools that's
  2524. used for developing games. You are not granted to publish, distribute,
  2525. sublicense, and/or sell copies of Cocos Creator.
  2526. The software or tools in this License Agreement are licensed, not sold.
  2527. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  2528. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2529. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2530. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2531. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2532. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2533. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2534. THE SOFTWARE.
  2535. ****************************************************************************/
  2536. var cacheManager = require('./jsb-cache-manager');
  2537. (function () {
  2538. if (window.sp === undefined || window.spine === undefined || window.middleware === undefined) return;
  2539. sp.VertexEffectDelegate = spine.VertexEffectDelegate;
  2540. jsb.generateGetSet(spine); // spine global time scale
  2541. Object.defineProperty(sp, 'timeScale', {
  2542. get: function get() {
  2543. return this._timeScale;
  2544. },
  2545. set: function set(value) {
  2546. this._timeScale = value;
  2547. spine.SkeletonAnimation.setGlobalTimeScale(value);
  2548. },
  2549. configurable: true
  2550. });
  2551. var _slotColor = cc.color(0, 0, 255, 255);
  2552. var _boneColor = cc.color(255, 0, 0, 255);
  2553. var _meshColor = cc.color(255, 255, 0, 255);
  2554. var _originColor = cc.color(0, 255, 0, 255);
  2555. var skeletonDataProto = sp.SkeletonData.prototype;
  2556. var _gTextureIdx = 1;
  2557. var _textureKeyMap = {};
  2558. var _textureMap = new WeakMap();
  2559. var skeletonDataMgr = spine.SkeletonDataMgr.getInstance();
  2560. spine.skeletonDataMgr = skeletonDataMgr;
  2561. skeletonDataMgr.setDestroyCallback(function (textureIndex) {
  2562. if (!textureIndex) return;
  2563. var texKey = _textureKeyMap[textureIndex];
  2564. if (texKey && _textureMap.has(texKey)) {
  2565. _textureMap["delete"](texKey);
  2566. delete _textureKeyMap[textureIndex];
  2567. }
  2568. });
  2569. var skeletonCacheMgr = spine.SkeletonCacheMgr.getInstance();
  2570. spine.skeletonCacheMgr = skeletonCacheMgr;
  2571. skeletonDataProto.destroy = function () {
  2572. this.reset();
  2573. skeletonCacheMgr.removeSkeletonCache(this._uuid);
  2574. cc.Asset.prototype.destroy.call(this);
  2575. };
  2576. skeletonDataProto.reset = function () {
  2577. if (this._skeletonCache) {
  2578. spine.disposeSkeletonData(this._uuid);
  2579. this._jsbTextures = null;
  2580. this._skeletonCache = null;
  2581. }
  2582. this._atlasCache = null;
  2583. };
  2584. skeletonDataProto.getRuntimeData = function () {
  2585. if (!this._skeletonCache) {
  2586. this.init();
  2587. }
  2588. return this._skeletonCache;
  2589. };
  2590. skeletonDataProto.init = function () {
  2591. if (this._skeletonCache) return;
  2592. var uuid = this._uuid;
  2593. if (!uuid) {
  2594. cc.errorID(7504);
  2595. return;
  2596. }
  2597. var skeletonCache = spine.retainSkeletonData(uuid);
  2598. if (skeletonCache) {
  2599. this._skeletonCache = skeletonCache;
  2600. this.width = this._skeletonCache.getWidth();
  2601. this.height = this._skeletonCache.getHeight();
  2602. return;
  2603. }
  2604. var atlasText = this.atlasText;
  2605. if (!atlasText) {
  2606. cc.errorID(7508, this.name);
  2607. return;
  2608. }
  2609. var textures = this.textures;
  2610. var textureNames = this.textureNames;
  2611. if (!(textures && textures.length > 0 && textureNames && textureNames.length > 0)) {
  2612. cc.errorID(7507, this.name);
  2613. return;
  2614. }
  2615. var jsbTextures = {};
  2616. for (var i = 0; i < textures.length; ++i) {
  2617. var texture = textures[i];
  2618. var textureIdx = this.recordTexture(texture);
  2619. var spTex = new middleware.Texture2D();
  2620. spTex.setRealTextureIndex(textureIdx);
  2621. spTex.setPixelsWide(texture.width);
  2622. spTex.setPixelsHigh(texture.height);
  2623. spTex.setTexParamCallback(function (texIdx, minFilter, magFilter, wrapS, warpT) {
  2624. var tex = this.getTextureByIndex(texIdx);
  2625. tex.setFilters(minFilter, magFilter);
  2626. tex.setWrapMode(wrapS, warpT);
  2627. }.bind(this));
  2628. spTex.setNativeTexture(texture.getImpl());
  2629. jsbTextures[textureNames[i]] = spTex;
  2630. }
  2631. this._jsbTextures = jsbTextures;
  2632. var filePath = null;
  2633. if (this.skeletonJsonStr) {
  2634. filePath = this.skeletonJsonStr;
  2635. } else {
  2636. filePath = cacheManager.getCache(this.nativeUrl) || this.nativeUrl;
  2637. }
  2638. this._skeletonCache = spine.initSkeletonData(uuid, filePath, atlasText, jsbTextures, this.scale);
  2639. if (this._skeletonCache) {
  2640. this.width = this._skeletonCache.getWidth();
  2641. this.height = this._skeletonCache.getHeight();
  2642. }
  2643. };
  2644. skeletonDataProto.recordTexture = function (texture) {
  2645. var index = _gTextureIdx;
  2646. var texKey = _textureKeyMap[index] = {
  2647. key: index
  2648. };
  2649. _textureMap.set(texKey, texture);
  2650. _gTextureIdx++;
  2651. return index;
  2652. };
  2653. skeletonDataProto.getTextureByIndex = function (textureIdx) {
  2654. var texKey = _textureKeyMap[textureIdx];
  2655. if (!texKey) return;
  2656. return _textureMap.get(texKey);
  2657. };
  2658. var renderCompProto = cc.RenderComponent.prototype;
  2659. var animation = spine.SkeletonAnimation.prototype; // The methods are added to be compatibility with old versions.
  2660. animation.setCompleteListener = function (listener) {
  2661. this._compeleteListener = listener;
  2662. this.setCompleteListenerNative(function (trackEntry) {
  2663. var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
  2664. this._compeleteListener && this._compeleteListener(trackEntry, loopCount);
  2665. });
  2666. }; // The methods are added to be compatibility with old versions.
  2667. animation.setTrackCompleteListener = function (trackEntry, listener) {
  2668. this._trackCompeleteListener = listener;
  2669. this.setTrackCompleteListenerNative(trackEntry, function (trackEntryNative) {
  2670. var loopCount = Math.floor(trackEntryNative.trackTime / trackEntryNative.animationEnd);
  2671. this._trackCompeleteListener && this._trackCompeleteListener(trackEntryNative, loopCount);
  2672. });
  2673. }; // Temporary solution before upgrade the Spine API
  2674. animation.setAnimationListener = function (target, callback) {
  2675. this._target = target;
  2676. this._callback = callback;
  2677. this.setStartListener(function (trackEntry) {
  2678. if (this._target && this._callback) {
  2679. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.START, null, 0);
  2680. }
  2681. });
  2682. this.setInterruptListener(function (trackEntry) {
  2683. if (this._target && this._callback) {
  2684. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.INTERRUPT, null, 0);
  2685. }
  2686. });
  2687. this.setEndListener(function (trackEntry) {
  2688. if (this._target && this._callback) {
  2689. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.END, null, 0);
  2690. }
  2691. });
  2692. this.setDisposeListener(function (trackEntry) {
  2693. if (this._target && this._callback) {
  2694. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.DISPOSE, null, 0);
  2695. }
  2696. });
  2697. this.setCompleteListener(function (trackEntry, loopCount) {
  2698. if (this._target && this._callback) {
  2699. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.COMPLETE, null, loopCount);
  2700. }
  2701. });
  2702. this.setEventListener(function (trackEntry, event) {
  2703. if (this._target && this._callback) {
  2704. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.EVENT, event, 0);
  2705. }
  2706. });
  2707. };
  2708. sp.Skeleton._assembler = null;
  2709. var skeleton = sp.Skeleton.prototype;
  2710. var AnimationCacheMode = sp.Skeleton.AnimationCacheMode;
  2711. Object.defineProperty(skeleton, 'paused', {
  2712. get: function get() {
  2713. return this._paused || false;
  2714. },
  2715. set: function set(value) {
  2716. this._paused = value;
  2717. if (this._nativeSkeleton) {
  2718. this._nativeSkeleton.paused(value);
  2719. }
  2720. }
  2721. });
  2722. Object.defineProperty(skeleton, "premultipliedAlpha", {
  2723. get: function get() {
  2724. if (this._premultipliedAlpha === undefined) {
  2725. return true;
  2726. }
  2727. return this._premultipliedAlpha;
  2728. },
  2729. set: function set(value) {
  2730. this._premultipliedAlpha = value;
  2731. if (this._nativeSkeleton) {
  2732. this._nativeSkeleton.setOpacityModifyRGB(this._premultipliedAlpha);
  2733. }
  2734. }
  2735. });
  2736. Object.defineProperty(skeleton, "timeScale", {
  2737. get: function get() {
  2738. if (this._timeScale === undefined) return 1.0;
  2739. return this._timeScale;
  2740. },
  2741. set: function set(value) {
  2742. this._timeScale = value;
  2743. if (this._nativeSkeleton) {
  2744. this._nativeSkeleton.setTimeScale(this._timeScale);
  2745. }
  2746. }
  2747. });
  2748. var _updateDebugDraw = skeleton._updateDebugDraw;
  2749. skeleton._updateDebugDraw = function () {
  2750. _updateDebugDraw.call(this);
  2751. if (this._nativeSkeleton && !this.isAnimationCached()) {
  2752. this._nativeSkeleton.setDebugMeshEnabled(this.debugMesh);
  2753. this._nativeSkeleton.setDebugSlotsEnabled(this.debugSlots);
  2754. this._nativeSkeleton.setDebugBonesEnabled(this.debugBones);
  2755. }
  2756. };
  2757. var _updateUseTint = skeleton._updateUseTint;
  2758. skeleton._updateUseTint = function () {
  2759. _updateUseTint.call(this);
  2760. if (this._nativeSkeleton) {
  2761. this._nativeSkeleton.setUseTint(this.useTint);
  2762. }
  2763. this._assembler && this._assembler.clearEffect();
  2764. };
  2765. var _updateBatch = skeleton._updateBatch;
  2766. skeleton._updateBatch = function () {
  2767. _updateBatch.call(this);
  2768. if (this._nativeSkeleton) {
  2769. this._nativeSkeleton.setBatchEnabled(this.enableBatch);
  2770. }
  2771. this._assembler && this._assembler.clearEffect();
  2772. };
  2773. var _onLoad = skeleton.onLoad;
  2774. skeleton.onLoad = function () {
  2775. if (_onLoad) {
  2776. _onLoad.call(this);
  2777. }
  2778. };
  2779. skeleton._resetAssembler = function () {
  2780. this._assembler = new renderer.CustomAssembler();
  2781. this.node._proxy.setAssembler(this._assembler);
  2782. };
  2783. var _updateMaterial = skeleton._updateMaterial;
  2784. var _materialHashMap = {};
  2785. var _materialId = 1;
  2786. skeleton._updateMaterial = function () {
  2787. _updateMaterial.call(this);
  2788. this._assembler && this._assembler.clearEffect();
  2789. var baseMaterial = this.getMaterial(0);
  2790. if (this._nativeSkeleton && baseMaterial) {
  2791. var originHash = baseMaterial.effect.getHash();
  2792. var id = _materialHashMap[originHash] || _materialId++;
  2793. _materialHashMap[originHash] = id;
  2794. baseMaterial.effect.updateHash(id);
  2795. var nativeEffect = baseMaterial.effect._nativeObj;
  2796. this._nativeSkeleton.setEffect(nativeEffect);
  2797. }
  2798. };
  2799. skeleton.setSkeletonData = function (skeletonData) {
  2800. null != skeletonData.width && null != skeletonData.height && this.node.setContentSize(skeletonData.width, skeletonData.height);
  2801. var uuid = skeletonData._uuid;
  2802. if (!uuid) {
  2803. cc.errorID(7504);
  2804. return;
  2805. }
  2806. var texValues = skeletonData.textures;
  2807. var texKeys = skeletonData.textureNames;
  2808. if (!(texValues && texValues.length > 0 && texKeys && texKeys.length > 0)) {
  2809. cc.errorID(7507, skeletonData.name);
  2810. return;
  2811. }
  2812. if (this._nativeSkeleton) {
  2813. this._nativeSkeleton.stopSchedule();
  2814. this._nativeSkeleton._comp = null;
  2815. this._nativeSkeleton = null;
  2816. }
  2817. var nativeSkeleton = null;
  2818. if (this.isAnimationCached()) {
  2819. nativeSkeleton = new spine.SkeletonCacheAnimation(uuid, this._cacheMode == AnimationCacheMode.SHARED_CACHE);
  2820. } else {
  2821. nativeSkeleton = new spine.SkeletonAnimation();
  2822. try {
  2823. spine.initSkeletonRenderer(nativeSkeleton, uuid);
  2824. } catch (e) {
  2825. cc._throw(e);
  2826. return;
  2827. }
  2828. nativeSkeleton.setDebugSlotsEnabled(this.debugSlots);
  2829. nativeSkeleton.setDebugMeshEnabled(this.debugMesh);
  2830. nativeSkeleton.setDebugBonesEnabled(this.debugBones);
  2831. }
  2832. this._nativeSkeleton = nativeSkeleton;
  2833. nativeSkeleton._comp = this;
  2834. nativeSkeleton.setUseTint(this.useTint);
  2835. nativeSkeleton.setOpacityModifyRGB(this.premultipliedAlpha);
  2836. nativeSkeleton.setTimeScale(this.timeScale);
  2837. nativeSkeleton.setBatchEnabled(this.enableBatch);
  2838. nativeSkeleton.bindNodeProxy(this.node._proxy);
  2839. nativeSkeleton.setColor(this.node.color);
  2840. this._skeleton = nativeSkeleton.getSkeleton(); // init skeleton listener
  2841. this._startListener && this.setStartListener(this._startListener);
  2842. this._endListener && this.setEndListener(this._endListener);
  2843. this._completeListener && this.setCompleteListener(this._completeListener);
  2844. this._eventListener && this.setEventListener(this._eventListener);
  2845. this._interruptListener && this.setInterruptListener(this._interruptListener);
  2846. this._disposeListener && this.setDisposeListener(this._disposeListener);
  2847. this._updateMaterial();
  2848. this.markForRender(true);
  2849. };
  2850. skeleton._updateColor = function () {
  2851. if (this._nativeSkeleton) {
  2852. this._nativeSkeleton.setColor(this.node.color);
  2853. }
  2854. };
  2855. skeleton.setAnimationStateData = function (stateData) {
  2856. if (this._nativeSkeleton && !this.isAnimationCached()) {
  2857. this._stateData = stateData;
  2858. return this._nativeSkeleton.setAnimationStateData(stateData);
  2859. }
  2860. };
  2861. skeleton.onEnable = function () {
  2862. renderCompProto.onEnable.call(this);
  2863. if (this._nativeSkeleton) {
  2864. this._nativeSkeleton.onEnable();
  2865. }
  2866. };
  2867. skeleton.onDisable = function () {
  2868. renderCompProto.onDisable.call(this);
  2869. if (this._nativeSkeleton) {
  2870. this._nativeSkeleton.onDisable();
  2871. }
  2872. };
  2873. skeleton.setVertexEffectDelegate = function (effectDelegate) {
  2874. if (this._nativeSkeleton && !this.isAnimationCached()) {
  2875. this._nativeSkeleton.setVertexEffectDelegate(effectDelegate);
  2876. }
  2877. };
  2878. skeleton.update = function () {
  2879. var nativeSkeleton = this._nativeSkeleton;
  2880. if (!nativeSkeleton) return;
  2881. var node = this.node;
  2882. if (!node) return;
  2883. if (!this.isAnimationCached() && (this.debugBones || this.debugSlots || this.debugMesh) && this._debugRenderer) {
  2884. var graphics = this._debugRenderer;
  2885. graphics.clear();
  2886. graphics.lineWidth = 2;
  2887. var debugData = this._debugData || nativeSkeleton.getDebugData();
  2888. if (!debugData) return;
  2889. var debugIdx = 0,
  2890. debugType = 0,
  2891. debugLen = 0;
  2892. while (true) {
  2893. debugType = debugData[debugIdx++];
  2894. if (debugType == 0) break;
  2895. debugLen = debugData[debugIdx++];
  2896. switch (debugType) {
  2897. case 1:
  2898. // slots
  2899. graphics.strokeColor = _slotColor;
  2900. for (var i = 0; i < debugLen; i += 8) {
  2901. graphics.moveTo(debugData[debugIdx++], debugData[debugIdx++]);
  2902. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  2903. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  2904. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  2905. graphics.close();
  2906. graphics.stroke();
  2907. }
  2908. break;
  2909. case 2:
  2910. // mesh
  2911. graphics.strokeColor = _meshColor;
  2912. for (var _i = 0; _i < debugLen; _i += 6) {
  2913. graphics.moveTo(debugData[debugIdx++], debugData[debugIdx++]);
  2914. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  2915. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  2916. graphics.close();
  2917. graphics.stroke();
  2918. }
  2919. break;
  2920. case 3:
  2921. // bones
  2922. graphics.strokeColor = _boneColor;
  2923. graphics.fillColor = _slotColor; // Root bone color is same as slot color.
  2924. for (var _i2 = 0; _i2 < debugLen; _i2 += 4) {
  2925. var bx = debugData[debugIdx++];
  2926. var by = debugData[debugIdx++];
  2927. var x = debugData[debugIdx++];
  2928. var y = debugData[debugIdx++]; // Bone lengths.
  2929. graphics.moveTo(bx, by);
  2930. graphics.lineTo(x, y);
  2931. graphics.stroke(); // Bone origins.
  2932. graphics.circle(bx, by, Math.PI * 1.5);
  2933. graphics.fill();
  2934. if (_i2 === 0) {
  2935. graphics.fillColor = _originColor;
  2936. }
  2937. }
  2938. break;
  2939. default:
  2940. return;
  2941. }
  2942. }
  2943. }
  2944. };
  2945. skeleton.updateWorldTransform = function () {
  2946. if (this._nativeSkeleton && !this.isAnimationCached()) {
  2947. this._nativeSkeleton.updateWorldTransform();
  2948. }
  2949. };
  2950. skeleton.setToSetupPose = function () {
  2951. if (this._nativeSkeleton) {
  2952. this._nativeSkeleton.setToSetupPose();
  2953. }
  2954. };
  2955. skeleton.setBonesToSetupPose = function () {
  2956. if (this._nativeSkeleton) {
  2957. this._nativeSkeleton.setBonesToSetupPose();
  2958. }
  2959. };
  2960. skeleton.setSlotsToSetupPose = function () {
  2961. if (this._nativeSkeleton) {
  2962. this._nativeSkeleton.setSlotsToSetupPose();
  2963. }
  2964. };
  2965. skeleton.setSlotsRange = function (startSlotIndex, endSlotIndex) {
  2966. if (this._nativeSkeleton && !this.isAnimationCached()) {
  2967. this._nativeSkeleton.setSlotsRange(startSlotIndex, endSlotIndex);
  2968. }
  2969. };
  2970. skeleton.updateAnimationCache = function (animName) {
  2971. if (!this.isAnimationCached()) return;
  2972. if (this._nativeSkeleton) {
  2973. if (animName) {
  2974. this._nativeSkeleton.updateAnimationCache(animName);
  2975. } else {
  2976. this._nativeSkeleton.updateAllAnimationCache();
  2977. }
  2978. }
  2979. };
  2980. skeleton.invalidAnimationCache = function () {
  2981. if (!this.isAnimationCached()) return;
  2982. if (this._nativeSkeleton) {
  2983. this._nativeSkeleton.updateAllAnimationCache();
  2984. }
  2985. };
  2986. skeleton.findBone = function (boneName) {
  2987. if (this._nativeSkeleton) return this._nativeSkeleton.findBone(boneName);
  2988. return null;
  2989. };
  2990. skeleton.findSlot = function (slotName) {
  2991. if (this._nativeSkeleton) return this._nativeSkeleton.findSlot(slotName);
  2992. return null;
  2993. };
  2994. skeleton.setSkin = function (skinName) {
  2995. if (this._nativeSkeleton) return this._nativeSkeleton.setSkin(skinName);
  2996. return null;
  2997. };
  2998. skeleton.getAttachment = function (slotName, attachmentName) {
  2999. if (this._nativeSkeleton) return this._nativeSkeleton.getAttachment(slotName, attachmentName);
  3000. return null;
  3001. };
  3002. skeleton.setAttachment = function (slotName, attachmentName) {
  3003. this._nativeSkeleton && this._nativeSkeleton.setAttachment(slotName, attachmentName);
  3004. };
  3005. skeleton.getTextureAtlas = function (regionAttachment) {
  3006. cc.warn("sp.Skeleton getTextureAtlas not support in native");
  3007. return null;
  3008. };
  3009. skeleton.setMix = function (fromAnimation, toAnimation, duration) {
  3010. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3011. this._nativeSkeleton.setMix(fromAnimation, toAnimation, duration);
  3012. }
  3013. };
  3014. skeleton.setAnimation = function (trackIndex, name, loop) {
  3015. if (this._nativeSkeleton) {
  3016. if (this.isAnimationCached()) {
  3017. return this._nativeSkeleton.setAnimation(name, loop);
  3018. } else {
  3019. return this._nativeSkeleton.setAnimation(trackIndex, name, loop);
  3020. }
  3021. }
  3022. return null;
  3023. };
  3024. skeleton.addAnimation = function (trackIndex, name, loop, delay) {
  3025. if (this._nativeSkeleton) {
  3026. delay = delay || 0;
  3027. if (this.isAnimationCached()) {
  3028. return this._nativeSkeleton.addAnimation(name, loop, delay);
  3029. } else {
  3030. return this._nativeSkeleton.addAnimation(trackIndex, name, loop, delay);
  3031. }
  3032. }
  3033. return null;
  3034. };
  3035. skeleton.findAnimation = function (name) {
  3036. if (this._nativeSkeleton) return this._nativeSkeleton.findAnimation(name);
  3037. return null;
  3038. };
  3039. skeleton.getCurrent = function (trackIndex) {
  3040. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3041. return this._nativeSkeleton.getCurrent(trackIndex);
  3042. }
  3043. return null;
  3044. };
  3045. skeleton.clearTracks = function () {
  3046. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3047. this._nativeSkeleton.clearTracks();
  3048. }
  3049. };
  3050. skeleton.clearTrack = function (trackIndex) {
  3051. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3052. this._nativeSkeleton.clearTrack(trackIndex);
  3053. }
  3054. };
  3055. skeleton.setStartListener = function (listener) {
  3056. this._startListener = listener;
  3057. if (this._nativeSkeleton) {
  3058. if (this.isAnimationCached()) {
  3059. this._nativeSkeleton.setStartListener(function (animationName) {
  3060. var self = this._comp;
  3061. self._startEntry.animation.name = animationName;
  3062. self._startListener && self._startListener(self._startEntry);
  3063. });
  3064. } else {
  3065. this._nativeSkeleton.setStartListener(listener);
  3066. }
  3067. }
  3068. };
  3069. skeleton.setInterruptListener = function (listener) {
  3070. this._interruptListener = listener;
  3071. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3072. this._nativeSkeleton.setInterruptListener(listener);
  3073. }
  3074. };
  3075. skeleton.setEndListener = function (listener) {
  3076. this._endListener = listener;
  3077. if (this._nativeSkeleton) {
  3078. if (this.isAnimationCached()) {
  3079. this._nativeSkeleton.setEndListener(function (animationName) {
  3080. var self = this._comp;
  3081. self._endEntry.animation.name = animationName;
  3082. self._endListener && self._endListener(self._endEntry);
  3083. });
  3084. } else {
  3085. this._nativeSkeleton.setEndListener(listener);
  3086. }
  3087. }
  3088. };
  3089. skeleton.setDisposeListener = function (listener) {
  3090. this._disposeListener = listener;
  3091. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3092. this._nativeSkeleton.setDisposeListener(listener);
  3093. }
  3094. };
  3095. skeleton.setCompleteListener = function (listener) {
  3096. this._completeListener = listener;
  3097. if (this._nativeSkeleton) {
  3098. if (this.isAnimationCached()) {
  3099. this._nativeSkeleton.setCompleteListener(function (animationName) {
  3100. var self = this._comp;
  3101. self._endEntry.animation.name = animationName;
  3102. self._completeListener && self._completeListener(self._endEntry);
  3103. });
  3104. } else {
  3105. this._nativeSkeleton.setCompleteListener(listener);
  3106. }
  3107. }
  3108. };
  3109. skeleton.setEventListener = function (listener) {
  3110. this._eventListener = listener;
  3111. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3112. this._nativeSkeleton.setEventListener(listener);
  3113. }
  3114. };
  3115. skeleton.setTrackStartListener = function (entry, listener) {
  3116. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3117. this._nativeSkeleton.setTrackStartListener(entry, listener);
  3118. }
  3119. };
  3120. skeleton.setTrackInterruptListener = function (entry, listener) {
  3121. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3122. this._nativeSkeleton.setTrackInterruptListener(entry, listener);
  3123. }
  3124. };
  3125. skeleton.setTrackEndListener = function (entry, listener) {
  3126. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3127. this._nativeSkeleton.setTrackEndListener(entry, listener);
  3128. }
  3129. };
  3130. skeleton.setTrackDisposeListener = function (entry, listener) {
  3131. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3132. this._nativeSkeleton.setTrackDisposeListener(entry, listener);
  3133. }
  3134. };
  3135. skeleton.setTrackCompleteListener = function (entry, listener) {
  3136. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3137. this._nativeSkeleton.setTrackCompleteListener(entry, listener);
  3138. }
  3139. };
  3140. skeleton.setTrackEventListener = function (entry, listener) {
  3141. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3142. this._nativeSkeleton.setTrackEventListener(entry, listener);
  3143. }
  3144. };
  3145. skeleton.getState = function () {
  3146. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3147. return this._nativeSkeleton.getState();
  3148. }
  3149. };
  3150. skeleton._ensureListener = function () {
  3151. cc.warn("sp.Skeleton _ensureListener not need in native");
  3152. };
  3153. skeleton._updateSkeletonData = function () {
  3154. if (this.skeletonData) {
  3155. this.skeletonData.init();
  3156. this.setSkeletonData(this.skeletonData);
  3157. this.attachUtil.init(this);
  3158. this.attachUtil._associateAttachedNode();
  3159. this._preCacheMode = this._cacheMode;
  3160. this.defaultSkin && this._nativeSkeleton.setSkin(this.defaultSkin);
  3161. this.animation = this.defaultAnimation;
  3162. } else {
  3163. if (this._nativeSkeleton) {
  3164. this._nativeSkeleton.stopSchedule();
  3165. this._nativeSkeleton._comp = null;
  3166. this._nativeSkeleton = null;
  3167. }
  3168. }
  3169. };
  3170. var _onDestroy = skeleton.onDestroy;
  3171. skeleton.onDestroy = function () {
  3172. _onDestroy.call(this);
  3173. if (this._nativeSkeleton) {
  3174. this._nativeSkeleton.stopSchedule();
  3175. this._nativeSkeleton._comp = null;
  3176. this._nativeSkeleton = null;
  3177. }
  3178. this._stateData = null;
  3179. this._materialCache = null;
  3180. }; ////////////////////////////////////////////////////////////
  3181. // adapt attach util
  3182. ////////////////////////////////////////////////////////////
  3183. var attachUtilProto = sp.AttachUtil.prototype;
  3184. var _attachUtilInit = attachUtilProto.init;
  3185. attachUtilProto.init = function (skeletonComp) {
  3186. _attachUtilInit.call(this, skeletonComp);
  3187. this._nativeSkeleton = skeletonComp._nativeSkeleton;
  3188. this._attachUtilNative = null;
  3189. };
  3190. var _generateAllAttachedNodes = attachUtilProto.generateAllAttachedNodes;
  3191. attachUtilProto.generateAllAttachedNodes = function () {
  3192. var res = _generateAllAttachedNodes.call(this);
  3193. this._associateAttachedNode();
  3194. return res;
  3195. };
  3196. var _generateAttachedNodes = attachUtilProto.generateAttachedNodes;
  3197. attachUtilProto.generateAttachedNodes = function (boneName) {
  3198. var res = _generateAttachedNodes.call(this, boneName);
  3199. this._associateAttachedNode();
  3200. return res;
  3201. };
  3202. var _associateAttachedNode = attachUtilProto._associateAttachedNode;
  3203. attachUtilProto._associateAttachedNode = function () {
  3204. if (!this._inited) return;
  3205. var rootNode = this._skeletonNode.getChildByName('ATTACHED_NODE_TREE');
  3206. if (!rootNode || !rootNode.isValid) return; // associate js
  3207. _associateAttachedNode.call(this); // associate native
  3208. if (!this._attachUtilNative) {
  3209. if (this._skeletonComp.isAnimationCached()) {
  3210. this._attachUtilNative = new spine.CacheModeAttachUtil();
  3211. } else {
  3212. this._attachUtilNative = new spine.RealTimeAttachUtil();
  3213. }
  3214. this._nativeSkeleton.setAttachUtil(this._attachUtilNative);
  3215. }
  3216. this._attachUtilNative.associateAttachedNode(this._skeleton, this._skeletonNode._proxy);
  3217. };
  3218. })();
  3219. },{"./jsb-cache-manager":29}],41:[function(require,module,exports){
  3220. /****************************************************************************
  3221. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3222. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  3223. http://www.cocos.com
  3224. Permission is hereby granted, free of charge, to any person obtaining a copy
  3225. of this software and associated engine source code (the "Software"), a limited,
  3226. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  3227. to use Cocos Creator solely to develop games on your target platforms. You shall
  3228. not use Cocos Creator software for developing other software or tools that's
  3229. used for developing games. You are not granted to publish, distribute,
  3230. sublicense, and/or sell copies of Cocos Creator.
  3231. The software or tools in this License Agreement are licensed, not sold.
  3232. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  3233. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3234. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3235. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3236. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3237. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3238. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3239. THE SOFTWARE.
  3240. ****************************************************************************/
  3241. 'use strict';
  3242. var sys = cc.sys;
  3243. sys.getNetworkType = jsb.Device.getNetworkType;
  3244. sys.getBatteryLevel = jsb.Device.getBatteryLevel;
  3245. sys.garbageCollect = jsb.garbageCollect;
  3246. sys.restartVM = __restartVM;
  3247. sys.isObjectValid = __isObjectValid;
  3248. sys.getSafeAreaRect = function () {
  3249. // x(top), y(left), z(bottom), w(right)
  3250. var edge = jsb.Device.getSafeAreaEdge();
  3251. var screenSize = cc.view.getFrameSize(); // Get leftBottom and rightTop point in UI coordinates
  3252. var leftBottom = new cc.Vec2(edge.y, screenSize.height - edge.z);
  3253. var rightTop = new cc.Vec2(screenSize.width - edge.w, edge.x); // Returns the real location in view.
  3254. var relatedPos = {
  3255. left: 0,
  3256. top: 0,
  3257. width: screenSize.width,
  3258. height: screenSize.height
  3259. };
  3260. cc.view.convertToLocationInView(leftBottom.x, leftBottom.y, relatedPos, leftBottom);
  3261. cc.view.convertToLocationInView(rightTop.x, rightTop.y, relatedPos, rightTop); // convert view point to design resolution size
  3262. cc.view._convertPointWithScale(leftBottom);
  3263. cc.view._convertPointWithScale(rightTop);
  3264. return cc.rect(leftBottom.x, leftBottom.y, rightTop.x - leftBottom.x, rightTop.y - leftBottom.y);
  3265. };
  3266. },{}],42:[function(require,module,exports){
  3267. "use strict";
  3268. /****************************************************************************
  3269. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  3270. https://www.cocos.com/
  3271. Permission is hereby granted, free of charge, to any person obtaining a copy
  3272. of this software and associated engine source code (the "Software"), a limited,
  3273. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  3274. to use Cocos Creator solely to develop games on your target platforms. You shall
  3275. not use Cocos Creator software for developing other software or tools that's
  3276. used for developing games. You are not granted to publish, distribute,
  3277. sublicense, and/or sell copies of Cocos Creator.
  3278. The software or tools in this License Agreement are licensed, not sold.
  3279. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  3280. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3281. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3282. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3283. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3284. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3285. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3286. THE SOFTWARE.
  3287. ****************************************************************************/
  3288. (function () {
  3289. if (!cc.TiledMap) return;
  3290. var RenderFlow = cc.RenderFlow; // tiled layer
  3291. var TiledLayer = cc.TiledLayer.prototype;
  3292. var _addUserNode = TiledLayer.addUserNode;
  3293. TiledLayer.addUserNode = function (node) {
  3294. var result = _addUserNode.call(this, node);
  3295. if (result) {
  3296. var proxy = node._proxy;
  3297. proxy && proxy.enableVisit(false);
  3298. }
  3299. };
  3300. var _removeUserNode = TiledLayer.removeUserNode;
  3301. TiledLayer.removeUserNode = function (node) {
  3302. var result = _removeUserNode.call(this, node);
  3303. if (result) {
  3304. var proxy = node._proxy;
  3305. proxy && proxy.enableVisit(true);
  3306. }
  3307. }; // override _buildMaterial to upload hash value to native
  3308. var _buildMaterial = TiledLayer._buildMaterial;
  3309. TiledLayer._buildMaterial = function (tilesetIdx) {
  3310. var material = _buildMaterial.call(this, tilesetIdx);
  3311. if (material) material.getHash();
  3312. }; // tiledmap buffer
  3313. var TiledMapBuffer = cc.TiledMapBuffer.prototype;
  3314. TiledMapBuffer._updateOffset = function () {
  3315. var offsetInfo = this._offsetInfo;
  3316. offsetInfo.vertexOffset = this.vertexOffset;
  3317. offsetInfo.indiceOffset = this.indiceOffset;
  3318. offsetInfo.byteOffset = this.byteOffset;
  3319. }; // tiledmap render data list
  3320. var TiledMapRenderDataList = cc.TiledMapRenderDataList.prototype;
  3321. TiledMapRenderDataList._pushRenderData = function () {
  3322. var renderData = {};
  3323. renderData.ia = {};
  3324. renderData.nodesRenderList = [];
  3325. this._dataList.push(renderData);
  3326. };
  3327. TiledMapRenderDataList.reset = function () {
  3328. this._offset = 0;
  3329. var assembler = this._nativeAssembler;
  3330. assembler._effect.length = 0;
  3331. assembler.reset();
  3332. };
  3333. TiledMapRenderDataList.setNativeAssembler = function (assembler) {
  3334. this._nativeAssembler = assembler;
  3335. };
  3336. TiledMapRenderDataList.popRenderData = function (buffer) {
  3337. if (this._offset >= this._dataList.length) {
  3338. this._pushRenderData();
  3339. }
  3340. var renderData = this._dataList[this._offset];
  3341. renderData.nodesRenderList.length = 0;
  3342. this._nativeAssembler.clearNodes(this._offset);
  3343. var ia = renderData.ia;
  3344. ia._meshIndex = buffer.getCurMeshIndex();
  3345. ia._start = buffer.indiceOffset;
  3346. ia._count = 0;
  3347. ia._verticesStart = buffer.vertexOffset;
  3348. ia._index = this._offset;
  3349. this._offset++;
  3350. return renderData;
  3351. };
  3352. TiledMapRenderDataList.pushNodesList = function (renderData, nodesList) {
  3353. var nodesRenderList = renderData.nodesRenderList;
  3354. nodesRenderList.push(nodesList);
  3355. var nativeNodes = [];
  3356. for (var j = 0; j < nodesRenderList.length; j++) {
  3357. var _nodesList = nodesRenderList[j];
  3358. if (!_nodesList) continue;
  3359. for (var idx = 0; idx < _nodesList.length; idx++) {
  3360. var dataComp = _nodesList[idx];
  3361. if (!dataComp) continue;
  3362. nativeNodes.push(dataComp.node._id);
  3363. }
  3364. }
  3365. this._nativeAssembler.updateNodes(renderData.ia._index, nativeNodes);
  3366. };
  3367. var ModelBatcherDelegate = cc.Class({
  3368. ctor: function ctor() {
  3369. this._nativeAssembler = null;
  3370. },
  3371. setNativeAssembler: function setNativeAssembler(assembler) {
  3372. this._nativeAssembler = assembler;
  3373. },
  3374. setBuffer: function setBuffer(buffer) {
  3375. this._buffer = buffer;
  3376. },
  3377. _flushIA: function _flushIA(ia) {
  3378. var iaIndex = ia._index;
  3379. var meshIndex = ia._meshIndex;
  3380. this._nativeAssembler.updateMeshIndex(iaIndex, meshIndex);
  3381. var verticesStart = ia._verticesStart;
  3382. var verticesOffset = this._buffer.vertexOffset;
  3383. var vertexCount = verticesOffset - verticesStart;
  3384. this._nativeAssembler.updateVerticesRange(iaIndex, verticesStart, vertexCount);
  3385. this._nativeAssembler.updateIndicesRange(iaIndex, ia._start, ia._count);
  3386. this._nativeAssembler.updateMaterial(iaIndex, this.material);
  3387. },
  3388. _flush: function _flush() {}
  3389. });
  3390. var TiledMapAssembler = cc.TiledLayer.__assembler__.prototype;
  3391. var _fillBuffers = TiledMapAssembler.fillBuffers;
  3392. cc.js.mixin(TiledMapAssembler, {
  3393. _extendNative: function _extendNative() {
  3394. renderer.TiledMapAssembler.prototype.ctor.call(this);
  3395. },
  3396. // override _updateRenderData function avoid base class cover material
  3397. _updateRenderData: function _updateRenderData() {
  3398. if (!this._renderComp || !this._renderComp.isValid) return;
  3399. this.updateRenderData(this._renderComp);
  3400. },
  3401. updateRenderData: function updateRenderData(comp) {
  3402. if (!comp._modelBatcherDelegate) {
  3403. comp._buffer = new cc.TiledMapBuffer(null, cc.gfx.VertexFormat.XY_UV_Color);
  3404. comp._renderDataList = new cc.TiledMapRenderDataList();
  3405. comp._modelBatcherDelegate = new ModelBatcherDelegate();
  3406. comp._buffer.setNativeAssembler(this);
  3407. comp._renderDataList.setNativeAssembler(this);
  3408. comp._modelBatcherDelegate.setBuffer(comp._buffer);
  3409. comp._modelBatcherDelegate.setNativeAssembler(this);
  3410. }
  3411. _fillBuffers.call(this, comp, comp._modelBatcherDelegate);
  3412. comp.node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA;
  3413. }
  3414. }, renderer.TiledMapAssembler.prototype);
  3415. })();
  3416. },{}],43:[function(require,module,exports){
  3417. "use strict";
  3418. /****************************************************************************
  3419. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  3420. https://www.cocos.com/
  3421. Permission is hereby granted, free of charge, to any person obtaining a copy
  3422. of this software and associated engine source code (the "Software"), a limited,
  3423. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  3424. to use Cocos Creator solely to develop games on your target platforms. You shall
  3425. not use Cocos Creator software for developing other software or tools that's
  3426. used for developing games. You are not granted to publish, distribute,
  3427. sublicense, and/or sell copies of Cocos Creator.
  3428. The software or tools in this License Agreement are licensed, not sold.
  3429. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  3430. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3431. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3432. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3433. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3434. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3435. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3436. THE SOFTWARE.
  3437. ****************************************************************************/
  3438. (function () {
  3439. if (!(cc && cc.VideoPlayer && cc.VideoPlayer.Impl)) {
  3440. return;
  3441. }
  3442. var vec3 = cc.Vec3;
  3443. var _worldMat = new cc.Mat4();
  3444. var _topLeft = new vec3();
  3445. var _bottomRight = new vec3();
  3446. var _impl = cc.VideoPlayer.Impl;
  3447. var _p = cc.VideoPlayer.Impl.prototype;
  3448. _p._bindEvent = function () {
  3449. var video = this._video,
  3450. self = this;
  3451. if (!video) {
  3452. return;
  3453. } //binding event
  3454. var cbs = this.__eventListeners;
  3455. cbs.loadedmetadata = function () {
  3456. self._loadedmeta = true;
  3457. self._dispatchEvent(_impl.EventType.META_LOADED);
  3458. if (self._playing) {
  3459. self._video.play();
  3460. }
  3461. };
  3462. cbs.ended = function () {
  3463. if (self._video !== video) return;
  3464. self._playing = false;
  3465. self._dispatchEvent(_impl.EventType.COMPLETED);
  3466. };
  3467. cbs.play = function () {
  3468. if (self._video !== video) return;
  3469. self._playing = true;
  3470. self._dispatchEvent(_impl.EventType.PLAYING);
  3471. };
  3472. cbs.pause = function () {
  3473. if (self._ignorePause || self._video !== video) return;
  3474. self._playing = false;
  3475. self._dispatchEvent(_impl.EventType.PAUSED);
  3476. };
  3477. cbs.click = function () {
  3478. self._dispatchEvent(_impl.EventType.CLICKED);
  3479. };
  3480. cbs.stoped = function () {
  3481. self._dispatchEvent(_impl.EventType.STOPPED);
  3482. self._ignorePause = false;
  3483. };
  3484. video.addEventListener("loadedmetadata", cbs.loadedmetadata);
  3485. video.addEventListener("ended", cbs.ended);
  3486. video.addEventListener("play", cbs.play);
  3487. video.addEventListener("pause", cbs.pause);
  3488. video.addEventListener("click", cbs.click);
  3489. video.addEventListener("stoped", cbs.stoped);
  3490. function onCanPlay() {
  3491. if (this._loaded) return;
  3492. this._loaded = true;
  3493. this._dispatchEvent(_impl.EventType.READY_TO_PLAY);
  3494. this._updateVisibility();
  3495. }
  3496. cbs.onCanPlay = onCanPlay.bind(this);
  3497. video.addEventListener('canplay', cbs.onCanPlay);
  3498. video.addEventListener('canplaythrough', cbs.onCanPlay);
  3499. video.addEventListener('suspend', cbs.onCanPlay);
  3500. };
  3501. _p._updateVisibility = function () {
  3502. if (!this._video) return;
  3503. var video = this._video;
  3504. if (this._visible) {
  3505. this._video.setVisible(true);
  3506. } else {
  3507. this._video.setVisible(false);
  3508. video.pause();
  3509. this._playing = false;
  3510. }
  3511. };
  3512. _p._updateSize = function (width, height) {};
  3513. _p.createDomElementIfNeeded = function () {
  3514. if (!jsb.VideoPlayer) {
  3515. cc.warn('VideoPlayer is not supported.');
  3516. return null;
  3517. }
  3518. if (!this._video) {
  3519. this._video = new jsb.VideoPlayer();
  3520. }
  3521. };
  3522. _p.removeDom = function () {
  3523. var video = this._video;
  3524. if (video) {
  3525. video.stop();
  3526. video.setVisible(false);
  3527. var cbs = this.__eventListeners;
  3528. cbs.loadedmetadata = null;
  3529. cbs.ended = null;
  3530. cbs.play = null;
  3531. cbs.pause = null;
  3532. cbs.click = null;
  3533. cbs.onCanPlay = null;
  3534. video.destroy();
  3535. }
  3536. this._video = null;
  3537. this._url = "";
  3538. };
  3539. _p.setURL = function (path) {
  3540. var source, extname;
  3541. if (this._url === path) {
  3542. return;
  3543. }
  3544. this.removeDom();
  3545. this._url = path;
  3546. this.createDomElementIfNeeded();
  3547. this._bindEvent();
  3548. var video = this._video;
  3549. if (!video) {
  3550. return;
  3551. }
  3552. video.setVisible(this._visible);
  3553. this._loaded = false;
  3554. this._played = false;
  3555. this._playing = false;
  3556. this._loadedmeta = false;
  3557. video.setURL(this._url);
  3558. this._forceUpdate = true;
  3559. };
  3560. _p.getURL = function () {
  3561. return this._url;
  3562. };
  3563. _p.play = function () {
  3564. var video = this._video;
  3565. if (!video || !this._visible || this._playing) return;
  3566. video.play();
  3567. this._playing = true;
  3568. };
  3569. _p.setStayOnBottom = function (enabled) {};
  3570. _p.pause = function () {
  3571. var video = this._video;
  3572. if (!this._playing || !video) return;
  3573. video.pause();
  3574. this._playing = false;
  3575. };
  3576. _p.resume = function () {
  3577. var video = this._video;
  3578. if (this._playing || !video) return;
  3579. video.resume();
  3580. this._playing = true;
  3581. };
  3582. _p.stop = function () {
  3583. var video = this._video;
  3584. if (!video || !this._visible) return;
  3585. this._ignorePause = true;
  3586. video.stop();
  3587. this._playing = false;
  3588. };
  3589. _p.setVolume = function (volume) {};
  3590. _p.seekTo = function (time) {
  3591. var video = this._video;
  3592. if (!video) return;
  3593. if (this._loaded) {
  3594. video.seekTo(time);
  3595. } else {
  3596. var cb = function cb() {
  3597. video.seekTo(time);
  3598. };
  3599. video.addEventListener(_impl._polyfill.event, cb);
  3600. }
  3601. };
  3602. _p.isPlaying = function () {
  3603. return this._playing;
  3604. };
  3605. _p.duration = function () {
  3606. var video = this._video;
  3607. var duration = -1;
  3608. if (!video) return duration;
  3609. duration = video.duration();
  3610. if (duration <= 0) {
  3611. cc.logID(7702);
  3612. }
  3613. return duration;
  3614. };
  3615. _p.currentTime = function () {
  3616. var video = this._video;
  3617. if (!video) return -1;
  3618. return video.currentTime();
  3619. };
  3620. _p.setKeepAspectRatioEnabled = function (isEnabled) {
  3621. if (!this._video) {
  3622. return false;
  3623. }
  3624. return this._video.setKeepAspectRatioEnabled(isEnabled);
  3625. };
  3626. _p.isKeepAspectRatioEnabled = function () {
  3627. if (!this._video) {
  3628. return false;
  3629. }
  3630. return this._video.isKeepAspectRatioEnabled();
  3631. };
  3632. _p.isFullScreenEnabled = function () {
  3633. return this._fullScreenEnabled;
  3634. };
  3635. _p.setEventListener = function (event, callback) {
  3636. this._EventList[event] = callback;
  3637. };
  3638. _p.removeEventListener = function (event) {
  3639. this._EventList[event] = null;
  3640. };
  3641. _p._dispatchEvent = function (event) {
  3642. var callback = this._EventList[event];
  3643. if (callback) callback.call(this, this, this._video.src);
  3644. };
  3645. _p.onPlayEvent = function () {
  3646. var callback = this._EventList[_impl.EventType.PLAYING];
  3647. callback.call(this, this, this._video.src);
  3648. };
  3649. _p.enable = function () {
  3650. var list = _impl.elements;
  3651. if (list.indexOf(this) === -1) list.push(this);
  3652. this.setVisible(true);
  3653. };
  3654. _p.disable = function () {
  3655. var list = _impl.elements;
  3656. var index = list.indexOf(this);
  3657. if (index !== -1) list.splice(index, 1);
  3658. this.setVisible(false);
  3659. };
  3660. _p.destroy = function () {
  3661. this.disable();
  3662. this.removeDom();
  3663. };
  3664. _p.setVisible = function (visible) {
  3665. if (this._visible !== visible) {
  3666. this._visible = !!visible;
  3667. this._updateVisibility();
  3668. }
  3669. };
  3670. _p.setFullScreenEnabled = function (enable) {
  3671. var video = this._video;
  3672. if (!video) {
  3673. return;
  3674. }
  3675. this._fullScreenEnabled = enable;
  3676. video.setFullScreenEnabled(enable);
  3677. };
  3678. _p.updateMatrix = function (node) {
  3679. if (!this._video || !this._visible) return;
  3680. var camera = cc.Camera.findCamera(node)._camera;
  3681. if (!camera) {
  3682. return;
  3683. }
  3684. node.getWorldMatrix(_worldMat);
  3685. if (!this._forceUpdate && this._m00 === _worldMat.m[0] && this._m01 === _worldMat.m[1] && this._m04 === _worldMat.m[4] && this._m05 === _worldMat.m[5] && this._m12 === _worldMat.m[12] && this._m13 === _worldMat.m[13] && this._w === node._contentSize.width && this._h === node._contentSize.height) {
  3686. return;
  3687. } // update matrix cache
  3688. this._m00 = _worldMat.m[0];
  3689. this._m01 = _worldMat.m[1];
  3690. this._m04 = _worldMat.m[4];
  3691. this._m05 = _worldMat.m[5];
  3692. this._m12 = _worldMat.m[12];
  3693. this._m13 = _worldMat.m[13];
  3694. this._w = node._contentSize.width;
  3695. this._h = node._contentSize.height;
  3696. var canvas_width = cc.game.canvas.width;
  3697. var canvas_height = cc.game.canvas.height;
  3698. var ap = node._anchorPoint; // Vectors in node space
  3699. vec3.set(_topLeft, -ap.x * this._w, (1.0 - ap.y) * this._h, 0);
  3700. vec3.set(_bottomRight, (1 - ap.x) * this._w, -ap.y * this._h, 0); // Convert to world space
  3701. vec3.transformMat4(_topLeft, _topLeft, _worldMat);
  3702. vec3.transformMat4(_bottomRight, _bottomRight, _worldMat); // Convert to Screen space
  3703. camera.worldToScreen(_topLeft, _topLeft, canvas_width, canvas_height);
  3704. camera.worldToScreen(_bottomRight, _bottomRight, canvas_width, canvas_height);
  3705. var finalWidth = _bottomRight.x - _topLeft.x;
  3706. var finalHeight = _topLeft.y - _bottomRight.y;
  3707. this._video.setFrame(_topLeft.x, canvas_height - _topLeft.y, finalWidth, finalHeight);
  3708. };
  3709. _impl.EventType = {
  3710. PLAYING: 0,
  3711. PAUSED: 1,
  3712. STOPPED: 2,
  3713. COMPLETED: 3,
  3714. META_LOADED: 4,
  3715. CLICKED: 5,
  3716. READY_TO_PLAY: 6
  3717. }; // video 队列,所有 vidoe 在 onEnter 的时候都会插入这个队列
  3718. _impl.elements = []; // video 在 game_hide 事件中被自动暂停的队列,用于回复的时候重新开始播放
  3719. _impl.pauseElements = [];
  3720. cc.game.on(cc.game.EVENT_HIDE, function () {
  3721. var list = _impl.elements;
  3722. for (var element, i = 0; i < list.length; i++) {
  3723. element = list[i];
  3724. if (element.isPlaying()) {
  3725. element.pause();
  3726. _impl.pauseElements.push(element);
  3727. }
  3728. }
  3729. });
  3730. cc.game.on(cc.game.EVENT_SHOW, function () {
  3731. var list = _impl.pauseElements;
  3732. var element = list.pop();
  3733. while (element) {
  3734. element.play();
  3735. element = list.pop();
  3736. }
  3737. });
  3738. })();
  3739. },{}],44:[function(require,module,exports){
  3740. "use strict";
  3741. /****************************************************************************
  3742. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  3743. https://www.cocos.com/
  3744. Permission is hereby granted, free of charge, to any person obtaining a copy
  3745. of this software and associated engine source code (the "Software"), a limited,
  3746. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  3747. to use Cocos Creator solely to develop games on your target platforms. You shall
  3748. not use Cocos Creator software for developing other software or tools that's
  3749. used for developing games. You are not granted to publish, distribute,
  3750. sublicense, and/or sell copies of Cocos Creator.
  3751. The software or tools in this License Agreement are licensed, not sold.
  3752. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  3753. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3754. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3755. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3756. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3757. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3758. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3759. THE SOFTWARE.
  3760. ****************************************************************************/
  3761. (function () {
  3762. if (!(cc && cc.WebView && cc.WebView.Impl)) {
  3763. return;
  3764. }
  3765. var vec3 = cc.Vec3;
  3766. var _worldMat = new cc.Mat4();
  3767. var _topLeft = new vec3();
  3768. var _bottomRight = new vec3();
  3769. cc.WebView.Impl = cc.Class({
  3770. "extends": cc.WebView.Impl,
  3771. ctor: function ctor() {
  3772. // keep webview data
  3773. this.jsCallback = null;
  3774. this.interfaceSchema = null;
  3775. }
  3776. });
  3777. var _impl = cc.WebView.Impl;
  3778. var _p = cc.WebView.Impl.prototype;
  3779. _p._updateVisibility = function () {
  3780. if (!this._iframe) return;
  3781. this._iframe.setVisible(this._visible);
  3782. };
  3783. _p._updateSize = function (w, h) {};
  3784. _p._initEvent = function () {
  3785. var iframe = this._iframe;
  3786. if (iframe) {
  3787. var cbs = this.__eventListeners,
  3788. self = this;
  3789. cbs.load = function () {
  3790. self._dispatchEvent(_impl.EventType.LOADED);
  3791. };
  3792. cbs.error = function () {
  3793. self._dispatchEvent(_impl.EventType.ERROR);
  3794. }; // native event callback
  3795. this._iframe.setOnDidFinishLoading(cbs.load);
  3796. this._iframe.setOnDidFailLoading(cbs.error);
  3797. }
  3798. };
  3799. _p._initExtraSetting = function () {
  3800. this.jsCallback && this.setOnJSCallback(this.jsCallback);
  3801. this.interfaceSchema && this.setJavascriptInterfaceScheme(this.interfaceSchema); // remove obj
  3802. this.jsCallback = null;
  3803. this.interfaceSchema = null;
  3804. };
  3805. _p._setOpacity = function (opacity) {
  3806. var iframe = this._iframe;
  3807. if (iframe && iframe.style) {
  3808. iframe.style.opacity = opacity / 255; // TODO, add impl to Native
  3809. }
  3810. };
  3811. _p.createDomElementIfNeeded = function (w, h) {
  3812. if (!jsb.WebView) {
  3813. cc.warn('WebView only supports mobile platform.');
  3814. return;
  3815. }
  3816. if (!this._iframe) {
  3817. this._iframe = jsb.WebView.create();
  3818. this._initEvent();
  3819. this._initExtraSetting();
  3820. }
  3821. };
  3822. _p.removeDom = function () {
  3823. var iframe = this._iframe;
  3824. if (iframe) {
  3825. var cbs = this.__eventListeners;
  3826. cbs.load = null;
  3827. cbs.error = null;
  3828. iframe.destroy();
  3829. this._iframe = null;
  3830. }
  3831. };
  3832. _p.setOnJSCallback = function (callback) {
  3833. var iframe = this._iframe;
  3834. if (iframe) {
  3835. iframe.setOnJSCallback(callback);
  3836. } else {
  3837. this.jsCallback = callback;
  3838. }
  3839. };
  3840. _p.setJavascriptInterfaceScheme = function (scheme) {
  3841. var iframe = this._iframe;
  3842. if (iframe) {
  3843. iframe.setJavascriptInterfaceScheme(scheme);
  3844. } else {
  3845. this.interfaceSchema = scheme;
  3846. }
  3847. };
  3848. _p.loadData = function (data, MIMEType, encoding, baseURL) {
  3849. var iframe = this._iframe;
  3850. if (iframe) {
  3851. iframe.loadData(data, MIMEType, encoding, baseURL);
  3852. }
  3853. };
  3854. _p.loadHTMLString = function (string, baseURL) {
  3855. var iframe = this._iframe;
  3856. if (iframe) {
  3857. iframe.loadHTMLString(string, baseURL);
  3858. }
  3859. };
  3860. /**
  3861. * Load an URL
  3862. * @param {String} url
  3863. */
  3864. _p.loadURL = function (url) {
  3865. var iframe = this._iframe;
  3866. if (iframe) {
  3867. iframe.src = url;
  3868. iframe.loadURL(url);
  3869. this._dispatchEvent(_impl.EventType.LOADING);
  3870. }
  3871. };
  3872. /**
  3873. * Stop loading
  3874. */
  3875. _p.stopLoading = function () {
  3876. cc.logID(7800);
  3877. };
  3878. /**
  3879. * Reload the WebView
  3880. */
  3881. _p.reload = function () {
  3882. var iframe = this._iframe;
  3883. if (iframe) {
  3884. iframe.reload();
  3885. }
  3886. };
  3887. /**
  3888. * Determine whether to go back
  3889. */
  3890. _p.canGoBack = function () {
  3891. var iframe = this._iframe;
  3892. if (iframe) {
  3893. return iframe.canGoBack();
  3894. }
  3895. };
  3896. /**
  3897. * Determine whether to go forward
  3898. */
  3899. _p.canGoForward = function () {
  3900. var iframe = this._iframe;
  3901. if (iframe) {
  3902. return iframe.canGoForward();
  3903. }
  3904. };
  3905. /**
  3906. * go back
  3907. */
  3908. _p.goBack = function () {
  3909. var iframe = this._iframe;
  3910. if (iframe) {
  3911. return iframe.goBack();
  3912. }
  3913. };
  3914. /**
  3915. * go forward
  3916. */
  3917. _p.goForward = function () {
  3918. var iframe = this._iframe;
  3919. if (iframe) {
  3920. return iframe.goForward();
  3921. }
  3922. };
  3923. /**
  3924. * In the webview execution within a period of js string
  3925. * @param {String} str
  3926. */
  3927. _p.evaluateJS = function (str) {
  3928. var iframe = this._iframe;
  3929. if (iframe) {
  3930. return iframe.evaluateJS(str);
  3931. }
  3932. };
  3933. /**
  3934. * Limited scale
  3935. */
  3936. _p.setScalesPageToFit = function () {
  3937. var iframe = this._iframe;
  3938. if (iframe) {
  3939. return iframe.setScalesPageToFit();
  3940. }
  3941. };
  3942. /**
  3943. * The binding event
  3944. * @param {_impl.EventType} event
  3945. * @param {Function} callback
  3946. */
  3947. _p.setEventListener = function (event, callback) {
  3948. this._EventList[event] = callback;
  3949. };
  3950. /**
  3951. * Delete events
  3952. * @param {_impl.EventType} event
  3953. */
  3954. _p.removeEventListener = function (event) {
  3955. this._EventList[event] = null;
  3956. };
  3957. _p._dispatchEvent = function (event) {
  3958. var callback = this._EventList[event];
  3959. if (callback) callback.call(this, this, this._iframe.src);
  3960. };
  3961. _p._createRenderCmd = function () {
  3962. return new _impl.RenderCmd(this);
  3963. };
  3964. _p.destroy = function () {
  3965. this.removeDom();
  3966. };
  3967. _p.setVisible = function (visible) {
  3968. if (this._visible !== visible) {
  3969. this._visible = !!visible;
  3970. this._updateVisibility();
  3971. }
  3972. };
  3973. _p.updateMatrix = function (node) {
  3974. if (!this._iframe || !this._visible) return;
  3975. var camera = cc.Camera.findCamera(node)._camera;
  3976. if (!camera) {
  3977. return;
  3978. }
  3979. node.getWorldMatrix(_worldMat);
  3980. if (this._m00 === _worldMat.m[0] && this._m01 === _worldMat.m[1] && this._m04 === _worldMat.m[4] && this._m05 === _worldMat.m[5] && this._m12 === _worldMat.m[12] && this._m13 === _worldMat.m[13] && this._w === node._contentSize.width && this._h === node._contentSize.height) {
  3981. return;
  3982. } // update matrix cache
  3983. this._m00 = _worldMat.m[0];
  3984. this._m01 = _worldMat.m[1];
  3985. this._m04 = _worldMat.m[4];
  3986. this._m05 = _worldMat.m[5];
  3987. this._m12 = _worldMat.m[12];
  3988. this._m13 = _worldMat.m[13];
  3989. this._w = node._contentSize.width;
  3990. this._h = node._contentSize.height;
  3991. var canvas_width = cc.game.canvas.width;
  3992. var canvas_height = cc.game.canvas.height;
  3993. var ap = node._anchorPoint; // Vectors in node space
  3994. vec3.set(_topLeft, -ap.x * this._w, (1.0 - ap.y) * this._h, 0);
  3995. vec3.set(_bottomRight, (1 - ap.x) * this._w, -ap.y * this._h, 0); // Convert to world space
  3996. vec3.transformMat4(_topLeft, _topLeft, _worldMat);
  3997. vec3.transformMat4(_bottomRight, _bottomRight, _worldMat); // Convert to screen space
  3998. camera.worldToScreen(_topLeft, _topLeft, canvas_width, canvas_height);
  3999. camera.worldToScreen(_bottomRight, _bottomRight, canvas_width, canvas_height);
  4000. var finalWidth = _bottomRight.x - _topLeft.x;
  4001. var finalHeight = _topLeft.y - _bottomRight.y;
  4002. this._iframe.setFrame(_topLeft.x, canvas_height - _topLeft.y, finalWidth, finalHeight);
  4003. };
  4004. })();
  4005. },{}],45:[function(require,module,exports){
  4006. "use strict";
  4007. /****************************************************************************
  4008. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  4009. http://www.cocos.com
  4010. Permission is hereby granted, free of charge, to any person obtaining a copy
  4011. of this software and associated engine source code (the "Software"), a limited,
  4012. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4013. to use Cocos Creator solely to develop games on your target platforms. You shall
  4014. not use Cocos Creator software for developing other software or tools that's
  4015. used for developing games. You are not granted to publish, distribute,
  4016. sublicense, and/or sell copies of Cocos Creator.
  4017. The software or tools in this License Agreement are licensed, not sold.
  4018. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4019. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4020. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4021. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4022. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4023. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4024. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4025. THE SOFTWARE.
  4026. ****************************************************************************/
  4027. var nativeCameraProto = renderer.Camera.prototype;
  4028. var _setNode = nativeCameraProto.setNode;
  4029. cc.js.mixin(nativeCameraProto, {
  4030. setNode: function setNode(node) {
  4031. this._persistentNode = node;
  4032. _setNode.call(this, node);
  4033. }
  4034. });
  4035. },{}],46:[function(require,module,exports){
  4036. "use strict";
  4037. /****************************************************************************
  4038. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  4039. http://www.cocos.com
  4040. Permission is hereby granted, free of charge, to any person obtaining a copy
  4041. of this software and associated engine source code (the "Software"), a limited,
  4042. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4043. to use Cocos Creator solely to develop games on your target platforms. You shall
  4044. not use Cocos Creator software for developing other software or tools that's
  4045. used for developing games. You are not granted to publish, distribute,
  4046. sublicense, and/or sell copies of Cocos Creator.
  4047. The software or tools in this License Agreement are licensed, not sold.
  4048. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4049. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4050. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4051. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4052. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4053. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4054. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4055. THE SOFTWARE.
  4056. ****************************************************************************/
  4057. var nativeLightProto = renderer.Light.prototype;
  4058. var _setNode = nativeLightProto.setNode;
  4059. cc.js.mixin(nativeLightProto, {
  4060. setNode: function setNode(node) {
  4061. this._node = node;
  4062. _setNode.call(this, node);
  4063. }
  4064. });
  4065. },{}],47:[function(require,module,exports){
  4066. "use strict";
  4067. /****************************************************************************
  4068. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4069. https://www.cocos.com/
  4070. Permission is hereby granted, free of charge, to any person obtaining a copy
  4071. of this software and associated engine source code (the "Software"), a limited,
  4072. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4073. to use Cocos Creator solely to develop games on your target platforms. You shall
  4074. not use Cocos Creator software for developing other software or tools that's
  4075. used for developing games. You are not granted to publish, distribute,
  4076. sublicense, and/or sell copies of Cocos Creator.
  4077. The software or tools in this License Agreement are licensed, not sold.
  4078. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4079. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4080. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4081. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4082. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4083. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4084. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4085. THE SOFTWARE.
  4086. ****************************************************************************/
  4087. (function () {
  4088. if (!cc.MeshBuffer) return;
  4089. var MeshBuffer = cc.MeshBuffer.prototype;
  4090. MeshBuffer.init = function (batcher, vertexFormat) {
  4091. this.byteOffset = 0;
  4092. this.indiceOffset = 0;
  4093. this.vertexOffset = 0;
  4094. this._vertexFormat = vertexFormat;
  4095. this._vertexBytes = this._vertexFormat._bytes;
  4096. this._vDatas = [];
  4097. this._uintVDatas = [];
  4098. this._iDatas = [];
  4099. this._arrOffset = 0;
  4100. this._vData = null;
  4101. this._uintVData = null;
  4102. this._iData = null;
  4103. this._initVDataCount = 256 * vertexFormat._bytes; // actually 256 * 4 * (vertexFormat._bytes / 4)
  4104. this._initIDataCount = 256 * 6;
  4105. this._offsetInfo = {
  4106. byteOffset: 0,
  4107. vertexOffset: 0,
  4108. indiceOffset: 0
  4109. };
  4110. this._renderDataList = new renderer.RenderDataList();
  4111. this._reallocBuffer();
  4112. };
  4113. MeshBuffer.setNativeAssembler = function (assembler) {
  4114. if (assembler !== this._nativeAssembler) {
  4115. this._nativeAssembler = assembler;
  4116. assembler.setRenderDataList(this._renderDataList);
  4117. }
  4118. };
  4119. MeshBuffer._updateVIDatas = function () {
  4120. var offset = this._arrOffset;
  4121. this._vDatas[offset] = this._vData;
  4122. this._uintVDatas[offset] = this._uintVData;
  4123. this._iDatas[offset] = this._iData;
  4124. this._renderDataList.updateMesh(offset, this._vData, this._iData);
  4125. };
  4126. MeshBuffer.getNativeAssembler = function () {
  4127. return this._nativeAssembler;
  4128. };
  4129. MeshBuffer.getCurMeshIndex = function () {
  4130. return this._arrOffset;
  4131. };
  4132. MeshBuffer.uploadData = function () {};
  4133. MeshBuffer.switchBuffer = function () {
  4134. var offset = ++this._arrOffset;
  4135. this.byteOffset = 0;
  4136. this.vertexOffset = 0;
  4137. this.indiceOffset = 0;
  4138. if (offset < this._vDatas.length) {
  4139. this._vData = this._vDatas[offset];
  4140. this._uintVData = this._uintVDatas[offset];
  4141. this._iData = this._iDatas[offset];
  4142. } else {
  4143. this._reallocBuffer();
  4144. }
  4145. };
  4146. MeshBuffer.checkAndSwitchBuffer = function (vertexCount) {
  4147. if (this.vertexOffset + vertexCount > 65535) {
  4148. this.switchBuffer();
  4149. if (!this._nativeAssembler) return;
  4150. this._nativeAssembler.updateIADatas && this._nativeAssembler.updateIADatas(this._arrOffset, this._arrOffset);
  4151. }
  4152. };
  4153. MeshBuffer.used = function (vertexCount, indiceCount) {
  4154. if (!this._nativeAssembler) return;
  4155. this._nativeAssembler.updateVerticesRange(this._arrOffset, 0, vertexCount);
  4156. this._nativeAssembler.updateIndicesRange(this._arrOffset, 0, indiceCount);
  4157. };
  4158. MeshBuffer.request = function (vertexCount, indiceCount) {
  4159. this.requestStatic(vertexCount, indiceCount);
  4160. return this._offsetInfo;
  4161. };
  4162. MeshBuffer._reallocBuffer = function () {
  4163. this._reallocVData(true);
  4164. this._reallocIData(true);
  4165. this._updateVIDatas();
  4166. };
  4167. MeshBuffer._reallocVData = function (copyOldData) {
  4168. var oldVData;
  4169. if (this._vData) {
  4170. oldVData = new Uint8Array(this._vData.buffer);
  4171. }
  4172. this._vData = new Float32Array(this._initVDataCount);
  4173. this._uintVData = new Uint32Array(this._vData.buffer);
  4174. var newData = new Uint8Array(this._uintVData.buffer);
  4175. if (oldVData && copyOldData) {
  4176. for (var i = 0, l = oldVData.length; i < l; i++) {
  4177. newData[i] = oldVData[i];
  4178. }
  4179. }
  4180. };
  4181. MeshBuffer._reallocIData = function (copyOldData) {
  4182. var oldIData = this._iData;
  4183. this._iData = new Uint16Array(this._initIDataCount);
  4184. if (oldIData && copyOldData) {
  4185. var iData = this._iData;
  4186. for (var i = 0, l = oldIData.length; i < l; i++) {
  4187. iData[i] = oldIData[i];
  4188. }
  4189. }
  4190. };
  4191. MeshBuffer.reset = function () {
  4192. this._arrOffset = 0;
  4193. this._vData = this._vDatas[0];
  4194. this._uintVData = this._uintVDatas[0];
  4195. this._iData = this._iDatas[0];
  4196. this.byteOffset = 0;
  4197. this.indiceOffset = 0;
  4198. this.vertexOffset = 0;
  4199. if (!this._nativeAssembler) return;
  4200. for (var i = 0, len = this._vDatas.length; i < len; i++) {
  4201. this._nativeAssembler.updateVerticesRange(i, 0, 0);
  4202. this._nativeAssembler.updateIndicesRange(i, 0, 0);
  4203. }
  4204. };
  4205. MeshBuffer.destroy = function () {
  4206. this.reset();
  4207. };
  4208. })();
  4209. },{}],48:[function(require,module,exports){
  4210. "use strict";
  4211. /****************************************************************************
  4212. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  4213. http://www.cocos.com
  4214. Permission is hereby granted, free of charge, to any person obtaining a copy
  4215. of this software and associated engine source code (the "Software"), a limited,
  4216. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4217. to use Cocos Creator solely to develop games on your target platforms. You shall
  4218. not use Cocos Creator software for developing other software or tools that's
  4219. used for developing games. You are not granted to publish, distribute,
  4220. sublicense, and/or sell copies of Cocos Creator.
  4221. The software or tools in this License Agreement are licensed, not sold.
  4222. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4223. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4224. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4225. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4226. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4227. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4228. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4229. THE SOFTWARE.
  4230. ****************************************************************************/
  4231. var RenderFlow = cc.RenderFlow;
  4232. cc.js.mixin(renderer.NodeProxy.prototype, {
  4233. _ctor: function _ctor() {
  4234. this._owner = null;
  4235. },
  4236. init: function init(owner) {
  4237. this._owner = owner;
  4238. var spaceInfo = owner._spaceInfo;
  4239. this._owner._dirtyPtr = spaceInfo.dirty;
  4240. this._dirtyPtr = spaceInfo.dirty;
  4241. this._parentPtr = spaceInfo.parent;
  4242. this._zOrderPtr = spaceInfo.zOrder;
  4243. this._cullingMaskPtr = spaceInfo.cullingMask;
  4244. this._opacityPtr = spaceInfo.opacity;
  4245. this._is3DPtr = spaceInfo.is3D;
  4246. this._skewPtr = spaceInfo.skew;
  4247. this._isVisitingTraversal = false;
  4248. owner._proxy = this;
  4249. this.updateOpacity();
  4250. this.update3DNode();
  4251. this.updateZOrder();
  4252. this.updateCullingMask();
  4253. this.updateSkew();
  4254. owner.on(cc.Node.EventType.SIBLING_ORDER_CHANGED, this.updateZOrder, this);
  4255. },
  4256. initNative: function initNative() {
  4257. this.setName(this._owner._name);
  4258. this.updateParent();
  4259. this.updateOpacity();
  4260. this.update3DNode();
  4261. this.updateZOrder();
  4262. this.updateSkew();
  4263. this.updateCullingMask();
  4264. },
  4265. destroy: function destroy() {
  4266. this.destroyImmediately();
  4267. this._owner.off(cc.Node.EventType.SIBLING_ORDER_CHANGED, this.updateZOrder, this);
  4268. this._owner._proxy = null;
  4269. this._owner = null;
  4270. },
  4271. updateParent: function updateParent() {
  4272. var parent = this._owner._parent;
  4273. if (parent) {
  4274. var parentSpaceInfo = parent._spaceInfo;
  4275. this._parentPtr[0] = parentSpaceInfo.unitID;
  4276. this._parentPtr[1] = parentSpaceInfo.index;
  4277. var parentDirtyPtr = parentSpaceInfo.dirty;
  4278. parentDirtyPtr[0] |= RenderFlow.FLAG_REORDER_CHILDREN;
  4279. this._dirtyPtr[0] |= RenderFlow.FLAG_OPACITY;
  4280. } else {
  4281. this._parentPtr[0] = 0xffffffff;
  4282. this._parentPtr[1] = 0xffffffff;
  4283. }
  4284. this.notifyUpdateParent();
  4285. },
  4286. updateZOrder: function updateZOrder() {
  4287. this._zOrderPtr[0] = this._owner._localZOrder;
  4288. var parent = this._owner._parent;
  4289. if (parent && parent._proxy) {
  4290. parent._proxy._dirtyPtr[0] |= RenderFlow.FLAG_REORDER_CHILDREN;
  4291. }
  4292. },
  4293. updateCullingMask: function updateCullingMask() {
  4294. this._cullingMaskPtr[0] = this._owner._cullingMask;
  4295. },
  4296. updateOpacity: function updateOpacity() {
  4297. this._opacityPtr[0] = this._owner.opacity;
  4298. this._dirtyPtr[0] |= RenderFlow.FLAG_OPACITY;
  4299. },
  4300. update3DNode: function update3DNode() {
  4301. this._is3DPtr[0] = this._owner.is3DNode ? 0x1 : 0x0;
  4302. this._dirtyPtr[0] |= RenderFlow.FLAG_LOCAL_TRANSFORM;
  4303. },
  4304. updateSkew: function updateSkew() {
  4305. var skewPtr = this._skewPtr;
  4306. var owner = this._owner;
  4307. var skx = owner._skewX;
  4308. var sky = owner._skewY;
  4309. skewPtr[0] = skx;
  4310. skewPtr[1] = sky;
  4311. if (!this._isVisitingTraversal && (skx !== 0 || sky !== 0)) {
  4312. this.switchTraverseToVisit();
  4313. this._isVisitingTraversal = true;
  4314. }
  4315. }
  4316. });
  4317. },{}],49:[function(require,module,exports){
  4318. /****************************************************************************
  4319. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  4320. http://www.cocos.com
  4321. Permission is hereby granted, free of charge, to any person obtaining a copy
  4322. of this software and associated engine source code (the "Software"), a limited,
  4323. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4324. to use Cocos Creator solely to develop games on your target platforms. You shall
  4325. not use Cocos Creator software for developing other software or tools that's
  4326. used for developing games. You are not granted to publish, distribute,
  4327. sublicense, and/or sell copies of Cocos Creator.
  4328. The software or tools in this License Agreement are licensed, not sold.
  4329. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4330. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4331. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4332. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4333. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4334. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4335. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4336. THE SOFTWARE.
  4337. ****************************************************************************/
  4338. 'use strict';
  4339. var RenderFlow = cc.RenderFlow;
  4340. var LOCAL_TRANSFORM = RenderFlow.FLAG_LOCAL_TRANSFORM;
  4341. var COLOR = RenderFlow.FLAG_COLOR;
  4342. var UPDATE_RENDER_DATA = RenderFlow.FLAG_UPDATE_RENDER_DATA;
  4343. var POSITION_ON = 1 << 0;
  4344. cc.Node.prototype.setLocalDirty = function (flag) {
  4345. this._localMatDirty |= flag;
  4346. this._worldMatDirty = true;
  4347. this._dirtyPtr[0] |= RenderFlow.FLAG_TRANSFORM;
  4348. };
  4349. cc.js.getset(cc.Node.prototype, "_renderFlag", function () {
  4350. return this._dirtyPtr[0];
  4351. }, function (flag) {
  4352. this._dirtyPtr[0] = flag;
  4353. if (flag & UPDATE_RENDER_DATA || flag & COLOR) {
  4354. cc.RenderFlow.register(this);
  4355. }
  4356. });
  4357. cc.PrivateNode.prototype._posDirty = function (sendEvent) {
  4358. var parent = this.parent;
  4359. if (parent) {
  4360. // Position correction for transform calculation
  4361. this._trs[0] = this._originPos.x - (parent._anchorPoint.x - 0.5) * parent._contentSize.width;
  4362. this._trs[1] = this._originPos.y - (parent._anchorPoint.y - 0.5) * parent._contentSize.height;
  4363. }
  4364. this.setLocalDirty(cc.Node._LocalDirtyFlag.POSITION);
  4365. if (sendEvent === true && this._eventMask & POSITION_ON) {
  4366. this.emit(cc.Node.EventType.POSITION_CHANGED);
  4367. }
  4368. };
  4369. },{}],50:[function(require,module,exports){
  4370. "use strict";
  4371. /****************************************************************************
  4372. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4373. https://www.cocos.com/
  4374. Permission is hereby granted, free of charge, to any person obtaining a copy
  4375. of this software and associated engine source code (the "Software"), a limited,
  4376. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4377. to use Cocos Creator solely to develop games on your target platforms. You shall
  4378. not use Cocos Creator software for developing other software or tools that's
  4379. used for developing games. You are not granted to publish, distribute,
  4380. sublicense, and/or sell copies of Cocos Creator.
  4381. The software or tools in this License Agreement are licensed, not sold.
  4382. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4383. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4384. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4385. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4386. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4387. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4388. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4389. THE SOFTWARE.
  4390. ****************************************************************************/
  4391. (function () {
  4392. if (!cc.QuadBuffer) return;
  4393. var QuadBuffer = cc.QuadBuffer.prototype;
  4394. QuadBuffer._fillQuadBuffer = function () {
  4395. var count = this._initIDataCount / 6;
  4396. var buffer = this._iData;
  4397. for (var i = 0, idx = 0; i < count; i++) {
  4398. var vertextID = i * 4;
  4399. buffer[idx++] = vertextID;
  4400. buffer[idx++] = vertextID + 1;
  4401. buffer[idx++] = vertextID + 2;
  4402. buffer[idx++] = vertextID + 1;
  4403. buffer[idx++] = vertextID + 3;
  4404. buffer[idx++] = vertextID + 2;
  4405. }
  4406. };
  4407. QuadBuffer._reallocBuffer = function () {
  4408. this._reallocVData(true);
  4409. this._reallocIData();
  4410. this._fillQuadBuffer();
  4411. this._updateVIDatas();
  4412. };
  4413. QuadBuffer.uploadData = function () {};
  4414. QuadBuffer.switchBuffer = function () {
  4415. cc.MeshBuffer.prototype.switchBuffer.call(this);
  4416. };
  4417. })();
  4418. },{}],51:[function(require,module,exports){
  4419. "use strict";
  4420. var proto = cc.RenderData.prototype;
  4421. cc.RenderData.prototype.init = function (assembler) {
  4422. this._renderDataList = new renderer.RenderDataList();
  4423. assembler.setRenderDataList(this._renderDataList);
  4424. this._nativeAssembler = assembler;
  4425. };
  4426. var originClear = proto.clear;
  4427. proto.clear = function () {
  4428. originClear.call(this);
  4429. this._renderDataList.clear();
  4430. };
  4431. var originUpdateMesh = proto.updateMesh;
  4432. proto.updateMesh = function (meshIndex, vertices, indices) {
  4433. originUpdateMesh.call(this, meshIndex, vertices, indices);
  4434. if (vertices && indices) {
  4435. this._renderDataList.updateMesh(meshIndex, vertices, indices);
  4436. }
  4437. };
  4438. proto.updateMeshRange = function (verticesCount, indicesCount) {
  4439. this._nativeAssembler.updateVerticesRange(0, 0, verticesCount);
  4440. this._nativeAssembler.updateIndicesRange(0, 0, indicesCount);
  4441. };
  4442. },{}],52:[function(require,module,exports){
  4443. "use strict";
  4444. /****************************************************************************
  4445. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  4446. http://www.cocos.com
  4447. Permission is hereby granted, free of charge, to any person obtaining a copy
  4448. of this software and associated engine source code (the "Software"), a limited,
  4449. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4450. to use Cocos Creator solely to develop games on your target platforms. You shall
  4451. not use Cocos Creator software for developing other software or tools that's
  4452. used for developing games. You are not granted to publish, distribute,
  4453. sublicense, and/or sell copies of Cocos Creator.
  4454. The software or tools in this License Agreement are licensed, not sold.
  4455. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4456. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4457. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4458. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4459. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4460. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4461. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4462. THE SOFTWARE.
  4463. ****************************************************************************/
  4464. var RenderFlow = cc.RenderFlow;
  4465. RenderFlow.FLAG_REORDER_CHILDREN = 1 << 29;
  4466. RenderFlow.FLAG_WORLD_TRANSFORM_CHANGED = 1 << 30;
  4467. RenderFlow.FLAG_OPACITY_CHANGED = 1 << 31;
  4468. var _dirtyTargets = [];
  4469. var _dirtyWaiting = [];
  4470. var _rendering = false;
  4471. var director = cc.director;
  4472. RenderFlow.render = function (scene, dt) {
  4473. var camera = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4474. _rendering = true;
  4475. RenderFlow.validateRenderers();
  4476. for (var i = 0, l = _dirtyTargets.length; i < l; i++) {
  4477. var node = _dirtyTargets[i];
  4478. node._inJsbDirtyList = false;
  4479. var comp = node._renderComponent;
  4480. if (!comp) continue;
  4481. var assembler = comp._assembler;
  4482. if (!assembler) continue;
  4483. var flag = node._dirtyPtr[0];
  4484. if (flag & RenderFlow.FLAG_UPDATE_RENDER_DATA) {
  4485. node._dirtyPtr[0] &= ~RenderFlow.FLAG_UPDATE_RENDER_DATA;
  4486. assembler._updateRenderData && assembler._updateRenderData();
  4487. }
  4488. if (flag & RenderFlow.FLAG_COLOR) {
  4489. node._dirtyPtr[0] &= ~RenderFlow.FLAG_COLOR;
  4490. comp._updateColor && comp._updateColor();
  4491. }
  4492. }
  4493. _dirtyTargets.length = 0;
  4494. dt = dt || 0;
  4495. this._nativeFlow.render(scene._proxy, dt, camera);
  4496. _dirtyTargets = _dirtyWaiting.slice(0);
  4497. _dirtyWaiting.length = 0;
  4498. _rendering = false;
  4499. };
  4500. RenderFlow.renderCamera = function (camera, scene) {
  4501. RenderFlow.render(scene, 0, camera);
  4502. };
  4503. RenderFlow.init = function (nativeFlow) {
  4504. cc.EventTarget.call(this);
  4505. this._nativeFlow = nativeFlow;
  4506. };
  4507. RenderFlow.register = function (target) {
  4508. if (target._inJsbDirtyList) return;
  4509. if (_rendering) {
  4510. _dirtyWaiting.push(target);
  4511. } else {
  4512. _dirtyTargets.push(target);
  4513. }
  4514. target._inJsbDirtyList = true;
  4515. };
  4516. },{}]},{},[26]);